/**
  * extracts tags from the provided text and connects them to this question. If a tag is deleted it
  * will be deleted from the relation
  *
  * @return void
  * @author The Young Shepherd
  **/
 public function save(Doctrine_Connection $conn = null)
 {
     $currentTags = array();
     foreach ($this->Tags as $tag) {
         $currentTags[] = $tag->name;
     }
     $newTags = array_keys(Toolkit::extractTags($this->Best->question . ' ' . $this->Best->answer));
     $deleteTags = array_diff($currentTags, $newTags);
     foreach ($deleteTags as $name) {
         foreach ($this->Tags as $index => $tag) {
             if ($tag->name === $name) {
                 unset($this->Tags[$index]);
                 break;
                 // go to next name to delete
             }
         }
     }
     $addTags = array_diff($newTags, $currentTags);
     foreach ($addTags as $name) {
         if (!($tag = Doctrine::getTable('Tag')->findOneByName($name))) {
             $tag = new Tag();
             $tag->name = $name;
         }
         $this->Tags[] = $tag;
     }
     return parent::save($conn);
 }
Example #2
0
 public function setBody($v)
 {
     parent::setBody($v);
     require_once 'markdown.php';
     // strip all HTML tags
     $v = htmlentities($v, ENT_QUOTES, 'UTF-8');
     $this->setHtmlBody(markdown($v));
 }
Example #3
0
 public function save(Doctrine_Connection $conn = null) {
   $new = $this->isNew() ? true : false;
   
   $question = parent::save($conn);
   
   if ($new) {
     $traitement = new TraitementAgent();
     $traitement->setQuestion($this);
     $traitement->save();
   }    
   
   return $question;
 }
Example #4
0
 public function getPeer()
 {
     if (self::$peer === null) {
         self::$peer = new QuestionPeer();
     }
     return self::$peer;
 }
Example #5
0
 public function save($con = null)
 {
     $con = Propel::getConnection();
     try {
         $con->begin();
         $ret = parent::save();
         $this->updateSearchIndex();
         $con->commit();
         return $ret;
     } catch (Exception $e) {
         $con->rollback();
         throw $e;
     }
 }