PageRenderTime 52ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/components/com_jcalpro/sef_ext/com_jcalpro.php

https://gitlab.com/endomorphosis/OLAAaction
PHP | 245 lines | 165 code | 24 blank | 56 comment | 30 complexity | b0756420b67fbaee71d53a4c1d0d7168 MD5 | raw file
  1. <?php
  2. /*
  3. **********************************************
  4. Copyright (c) 2006-2010 Anything-Digital.com
  5. **********************************************
  6. JCal Pro is a fork of the existing Extcalendar component for Joomla!
  7. (com_extcal_0_9_2_RC4.zip from mamboguru.com).
  8. Extcal (http://sourceforge.net/projects/extcal) was renamed
  9. and adapted to become a Mambo/Joomla! component by
  10. Matthew Friedman, and further modified by David McKinnis
  11. (mamboguru.com) to repair some security holes.
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 2 of the License, or
  15. (at your option) any later version.
  16. This header must not be removed. Additional contributions/changes
  17. may be added to this header as long as no information is deleted.
  18. **********************************************
  19. $Id: com_jcalpro.php 667 2011-01-24 21:02:32Z jeffchannell $
  20. **********************************************
  21. Get the latest version of JCal Pro at:
  22. http://dev.anything-digital.com//
  23. **********************************************
  24. */
  25. defined( '_JEXEC' ) or die( 'Direct Access to this location is not allowed.' );
  26. // ------------------ standard plugin initialize function - don't change ---------------------------
  27. global $sh_LANG, $mainframe;
  28. $sefConfig = & shRouter::shGetConfig();
  29. $shLangName = '';
  30. $shLangIso = '';
  31. $title = array();
  32. $shItemidString = '';
  33. $dosef = shInitializePlugin( $lang, $shLangName, $shLangIso, $option);
  34. if ($dosef == false) return;
  35. // ------------------ standard plugin initialize function - don't change ---------------------------
  36. // include utility functions, shared with meta_ext plugin
  37. include_once( JPATH_ROOT.DS.'components'.DS.'com_jcalpro'.DS.'sef_ext'.DS.'com_jcalpro_lib.php');
  38. // ------------------ Load plugin language file ---------------------------------------------------
  39. $shLangIso = jclLoadPluginLanguage( 'com_jcalpro_lang', $shLangIso, '_JCL_SH404SEF_CALENDAR');
  40. // ------------------ End of loading plugin language file ------------------------------------------
  41. // ------------------ End of loading plugin language file ------------------------------------------
  42. // Update issue : as of 1.5.5 of sh404sef, we created sh404sef backend parameters for jcal
  43. // those params are used in this new version of the jcal plugin for sh404sef
  44. // howver, users upgrading their Jcal pro without upgrading their sh404sef will
  45. // experience errors. So we are making sure this does not happen here
  46. if (is_null( $sefConfig->jclInsertCalendarId)) {
  47. $sefConfig->jclInsertEventId = false;
  48. $sefConfig->jclInsertCategoryId = false;
  49. $sefConfig->jclInsertCalendarId = false;
  50. $sefConfig->jclInsertCalendarName = false;
  51. $sefConfig->jclInsertDate = false;
  52. $sefConfig->jclInsertDateInEventView = true;
  53. }
  54. // -----------------
  55. // get url variable
  56. $extmode = empty($extmode) ? null : $extmode;
  57. $event_mode = empty($event_mode) ? null : $event_mode;
  58. $cal_id = empty($cal_id) ? null : $cal_id;
  59. $cat_id = empty($cat_id) ? null : $cat_id;
  60. $cat_ext = empty($cat_ext) ? null : $cat_ext;
  61. $extid = empty($extid) ? null : $extid;
  62. $date = empty($date) ? null : $date;
  63. $view = empty($view) ? null : $view;
  64. // Build the root of the url
  65. $shName = shGetComponentPrefix($option);
  66. $shName = empty($shName) ? getMenuTitle($option, (isset($view) ? @$view : null), $Itemid ) : $shName;
  67. if ($sefConfig->jclInsertCalendarId && !empty( $cal_id) && !empty($shName) && $shName != '/') {
  68. $shName = $cal_id . $shName;
  69. }
  70. if ($sefConfig->jclInsertCalendarName && !empty($shName) && $shName != '/') {
  71. $title[] = $shName;
  72. $title[] = '/';
  73. }
  74. // build url
  75. // calendar can be set through url
  76. if (!empty( $cal_id)) {
  77. $calTitle = jclGetCalendarName( $cal_id, $option, $shLangName);
  78. if (!empty( $calTitle)) {
  79. $title[] = $calTitle;
  80. shRemoveFromGETVarsList('cal_id');
  81. }
  82. }
  83. // flag to avoid inserting date twice
  84. $dateInserted = false;
  85. // main display mode
  86. switch ($extmode) {
  87. default:
  88. $dosef = false;
  89. break;
  90. case '' :
  91. // to avoid the 'default' case
  92. shRemoveFromGETVarsList('view');
  93. break;
  94. case 'cal' :
  95. $title[] = $sh_LANG[$shLangIso]['_JCL_SH404SEF_MONTHLY'];
  96. $title[] = '/';
  97. shRemoveFromGETVarsList('extmode');
  98. shRemoveFromGETVarsList('view');
  99. break;
  100. case 'flat' :
  101. $title[] = $sh_LANG[$shLangIso]['_JCL_SH404SEF_FLAT'];
  102. $title[] = '/';
  103. shRemoveFromGETVarsList('extmode');
  104. shRemoveFromGETVarsList('view');
  105. break;
  106. case 'week' :
  107. $title[] = $sh_LANG[$shLangIso]['_JCL_SH404SEF_WEEKLY'];
  108. $title[] = '/';
  109. shRemoveFromGETVarsList('extmode');
  110. shRemoveFromGETVarsList('view');
  111. break;
  112. case 'day' :
  113. $title[] = $sh_LANG[$shLangIso]['_JCL_SH404SEF_DAYLY'];
  114. $title[] = '/';
  115. shRemoveFromGETVarsList('extmode');
  116. shRemoveFromGETVarsList('view');
  117. break;
  118. case 'cats' :
  119. $title[] = $sh_LANG[$shLangIso]['_JCL_SH404SEF_CATEGORIES'];
  120. $title[] = '/';
  121. shRemoveFromGETVarsList('extmode');
  122. shRemoveFromGETVarsList('view');
  123. break;
  124. case 'cat' :
  125. $catTitle = jclGetCategoryTitle( $cat_id, $cat_ext, $option, $shLangName);
  126. if (!empty( $catTitle)) {
  127. // if we have a category title, use it
  128. $title[] = $catTitle;
  129. shRemoveFromGETVarsList('cat_id');
  130. shRemoveFromGETVarsList('cat_ext');
  131. }
  132. shRemoveFromGETVarsList('extmode');
  133. shRemoveFromGETVarsList('view');
  134. break;
  135. case 'view' :
  136. $eventData = null;
  137. $eventTitle = jclGetEventData( $extid, $eventData, $option, $shLangName);
  138. if (!empty( $eventTitle)) {
  139. // optionnally insert date
  140. if ($sefConfig->jclInsertDateInEventView) {
  141. if (!function_exists( 'jcUTCDateToFormat')) {
  142. // we may be doing an auto-redirect, and functions.inc.php may not be loaded
  143. require_once (JPATH_ROOT .DS. 'components'.DS.'com_jcalpro'.DS.'include'.DS.'functions.inc.php');
  144. }
  145. $title[] = jcUTCDateToFormat($eventData->start_date, '%Y-%m-%d');
  146. shRemoveFromGETVarsList('date');
  147. $dateInserted = true;
  148. }
  149. // if we have an event title (we should), use it
  150. $title[] = $eventTitle;
  151. if (!empty($eventData->rec_id)) {
  152. // if a recurrence of an event, add id to segragate
  153. // from initial event
  154. $title[] = $extid;
  155. }
  156. shRemoveFromGETVarsList('extid');
  157. }
  158. shRemoveFromGETVarsList('extmode');
  159. shRemoveFromGETVarsList('view');
  160. break;
  161. case 'extcal_search' :
  162. $title[] = $sh_LANG[$shLangIso]['_JCL_SH404SEF_SEARCH'];
  163. $title[] = '/';
  164. shRemoveFromGETVarsList('extmode');
  165. shRemoveFromGETVarsList('view');
  166. break;
  167. case 'event' :
  168. switch ($event_mode) {
  169. case 'add' :
  170. $title[] = $sh_LANG[$shLangIso]['_JCL_SH404SEF_ADD_EVENT'];
  171. $title[] = '/';
  172. break;
  173. case 'edit' :
  174. $title[] = $sh_LANG[$shLangIso]['_JCL_SH404SEF_EDIT_EVENT'];
  175. $title[] = '/';
  176. break;
  177. case 'del' :
  178. $title[] = $sh_LANG[$shLangIso]['_JCL_SH404SEF_DELETE_EVENT'];
  179. $title[] = '/';
  180. break;
  181. case 'apr' :
  182. $title[] = $sh_LANG[$shLangIso]['_JCL_SH404SEF_APPROVE_EVENT'];
  183. $title[] = '/';
  184. break;
  185. default:
  186. $title[] = $sh_LANG[$shLangIso]['_JCL_SH404SEF_VIEW_EVENT'];
  187. $title[] = '/';
  188. break;
  189. }
  190. shRemoveFromGETVarsList('extmode');
  191. shRemoveFromGETVarsList('event_mode');
  192. shRemoveFromGETVarsList('view');
  193. break;
  194. }
  195. // insert requested date
  196. if ($sefConfig->jclInsertDate && !empty( $date) && !$dateInserted) {
  197. $title[] = $date;
  198. shRemoveFromGETVarsList('date');
  199. }
  200. // don't return an empty url
  201. if (empty( $title) && !empty($shName) && $shName != '/') {
  202. $title[] = $shName;
  203. $title[] = '/';
  204. }
  205. // remove standard variables
  206. shRemoveFromGETVarsList('option');
  207. if (!empty($Itemid)) {
  208. shRemoveFromGETVarsList('Itemid');
  209. }
  210. shRemoveFromGETVarsList('lang');
  211. // ------------------ standard plugin finalize function - don't change ---------------------------
  212. if ($dosef){
  213. $string = shFinalizePlugin( $string, $title, $shAppendString, $shItemidString,
  214. (isset($limit) ? @$limit : null), (isset($limitstart) ? @$limitstart : null),
  215. (isset($shLangName) ? @$shLangName : null));
  216. }
  217. // ------------------ standard plugin finalize function - don't change ---------------------------