PageRenderTime 16ms CodeModel.GetById 8ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/com_joomleague/components/com_joomleague/modules/mod_joomleague_birthday/mod_joomleague_birthday.php

https://gitlab.com/volleyuisp/joomleague
PHP | 109 lines | 88 code | 8 blank | 13 comment | 17 complexity | dfad7786a8dd80845806329d46fd0425 MD5 | raw file
  1<?php
  2/**
  3 * @package	 	Joomla
  4 * @subpackage  Joomleague results module
  5 * @copyright	Copyright (C) 2005-2014 joomleague.at. All rights reserved.
  6 * @license	 	GNU/GPL, see LICENSE.php
  7 * Joomla! is free software. This version may have been modified pursuant to the
  8 * GNU General Public License, and as distributed it includes or is derivative
  9 * of works licensed under the GNU General Public License or other free or open
 10 * source software licenses. See COPYRIGHT.php for copyright notices and
 11 * details.
 12 */
 13
 14defined('_JEXEC') or die('Restricted access');
 15require_once(dirname(__FILE__).DS.'helper.php');
 16require_once(JPATH_SITE.DS.'components'.DS.'com_joomleague'.DS.'joomleague.core.php');
 17$document = JFactory::getDocument();
 18
 19//add css file
 20$document->addStyleSheet(JUri::base().'modules/mod_joomleague_birthday/css/mod_joomleague_birthday.css');
 21
 22// Prevent that result is null when either $players or $crew is null by casting each to an array.
 23$persons = array_merge((array)$players, (array)$crew);
 24if(count($persons)>1)   $persons = jl_birthday_sort($persons, array("n+days_to_birthday", "n".$params->get('sort_order')."age"), false);
 25
 26$k=0;
 27$counter=0;
 28?>
 29<table class="birthday">
 30<?php
 31if(count($persons) > 0) {
 32	foreach ($persons AS $person) {
 33		if (($params->get('limit')> 0) && ($counter == intval($params->get('limit')))) break;
 34		$class = ($k == 0)? $params->get('sectiontableentry1') : $params->get('sectiontableentry2');
 35
 36		$thispic = "";
 37		$flag = $params->get('show_player_flag')? Countries::getCountryFlag($person['country']) . "&nbsp;" : "";
 38		$text = htmlspecialchars(JoomleagueHelper::formatName(null, $person['firstname'], 
 39													$person['nickname'], 
 40													$person['lastname'], 
 41													$params->get("name_format")), ENT_QUOTES, 'UTF-8');
 42		$usedname = $flag.$text;
 43		
 44		$person_link = "";
 45		$person_type = $person['type'];
 46		if($person_type==1) {
 47			$person_link = JoomleagueHelperRoute::getPlayerRoute($person['project_id'],
 48																$person['team_id'],
 49																$person['id']);
 50		} else if($person_type==2) {
 51			$person_link = JoomleagueHelperRoute::getStaffRoute($person['project_id'],
 52																$person['team_id'],
 53																$person['id']);
 54		} else if($person_type==3) {
 55			$person_link = JoomleagueHelperRoute::getRefereeRoute($person['project_id'],
 56																$person['team_id'],
 57																$person['id']);
 58		}
 59		$showname = JHtml::link( $person_link, $usedname );
 60		?>
 61	<tr class="<?php echo $params->get('heading_style');?>">
 62		<td class="birthday"><?php echo $showname;?></td>
 63	</tr>
 64	<tr class="<?php echo $class;?>">
 65		<td class="birthday">
 66		<?php
 67		if ($params->get('show_picture')==1) {
 68			if (file_exists(JPATH_BASE.'/'.$person['picture'])&&$person['picture']!='') {
 69				$thispic = $person['picture'];
 70			}
 71			elseif (file_exists(JPATH_BASE.'/'.$person['default_picture'])&&$person['default_picture']!='') {
 72				$thispic = $person['default_picture'];
 73			}
 74			echo '<img src="'.JUri::base().$thispic.'" alt="'.$text.'" title="'.$text.'"';
 75			if ($params->get('picture_width') != '') echo ' width="'.$params->get('picture_width').'"';
 76			echo ' /><br />';
 77
 78		}
 79		switch ($person['days_to_birthday']) {
 80			case 0: $whenmessage = JText::_($params->get('todaymessage'));break;
 81			case 1: $whenmessage = JText::_($params->get('tomorrowmessage'));break;
 82			default: $whenmessage = str_replace('%DAYS_TO%', $person['days_to_birthday'], trim(JText::_($params->get('futuremessage'))));break;
 83		}
 84		$birthdaytext = htmlentities(trim(JText::_($params->get('birthdaytext'))), ENT_COMPAT , 'UTF-8');
 85		$dayformat = htmlentities(trim($params->get('dayformat')));
 86		$birthdayformat = htmlentities(trim($params->get('birthdayformat')));
 87		$birthdaytext = str_replace('%WHEN%', $whenmessage, $birthdaytext);
 88		$birthdaytext = str_replace('%AGE%', $person['age'], $birthdaytext);
 89		$birthdaytext = str_replace('%DATE%', JHtml::_('date', $person['year'].'-'.$person['daymonth'], $dayformat, $params->get('time_zone')), $birthdaytext);
 90		$birthdaytext = str_replace('%DATE_OF_BIRTH%', JHtml::_('date', $person['date_of_birth'], $birthdayformat, $params->get('time_zone')), $birthdaytext);
 91		$birthdaytext = str_replace('%BR%', '<br />', $birthdaytext);
 92		$birthdaytext = str_replace('%BOLD%', '<b>', $birthdaytext);
 93		$birthdaytext = str_replace('%BOLDEND%', '</b>', $birthdaytext);
 94			
 95		echo $birthdaytext;
 96		?></td>
 97	</tr>
 98	<?php
 99	$k = 1 - $k;
100	$counter++;
101	}
102}
103else {
104?>
105<tr>
106	<td class="birthday"><?php echo''.str_replace('%DAYS%', $params->get('maxdays'), htmlentities(trim($params->get('not_found_text')))).''; ?></td>
107</tr>
108<?php } ?>
109</table>