PageRenderTime 38ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/iCagenda/admin/models/fields/modal/icalert_msg.php

https://gitlab.com/Alzakath/icagenda
PHP | 192 lines | 142 code | 25 blank | 25 comment | 30 complexity | c65f6d86c3675ec4f441551bac094397 MD5 | raw file
  1. <?php
  2. /**
  3. *------------------------------------------------------------------------------
  4. * iCagenda v3 by Jooml!C - Events Management Extension for Joomla! 2.5 / 3.x
  5. *------------------------------------------------------------------------------
  6. * @package com_icagenda
  7. * @copyright Copyright (c)2012-2015 Cyril Rezé, Jooml!C - All rights reserved
  8. *
  9. * @license GNU General Public License version 3 or later; see LICENSE.txt
  10. * @author Cyril Rezé (Lyr!C)
  11. * @link http://www.joomlic.com
  12. *
  13. * @version 3.3.3 2014-04-12
  14. * @since 3.2.8
  15. *------------------------------------------------------------------------------
  16. */
  17. // No direct access to this file
  18. defined('_JEXEC') or die();
  19. jimport( 'joomla.filesystem.path' );
  20. jimport('joomla.form.formfield');
  21. class JFormFieldModal_icalert_msg extends JFormField
  22. {
  23. protected $type='modal_icalert_msg';
  24. protected function getLabel()
  25. {
  26. return ' ';
  27. }
  28. protected function getInput()
  29. {
  30. $replace = array("jform", "params", "[", "]");
  31. $name_input = str_replace($replace, "", $this->name);
  32. $get_error = explode('_', $name_input);
  33. $error = $get_error['1'];
  34. $name = $get_error['0'];
  35. $url=JPATH_SITE.'/components/com_icagenda/themes/packs';
  36. // Set Function to condition to be checked
  37. $events_php=$this->getList($url);
  38. $cal_date=$this->getCalDate($url);
  39. if ($name == 'eventsfile')
  40. {
  41. $list = $events_php;
  42. $doc_url = 'http://www.icagenda.com/theme-pack-upgrade/3-2-8-new-option-all-dates';
  43. $parent_field = 'datesDisplay';
  44. $action_value = '1';
  45. }
  46. elseif ($name == 'caldate')
  47. {
  48. $list = $cal_date;
  49. $doc_url = 'http://www.icagenda.com/theme-pack-upgrade/3-3-3-change-cal-date-to-data-cal-date';
  50. $parent_field = 'setTodayTimezone';
  51. $action_value = '';
  52. }
  53. $span_style = 'input-xlarge';
  54. if (version_compare(JVERSION, '3.0', 'lt')) {
  55. $listP = implode('<br /> - ', $list);
  56. $setlist = ' - '.$listP.' ';
  57. } else {
  58. $listP = implode('</li><li>', $list);
  59. $setlist = '<ul><li>'.$listP.'</li></ul>';
  60. // $span_style = 'span8';
  61. }
  62. $html = array();
  63. if (count($list) >= 1)
  64. {
  65. $html[] = '<div id="icalert_'.$this->id.'" class="'.$span_style.' alert alert-error" style="clear:both">';
  66. $html[] = '<b>'.JText::_( $this->title ).'</b>';
  67. $html[] = '<p>';
  68. $html[] = JText::_( $this->description ) . ' <a class="modal" rel="{size: {x: 700, y: 500}, handler:\'iframe\'}" href="'.$doc_url.'">' .JText::_( 'IC_MORE_INFORMATION' ). '</a>';
  69. $html[] = '</p>';
  70. if ($this->id == 'jform_params_'.$name.'_error')
  71. {
  72. $html[] = '<p>';
  73. $html[] = '<b><i>'.JText::_( 'COM_ICAGENDA_EVENTS_PHPFILE_MISSING_PACKS_LIST' ).'</i></b><br />';
  74. $html[] = $setlist;
  75. $html[] = '</p>';
  76. }
  77. $html[] = '</div>';
  78. $html[] = '<script type="text/javascript">';
  79. $html[] = ' var icdisplay = document.getElementById("jform_params_'.$parent_field.'").value;';
  80. $html[] = ' document.getElementById("icalert_'.$this->id.'").style.display = "none";';
  81. $html[] = ' if (icdisplay == "'.$action_value.'") {';
  82. $html[] = ' document.getElementById("icalert_'.$this->id.'").style.display = "block";';
  83. $html[] = ' }';
  84. $html[] = ' function icalert()';
  85. $html[] = ' {';
  86. $html[] = ' var icdisplay = document.getElementById("jform_params_'.$parent_field.'").value;';
  87. $html[] = ' document.getElementById("icalert_'.$this->id.'").style.display = "none";';
  88. $html[] = ' if (icdisplay == "'.$action_value.'") {';
  89. $html[] = ' document.getElementById("icalert_'.$this->id.'").style.display = "block";';
  90. $html[] = ' }';
  91. $html[] = ' }';
  92. $html[] = '</script>';
  93. }
  94. return implode("\n", $html);
  95. }
  96. /**
  97. * Function to check if the file 'THEME_events.php' exists in each Theme Pack
  98. */
  99. function getList($dirname)
  100. {
  101. $arrayfiles = Array();
  102. if(file_exists($dirname))
  103. {
  104. $handle = opendir($dirname);
  105. while (false !== ($file = readdir($handle)))
  106. {
  107. if ( !is_file($dirname.$file)
  108. && $file!= '.'
  109. && $file!='..'
  110. && $file!='index.php'
  111. && $file!='index.html'
  112. && $file!='.DS_Store'
  113. && $file!='.thumbs' )
  114. {
  115. if (!file_exists($dirname.'/'.$file.'/'.$file.'_events.php'))
  116. {
  117. array_push($arrayfiles,$file);
  118. }
  119. }
  120. }
  121. $handle = closedir($handle);
  122. }
  123. sort($arrayfiles);
  124. return $arrayfiles;
  125. }
  126. /**
  127. * Function to check if 'data-cal-date' is defined inside the file 'THEME_day.php' for each Theme Pack.
  128. * Returns an alert if deprecated 'cal_date' found.
  129. */
  130. function getCalDate($dirname)
  131. {
  132. $arrayfiles = Array();
  133. if (ini_get('allow_url_fopen'))
  134. {
  135. if (file_exists($dirname))
  136. {
  137. $handle = opendir($dirname);
  138. while (false !== ($file = readdir($handle)))
  139. {
  140. if ( !is_file($dirname.$file)
  141. && $file!= '.'
  142. && $file!='..'
  143. && $file!='index.php'
  144. && $file!='index.html'
  145. && $file!='.DS_Store'
  146. && $file!='.thumbs' )
  147. {
  148. $t_day = $dirname.'/'.$file.'/'.$file.'_day.php';
  149. $file_t_day = file_get_contents($t_day);
  150. if (!strpos($file_t_day, "cal_date")
  151. && !strpos($file_t_day, "data-cal-date"))
  152. {
  153. array_push($arrayfiles,$file);
  154. }
  155. elseif (strpos($file_t_day, "cal_date"))
  156. {
  157. array_push($arrayfiles,$file);
  158. }
  159. }
  160. }
  161. }
  162. $handle = closedir($handle);
  163. }
  164. sort($arrayfiles);
  165. return $arrayfiles;
  166. }
  167. }