Esempio 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)
 {
     RHelperAsset::load('tracks.css');
     $mainframe = JFactory::getApplication();
     $projectId = JFactory::getApplication()->input->getInt('p', 0);
     $model = $this->getModel();
     $results = $model->getResults($projectId);
     $project = $model->getProject($projectId);
     $params = $model->getParams();
     $document = JFactory::getDocument();
     $document->setTitle($project->name);
     $breadcrumbs = $mainframe->getPathWay();
     $breadcrumbs->addItem($project->name, TrackslibHelperRoute::getProjectRoute($project->id));
     $this->assignRef('results', $results);
     $this->assignRef('project', $project);
     $this->assignRef('params', $params);
     parent::display($tpl);
 }
Esempio n. 2
0
?>
</th>
			<th><?php 
echo JText::_('');
?>
</th>
			<th><?php 
echo JText::_('');
?>
</th>
		</tr>
		</thead>
		<?php 
if (count($this->projects)) {
    foreach ($this->projects as $project) {
        $link_project = JRoute::_(TrackslibHelperRoute::getProjectRoute($project->slug));
        $link_ranking = JRoute::_(TrackslibHelperRoute::getRankingRoute($project->slug));
        $link_teams_ranking = JRoute::_(TrackslibHelperRoute::getTeamRankingRoute($project->slug));
        ?>
				<tr>
					<td>
						<a href="<?php 
        echo $link_project;
        ?>
" title="<?php 
        echo JText::_('COM_TRACKS_Display');
        ?>
">
							<?php 
        echo $project->name;
        ?>
Esempio n. 3
0
 /**
  * Tracks 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  $text      Target search string
  * @param   string  $phrase    matching option, exact|any|all
  * @param   string  $ordering  ordering option, newest|oldest|popular|alpha|category
  * @param   mixed   $areas     An array if the search it to be restricted to areas, null if search all
  *
  * @return array
  */
 public function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
 {
     $db = JFactory::getDbo();
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $groups = implode(',', $user->getAuthorisedViewLevels());
     if (is_array($areas)) {
         if (!array_intersect($areas, array_keys($this->onContentSearchAreas()))) {
             return array();
         }
     }
     $limit = $this->params->def('search_limit', 50);
     $text = trim($text);
     if (!$text) {
         return array();
     }
     $section = JText::_('PLG_SEARCH_TRACKS_TRACKS');
     $rows = array();
     if (!$areas || in_array('tracksindividuals', $areas)) {
         $query = $db->getQuery(true);
         switch ($phrase) {
             // Search exact
             case 'exact':
                 $string = $db->Quote('%' . $db->escape($text, true) . '%', false);
                 $wheres2 = array();
                 $wheres2[] = 'LOWER(i.first_name) LIKE ' . $string;
                 $wheres2[] = 'LOWER(i.last_name) LIKE ' . $string;
                 $wheres2[] = 'LOWER(i.nickname) LIKE ' . $string;
                 $query->where('(' . implode(' OR ', $wheres2) . ')');
                 break;
                 // Search all or any
             // Search all or any
             case 'all':
             case 'any':
             default:
                 $words = explode(' ', $text);
                 $wheres = array();
                 foreach ($words as $word) {
                     $word = $db->Quote('%' . $db->escape($word, true) . '%', false);
                     $wheres2 = array();
                     $wheres2[] = 'LOWER(i.first_name) LIKE ' . $word;
                     $wheres2[] = 'LOWER(i.last_name) LIKE ' . $word;
                     $wheres2[] = 'LOWER(i.nickname) LIKE ' . $word;
                     $wheres[] = implode(' OR ', $wheres2);
                 }
                 $query->where('(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')');
                 break;
         }
         $query->order('i.last_name ASC, i.first_name ASC');
         $query->select('CONCAT_WS(", ", i.last_name, i.first_name) AS title')->select('CONCAT_WS( " / ", ' . $db->Quote($section) . ', ' . $db->Quote(JText::_('PLG_SEARCH_TRACKS_INDIVIDUALS')) . ' ) AS section')->select('CASE WHEN CHAR_LENGTH( i.alias ) THEN CONCAT_WS( \':\', i.id, i.alias ) ELSE i.id END AS slug')->select('NULL AS created')->select('2 AS browsernav')->from('#__tracks_individuals AS i');
         $db->setQuery($query, 0, $limit);
         $results = $db->loadObjectList();
         // The 'output' of the displayed link
         foreach ($results as $key => $row) {
             $results[$key]->href = TrackslibHelperRoute::getIndividualRoute($row->slug);
         }
         $rows = array_merge($rows, $results);
     }
     if (!$areas || in_array('tracksteams', $areas)) {
         $query = $db->getQuery(true);
         switch ($phrase) {
             case 'exact':
                 $string = $db->Quote('%' . $db->escape($text, true) . '%', false);
                 $query->where('LOWER(t.name) LIKE ' . $string);
                 break;
             case 'all':
             case 'any':
             default:
                 $words = explode(' ', $text);
                 $wheres = array();
                 foreach ($words as $word) {
                     $word = $db->Quote('%' . $db->escape($word, true) . '%', false);
                     $wheres[] = 'LOWER(t.name) LIKE ' . $word;
                 }
                 $query->where('(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')');
                 break;
         }
         switch ($ordering) {
             case 'alpha':
                 $query->order('t.name ASC');
                 break;
             case 'oldest':
             case 'popular':
             case 'newest':
             default:
                 $query->order('t.name ASC');
         }
         $query->select('t.name AS title')->select('CONCAT_WS( " / ", ' . $db->Quote($section) . ', ' . $db->Quote(JText::_('PLG_SEARCH_TRACKS_TEAMS')) . ' ) AS section')->select('CASE WHEN CHAR_LENGTH( t.alias ) THEN CONCAT_WS( \':\', t.id, t.alias ) ELSE t.id END AS slug')->select('NULL AS created')->select('"2" AS browsernav')->from('#__tracks_teams AS t');
         $db->setQuery($query, 0, $limit);
         $results = $db->loadObjectList();
         foreach ($results as $key => $row) {
             $results[$key]->href = TrackslibHelperRoute::getTeamRoute($row->slug);
         }
         $rows = array_merge($rows, $results);
     }
     if (!$areas || in_array('tracksprojects', $areas)) {
         $query = $db->getQuery(true);
         switch ($phrase) {
             case 'exact':
                 $string = $db->Quote('%' . $db->escape($text, true) . '%', false);
                 $query->where('LOWER(p.name) LIKE ' . $string);
                 break;
             case 'all':
             case 'any':
             default:
                 $words = explode(' ', $text);
                 $wheres = array();
                 foreach ($words as $word) {
                     $word = $db->Quote('%' . $db->escape($word, true) . '%', false);
                     $wheres[] = 'LOWER(p.name) LIKE ' . $word;
                 }
                 $query->where('(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')');
                 break;
         }
         switch ($ordering) {
             case 'alpha':
                 $query->order('p.name ASC');
                 break;
             case 'oldest':
             case 'popular':
             case 'newest':
             default:
                 $query->order('p.name ASC');
         }
         $query->select('p.name AS title')->select('CONCAT_WS( " / ", ' . $db->Quote($section) . ', ' . $db->Quote(JText::_('PLG_SEARCH_TRACKS_PROJECTS')) . ' ) AS section')->select('CASE WHEN CHAR_LENGTH( p.alias ) THEN CONCAT_WS( \':\', p.id, p.alias ) ELSE p.id END AS slug')->select('NULL AS created')->select(' "2" AS browsernav')->from('#__tracks_projects AS p');
         $db->setQuery($query, 0, $limit);
         $results = $db->loadObjectList();
         foreach ($results as $key => $row) {
             $results[$key]->href = TrackslibHelperRoute::getProjectRoute($row->slug);
         }
         $rows = array_merge($rows, $results);
     }
     if (!$areas || in_array('tracksrounds', $areas)) {
         $query = $db->getQuery(true);
         switch ($phrase) {
             case 'exact':
                 $string = $db->Quote('%' . $db->escape($text, true) . '%', false);
                 $query->where('LOWER(r.name) LIKE ' . $string);
                 break;
             case 'all':
             case 'any':
             default:
                 $words = explode(' ', $text);
                 $wheres = array();
                 foreach ($words as $word) {
                     $word = $db->Quote('%' . $db->escape($word, true) . '%', false);
                     $wheres[] = 'LOWER(r.name) LIKE ' . $word;
                 }
                 $query->where('(' . implode($phrase == 'all' ? ') AND (' : ') OR (', $wheres) . ')');
                 break;
         }
         switch ($ordering) {
             case 'alpha':
                 $query->order('r.name ASC');
                 break;
             case 'oldest':
             case 'popular':
             case 'newest':
             default:
                 $query->order('r.name ASC');
         }
         $query->select('r.name AS title')->select('CONCAT_WS( " / ", ' . $db->Quote($section) . ', ' . $db->Quote(JText::_('PLG_SEARCH_TRACKS_ROUNDS')) . ' ) AS section')->select('CASE WHEN CHAR_LENGTH( r.alias ) THEN CONCAT_WS( \':\', r.id, r.alias ) ELSE r.id END AS slug')->select('NULL AS created')->select('"2" AS browsernav')->from('#__tracks_rounds AS r');
         $db->setQuery($query, 0, $limit);
         $results = $db->loadObjectList();
         foreach ($results as $key => $row) {
             $results[$key]->href = TrackslibHelperRoute::getRoundRoute($row->slug);
         }
         $rows = array_merge($rows, $results);
     }
     return $rows;
 }
Esempio n. 4
0
						<?php 
        }
        ?>
					<?php 
    }
    ?>
				</td>
			</tr>
		<?php 
}
?>
		</tbody>
	</table>
	<div class="icalbutton">
		<a href="<?php 
echo JRoute::_(TrackslibHelperRoute::getProjectRoute($this->project->slug) . '&format=ical');
?>
"
		   title="<?php 
echo JText::_('COM_TRACKS_ICAL_EXPORT');
?>
">
			<img src="<?php 
echo JURI::root() . '/media/com_tracks/images/ical.gif';
?>
"
			     alt="<?php 
echo JText::_('COM_TRACKS_ICAL_EXPORT');
?>
"/>
		</a>