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);
 }
Exemplo n.º 2
0
 /**
  * Build the orderby for the query
  *
  * @return	string	$order_by portion of query
  * 
  */
 protected function buildOrderBy()
 {
     $app = JFactory::getApplication('site');
     $db = $this->getDbo();
     $params = $this->state->params;
     $item_id = $app->input->getInt('id', 0) . ':' . $app->input->getInt('Itemid', 0);
     $order_col = $app->getUserStateFromRequest('com_knvbapi2.category.list.' . $item_id . '.filter_order', 'filter_order', '', 'string');
     $order_dirn = $app->getUserStateFromRequest('com_knvbapi2.category.list.' . $item_id . '.filter_order_Dir', 'filter_order_Dir', '', 'cmd');
     $order_by = ' ';
     if (!in_array($order_col, $this->filter_fields)) {
         $order_col = null;
     }
     if (!in_array(JString::strtoupper($order_dirn), array('ASC', 'DESC', ''))) {
         $order_dirn = 'ASC';
     }
     if ($order_col and $order_dirn) {
         $order_by .= $db->escape($order_col) . ' ' . $db->escape($order_dirn) . ', ';
     }
     switch ($params->get('items_to_display', '')) {
         case 'Teamnaams':
             $secondary_order_by = $params->get('teamnaam_orderby_sec', 'none');
             $order_date = $params->get('teamnaam_order_date');
             $category_order_by = $params->def('teamnaam_orderby_pri', '');
             $primary = Knvbapi2HelperQuery::orderbyPrimary($category_order_by);
             $secondary = Knvbapi2HelperQuery::orderbySecondary($secondary_order_by, $order_date, 'ordering') . ', ';
             $order_by .= $db->escape($primary) . $db->escape($secondary) . $db->quoteName('a.created');
             break;
         default:
             $category_order_by = 'ordering';
             $primary = Knvbapi2HelperQuery::orderbyPrimary($category_order_by);
             $order_by .= $db->escape($primary);
             break;
     }
     return JString::trim($order_by);
 }