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

/e107_plugins/list_new/list_class.php

https://github.com/CasperGemini/e107
PHP | 860 lines | 561 code | 80 blank | 219 comment | 84 complexity | db1ac76b0cbb74173ab7f064feace23c MD5 | raw file
Possible License(s): GPL-2.0
  1. <?php
  2. /*
  3. * e107 website system
  4. *
  5. * Copyright (C) 2008-2013 e107 Inc (e107.org)
  6. * Released under the terms and conditions of the
  7. * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
  8. *
  9. * List Class
  10. *
  11. *
  12. */
  13. if (!defined('e107_INIT')) { exit; }
  14. /**
  15. * Base class for list_new plugin
  16. *
  17. * @package e107_plugins
  18. * @subpackage list_new
  19. */
  20. /**
  21. * class listclass
  22. * The base class
  23. */
  24. class listclass
  25. {
  26. var $defaultArray;
  27. var $sections;
  28. var $titles;
  29. var $content_types;
  30. var $content_name;
  31. var $list_pref;
  32. var $mode;
  33. var $shortcodes = FALSE;
  34. /**
  35. * constructor
  36. *
  37. * @param string $mode the mode of the caller (default, admin)
  38. * @return void
  39. *
  40. */
  41. function listclass($mode='')
  42. {
  43. global $TEMPLATE_LIST_NEW, $list_shortcodes;
  44. $this->plugin_dir = e_PLUGIN."list_new/";
  45. $this->e107 = e107::getInstance();
  46. //language
  47. include_lan($this->plugin_dir."languages/".e_LANGUAGE.".php");
  48. //template
  49. if (is_readable(THEME."list_template.php"))
  50. {
  51. require_once(THEME."list_template.php");
  52. }
  53. else
  54. {
  55. require_once($this->plugin_dir."list_template.php");
  56. }
  57. $this->template = $TEMPLATE_LIST_NEW;
  58. //shortcodes
  59. require_once($this->plugin_dir."list_shortcodes.php");
  60. // $this->shortcodes = $list_shortcodes;
  61. $this->shortcodes = new list_shortcodes();
  62. $this->shortcodes->rc = $this;
  63. if($mode=='admin')
  64. {
  65. require_once($this->plugin_dir."list_admin_class.php");
  66. $this->admin = new list_admin($this);
  67. }
  68. //default sections (present in this list plugin)
  69. $this->defaultArray = array("news", "comment", "members");
  70. }
  71. /**
  72. * helper method, parse the template
  73. *
  74. * @param string $template the template to parse
  75. * @return string
  76. *
  77. */
  78. function parseTemplate($template)
  79. {
  80. //for each call to the template, provide the correct data set through load_globals
  81. //list_shortcodes::load_globals();
  82. return e107::getParser()->parseTemplate($this->template[$template], true, $this->shortcodes);
  83. }
  84. /**
  85. * get preferences, retrieve all preferences from core table
  86. *
  87. * @return array
  88. *
  89. */
  90. function getListPrefs()
  91. {
  92. return e107::pref('list_new'); //TODO Convert from old format to new.
  93. /*
  94. $sql = e107::getDb();
  95. //check preferences from database
  96. $num_rows = $sql->gen("SELECT * FROM #core WHERE e107_name='list' ");
  97. $row = $sql->fetch();
  98. //insert default preferences
  99. if (empty($row['e107_value']))
  100. {
  101. $this->getSections();
  102. $this->list_pref = $this->getDefaultPrefs();
  103. $tmp = $this->e107->arrayStorage->WriteArray($this->list_pref);
  104. $sql->insert("core", "'list', '$tmp' ");
  105. $sql->gen("SELECT * FROM #core WHERE e107_name='list' ");
  106. }
  107. $this->list_pref = $this->e107->arrayStorage->ReadArray($row['e107_value']);
  108. return $this->list_pref;
  109. */
  110. }
  111. /**
  112. * prepareSection checks if the sections should be displayed
  113. *
  114. * @param string $mode the mode of the area (menu/page - new/recent)
  115. * @return array
  116. *
  117. */
  118. function prepareSection($mode)
  119. {
  120. $len = strlen($mode) + 9;
  121. $sections = array();
  122. //get all sections to use
  123. foreach($this->list_pref as $key=>$value)
  124. {
  125. if(substr($key,-$len) == "_{$mode}_display" && $value == "1")
  126. {
  127. $sections[] = substr($key,0,-$len);
  128. }
  129. }
  130. return $sections;
  131. }
  132. /**
  133. * prepareSectionArray parses the preferences for each section
  134. *
  135. * @param string $mode the mode of the area (menu/page - new/recent)
  136. * @return array
  137. *
  138. */
  139. function prepareSectionArray($mode)
  140. {
  141. //section reference
  142. for($i=0;$i<count($this->sections);$i++)
  143. {
  144. $s = $this->sections[$i];
  145. if(varsettrue($this->list_pref[$s."_".$mode."_display"]) == '1')
  146. {
  147. $arr[$s]['caption'] = varsettrue($this->list_pref[$s."_".$mode."_caption"]);
  148. $arr[$s]['display'] = varsettrue($this->list_pref[$s."_".$mode."_display"]);
  149. $arr[$s]['open'] = varsettrue($this->list_pref[$s."_".$mode."_open"]);
  150. $arr[$s]['author'] = varsettrue($this->list_pref[$s."_".$mode."_author"]);
  151. $arr[$s]['category'] = varsettrue($this->list_pref[$s."_".$mode."_category"]);
  152. $arr[$s]['date'] = varsettrue($this->list_pref[$s."_".$mode."_date"]);
  153. $arr[$s]['icon'] = varsettrue($this->list_pref[$s."_".$mode."_icon"]);
  154. $arr[$s]['amount'] = varsettrue($this->list_pref[$s."_".$mode."_amount"]);
  155. $arr[$s]['order'] = varsettrue($this->list_pref[$s."_".$mode."_order"]);
  156. $arr[$s]['section'] = $s;
  157. }
  158. }
  159. //sort array on order values set in preferences
  160. usort($arr, create_function('$e,$f','return $e["order"]==$f["order"]?0:($e["order"]>$f["order"]?1:-1);'));
  161. return $arr;
  162. }
  163. /**
  164. * getDefaultSections loads all default 'core' sections from the constructor
  165. *
  166. * @return void
  167. *
  168. */
  169. function getDefaultSections()
  170. {
  171. //default always present sections
  172. for($i=0;$i<count($this->defaultArray);$i++)
  173. {
  174. $this->sections[] = $this->defaultArray[$i];
  175. $this->titles[] = $this->defaultArray[$i];
  176. }
  177. return;
  178. }
  179. //content needs this to split each main parent into separate sections
  180. /**
  181. * getContentSections loads all top level content categories
  182. *
  183. * @param string $mode (default, add)
  184. * @return void
  185. *
  186. */
  187. function getContentSections($mode='')
  188. {
  189. $sql = e107::getDb();
  190. global $pref;
  191. if (!$content_install = isset($pref['plug_installed']['content']))
  192. {
  193. return;
  194. }
  195. $content_types = array();
  196. //get top level categories
  197. if($mainparents = $sql->gen("SELECT content_id, content_heading FROM #pcontent WHERE content_parent = '0' AND (content_datestamp=0 || content_datestamp < ".time().") AND (content_enddate=0 || content_enddate>".time().") ORDER BY content_heading"))
  198. {
  199. $content_name = 'content';
  200. while($row = $sql->fetch())
  201. {
  202. $content_types[] = "content_".$row['content_id'];
  203. if(varsettrue($mode) == "add")
  204. {
  205. $this->sections[] = "content_".$row['content_id'];
  206. $this->titles[] = $content_name." : ".$row['content_heading'];
  207. }
  208. }
  209. }
  210. $this->content_types = array_unique($content_types);
  211. $this->content_name = $content_name;
  212. return;
  213. }
  214. /**
  215. * getSections loads all sections
  216. *
  217. * @return void
  218. *
  219. */
  220. function getSections()
  221. {
  222. global $pref;
  223. $this->getDefaultSections();
  224. if(is_array($pref['e_list_list']))
  225. {
  226. foreach($pref['e_list_list'] as $file)
  227. {
  228. if ($plugin_installed = isset($pref['plug_installed'][$file]))
  229. {
  230. if($file == "content")
  231. {
  232. $this->getContentSections("add");
  233. }
  234. else
  235. {
  236. $this->sections[] = $file;
  237. $this->titles[] = $file;
  238. }
  239. }
  240. }
  241. }
  242. return;
  243. }
  244. /**
  245. * getDefaultPrefs retrieve all default preferences (if none present)
  246. *
  247. * @return array
  248. *
  249. */
  250. function getDefaultPrefs()
  251. {
  252. global $pref;
  253. $prf = array();
  254. //section preferences
  255. for($i=0;$i<count($this->sections);$i++)
  256. {
  257. $s = $this->sections[$i];
  258. if(!in_array($this->sections[$i], $this->defaultArray))
  259. {
  260. if(!in_array($s, $this->content_types))
  261. {
  262. if ($plugin_installed = isset($pref['plug_installed'][e107::getParser()->toDB($s, true)]))
  263. {
  264. $prf["$s_recent_menu_caption"] = $s;
  265. $prf["$s_recent_page_caption"] = $s;
  266. $prf["$s_new_menu_caption"] = $s;
  267. $prf["$s_new_page_caption"] = $s;
  268. }
  269. }
  270. else
  271. {
  272. $prf["$s_recent_menu_caption"] = $this->titles[$i];
  273. $prf["$s_recent_page_caption"] = $this->titles[$i];
  274. $prf["$s_new_menu_caption"] = $this->titles[$i];
  275. $prf["$s_new_page_caption"] = $this->titles[$i];
  276. }
  277. }
  278. else
  279. {
  280. $prf["$s_recent_menu_caption"] = $s;
  281. $prf["$s_recent_page_caption"] = $s;
  282. $prf["$s_new_menu_caption"] = $s;
  283. $prf["$s_new_page_caption"] = $s;
  284. }
  285. $prf["$s_recent_menu_display"] = "1";
  286. $prf["$s_recent_menu_open"] = "0";
  287. $prf["$s_recent_menu_author"] = "0";
  288. $prf["$s_recent_menu_category"] = "0";
  289. $prf["$s_recent_menu_date"] = "1";
  290. $prf["$s_recent_menu_amount"] = "5";
  291. $prf["$s_recent_menu_order"] = ($i+1);
  292. $prf["$s_recent_menu_icon"] = '';
  293. $prf["$s_recent_page_display"] = "1";
  294. $prf["$s_recent_page_open"] = "1";
  295. $prf["$s_recent_page_author"] = "1";
  296. $prf["$s_recent_page_category"] = "1";
  297. $prf["$s_recent_page_date"] = "1";
  298. $prf["$s_recent_page_amount"] = "10";
  299. $prf["$s_recent_page_order"] = ($i+1);
  300. $prf["$s_recent_page_icon"] = "1";
  301. $prf["$s_new_menu_display"] = "1";
  302. $prf["$s_new_menu_open"] = "0";
  303. $prf["$s_new_menu_author"] = "0";
  304. $prf["$s_new_menu_category"] = "0";
  305. $prf["$s_new_menu_date"] = "1";
  306. $prf["$s_new_menu_amount"] = "5";
  307. $prf["$s_new_menu_order"] = ($i+1);
  308. $prf["$s_new_menu_icon"] = "1";
  309. $prf["$s_new_page_display"] = "1";
  310. $prf["$s_new_page_open"] = "1";
  311. $prf["$s_new_page_author"] = "1";
  312. $prf["$s_new_page_category"] = "1";
  313. $prf["$s_new_page_date"] = "1";
  314. $prf["$s_new_page_amount"] = "10";
  315. $prf["$s_new_page_order"] = ($i+1);
  316. $prf["$s_new_page_icon"] = "1";
  317. }
  318. //new menu preferences
  319. $prf['new_menu_caption'] = LIST_ADMIN_15;
  320. $prf['new_menu_icon_use'] = "1";
  321. $prf['new_menu_icon_default'] = "1";
  322. $prf['new_menu_char_heading'] = "20";
  323. $prf['new_menu_char_postfix'] = "...";
  324. $prf['new_menu_datestyle'] = "%d %b";
  325. $prf['new_menu_datestyletoday'] = "%H:%M";
  326. $prf['new_menu_showempty'] = "1";
  327. $prf['new_menu_openifrecords'] = '';
  328. //new page preferences
  329. $prf['new_page_caption'] = LIST_ADMIN_15;
  330. $prf['new_page_icon_use'] = "1";
  331. $prf['new_page_icon_default'] = "1";
  332. $prf['new_page_char_heading'] = '';
  333. $prf['new_page_char_postfix'] = '';
  334. $prf['new_page_datestyle'] = "%d %b";
  335. $prf['new_page_datestyletoday'] = "%H:%M";
  336. $prf['new_page_showempty'] = "1";
  337. $prf['new_page_colomn'] = "1";
  338. $prf['new_page_welcometext'] = LIST_ADMIN_16;
  339. $prf['new_page_timelapse'] = "1";
  340. $prf['new_page_timelapse_days'] = "30";
  341. $prf['new_page_openifrecords'] = '';
  342. //recent menu preferences
  343. $prf['recent_menu_caption'] = LIST_ADMIN_14;
  344. $prf['recent_menu_icon_use'] = "1";
  345. $prf['recent_menu_icon_default'] = "1";
  346. $prf['recent_menu_char_heading'] = "20";
  347. $prf['recent_menu_char_postfix'] = "...";
  348. $prf['recent_menu_datestyle'] = "%d %b";
  349. $prf['recent_menu_datestyletoday'] = "%H:%M";
  350. $prf['recent_menu_showempty'] = '';
  351. $prf['recent_menu_openifrecords'] = '';
  352. //recent page preferences
  353. $prf['recent_page_caption'] = LIST_ADMIN_14;
  354. $prf['recent_page_icon_use'] = "1";
  355. $prf['recent_page_icon_default'] = "1";
  356. $prf['recent_page_char_heading'] = '';
  357. $prf['recent_page_char_postfix'] = '';
  358. $prf['recent_page_datestyle'] = "%d %b";
  359. $prf['recent_page_datestyletoday'] = "%H:%M";
  360. $prf['recent_page_showempty'] = '';
  361. $prf['recent_page_colomn'] = "1";
  362. $prf['recent_page_welcometext'] = LIST_ADMIN_13;
  363. $prf['recent_page_openifrecords'] = '';
  364. return $prf;
  365. }
  366. /**
  367. * displaySection, prepare and render a section
  368. *
  369. * @param array $arr the array of preferences for this section
  370. * @return string
  371. *
  372. */
  373. function displaySection($arr)
  374. {
  375. //set settings
  376. $this->settings = $arr;
  377. //get content sections
  378. $this->getContentSections();
  379. //load e_list file
  380. $this->data = $this->load_elist();
  381. //$this->shortcodes->rc->data = $this->data;
  382. //set record variables
  383. $this->row = array();
  384. $this->row['caption'] = '';
  385. $this->row['icon'] = '';
  386. $this->row['date'] = '';
  387. $this->row['heading'] = '';
  388. $this->row['author'] = '';
  389. $this->row['category'] = '';
  390. $this->row['info'] = '';
  391. $text = '';
  392. switch($this->mode)
  393. {
  394. case 'recent_menu':
  395. $text .= $this->parseRecord('MENU_RECENT');
  396. break;
  397. case 'new_menu':
  398. $text .= $this->parseRecord('MENU_NEW');
  399. break;
  400. case 'recent_page':
  401. $text .= $this->parseRecord('PAGE_RECENT');
  402. break;
  403. case 'new_page':
  404. $text .= $this->parseRecord('PAGE_NEW');
  405. break;
  406. }
  407. return $text;
  408. }
  409. /**
  410. * parseRecord renders the items within a section
  411. *
  412. * @param string $area the area for display
  413. * @return string
  414. *
  415. */
  416. function parseRecord($area)
  417. {
  418. if(!in_array($area, array('MENU_RECENT', 'MENU_NEW', 'PAGE_RECENT', 'PAGE_NEW')))
  419. {
  420. return;
  421. }
  422. //echo "parse: ".$area."_START<br />";
  423. $text = $this->parseTemplate($area.'_START');
  424. if(is_array($this->data['records']))
  425. {
  426. foreach($this->data['records'] as $this->row)
  427. {
  428. $this->shortcodes->row = $this->row;
  429. //echo "parse: ".$area."<br />";
  430. $text .= $this->parseTemplate($area);
  431. }
  432. }
  433. elseif(!is_array($this->data['records']) && $this->data['records'] != "")
  434. {
  435. if($this->list_pref[$this->mode."_showempty"])
  436. {
  437. // $this->row['heading'] = $this->data['records'];
  438. $this->shortcodes->row['heading'] = $this->data['records'];
  439. //echo "parse: ".$area."<br />";
  440. $text .= $this->parseTemplate($area);
  441. }
  442. }
  443. //echo "parse: ".$area."_END<br />";
  444. $text .= $this->parseTemplate($area.'_END');
  445. return $text;
  446. }
  447. /**
  448. * load_elist loads and checks all e_list.php files
  449. *
  450. * @return array
  451. *
  452. */
  453. function load_elist()
  454. {
  455. $listArray = '';
  456. //require is needed here instead of require_once, since both the menu and the page could be visible at the same time
  457. if(is_array($this->content_types) && in_array($this->settings['section'], $this->content_types))
  458. {
  459. $file = $this->content_name;
  460. if(is_readable(e_PLUGIN.$file."/e_list.php"))
  461. {
  462. $this->mode_content = $this->settings['section'];
  463. //echo "require: ".e_PLUGIN.$file."/e_list.php<br />";
  464. require_once(e_PLUGIN.$file."/e_list.php");
  465. $listArray = $this->load_data($file);
  466. }
  467. }
  468. else
  469. {
  470. $file = $this->settings['section'];
  471. if(in_array($file, $this->defaultArray))
  472. {
  473. //echo "require: ".$this->plugin_dir."section/list_".$file.".php<br />";
  474. require_once($this->plugin_dir."section/list_".$file.".php");
  475. $listArray = $this->load_data($file);
  476. }
  477. else
  478. {
  479. if (plugInstalled($file))
  480. {
  481. if(is_readable(e_PLUGIN.$file."/e_list.php"))
  482. {
  483. //echo "require: ".e_PLUGIN.$file."/e_list.php<br />";
  484. require_once(e_PLUGIN.$file."/e_list.php");
  485. $listArray = $this->load_data($file);
  486. }
  487. }
  488. }
  489. }
  490. return $listArray;
  491. }
  492. /**
  493. * load_data calls the class from the e_list file and retrieves the data
  494. *
  495. * @param string $file the section to load (class name)
  496. * @return array
  497. *
  498. */
  499. function load_data($file)
  500. {
  501. $name = "list_".$file;
  502. $listArray = '';
  503. //instantiate the class with this as parm
  504. if(!class_exists($name))
  505. {
  506. //echo "class $name doesn't exist<br />";
  507. }
  508. else
  509. {
  510. $class = new $name($this);
  511. //call method
  512. if(!method_exists($class, 'getListData'))
  513. {
  514. //echo "method getListData doesn't exist in class $class<br />";
  515. }
  516. else
  517. {
  518. $listArray = $class->getListData();
  519. if (e107::getPref('profanity_filter'))
  520. {
  521. $tp = e107::getParser();
  522. if (!is_object($parser->e_pf))
  523. {
  524. // require_once(e_HANDLER.'profanity_filter.php');
  525. $parser->e_pf = new e_profanityFilter;
  526. }
  527. foreach ($listArray as $k => $v)
  528. {
  529. if (isset($v['heading']))
  530. {
  531. $listArray[$k]['heading'] = $tp->e_pf->filterProfanities($v['heading']);
  532. }
  533. }
  534. }
  535. }
  536. }
  537. return $listArray;
  538. }
  539. /**
  540. * get datestamp last visit
  541. *
  542. * @return int datestamp
  543. *
  544. */
  545. function getlvisit()
  546. {
  547. global $qs;
  548. $lvisit = defined('USERLV') ? USERLV : time() + 1000; // Set default value
  549. if(varsettrue($qs[0]) == "new")
  550. {
  551. if(varsettrue($this->list_pref['new_page_timelapse']))
  552. {
  553. if(varsettrue($this->list_pref['new_page_timelapse_days']) && is_numeric($this->list_pref['new_page_timelapse_days']))
  554. {
  555. $days = $this->list_pref['new_page_timelapse_days'];
  556. }
  557. else
  558. {
  559. $days = "30";
  560. }
  561. if(isset($qs[1]) && is_numeric($qs[1]) && $qs[1] <= $days)
  562. {
  563. $lvisit = time()-$qs[1]*86400;
  564. }
  565. }
  566. }
  567. return $lvisit;
  568. }
  569. /**
  570. * get bullet icon, either use the icon set in admin or the default theme bullet
  571. *
  572. * @param string $icon the icon to use as set in admin
  573. * @return string $bullet
  574. *
  575. */
  576. function getBullet($icon)
  577. {
  578. $default_bullet = '';
  579. if($this->list_pref[$this->mode."_icon_default"])
  580. {
  581. if(defined('BULLET'))
  582. {
  583. $default_bullet = '<img src="'.THEME.'images/'.BULLET.'" alt="" class="icon" />';
  584. }
  585. elseif(file_exists(THEME.'images/bullet2.gif'))
  586. {
  587. $default_bullet = '<img src="'.THEME.'images/bullet2.gif" alt="" class="icon" />';
  588. }
  589. }
  590. $icon_width = '8';
  591. $icon_height = '8';
  592. $style_pre = '';
  593. if($this->list_pref[$this->mode."_icon_use"])
  594. {
  595. if($icon)
  596. {
  597. if(is_readable($this->plugin_dir."images/".$icon))
  598. {
  599. $bullet = "<img src='".$this->plugin_dir."images/".$icon."' alt='' />";
  600. }
  601. }
  602. }
  603. $bullet = varsettrue($bullet, $default_bullet);
  604. return $bullet;
  605. }
  606. /**
  607. * helper method, parse heading to specific length with postfix
  608. *
  609. * @param string $heading the heading from the item record
  610. * @return string $heading the parsed heading
  611. *
  612. */
  613. function parse_heading($heading)
  614. {
  615. if($this->list_pref[$this->mode."_char_heading"] && strlen($heading) > $this->list_pref[$this->mode."_char_heading"])
  616. {
  617. $heading = substr($heading, 0, $this->list_pref[$this->mode."_char_heading"]).$this->list_pref[$this->mode."_char_postfix"];
  618. }
  619. return $heading;
  620. }
  621. /**
  622. * helper method, format the date
  623. *
  624. * @param int $datestamp the datestamp of the item record
  625. * @return string the formatted date
  626. *
  627. */
  628. function getListDate($datestamp)
  629. {
  630. $datestamp += TIMEOFFSET;
  631. $todayarray = getdate();
  632. $current_day = $todayarray['mday'];
  633. $current_month = $todayarray['mon'];
  634. $current_year = $todayarray['year'];
  635. $thisday = date("d", $datestamp);
  636. $thismonth = date("m", $datestamp);
  637. $thisyear = date("Y", $datestamp);
  638. //check and use the today date style if day is today
  639. if($thisyear == $current_year)
  640. {
  641. if($thismonth == $current_month)
  642. {
  643. if($thisday == $current_day)
  644. {
  645. $datepreftoday = $this->list_pref[$this->mode."_datestyletoday"];
  646. return strftime($datepreftoday, $datestamp);
  647. }
  648. }
  649. }
  650. //else use default date style
  651. $datepref = $this->list_pref[$this->mode."_datestyle"];
  652. return strftime($datepref, $datestamp);
  653. }
  654. /**
  655. * display timelapse element (on newpage)
  656. *
  657. * @return string the timelapse element
  658. *
  659. */
  660. function displayTimelapse()
  661. {
  662. global $rs; //FIXME $frm
  663. if(isset($this->list_pref['new_page_timelapse']) && $this->list_pref['new_page_timelapse'])
  664. {
  665. if(isset($this->list_pref['new_page_timelapse_days']) && is_numeric($this->list_pref['new_page_timelapse_days']))
  666. {
  667. $days = $this->list_pref['new_page_timelapse_days'];
  668. }
  669. else
  670. {
  671. $days = '30';
  672. }
  673. $timelapse = 0;
  674. if(isset($qs[1]) && is_numeric($qs[1]) && $qs[1] <= $days)
  675. {
  676. $timelapse = $qs[1];
  677. }
  678. $url = $this->plugin_dir."list.php?new";
  679. $selectjs = "onchange=\"if(this.options[this.selectedIndex].value != 'none'){ return document.location=this.options[this.selectedIndex].value; }\"";
  680. $this->row['timelapse'] = LIST_MENU_6;
  681. $this->row['timelapse'] .= $rs->form_select_open("timelapse", $selectjs).$rs->form_option(LIST_MENU_5, 0, $url);
  682. for($a=1; $a<=$days; $a++)
  683. {
  684. $this->row['timelapse'] .= $rs->form_option($a, ($timelapse == $a ? '1' : '0'), $url.".".$a);
  685. }
  686. $this->row['timelapse'] .= $rs->form_select_close();
  687. return $this->parseTemplate('TIMELAPSE_TABLE');
  688. }
  689. return;
  690. }
  691. /**
  692. * display the page (either recent or new)
  693. *
  694. * @return string
  695. *
  696. */
  697. function displayPage()
  698. {
  699. global $qs;
  700. //get preferences
  701. if(!isset($this->list_pref))
  702. {
  703. $this->list_pref = $this->getListPrefs();
  704. $this->shortcodes->list_pref = $this->list_pref;
  705. }
  706. //get sections
  707. $this->sections = $this->prepareSection($this->mode);
  708. $arr = $this->prepareSectionArray($this->mode);
  709. //timelapse
  710. if(varsettrue($qs[0]) == "new")
  711. {
  712. $text .= $this->displayTimelapse();
  713. }
  714. $text .= $this->parseTemplate('COL_START');
  715. //welcometext
  716. if($this->list_pref[$this->mode."_welcometext"])
  717. {
  718. $text .= $this->parseTemplate('COL_WELCOME');
  719. }
  720. //display the sections
  721. $k=0;
  722. foreach($arr as $sect)
  723. {
  724. if($sect['display'] == '1')
  725. {
  726. $sectiontext = $this->displaySection($sect);
  727. if($sectiontext != '')
  728. {
  729. $v = $k/$this->list_pref[$this->mode."_colomn"];
  730. if( intval($v) == $v )
  731. {
  732. $text .= $this->parseTemplate('COL_ROWSWITCH');
  733. }
  734. $text .= $this->parseTemplate('COL_CELL_START');
  735. $text .= $sectiontext;
  736. $text .= $this->parseTemplate('COL_CELL_END');
  737. $k++;
  738. }
  739. }
  740. }
  741. $text .= $this->parseTemplate('COL_END');
  742. return $text;
  743. }
  744. /**
  745. * display the menu (either recent or new)
  746. *
  747. * @return string
  748. *
  749. */
  750. function displayMenu()
  751. {
  752. //get preferences
  753. if(!isset($this->list_pref))
  754. {
  755. $this->list_pref = $this->getListPrefs();
  756. $this->shortcodes->list_pref = $this->list_pref;
  757. }
  758. //get sections
  759. $this->sections = $this->prepareSection($this->mode);
  760. $arr = $this->prepareSectionArray($this->mode);
  761. //display the sections
  762. $text = '';
  763. foreach($arr as $sect)
  764. {
  765. if($sect['display'] == '1')
  766. {
  767. $sectiontext = $this->displaySection($sect);
  768. if($sectiontext != '')
  769. {
  770. $text .= $sectiontext;
  771. }
  772. }
  773. }
  774. return $text;
  775. }
  776. }
  777. ?>