PageRenderTime 29ms CodeModel.GetById 6ms RepoModel.GetById 0ms app.codeStats 1ms

/joomla/modules/mod_jevents_cal/tmpl/flatplus/calendar.php

https://gitlab.com/ricardosanchez/prueba
PHP | 346 lines | 277 code | 45 blank | 24 comment | 53 complexity | 6415f134bf8635fe302b62a00a0c669f MD5 | raw file
  1. <?php
  2. /**
  3. * copyright (C) 2008-2016 GWE Systems Ltd - All rights reserved
  4. */
  5. // Check to ensure this file is included in Joomla!
  6. defined('_JEXEC') or die();
  7. /**
  8. * HTML View class for the component frontend
  9. *
  10. * @static
  11. *
  12. */
  13. include_once (JPATH_SITE . "/modules/mod_jevents_cal/tmpl/default/calendar.php");
  14. class FlatplusModCalView extends DefaultModCalView
  15. {
  16. function _displayCalendarMod($time, $startday, $linkString, &$day_name, $monthMustHaveEvent = false, $basedate = false)
  17. {
  18. $db = JFactory::getDBO();
  19. $cfg = JEVConfig::getInstance();
  20. $compname = JEV_COM_COMPONENT;
  21. $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
  22. $colorscheme = $params->get("colourscheme", "red");
  23. $cal_day = date("d", $time);
  24. // $cal_year=date("Y",$time);
  25. // $cal_month=date("m",$time);
  26. // list($cal_year,$cal_month,$cal_day) = JEVHelper::getYMD();
  27. if (!$basedate)
  28. $basedate = $time;
  29. $base_year = date("Y", $basedate);
  30. $base_month = date("m", $basedate);
  31. $basefirst_of_month = JevDate::mktime(0, 0, 0, $base_month, 1, $base_year);
  32. $requestYear = JFactory::getApplication()->input->getInt("year", 0);
  33. $requestMonth = JFactory::getApplication()->input->getInt("month", 0);
  34. // special case when site link set the dates for the mini-calendar in the URL but not in the ajax request
  35. if ($requestMonth && $requestYear && JFactory::getApplication()->input->getString("task", "") != "modcal.ajax" && $this->modparams->get("minical_usedate", 0))
  36. {
  37. $requestDay = JFactory::getApplication()->input->getInt("day", 1);
  38. $requestTime = JevDate::mktime(0, 0, 0, $requestMonth, $requestDay, $requestYear);
  39. if ($time - $basedate > 100000)
  40. $requestTime = JevDate::strtotime("+1 month", $requestTime);
  41. else if ($time - $basedate < - 100000)
  42. $requestTime = JevDate::strtotime("-1 month", $requestTime);
  43. $cal_year = date("Y", $requestTime);
  44. $cal_month = date("m", $requestTime);
  45. $base_year = $requestYear;
  46. $base_month = $requestMonth;
  47. $basefirst_of_month = JevDate::mktime(0, 0, 0, $requestMonth, $requestDay, $requestYear);
  48. } else
  49. {
  50. $cal_year = date("Y", $time);
  51. $cal_month = date("m", $time);
  52. }
  53. $base_prev_month = $base_month - 1;
  54. $base_next_month = $base_month + 1;
  55. $base_next_month_year = $base_year;
  56. $base_prev_month_year = $base_year;
  57. if ($base_prev_month == 0)
  58. {
  59. $base_prev_month = 12;
  60. $base_prev_month_year -= 1;
  61. }
  62. if ($base_next_month == 13)
  63. {
  64. $base_next_month = 1;
  65. $base_next_month_year += 1;
  66. }
  67. $reg = JFactory::getConfig();
  68. $reg->set("jev.modparams", $this->modparams);
  69. if ($this->modparams->get("showtooltips", 0))
  70. {
  71. $data = $this->datamodel->getCalendarData($cal_year, $cal_month, 1, false, false);
  72. $this->hasTooltips = true;
  73. }
  74. else
  75. {
  76. $data = $this->datamodel->getCalendarData($cal_year, $cal_month, 1, true, $this->modparams->get("noeventcheck", 0));
  77. }
  78. $reg->set("jev.modparams", false);
  79. $width = $this->modparams->get("mod_cal_width", "165px");
  80. $height = $this->modparams->get("mod_cal_height", "auto");
  81. $rowheight = $this->modparams->get("mod_cal_rowheight", "auto");
  82. $month_name = JEVHelper::getMonthName($cal_month);
  83. $to_day = date("Y-m-d", $this->timeWithOffset);
  84. $today = JevDate::mktime(0, 0, 0, $cal_month, $cal_day, $cal_year);
  85. $cal_prev_month = $cal_month - 1;
  86. $cal_next_month = $cal_month + 1;
  87. $cal_next_month_year = $cal_year;
  88. $cal_prev_month_year = $cal_year;
  89. // additional EBS
  90. if ($cal_prev_month == 0)
  91. {
  92. $cal_prev_month = 12;
  93. $cal_prev_month_year -= 1;
  94. }
  95. if ($cal_next_month == 13)
  96. {
  97. $cal_next_month = 1;
  98. $cal_next_month_year += 1;
  99. }
  100. $viewname = $this->getTheme();
  101. $viewpath = JURI::root(true) . "/components/$compname/views/" . $viewname . "/assets";
  102. $viewimages = $viewpath . "/images";
  103. $linkpref = "index.php?option=$compname&Itemid=" . $this->myItemid . $this->cat . "&task=";
  104. $jev_component_name = JEV_COM_COMPONENT;
  105. $this->_navigationJS($this->_modid);
  106. $scriptlinks = "";
  107. if ($this->minical_prevmonth)
  108. {
  109. $linkprevious = htmlentities(JURI::base() . "index.php?option=$jev_component_name&task=modcal.ajax&day=1&month=$base_prev_month&year=$base_prev_month_year&modid=$this->_modid&tmpl=component" . $this->cat);
  110. $scriptlinks .= "linkprevious = '".$linkprevious."';\n";
  111. $linkprevious = '<img border="0" title="' . JText::_("JEV_PREVIOUSMONTH") . '" alt="' . JText::_("JEV_LAST_MONTH") . '" class="mod_events_link" src="' . $viewimages . '/mini_arrowleft.gif" onmousedown="callNavigation(\'' . $linkprevious . '\');" ontouchstart="callNavigation(\'' . $linkprevious . '\');" />';
  112. }
  113. else
  114. {
  115. $linkprevious = "";
  116. }
  117. if ($this->minical_actmonth == 1)
  118. {
  119. $linkcurrent = $linkpref . "month.calendar&day=$cal_day&month=$cal_month&year=$cal_year";
  120. $linkcurrent = JRoute::_($linkcurrent);
  121. $linkcurrent = $this->htmlLinkCloaking($linkcurrent, $month_name . " " . $cal_year, array(
  122. "style" => "text-decoration:none;color:inherit;"
  123. ));
  124. }
  125. elseif ($this->minical_actmonth == 2)
  126. {
  127. $linkcurrent = $month_name . " " . $cal_year;
  128. }
  129. else
  130. {
  131. $linkcurrent = "";
  132. }
  133. /*
  134. * $linknext = $linkpref."month.calendar&day=$cal_day&month=$cal_next_month&year=$cal_next_month_year"; $linknext = JRoute::_($linknext); $linknext = $this->htmlLinkCloaking($linknext, '<img border="0" title="' . JText::_("JEV_NEXT_MONTH") . '" alt="' . JText::_("JEV_NEXT_MONTH") . '" src="'.$viewimages.'/mini_arrowright.gif"/>' );
  135. */
  136. $this->_navigationJS($this->_modid);
  137. if ($this->minical_nextmonth)
  138. {
  139. $linknext = htmlentities(JURI::base() . "index.php?option=$jev_component_name&task=modcal.ajax&day=1&month=$base_next_month&year=$base_next_month_year&modid=$this->_modid&tmpl=component" . $this->cat);
  140. $scriptlinks .= "linknext = '".$linknext."';\n";
  141. $linknext = '<img border="0" title="' . JText::_("JEV_NEXT_MONTH") . '" alt="' . JText::_("JEV_NEXT_MONTH") . '" class="mod_events_link" src="' . $viewimages . '/mini_arrowright.gif" onmousedown="callNavigation(\'' . $linknext . '\');" ontouchstart="callNavigation(\'' . $linknext . '\');" />';
  142. }
  143. else
  144. {
  145. $linknext = "";
  146. }
  147. $class= "cal_".$base_month."_".$this->_modid;
  148. $content = '
  149. <div id="flatcal_minical" class="jev_color_' . $colorscheme . '">
  150. <table width="' . $width . '" cellspacing="1" cellpadding="0" border="0" align="center" class="flatcal_main_t">
  151. <tr>
  152. <td style="vertical-align: top;">';
  153. if ($this->minical_showlink)
  154. {
  155. $content .= '
  156. <table style="width:100%;" cellspacing="0" cellpadding="2" border="0" class="flatcal_navbar">
  157. <tr>
  158. <td class="link_prev">
  159. ' . $linkprevious . '
  160. </td>
  161. <td class="flatcal_month_label">
  162. ' . $linkcurrent . '
  163. </td>
  164. <td class="link_next">
  165. ' . $linknext . '
  166. </td>
  167. </tr>
  168. </table>';
  169. }
  170. $content .= '<table style="width:100%; " class="flatcal_weekdays">';
  171. $lf = "\n";
  172. // Days name rows - with blank week no.
  173. $content .= "<tr>\n";
  174. for ($i = 0; $i < 7; $i ++)
  175. {
  176. $content .= "<td class='flatcal_weekdays'>" . $day_name [($i + $startday) % 7] . "</td>" . $lf;
  177. }
  178. $content .= "</tr>\n";
  179. $datacount = count($data ["dates"]);
  180. $dn = 0;
  181. for ($w = 0; $w < 6 && $dn < $datacount; $w ++)
  182. {
  183. $content .= "<tr style='height:$rowheight;'>\n";
  184. // the week column
  185. list ( $week, $link ) = each($data ['weeks']);
  186. for ($d = 0; $d < 7 && $dn < $datacount; $d ++)
  187. {
  188. $currentDay = $data ["dates"] [$dn];
  189. switch ($currentDay ["monthType"]) {
  190. case "prior" :
  191. case "following" :
  192. $content .= "<td class='flatcal_othermonth'/>\n";
  193. break;
  194. case "current" :
  195. $dayOfWeek = JevDate::strftime("%w", $currentDay ["cellDate"]);
  196. $class = ($currentDay ["today"]) ? "flatcal_todaycell" : "flatcal_daycell";
  197. $linkclass = "flatcal_daylink";
  198. if ($dayOfWeek == 0 && !$currentDay ["today"])
  199. {
  200. $class = "flatcal_sundaycell";
  201. $linkclass = "flatcal_sundaylink";
  202. }
  203. if ($currentDay ["events"] || $this->modparams->get("noeventcheck", 0))
  204. {
  205. $linkclass = "flatcal_busylink";
  206. }
  207. $content .= "<td class='" . $class . "'>\n";
  208. // To make sure there are no strict php error messages when currentDay is changed we add second method
  209. if (method_exists($this, "getTooltipReference")){
  210. $tooltip = $this->getTooltipReference($currentDay, array('class'=>$linkclass));
  211. }
  212. else {
  213. $tooltip = $this->getTooltip($currentDay, array('class'=>$linkclass));
  214. }
  215. if ($tooltip)
  216. {
  217. $content .= $tooltip;
  218. }
  219. else
  220. {
  221. if ($this->modparams->get("emptydaylinks", 1) || $currentDay["events"] || $this->modparams->get("noeventcheck", 0))
  222. {
  223. $content .= $this->htmlLinkCloaking($currentDay["link"], $currentDay['d'], array('class' => $linkclass, 'title' => JText::_('JEV_CLICK_TOSWITCH_DAY')));
  224. }
  225. else
  226. {
  227. $content .= $currentDay['d'];
  228. }
  229. }
  230. $content .= "</td>\n";
  231. break;
  232. }
  233. $dn ++;
  234. }
  235. $content .= "</tr>\n";
  236. }
  237. $content .= "</table>\n";
  238. $content .= "</td></tr><tr class='full_cal_link'><td> </td></tr></table></div>\n";
  239. if ($scriptlinks!=""){
  240. $content .= "<script style='text/javascript'>xyz=1;".$scriptlinks."zyx=1;</script>";
  241. }
  242. return $content;
  243. }
  244. protected function getTooltip($currentDay, $linkattr) {
  245. $tooltip = "";
  246. if (!isset($currentDay["events"]) || !is_array($currentDay["events"]) || count($currentDay["events"])==0){
  247. return $tooltip;
  248. }
  249. // This loads jQuery too!
  250. JevHtmlBootstrap::framework();
  251. foreach ($currentDay["events"] as $event) {
  252. $link = $event->viewDetailLink($event->yup(), $event->mup(), $event->dup(), true, $this->myItemid);//JRoute::_('index.php?option='.$jev_component_name.'&Itemid='.$this->myItemid.$this->cat.'&task=icalrepeat.detail';
  253. $tooltip .= "<a href='".$link."'>". $event->title()."</a><br/>";
  254. }
  255. $tooltip .= "<hr class='jev-click-to-open'/><small class='jev-click-to-open'>".JText::_("JEV_EVENTS_CLICK_EVENT_FOR_MORE_DETAILS",true)."</small>";
  256. $tipTitle = '<div class="jevtt_title" >'.JText::_("JEV_EVENTS_THIS_DAY",true) .'</div>';
  257. $tipText = '<div class="jevtt_text">'.$tooltip.'</div>';
  258. $tooltip = htmlspecialchars($tipTitle.$tipText,ENT_QUOTES);
  259. $link = $this->htmlLinkCloaking($currentDay["link"], $currentDay['d'], $linkattr);
  260. $tooltip = '<span class="editlinktip hasjevtip" title="'.$tooltip.'" >'.$link.'</span>';
  261. static $script;
  262. if (!isset($script )){
  263. $script = true;
  264. JevHtmlBootstrap::popover('.hasjevtip' , array("trigger"=>"hover focus", "placement"=>"top", "container"=>"body", "delay"=> array( "show"=> 150, "hide"=> 150 )));
  265. }
  266. return $tooltip;
  267. }
  268. protected function getTooltipReference(&$currentDay, $linkattr) {
  269. $tooltip = "";
  270. if (!isset($currentDay["events"]) || !is_array($currentDay["events"]) || count($currentDay["events"])==0){
  271. return $tooltip;
  272. }
  273. // This loads jQuery too!
  274. JevHtmlBootstrap::framework();
  275. // This needs core bootstrap css not our namespaced version!
  276. $params = JComponentHelper::getParams(JEV_COM_COMPONENT);
  277. if ($params->get("fpcolourscheme", 1)) {
  278. JHtmlBootstrap::loadCss();
  279. }
  280. foreach ($currentDay["events"] as $event) {
  281. $link = $event->viewDetailLink($event->yup(), $event->mup(), $event->dup(), true, $this->myItemid);//JRoute::_('index.php?option='.$jev_component_name.'&Itemid='.$this->myItemid.$this->cat.'&task=icalrepeat.detail';
  282. if (count ($currentDay["events"])==1 && JComponentHelper::getParams("com_jevents")->get("redirect_detail",1)){
  283. $currentDay["link"] = $link;
  284. }
  285. $tooltip .= "<a href='".$link."'>". $event->title()."</a><br/>";
  286. }
  287. $tooltip .= "<hr class='jev-click-to-open'/><small class='jev-click-to-open'>".JText::_("JEV_EVENTS_CLICK_EVENT_FOR_MORE_DETAILS",true)."</small>";
  288. $tipTitle = '<div class="jevtt_title" >'.JText::_("JEV_EVENTS_THIS_DAY",true) .'</div>';
  289. $tipText = '<div class="jevtt_text">'.$tooltip.'</div>';
  290. $tooltip = htmlspecialchars($tipTitle.$tipText,ENT_QUOTES);
  291. $link = $this->htmlLinkCloaking($currentDay["link"], $currentDay['d'], $linkattr);
  292. $tooltip = '<span class="editlinktip hasjevtip" title="'.$tooltip.'" >'.$link.'</span>';
  293. static $script;
  294. if (!isset($script )){
  295. $script = true;
  296. JevHtmlBootstrap::popover('.hasjevtip' , array("trigger"=>"hover focus", "placement"=>"top", "container"=>"body", "delay"=> array( "show"=> 150, "hide"=> 150 )));
  297. }
  298. return $tooltip;
  299. }
  300. }