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/shared/settings.php

Uses WebCore template(s):

00 <?php
01   require_once ('webcore/init.php');
02   require_once ($Page->page_template_for ('webcore/pages/settings.php'));
03 ?>
04

Source for template: webcore/pages/settings.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   /** @var THEMED_PAGE $themed_page */
29   $themed_page = $Page;
30   /** @var $theme_query THEME_QUERY */
31   $theme_query = $themed_page->theme_query ();
32  
33   /** @var THEME[] $themes */
34   $themes = $theme_query->objects ();
35  
36   $Page->title->subject = $theme_query->size () . ' Themes';
37   $Page->template_options->title = 'Settings';
38   $Page->template_options->settings_url = '';
39  
40   $Page->location->add_root_link ();
41   $Page->location->append ('Settings');
42   $Page->location->append ($theme_query->size () . ' Themes');
43  
44   // Leave the form initialization before the call to $Page->start_display() so that the page is rendered
45   // most recently selected theme
46   include_once ('webcore/forms/theme_selector_form.php');
47   $form = new THEME_SELECTOR_FORM ($Page, $themes);
48   $form->process_plain ();
49   $form->load_with_defaults ();
50  
51   $Page->add_script_file('{scripts}webcore_calendar.js');
52  
53 require_once('webcore/forms/form.php');
54 require_once('webcore/forms/form_renderer.php');
55  
56 class SAMPLE_FORM extends FORM
57 {
58   function __construct($context)
59   {
60     parent::__construct ($context);
61  
62     $field = new INTEGER_FIELD ();
63     $field->id = 'radio';
64     $field->caption = 'Radio';
65     $this->add_field ($field);
66  
67     $field = new TEXT_FIELD ();
68     $field->id = 'name';
69     $field->caption = 'Name';
70     $field->required = true;
71     $this->add_field ($field);
72     $this->set_value('name', 'Filler text');
73  
74     $field = new MUNGER_TEXT_FIELD ();
75     $field->id = 'description';
76     $field->caption = 'Description';
77     $this->add_field ($field);
78     $this->set_value('description', 'Filler text that demonstrates which font is being used in longer, wrapping text.');
79  
80     $field = new DATE_TIME_FIELD();
81     $field->id = 'date';
82     $field->caption = 'Date';
83     $this->add_field ($field);
84     $this->set_value('date', new DATE_TIME());
85  
86     $field = new BOOLEAN_FIELD ();
87     $field->id = 'bool1';
88     $field->set_value(1);
89     $field->caption = 'Option 1';
90     $this->add_field ($field);
91  
92     $field = new BOOLEAN_FIELD ();
93     $field->id = 'bool2';
94     $field->caption = 'Option 2';
95     $this->add_field ($field);
96  
97     $field = new ENUMERATED_FIELD();
98     $field->id = 'select';
99     $field->caption = 'Select';
100     $field->add_value (0);
101     $field->add_value (1);
102     $field->add_value (2);
103     $field->add_value (3);
104     $field->required = true;
105     $this->add_field ($field);
106   }
107  
108   /**
109    * Draw the controls for the form.
110    * @param FORM_RENDERER $renderer
111    * @access private
112    */
113   protected function _draw_controls($renderer)
114   {
115     $renderer->default_control_height = '75px';
116  
117     $renderer->start();
118     $props = $renderer->make_list_properties ();
119     $props->add_item('bool1', 1);
120     $props->add_item('bool2', 1);
121     $props->items_per_row = 4;
122     $renderer->draw_check_boxes_row('Options', $props);
123     $renderer->start_row('Text', 'text-line');
124     $text_props = new FORM_TEXT_CONTROL_OPTIONS();
125     $text_props->css_class = 'small';
126     echo $renderer->date_as_html('date');
127     echo ' ';
128     echo $renderer->text_line_as_html('name', $text_props);
129     $renderer->finish_row();
130     $renderer->draw_text_box_row('description');
131  
132     $renderer->start_block('');
133  
134     $props = $renderer->make_list_properties ();
135     $props->show_descriptions = true;
136     $props->css_class = 'small';
137     $props->add_item ('Option One', 0, 'Description for option one.');
138     $props->add_item ('Option Two', 1, 'Description for option two.');
139     $renderer->draw_radio_group_row('select', $props);
140  
141     $field = $this->field_at('select');
142  
143     $renderer->start_row('Menus', 'text-line');
144     echo $renderer->drop_down_as_html('select', $props);
145     echo ' ';
146     $field->required = true;
147     echo $renderer->drop_down_as_html('select', $props);
148     $renderer->finish_row();
149  
150     $renderer->start_row('Lists');
151     $field->required = false;
152     echo $renderer->list_box_as_html('select', $props);
153     echo ' ';
154     $field->required = true;
155     echo $renderer->list_box_as_html('select', $props);
156     $renderer->finish_row();
157  
158     $renderer->finish_block();
159     $renderer->draw_submit_button_row();
160  
161     $renderer->finish();
162   }
163 }
164  
165   $Page->start_display ();
166 ?>
167 <div class="main-box">
168   <div class="columns text-flow">
169     <div class="left-sidebar">
170       <p>Customize the font and theme to the right and see a preview below.</p>
171       <div class="form-content">
172         <?php
173         $form->display ();
174         ?>
175       </div>
176       <p>You can also switch themes with the samples below. Press the button under the thumbnail to select a theme.</p>
177       <div class="grid-content">
178         <?php
179         $class_name = $Page->final_class_name ('THEME_GRID', 'webcore/gui/theme_grid.php');
180  
181         /** @var $grid THEME_GRID */
182         $grid = new $class_name ($Page);
183         $grid->is_chooser = true;
184         $grid->pager->pages_to_show = 2;
185         $grid->pager->show_first_and_last = false;
186         $grid->pager->show_total = false;
187         $grid->set_page_size (Default_page_size);
188         $grid->set_query ($theme_query);
189         $grid->display ();
190         ?>
191       </div>
192     </div>
193     <div>
194       <h1>Preview (level 1 heading)</h1>
195       <h2>Buttons & Menus (level 2 heading)</h2>
196       <?php
197       require_once ('webcore/gui/page_navigator.php');
198       $navigator = new PAGE_NAVIGATOR($Page);
199       $navigator->set_ranges(50, 10);
200       $navigator->pages_to_show = 4;
201       $navigator->display();
202       ?>
203       <div class="button-content">
204         <?php
205         require_once ('webcore/cmd/commands.php');
206         $menu = $Page->make_menu();
207         $menu->commands->append_group('Group One');
208         $menu->append('One', '#', '{icons}/buttons/edit');
209         $menu->append('Two', '#', '{icons}/buttons/add');
210         $item = $menu->append('Three', '#', '{icons}/buttons/delete');
211         $item->description = 'Button three includes a description below';
212         $menu->renderer->content_mode &= ~Menu_show_icon;
213         $menu->display();
214         ?>
215       </div>
216       <div class="button-content">
217         <?php
218         $menu->renderer->separator_class = 'objects';
219         $menu->display();
220         ?>
221       </div>
222       <div class="button-content">
223         <?php
224         $menu->renderer->separator_class = 'location';
225         $menu->display();
226         ?>
227       </div>
228       <div class="button-content">
229         <a href="#" class="button">L</a><?php
230         $menu->renderer->set_size(Menu_size_compact);
231         $menu->renderer->content_mode |= Menu_show_as_buttons | Menu_show_icon;
232         $menu->renderer->options &= ~Menu_options_show_trigger_title;
233         $menu->display();
234         $menu->renderer->set_size(Menu_size_full);
235         $menu->renderer->content_mode = Menu_show_all_as_buttons;
236         $menu->display();
237         $menu->renderer->set_size(Menu_size_compact);
238         $menu->renderer->content_mode |= Menu_show_as_buttons | Menu_show_icon;
239         $menu->renderer->options &= ~Menu_options_show_trigger_title;
240         $menu->display();
241         ?><a href="#" class="button">R</a>
242       </div>
243       <div class="button-content">
244         <a href="#" class="button">L</a><?php
245         $menu->renderer->set_size(Menu_size_full);
246         $menu->renderer->content_mode = Menu_show_all_as_buttons;
247         $menu->display();
248         ?><a href="#" class="button">R</a>
249       </div>
250       <div class="button-content">
251         <?php
252         $renderer = $Page->make_controls_renderer ();
253         echo $renderer->button_as_html ('', '#', '{icons}buttons/upgrade', Thirty_two_px);
254         echo $renderer->button_as_html ('Upgrayedd', '#', '{icons}buttons/upgrade', Thirty_two_px);
255         echo $renderer->button_as_html ('', '#', '{icons}buttons/upgrade', Twenty_px);
256         echo $renderer->button_as_html ('Upgrayedd', '#', '{icons}buttons/upgrade', Twenty_px);
257         echo $renderer->button_as_html ('', '#', '{icons}buttons/upgrade', Sixteen_px);
258         echo $renderer->button_as_html ('Upgrayedd', '#', '{icons}buttons/upgrade', Sixteen_px);
259         ?>
260       </div>
261       <div class="tree-content">
262         <?php
263         include ('webcore/gui/tree_node.php');
264         include ('webcore/gui/selector_tree_decorator.php');
265  
266         $tree = $Page->make_tree_renderer ();
267         $tree->node_info = new GENERIC_TREE_NODE_INFO($Page);
268  
269         $documents_node = new TREE_NODE ('Documents', '', false);
270         $documents_node->append (new TREE_NODE ('Specs (PDF)', '#', '', true));
271         $documents_node->append (new TREE_NODE ('Specs 2 (PDF)', '#'));
272         $documents_node->append (new TREE_NODE ('Specs 3 (PDF)', '#'));
273  
274         $root = new TREE_NODE ('Encodo', '', false, '', true);
275         $root->append ($documents_node);
276  
277         $roots [] = $root;
278         $roots [] = new TREE_NODE ('Earthli');
279  
280         $tree->display ($roots);
281  
282         $archive_node = new TREE_NODE ('Archive', '', false);
283         $archive_node->append (new TREE_NODE ('Specs (PDF)', '#'));
284         $archive_node->append (new TREE_NODE ('Specs 2 (PDF)', '#'));
285         $archive_node->append (new TREE_NODE ('Specs 3 (PDF)', '#'));
286  
287         $root = new TREE_NODE ('Home', '', false);
288         $root->append ($archive_node);
289  
290         foreach ($archive_node->children() as $child_node)
291         {
292           $tree->node_info->set_selected_node($child_node);
293         }
294  
295         $roots = null;
296         $roots [] = $root;
297  
298         $tree->decorator = new SELECTOR_TREE_DECORATOR($tree);
299         $tree->display ($roots);
300         ?>
301       </div>
302       <h3>Form elements (level 3 heading)</h3>
303       <div class="form-content">
304         <?php
305         $form = new SAMPLE_FORM($Page);
306         $form_renderer = new FORM_RENDERER($form);
307         $form->display();
308         ?>
309       </div>
310       <div class="info-box-top">
311         <p>This is an info box at the top of a <a href="#">page</a> or <a href="#">section</a>.</p>
312       </div>
313       <h4>Text and block elements (level 4 heading)</h4>
314       <p>Standard paragraph text.</p>
315       <ol><li>Item One</li><li>Item Two</li></ol>
316       <ul><li>Item One</li><li>Item Two</li></ul>
317       <div class="info-box-bottom">
318         <p>This is an info box at the bottom of a <a href="#">page</a> or <a href="#">section</a>.</p>
319         <p>Paragraph two.</p>
320         <p>Paragraph three.</p>
321         <p>Div one.</p>
322         <p>Paragraph four.</p>
323         <p>Div two.</p>
324       </div>
325       <p class="quote-block">"This is a block quote. These are often used in article to include
326         text from other sources. This is generally used for larger citations. Use the inline
327         style for smaller citations."</p>
328       <div class="preview">
329         <h3 class="preview-title">Title</h3>
330         <p>This is text in a preview box. <span class="quote-inline">This is an example of an inline quotation.</span>
331           This text following the citation and should make the paragraph wrap at least once.</p>
332       </div>
333       <?php
334         $Page->show_message('This is a <a href="#">caution</a> box.', 'info');
335         $Page->show_message('This is a <a href="#">warning</a> box.', 'warning');
336         $Page->show_message('This is an <a href="#">error</a> box.');
337       ?>
338       <h3>Chart/Graph</h3>
339       <div class="graph-background">
340         <div class="graph-foreground" style="width: 30px; height: 100px"></div>
341         <div class="graph-foreground" style="width: 30px; height: 10px"></div>
342         <div class="graph-foreground" style="width: 30px; height: 80px"></div>
343         <div class="graph-foreground" style="width: 30px; height: 75px"></div>
344         <div class="graph-foreground" style="width: 30px; height: 75px"></div>
345         <div class="graph-foreground" style="width: 30px; height: 100px"></div>
346         <div class="graph-foreground" style="width: 30px; height: 50px"></div>
347       </div>
348       <div class="chart">
349         <h3 class="chart-title">Box</h3>
350         <div class="chart-body">
351           <p>The following is a code from the <c>MUNGER</c>.</p>
352           <pre><code>protected function _process($input, $tokenizer)
353     {
354       $tokenizer->set_input($input);
355       while ($tokenizer->available())
356       {
357         $tokenizer->read_next();
358         $token = $tokenizer->current();
359         $this->_process($token);
360       }
361     }</code></pre>
362         </div>
363       </div>
364       <p>This is code by itself.</p>
365     <pre><code>protected function _process($input, $tokenizer)
366     {
367       $tokenizer->set_input($input);
368       while ($tokenizer->available())
369       {
370         $tokenizer->read_next();
371         $token = $tokenizer->current();
372         $this->_process($token);
373       }
374     }</code></pre>
375       <div class="abstract">
376         This is the text of an abstract. These are often used to summarize much longer blocks of text, similar in a way to the block at the beginning of a scientific paper.
377       </div>
378       <p>This is text before a rule.</p>
379       <hr>
380       <p>This is text after a rule.</p>
381       <div class="quote pullquote right align-right" style="width: 150px">Pull-quotes catch your eye.</div>
382       <p>This is the text that accompanies the pull-quote. Pull-quotes are often used to highlight interesting bits of text in much longer articles in order to pique a reader's interest or to catch a scanner's eye.</p>
383       <table class="basic columns left-labels">
384         <tr>
385           <th>Style</th>
386           <th>Description</th>
387         </tr>
388         <tr>
389           <td><strong>strong</strong></td>
390           <td>Strongly formatted text</td>
391         </tr>
392         <tr>
393           <td><em>emphasized</em></td>
394           <td>Emphasized text</td>
395         </tr>
396         <tr>
397           <td><small class="notes">notes</small></td>
398           <td>Notes/comments</td>
399         </tr>
400         <tr>
401           <td><code>code</code></td>
402           <td>Inline code</td>
403         </tr>
404         <tr>
405           <td><strong class="highlight">highlighted</strong></td>
406           <td>Highlighted text</td>
407         </tr>
408         <tr>
409           <td><strong class="selected">selected</strong></td>
410           <td>Selected text</td>
411         </tr>
412         <tr>
413           <td><del>deleted</del></td>
414           <td>Deleted text</td>
415         </tr>
416         <tr>
417           <td><var>variableOne</var></td>
418           <td>Variable names</td>
419         </tr>
420         <tr>
421           <td><kbd>&#8984;</kbd> + <kbd>B</kbd></td>
422           <td>Keyboard characters</td>
423         </tr>
424         <tr>
425           <td><dfn>definition</dfn></td>
426           <td>Definitions</td>
427         </tr>
428         <tr>
429           <td><abbr title="Computer-aided Design">CAD</abbr></td>
430           <td>Abbreviations</td>
431         </tr>
432         <tr>
433           <td><cite>citation</cite></td>
434           <td>Citations</td>
435         </tr>
436       </table>
437     </div>
438   </div>
439 </div>
440 <?php
441   $Page->finish_display ();
442 ?>