コード例 #1
0
ファイル: VideoTag.php プロジェクト: ngdvan/lntguitar
 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();
         }
     }
 }
コード例 #2
0
ファイル: VideoTagCloud.php プロジェクト: ngdvan/lntguitar
 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";
     }
 }
コード例 #3
0
 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);
 }
コード例 #4
0
ファイル: Video.php プロジェクト: ngdvan/lntguitar
 /**
  * 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, '');
 }
コード例 #5
0
ファイル: VideoController.php プロジェクト: ngdvan/lntguitar
 /**
  * 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);
         }
     }
 }