Example #1
0
 private function admin()
 {
     $today = strtotime('today');
     $month = strtotime('first day of this month');
     $last30 = strtotime('-30 days');
     // Users statistics
     $users['today'] = number_format(User::whereGt('reg_date', $today)->count());
     $users['month'] = number_format(User::whereGt('reg_date', $month)->count());
     $users['last30'] = number_format(User::whereGt('reg_date', $last30)->count());
     $users['total'] = number_format(User::count());
     View::set('users', $users);
     // Playlists statistics
     $playlists['today'] = number_format(Playlist::whereGt('date', $today)->count());
     $playlists['month'] = number_format(Playlist::whereGt('date', $month)->count());
     $playlists['last30'] = number_format(Playlist::whereGt('date', $last30)->count());
     $playlists['total'] = number_format(Playlist::count());
     View::set('playlists', $playlists);
     // Tracks statistics
     $tracks = number_format(Track::count());
     View::set('tracks', $tracks);
     // Tags statistics
     $tags = number_format(Tag::count());
     View::set('tags', $tags);
     // Comments statistics
     $comments = number_format(Comment::count());
     View::set('comments', $comments);
     // Likes
     $likes = number_format(PlaylistLike::count());
     View::set('likes', $likes);
     // Reports
     $reports = number_format(Report::count());
     View::set('reports', $reports);
     View::show('admin/admin');
 }
Example #2
0
 public function run()
 {
     $model = new Tag();
     //条件
     $criteria = new CDbCriteria();
     $tag_name = trim(Yii::app()->request->getParam('tag_name'));
     $tag_name && $criteria->addSearchCondition('tag_name', $tag_name);
     $criteria->order = 't.id ASC';
     $count = $model->count($criteria);
     //分页
     $pages = new CPagination($count);
     $pages->pageSize = 20;
     $pages->applyLimit($criteria);
     //查询
     $result = $model->findAll($criteria);
     $this->controller->render('index', array('model' => $model, 'datalist' => $result, 'pagebar' => $pages));
 }
Example #3
0
 /**
  * 标签管理
  *
  */
 public function actionIndex()
 {
     $model = new Tag();
     $criteria = new CDbCriteria();
     $condition = '1';
     $tagName = $this->_request->getParam('tagName');
     $tagName && ($condition .= ' AND tag_name LIKE \'%' . $tagName . '%\'');
     $criteria->condition = $condition;
     $criteria->order = 't.id DESC';
     $count = $model->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 13;
     $pageParams = $this->buildCondition($_GET, array('tagName'));
     $pages->params = is_array($pageParams) ? $pageParams : array();
     $criteria->limit = $pages->pageSize;
     $criteria->offset = $pages->currentPage * $pages->pageSize;
     $result = $model->findAll($criteria);
     $this->render('index', array('datalist' => $result, 'pagebar' => $pages));
 }
Example #4
0
 /**
  * Show general application stats
  * /administration
  *
  * @return View
  */
 public function get_index()
 {
     $issues = Project\Issue::count_issues();
     return $this->layout->with('active', 'dashboard')->nest('content', 'administration.index', array('users' => User::where('deleted', '=', 0)->count(), 'active_projects' => Project::where('status', '=', 1)->count(), 'archived_projects' => Project::where('status', '=', 0)->count(), 'issues' => $issues, 'tags' => Tag::count()));
 }
Example #5
0
 /**
  * tags
  *
  * This returns tags to the user, in a pretty xml document with the information
  *
  * @param    array    $tags    (description here...)
  * @return    string    return xml
  */
 public static function tags($tags)
 {
     if (count($tags) > self::$limit or self::$offset > 0) {
         $tags = array_splice($tags, self::$offset, self::$limit);
     }
     $string = '';
     foreach ($tags as $tag_id) {
         $tag = new Tag($tag_id);
         $counts = $tag->count();
         $string .= "<tag id=\"{$tag_id}\">\n" . "\t<name><![CDATA[{$tag->name}]]></name>\n" . "\t<albums>" . intval($counts['album']) . "</albums>\n" . "\t<artists>" . intval($counts['artist']) . "</artists>\n" . "\t<songs>" . intval($counts['song']) . "</songs>\n" . "\t<videos>" . intval($counts['video']) . "</videos>\n" . "\t<playlists>" . intval($counts['playlist']) . "</playlists>\n" . "\t<stream>" . intval($counts['live_stream']) . "</stream>\n" . "</tag>\n";
     }
     // end foreach
     $final = self::_header() . $string . self::_footer();
     return $final;
 }
Example #6
0
 public function run()
 {
     if (Tag::count() == 0) {
         $this->generate();
     }
 }
 public static function addGenres($xml, $tags)
 {
     $xgenres = $xml->addChild('genres');
     foreach ($tags as $tag) {
         $otag = new Tag($tag['id']);
         $xgenre = $xgenres->addChild('genre', htmlspecialchars($otag->name));
         $counts = $otag->count('', $GLOBALS['user']->id);
         $xgenre->addAttribute("songCount", $counts['song']);
         $xgenre->addAttribute("albumCount", $counts['album']);
     }
 }