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/index.php
Uses WebCore template(s):
00 <?php
01
02 /****************************************************************************
03
04 Copyright (c) 2003 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/index.php'));
30
31
Source for template: webcore/pages/index.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
28 /*
29 $show_only_root_folders - Set this to True to prevent the index from loading
30 all the folders in the entire application. With a lot
31 of folders, this is a big performance hit.
32 */
33
34 $App->set_referer ();
35
36 $folder_query = $App->login->folder_query ();
37
38 if (! empty ($show_only_root_folders))
39 {
40 /** @var $folder FOLDER */
41 $folder = $folder_query->object_at_id ($App->root_folder_id);
42 $folder_query->restrict ('parent_id = ' . $App->root_folder_id);
43
44 if (! empty($sort_by_modified))
45 {
46 $sub_query = '(SELECT entry.time_modified FROM ' . $App->table_names->entries . ' entry WHERE entry.owner_id = fldr.owner_id ORDER BY entry.time_modified DESC LIMIT 1) as entry_time_modified';
47
48 $folder_query->add_select ($sub_query);
49 $folder_query->add_order ('entry_time_modified DESC', true);
50 }
51
52 $folders = $folder_query->tree ();
53 }
54 else
55 {
56 $folders = $folder_query->root_tree ($App->root_folder_id);
57 $folder = $folder_query->object_at_id ($App->root_folder_id);
58 }
59
60 $folder_query->clear_restrictions();
61
62 if (! safe_sizeof ($folders) && $App->login->is_anonymous ())
63 {
64 $Env->redirect_local ('log_in.php');
65 }
66
67 $class_name = $App->final_class_name ('INDEX_PANEL_MANAGER', 'webcore/gui/panel.php');
68 /** @var $panel_manager INDEX_PANEL_MANAGER */
69 $panel_manager = new $class_name ($App, $folders);
70 $panel = $panel_manager->selected_panel ();
71
72 $Page->title->subject = $panel->num_objects () . ' ' . $panel->raw_title();
73
74 $Page->location->add_root_link (false);
75
76 if (isset ($folder))
77 {
78 $Page->location->append ($folder->title_as_html ());
79 }
80 else
81 {
82 $Page->location->append ($App->short_title);
83 }
84
85 $Page->location->append($Page->title->subject);
86
87 $Page->add_script_file ('{scripts}webcore_forms.js');
88
89 $Page->newsfeed_options->title->subject = $App->title;
90 $Page->newsfeed_options->file_name = '{app}/index_rss.php';
91
92 $Page->start_display ();
93 ?>
94 <div class="top-box">
95 <div class="columns text-flow">
96 <?php
97 if (isset ($folder))
98 {
99 /** @var $renderer OBJECT_RENDERER */
100 $renderer = $folder->handler_for (Handler_html_renderer);
101 $options = $renderer->options ();
102 $options->show_as_summary = true;
103 $options->show_users = false;
104
105 $text = $renderer->display_to_string ($folder);
106
107 if ($text)
108 {
109 ?>
110 <div class="left-sidebar">
111 <?php echo $text; ?>
112 </div>
113 <?php
114 }
115 }
116
117 ?>
118 <div>
119 <h4>Contents</h4>
120 <div class="panels">
121 <?php $panel_manager->display (); ?>
122 </div>
123 </div>
124 <?php
125 if (! empty ($folders))
126 {
127 $folder_type_info = $App->type_info_for ('FOLDER');
128 ?>
129 <div class="tree-content">
130 <h4><?php echo $folder_type_info->plural_title; ?></h4>
131 <?php
132 $tree = $App->make_tree_renderer ();
133 include_once ('webcore/gui/folder_tree_node_info.php');
134 $tree->node_info = new FOLDER_TREE_NODE_INFO ($App);
135 $tree->node_info->page_args = read_vars (array ('panel', 'time_frame'));
136 $tree->display ($folders);
137 ?>
138 </div>
139 <?php
140 }
141 ?>
142 <div>
143 <h4>Search</h4>
144 <div class="form-content">
145 <?php
146 $class_name = $App->final_class_name ('EXECUTE_SEARCH_FORM', 'webcore/forms/execute_search_form.php');
147 $search = null;
148 $selected_panel = $panel_manager->selected_panel ();
149 /** @var $form EXECUTE_SEARCH_FORM */
150 $form = new $class_name ($App, $search);
151 $form->load_with_defaults ();
152 $form->set_value ('state', $selected_panel->state);
153 $form->display ();
154 ?>
155 </div>
156 </div>
157 </div>
158 </div>
159 <div class="main-box">
160 <div class="menu-bar-top">
161 <?php
162 if ($panel->uses_time_selector)
163 {
164 $panel_manager->display_time_menu ();
165 }
166 $pager = $panel->get_pager();
167
168 if ($pager)
169 {
170 $pager->pages_to_show = 0;
171 $pager->display();
172 }
173
174 $grid = $panel->get_grid();
175 if ($grid)
176 {
177 $grid->show_pager = false;
178 }
179
180 /** @var MENU_RENDERER $renderer */
181 $renderer = $folder->handler_for (Handler_menu);
182 $renderer->set_size(Menu_size_standard);
183 $renderer->num_important_commands = 2;
184 /** @var COMMANDS $commands */
185 $commands = $folder->handler_for(Handler_commands);
186 $renderer->display($commands);
187 ?>
188 </div>
189 <?php
190 $panel->display ();
191
192 if ($panel->num_objects ())
193 {
194 // don't show the bottom selector if there are no objects
195 ?>
196 <div class="menu-bar-bottom">
197 <?php
198 if ($panel->uses_time_selector)
199 {
200 $panel_manager->display_time_menu ();
201 }
202 if ($pager)
203 {
204 $pager->pages_to_show = 5;
205 $pager->display(true);
206 }
207 ?>
208 </div>
209 <?php
210 }
211 ?>
212 </div>
213 <?php
214 $Page->finish_display ();
215 ?>
216