コード例 #1
0
ファイル: blog.php プロジェクト: anqh/anqh
 /**
  * Action: user's blog
  */
 public function action_user()
 {
     $user = Model_User::find_user(urldecode((string) $this->request->param('username')));
     if (!$user) {
         $this->request->redirect(Route::url('blogs'));
         return;
     }
     $blogs = Model_Blog_Entry::factory()->find_by_user($user);
     if ($months = $this->_build_months($blogs)) {
         // Default to last month
         $year = (int) $this->request->param('year');
         $month = (int) $this->request->param('month');
         if (!$year) {
             $year = max(array_keys($months));
             $month = max(array_keys($months[$year]));
         } else {
             if (!$month) {
                 $month = isset($months[$year]) ? min(array_keys($months[$year])) : 1;
             }
         }
         $year = min($year, date('Y'));
         $month = min(12, max(1, $month));
         // Build page
         $this->view = Controller_User::_set_page($user);
         $this->view->tab = 'blog';
         $this->view->add(View_Page::COLUMN_CENTER, '<h2>' . HTML::chars(date('F Y', mktime(null, null, null, $month, 1, $year))) . '</h2>');
         // Pagination
         $params = array('username' => urlencode($user->username));
         $this->view->add(View_Page::COLUMN_CENTER, $this->section_month_pagination($months, 'blog_user', $params, $year, $month));
         // Entries
         if (isset($months[$year]) && isset($months[$year][$month])) {
             foreach ($months[$year][$month] as $entry) {
                 $this->view->add(View_Page::COLUMN_CENTER, $this->section_entry($entry, true));
             }
         }
         // Month browser
         $this->view->add(View_Page::COLUMN_RIGHT, $this->section_month_browser($months, 'blog_user', $params, $year, $month));
     } else {
         // No entires found
         $this->view->add(View_Page::COLUMN_CENTER, new View_Alert(__('Alas, the quill seems to be dry, no blog entries found.'), null, View_Alert::INFO));
     }
 }
コード例 #2
0
ファイル: galleries.php プロジェクト: anqh/anqh
 /**
  * Action: photographer profile
  */
 public function action_profile()
 {
     $user = Model_User::find_user(urldecode((string) $this->request->param('username')));
     if (!$user) {
         $this->request->redirect(Route::url('galleries'));
         return;
     }
     // Build page
     $this->view = Controller_User::_set_page($user);
     $this->view->tab = 'galleries';
     // Galleries
     $galleries = Model_Gallery::factory()->find_by_user($user->id);
     $this->view->add(View_Page::COLUMN_CENTER, $this->section_galleries_thumbs($galleries, true, false));
     // Top images
     foreach (array(Model_Image::TOP_RATED, Model_Image::TOP_COMMENTED, Model_Image::TOP_VIEWED) as $type) {
         $section = $this->section_top($type, 6, $user->id, false);
         $section->aside = true;
         $this->view->add(View_Page::COLUMN_RIGHT, $section);
     }
 }
コード例 #3
0
ファイル: music.php プロジェクト: anqh/anqh
 /**
  * Action: Artist profile
  */
 public function action_profile()
 {
     $user = Model_User::find_user(urldecode((string) $this->request->param('username')));
     if (!$user) {
         $this->request->redirect(Route::url('charts'));
         return;
     }
     // Build page
     $this->view = Controller_User::_set_page($user);
     $this->view->tab = 'music';
     // Browse
     $tracks = Model_Music_Track::factory()->find_by_user($user->id, Model_Music_Track::TYPE_MIX, 0);
     if ($count = count($tracks)) {
         $this->view->add(View_Page::COLUMN_LEFT, $this->section_browse($tracks, __('Mixtapes') . ' <small>(' . $count . ')</small>'));
     }
     $tracks = Model_Music_Track::factory()->find_by_user($user->id, Model_Music_Track::TYPE_TRACK, 0);
     if ($count = count($tracks)) {
         $this->view->add(View_Page::COLUMN_RIGHT, $this->section_browse($tracks, __('Tracks') . ' <small>(' . $count . ')</small>'));
     }
 }