CMS  Version 3.9
text_lookup_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 /*
35  * For admin to define text that appears on
36  * various pages in the site.
37  *
38  * Janice Gallant for Sonjara, Inc.
39  *
40  * 09/03/2010
41  */
42 
43 
44 Fakoli::using("text_lookup", "email");
45 Fakoli::usingFeature("auto_form");
46 Fakoli::usingFile("framework/tab_bar.inc");
47 
48 $text_id = checkNumeric($_GET["text_id"]);
49 
50 $menu_item = "Text Lookup";
51 
52 $text = new TextLookup();
53 
54 if ($text_id)
55 {
56  $text->load($text_id);
57 }
58 else
59 {
60  $text->category = "General";
61  $text->enabled = true;
62 }
63 
64 
65 $redirect = "/admin/text_lookup_list";
66 
67 $form = new AutoForm($text);
68 $form->unique("code", "Text already exists with that code.");
69 $form->required("code");
70 
71 $form->dropdown("category")->allowAddEntry();
72 
73 $classes = ComponentManager::fireEvent("EnumerateDataItemClasses", $classes);
74 if (count($classes) > 0)
75  $classNameList = array_combine($classes, $classes);
76 
77 $classSelect = new SelectFieldRenderer($form, "class_name", "Class Name", $classNameList);
78 $classSelect->allowAddEntry();
79 $form->annotate("class_name", "If merge codes are used, identify the class name that can access the values.");
80 $form->button("Cancel", $redirect);
81 $form->allowDelete = true;
82 $form->onDelete = onDeleteCascade;
83 
85 
86 if($text_id)
87  $form->annotate("code", "Code field changes will require changes to existing lookups in the code base.");
88 else
89  $form->annotate("code", "Please provide the code as all lowercase letters and link words with an underscore (e.g., my_code)");
90 
91 
93 
94 if ($method == "POST")
95 {
96  if ($form->save())
97  {
98  Fakoli::notify("Changes Saved");
99  }
100 }
101 
102 $script .= $form->writeScript();
103 
104 $tabs->writeHTML();
105 ?>
106 <div id="tab_border">
107 <p>This form allows you to edit text that appears in the website. The text is retrieved for display on a web page using the code name given here.</p>
108 <p><a class="button" href="#" onclick="new TextLookup().showAdvancedFeatures(); return false">Advanced Features</a></p>
109 <?php
110 
112 {
114 }
115 
116 $form->drawForm();
117 ?></div>
$tabs page
static fireEvent($event, $parameter=null, $mustBeConsumed=false)
Fire an event to all subscribers as detailed in their manifests.
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
static usingFile()
Uses the specified framework file(s) from the framework directory.
Definition: core.inc:369
static notify($message, $blocking=false, $button="OK", $onClick="null")
Utility method to display a notification message to the user when the page has finished loading.
Definition: core.inc:1198
static deleteText($text)
static getTabs($key="")
$method
Pull out a simple reference to the request method.
Definition: core.inc:1573
$forumRequest to
$classSelect
$menu_item
onDeleteCascade(&$text)
if($method=="POST") $script