PageRenderTime 50ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/com_joomleague/components/com_joomleague/modules/mod_joomleague_calendar/connectors/jevents.php

https://gitlab.com/julienv/joomleague
PHP | 401 lines | 82 code | 12 blank | 307 comment | 13 complexity | 0d3ff9991d1a30c8bdf8a107e053138b MD5 | raw file
  1. <?php
  2. class JEventsConnector extends JLCalendar{
  3. var $xparams;
  4. var $prefix;
  5. var $jevent;
  6. function getEntries ($caldates, $params, &$matches) {
  7. if (!JEventsConnector::_checkJEvents()){
  8. return;
  9. }
  10. $year = substr($caldates['start'], 0, 4);
  11. $month = (substr($caldates['start'], 5, 1)=='0') ? substr($caldates['start'], 6, 1) : substr($caldates['start'], 5, 2);
  12. $this->xparams = $params;
  13. /**
  14. * Gets calendar data for use in main calendar and module
  15. *
  16. * @param int $year
  17. * @param int $month
  18. * @param int $day
  19. * @param boolean $short - use true for module which only requires knowledge of if dat has an event
  20. * @param boolean $veryshort - use true for module which only requires dates and nothing about events
  21. * @return array - calendar data array
  22. */
  23. $data = $this->jevent->getCalendarData( $year, $month, 1 );
  24. $formatted = JEventsConnector::formatEntries($data['dates'], $matches);
  25. return $formatted;
  26. }
  27. function formatEntries( $rows, &$matches ) {
  28. $newrows = array();
  29. foreach ($rows AS $key => $row) {
  30. if (!empty($row['events'])){
  31. foreach($row['events'] AS $event) {
  32. $newrow = array();
  33. $user = JFactory::getUser();
  34. if ($user->id == 62) {
  35. /*
  36. echo '<pre>';
  37. print_r ($row);
  38. echo '</pre>';
  39. */
  40. }
  41. $newrow['link'] = JEventsConnector::buildLink ($event, $row['year'], $row['month']);
  42. $newrow['date'] = strftime('%Y-%m-%d', $row['cellDate']). ' '.strftime('%H:%M', $event->_dtstart);
  43. $newrow['type'] = 'jevents';
  44. $newrow['time'] = '';
  45. if ($event->_alldayevent != 1) {
  46. $newrow['time'] = strftime('%H:%M', $event->_dtstart);
  47. $newrow['time'] .= ($event->_dtstart != $event->_dtend AND $event->_noendtime == 0) ? '-'.strftime('%H:%M', $event->_dtend) : '';
  48. }
  49. $newrow['headingtitle'] = $this->xparams->get('jevents_text', 'JEvents');
  50. $newrow['name'] = '';
  51. $newrow['title'] = $event->_title;
  52. $newrow['location'] = $event->_location;
  53. $newrow['color'] = $event->_color_bar;
  54. $newrow['matchcode'] = 0;
  55. $newrow['project_id'] = 0;
  56. $matches[] = $newrow;
  57. }
  58. }
  59. }
  60. }
  61. private function _raiseError($message) {
  62. echo $message;
  63. }
  64. private function _checkJEvents() {
  65. if (file_exists(JPATH_SITE.DS.'components'.DS.'com_jevents'.DS.'mod.defines.php')
  66. AND
  67. file_exists(JPATH_SITE.DS.'components'.DS.'com_jevents'.DS.'libraries'.DS.'datamodel.php')
  68. )
  69. {
  70. require_once JPATH_SITE.DS.'components'.DS.'com_jevents'.DS.'mod.defines.php';
  71. require_once JPATH_SITE.DS.'components'.DS.'com_jevents'.DS.'libraries'.DS.'datamodel.php';
  72. }
  73. else {
  74. JEventsConnector::_raiseError('Required files not found! This connector needs JEvents 1.5.2 to be installed');
  75. return false;
  76. }
  77. if (class_exists('JEventsDataModel')) {
  78. $this->jevent = new JEventsDataModel();
  79. }
  80. else {
  81. JEventsConnector::_raiseError('Required class not found! This connector needs JEvents 1.5.2 installed');
  82. return false;
  83. }
  84. if (!is_callable(array($this->jevent, 'getCalendarData'))) {
  85. JEventsConnector::_raiseError('Required function "getRangeData" is not callable! This connector needs JEvents 1.5.2 installed');
  86. return false;
  87. }
  88. return true;
  89. }
  90. function buildLink (&$event, $year, $month) {
  91. require_once JPATH_SITE.DS.'components'.DS.'com_jevents'.DS.'router.php';
  92. $link = 'index.php?option=com_jevents&amp;task=icalrepeat.detail&amp;evid='
  93. .$event->_eventdetail_id.'&amp;year='.$year.'&amp;month='.$month.'&amp;day='
  94. .$event->_dup.'&amp;uid='.$event->_uid;
  95. return JRoute::_($link);
  96. }
  97. }
  98. // jevents returns a list like that:
  99. /*
  100. Array
  101. (
  102. [countDisplay] => 0
  103. [monthType] => current
  104. [month] => 09
  105. [year] => 2009
  106. [today] =>
  107. [d] => 28
  108. [d0] => 28
  109. [link] => /jl15/index.php?option=com_jevents&task=day.listevents&year=2009&month=09&day=28&Itemid=58
  110. [cellDate] => 1254088800
  111. [events] => Array
  112. (
  113. [0] => jIcalEventRepeat Object
  114. (
  115. [_nextRepeat:private] =>
  116. [_prevRepeat:private] =>
  117. [_icsid] => 1
  118. [_repeats] =>
  119. [data] => stdClass Object
  120. (
  121. )
  122. [_unixstartdate] =>
  123. [_unixenddate] =>
  124. [_location] => Ahlen
  125. [_contact] =>
  126. [_extra_info] =>
  127. [_color] => #3333FF
  128. [_published] => 1
  129. [_multiday] => 0
  130. [_noendtime] => 0
  131. [_catid] => 34
  132. [_rp_id] => 11
  133. [_eventid] => 2
  134. [_eventdetail_id] => 2
  135. [_duplicatecheck] => 6a88b0b55270f07916b4567dd1e8ef94
  136. [_startrepeat] => 2009-09-28 00:00:00
  137. [_endrepeat] => 2009-09-28 23:59:59
  138. [_ev_id] => 2
  139. [_uid] => 2961b56f25beee13f61065dfd925bb2b
  140. [_refreshed] => 0000-00-00 00:00:00
  141. [_created] =>
  142. [_created_by] => 62
  143. [_created_by_alias] =>
  144. [_modified_by] => 62
  145. [_rawdata] =>
  146. [_recurrence_id] =>
  147. [_detail_id] => 2
  148. [_state] => 1
  149. [_access] => 2
  150. [_rr_id] => 2
  151. [_freq] => WEEKLY
  152. [_until] => 1259535600
  153. [_untilraw] =>
  154. [_count] => 99999
  155. [_rinterval] => 1
  156. [_bysecond] =>
  157. [_byminute] =>
  158. [_byhour] =>
  159. [_byday] => MO
  160. [_bymonthday] =>
  161. [_byyearday] =>
  162. [_byweekno] =>
  163. [_bymonth] =>
  164. [_bysetpos] =>
  165. [_wkst] =>
  166. [_evdet_id] => 2
  167. [_dtstart] => 1254088800
  168. [_dtstartraw] =>
  169. [_duration] => 0
  170. [_durationraw] =>
  171. [_dtend] => 1254088799
  172. [_dtendraw] =>
  173. [_dtstamp] =>
  174. [_class] =>
  175. [_categories] =>
  176. [_description] =>
  177. [_geolon] => 0
  178. [_geolat] => 0
  179. [_priority] => 0
  180. [_status] =>
  181. [_summary] => test2
  182. [_organizer] =>
  183. [_url] =>
  184. [_sequence] => 0
  185. [_hits] => 0
  186. [_yup] => 2009
  187. [_mup] => 09
  188. [_dup] => 28
  189. [_ydn] => 2009
  190. [_mdn] => 09
  191. [_ddn] => 28
  192. [_hup] => 0
  193. [_minup] => 0
  194. [_sup] => 0
  195. [_hdn] => 23
  196. [_mindn] => 59
  197. [_sdn] => 59
  198. [_interval] => 1
  199. [_content] =>
  200. [_title] => test2
  201. [_publish_up] => 2009-09-28 00:00:00
  202. [_reccurtype] => 0
  203. [_reccurday] =>
  204. [_reccurweekdays] =>
  205. [_reccurweeks] =>
  206. [_alldayevent] => 1
  207. [_useCatColor] => 0
  208. [_color_bar] => #3333FF
  209. [_publish_down] => 2009-09-28 23:59:59
  210. [_contactlink] => n/a
  211. [eventDaysMonth] => Array
  212. (
  213. [1251756000] =>
  214. [1251842400] =>
  215. [1251928800] =>
  216. [1252015200] =>
  217. [1252101600] =>
  218. [1252188000] =>
  219. [1252274400] =>
  220. [1252360800] =>
  221. [1252447200] =>
  222. [1252533600] =>
  223. [1252620000] =>
  224. [1252706400] =>
  225. [1252792800] =>
  226. [1252879200] =>
  227. [1252965600] =>
  228. [1253052000] =>
  229. [1253138400] =>
  230. [1253224800] =>
  231. [1253311200] =>
  232. [1253397600] =>
  233. [1253484000] =>
  234. [1253570400] =>
  235. [1253656800] =>
  236. [1253743200] =>
  237. [1253829600] =>
  238. [1253916000] =>
  239. [1254002400] =>
  240. [1254088800] => 1
  241. [1254175200] =>
  242. [1254261600] =>
  243. )
  244. [_startday] => 1254088800
  245. [_endday] => 1254088800
  246. )
  247. [1] => jIcalEventRepeat Object
  248. (
  249. [_nextRepeat:private] =>
  250. [_prevRepeat:private] =>
  251. [_icsid] => 1
  252. [_repeats] =>
  253. [data] => stdClass Object
  254. (
  255. )
  256. [_unixstartdate] =>
  257. [_unixenddate] =>
  258. [_location] =>
  259. [_contact] =>
  260. [_extra_info] =>
  261. [_color] =>
  262. [_published] => 1
  263. [_multiday] => 0
  264. [_noendtime] => 1
  265. [_catid] => 34
  266. [_rp_id] => 21
  267. [_eventid] => 3
  268. [_eventdetail_id] => 3
  269. [_duplicatecheck] => acbdc8b63e5e72eeb47f37760be76d3b
  270. [_startrepeat] => 2009-09-28 13:00:00
  271. [_endrepeat] => 2009-09-28 15:00:00
  272. [_ev_id] => 3
  273. [_uid] => a4c6f9280c32058b3ca564705c2f9728
  274. [_refreshed] => 0000-00-00 00:00:00
  275. [_created] =>
  276. [_created_by] => 62
  277. [_created_by_alias] =>
  278. [_modified_by] => 62
  279. [_rawdata] =>
  280. [_recurrence_id] =>
  281. [_detail_id] => 3
  282. [_state] => 1
  283. [_access] => 0
  284. [_rr_id] => 3
  285. [_freq] => WEEKLY
  286. [_until] => 1259535600
  287. [_untilraw] =>
  288. [_count] => 99999
  289. [_rinterval] => 1
  290. [_bysecond] =>
  291. [_byminute] =>
  292. [_byhour] =>
  293. [_byday] => MO
  294. [_bymonthday] =>
  295. [_byyearday] =>
  296. [_byweekno] =>
  297. [_bymonth] =>
  298. [_bysetpos] =>
  299. [_wkst] =>
  300. [_evdet_id] => 3
  301. [_dtstart] => 1254135600
  302. [_dtstartraw] =>
  303. [_duration] => 0
  304. [_durationraw] =>
  305. [_dtend] => 1254142800
  306. [_dtendraw] =>
  307. [_dtstamp] =>
  308. [_class] =>
  309. [_categories] =>
  310. [_description] =>
  311. [_geolon] => 0
  312. [_geolat] => 0
  313. [_priority] => 0
  314. [_status] =>
  315. [_summary] => test3 (no endtime)
  316. [_organizer] =>
  317. [_url] =>
  318. [_sequence] => 0
  319. [_hits] => 1
  320. [_yup] => 2009
  321. [_mup] => 09
  322. [_dup] => 28
  323. [_ydn] => 2009
  324. [_mdn] => 09
  325. [_ddn] => 28
  326. [_hup] => 13
  327. [_minup] => 0
  328. [_sup] => 0
  329. [_hdn] => 15
  330. [_mindn] => 0
  331. [_sdn] => 0
  332. [_interval] => 1
  333. [_content] =>
  334. [_title] => test3 (no endtime)
  335. [_publish_up] => 2009-09-28 13:00:00
  336. [_reccurtype] => 0
  337. [_reccurday] =>
  338. [_reccurweekdays] =>
  339. [_reccurweeks] =>
  340. [_alldayevent] => 0
  341. [_useCatColor] => 1
  342. [_color_bar] => #ffffff
  343. [_publish_down] => 2009-09-28 15:00:00
  344. [_contactlink] => n/a
  345. [eventDaysMonth] => Array
  346. (
  347. [1251756000] =>
  348. [1251842400] =>
  349. [1251928800] =>
  350. [1252015200] =>
  351. [1252101600] =>
  352. [1252188000] =>
  353. [1252274400] =>
  354. [1252360800] =>
  355. [1252447200] =>
  356. [1252533600] =>
  357. [1252620000] =>
  358. [1252706400] =>
  359. [1252792800] =>
  360. [1252879200] =>
  361. [1252965600] =>
  362. [1253052000] =>
  363. [1253138400] =>
  364. [1253224800] =>
  365. [1253311200] =>
  366. [1253397600] =>
  367. [1253484000] =>
  368. [1253570400] =>
  369. [1253656800] =>
  370. [1253743200] =>
  371. [1253829600] =>
  372. [1253916000] =>
  373. [1254002400] =>
  374. [1254088800] => 1
  375. [1254175200] =>
  376. [1254261600] =>
  377. )
  378. [_startday] => 1254088800
  379. [_endday] => 1254088800
  380. )
  381. )
  382. )
  383. */