Ejemplo n.º 1
0
 public function callElement()
 {
     // get request vars
     $element = YRequest::getCmd('element', '');
     $method = YRequest::getCmd('method', '');
     $args = YRequest::getVar('args', array(), 'default', 'array');
     $item_id = (int) YRequest::getInt('item_id', 0);
     JArrayHelper::toString($args);
     // get item
     $item = YTable::getInstance('item')->get($item_id);
     // raise warning when item can not be accessed
     if (empty($item->id) || !$item->canAccess($this->user)) {
         JError::raiseError(500, JText::_('Unable to access item'));
         return;
     }
     // raise warning when item is not published
     $nulldate = JFactory::getDBO()->getNullDate();
     $date = JFactory::getDate()->toUnix();
     $publish_up = JFactory::getDate($item->publish_up);
     $publish_down = JFactory::getDate($item->publish_down);
     if ($item->state != 1 || !(($item->publish_up == $nulldate || $publish_up->toUnix() <= $date) && ($item->publish_down == $nulldate || $publish_down->toUnix() >= $date))) {
         JError::raiseError(404, JText::_('Item not published'));
         return;
     }
     // get element and execute callback method
     if ($element = $item->getElement($element)) {
         $element->callback($method, $args);
     }
 }
Ejemplo n.º 2
0
 public function __construct($default = array())
 {
     parent::__construct($default);
     // init vars
     $this->joomla = JFactory::getApplication();
     $this->user = JFactory::getUser();
     $this->session = JFactory::getSession();
     $this->document = JFactory::getDocument();
     $this->dispatcher = JDispatcher::getInstance();
     $this->option = YRequest::getCmd('option');
     $this->link_base = 'index.php?option=' . $this->option;
     $this->controller = $this->getName();
     // add super administrator var to user
     $this->user->superadmin = UserHelper::isJoomlaSuperAdmin($this->user);
     // init additional admin vars
     if ($this->joomla->isAdmin()) {
         $this->baseurl = 'index.php?option=' . $this->option . '&controller=' . $this->getName();
     }
     // init additional site vars
     if ($this->joomla->isSite()) {
         $this->itemid = (int) $GLOBALS['Itemid'];
         $this->params = $this->joomla->getParams();
         $this->pathway = $this->joomla->getPathway();
     }
 }
Ejemplo n.º 3
0
 public function getApplicationParams()
 {
     // init vars
     $template = YRequest::getCmd('template');
     $this->params = $this->application->getParams();
     // set template
     $this->params->set('template', $template);
     // display view
     $this->getView()->setLayout('_applicationparams')->display();
 }
Ejemplo n.º 4
0
 public function getItemRoute($item)
 {
     YTable::getInstance('application')->get($item->application_id)->getCategoryTree(true);
     // have we found the link before?
     if (isset(self::$_item_links[$item->id])) {
         return self::$_item_links[$item->id];
     }
     // init vars
     $categories = $item->getRelatedCategoryIds(true);
     $categories = array_filter($categories, create_function('$id', 'return !empty($id);'));
     // build item link
     $link = RouteHelper::LINK_BASE . '&task=item&item_id=' . $item->id;
     // Priority 1: direct link to item
     $itemid = null;
     if ($menu_item = self::_findItem($item->id)) {
         $itemid = $menu_item->id;
     }
     // are we in category view?
     $category_id = null;
     if (!$itemid && (YRequest::getCmd('task') == 'category' || YRequest::getCmd('view') == 'category')) {
         $category_id = (int) YRequest::getInt('category_id', JFactory::getApplication()->getParams()->get('category'));
         $category_id = in_array($category_id, $categories) ? $category_id : null;
     }
     if (!$itemid && !$category_id) {
         $primary = $item->getPrimaryCategory();
         // Priority 2: direct link to primary category
         if ($primary && ($menu_item = self::_findCategory($primary->id))) {
             $itemid = $menu_item->id;
             // Priority 3: find in primary category path
         } else {
             if ($primary && ($menu_item = self::_findInCategoryPath($primary))) {
                 $itemid = $menu_item->id;
             } else {
                 $found = false;
                 foreach ($categories as $category) {
                     // Priority 4: direct link to any related category
                     if ($menu_item = self::_findCategory($category)) {
                         $itemid = $menu_item->id;
                         $found = true;
                         break;
                     }
                 }
                 if (!$found) {
                     $categories = $item->getRelatedCategories(true);
                     foreach ($categories as $category) {
                         // Priority 5: find in any related categorys path
                         if ($menu_item = self::_findInCategoryPath($category)) {
                             $itemid = $menu_item->id;
                             $found = true;
                             break;
                         }
                     }
                 }
                 // Priority 6: link to frontpage
                 if (!$found && ($menu_item = self::_findFrontpage($item->application_id))) {
                     $itemid = $menu_item->id;
                 }
             }
         }
     }
     if ($category_id) {
         $link .= '&category_id=' . $category_id;
     }
     if ($itemid) {
         $link .= '&Itemid=' . $itemid;
         // Priority 7: current item id
     } else {
         if ($menu = JSite::getMenu()->getActive()) {
             $link .= '&Itemid=' . $menu->id;
         }
     }
     // store link for future lookups
     self::$_item_links[$item->id] = $link;
     return $link;
 }
Ejemplo n.º 5
0
 public function callElement()
 {
     // get request vars
     $element_identifier = YRequest::getString('elm_id', '');
     $item_id = YRequest::getInt('item_id', 0);
     $type = YRequest::getString('type', '');
     $this->method = YRequest::getCmd('method', '');
     $this->args = YRequest::getVar('args', array(), 'default', 'array');
     JArrayHelper::toString($this->args);
     // load element
     if ($item_id) {
         $item = YTable::getInstance('item')->get($item_id);
     } elseif (!empty($type)) {
         $item = new Item();
         $item->application_id = $this->application->id;
         $item->type = $type;
     }
     // execute callback method
     if ($element = $item->getElement($element_identifier)) {
         echo $element->callback($this->method, $this->args);
     }
 }
Ejemplo n.º 6
0
 public function dispatch()
 {
     // get joomla and application table
     $joomla = JFactory::getApplication();
     // load site language
     if ($joomla->isSite()) {
         JFactory::getLanguage()->load('com_zoo', $this->getPath(), null, true);
     }
     // get request vars
     $task = YRequest::getCmd('task');
     $ctrl = YRequest::getWord('controller', 'default');
     // perform the request task
     $controller = $this->getController($ctrl);
     $controller->execute($task);
     $controller->redirect();
 }