root/trunk/wifidog-auth/wifidog/admin/generic_object_admin.php @ 562

Revision 562, 5.9 KB (checked in by fproulx, 8 years ago)

2005-04-22 Fran��ois Proulx <francois.proulx@…>

  • Fixed bug in FlickrPhotostream?.php
  • Params did not match new methods requirements ( getUserByEmail )
  • Changed stylesheet class name for Flickr to match new changes
  • Fixed bugs in File
  • Wrote part of EmbeddedContent? ( partially working )
  • TODO: add support for parameters and attributes in EmbeddedContent?
  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1<?php
2
3
4/********************************************************************\
5 * This program is free software; you can redistribute it and/or    *
6 * modify it under the terms of the GNU General Public License as   *
7 * published by the Free Software Foundation; either version 2 of   *
8 * the License, or (at your option) any later version.              *
9 *                                                                  *
10 * This program is distributed in the hope that it will be useful,  *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
13 * GNU General Public License for more details.                     *
14 *                                                                  *
15 * You should have received a copy of the GNU General Public License*
16 * along with this program; if not, contact:                        *
17 *                                                                  *
18 * Free Software Foundation           Voice:  +1-617-542-5942       *
19 * 59 Temple Place - Suite 330        Fax:    +1-617-542-2652       *
20 * Boston, MA  02111-1307,  USA       gnu@gnu.org                   *
21 *                                                                  *
22 \********************************************************************/
23/**@file generic_object_admin.php
24 * A simple interface to edit any object that implements the GenericObject interface.  The php file takes the following params:
25 * $_REQUEST['action']: new, edit, delete, preview (also save, but not meant for calling from outside this file)
26 * $_REQUEST['object_id']:  The id of the object ot be edited
27 * $_REQUEST['object_class']:  The class name of the object ot be edited
28 * $_REQUEST['node_id']: In preview mode, the current node to simulate display
29 * $_REQUEST['debug']:  If present and non empty, the $_REQUEST variables will be displayed
30 * @author Copyright (C) 2005 Benoit Grégoire <bock@step.polymtl.ca>,
31 * Technologies Coeus inc.
32 */
33define('BASEPATH', '../');
34require_once 'admin_common.php';
35require_once BASEPATH.'classes/GenericObject.php';
36
37$smarty->display("templates/header.html");
38if (!empty ($_REQUEST['debug'])) {
39        echo "<pre>";
40        print_r($_REQUEST);
41        echo "</pre>";
42}
43$html = '';
44$html = '<h3>'._("Generic object editor").'</h3>';
45if (empty ($_REQUEST['object_class'])) {
46        echo "<div class='errormsg'>"._("Sorry, the 'object_class' parameter must be specified")."</div>\n";
47        exit;
48} else {
49        $class = $_REQUEST['object_class'];
50}
51
52if ($_REQUEST['action'] == 'new') {
53        $object = call_user_func(array ($class, 'createNewObject'));
54        $_REQUEST['action'] = 'edit';
55} else {
56        if (empty ($_REQUEST['object_id'])) {
57                echo "<div class='errormsg'>"._("Sorry, the 'object_id' parameter must be specified")."</div>\n";
58                exit;
59        }
60        $object = call_user_func(array ($class, 'getObject'), $_REQUEST['object_id']);
61}
62
63if ($_REQUEST['action'] == 'save') {
64        $html .= $object->processAdminUI();
65        $object = call_user_func(array ($class, 'getObject'), $_REQUEST['object_id']);
66        $_REQUEST['action'] = 'edit';
67}
68
69if ($_REQUEST['action'] == 'delete') {
70        $errmsg = '';
71
72        if ($object->delete($errmsg)) {
73                $html .= "<div class='successmsg'>"._("Content successfully deleted")."</div>\n";
74        } else {
75                $html .= "<div class='errormsg'>"._("Deletion failed, error was: ")."$errmsg</div>\n";
76                $_REQUEST['action'] = 'edit';
77        }
78}
79
80if ($_REQUEST['action'] == 'edit') {
81        $common_input = '';
82        if (!empty ($_REQUEST['debug'])) {
83                $common_input .= "<input type=submit name='debug' value='true'>\n";
84        }
85        $common_input .= "<input type='hidden' name='object_id' value='".$object->GetId()."'>\n";
86        $common_input .= "<input type='hidden' name='object_class' value='".get_class($object)."'>\n";
87
88        $html .= "<form enctype='multipart/form-data' action='".GENERIC_OBJECT_ADMIN_ABS_HREF."' method='post'>";
89        $html .= $common_input;
90        $html .= $object->getAdminUI();
91        $html .= "<input type='hidden' name='action' value='save'>\n";
92        $html .= "<input type=submit name='save_submit' value='"._("Save")." ".get_class($object)."'>\n";
93        $html .= '</form>';
94
95        $html .= "<form action='".GENERIC_OBJECT_ADMIN_ABS_HREF."' method='post'>";
96        $html .= $common_input;
97        $html .= "<input type='hidden' name='action' value='preview'>\n";
98        $html .= "<input type=submit name='preview_submit' value='"._("Preview")." ".get_class($object)."'>\n";
99        $html .= '</form>';
100
101        $html .= "<form action='".GENERIC_OBJECT_ADMIN_ABS_HREF."' method='post'>";
102        $html .= $common_input;
103        $html .= "<input type='hidden' name='action' value='delete'>\n";
104        $html .= "<input type=submit name='delete_submit' value='"._("Delete")." ".get_class($object)."'>\n";
105        $html .= '</form>';
106}
107
108if ($_REQUEST['action'] == 'preview') {
109        if (empty ($_REQUEST['node_id'])) {
110                $node_id = null;
111                $node = null;
112        } else {
113                $node_id = $_REQUEST['node_id'];
114                $node = Node :: getObject($node_id);
115                Node :: setCurrentNode($node);
116        }
117        $common_input = '';
118        if (!empty ($_REQUEST['debug'])) {
119                $common_input .= "<input type=submit name='debug' value='true'>\n";
120        }
121        $common_input .= "<input type='hidden' name='object_id' value='".$object->GetId()."'>\n";
122        $common_input .= "<input type='hidden' name='object_class' value='".get_class($object)."'>\n";
123        $common_input .= "<input type='hidden' name='node_id' value='".$node_id."'>\n";
124
125        $html .= "<form action='".GENERIC_OBJECT_ADMIN_ABS_HREF."' method='post'>";
126        $html .= $common_input;
127
128        $name = "node_id";
129        $html .= Node :: getSelectNodeUI($name);
130
131        $html .= $object->getUserUI();
132        $html .= "<input type='hidden' name='action' value='preview'>\n";
133        $html .= "<input type=submit name='preview_submit' value='"._("Preview")." ".get_class($object)."'>\n";
134        $html .= '</form>';
135
136        $html .= "<form action='".GENERIC_OBJECT_ADMIN_ABS_HREF."' method='post'>";
137        $html .= $common_input;
138        $html .= "<input type='hidden' name='action' value='edit'>\n";
139        $html .= "<input type=submit name='edit_submit' value='"._("Edit")." ".get_class($object)."'>\n";
140        $html .= '</form>';
141}
142
143echo $html;
144$smarty->display("templates/footer.html");
145?>
146
Note: See TracBrowser for help on using the browser.