Ejemplo n.º 1
0
 public function recents_for_userAction()
 {
     $request = $this->getRequest();
     $this->setViewChange('search');
     $username = $request->getRequest('recents_for_user');
     $username = trim(mb_strtolower(urldecode($username), 'UTF-8'));
     $this->view->crumbs = array(array('name' => $this->translate('Home'), 'href' => $request->getBaseUrl()), array('name' => $this->translate('Forum'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=forum')), array('name' => $username));
     $this->view->mainCategories = array();
     $this->view->mainCategories = Model_Forum::getAll();
     foreach ($this->view->mainCategories as $k => $v) {
         $this->view->mainCategories[$k]['href'] = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=thread/' . $this->view->mainCategories[$k]['id'] . '/' . WM_Router::clearName($this->view->mainCategories[$k]['name']));
     }
     $this->view->mainCategories = array_merge(array(0 => array('name' => $this->translate('All Topics'), 'href' => WM_Router::create($request->getBaseUrl() . '?controller=forum'))), $this->view->mainCategories);
     $this->view->headline = $this->translate('All Topics');
     $this->view->sel_thread = -1;
     $this->view->headline = $this->translate('Recent') . ': ' . $username;
     $threads = Model_Forum::getRecentByUser($username);
     $total_records = count($threads);
     if ($threads) {
         $model_images = new Model_Images();
         $page = (int) $request->getRequest('page', 1);
         if ($page < 1) {
             $page = 1;
         }
         $limit = JO_Registry::get('front_limit');
         $total_records = count($threads);
         $start = $page * $limit - $limit;
         if ($start > $total_records) {
             $page = max(ceil($total_records / $limit), 1);
             $start = $page * $limit - $limit;
         } elseif ($start < 0) {
             $start = 0;
         }
         $threads = array_slice($threads, $start, $limit);
         $bbcode_parser = new WM_BBCode_Parser();
         $bbcode_parser->loadDefaultCodes();
         foreach ($threads as $th) {
             if ($th['avatar']) {
                 $th['avatar'] = $model_images->resize($th['avatar'], JO_Registry::forceGet('user_avatar_width'), JO_Registry::forceGet('user_avatar_height'), true);
             } else {
                 $th['avatar'] = 'data/themes/images/noavatar.png';
             }
             $th['userhref'] = WM_Router::create($request->getBaseUrl() . '?controller=users&action=index&username='******'username']));
             $th_link = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=topic/' . $th['id'] . '/' . WM_Router::clearName($th['name']));
             $th['threadhref'] = $thread_link;
             $th['reporthref'] = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=report/' . $th['id']);
             $th['recent_link'] = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=recents_for_user&username='******'username']));
             $th['threads_user_link'] = WM_Router::create($request->getBaseUrl() . '?controller=forum&action=threads_for_user&username='******'username']));
             $bbcode_parser->parse($th['comment']);
             $th['comment_formated'] = Model_Comments::replaceEmoticons($bbcode_parser->getAsHtml());
             $last_page = ceil($thread['cnt'] / $limit);
             $th['datetime'] = WM_Date::format($th['datetime'], 'dd M yy H:i');
             $th['badges'] = Helper_Author::userBadges($th['badges']);
             $this->view->threads[] = $th;
         }
         $pagination = new Model_Pagination();
         $pagination->setLimit($limit);
         $pagination->setPage($page);
         $pagination->setText(array('text_prev' => $this->view->translate('Prev'), 'text_next' => $this->view->translate('Next')));
         $pagination->setTotal($total_records);
         $pagination->setUrl(WM_Router::create($request->getBaseUrl() . '?controller=forum&action=index&page={page}'));
         $this->view->pagination = $pagination->render();
         if (!empty($this->view->pagination)) {
             $this->view->pagination = str_replace('{of}', $this->view->translate('OF'), $this->view->pagination);
         }
     }
     $this->view->children = array();
     $this->view->children['rightside'] = 'forum/rightside';
     $this->view->children['header_part'] = 'layout/header_part';
     $this->view->children['footer_part'] = 'layout/footer_part';
 }