CMS  Version 3.9
site_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("site");
35 Fakoli::using("field_renderers");
36 Fakoli::usingFile("framework/auto_form.inc");
37 
38 Fakoli::assertRole("admin");
39 
40 $menu_item = "Sites";
41 
42 $site_id = checkNumeric($_GET["site_id"]);
43 
44 $site = new Site();
45 
46 $form = new AutoForm($site);
47 
48 $form->required("title");
49 $form->allowDelete = true;
50 $redirect = "/admin/sites";
51 $form->button("Cancel", $redirect);
52 $form->annotate("meta_tag_description", "Default content for the description meta-tag");
53 $form->annotate("meta_tag_keyword", "Default content for the keywords meta-tag");
54 
55 $themeSelect = new SelectFieldRenderer($form, "theme", "Theme", SiteManager::getThemeOptions());
56 $templateSelect = new TemplateSelectFieldRenderer($form, "default_template", "Default Template", "theme");
57 $printTemplateSelect = new TemplateSelectFieldRenderer($form, "print_template", "Print Template", "theme");
58 $popupTemplateSelect = new TemplateSelectFieldRenderer($form, "popup_template", "Popup Template", "theme");
59 $mobileTemplateSelect = new TemplateSelectFieldRenderer($form, "mobile_template", "Mobile Template", "theme");
60 
61 if ($method == "POST")
62 {
63 
64  if ($form->save())
65  {
66  redirect($redirect);
67  }
68 }
69 
70 if ($site_id)
71 {
72  $site->load($site_id);
73  $title = "Edit Site Details for {$site->site_name}";
74 }
75 else
76 {
77  $title = "Add a New Site";
78 }
79 
80 $script .= $form->writeScript();
81 
82 
83 
84 $form->drawForm();
85 
86 
87 ?>
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 assertRole($role, $redirect="", $message="")
Assert that the user has one of the specified roles.
Definition: core.inc:297
Definition: site.inc:40
static getThemeOptions()
$method
Pull out a simple reference to the request method.
Definition: core.inc:1573
$form
Definition: site_form.inc:46
$mobileTemplateSelect
Definition: site_form.inc:59
$templateSelect
Definition: site_form.inc:56
$popupTemplateSelect
Definition: site_form.inc:58
$printTemplateSelect
Definition: site_form.inc:57
$site
Definition: site_form.inc:44
$redirect
Definition: site_form.inc:50
$menu_item
Definition: site_form.inc:40
$site_id
Definition: site_form.inc:42
$themeSelect
Definition: site_form.inc:55
$script
Definition: site_form.inc:80