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 VideoTag(); $tag->name = $name; $tag->frequency = 1; $tag->save(); } } }
protected function renderContent() { $tags = VideoTag::model()->findTagWeights($this->maxTags); foreach ($tags as $tag => $weight) { $link = CHtml::link(CHtml::encode($tag), array('video/tag', 'tag' => $tag)); echo CHtml::tag('span', array('class' => 'tag', 'style' => "font-size:" . ($weight + 3) . "pt"), $link) . "\n"; } }
public function tag($tag) { $page = Input::get('page'); if (!empty($page)) { $page = Input::get('page'); } else { $page = 1; } if (!isset($tag)) { return Redirect::to('videos'); } $tag_name = $tag; $tag = Tag::where('name', '=', $tag)->first(); $tags = VideoTag::where('tag_id', '=', $tag->id)->get(); $tag_array = array(); foreach ($tags as $key => $tag) { array_push($tag_array, $tag->video_id); } $videos = Video::where('active', '=', '1')->whereIn('id', $tag_array)->paginate($this->videos_per_page); $data = array('videos' => $videos, 'current_page' => $page, 'page_title' => 'Videos tagged with "' . $tag_name . '"', 'page_description' => 'Page ' . $page, 'menu' => Menu::orderBy('order', 'ASC')->get(), 'pagination_url' => '/videos/tags/' . $tag_name, 'video_categories' => VideoCategory::all(), 'post_categories' => PostCategory::all(), 'theme_settings' => ThemeHelper::getThemeSettings(), 'pages' => Page::all()); return View::make('Theme::video-list', $data); }
/** * This is invoked after the record is deleted. */ protected function afterDelete() { parent::afterDelete(); //Comment::model()->deleteAll('post_id='.$this->id); VideoTag::model()->updateFrequency($this->tags, ''); }
/** * 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 = VideoTag::model()->suggestTags($keyword); if ($tags !== array()) { echo implode("\n", $tags); } } }