<commit_before><?php
/**
 * This class has been auto-generated by the Doctrine ORM Framework
 */
class PluginContentTable extends Doctrine_Table
{
  public function getTypeQuery($typeName)
  {
    $table = Doctrine::getTable($typeName);

    if (method_exists($table, 'getContentQuery'))
    {
      $q = $table->getContentQuery();
    } else {
      $q = $this->getBaseQuery();

      if (sfConfig::get('sf_logging_enabled'))
      {
        sfContext::getInstance()->getLogger()->notice('To improve performance you should have a callable method named "getContentQuery()" on your table class that efficiently selects all the required data for your content type with joins and specific selects.');
      }
    }

    $q->innerJoin('c.'.$typeName.' cr');

    if (sfSympalConfig::isI18nEnabled($typeName))
    {
      $q->leftJoin('cr.Translation crt');
    }

    $q = sfProjectConfiguration::getActive()->getEventDispatcher()->filter(new sfEvent($this, 'sympal.load_'.sfInflector::tableize($typeName).'_query'), $q)->getReturnValue();

    return $q;
  }

  public function getContent($params = array())
  {
    $request = sfContext::getInstance()->getRequest();
    $contentType = $request->getParameter('sympal_content_type');
    $contentId = $request->getParameter('sympal_content_id');
    $contentSlug = $request->getParameter('sympal_content_slug');
    $q = $this->getTypeQuery($contentType);

    if ($contentId)
    {
      $q->andWhere('c.id = ?', $contentId);
    } else if ($contentSlug) {
      if ($this->hasRelation('Translation') && $this->getRelation('Translation')->getTable()->hasField('slug'))
      {
        $q->andWhere('c.slug = ? OR ct.i18n_slug = ?', array($contentSlug, $contentSlug));
      } else {
        $q->andWhere('c.slug = ?', $contentSlug);
      }
    }

    foreach ($params as $key => $value)
    {
      if ($key == 'slug' && $this->hasRelation('Translation'))
      {
        $q->andWhere('c.slug = ? OR ct.i18n_slug = ?', array($value, $value));
        continue;
      }

      if ($this->hasField($key))
      {
        $q->andWhere('c.'.$key.' = ?', $value);
      } else if ($this->hasRelation('Translation')) {
        if ($this->getRelation('Translation')->getTable()->hasField($key))
        {
          $q->andWhere('ct.'.$key, $value);
        }
      } else if ($this->getRelation($contentType)->getTable()->hasField($key)) {
        $q->andWhere('cr.'.$key.' = ?', $value);
      }
    }

    $q = sfProjectConfiguration::getActive()->getEventDispatcher()->filter(new sfEvent($this, 'sympal.filter_get_content_query'), $q)->getReturnValue();

    $content = $q->fetchOne();

    $content = sfProjectConfiguration::getActive()->getEventDispatcher()->filter(new sfEvent($this, 'sympal.filter_get_content'), $content)->getReturnValue();

    return $content;
  }

  public function getBaseQuery()
  {
    $sympalContext = sfSympalContext::getInstance();
    $q = Doctrine_Query::create()
      ->from('Content c')
      ->leftJoin('c.Permissions p')
      ->leftJoin('c.Groups g')
      ->leftJoin('c.Slots sl')
      ->leftJoin('sl.Type sty')
      ->leftJoin('c.Type ty')
      ->leftJoin('ty.ContentTemplates t')
      ->leftJoin('c.MasterMenuItem m')
      ->leftJoin('c.MenuItem mm')
      ->leftJoin('c.CreatedBy u')
      ->innerJoin('c.Site csi WITH csi.slug = ?', $sympalContext->getSite());

    if (!sfSympalToolkit::isEditMode())
    {
      $expr = new Doctrine_Expression('NOW()');
      $q->andWhere('c.is_published = 1')
        ->andWhere('c.date_published < '.$expr);
    }

    if (sfSympalConfig::isI18nEnabled('ContentSlot'))
    {
      $q->leftJoin('sl.Translation slt');
    }

    if (sfSympalConfig::isI18nEnabled('Content'))
    {
      $q->leftJoin('c.Translation ct');
    }

    $q = sfProjectConfiguration::getActive()->getEventDispatcher()->filter(new sfEvent($this, 'sympal.filter_content_base_query'), $q)->getReturnValue();

    return $q;
  }
}<commit_msg>[1.0] sfSympalPlugin: adding missing join for content template<commit_after><?php
/**
 * This class has been auto-generated by the Doctrine ORM Framework
 */
class PluginContentTable extends Doctrine_Table
{
  public function getTypeQuery($typeName)
  {
    $table = Doctrine::getTable($typeName);

    if (method_exists($table, 'getContentQuery'))
    {
      $q = $table->getContentQuery();
    } else {
      $q = $this->getBaseQuery();

      if (sfConfig::get('sf_logging_enabled'))
      {
        sfContext::getInstance()->getLogger()->notice('To improve performance you should have a callable method named "getContentQuery()" on your table class that efficiently selects all the required data for your content type with joins and specific selects.');
      }
    }

    $q->innerJoin('c.'.$typeName.' cr');

    if (sfSympalConfig::isI18nEnabled($typeName))
    {
      $q->leftJoin('cr.Translation crt');
    }

    $q = sfProjectConfiguration::getActive()->getEventDispatcher()->filter(new sfEvent($this, 'sympal.load_'.sfInflector::tableize($typeName).'_query'), $q)->getReturnValue();

    return $q;
  }

  public function getContent($params = array())
  {
    $request = sfContext::getInstance()->getRequest();
    $contentType = $request->getParameter('sympal_content_type');
    $contentId = $request->getParameter('sympal_content_id');
    $contentSlug = $request->getParameter('sympal_content_slug');
    $q = $this->getTypeQuery($contentType);

    if ($contentId)
    {
      $q->andWhere('c.id = ?', $contentId);
    } else if ($contentSlug) {
      if ($this->hasRelation('Translation') && $this->getRelation('Translation')->getTable()->hasField('slug'))
      {
        $q->andWhere('c.slug = ? OR ct.i18n_slug = ?', array($contentSlug, $contentSlug));
      } else {
        $q->andWhere('c.slug = ?', $contentSlug);
      }
    }

    foreach ($params as $key => $value)
    {
      if ($key == 'slug' && $this->hasRelation('Translation'))
      {
        $q->andWhere('c.slug = ? OR ct.i18n_slug = ?', array($value, $value));
        continue;
      }

      if ($this->hasField($key))
      {
        $q->andWhere('c.'.$key.' = ?', $value);
      } else if ($this->hasRelation('Translation')) {
        if ($this->getRelation('Translation')->getTable()->hasField($key))
        {
          $q->andWhere('ct.'.$key, $value);
        }
      } else if ($this->getRelation($contentType)->getTable()->hasField($key)) {
        $q->andWhere('cr.'.$key.' = ?', $value);
      }
    }

    $q = sfProjectConfiguration::getActive()->getEventDispatcher()->filter(new sfEvent($this, 'sympal.filter_get_content_query'), $q)->getReturnValue();

    $content = $q->fetchOne();

    $content = sfProjectConfiguration::getActive()->getEventDispatcher()->filter(new sfEvent($this, 'sympal.filter_get_content'), $content)->getReturnValue();

    return $content;
  }

  public function getBaseQuery()
  {
    $sympalContext = sfSympalContext::getInstance();
    $q = Doctrine_Query::create()
      ->from('Content c')
      ->leftJoin('c.Permissions p')
      ->leftJoin('c.Groups g')
      ->leftJoin('c.Template cte')
      ->leftJoin('c.Slots sl')
      ->leftJoin('sl.Type sty')
      ->leftJoin('c.Type ty')
      ->leftJoin('ty.ContentTemplates t')
      ->leftJoin('c.MasterMenuItem m')
      ->leftJoin('c.MenuItem mm')
      ->leftJoin('c.CreatedBy u')
      ->innerJoin('c.Site csi WITH csi.slug = ?', $sympalContext->getSite());

    if (!sfSympalToolkit::isEditMode())
    {
      $expr = new Doctrine_Expression('NOW()');
      $q->andWhere('c.is_published = 1')
        ->andWhere('c.date_published < '.$expr);
    }

    if (sfSympalConfig::isI18nEnabled('ContentSlot'))
    {
      $q->leftJoin('sl.Translation slt');
    }

    if (sfSympalConfig::isI18nEnabled('Content'))
    {
      $q->leftJoin('c.Translation ct');
    }

    $q = sfProjectConfiguration::getActive()->getEventDispatcher()->filter(new sfEvent($this, 'sympal.filter_content_base_query'), $q)->getReturnValue();

    return $q;
  }
}
{'fraction_non_alphanumeric': 0.1854778028592927, 'fraction_numerical': 0.0030097817908201654, 'mean_word_length': 3.393939393939394, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 126, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5620968', 'n_tokens_mistral': 2562, 'n_tokens_neox': 2507, 'n_words': 423}