CMS  Version 3.9
setting_form.inc
Go to the documentation of this file.
1 <?php
2 /**************************************************************
3 
4  Copyright (c) 2010 Sonjara, Inc
5 
6  Permission is hereby granted, free of charge, to any person
7  obtaining a copy of this software and associated documentation
8  files (the "Software"), to deal in the Software without
9  restriction, including without limitation the rights to use,
10  copy, modify, merge, publish, distribute, sublicense, and/or sell
11  copies of the Software, and to permit persons to whom the
12  Software is furnished to do so, subject to the following
13  conditions:
14 
15  The above copyright notice and this permission notice shall be
16  included in all copies or substantial portions of the Software.
17 
18  Except as contained in this notice, the name(s) of the above
19  copyright holders shall not be used in advertising or otherwise
20  to promote the sale, use or other dealings in this Software
21  without prior written authorization.
22 
23  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
25  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
27  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
28  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
30  OTHER DEALINGS IN THE SOFTWARE.
31 
32 *****************************************************************/
33 
34 Fakoli::using("settings", "field_renderers");
35 Fakoli::usingFeature("auto_form");
36 
37 $settings_id = checkNumeric($_GET["settings_id"]);
38 
40 
41 $menu_item = "Define Settings Options";
42 
43 if ($settings_id)
44 {
45  $setting->load($settings_id);
46  $title = "Edit Setting";
47 }
48 else
49 {
50  $title = "Add Setting";
51 }
52 
53 $form = new AutoForm($setting);
54 
55 $form->readOnly("component");
56 $form->hide("value");
57 $form->button("Cancel", "/admin/setting_list");
58 $form->annotate("name", "Please use a code-style name with lowercase letters and underscores between words (e.g., output_path). <b><i>Warning</b></i> Changes to the name will require code changes.");
59 $form->annotate("options", "Option list for select or checklist field renderers or name of custom field renderer (e.g., FileUploadFieldRenderer). <b><i>Warning</b></i>: changing the order of options will change the selected value on the Application Settings form.");
60 $form->annotate("name", "Name changes must be accompanied by code updates to the function that sets the default value.");
61 $typeSelect = new SelectFieldRenderer($form, "field_type", "Field Type", Settings::$fieldTypes);
62 
63 if ($method == "POST")
64 {
65  if($form->save())
66  redirect("/admin/setting_list");
67 }
68 
69 $script .= $form->writeScript();
70 
71 ?>
72 <h4>This features allows you to customize the system's application setting options. It is designed for use by systems administrators. CMS Users can modify <a href="/admin/settings">Application Settings</a> under CMS Site Configuration.</h4>
73 <?php
74 $form->drawForm();
75 ?>
static usingFeature()
Uses the specified framework feature(s).
Definition: core.inc:388
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
The Settings class provides components with a common API for specifying application settings and conf...
Definition: settings.inc:49
static $fieldTypes
Definition: settings.inc:68
$method
Pull out a simple reference to the request method.
Definition: core.inc:1573
$forumRequest to
$form
$setting
$menu_item
$settings_id
$typeSelect
if($method=="POST") $script