Пример #1
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_knvbapi.category.list.' . $item_id . '.filter_order', 'filter_order', '', 'string');
     $order_dirn = $app->getUserStateFromRequest('com_knvbapi.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 'Competities':
             $secondary_order_by = $params->get('competitie_orderby_sec', 'none');
             $order_date = $params->get('competitie_order_date');
             $category_order_by = $params->def('competitie_orderby_pri', '');
             $primary = KnvbapiHelperQuery::orderbyPrimary($category_order_by);
             $secondary = KnvbapiHelperQuery::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 = KnvbapiHelperQuery::orderbyPrimary($category_order_by);
             $order_by .= $db->escape($primary);
             break;
     }
     return JString::trim($order_by);
 }
Пример #2
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 competitie slugs and set the trigger events.
     foreach ($items as $i => &$item) {
         // Add router helpers.
         $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id;
         $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid;
         $item->parent_slug = $item->category_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id;
         //
         // Process the knvbapi plugins.
         //
         JPluginHelper::importPlugin('knvbapi');
         $dispatcher->trigger('onCompetitiePrepare', array('com_knvbapi.competitie', &$item, &$item->params, $i));
         $item->event = new stdClass();
         $results = $dispatcher->trigger('onCompetitieAfterName', array('com_knvbapi.competitie', &$item, &$item->params, $i));
         $item->event->afterDisplayCompetitieName = JString::trim(implode("\n", $results));
         $results = $dispatcher->trigger('onCompetitieBeforeDisplay', array('com_knvbapi.competitie', &$item, &$item->params, $i));
         $item->event->beforeDisplayCompetitie = JString::trim(implode("\n", $results));
         $results = $dispatcher->trigger('onCompetitieAfterDisplay', array('com_knvbapi.competitie', &$item, &$item->params, $i));
         $item->event->afterDisplayCompetitie = 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('competitie_num_leading', 1);
         $num_intro = (int) $params->def('competitie_num_intro', 4);
         $num_links = (int) $params->def('competitie_num_links', 4);
         // Preprocess the breakdown of leading, intro and linked competities.
         // This makes it much easier for the designer to just interogate the arrays.
         $max = count($items);
         // The first group is the leading competities.
         $limit = $num_leading;
         for ($i = 0; $i < $limit and $i < $max; $i++) {
             $this->lead_items[$i] =& $items[$i];
         }
         // The second group is the intro competities.
         $limit = $num_leading + $num_intro;
         // Order competities 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('competitie_num_columns', 1));
         $order = $params->def('competitie_multi_column_order', 1);
         if ($order == 0 and $this->columns > 1) {
             // call order down helper
             $this->intro_items = KnvbapiHelperQuery::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);
 }