The best way to learn how to use the WebCore is by example. See the documentation for more information.
The requested URL is always shown first; if a page uses one or more WebCore templates, those are shown afterwards.
Source for: https://www.earthli.com/news/view_article.php
Uses WebCore template(s):
00 <?php
01
02 /****************************************************************************
03
04 Copyright (c) 2002-2014 Marco Von Ballmoos
05
06 This file is part of earthli News.
07
08 earthli News is free software; you can redistribute it and/or modify
09 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
12
13 earthli News is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with earthli News; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
22 For more information about the earthli News, visit:
23
24 http://www.earthli.com/software/webcore/news
25
26 ****************************************************************************/
27
28 require_once ('news/start.php');
29 require_once ($App->page_template_for ('webcore/pages/view_entry.php'));
30 ?>
31
Source for template: webcore/pages/view_entry.php
00 <?php
01
02 /****************************************************************************
03 *
04 * Copyright (c) 2002-2014 Marco Von Ballmoos
05 *
06 * This file is part of earthli WebCore.
07 *
08 * earthli WebCore is free software; you can redistribute it and/or modify
09 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * earthli WebCore is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with earthli WebCore; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 * For more information about the earthli WebCore, visit:
23 *
24 * http://www.earthli.com/software/webcore
25 ****************************************************************************/
26
27 $id = read_var ('id');
28
29 /** @var APPLICATION $App */
30 $folder_query = $App->login->folder_query ();
31 $folder = $folder_query->folder_for_entry_at_id ($id);
32
33 if (isset ($folder))
34 {
35 $entry_query = $folder->entry_query ();
36
37 /* Set this global value to optimize the query for accessing the particular
38 type of entry. */
39 if (isset ($entry_type_id))
40 {
41 $entry_query->set_type ($entry_type_id);
42 }
43
44 /** @var $entry ENTRY */
45 $entry = $entry_query->object_at_id ($id);
46 }
47
48 if (isset($entry_query) && isset ($entry) && $App->login->is_allowed (Privilege_set_entry, Privilege_view, $entry))
49 {
50 $App->set_referer ();
51 $App->set_search_text (read_var ('search_text'));
52
53 /** @var THEMED_PAGE $Page */
54 $Page->social_options->enabled = true;
55 $entry->set_social_options($Page->social_options);
56
57 $entry_info = $entry->type_info ();
58
59 /** @var $location_renderer LOCATION_RENDERER */
60 $location_renderer = $entry->handler_for (Handler_location);
61 $location_renderer->add_to_page_as_text ($Page, $entry);
62
63 /** @var $navigator OBJECT_NAVIGATOR */
64 $navigator = $entry->handler_for (Handler_navigator);
65 $navigator->set_query ($entry_query);
66 $navigator->set_selected ($id);
67 $has_multiple_entries = $navigator->size () > 1;
68
69 include_once ('webcore/util/options.php');
70 $mobile_option = new STORED_OPTION ($App, "mobile_mode_{$entry_info->id}");
71 $mobile_mode = $mobile_option->value ();
72
73 if ($mobile_mode === null)
74 {
75 $mobile_mode = isset($mobile_mode_default) ? $mobile_mode_default : 0;
76 }
77
78 $Page->add_script_file ('{scripts}swiped-events.min.js');
79
80 if (!$mobile_mode)
81 {
82 $Page->start_display ();
83 ?>
84 <div class="top-box">
85 <?php
86
87 if ($has_multiple_entries)
88 {
89 $show_list_option = new STORED_OPTION ($App, "show_{$entry_info->id}_list");
90 $show_entry_list = $show_list_option->value ();
91
92 $show_links = ($navigator->size () > 1) && $show_entry_list;
93
94 echo '<div class="object-navigator">';
95
96 if ($show_links)
97 {
98 ?>
99 <div class="links">
100 <?php echo $navigator->list_near_selected (); ?>
101 </div>
102 <?php
103 }
104
105 echo '</div>';
106
107 echo '<div class="button-content">';
108 echo '<span class="pager">';
109 echo $navigator->controls ();
110 echo "\n<script>" . $navigator->shortcut_key_scripts () . "</script>";
111 echo '</span>';
112
113 if (!$show_entry_list)
114 {
115 $icon = '{icons}buttons/show_list';
116 $caption = 'Show list';
117 }
118 else
119 {
120 $icon = '{icons}buttons/close';
121 $caption = 'Hide list';
122 }
123
124 $show_list_option_link = $show_list_option->setter_url_as_html (!$show_entry_list);
125
126 ?><a href="<?php echo $show_list_option_link; ?>"
127 class="button"><?php echo $Page->get_icon_with_text ($icon, Sixteen_px, $caption); ?></a><?php
128
129 $icon = '{icons}indicators/high_green';
130 $caption = 'Mobile Mode';
131
132 $mobile_mode_link = $mobile_option->setter_url_as_html (!$mobile_mode);
133
134 ?><a href="<?php echo $mobile_mode_link; ?>"
135 class="button"><?php echo $Page->get_icon_with_text ($icon, Sixteen_px, $caption); ?></a><?php
136 }
137 else
138 {
139 echo '<div class="button-content">';
140
141 $icon = '{icons}indicators/high_green';
142 $caption = 'Mobile Mode';
143
144 $mobile_mode_link = $mobile_option->setter_url_as_html (!$mobile_mode);
145
146 ?><a href="<?php echo $mobile_mode_link; ?>"
147 class="button"><?php echo $Page->get_icon_with_text ($icon, Sixteen_px, $caption); ?></a><?php
148 }
149
150 /** @var $command_renderer MENU_RENDERER */
151 $menu_renderer = $entry->handler_for (Handler_menu);
152 $menu_renderer->set_size (Menu_size_standard);
153 /** @var COMMANDS $commands */
154 $commands = $entry->handler_for (Handler_commands);
155 $menu_renderer->display ($commands);
156
157 echo '</div>';
158 ?>
159 </div>
160 <div class="main-box">
161 <div class="text-flow">
162 <h1>
163 <?php
164 $t = $entry->title_formatter ();
165 $t->max_visible_output_chars = 0;
166 echo $entry->title_as_html ($t);
167 ?>
168 </h1>
169 <?php
170 /** @var $object_renderer OBJECT_RENDERER */
171 $object_renderer = $entry->handler_for (Handler_html_renderer);
172 $object_renderer->display ($entry);
173
174 /** @var $associated_data ENTRY_ASSOCIATED_DATA_RENDERER */
175 $associated_data = $entry->handler_for (Handler_associated_data);
176 if (isset ($associated_data))
177 {
178 ?>
179 <div class="clear-both">
180 <?php
181 $associated_data->display ($entry);
182 ?>
183 </div>
184 <?php
185 }
186 ?>
187 </div>
188 </div>
189 <?php
190 }
191 else
192 {
193 $Page->template_options->header_visible = false;
194 $Page->template_options->footer_visible = false;
195 $Page->start_display ();
196 if ($has_multiple_entries)
197 {
198 echo "\n<script>" . $navigator->shortcut_key_scripts () . "</script>";
199 }
200 ?>
201 <div class="text-flow minimal">
202
203 <div class="minimal-commands">
204 <?php
205 /** @var MENU_RENDERER $renderer */
206 $renderer = $entry->handler_for (Handler_menu);
207 $renderer->set_size (Menu_size_minimal);
208 /** @var COMMANDS $commands */
209
210 $quick_commands = new COMMANDS ($App);
211
212 $location_commands = array_reverse ($Page->location->commands->command_list ());
213
214 $mobile_option_command = new COMMAND();
215 $mobile_option_command->caption = 'Close Mobile Mode';
216 $mobile_option_command->icon = '{icons}/buttons/close';
217 $mobile_option_command->link = $mobile_option->setter_url_as_html (!$mobile_mode);
218
219 $quick_commands->append ($mobile_option_command);
220
221 foreach ($location_commands as $command)
222 {
223 if ($command->link || substr ($command->caption, 0, strlen ('<a')) === '<a')
224 {
225 $quick_commands->append ($command, 'Locations');
226 }
227 }
228
229 $renderer->display ($quick_commands);
230 ?>
231 </div>
232 <div class="minimal-commands-content">
233 <h1>
234 <?php
235 $t = $entry->title_formatter ();
236 $t->max_visible_output_chars = 0;
237 echo $entry->title_as_html ($t);
238
239 if ($has_multiple_entries)
240 {
241 $counts = $navigator->counts ();
242 echo " ($counts)";
243 }
244 ?>
245 </h1>
246 </div>
247 <?php
248 /** @var $object_renderer OBJECT_RENDERER */
249 $object_renderer = $entry->handler_for (Handler_html_renderer);
250 $options = new OBJECT_RENDERER_OPTIONS();
251 $options->minimal = true;
252 $object_renderer->display ($entry, $options);
253 ?>
254 </div>
255 <?php
256 /** @var $associated_data ENTRY_ASSOCIATED_DATA_RENDERER */
257 $associated_data = $entry->handler_for (Handler_associated_data);
258 if (isset ($associated_data))
259 {
260 ?>
261 <div class="clear-both">
262 <?php
263 $associated_data->display ($entry);
264 ?>
265 </div>
266 <?php
267 }
268 }
269 $Page->finish_display ();
270 }
271 else
272 {
273 $Page->raise_security_violation ("You are not allowed to view this item.", $folder);
274 }
275 ?>