index.php 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. ////////////////////////////////////////////////////////////////////////////////
  3. // Copyright (C) ReloadCMS Development Team //
  4. // http://reloadcms.sf.net //
  5. // //
  6. // This program is distributed in the hope that it will be useful, //
  7. // but WITHOUT ANY WARRANTY, without even the implied warranty of //
  8. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
  9. // //
  10. // This product released under GNU General Public License v2 //
  11. ////////////////////////////////////////////////////////////////////////////////
  12. $intro = file_get_contents(DATA_PATH . 'intro.html');
  13. if(!empty($intro) && !@$system->config['wmh']){
  14. show_window('', $intro, 'left');
  15. }
  16. if(!empty($menu_points['index-menus'])){
  17. $old_point = $system->current_point;
  18. $system->setCurrentPoint('index-menus');
  19. $c_module = $module;
  20. foreach ($menu_points['index-menus'] as $menu){
  21. if(substr($menu, 0, 4) == 'ucm:' && is_readable(DF_PATH . substr($menu, 4) . '.ucm')) {
  22. $file = file(DF_PATH . substr($menu, 4) . '.ucm');
  23. $title = preg_replace("/[\n\r]+/", '', $file[0]);
  24. $align = preg_replace("/[\n\r]+/", '', $file[1]);
  25. unset($file[0]);
  26. unset($file[1]);
  27. show_window($title, implode('', $file), $align);
  28. } elseif (!empty($system->modules['menu'][$menu])){
  29. $module = $menu;
  30. $module_dir = MODULES_PATH . $menu;
  31. require(MODULES_PATH . $menu . '/index.php');
  32. } else {
  33. show_window('', __('Module not found'), 'center');
  34. }
  35. }
  36. $system->setCurrentPoint('index-main');
  37. $module = $c_module;
  38. }
  39. if(empty($system->config['index_module']) || $system->config['index_module'] == 'news' || $system->config['index_module'] == 'default'){
  40. $articles = new articles();
  41. if(!$articles->setWorkContainer('news')){
  42. show_error($articles->last_error);
  43. } else {
  44. $result = '';
  45. if(($list = $articles->getStat('time')) !== false){
  46. if(!empty($system->config['perpage'])) {
  47. $pages = ceil(sizeof($list) / $system->config['perpage']);
  48. if(!empty($_GET['page']) && ((int) $_GET['page']) > 0) {
  49. $page = ((int) $_GET['page'])-1;
  50. } else {
  51. $page = 0;
  52. }
  53. $start = $page * $system->config['perpage'];
  54. $total = $system->config['perpage'];
  55. $end = $total + $start;
  56. if($end > sizeof($list)) $end = sizeof($list);
  57. } else {
  58. $pages = 1;
  59. $page = 0;
  60. $start = 0;
  61. $total = sizeof($list);
  62. }
  63. $keys = array_keys($list);
  64. for ($a = $start; $a < $end; $a++){
  65. $time = &$list[$keys[$a]];
  66. $id = explode('.', $keys[$a]);
  67. if(($category = $articles->getCategory($id[0], true)) !== false && ($article = $articles->getArticle($id[0], $id[1], true, true, false, false)) !== false){
  68. $result .= rcms_parse_module_template('art-article.tpl', $article + array('showtitle' => true,
  69. 'linktext' => (($article['text_nonempty']) ? __('Read more...') : __('Comments')) . ' (' . $article['comcnt'] . '/' . $article['views'] . ')',
  70. 'iconurl' => '?module=articles&amp;c=news&amp;b=' . $id[0],
  71. 'linkurl' => '?module=articles&amp;c=news&amp;b=' . $id[0] . '&amp;a=' . $article['id'],
  72. 'cat_data' => $category));
  73. }
  74. }
  75. $result .= '<div align="right">' . rcms_pagination(sizeof($list), $system->config['perpage'], $page + 1, '?module=' . $module) . '</div>';
  76. }
  77. show_window(__('Latest news'), $result);
  78. }
  79. $system->config['pagename'] = __('Latest news');
  80. } elseif ($system->config['index_module'] != 'empty' && !empty($system->modules['main'][$module])){
  81. $my_module = $module;
  82. $module = $system->config['index_module'];
  83. include_once(MODULES_PATH . $module . '/index.php');
  84. $module = $my_module;
  85. }
  86. if(!empty($menu_points['index-menus'])){
  87. $system->setCurrentPoint($old_point);
  88. show_window(__('Index'), rcms_parse_module_template('index.tpl'));
  89. }
  90. ?>