Exemplo n.º 1
0
 /**
  * Get module contents
  *
  * @return  void
  */
 public function run()
 {
     require_once Component::path('com_poll') . DS . 'models' . DS . 'poll.php';
     // Load the latest poll
     $this->poll = Poll::current();
     require $this->getLayoutPath();
 }
Exemplo n.º 2
0
 /**
  * Display module content
  *
  * @return  void
  */
 public function display()
 {
     require_once \Component::path('com_poll') . DS . 'models' . DS . 'poll.php';
     $menu = \App::get('menu');
     $items = $menu->getItems('link', 'index.php?option=com_poll&view=poll');
     $itemid = isset($items[0]) ? '&Itemid=' . $items[0]->id : '';
     if ($id = $this->params->get('id', 0)) {
         $poll = \Components\Poll\Models\Poll::oneOrNew($id);
     } else {
         $poll = \Components\Poll\Models\Poll::current();
     }
     if ($poll && $poll->id) {
         require $this->getLayoutPath();
     }
 }
Exemplo n.º 3
0
 /**
  * Method to show the latest poll
  *
  * @return  void
  */
 public function latestTask()
 {
     $poll = Poll::current();
     // if id value is passed and poll not published then exit
     if ($poll->get('id') && $poll->get('state') != 1) {
         App::abort(403, Lang::txt('JGLOBAL_AUTH_ACCESS_DENIED'));
     }
     $options = $poll->options()->where('text', '!=', '')->order('hits', 'desc')->ordered()->rows();
     // Adds parameter handling
     $params = App::get('menu.params');
     //Set page title information
     $menus = App::get('menu');
     $menu = $menus->getActive();
     // because the application sets a default page title, we need to get it
     // right from the menu item itself
     if (is_object($menu)) {
         $menu_params = new \Hubzero\Config\Registry($menu->params);
         if (!$menu_params->get('page_title')) {
             $params->set('page_title', $poll->get('title'));
         }
     } else {
         $params->set('page_title', $poll->get('title'));
     }
     Document::setTitle($params->get('page_title'));
     //Set pathway information
     Pathway::append(Lang::txt('COM_POLL'), Route::url('index.php?option=' . $this->_option));
     Pathway::append($poll->get('title'), Route::url('index.php?option=' . $this->_option . '&id=' . $poll->get('id') . ':' . $poll->get('alias')));
     $params->def('show_page_title', 1);
     $params->def('page_title', $poll->get('title'));
     $this->view->set('options', $options)->set('params', $params)->set('poll', $poll)->display();
 }