Beispiel #1
0
 protected function renderContent()
 {
     $tags = Blogtag::model()->findTagWeights($this->maxTags);
     foreach ($tags as $tag => $weight) {
         $link = CHtml::link(CHtml::encode($tag), array('blogpost/index', 'tag' => $tag));
         echo CHtml::tag('span', array('class' => 'tag', 'style' => "font-size:{$weight}pt"), $link) . "\n";
     }
 }
Beispiel #2
0
 /**
  * Suggests tags based on the current user input.
  * This is called via AJAX when the user is entering the tags input.
  */
 public function actionSuggestTags()
 {
     if (isset($_GET['q']) && ($keyword = trim($_GET['q'])) !== '') {
         $tags = Blogtag::model()->suggestTags($keyword);
         if ($tags !== array()) {
             echo implode("\n", $tags);
         }
     }
 }
Beispiel #3
0
 public function addTags($tags)
 {
     $criteria = new CDbCriteria();
     $criteria->addInCondition('name', $tags);
     $this->updateCounters(array('frequency' => 1), $criteria);
     foreach ($tags as $name) {
         if (!$this->exists('name=:name', array(':name' => $name))) {
             $tag = new Blogtag();
             $tag->name = $name;
             $tag->frequency = 1;
             $tag->save();
         }
     }
 }
Beispiel #4
0
 /**
  * This is invoked after the record is deleted.
  */
 protected function afterDelete()
 {
     parent::afterDelete();
     Blogomment::model()->deleteAll('post_id=' . $this->id);
     Blogtag::model()->updateFrequency($this->tags, '');
 }