CMS  Version 3.9
settings_manager.inc
Go to the documentation of this file.
1 <?php
7 /**************************************************************
8 
9  Copyright (c) 2010 Sonjara, Inc
10 
11  Permission is hereby granted, free of charge, to any person
12  obtaining a copy of this software and associated documentation
13  files (the "Software"), to deal in the Software without
14  restriction, including without limitation the rights to use,
15  copy, modify, merge, publish, distribute, sublicense, and/or sell
16  copies of the Software, and to permit persons to whom the
17  Software is furnished to do so, subject to the following
18  conditions:
19 
20  The above copyright notice and this permission notice shall be
21  included in all copies or substantial portions of the Software.
22 
23  Except as contained in this notice, the name(s) of the above
24  copyright holders shall not be used in advertising or otherwise
25  to promote the sale, use or other dealings in this Software
26  without prior written authorization.
27 
28  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
30  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
32  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
34  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35  OTHER DEALINGS IN THE SOFTWARE.
36 
37 *****************************************************************/
38 
39 Fakoli::using("settings");
40 Fakoli::usingFeature("data_tabs");
41 
43 {
45  {
46  }
47 
48  function export()
49  {
50  return SerializationManager::serialize(Settings, "ORDER BY settings_id");
51  }
52 
53  function import($doc, $tx)
54  {
56  }
57 }
58 
60 {
61  static $extensionMap = array();
62 
64  {
66  }
67 
68  static function getExtension($component)
69  {
71  }
72 
73  function SettingsManager()
74  {
75 
76  }
77 
78  /*
79  * The following config settings appear not be be in use in
80  * any of our projects and thus are not included in application
81  * settings:
82  *
83  * news_item_count
84  * latest_addition_count
85  * document
86  * tmp
87  *
88  * The following config settings are not included and will
89  * remain in $config array:
90  *
91  * homedir
92  * uploadbase
93  * http_host
94  */
95  static function setDefaults()
96  {
97  trace("SettingsManager::setDefaults", 3);
98 
99  global $config;
100 
101  preg_match_all("/([\\w\\d_]+)\.?([^}]*)/", $config["http_host"], $matches, PREG_SET_ORDER);
102  if(count($matches) > 0)
103  {
104  $matches = $matches[0];
105  if(count($matches) > 1)
106  {
107  $path = $matches[1];
108  $sitename = prettify($path);
109  }
110  }
111 
112  Settings::setDefaultValue("settings", "prettyUrls", true, "Boolean", "Whether urls are translated to CMS identifiers", "General");
113  Settings::setDefaultValue("settings", "allow_pdf_download", true, "Boolean", "", "General");
114  Settings::setDefaultValue("settings", "sitename", $sitename, "String", "", "General");
115  Settings::setDefaultValue("settings", "wrap_modules", true, Boolean, "Specifies whether to wrap module output in a div tag, or render them bare", "General");
116  Settings::setDefaultValue("settings", "system_notification_email", $config["email_contact"], String, "The email address to which system notifications should be sent", "General");
117  Settings::setDefaultValue("settings", "local_IP_address", "", String, "Specifies the server's local IP address for environments (such as Microsoft Azure) where this cannot be determined automatically", "General");
118 
119  Settings::setDefaultValue("settings", "formCSS", "form", "String", "", "AutoForm");
120  Settings::setDefaultValue("settings", "labelCSS", "label", "String", "", "AutoForm");
121  Settings::setDefaultValue("settings", "valueCSS", "value", "String", "", "AutoForm");
122  Settings::setDefaultValue("settings", "buttonCSS", "button", "String", "", "AutoForm");
123  Settings::setDefaultValue("settings", "buttonAlignment", "left", "String", "", "AutoForm");
124  Settings::setDefaultValue("settings", "buttonLineCSS", "submit", "String", "", "AutoForm");
125 
126  Settings::setDefaultValue("settings", "componentPath", "/fakoli", "String", "", "AutoForm");
127  Settings::setDefaultValue("settings", "HTMLEditorHideStyleBar", true, "Boolean", "", "AutoForm");
128  Settings::setDefaultValue("settings", "HTMLEditorDefaultWidth", "540px", "String", "", "AutoForm");
129  Settings::setDefaultValue("settings", "HTMLEditorDefaultHeight", "200px", "String", "", "AutoForm");
130  Settings::setDefaultValue("settings", "javascriptEnabled", true, "Boolean", "", "AutoForm");
131  Settings::setDefaultValue("settings", "markRequiredFields", true, "Boolean", "", "AutoForm");
132  Settings::setDefaultValue("settings", "onFormatLabel", "addContextHelp", "String", "Callback function for start of field label", "AutoForm");
133  Settings::setDefaultValue("settings", "requiredFieldsText", "* indicates required field", "String", "", "AutoForm");
134  Settings::setDefaultValue("settings", "passwordEnterLabel", "Enter", "String", "The text of the password entry field label", "AutoForm");
135  Settings::setDefaultValue("settings", "passwordEnterLabel", "Confirm", "String", "The text of the password confirmation field label", "AutoForm");
136  Settings::setDefaultValue("settings", "buttons_at_top", false, "Boolean", "Whether the form's save/cancel buttons appear at the top of the form in addition to the bottom.", "AutoForm");
137  Settings::setDefaultValue("settings", "default_layout", "table", String, "Specifies the default layout manager to use when rendering forms", "AutoForm", "table\nsimple\nmobile");
138  Settings::setDefaultValue("settings", "interstitialSpinner", "/fakoli/images/spinner.gif", String, "Specifies the default spinner animation to use with interstitials", "AutoForm");
139 
140  Settings::setDefaultValue("settings", "font_awesome_URL", "", 'String', "If you want to use a specific version of Font Awesome (for instance if you have a Pro subscription) enter the URL here", "Font Awesome");
141  }
142 
152  static function configurationBootstrap()
153  {
154  global $auto_form_defaults;
155  global $fontawesome;
156 
157  $afDefaults = Cache::get("auto_form_defaults");
158  if (!$afDefaults)
159  {
160  $afDefaults = array();
161  $autoFormSettings = Query::create(Settings, "WHERE component='settings' AND category='AutoForm'")
162  ->filter(new InclusionFilter("name", "value"))
163  ->execute();
164 
165  foreach($autoFormSettings as $setting)
166  {
167  $afDefaults[$setting->name] = $setting->value;
168  }
169 
170  Cache::put("auto_form_defaults", $afDefaults);
171  }
172 
173  foreach($afDefaults as $name => $value)
174  {
175  if (!isset($auto_form_defaults[$name])) $auto_form_defaults[$name] = $value;
176  }
177 
178  $fontawesomeURL = Cache::get("font_awesome_URL");
179  if (!$fontawesomeURL)
180  {
181  $fontawesomeURL = Settings::getValue("settings", "font_awesome_URL");
182  if (!$fontawesomeURL) $fontawesomeURL = $fontawesome;
183  Cache::put("font_awesome_URL", $fontawesomeURL);
184  }
185 
186  $fontawesome = $fontawesomeURL;
187  }
188 
189  static function getSubTabs($component)
190  {
191  $tabs = null;
192  $settingCategories = array();
193 
194  $categories = Query::create(Settings, "WHERE component = :component && (category != '' OR category != null)")
195  ->bind("component", $component->name)
196  ->execute();
197 
198  if(count($categories) > 0)
199  {
200  $categories = removeDuplicates($categories, "category");
201  if(count($categories) > 1)
202  {
203  $idx = 1;
204  foreach($categories as $category)
205  {
206  $settingCategory = new SettingsCategory();
207  $settingCategory->component_id = $component->component_id;
208  $settingCategory->category_id = $idx;
209  $settingCategory->component = $component->name;
210  $settingCategory->category = $category->category;
211  $settingCategories[] = $settingCategory;
212  $idx++;
213  }
214 
215  $tabs = new DataItemTabBar("subtabs", $settingCategories);
216  }
217  }
218  return $tabs;
219  }
220 
221  static function upgradeComponent($version)
222  {
224  $mgr->upgrade($version);
225  }
226 
228  {
229  SerializationManager::registerHandler("settings", "Settings and Permissions", new SettingsSerializationHandler());
230  return true;
231  }
232 }?>
$tabs
$handler
Definition: event_form.inc:62
$component
Definition: help.inc:38
if(! $page) $path
Definition: page.inc:57
$name
Definition: upload.inc:54
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 serialize($class, $constraint="")
Serializes the specified DataItems to XML.
registerHandler($component, $title, $handler)
Registers a serialization handler for a component.
static unserialize($class, $doc, $tx, $save=true)
Instantiates DataItems from the supplied XML document and stores them in the database.
The Settings class provides components with a common API for specifying application settings and conf...
Definition: settings.inc:49
static getValue($component, $name)
Retrieve the value of the specified Setting.
Definition: settings.inc:104
static setDefaultValue($component, $name, $value, $field_type="String", $annotation="", $category="", $options="", $weight=0)
Sets the default value of the given component setting.
Definition: settings.inc:174
static getExtension($component)
static getSubTabs($component)
static registerSerializationHandler()
static upgradeComponent($version)
static registerExtension($component, $handler)
static configurationBootstrap()
Sets the Fakoli framework configuration variables according to the settings stored in the database.
$fontawesome
Definition: core.inc:45
global $config
Definition: import.inc:4
$setting