Ejemplo n.º 1
0
 public function rightsideAction()
 {
     $request = $this->getRequest();
     $limit = JO_Registry::get('front_limit');
     if ($request->getAction() == 'topic') {
         $this->view->add_link_head = $this->translate('Post a reply');
     } else {
         $this->view->add_link_head = $this->translate('Post new thread');
     }
     $help = Model_Pages::get(JO_Registry::forceGet('page_forum_rules'));
     if ($help) {
         $this->view->rules_link = WM_Router::create($request->getBaseUrl() . '?controller=pages&page_id=' . $help['id'] . '&name=' . WM_Router::clearName($help['name']));
     }
     if (JO_Session::get('user_id')) {
         $lnk = $request->getFullUrl();
         $lnk = explode('#', $lnk);
         $this->view->post_link = $lnk[0] . '#cform';
     } else {
         $this->view->post_link = WM_Router::create($request->getBaseUrl() . '?controller=users&action=login');
     }
     $threads = Model_Forum::getLastThreads();
     $this->view->threads = array();
     if ($threads) {
         foreach ($threads as $thread) {
             $thread['href'] = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=topic/' . $thread['id'] . '/' . WM_Router::clearName($thread['name']));
             if ($thread['lusername']) {
                 $thread['last_href'] = '';
                 $thread['datetime'] = WM_Date::format($thread['last_post'], 'dd M yy H:i');
                 $last_page = ceil($thread['cnt'] / $limit);
                 $thread['lasthref'] = $thread['href'] . ($last_page > 1 ? '/page/' . $last_page : '');
             }
             $this->view->threads[] = $thread;
         }
     }
     if (JO_Session::get('user_id')) {
         $rthreads = Model_Forum::getRecentThreads(JO_Session::get('user_id'));
         $this->view->recent_threads = array();
         if ($rthreads) {
             foreach ($rthreads as $rthread) {
                 $rthread['href'] = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=topic/' . $rthread['id'] . '/' . WM_Router::clearName($rthread['name']));
                 if ($rthread['lusername']) {
                     $rthread['last_href'] = '';
                     $rthread['datetime'] = WM_Date::format($rthread['last_post'], 'dd M yy H:i');
                     $last_page = ceil($rthread['cnt'] / $limit);
                     $rthread['lasthref'] = $rthread['href'] . ($last_page > 1 ? '/page/' . $last_page : '');
                 }
                 $this->view->recent_threads[] = $rthread;
             }
         }
     }
     $this->view->srch_link = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=search');
     $this->view->rss_link = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=rss');
 }