/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. defined('_JEXEC') or die('Restricted access');
  14. require_once(dirname(__FILE__).DS.'helper.php');
  15. require_once(JPATH_SITE.DS.'components'.DS.'com_joomleague'.DS.'joomleague.core.php');
  16. $document = JFactory::getDocument();
  17. //add css file
  18. $document->addStyleSheet(JUri::base().'modules/mod_joomleague_birthday/css/mod_joomleague_birthday.css');
  19. // Prevent that result is null when either $players or $crew is null by casting each to an array.
  20. $persons = array_merge((array)$players, (array)$crew);
  21. if(count($persons)>1) $persons = jl_birthday_sort($persons, array("n+days_to_birthday", "n".$params->get('sort_order')."age"), false);
  22. $k=0;
  23. $counter=0;
  24. ?>
  25. <table class="birthday">
  26. <?php
  27. if(count($persons) > 0) {
  28. foreach ($persons AS $person) {
  29. if (($params->get('limit')> 0) && ($counter == intval($params->get('limit')))) break;
  30. $class = ($k == 0)? $params->get('sectiontableentry1') : $params->get('sectiontableentry2');
  31. $thispic = "";
  32. $flag = $params->get('show_player_flag')? Countries::getCountryFlag($person['country']) . "&nbsp;" : "";
  33. $text = htmlspecialchars(JoomleagueHelper::formatName(null, $person['firstname'],
  34. $person['nickname'],
  35. $person['lastname'],
  36. $params->get("name_format")), ENT_QUOTES, 'UTF-8');
  37. $usedname = $flag.$text;
  38. $person_link = "";
  39. $person_type = $person['type'];
  40. if($person_type==1) {
  41. $person_link = JoomleagueHelperRoute::getPlayerRoute($person['project_id'],
  42. $person['team_id'],
  43. $person['id']);
  44. } else if($person_type==2) {
  45. $person_link = JoomleagueHelperRoute::getStaffRoute($person['project_id'],
  46. $person['team_id'],
  47. $person['id']);
  48. } else if($person_type==3) {
  49. $person_link = JoomleagueHelperRoute::getRefereeRoute($person['project_id'],
  50. $person['team_id'],
  51. $person['id']);
  52. }
  53. $showname = JHtml::link( $person_link, $usedname );
  54. ?>
  55. <tr class="<?php echo $params->get('heading_style');?>">
  56. <td class="birthday"><?php echo $showname;?></td>
  57. </tr>
  58. <tr class="<?php echo $class;?>">
  59. <td class="birthday">
  60. <?php
  61. if ($params->get('show_picture')==1) {
  62. if (file_exists(JPATH_BASE.'/'.$person['picture'])&&$person['picture']!='') {
  63. $thispic = $person['picture'];
  64. }
  65. elseif (file_exists(JPATH_BASE.'/'.$person['default_picture'])&&$person['default_picture']!='') {
  66. $thispic = $person['default_picture'];
  67. }
  68. echo '<img src="'.JUri::base().$thispic.'" alt="'.$text.'" title="'.$text.'"';
  69. if ($params->get('picture_width') != '') echo ' width="'.$params->get('picture_width').'"';
  70. echo ' /><br />';
  71. }
  72. switch ($person['days_to_birthday']) {
  73. case 0: $whenmessage = JText::_($params->get('todaymessage'));break;
  74. case 1: $whenmessage = JText::_($params->get('tomorrowmessage'));break;
  75. default: $whenmessage = str_replace('%DAYS_TO%', $person['days_to_birthday'], trim(JText::_($params->get('futuremessage'))));break;
  76. }
  77. $birthdaytext = htmlentities(trim(JText::_($params->get('birthdaytext'))), ENT_COMPAT , 'UTF-8');
  78. $dayformat = htmlentities(trim($params->get('dayformat')));
  79. $birthdayformat = htmlentities(trim($params->get('birthdayformat')));
  80. $birthdaytext = str_replace('%WHEN%', $whenmessage, $birthdaytext);
  81. $birthdaytext = str_replace('%AGE%', $person['age'], $birthdaytext);
  82. $birthdaytext = str_replace('%DATE%', JHtml::_('date', $person['year'].'-'.$person['daymonth'], $dayformat, $params->get('time_zone')), $birthdaytext);
  83. $birthdaytext = str_replace('%DATE_OF_BIRTH%', JHtml::_('date', $person['date_of_birth'], $birthdayformat, $params->get('time_zone')), $birthdaytext);
  84. $birthdaytext = str_replace('%BR%', '<br />', $birthdaytext);
  85. $birthdaytext = str_replace('%BOLD%', '<b>', $birthdaytext);
  86. $birthdaytext = str_replace('%BOLDEND%', '</b>', $birthdaytext);
  87. echo $birthdaytext;
  88. ?></td>
  89. </tr>
  90. <?php
  91. $k = 1 - $k;
  92. $counter++;
  93. }
  94. }
  95. else {
  96. ?>
  97. <tr>
  98. <td class="birthday"><?php echo''.str_replace('%DAYS%', $params->get('maxdays'), htmlentities(trim($params->get('not_found_text')))).''; ?></td>
  99. </tr>
  100. <?php } ?>
  101. </table>