Simple status box for the sidebar.
[elgg_plugins.git] / presentation / view.php
blob272983ec7d51af834b47a8cb74ab191ab3c92864
1 <?php
2 /**
3 * Elgg Presentation tool
4 *
5 * @author Sven Edge
6 * @package mod_presentation
7 */
9 // Load Elgg framework
10 @require_once("../../includes.php");
12 // Define context
13 define("context","presentation");
15 // Load global variables
16 global $CFG, $PAGE, $page_owner, $profile_id, $metatags, $template, $template_name;
18 // Initialise page body and title
19 $body = "";
20 $title = __gettext("View Presentation");
22 $view = optional_param('view');
23 if ($view == "clean") {
24 // non-elgg in-elgg view
26 $template_name = '';
27 templates_page_setup();
29 $metatags = '';
30 //var_dump($template_name);
31 $metatags .= "\n" . '<script type="text/javascript" src="' . $CFG->wwwroot . 'mod/presentation/presentation.js"></script>' . "\n";
33 $template['pageshell'] = file_get_contents($CFG->dirroot . "mod/presentation/plainviewpageshell.html");
34 $template['css'] = file_get_contents($CFG->dirroot . "mod/presentation/presentation.css");
35 $template['css'] .= file_get_contents($CFG->dirroot . "mod/presentation/plainviewpageshell.css");
36 //var_dump($template);
39 $pres = optional_param('id',0,PARAM_INT);
40 if ($presrec = get_record("presentations", "ident", $pres)) {
41 $page_owner = $presrec->owner;
42 $profile_id = $page_owner;
43 $ownername = user_info("username",$page_owner);
45 $title = run("profile:display:name", $page_owner) . " :: " . __gettext("View Presentation");
47 if (isloggedin() && $presrec->owner == $USER->ident) {
48 $PAGE->menu_sub[] = array(
49 'name' => 'presentation:edit',
50 'html' => a_href(
51 $CFG->wwwroot . $ownername . '/presentations/' . $presrec->ident . '/edit',
52 __gettext("Edit")
57 $PAGE->menu_sub[] = array(
58 'name' => 'presentation:edit',
59 'html' => a_href(
60 $CFG->wwwroot . $ownername . '/presentations/' . $presrec->ident . '/clean',
61 __gettext("Plain View")
65 if ($view != "clean") {
66 templates_page_setup();
69 $presentationsallowed = presentation_get_presentations_visible($page_owner);
70 //var_dump($presentationsallowed);
72 if ($presrec && $presentationsallowed && array_key_exists($presrec->ident, $presentationsallowed)) {
74 $tinymceids = array();
76 $body .= '<h1>';
77 if ($view == "clean") {
78 $body .= '<a href="' . $CFG->wwwroot . $ownername . '/profile/">' . run("profile:display:name", $presrec->owner) . '</a> :: ';
80 $body .= htmlspecialchars($presrec->name) . "</h1>";
82 if ($view == "clean") {
83 $menuedit = false;
84 $menucomments = true;
85 $disableaddcommentsform = true;
86 } else {
87 $menuedit = false;
88 $menucomments = true;
89 $disableaddcommentsform = false;
91 if ($sections = presentation_get_sections($presrec->ident)) {
92 //var_dump($sections);
94 $body .= '<div class="presentation-contentslist"><h2><a href="javascript:toggleVisibility(\'presentationcontentslist\')">' . __gettext('Contents') . '</a></h2><ol id="presentationcontentslist">';
95 $i=1;
96 foreach ($sections as $asection) {
97 $atitle = presentation_section_gettitle($asection);
98 $body .= '<li><a href="#sectop' . $i . '">' . $atitle . '</a></li>';
99 $i++;
101 $body .= '</ol>
102 <script type="text/javascript">
103 <!--
104 toggleVisibility(\'presentationcontentslist\');
105 // -->
106 </script><!-- --></div>
109 $i=1;
110 foreach ($sections as $asection) {
111 $body .= '<a name="sectop' . $i . '"></a>' . presentation_section_display($asection, $menuedit, $menucomments, $disableaddcommentsform);
112 $tinymceids[] = 'commentbodyp' . $presrec->ident . 's' . $asection->ident;
113 $i++;
116 } else {
117 $body .= "<p>" . __gettext("This presentation doesn't have any content yet.") . "</p>\n";
120 $numcomments = 0;
121 if ($comments = presentation_get_comments($presrec->ident, 0)) {
122 $numcomments = count($comments);
124 $body .= "<h2>";
125 if ($view == "clean") {
126 $body .= '<a href="javascript:toggleVisibility(\'presentationoverallcomments\')">';
128 $body .= sprintf(__gettext('%s Presentation Comments'), $numcomments);
129 if ($view == "clean") {
130 $body .= '</a>';
132 $body .= "</h2>\n";
133 $body .= '<div id="presentationoverallcomments">';
135 if ($numcomments) {
136 $body .= presentation_comments_display($presrec->ident, 0, $comments);
139 if (logged_on || (!$CFG->disable_publiccomments && user_flag_get("publiccomments",$presrec->owner)) ) {
140 $tinymceids[] = 'commentbodyp' . $presrec->ident . 's0';
141 $body .= presentation_comments_add_form($presrec->ident, 0, $_SERVER['REQUEST_URI']);
142 } else {
143 $body .= "<p>" . __gettext("You must be logged in to post a comment.") . "</p>";
146 $body .= '</div>';
148 if ($view == "clean") {
149 $body .= <<< END
150 <script type="text/javascript">
151 <!--
152 toggleVisibility('presentationoverallcomments');
153 // -->
154 </script>
155 <!-- -->
156 END;
159 run('tinymce:include', array($tinymceids) );
161 } else {
162 $body = __gettext('Error: Access denied.');
164 } else {
165 $body = __gettext('Error: Presentation not found.');
175 if ($view == "clean") {
177 // non-elgg in-elgg view
178 echo templates_page_draw( array(
179 $title, $body
183 } else {
185 // Output to the screen
186 $body = templates_draw(array(
187 'context' => 'contentholder',
188 'title' => $title,
189 'body' => $body
193 echo templates_page_draw( array(
194 $title, $body