<commit_before><?php



/**
 * Skeleton subclass for representing a row from the 'sf_blog_post' table.
 *
 * 
 *
 * This class was autogenerated by Propel 1.5.5 on:
 *
 * Mon 27 Dec 2010 07:15:57 PM WIT
 *
 * You should add additional methods to this class to meet the
 * application requirements.  This class will only be generated as
 * long as it does not already exist in the output directory.
 *
 * @package    propel.generator.plugins.sfSimpleBlog15Plugin.lib.model.plugin
 */
class PluginsfSimpleBlogPost extends BasesfSimpleBlogPost {
  protected $previousPublishedAt = null;
  protected $previousIsPublished = false;
  
  public function  getExtract()
  {
    //search for <p><!-- pagebreak --></p>
    $v = $this->getContent();
    if (false === $pos = stripos($v, '<p><!-- pagebreak -->'))
    {
      $pos = stripos($v, '<!-- pagebreak -->');
    }
    if ($pos !== false)
    {
      return substr($v, 0, $pos-1);
    }
    return $v;
  }

  public function setIsPublished($v)
  {
    $this->previousIsPublished = $this->getIsPublished();
    return parent::setIsPublished($v);
  }
  public function setInternalPublishedAt($v)
  {
    parent::setInternalPublishedAt($v);
    return $this->setPublishedAt($v);
  }

  public function  setPublishedAt($v)
  {
    if (!$this->isNew()) $this->previousPublishedAt = $this->getPublishedAt(null);
    return parent::setPublishedAt($v);
  }
  
  public function getAuthor(PropelPDO $con = null)
  {
    return $this->getsfGuardUser($con);
  }

  public function getAuthorName()
  {
    return $this->getAuthor()->getProfile()->getFullName();
  }
  
  public function getAuthorEmail()
  {
    return $this->getAuthor()->getProfile()->getEmail();
  }

  public function getAuthorWebsite()
  {
    return $this->getAuthor()->getProfile()->getWebsite();
  }

  public function setAuthor(sfGuardUser $v = null)
  {
    return $this->setsfGuardUser($v);
  }

  public function allowComments()
  {
    if ($this->getAllowComments())
    {
      $validity = sfConfig::get('app_sfSimpleBlog_comment_disable_after', 0);
      if ($validity == 0 || $this->getPublishedSinceDays() < $validity)
      {
        return true;
      }
    }

    return false;
  }

  public function getPublishedSinceDays()
  {
    return round((time() - $this->getPublishedAt('U')) / (24 * 60 * 60));
  }

  public function setTagsFromString($v)
  {
    $this->addTag($v);
    return $this;
  }

  public function getTagsAsString()
  {
    $tags = $this->getTags();
    return implode($tags, ', ');
  }

  public function getCategoriesAsString()
  {
    $postCategories = $this->getsfSimpleBlogCategorys();
    $categories = array();
    foreach ($postCategories as $postCategory)
    {
      $categories[] = (string) $postCategory;
    }
    if ($categories) return implode($categories, ', ');
    return '';
  }

  public function getPreviousPost()
  {
    return sfSimpleBlogPostQuery::create()
        ->previousPublished($this->getInternalPublishedAt())
        ->findOne();
  }

  public function getNextPost()
  {
    return sfSimpleBlogPostQuery::create()
        ->nextPublished($this->getInternalPublishedAt())
        ->findOne();
  }

  /* RSS Feed*/
  public function getFeedUniqueId()
  {
    return 'article '.$this->getId().' at '.$_SERVER['HTTP_HOST'];
  }

  public function getFeedLink()
  {
    return sfSimpleBlogTools::generatePostUri($this);
  }

  public function preSave(PropelPDO $con = null)
  {
    if ($this->isNew() && $this->getIsPublished())
    {
      sfSimpleBlogArchivePeer::incrementCounter($this->getPublishedAt(), $con);
    }
    elseif (!$this->isNew())
    {
      if (!$this->getIsPublished())
      {
        if ($this->previousIsPublished)
        {
          //user unpublished an article
          sfSimpleBlogArchivePeer::decrementCounter($this->previousPublishedAt->format('Y-m-d'), $con);
        }
      }
      else
      {
        if (!$this->previousIsPublished)
        {
          //user published an article
          sfSimpleBlogArchivePeer::incrementCounter($this->getPublishedAt(), $con);
        }
        else
        {
          if (!($this->previousPublishedAt->format('n') == $this->getPublishedAt('n') && $this->previousPublishedAt->format('Y') == $this->getPublishedAt('Y')))<commit_msg>fixed bug when unpublished post<commit_after><?php



/**
 * Skeleton subclass for representing a row from the 'sf_blog_post' table.
 *
 * 
 *
 * This class was autogenerated by Propel 1.5.5 on:
 *
 * Mon 27 Dec 2010 07:15:57 PM WIT
 *
 * You should add additional methods to this class to meet the
 * application requirements.  This class will only be generated as
 * long as it does not already exist in the output directory.
 *
 * @package    propel.generator.plugins.sfSimpleBlog15Plugin.lib.model.plugin
 */
class PluginsfSimpleBlogPost extends BasesfSimpleBlogPost {
  protected $previousPublishedAt = null;
  protected $previousIsPublished = false;
  
  public function  getExtract()
  {
    //search for <p><!-- pagebreak --></p>
    $v = $this->getContent();
    if (false === $pos = stripos($v, '<p><!-- pagebreak -->'))
    {
      $pos = stripos($v, '<!-- pagebreak -->');
    }
    if ($pos !== false)
    {
      return substr($v, 0, $pos-1);
    }
    return $v;
  }

  public function setIsPublished($v)
  {
    $this->previousIsPublished = $this->getIsPublished();
    if (!$this->isNew()) {
      $this->previousPublishedAt = $this->getPublishedAt(null);
    }
    return parent::setIsPublished($v);
  }
  public function setInternalPublishedAt($v)
  {
    parent::setInternalPublishedAt($v);
    return $this->setPublishedAt($v);
  }

  public function  setPublishedAt($v)
  {
    return parent::setPublishedAt($v);
  }
  
  public function getAuthor(PropelPDO $con = null)
  {
    return $this->getsfGuardUser($con);
  }

  public function getAuthorName()
  {
    return $this->getAuthor()->getProfile()->getFullName();
  }
  
  public function getAuthorEmail()
  {
    return $this->getAuthor()->getProfile()->getEmail();
  }

  public function getAuthorWebsite()
  {
    return $this->getAuthor()->getProfile()->getWebsite();
  }

  public function setAuthor(sfGuardUser $v = null)
  {
    return $this->setsfGuardUser($v);
  }

  public function allowComments()
  {
    if ($this->getAllowComments())
    {
      $validity = sfConfig::get('app_sfSimpleBlog_comment_disable_after', 0);
      if ($validity == 0 || $this->getPublishedSinceDays() < $validity)
      {
        return true;
      }
    }

    return false;
  }

  public function getPublishedSinceDays()
  {
    return round((time() - $this->getPublishedAt('U')) / (24 * 60 * 60));
  }

  public function setTagsFromString($v)
  {
    $this->addTag($v);
    return $this;
  }

  public function getTagsAsString()
  {
    $tags = $this->getTags();
    return implode($tags, ', ');
  }

  public function getCategoriesAsString()
  {
    $postCategories = $this->getsfSimpleBlogCategorys();
    $categories = array();
    foreach ($postCategories as $postCategory)
    {
      $categories[] = (string) $postCategory;
    }
    if ($categories) return implode($categories, ', ');
    return '';
  }

  public function getPreviousPost()
  {
    return sfSimpleBlogPostQuery::create()
        ->previousPublished($this->getInternalPublishedAt())
        ->findOne();
  }

  public function getNextPost()
  {
    return sfSimpleBlogPostQuery::create()
        ->nextPublished($this->getInternalPublishedAt())
        ->findOne();
  }

  /* RSS Feed*/
  public function getFeedUniqueId()
  {
    return 'article '.$this->getId().' at '.$_SERVER['HTTP_HOST'];
  }

  public function getFeedLink()
  {
    return sfSimpleBlogTools::generatePostUri($this);
  }

  public function preSave(PropelPDO $con = null)
  {
    if ($this->isNew() && $this->getIsPublished()) {
      sfSimpleBlogArchivePeer::incrementCounter($this->getPublishedAt(), $con);
    }
    elseif (!$this->isNew())
    {
      if (!$this->getIsPublished())
      {
        if ($this->previousIsPublished)
        {
          //user unpublished an article
          sfSimpleBlogArchivePeer::decrementCounter($this->previousPublishedAt->format('Y-m-d'), $con);
        }
      }
      else
      {
        if (!$this->previousIsPublished)
        {
          //user published an article
          sfSimpleBlogArchivePeer::incrementCounter($this->getPublishedAt(), $con);
        }
        else
        {
          if (!($this->previousPublishedAt->format('n') == $this->getPublishedAt('n') && $this->previousPublishedAt->format('Y') == $this->getPublishedAt('Y')))
{'fraction_non_alphanumeric': 0.15151515151515152, 'fraction_numerical': 0.006293706293706294, 'mean_word_length': 3.061050638902035, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 109, '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': '7578716', 'n_tokens_mistral': 2784, 'n_tokens_neox': 2598, 'n_words': 547}