PageRenderTime 28ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/system/expressionengine/modules/channel/mod.channel_calendar.php

https://bitbucket.org/mbaily/tremain
PHP | 788 lines | 487 code | 144 blank | 157 comment | 64 complexity | 38adb1d550beabfa2b871bb3cc9cd6a0 MD5 | raw file
  1. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  2. /**
  3. * ExpressionEngine - by EllisLab
  4. *
  5. * @package ExpressionEngine
  6. * @author EllisLab Dev Team
  7. * @copyright Copyright (c) 2003 - 2013, EllisLab, Inc.
  8. * @license http://ellislab.com/expressionengine/user-guide/license.html
  9. * @link http://ellislab.com
  10. * @since Version 2.0
  11. * @filesource
  12. */
  13. // --------------------------------------------------------------------
  14. /**
  15. * ExpressionEngine Channel Calendar Module
  16. *
  17. * @package ExpressionEngine
  18. * @subpackage Modules
  19. * @category Modules
  20. * @author EllisLab Dev Team
  21. * @link http://ellislab.com
  22. */
  23. class Channel_calendar extends Channel {
  24. var $sql = '';
  25. /** ----------------------------------------
  26. /** Channel Calendar
  27. /** ----------------------------------------*/
  28. function calendar()
  29. {
  30. // Rick is using some funky conditional stuff for the calendar, so
  31. // we have to reassign the var_cond array using the legacy conditional
  32. // parser. Bummer, but whatcha going to do?
  33. ee()->TMPL->var_cond = ee()->functions->assign_conditional_variables(ee()->TMPL->tagdata, '/', LD, RD);
  34. /** ----------------------------------------
  35. /** Determine the Month and Year
  36. /** ----------------------------------------*/
  37. $year = '';
  38. $month = '';
  39. // Hard-coded month/year via tag parameters
  40. if (ee()->TMPL->fetch_param('month') AND ee()->TMPL->fetch_param('year'))
  41. {
  42. $year = ee()->TMPL->fetch_param('year');
  43. $month = ee()->TMPL->fetch_param('month');
  44. if (strlen($month) == 1)
  45. {
  46. $month = '0'.$month;
  47. }
  48. }
  49. else
  50. {
  51. // Month/year in query string
  52. if (preg_match("#(\d{4}/\d{2})#", ee()->uri->query_string, $match))
  53. {
  54. $ex = explode('/', $match['1']);
  55. $time = gmmktime(0, 0, 0, $ex['1'], 01, $ex['0']);
  56. $year = ee()->localize->format_date('%Y', $time, FALSE);
  57. $month = ee()->localize->format_date('%m', $time, FALSE);
  58. }
  59. else
  60. {
  61. // Defaults to current month/year
  62. $year = ee()->localize->format_date('%Y');
  63. $month = ee()->localize->format_date('%m');
  64. }
  65. }
  66. /** ----------------------------------------
  67. /** Set Unix timestamp for the given month/year
  68. /** ----------------------------------------*/
  69. $date = gmmktime(12, 0, 0, $month, 1, $year);
  70. /** ----------------------------------------
  71. /** Determine the total days in the month
  72. /** ----------------------------------------*/
  73. ee()->load->library('calendar');
  74. $adjusted_date = ee()->calendar->adjust_date($month, $year);
  75. $month = $adjusted_date['month'];
  76. $year = $adjusted_date['year'];
  77. ee()->load->helper('date');
  78. $total_days = days_in_month($month, $year);
  79. $previous_date = mktime(12, 0, 0, $month-1, 1, $year);
  80. $next_date = mktime(12, 0, 0, $month+1, 1, $year);
  81. /** ---------------------------------------
  82. /** Determine the total days of the previous month
  83. /** ---------------------------------------*/
  84. $adj_prev_date = ee()->calendar->adjust_date($month-1, $year);
  85. $prev_month = $adj_prev_date['month'];
  86. $prev_year = $adj_prev_date['year'];
  87. $prev_total_days = days_in_month($prev_month, $prev_year);
  88. /** ----------------------------------------
  89. /** Set the starting day of the week
  90. /** ----------------------------------------*/
  91. // This can be set using a parameter in the tag: start_day="saturday"
  92. // By default the calendar starts on sunday
  93. $start_days = array('sunday' => 0, 'monday' => 1, 'tuesday' => 2, 'wednesday' => 3, 'thursday' => 4, 'friday' => 5, 'saturday' => 6);
  94. $start_day = (isset($start_days[ee()->TMPL->fetch_param('start_day')])) ? $start_days[ee()->TMPL->fetch_param('start_day')]: 0;
  95. $day = $start_day + 1 - ee()->localize->format_date('%w', $date);
  96. while ($day > 1)
  97. {
  98. $day -= 7;
  99. }
  100. /** ----------------------------------------
  101. /** {previous_path="channel/index"}
  102. /** ----------------------------------------*/
  103. // This variables points to the previous month
  104. if (preg_match_all("#".LD."previous_path=(.+?)".RD."#", ee()->TMPL->tagdata, $matches))
  105. {
  106. $adjusted_date = ee()->calendar->adjust_date($month - 1, $year, TRUE);
  107. foreach ($matches['1'] as $match)
  108. {
  109. $path = ee()->functions->create_url($match).'/'.$adjusted_date['year'].'/'.$adjusted_date['month'];
  110. ee()->TMPL->tagdata = preg_replace("#".LD."previous_path=.+?".RD."#", $path, ee()->TMPL->tagdata, 1);
  111. }
  112. }
  113. /** ----------------------------------------
  114. /** {next_path="channel/index"}
  115. /** ----------------------------------------*/
  116. // This variables points to the next month
  117. if (preg_match_all("#".LD."next_path=(.+?)".RD."#", ee()->TMPL->tagdata, $matches))
  118. {
  119. $adjusted_date = ee()->calendar->adjust_date($month + 1, $year, TRUE);
  120. foreach ($matches['1'] as $match)
  121. {
  122. $path = ee()->functions->create_url($match).'/'.$adjusted_date['year'].'/'.$adjusted_date['month'];
  123. ee()->TMPL->tagdata = preg_replace("#".LD."next_path=.+?".RD."#", $path, ee()->TMPL->tagdata, 1);
  124. }
  125. }
  126. /** ----------------------------------------
  127. /** {date format="%m %Y"}
  128. /** ----------------------------------------*/
  129. // This variable is used in the heading of the calendar
  130. // to show the month and year
  131. if (preg_match_all("#".LD."date format=[\"|'](.+?)[\"|']".RD."#", ee()->TMPL->tagdata, $matches))
  132. {
  133. foreach ($matches['1'] as $match)
  134. {
  135. ee()->TMPL->tagdata = preg_replace("#".LD."date format=.+?".RD."#", ee()->localize->format_date($match, $date), ee()->TMPL->tagdata, 1);
  136. }
  137. }
  138. /** ----------------------------------------
  139. /** {previous_date format="%m %Y"}
  140. /** ----------------------------------------*/
  141. // This variable is used in the heading of the calendar
  142. // to show the month and year
  143. if (preg_match_all("#".LD."previous_date format=[\"|'](.+?)[\"|']".RD."#", ee()->TMPL->tagdata, $matches))
  144. {
  145. foreach ($matches['1'] as $match)
  146. {
  147. ee()->TMPL->tagdata = preg_replace("#".LD."previous_date format=.+?".RD."#", ee()->localize->format_date($match, $previous_date), ee()->TMPL->tagdata, 1);
  148. }
  149. }
  150. /** ----------------------------------------
  151. /** {next_date format="%m %Y"}
  152. /** ----------------------------------------*/
  153. // This variable is used in the heading of the calendar
  154. // to show the month and year
  155. if (preg_match_all("#".LD."next_date format=[\"|'](.+?)[\"|']".RD."#", ee()->TMPL->tagdata, $matches))
  156. {
  157. foreach ($matches['1'] as $match)
  158. {
  159. ee()->TMPL->tagdata = preg_replace("#".LD."next_date format=.+?".RD."#", ee()->localize->format_date($match, $next_date), ee()->TMPL->tagdata, 1);
  160. }
  161. }
  162. /** ----------------------------------------
  163. /** Day Heading
  164. /** ----------------------------------------*/
  165. /*
  166. This code parses out the headings for each day of the week
  167. Contained in the tag will be this variable pair:
  168. {calendar_heading}
  169. <td class="calendarDayHeading">{lang:weekday_abrev}</td>
  170. {/calendar_heading}
  171. There are three display options for the header:
  172. {lang:weekday_abrev} = S M T W T F S
  173. {lang:weekday_short} = Sun Mon Tues, etc.
  174. {lang:weekday_long} = Sunday Monday Tuesday, etc.
  175. */
  176. foreach (array('Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa') as $val)
  177. {
  178. $day_names_a[] = ( ! ee()->lang->line($val)) ? $val : ee()->lang->line($val);
  179. }
  180. foreach (array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat') as $val)
  181. {
  182. $day_names_s[] = ( ! ee()->lang->line($val)) ? $val : ee()->lang->line($val);
  183. }
  184. foreach (array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday') as $val)
  185. {
  186. $day_names_l[] = ( ! ee()->lang->line($val)) ? $val : ee()->lang->line($val);
  187. }
  188. if (preg_match("/".LD."calendar_heading".RD."(.*?)".LD.'\/'."calendar_heading".RD."/s", ee()->TMPL->tagdata, $match))
  189. {
  190. $temp = '';
  191. for ($i = 0; $i < 7; $i ++)
  192. {
  193. $temp .= str_replace(array( LD.'lang:weekday_abrev'.RD,
  194. LD.'lang:weekday_short'.RD,
  195. LD.'lang:weekday_long'.RD),
  196. array( $day_names_a[($start_day + $i) %7],
  197. $day_names_s[($start_day + $i) %7],
  198. $day_names_l[($start_day + $i) %7]),
  199. trim($match['1'])."\n");
  200. }
  201. ee()->TMPL->tagdata = preg_replace ("/".LD."calendar_heading".RD.".*?".LD.'\/'."calendar_heading".RD."/s", trim($temp), ee()->TMPL->tagdata);
  202. }
  203. /** ----------------------------------------
  204. /** Separate out cell data
  205. /** ----------------------------------------*/
  206. // We need to strip out the various variable pairs
  207. // that allow us to render each calendar cell.
  208. // We'll do this up-front and assign temporary markers
  209. // in the template which we will replace with the final
  210. // data later
  211. $row_start = '';
  212. $row_end = '';
  213. $row_chunk = '';
  214. $row_chunk_m = '94838dkAJDei8azDKDKe01';
  215. $entries = '';
  216. $entries_m = 'Gm983TGxkedSPoe0912NNk';
  217. $if_today = '';
  218. $if_today_m = 'JJg8e383dkaadPo20qxEid';
  219. $if_entries = '';
  220. $if_entries_m = 'Rgh43K0L0Dff9003cmqQw1';
  221. $if_not_entries = '';
  222. $if_not_entries_m = 'yr83889910BvndkGei8ti3';
  223. $if_blank = '';
  224. $if_blank_m = '43HDueie4q7pa8dAAseit6';
  225. if (preg_match("/".LD."calendar_rows".RD."(.*?)".LD.'\/'."calendar_rows".RD."/s", ee()->TMPL->tagdata, $match))
  226. {
  227. $row_chunk = trim($match['1']);
  228. // Fetch all the entry_date variable
  229. if (preg_match_all("/".LD."entry_date\s+format=[\"'](.*?)[\"']".RD."/s", $row_chunk, $matches))
  230. {
  231. for ($j = 0; $j < count($matches['0']); $j++)
  232. {
  233. $matches['0'][$j] = str_replace(array(LD,RD), '', $matches['0'][$j]);
  234. $entry_dates[$matches['0'][$j]] = $matches['1'][$j];
  235. }
  236. }
  237. if (preg_match("/".LD."row_start".RD."(.*?)".LD.'\/'."row_start".RD."/s", $row_chunk, $match))
  238. {
  239. $row_start = trim($match['1']);
  240. $row_chunk = trim(str_replace ($match['0'], "", $row_chunk));
  241. }
  242. if (preg_match("/".LD."row_end".RD."(.*?)".LD.'\/'."row_end".RD."/s", $row_chunk, $match))
  243. {
  244. $row_end = trim($match['1']);
  245. $row_chunk = trim(str_replace($match['0'], "", $row_chunk));
  246. }
  247. foreach (ee()->TMPL->var_cond as $key => $val)
  248. {
  249. if ($val['3'] == 'today')
  250. {
  251. $if_today = trim($val['2']);
  252. $row_chunk = str_replace ($val['1'], $if_today_m, $row_chunk);
  253. unset(ee()->TMPL->var_cond[$key]);
  254. }
  255. if ($val['3'] == 'entries')
  256. {
  257. $if_entries = trim($val['2']);
  258. $row_chunk = str_replace ($val['1'], $if_entries_m, $row_chunk);
  259. unset(ee()->TMPL->var_cond[$key]);
  260. }
  261. if ($val['3'] == 'not_entries')
  262. {
  263. $if_not_entries = trim($val['2']);
  264. $row_chunk = str_replace ($val['1'], $if_not_entries_m, $row_chunk);
  265. unset(ee()->TMPL->var_cond[$key]);
  266. }
  267. if ($val['3'] == 'blank')
  268. {
  269. $if_blank = trim($val['2']);
  270. $row_chunk = str_replace ($val['1'], $if_blank_m, $row_chunk);
  271. unset(ee()->TMPL->var_cond[$key]);
  272. }
  273. if (preg_match("/".LD."entries".RD."(.*?)".LD.'\/'."entries".RD."/s", $if_entries, $match))
  274. {
  275. $entries = trim($match['1']);
  276. $if_entries = trim(str_replace($match['0'], $entries_m, $if_entries));
  277. }
  278. }
  279. ee()->TMPL->tagdata = preg_replace ("/".LD."calendar_rows".RD.".*?".LD.'\/'."calendar_rows".RD."/s", $row_chunk_m, ee()->TMPL->tagdata);
  280. }
  281. /** ----------------------------------------
  282. /** Fetch {switch} variable
  283. /** ----------------------------------------*/
  284. // This variable lets us use a different CSS class
  285. // for the current day
  286. $switch_t = '';
  287. $switch_c = '';
  288. if (ee()->TMPL->fetch_param('switch'))
  289. {
  290. $x = explode("|", ee()->TMPL->fetch_param('switch'));
  291. if (count($x) == 2)
  292. {
  293. $switch_t = $x['0'];
  294. $switch_c = $x['1'];
  295. }
  296. }
  297. /** ---------------------------------------
  298. /** Set the day number numeric format
  299. /** ---------------------------------------*/
  300. $day_num_fmt = (ee()->TMPL->fetch_param('leading_zeroes') == 'yes') ? "%02d" : "%d";
  301. /** ----------------------------------------
  302. /** Build the SQL query
  303. /** ----------------------------------------*/
  304. $this->initialize();
  305. $this->build_sql_query('/'.$year.'/'.$month.'/');
  306. if ($this->sql != '')
  307. {
  308. $query = ee()->db->query($this->sql);
  309. $data = array();
  310. if ($query->num_rows() > 0)
  311. {
  312. // We'll need this later
  313. ee()->load->library('typography');
  314. ee()->typography->initialize(array(
  315. 'convert_curly' => FALSE
  316. ));
  317. /** ----------------------------------------
  318. /** Fetch query results and build data array
  319. /** ----------------------------------------*/
  320. foreach ($query->result_array() as $row)
  321. {
  322. /** ----------------------------------------
  323. /** Define empty arrays and strings
  324. /** ----------------------------------------*/
  325. $defaults = array(
  326. 'entry_date' => 'a',
  327. 'permalink' => 'a',
  328. 'title_permalink' => 'a',
  329. 'author' => 's',
  330. 'profile_path' => 'a',
  331. 'id_path' => 'a',
  332. 'base_fields' => 'a',
  333. 'day_path' => 'a',
  334. 'comment_auto_path' => 's',
  335. 'comment_entry_id_auto_path' => 's',
  336. 'comment_url_title_auto_path' => 's'
  337. );
  338. foreach ($defaults as $key => $val)
  339. {
  340. $$key = ($val == 'a') ? array() : '';
  341. }
  342. /** ---------------------------
  343. /** Single Variables
  344. /** ---------------------------*/
  345. foreach (ee()->TMPL->var_single as $key => $val)
  346. {
  347. if (isset($entry_dates[$key]))
  348. {
  349. $entry_date[$key] = ee()->localize->format_date(
  350. $entry_date[$key],
  351. $row['entry_date']
  352. );
  353. }
  354. /** ----------------------------------------
  355. /** parse permalink
  356. /** ----------------------------------------*/
  357. if (strncmp($key, 'permalink', 9) == 0)
  358. {
  359. if (ee()->functions->extract_path($key) != '' AND ee()->functions->extract_path($key) != 'SITE_INDEX')
  360. {
  361. $path = ee()->functions->extract_path($key).'/'.$row['entry_id'];
  362. }
  363. else
  364. {
  365. $path = $row['entry_id'];
  366. }
  367. $permalink[$key] = ee()->functions->create_url($path);
  368. }
  369. /** ----------------------------------------
  370. /** parse title permalink
  371. /** ----------------------------------------*/
  372. if (strncmp($key, 'title_permalink', 15) == 0 OR strncmp($key, 'url_title_path', 14) == 0)
  373. {
  374. if (ee()->functions->extract_path($key) != '' AND ee()->functions->extract_path($key) != 'SITE_INDEX')
  375. {
  376. $path = ee()->functions->extract_path($key).'/'.$row['url_title'];
  377. }
  378. else
  379. {
  380. $path = $row['url_title'];
  381. }
  382. $title_permalink[$key] = ee()->functions->create_url($path);
  383. }
  384. /** ----------------------------------------
  385. /** {comment_auto_path}
  386. /** ----------------------------------------*/
  387. if ($key == "comment_auto_path")
  388. {
  389. $comment_auto_path = ($row['comment_url'] == '') ? $row['channel_url'] : $row['comment_url'];
  390. }
  391. /** ----------------------------------------
  392. /** {comment_url_title_auto_path}
  393. /** ----------------------------------------*/
  394. if ($key == "comment_url_title_auto_path")
  395. {
  396. $path = ($row['comment_url'] == '') ? $row['channel_url'] : $row['comment_url'];
  397. $comment_url_title_auto_path = $path.$row['url_title'];
  398. }
  399. /** ----------------------------------------
  400. /** {comment_entry_id_auto_path}
  401. /** ----------------------------------------*/
  402. if ($key == "comment_entry_id_auto_path")
  403. {
  404. $path = ($row['comment_url'] == '') ? $row['channel_url'] : $row['comment_url'];
  405. $comment_entry_id_auto_path = $path.$row['entry_id'];
  406. }
  407. /** ----------------------------------------
  408. /** {author}
  409. /** ----------------------------------------*/
  410. if ($key == "author")
  411. {
  412. $author = ($row['screen_name'] != '') ? $row['screen_name'] : $row['username'];
  413. }
  414. /** ----------------------------------------
  415. /** profile path
  416. /** ----------------------------------------*/
  417. if (strncmp($key, 'profile_path', 12) == 0)
  418. {
  419. $profile_path[$key] = ee()->functions->create_url(ee()->functions->extract_path($key).'/'.$row['member_id']);
  420. }
  421. /** ----------------------------------------
  422. /** parse comment_path
  423. /** ----------------------------------------*/
  424. if (strncmp($key, 'comment_path', 12) == 0 OR strncmp($key, 'entry_id_path', 13) == 0)
  425. {
  426. $id_path[$key] = ee()->functions->create_url(ee()->functions->extract_path($key).'/'.$row['entry_id']);
  427. }
  428. /** ----------------------------------------
  429. /** Basic fields (username, screen_name, etc.)
  430. /** ----------------------------------------*/
  431. if (isset($row[$val]))
  432. {
  433. $base_fields[$key] = $row[$val];
  434. }
  435. /** ----------------------------------------
  436. /** {day_path}
  437. /** ----------------------------------------*/
  438. if (strncmp($key, 'day_path', 8) == 0)
  439. {
  440. $formatted_date_path = ee()->localize->format_date('%Y/%m/%d', $row['entry_date']);
  441. if (ee()->functions->extract_path($key) != ''
  442. AND ee()->functions->extract_path($key) != 'SITE_INDEX')
  443. {
  444. $formatted_date_path = ee()->functions->extract_path($key).'/'.$formatted_date_path;
  445. }
  446. $if_entries = str_replace(LD.$key.RD, LD.'day_path'.$val.RD, $if_entries);
  447. $day_path[$key] = ee()->functions->create_url($formatted_date_path);
  448. }
  449. }
  450. // END FOREACH SINGLE VARIABLES
  451. /** ----------------------------------------
  452. /** Build Data Array
  453. /** ----------------------------------------*/
  454. $d = ee()->localize->format_date('%d', $row['entry_date']);
  455. if (substr($d, 0, 1) == '0')
  456. {
  457. $d = substr($d, 1);
  458. }
  459. $data[$d][] = array(
  460. ee()->typography->parse_type($row['title'], array('text_format' => 'lite', 'html_format' => 'none', 'auto_links' => 'n', 'allow_img_url' => 'no')),
  461. $row['url_title'],
  462. $entry_date,
  463. $permalink,
  464. $title_permalink,
  465. $author,
  466. $profile_path,
  467. $id_path,
  468. $base_fields,
  469. $day_path,
  470. $comment_auto_path,
  471. $comment_url_title_auto_path,
  472. $comment_entry_id_auto_path
  473. );
  474. } // END FOREACH
  475. } // END if ($query->num_rows() > 0)
  476. } // END if ($this->query != '')
  477. /** ----------------------------------------
  478. /** Build Calendar Cells
  479. /** ----------------------------------------*/
  480. $out = '';
  481. $today = array(
  482. 'mday' => ee()->localize->format_date('%j'),
  483. 'mon' => ee()->localize->format_date('%n'),
  484. 'year' => ee()->localize->format_date('%Y')
  485. );
  486. while ($day <= $total_days)
  487. {
  488. $out .= $row_start;
  489. for ($i = 0; $i < 7; $i++)
  490. {
  491. if ($day > 0 AND $day <= $total_days)
  492. {
  493. if ($if_entries != '' AND isset($data[$day]))
  494. {
  495. $out .= str_replace($if_entries_m, $this->var_replace($if_entries, $data[$day], $entries), $row_chunk);
  496. foreach($day_path as $k => $v)
  497. {
  498. $out = str_replace(LD.'day_path'.$k.RD, $data[$day]['0']['9'][$k], $out);
  499. }
  500. }
  501. else
  502. {
  503. $out .= str_replace($if_not_entries_m, $if_not_entries, $row_chunk);
  504. }
  505. $out = str_replace(LD.'day_number'.RD, sprintf($day_num_fmt, $day), $out);
  506. if ($day == $today["mday"] AND $month == $today["mon"] AND $year == $today["year"])
  507. {
  508. $out = str_replace(LD.'switch'.RD, $switch_t, $out);
  509. }
  510. else
  511. {
  512. $out = str_replace(LD.'switch'.RD, $switch_c, $out);
  513. }
  514. }
  515. else
  516. {
  517. $out .= str_replace($if_blank_m, $if_blank, $row_chunk);
  518. $out = str_replace(LD.'day_number'.RD, ($day <= 0) ? sprintf($day_num_fmt, $prev_total_days + $day) : sprintf($day_num_fmt, $day - $total_days), $out);
  519. }
  520. $day++;
  521. }
  522. $out .= $row_end;
  523. }
  524. // Garbage collection
  525. $out = str_replace(
  526. array(
  527. $entries_m,
  528. $if_blank_m,
  529. $if_today_m,
  530. $if_entries_m,
  531. $if_not_entries_m
  532. ),
  533. '',
  534. $out
  535. );
  536. return str_replace ($row_chunk_m, $out, ee()->TMPL->tagdata);
  537. }
  538. /** ----------------------------------------
  539. /** Replace Calendar Variables
  540. /** ----------------------------------------*/
  541. function var_replace($chunk, $data, $row = '')
  542. {
  543. if ($row != '')
  544. {
  545. $temp = '';
  546. foreach ($data as $val)
  547. {
  548. $str = $row;
  549. $str = str_replace(array(LD.'title'.RD,
  550. LD.'url_title'.RD,
  551. LD.'author'.RD,
  552. LD.'comment_auto_path'.RD,
  553. LD.'comment_url_title_auto_path'.RD,
  554. LD.'comment_entry_id_auto_path'.RD),
  555. array($val['0'],
  556. $val['1'],
  557. $val['5'],
  558. $val['10'],
  559. $val['11'],
  560. $val['12']),
  561. $str);
  562. // Entry Date
  563. foreach ($val['2'] as $k => $v)
  564. {
  565. $str = str_replace(LD.$k.RD, $v, $str);
  566. }
  567. // Permalink
  568. foreach ($val['3'] as $k => $v)
  569. {
  570. $str = str_replace(LD.$k.RD, $v, $str);
  571. }
  572. // Title permalink
  573. foreach ($val['4'] as $k => $v)
  574. {
  575. $str = str_replace(LD.$k.RD, $v, $str);
  576. }
  577. // Profile path
  578. foreach ($val['6'] as $k => $v)
  579. {
  580. $str = str_replace(LD.$k.RD, $v, $str);
  581. }
  582. // ID path
  583. foreach ($val['7'] as $k => $v)
  584. {
  585. $str = str_replace(LD.$k.RD, $v, $str);
  586. }
  587. // Base Fields
  588. foreach ($val['8'] as $k => $v)
  589. {
  590. $str = str_replace(LD.$k.RD, $v, $str);
  591. }
  592. // Day path
  593. foreach ($val['9'] as $k => $v)
  594. {
  595. $str = str_replace(LD.$k.RD, $v, $str);
  596. }
  597. $temp .= $str;
  598. }
  599. $chunk = str_replace('Gm983TGxkedSPoe0912NNk', $temp, $chunk);
  600. }
  601. return $chunk;
  602. }
  603. }
  604. // END CLASS
  605. /* End of file mod.channel_calendar.php */
  606. /* Location: ./system/expressionengine/modules/channel/mod.channel_calendar.php */