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/edit_comment.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/edit_comment.php'));
30 ?>
31
Source for template: webcore/pages/edit_comment.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 $id = read_var ('id');
29 $folder_query = $App->login->folder_query ();
30 $folder = $folder_query->folder_for_comment_at_id ($id);
31
32 if (isset ($folder))
33 {
34 $entry_query = $folder->entry_query ();
35 $entry = $entry_query->object_for_comment_at_id ($id);
36
37 if (isset ($entry))
38 {
39 $com_query = $entry->comment_query ();
40 $comment = $com_query->object_at_id ($id);
41
42 if (isset ($comment))
43 {
44 if ($comment->parent_id)
45 {
46 $parent = $com_query->object_at_id ($comment->parent_id);
47 }
48 }
49 }
50 }
51
52 if (isset ($comment) && (! $comment->parent_id || isset ($parent)) && $App->login->is_allowed (Privilege_set_comment, Privilege_modify, $comment))
53 {
54 $class_name = $App->final_class_name ('COMMENT_FORM', 'webcore/forms/comment_form.php');
55 /** @var $form COMMENT_FORM */
56 $form = new $class_name ($folder);
57
58 $form->process_existing ($comment);
59 if ($form->committed ())
60 {
61 $App->return_to_referer ($comment->home_page ());
62 }
63 else
64 {
65 if (isset ($parent))
66 {
67 $prev = $parent;
68 }
69 else
70 {
71 $prev = $entry;
72 }
73
74 $form->add_preview ($prev, 'In reply to: ' . $prev->title_as_html (), false);
75 }
76
77 $Page->title->add_object ($folder);
78 $Page->title->add_object ($entry);
79 $Page->title->add_object ($comment);
80 $Page->title->subject = 'Edit Comment';
81
82 $Page->location->add_folder_link ($folder);
83 $Page->location->add_object_link ($entry);
84 $Page->location->add_object_link ($comment, '', '{icons}buttons/reply');
85 $Page->location->append ($Page->title->subject, '', '{icons}/buttons/edit');
86
87 $Page->start_display ();
88 ?>
89 <div class="main-box">
90 <div class="form-content">
91 <?php
92 $form->display ();
93 ?>
94 </div>
95 </div>
96 <?php
97 $Page->finish_display ();
98 }
99 else
100 {
101 $Page->raise_security_violation ('You are not allowed to edit this comment.', $folder);
102 }
103 ?>