Exemplo n.º 1
0
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise a Error object.
  */
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $state = $this->get('State');
     $params = $state->params;
     $items = $this->get('Items');
     $pagination = $this->get('Pagination');
     $dispatcher = JEventDispatcher::getInstance();
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     // PREPARE THE DATA
     if ($app->input->getString('layout', 'default') != 'blog') {
     }
     // Compute the selectie slugs and set the trigger events.
     foreach ($items as $i => &$item) {
         // Add router helpers.
         $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
         //
         // Process the knvbapi2 plugins.
         //
         JPluginHelper::importPlugin('knvbapi2');
         $dispatcher->trigger('onSelectiePrepare', array('com_knvbapi2.selectie', &$item, &$item->params, $i));
         $item->event = new stdClass();
         $results = $dispatcher->trigger('onSelectieAfterName', array('com_knvbapi2.selectie', &$item, &$item->params, $i));
         $item->event->afterDisplaySelectieName = JString::trim(implode("\n", $results));
         $results = $dispatcher->trigger('onSelectieBeforeDisplay', array('com_knvbapi2.selectie', &$item, &$item->params, $i));
         $item->event->beforeDisplaySelectie = JString::trim(implode("\n", $results));
         $results = $dispatcher->trigger('onSelectieAfterDisplay', array('com_knvbapi2.selectie', &$item, &$item->params, $i));
         $item->event->afterDisplaySelectie = JString::trim(implode("\n", $results));
         $dispatcher = JEventDispatcher::getInstance();
     }
     if ($app->input->getString('layout', 'default') == 'blog') {
         // Get the metrics for the structural page layout.
         $num_leading = (int) $params->def('selectie_num_leading', 1);
         $num_intro = (int) $params->def('selectie_num_intro', 4);
         $num_links = (int) $params->def('selectie_num_links', 4);
         // Preprocess the breakdown of leading, intro and linked selecties.
         // This makes it much easier for the designer to just interogate the arrays.
         $max = count($items);
         // The first group is the leading selecties.
         $limit = $num_leading;
         for ($i = 0; $i < $limit and $i < $max; $i++) {
             $this->lead_items[$i] =& $items[$i];
         }
         // The second group is the intro selecties.
         $limit = $num_leading + $num_intro;
         // Order selecties across, then down (or single column mode)
         for ($i = $num_leading; $i < $limit and $i < $max; $i++) {
             $this->intro_items[$i] =& $items[$i];
         }
         $this->columns = max(1, $params->def('selectie_num_columns', 1));
         $order = $params->def('selectie_multi_column_order', 1);
         if ($order == 0 and $this->columns > 1) {
             // call order down helper
             $this->intro_items = Knvbapi2HelperQuery::orderDownColumns($this->intro_items, $this->columns);
         }
         // The remainder are the links.
         $limit = $num_leading + $num_intro + $num_links;
         for ($i = $num_leading + $num_intro; $i < $limit and $i < $max; $i++) {
             $this->link_items[$i] =& $items[$i];
         }
     }
     //Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->params =& $params;
     $this->state =& $state;
     $this->items =& $items;
     $this->pagination =& $pagination;
     $this->prepareDocument();
     parent::display($tpl);
 }