PageRenderTime 62ms CodeModel.GetById 31ms RepoModel.GetById 0ms app.codeStats 0ms

/system/modules/weblog/mod.weblog_calendar.php

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