/** * Create an item feed. * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * */ public function display($tpl = null) { // parameters $app = JFactory::getApplication(); $db = JFactory::getDbo(); $doc = JFactory::getDocument(); $state = $this->get('State'); $params = $state->params; $feed_email = @$app->get('feed_email') ? $app->get('feed_email') : 'creator'; $site_email = $app->get('mailfrom'); $doc->link = JRoute::_('index.php?option=com_knvbapi&view=datakeuzes'); // Get some data from the model $app->input->set('limit', $app->get('feed_limit')); $rows = $this->get('Items'); foreach ($rows as $row) { // strip html from feed item name $title = $this->escape($row->name); $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8'); // Compute the datakeuze slug $row->slug = $row->id; if ($row->alias) { $row->slug .= ':' . $row->alias; } // url link to datakeuze $link = JRoute::_(KnvbapiHelperRoute::getDatakeuzeRoute($row->slug, $row->language, 'default', $params->get('keep_datakeuze_itemid')), false); $description = ''; $description = $row->description; // TODO: Only pull fulltext if necessary (actually, just get the necessary fields). if (!$params->get('feed_summary', 0)) { $description = $row->intro; } $created_by = $row->created_by_name ? $row->created_by_name : $row->created_by; @($date = $row->publish_up ? date('r', strtotime($row->publish_up)) : ''); // load individual item creator class $item = new JFeedItem(); $item->title = $title; $item->link = $link; $item->description = $description; $item->date = $date; $item->creator = $created_by; if ($feed_email == 'site') { $item->creatorEmail = $site_email; } else { $item->creatorEmail = $row->created_by_email; } // loads item info into rss array $doc->addItem($item); } }
/** * Create an item feed. * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * */ public function display($tpl = null) { $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $params = $app->getParams(); $feed_email = @$app->get('feed_email') ? $app->get('feed_email') : 'creator'; // Get some data from the model $app->input->set('limit', $app->get('feed_limit')); $category = $this->get('Category'); $rows = $this->get('Items'); $doc->link = JRoute::_(KnvbapiHelperRoute::getCategoryRoute($category->id, $params->get('keep_competitie_itemid'))); foreach ($rows as $row) { // strip html from feed item title $title = $this->escape($row->name); $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8'); // Compute the slug $row->slug = $row->id; if ($row->alias) { $row->slug .= ':' . $row->alias; } // url link to competitie // & used instead of & as this is converted by feed creator $link = JRoute::_(KnvbapiHelperRoute::getCompetitieRoute($row->slug, $row->catid, $row->language, 'default', $params->get('keep_competitie_itemid')), false); $description = $row->description; // TODO: Only pull fulltext if necessary (actually, just get the necessary fields). $description = $params->get('feed_summary', 0) ? $description : $row->intro; $creator = $row->created_by_alias ? $row->created_by_alias : $row->creator; @($date = $row->created ? date('r', strtotime($row->created)) : ''); // load individual item creator class $item = new JFeedItem(); $item->title = $title; $item->link = $link; $item->description = $description; $item->date = $date; $item->category = $row->category; $item->creator = $creator; if ($feed_email == 'site') { $item->creatorEmail = $site_email; } else { $item->creatorEmail = $row->creator_email; } // loads item info into rss array $doc->addItem($item); } }
/** * Method to index an item. The item must be a FinderIndexerResult object. * * @param FinderIndexerResult $item The item to index as an FinderIndexerResult object. * @param string $format The item format * * @return void * * @throws Exception on database error. */ protected function index(FinderIndexerResult $item, $format = 'html') { $item->setLanguage(); // Check if the extension is enabled if (JComponentHelper::isEnabled($this->extension) == false) { return; } // Initialize the item parameters. $registry = new Registry(); $registry->loadString($item->params); $item->params = JComponentHelper::getParams('com_knvbapi', true); $item->params->merge($registry); $registry = null; //release memory $registry = new Registry(); $registry->loadString($item->metadata); $item->metadata = $registry; $registry = null; //release memory // Trigger the onContentPrepare event. $item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params); $item->body = FinderIndexerHelper::prepareContent($item->body, $item->params); if ($this->sub_layout != 'default') { $view = $this->layout . '&layout=' . $this->sub_layout; } else { $view = $this->layout; } // Build the necessary route and path information. $item->url = $this->getURL($item->id, $this->extension, $view); $item->route = KnvbapiHelperRoute::getDatakeuzeRoute($item->slug, $item->language, $this->sub_layout); $item->path = FinderIndexerHelper::getContentPath($item->route); // Get the menu title if it exists. $title = $this->getItemMenuTitle($item->url); if (!empty($title) and $this->params->get('use_menu_title', true)) { $item->title = $title; } else { $item->title = $item->name; } // Add the meta-data processing instructions. $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc'); $item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_name'); // Translate the state. $item->state = $this->translateState($item->state); // Add the type taxonomy data. $item->addTaxonomy('Type', 'Datakeuze'); // Add the created_by taxonomy data. if (!empty($item->created_by_alias)) { $item->addTaxonomy('Author', !empty($item->created_by_name) ? $item->created_by_name : $item->created_by); } // Add the language taxonomy data. $item->addTaxonomy('Language', $item->language); // Get content extras. FinderIndexerHelper::getContentExtras($item); // Index the item. $this->indexer->index($item); }
/** * Prepares the document */ protected function prepareDocument() { $app = JFactory::getApplication(); $menus = $app->getMenu(); $lang = JFactory::getLanguage(); $pathway = $app->getPathway(); $title = null; // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if ($menu) { $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); } else { $this->params->def('page_heading', JText::_('COM_KNVBAPI_CATEGORY_HEADER')); } $id = (int) @$menu->query['id']; if ($menu and ($menu->query['option'] != 'com_knvbapi' or $menu->query['view'] == 'competitie' or $id != $this->category->id)) { $path = array(array('title' => $this->category->title, 'link' => '')); $category = $this->category->getParent(); while (($menu->query['option'] != 'com_knvbapi' or $menu->query['view'] == 'competitie' or $id != $category->id) and $category->id > 1) { $path[] = array('title' => $category->title, 'link' => KnvbapiHelperRoute::getCategoryRoute($category->id, $this->params->get('keep_competitie_itemid'))); $category = $category->getParent(); } $path = array_reverse($path); foreach ($path as $item) { $pathway->addItem($item['title'], $item['link']); } } $title = $this->params->get('page_title', ''); if (empty($title)) { $title = htmlspecialchars_decode($app->get('sitename')); } elseif ($app->get('sitename_pagetitles', 0)) { $title = JText::sprintf('JPAGETITLE', htmlspecialchars_decode($app->get('sitename')), $title); } $this->document->setTitle($title); // Get Menu Item meta description, Keywords and robots instruction to insert in page header if ($this->category->metadesc) { $this->document->setDescription($this->category->metadesc); } elseif (!$this->category->metadesc and $this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } if ($this->category->metakey) { $this->document->setMetadata('keywords', $this->category->metakey); } elseif (!$this->category->metakey and $this->params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } if ($this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } if ($app->get('MetaAuthor') == '1' and $this->category->get('author', '')) { $this->document->setMetaData('author', $this->category->get('author', '')); } if (!is_object($this->category->metadata)) { $this->category->metadata = new Registry($this->category->metadata); } $metadata = $this->category->metadata->toArray(); foreach ($metadata as $k => $v) { if ($v) { $this->document->setMetadata($k, $v); } } // Add feed links if ($this->params->get('show_feed_link', 1)) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $this->document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $this->document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs); } // Include Helpers JHtml::addIncludePath(JPATH_COMPONENT . '/helpers'); }
?> <?php $title = '<span itemprop="genre">' . $this->escape($this->item->category_title) . '</span>'; ?> <div class="formelm"> <label> <?php echo JText::_('COM_KNVBAPI_FIELD_CATEGORY_LABEL'); ?> </label> <span> <?php if ($params->get('link_competitie_category') and $this->item->catslug) { ?> <?php $url = '<a href="' . JRoute::_(KnvbapiHelperRoute::getCategoryRoute($this->item->catslug, $params->get('keep_competitie_itemid'))) . '" itemprop="url">' . $title . '</a>'; ?> <?php echo $url; ?> <?php } else { ?> <?php echo $title; ?> <?php } ?> </span>
?> <?php //Optional link to let them register to see the whole competitie. ?> <?php if ($params->get('show_competitie_readmore')) { if ($params->get('access-view')) { $link = JRoute::_(KnvbapiHelperRoute::getCompetitieRoute($this->item->slug, $this->item->catid, $this->item->language, $layout, $params->get('keep_competitie_itemid'))); } else { if ($params->get('show_competitie_noauth') and $user->get('guest')) { $menu = JFactory::getApplication()->getMenu(); $active = $menu->getActive(); $item_id = $active->id; $link_1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $item_id); $return_url = JRoute::_(KnvbapiHelperRoute::getCompetitieRoute($this->item->slug, $this->item->catid, $this->item->language, $layout, $params->get('keep_competitie_itemid'))); $link = new JUri($link_1); $link->setVar('return', base64_encode($return_url)); } } ?> <p class="readmore"> <a href="<?php echo $link; ?> " itemprop="url"> <?php $item_params = new Registry(); $item_params->loadString($this->item->params); if ($item_params->get('competitie_alternative_readmore') == null) { if ($params->get('access-view')) {
/** * Helper for mod_knvbapi * * @param json/registry $params Module parameters * * @return array $items Items to display */ public static function getList(&$params) { // Get the dbo $db = JFactory::getDbo(); // Get an instance of the generic teams model $model = JModelLegacy::getInstance('Teams', 'KnvbapiModel', array('ignore_request' => true)); // Set application parameters in model $app = JFactory::getApplication(); $app_params = $app->getParams(); $model->setState('params', $app_params); // Set the filters based on the module params $model->setState('list.start', 0); $model->setState('list.limit', (int) $params->get('count', 5)); $model->setState('filter.published', 1); // Access filter $access = !JComponentHelper::getParams('com_knvbapi')->get('show_team_noauth'); $authorised = JAccess::getAuthorisedViewLevels(JFactory::getUser()->get('id')); $model->setState('filter.access', $access); // User filter $user_id = JFactory::getUser()->get('id'); switch ($params->get('user_id')) { case 'by_me': $model->setState('filter.created_by_id', (int) $user_id); break; case 'not_me': $model->setState('filter.created_by_id', $user_id); $model->setState('filter.created_by_id.include', false); break; case '0': break; default: $model->setState('filter.created_by_id', (int) $params->get('user_id')); break; } // Filter by language $model->setState('filter.language', JLanguageMultilang::isEnabled()); // Filter by featured $model->setState('filter.featured', $params->get('show_featured')); // Filter by language $model->setState('filter.language', JLanguageMultilang::isEnabled()); $order_map = array('m_dsc' => 'a.modified DESC, a.created', 'c_dsc' => 'a.created', 'p_dsc' => 'a.publish_up', 'h_dsc' => 'a.hits', 'n_asc' => 'a.name', 'n_dsc' => 'a.name', 'o_asc' => 'a.ordering'); $ordering = JArrayHelper::getValue($order_map, $params->get('ordering'), 'a.name'); if (JString::substr($params->get('ordering'), -3, 3) == 'dsc') { $dir = 'DESC'; } else { $dir = 'ASC'; } $model->setState('list.ordering', $ordering); $model->setState('list.direction', $dir); $items = $model->getItems(); if ($params->get('itemid') != '') { $item_id_str = '&Itemid=' . (string) $params->get('itemid'); $keep_item_id = false; } else { $item_id_str = ''; $keep_item_id = true; } if ($params->get('team_layout') != '') { $layout = str_replace('_:', '', (string) $params->get('team_layout')); $layout_str = '&layout=' . $layout; } else { $layout = ''; $layout_str = ''; } foreach ($items as &$item) { $item->slug = $item->id . ':' . $item->alias; if ($access or in_array($item->access, $authorised)) { if ($item_id_str == '') { // We know that user has the privilege to view the team $item->link = JRoute::_(KnvbapiHelperRoute::getTeamRoute($item->slug, $item->language, $layout)); } else { $item->link = JRoute::_('index.php?option=com_knvbapi&view=team' . $layout_str . $item_id_str . '&id=' . $item->id); } } else { $item->link = JRoute::_('index.php?option=com_users&view=login'); } } return $items; }
/** * 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(); $user = JFactory::getUser(); $user_id = $user->get('id'); $dispatcher = JEventDispatcher::getInstance(); $this->state = $this->get('State'); $this->item = $this->get('Item'); $this->print = $app->input->getBool('print'); $this->user = $user; // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } // Create a shortcut for $item. $item = $this->item; // Add router helpers. $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; // Merge datakeuze params. If this is single-datakeuze view, menu params override datakeuze params // Otherwise, datakeuze params override menu item params $this->params = $this->state->get('params'); $active = $app->getMenu()->getActive(); $temp = clone $this->params; // Check to see which parameters should take priority if ($active) { $current_link = $active->link; // If the current view is the active item and an datakeuze view for this datakeuze, then the menu item params take priority if (JString::strpos($current_link, 'view=datakeuze') and JString::strpos($current_link, '&id=' . (string) $item->id)) { // $item->params are the datakeuze params, $temp are the menu item params // Merge so that the menu item params take priority $item->params->merge($temp); // Load layout from active query (in case it is an alternative menu item) if (isset($active->query['layout'])) { $this->setLayout($active->query['layout']); } else { if ($layout = $item->params->get('datakeuze_layout')) { $this->setLayout($layout); } } // $item->params are the article params, $temp are the menu item params // Merge so that the menu item params take priority $item->params->merge($temp); } else { // Current view is not a single datakeuze, so the datakeuze params take priority here // Merge the menu item params with the datakeuze params so that the datakeuze params take priority $temp->merge($item->params); $item->params = $temp; if ($this->getLayout() == 'blog') { $this->setLayout('article'); } } } else { // Merge so that datakeuze params take priority $temp->merge($item->params); $item->params = $temp; // Check for alternative layouts (since we are not in a single-datakeuze menu item) // Single-datakeuze menu item layout takes priority over alt layout for an datakeuze if ($layout = $item->params->get('datakeuze_layout')) { $this->setLayout($layout); } } $item->readmore_link = JRoute::_(KnvbapiHelperRoute::getDatakeuzeRoute($item->slug, $item->language, $this->getLayout(), $this->params->get('keep_datakeuze_itemid'))); if ($this->params->get('show_datakeuze_tags') == '1') { $item->tags = new JHelperTags(); $item->tags->getItemTags('com_knvbapi.datakeuze', $item->id); $item->tag_layout = new JLayoutFile('joomla.content.tags'); } $offset = $this->state->get('list.offset'); // Check the view access to the datakeuze (the model has already computed the values). if ($item->params->get('access-view') != true) { // If a no authority viewing is allowed show the item and rely on display code to show correct if (!$item->params->get('show_datakeuze_noauth')) { // If a guest user, they may be able to log in to view the full datakeuze if ($user->get('guest')) { // Redirect to login $uri = JUri::getInstance(); $app->redirect('index.php?option=com_users&view=login&return=' . base64_encode($uri), JText::_('COM_KNVBAPI_DATAKEUZES_ERROR_LOGIN_TO_VIEW_ITEM')); } else { JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR')); } return; } } // // Process the knvbapi plugins. // JPluginHelper::importPlugin('knvbapi'); $results = $dispatcher->trigger('onDatakeuzePrepare', array('com_knvbapi.datakeuze', &$item, &$this->params, $offset)); $item->event = new stdClass(); $results = $dispatcher->trigger('onDatakeuzeAfterName', array('com_knvbapi.datakeuze', &$item, &$this->params, $offset)); $item->event->afterDisplayDatakeuzeName = JString::trim(implode("\n", $results)); $results = $dispatcher->trigger('onDatakeuzeBeforeDisplay', array('com_knvbapi.datakeuze', &$item, &$this->params, $offset)); $item->event->beforeDisplayDatakeuze = JString::trim(implode("\n", $results)); $results = $dispatcher->trigger('onDatakeuzeAfterDisplay', array('com_knvbapi.datakeuze', &$item, &$this->params, $offset)); $item->event->afterDisplayDatakeuze = JString::trim(implode("\n", $results)); // Increment the hit counter of the datakeuze. $model = $this->getModel(); $model->hit(); $this->prepareDocument(); //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($this->params->get('pageclass_sfx')); parent::display($tpl); }
?> " itemscope itemtype="http://schema.org/CreativeWork"> <?php } ?> <td class="center" style="display:none;"> <?php echo JHtml::_('grid.id', $i, $item->id); ?> </td> <?php if (in_array($item->access, $user->getAuthorisedViewLevels()) or $params->get('show_competitie_noauth')) { ?> <td class="list-name"> <a href="<?php echo JRoute::_(KnvbapiHelperRoute::getCompetitieRoute($item->slug, $item->catid, $item->language, $layout, $params->get('keep_competitie_itemid'))); ?> " itemprop="url" > <span itemprop="url"><?php echo $this->escape($item->name); ?> </span> </a> </td> <?php if ($this->params->get('list_show_competitie_date')) { ?> <td class="list-date">
?> " itemscope itemtype="http://schema.org/CreativeWork"> <?php } ?> <td class="center" style="display:none;"> <?php echo JHtml::_('grid.id', $i, $item->id); ?> </td> <?php if (in_array($item->access, $user->getAuthorisedViewLevels()) or $params->get('show_datakeuze_noauth')) { ?> <td class="list-name"> <a href="<?php echo JRoute::_(KnvbapiHelperRoute::getDatakeuzeRoute($item->slug, $item->language, $layout, $params->get('keep_datakeuze_itemid'))); ?> " itemprop="url" > <span itemprop="url"><?php echo $this->escape($item->name); ?> </span> </a> </td> <?php if ($this->params->get('list_show_datakeuze_date')) { ?> <td class="list-date">
/** * On Before Display event procedure for item navigation * @param string $context Context of the paging * @param array &$row Passed by reference and row updated with html for prev and/or next buttons * @param json/registry &$params Item navigation parameters * @param integer $page Current Item page * * @return void */ public function onCompetitieBeforeDisplay($context, &$row, &$params, $page = 0) { $app = JFactory::getApplication(); $view = $app->input->getString('view'); $layout = $app->input->getString('layout'); $print = $app->input->getBool('print'); if ($print) { return false; } if ($params->get('show_competitie_navigation') and $context == 'com_knvbapi.competitie' and $view == 'competitie') { $html = ''; $db = JFactory::getDbo(); $user = JFactory::getUser(); $lang = JFactory::getLanguage(); $null_date = $db->getNullDate(); $date = JFactory::getDate(); $now = $date->toSQL(); $uid = $row->id; $option = 'com_knvbapi'; $can_publish = $user->authorise('core.edit.state', $option . '.competitie.' . $row->id); $query = $db->getQuery(true); $slug_select = ' CASE WHEN '; $slug_select .= $query->charLength('a.alias', '!=', '0'); $slug_select .= ' THEN '; $a_id = $query->castAsChar('a.id'); $slug_select .= $query->concatenate(array($a_id, 'a.alias'), ':'); $slug_select .= ' ELSE '; $slug_select .= $a_id . ' END as slug, '; $slug_select .= ' CASE WHEN '; $slug_select .= $query->charLength('cc.alias', '!=', '0'); $slug_select .= ' THEN '; $c_id = $query->castAsChar('cc.id'); $slug_select .= $query->concatenate(array($c_id, 'cc.alias'), ':'); $slug_select .= ' ELSE '; $slug_select .= $c_id . ' END as catslug, '; $query->select($slug_select . $db->quoteName('a.params') . ',' . $db->quoteName('a.language') . ', ' . $db->quoteName('a.catid') . ', ' . $db->quoteName('a.id')); $query->from($db->quoteName('#__knvbapi_competities') . ' AS a'); $query->join('LEFT', $db->quoteName('#__categories') . ' AS cc ON ' . $db->quoteName('cc.id') . ' = ' . $db->quoteName('a.catid')); // Join over users for created by $query->select($db->quoteName('ua.name') . ' AS created_by_name'); $query->join('LEFT', $db->quoteName('#__users') . ' AS ua on ' . $db->quoteName('ua.id') . ' = ' . $db->quoteName('a.created_by')); if ($app->isSite() and JLanguageMultilang::isEnabled()) { $query->where($db->quoteName('a.language') . ' IN (' . $db->quote($lang->getTag()) . ',' . $db->quote('*') . ')'); } // Filter by a same category as the selected row if ($params->get('limit_category_fieldtype_navigation', false) == true) { $query->where($db->quoteName('a.catid') . ' = ' . (int) $row->catid); } if (!$can_publish) { $query->where('(' . $db->quoteName('a.state') . ' = 1 OR ' . $db->quoteName('a.state') . ' = -1)' . ' AND (' . $db->quoteName('a.publish_up') . ' = ' . $db->quote($null_date) . ' OR ' . $db->quoteName('a.publish_up') . ' <= ' . $db->quote($now) . ')' . ' AND (' . $db->quoteName('a.publish_down') . ' = ' . $db->quote($null_date) . ' OR ' . $db->quoteName('a.publish_down') . ' >= ' . $db->quote($now) . ')'); } else { $query->where($db->quoteName('a.state') . ' = ' . (int) $row->state); } if ($params->get('show_competitie_noauth') != 1 and $params->get('show_competitie_noauth') != 'use_competitie') { $query->where($db->quoteName('a.access') . ' = ' . (int) $row->access); } // Add the list ordering clause. $initial_sort = $params->get('competitie_initial_sort'); // Falll back to old style if the parameter hasn't been set yet. if (empty($initial_sort)) { $query->order($db->quoteName($db->escape($params->get('list.ordering', 'a.ordering'))) . ' ' . $db->escape($params->get('list.direction', 'ASC'))); } else { $query->order($db->quoteName('a.' . $initial_sort) . ' ' . $db->escape($params->get('list.direction', 'ASC'))); } $db->setQuery($query); $list = $db->loadObjectList('id'); // This check needed if incorrect Itemid is given resulting in an incorrect result. if (!is_array($list)) { $list = array(); } reset($list); // Location of current competitie item in array list. $location = array_search($uid, array_keys($list)); $rows = array_values($list); $row->prev = null; $row->next = null; // Get the global params $global_params = JComponentHelper::getParams('com_knvbapi', true); if ($location - 1 >= 0) { $row->prev = $location - 1; // The previous competitie item cannot be in the array position -1. for ($i = $location - 1; $i >= 0; $i--) { $row->prev = $rows[$i]; break; } } if ($location + 1 < count($rows)) { $row->next = $location + 1; // The next competitie item cannot be in an array position greater than the number of array postions. for ($i = $location + 1; $i <= count($rows) - 1; $i++) { $row->next = $rows[$i]; break; } } $pn_space = ""; if (JText::_('JGLOBAL_LT') or JText::_('JGLOBAL_GT')) { $pn_space = " "; } $keep_item_id = (int) $params->get('keep_competitie_itemid', 0); if ($row->prev) { $row->prev_label = $this->params->get('display', 0) == 0 ? JText::_('JPREV') : $row->prev->name; $row->prev = JRoute::_(KnvbapiHelperRoute::getCompetitieRoute($row->prev->slug, $row->prev->catid, $row->prev->language, $layout, $keep_item_id)); } else { $row->prev_label = ''; $row->prev = ''; } if ($row->next) { $row->next_label = $this->params->get('display', 0) == 0 ? JText::_('JNEXT') : $row->next->name; $row->next = JRoute::_(KnvbapiHelperRoute::getCompetitieRoute($row->next->slug, $row->next->catid, $row->next->language, $layout, $keep_item_id)); } else { $row->next_label = ''; $row->next = ''; } // Output. if ($row->prev or $row->next) { $lang = JFactory::getLanguage(); $html = '<ul class="pager pagenav">'; if ($row->prev) { $direction = $lang->isRTL() ? 'right' : 'left'; $html .= ' <li class="previous"> <a href="' . $row->prev . '" rel="prev">' . '<i class="icon-chevron-' . $direction . '"></i> ' . $row->prev_label . '</a>' . '</li>'; } if ($row->next) { $direction = $lang->isRTL() ? 'left' : 'right'; $html .= ' <li class="next"> <a href="' . $row->next . '" rel="next">' . $row->next_label . ' <i class="icon-chevron-' . $direction . '"></i>' . '</a>' . '</li>'; } $html .= '</ul>'; $row->pagination = $html; $row->paginationposition = $this->params->get('competitie_position', 1); // This will default to the 1.5 and 1.6-1.7 behavior. $row->paginationrelative = $this->params->get('competitie_relative', 0); } } return; }
?> <?php //Optional link to let them register to see the whole datakeuze. ?> <?php if ($params->get('show_datakeuze_readmore')) { if ($params->get('access-view')) { $link = JRoute::_(KnvbapiHelperRoute::getDatakeuzeRoute($this->item->slug, $this->item->language, $layout, $params->get('keep_datakeuze_itemid'))); } else { if ($params->get('show_datakeuze_noauth') and $user->get('guest')) { $menu = JFactory::getApplication()->getMenu(); $active = $menu->getActive(); $item_id = $active->id; $link_1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $item_id); $return_url = JRoute::_(KnvbapiHelperRoute::getDatakeuzeRoute($this->item->slug, $this->item->language, $layout, $params->get('keep_datakeuze_itemid'))); $link = new JUri($link_1); $link->setVar('return', base64_encode($return_url)); } } ?> <p class="readmore"> <a href="<?php echo $link; ?> " itemprop="url"> <?php $item_params = new Registry(); $item_params->loadString($this->item->params); if ($item_params->get('datakeuze_alternative_readmore') == null) { if ($params->get('access-view')) {
?> <?php //Optional link to let them register to see the whole team. ?> <?php if ($params->get('show_team_readmore')) { if ($params->get('access-view')) { $link = JRoute::_(KnvbapiHelperRoute::getTeamRoute($this->item->slug, $this->item->language, $layout, $params->get('keep_team_itemid'))); } else { if ($params->get('show_team_noauth') and $user->get('guest')) { $menu = JFactory::getApplication()->getMenu(); $active = $menu->getActive(); $item_id = $active->id; $link_1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $item_id); $return_url = JRoute::_(KnvbapiHelperRoute::getTeamRoute($this->item->slug, $this->item->language, $layout, $params->get('keep_team_itemid'))); $link = new JUri($link_1); $link->setVar('return', base64_encode($return_url)); } } ?> <p class="readmore"> <a href="<?php echo $link; ?> " itemprop="url"> <?php $item_params = new Registry(); $item_params->loadString($this->item->params); if ($item_params->get('team_alternative_readmore') == null) { if ($params->get('access-view')) {
?> " itemscope itemtype="http://schema.org/CreativeWork"> <?php } ?> <td class="center" style="display:none;"> <?php echo JHtml::_('grid.id', $i, $item->id); ?> </td> <?php if (in_array($item->access, $user->getAuthorisedViewLevels()) or $params->get('show_team_noauth')) { ?> <td class="list-name"> <a href="<?php echo JRoute::_(KnvbapiHelperRoute::getTeamRoute($item->slug, $item->language, $layout, $params->get('keep_team_itemid'))); ?> " itemprop="url" > <span itemprop="url"><?php echo $this->escape($item->name); ?> </span> </a> </td> <?php if ($this->params->get('list_show_team_date')) { ?> <td class="list-date">
/** * Creates the navigation for the item * * @param object &$row The competitie object. Note $competitie->text is also available * @param int $page The total number of pages * @param int $n The page number * * @return void */ protected function _createCompetitieNavigation(&$row, $page, $n) { $input = JFactory::getApplication()->input; $layout = $input->getString('layout', ''); if ($layout != '') { $layout = '&layout=' . $layout; } $space = ''; if (JText::_('JGLOBAL_LT') or JText::_('JGLOBAL_LT')) { $space = ' '; } if ($page < $n - 1) { $page_next = $page + 1; $link_next = JRoute::_(KnvbapiHelperRoute::getCompetitieRoute($row->slug, $row->catid, $row->language) . $layout . '&showall=&limitstart=' . $page_next); // Next >> $next = '<a href="' . $link_next . '">' . JText::_('JNEXT') . $space . JText::_('JGLOBAL_GT') . JText::_('JGLOBAL_GT') . '</a>'; } else { $next = JText::_('JNEXT'); } if ($page > 0) { $page_prev = $page - 1 == 0 ? '' : $page - 1; $link_prev = JRoute::_(KnvbapiHelperRoute::getCompetitieRoute($row->slug, $row->catid, $row->language) . $layout . '&showall=&limitstart=' . $page_prev); // << Prev $prev = '<a href="' . $link_prev . '">' . JText::_('JGLOBAL_LT') . JText::_('JGLOBAL_LT') . $space . JText::_('JPREV') . '</a>'; } else { $prev = JText::_('JPREV'); } $row->introdescription .= '<ul><li>' . $prev . ' </li><li>' . $next . '</li></ul>'; }
/** * Teams Search method * The sql must return the following fields that are used in a common display * routine: href, title, section, created, text, browsernav * @param string Target search string * @param string mathcing option, exact|any|all * @param string ordering option, newest|oldest|popular|alpha|category(if used) * @param mixed An array if the search it to be restricted to areas, null if search all */ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null) { $db = JFactory::getDbo(); $app = JFactory::getApplication(); $user = JFactory::getUser(); $groups = implode(',', $user->getAuthorisedViewLevels()); $tag = JFactory::getLanguage()->getTag(); require_once JPATH_SITE . '/components/com_knvbapi/helpers/route.php'; require_once JPATH_ADMINISTRATOR . '/components/com_search/helpers/search.php'; $search_text = $text; if (is_array($areas)) { if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) { return array(); } } $sTeam = 1; $sTeamArchived = 0; $limit = 50; $sTeam = $this->params->get('search_teams', 1); $sTeamArchived = $this->params->get('search_archived_teams', 0); $limit = $this->params->def('search_limit', 50); if ($this->params->get('itemid') != '') { $item_id_str = '&Itemid=' . (string) $this->params->get('itemid'); $keep_item_id = true; } else { $item_id_str = ''; $keep_item_id = false; } $null_date = $db->getNullDate(); $date = JFactory::getDate(); $now = $date->toSQL(); $text = JString::trim($text); if ($text == '') { return array(); } switch ($phrase) { case 'exact': $text = $db->quote('%' . $db->escape($text, true) . '%', false); $wheres_2 = array(); $wheres_2[] = $db->quoteName('a.name') . ' LIKE ' . $text; $wheres_2[] = $db->quoteName('a.description') . ' LIKE ' . $text; $wheres_2[] = $db->quoteName('a.metakey') . ' LIKE ' . $text; $wheres_2[] = $db->quoteName('a.metadesc') . ' LIKE ' . $text; $where = '(' . implode(') OR (', $wheres_2) . ')'; break; case 'all': case 'any': default: $words = explode(' ', $text); $wheres = array(); foreach ($words as $word) { $word = $db->quote('%' . $db->escape($word, true) . '%', false); $wheres_2 = array(); $wheres_2[] = 'LOWER(' . $db->quoteName('a.name') . ') LIKE LOWER(' . $word . ')'; $wheres_2[] = 'LOWER(' . $db->quoteName('a.description') . ') LIKE LOWER(' . $word . ')'; $wheres_2[] = 'LOWER(' . $db->quoteName('a.metakey') . ') LIKE LOWER(' . $word . ')'; $wheres_2[] = 'LOWER(' . $db->quoteName('a.metadesc') . ') LIKE LOWER(' . $word . ')'; $wheres[] = implode(' OR ', $wheres_2); } $where = '(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')'; break; } $order = ''; switch ($ordering) { case 'oldest': $order = $db->quoteName('a.created') . ' ASC'; break; case 'popular': $order = $db->quoteName('a.hits') . ' DESC'; break; case 'alpha': $order = $db->quoteName('a.name') . ' ASC'; break; case 'newest': $order = $db->quoteName('a.created') . ' DESC'; break; default: $order = $db->quoteName('a.ordering') . ' DESC'; break; } $rows = array(); $query = $db->getQuery(true); $search_section = JText::_('PLG_SEARCH_TEAMS_TEAMS'); // search teams if ($sTeam and $limit > 0) { $query->clear(); //sqlsrv changes $slug_select = ' CASE WHEN '; $slug_select .= $query->charLength('a.alias', '!=', '0'); $slug_select .= ' THEN '; $a_id = $query->castAsChar('a.id'); $slug_select .= $query->concatenate(array($a_id, 'a.alias'), ':'); $slug_select .= ' ELSE '; $slug_select .= $a_id . ' END as slug, '; $query->select($db->quoteName('a.name') . ' AS title, ' . $db->quoteName('a.metadesc') . ', ' . $db->quoteName('a.metakey') . ', ' . $db->quoteName('a.created') . ' AS created, ' . $db->quoteName('a.description') . ' AS text, ' . $db->quoteName('a.language') . ' AS language, ' . $db->quote($search_section) . ' AS section, ' . $slug_select . '"2" AS browsernav'); $query->from($db->quoteName('#__knvbapi_teams') . ' AS a'); $query->where('(' . $where . ')' . 'AND ' . $db->quoteName('a.state') . ' = 1 ' . 'AND ' . $db->quoteName('a.access') . ' IN (' . $groups . ') ' . 'AND (' . $db->quoteName('a.publish_up') . ' = ' . $db->quote($null_date) . ' OR ' . $db->quoteName('a.publish_up') . ' <= ' . $db->quote($now) . ') ' . 'AND (' . $db->quoteName('a.publish_down') . ' = ' . $db->quote($null_date) . ' OR ' . $db->quoteName('a.publish_down') . ' >= ' . $db->quote($now) . ') '); // Filter by language if ($app->isSite() and JLanguageMultilang::isEnabled()) { $query->where($db->quoteName('a.language') . ' IN (' . $db->quote($tag) . ',' . $db->quote('*') . ')'); $query->where($db->quoteName('c.language') . ' IN (' . $db->quote($tag) . ',' . $db->quote('*') . ')'); } $query->group($db->quoteName('a.id') . ', ' . $db->quoteName('a.name')); $query->order($order); $db->setQuery($query, 0, $limit); $list = $db->loadObjectList(); $limit -= count($list); if (isset($list)) { foreach ($list as $key => $item) { $list[$key]->href = JRoute::_(KnvbapiHelperRoute::getTeamRoute($item->slug, $item->language, $this->layout, $keep_item_id)); //Add the selected item id to the link if there is one $list[$key]->href .= $item_id_str; } } $rows[] = $list; } // search archived teams if ($sTeamArchived and $limit > 0) { $query->clear(); //sqlsrv changes $slug_select = ' CASE WHEN '; $slug_select .= $query->charLength('a.alias', '!=', '0'); $slug_select .= ' THEN '; $a_id = $query->castAsChar('a.id'); $slug_select .= $query->concatenate(array($a_id, 'a.alias'), ':'); $slug_select .= ' ELSE '; $slug_select .= $a_id . ' END AS slug, '; $query->select($db->quoteName('a.name') . ' AS title, ' . $db->quoteName('a.metadesc') . ', ' . $db->quoteName('a.metakey') . ', ' . $db->quoteName('a.created') . ' AS created, ' . $db->quoteName('a.description') . ' AS text, ' . $db->quoteName('a.language') . ' AS language, ' . $db->quote($search_section) . ' AS section, ' . $slug_select . '"2" AS browsernav'); $query->from($db->quoteName('#__knvbapi_teams') . ' AS a'); $query->where('(' . $where . ') ' . 'AND ' . $db->quoteName('a.state') . ' = 2 ' . 'AND ' . $db->quoteName('a.access') . ' IN (' . $groups . ') ' . 'AND (' . $db->quoteName('a.publish_up') . ' = ' . $db->quote($null_date) . ' OR ' . $db->quoteName('a.publish_up') . ' <= ' . $db->quote($now) . ') ' . 'AND (' . $db->quoteName('a.publish_down') . ' = ' . $db->quote($null_date) . ' OR ' . $db->quoteName('a.publish_down') . ' >= ' . $db->quote($now) . ') '); // Filter by language if ($app->isSite() and JLanguageMultilang::isEnabled()) { $query->where($db->quoteName('a.language') . ' IN (' . $db->quote($tag) . ',' . $db->quote('*') . ')'); $query->where($db->quoteName('c.language') . ' IN (' . $db->quote($tag) . ',' . $db->quote('*') . ')'); } $query->order($order); $db->setQuery($query, 0, $limit); $list3 = $db->loadObjectList(); // find an itemid for archived to use if there isn't another one $item = $app->getMenu()->getItems('link', 'index.php?option=com_knvbapi&view=teamarchive', true); $item_id = isset($item) ? '&Itemid=' . $item->id : $item_id_str; if (isset($list3)) { foreach ($list3 as $key => $item) { $date = JFactory::getDate($item->created); $created_month = $date->format("n"); $created_year = $date->format("Y"); $list3[$key]->href = JRoute::_('index.php?option=com_knvbapi&view=teamarchive' . '&year=' . $created_year . '&month=' . $created_month . $item_id); } } $rows[] = $list3; } $results = array(); if (count($rows)) { foreach ($rows as $row) { $new_row = array(); foreach ($row as $team) { if (SearchHelper::checkNoHTML($team, $search_text, array('title', 'description', 'metadesc', 'metakey'))) { $new_row[] = $team; } } $results = array_merge($results, (array) $new_row); } } return $results; }
/** * Prepares the document */ protected function prepareDocument() { $app = JFactory::getApplication(); $menus = $app->getMenu(); $lang = JFactory::getLanguage(); $pathway = $app->getPathway(); $title = null; // Because the application sets a default page title, // we need to get it from the menu item itself $menu = $menus->getActive(); if ($menu and $menu->params->get('show_page_heading')) { $this->params->def('page_heading', $this->params->get('page_title', $menu->title)); } else { $this->params->def('page_heading', $this->item->name); } $title = $this->params->get('page_title', ''); $id = (int) @$menu->query['id']; // if the menu item does not concern this competitie if ($menu and ($menu->query['option'] != 'com_knvbapi' or $menu->query['view'] != 'competitie' or $id != $this->item->id)) { // If this is not a single competitie menu item, set the page title to the competitie name if ($this->item->name) { $title = $this->item->name; } $path = array(array('title' => $this->item->name, 'link' => '')); if ($this->params->get('show_competitie_category_breadcrumb', '0')) { $options['countItems'] = false; $options['table'] = '#__knvbapi_competities'; $category = JCategories::getInstance('Knvbapi', $options)->get($this->item->catid); while ($category and ($menu->query['option'] != 'com_knvbapi' or $menu->query['view'] == 'competitie' or $id != $category->id) and $category->id > 1) { $path[] = array('title' => $category->title, 'link' => KnvbapiHelperRoute::getCategoryRoute($category->id, $this->params->get('keep_competitie_itemid'))); $category = $category->getParent(); } } $path = array_reverse($path); foreach ($path as $item) { $pathway->addItem($item['title'], $item['link']); } } // Check for empty title and add site name if param is set if (empty($title)) { $title = htmlspecialchars_decode($app->get('sitename')); } elseif ($app->get('sitename_pagetitles', 0)) { $title = JText::sprintf('JPAGETITLE', htmlspecialchars_decode($app->get('sitename')), $title); } if (empty($title)) { $title = $this->item->name; } $this->document->setTitle($title); // Get Menu Item meta description, Keywords and robots instruction to insert in page header if ($this->item->metadesc) { $this->document->setDescription($this->item->metadesc); } else { if (!$this->item->metadesc and $this->params->get('menu-meta_description')) { $this->document->setDescription($this->params->get('menu-meta_description')); } } if ($this->item->metakey) { $this->document->setMetadata('keywords', $this->item->metakey); } else { if (!$this->item->metakey and $this->params->get('menu-meta_keywords')) { $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords')); } } // Get Robots instruction to insert in page header if ($this->item->robots) { $this->document->setMetadata('robots', $this->item->robots); } else { if (!$this->item->robots and $this->params->get('robots')) { $this->document->setMetadata('robots', $this->params->get('robots')); } } if ($app->get('MetaAuthor') == '1') { $author = $this->item->created_by_alias ? $this->item->created_by_alias : $this->item->author; $this->document->setMetaData('author', $author); } // If there is a pagebreak heading or title, add it to the page title if (!empty($this->item->page_title)) { $this->item->name = $this->item->name . ' - ' . $this->item->page_title; $this->document->setTitle($this->item->page_title . ' - ' . JText::sprintf('COM_KNVBAPI_PAGEBREAK_PAGE_NUM', $this->state->get('list.offset') + 1)); } // Include Helpers JHtml::addIncludePath(JPATH_COMPONENT . '/helpers'); }
/** * Create an item feed. * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * */ public function display($tpl = null) { // parameters $app = JFactory::getApplication(); $db = JFactory::getDbo(); $doc = JFactory::getDocument(); $state = $this->get('State'); $params = $state->params; $feed_email = @$app->get('feed_email') ? $app->get('feed_email') : 'creator'; $site_email = $app->get('mailfrom'); $doc->link = JRoute::_('index.php?option=com_knvbapi&view=competities'); // Get some data from the model $app->input->set('limit', $app->get('feed_limit')); $options['countItems'] = false; $options['table'] = '#__knvbapi_competities'; $categories = JCategories::getInstance('Knvbapi', $options); $rows = $this->get('Items'); foreach ($rows as $row) { // strip html from feed item name $title = $this->escape($row->name); $title = html_entity_decode($title, ENT_COMPAT, 'UTF-8'); // Compute the competitie slug $row->slug = $row->id; if ($row->alias) { $row->slug .= ':' . $row->alias; } // url link to competitie $link = JRoute::_(KnvbapiHelperRoute::getCompetitieRoute($row->slug, $row->catid, $row->language, 'default', $params->get('keep_competitie_itemid')), false); $description = ''; $description = $row->description; // TODO: Only pull fulltext if necessary (actually, just get the necessary fields). if (!$params->get('feed_summary', 0)) { $description = $row->intro; } $created_by = $row->created_by_name ? $row->created_by_name : $row->created_by; @($date = $row->publish_up ? date('r', strtotime($row->publish_up)) : ''); // load individual item creator class $item = new JFeedItem(); $item->title = $title; $item->link = $link; $item->description = $description; $item->date = $date; $item_category = $categories->get($row->catid); $item->category = array(); if ($item->featured == 1) { $item->category[] = JText::_('JFEATURED'); // All featured competities are categorized as "Featured" } for ($item_category = $categories->get($row->catid); $item_category !== null; $item_category = $item_category->getParent()) { if ($item_category->id > 1) { // Only add non-root categories $item->category[] = $item_category->title; } } $item->creator = $created_by; if ($feed_email == 'site') { $item->creatorEmail = $site_email; } else { $item->creatorEmail = $row->created_by_email; } // loads item info into rss array $doc->addItem($item); } }
/** * Method to generate a popup link to print an team * * @param object $team The team information * @param Registry $params The item parameters * @param array $attribs Optional attributes for the link * @param boolean $legacy True to use legacy images, false to use icomoon based graphic * * @return string The HTML markup for the popup link */ public static function print_popup($team, $params, $attribs = array(), $legacy = false) { $app = JFactory::getApplication(); $input = $app->input; $request = $input->request; $layout = $app->input->getString('layout', 'default'); $link = JRoute::_(KnvbapiHelperRoute::getTeamRoute($team->slug, $team->language, $layout, $params->get('keep_team_itemid')), false); if (strpos($link, '?') === false) { $link .= '?'; } $link .= '&tmpl=component&print=1&layout=default&page=' . @$request->limitstart; $window_params = 'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no'; // checks template image directory for image, if non found default are loaded if ($params->get('show_team_icons')) { if ($legacy) { $text = JHtml::_('image', 'com_knvbapi/printButton.png', JText::_('JGLOBAL_PRINT'), null, true); } else { $text = '<span class="icon-print"></span>' . JText::_('JGLOBAL_PRINT'); } } else { $text = JText::_('JGLOBAL_PRINT'); } $attribs['title'] = JText::_('JGLOBAL_PRINT'); $attribs['onclick'] = "window.open(this.href,'win2','" . $window_params . "'); return false;"; $attribs['rel'] = 'nofollow'; return JHtml::_('link', JRoute::_($link), $text, $attribs); }
?> <?php if ($this->params->get('show_empty_categories') or $child->getNumItems(true) or count($child->getChildren())) { if (!isset($this->children[$this->parent->id][$id + 1])) { $class = ' class="last"'; } ?> <li <?php echo $class; ?> > <?php $class = ''; ?> <span class="item-title"><a href="<?php echo JRoute::_(KnvbapiHelperRoute::getCategoryRoute($child->id, $this->params->get('keep_competitie_itemid'), $child->language)); ?> "> <?php echo $this->escape($child->title); ?> </a> </span> <?php if ($this->params->get('show_subcategories_desc') == 1) { ?> <?php if ($child->description) { ?> <div class="category-desc"> <?php