PageRenderTime 56ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 1ms

/wp-content/plugins/simple-forum/forum/sf-forum-view.php

https://bitbucket.org/crypticrod/sr_wp_code
PHP | 183 lines | 123 code | 32 blank | 28 comment | 40 complexity | aadf870d32d7b229a17eb473a062e361 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.1, GPL-3.0, LGPL-2.0, AGPL-3.0
  1. <?php
  2. /*
  3. Simple:Press
  4. Forum View Display
  5. $LastChangedDate: 2010-11-18 07:46:36 -0700 (Thu, 18 Nov 2010) $
  6. $Rev: 4960 $
  7. */
  8. if(preg_match('#' . basename(__FILE__) . '#', $_SERVER['PHP_SELF'])) {
  9. die('Access Denied');
  10. }
  11. function sf_render_forum()
  12. {
  13. global $sfvars, $current_user, $sfglobals;
  14. $forumid = $sfvars['forumid'];
  15. if (!sf_forum_exists($forumid))
  16. {
  17. status_header(404);
  18. $sfvars['error'] = true;
  19. update_sfnotice('sfmessage', '1@'.sprintf(__('Forum %s Not Found', 'sforum'), $sfvars['forumslug']));
  20. $out = sf_render_queued_message();
  21. $out.= '<div class="sfmessagestrip">'."\n";
  22. $out.= sprintf(__("There is no such forum named %s", "sforum"), $sfvars['forumslug'])."\n";
  23. $out.= '</div>'."\n";
  24. return $out;
  25. }
  26. # Setup stuff we will need for the query
  27. if (empty($sfvars['page'])) ($sfvars['page'] = 1);
  28. if (empty($sfvars['searchvalue']) ? $search = false : $search = true);
  29. $showadd = false;
  30. # grab the records for this page
  31. $forums = sf_get_combined_forums_and_topics($sfvars['forumid'], $sfvars['page']);
  32. # If No Access to anything then return access denied flag
  33. if ($forums[0]['forum_id'] == "Access Denied") return 'Access Denied';
  34. if ($forums)
  35. {
  36. # grab the complete first/last post stats
  37. $posts = array();
  38. foreach ($forums as $forum)
  39. {
  40. if (isset($forum['topics']))
  41. {
  42. foreach ($forum['topics'] as $topic)
  43. {
  44. $posts[$topic['topic_id']] = $topic['post_count'];
  45. }
  46. }
  47. }
  48. $stats = sf_get_combined_topic_stats($posts, $current_user->ID);
  49. foreach ($forums as $forum)
  50. {
  51. $out = '';
  52. if (($forum['children']) != '' && $search == false)
  53. {
  54. $out.= sf_render_subforums(sf_filter_title_display($forum['forum_name']), $forum['children'], $forum['group_id']);
  55. }
  56. # setup more vars settings later
  57. if ($forum['forum_status'] ? $forumlock=true : $forumlock=false);
  58. if (($sfglobals['admin']['sftools'] && $current_user->sfforumicons) ? $admintools=true : $admintools=false);
  59. # == IS FORUM LOCKED OR CAN WE ADD
  60. if ($current_user->sfaddnew) $showadd = true;
  61. if ($forumlock) $showadd = false;
  62. if ($current_user->forumadmin) $showadd = true;
  63. if ($sfglobals['lockdown']) $showadd = false;
  64. # Setup more stuff we will need
  65. $coldisplaytext = sf_render_search_heading($search);
  66. # make sure we have some page links (top/bottom/both)
  67. $pageoverride = false;
  68. if($search == true && $sfglobals['display']['pagelinks']['ptop'] == false && $sfglobals['display']['pagelinks']['pbottom'] == false)
  69. {
  70. $pageoverride = true;
  71. }
  72. # Setup page links for this topic
  73. $thispagelinks = sf_compile_paged_topics($sfvars['forumslug'], $sfvars['forumid'], $sfvars['page'], $search, $sfvars['searchpage'], $forum['topic_count']);
  74. # Setup forum icon
  75. if (!empty($forum['forum_icon']))
  76. {
  77. $icon = SFCUSTOMURL.$forum['forum_icon'];
  78. } else {
  79. $icon = SFRESOURCES.'forum.png';
  80. }
  81. # Start display
  82. # Display forum header
  83. $out.= '<div id="forum-'.$forum['forum_id'].'" class="sfblock">'."\n";
  84. $out.= sf_render_main_header_table('forum', '', sf_filter_title_display($forum['forum_name']), sf_filter_text_display($forum['forum_desc']), $icon, $forumlock, $showadd);
  85. # Display top page link navigation
  86. $out.= sf_render_topic_pagelinks($thispagelinks, false, $showadd, $forumlock, true, $pageoverride);
  87. if (isset($forum['topics']))
  88. {
  89. # Special Message
  90. if (!empty($forum['forum_message']))
  91. {
  92. $out.= sf_render_special_forum_message(sf_filter_text_display($forum['forum_message']));
  93. }
  94. $out.= '<table class="sfforumtable">'."\n";
  95. # Display topic column headers
  96. $out.= sf_render_forum_column_header_row($coldisplaytext);
  97. $alt = '';
  98. $value['forumlock']=$forumlock;
  99. $value['admintools']=$admintools;
  100. foreach ($forum['topics'] as $topic)
  101. {
  102. # Display current topic row
  103. $out.= sf_render_topic_entry_row($forum, $topic, $stats[$topic['topic_id']], $value, $alt);
  104. if ($alt == '') $alt = 'sfalt'; else $alt = '';
  105. }
  106. $out.= '</table>'."\n";
  107. # Display bottom page link navigation
  108. $out.= sf_render_topic_pagelinks($thispagelinks, true, $showadd, $forumlock, true, $pageoverride);
  109. # Store the topic page so that we can get back to it later
  110. sf_push_topic_page($sfvars['forumid'], $sfvars['page']);
  111. } else {
  112. if ($search)
  113. {
  114. $out.= '<div class="sfmessagestrip">'.__("The Search found No Results", "sforum").'</div>'."\n";
  115. } else {
  116. if (!empty($forum['forum_message']))
  117. {
  118. $out.= sf_render_special_forum_message(sf_filter_text_display($forum['forum_message']));
  119. }
  120. $out.= '<div class="sfmessagestrip">'.__("There are No Topics defined in this Forum", "sforum").'</div>'."\n";
  121. # Display bottom page link navigation
  122. $out.= sf_render_topic_pagelinks($thispagelinks, true, $showadd, $forumlock, true, $pageoverride);
  123. }
  124. }
  125. }
  126. }
  127. $out.= '</div>'."\n";
  128. # Display new (hidden) topic form
  129. if ($showadd)
  130. {
  131. $out.= '<a id="dataform"></a>'."\n";
  132. $out.= sf_add_topic($sfvars['forumid'], $forum['forum_name'], $forum['topic_status_set'], $forum['use_tags'], $current_user->ID);
  133. if (isset($_GET['new']) && $_GET['new'] == 'topic')
  134. {
  135. # inline js to open topic form
  136. add_action( 'wp_footer', 'sfjs_open_topic_form' );
  137. }
  138. }
  139. return $out;
  140. }
  141. # inline opens add topic wondow of called frm post view
  142. function sfjs_open_topic_form() {
  143. ?>
  144. <script type="text/javascript">
  145. jQuery(document).ready(function() {
  146. sfjtoggleLayer("sfpostform");
  147. });
  148. </script>
  149. <?php
  150. }
  151. ?>