CMS  Version 3.9
scroll_form.inc
Go to the documentation of this file.
1 <?php
2 /**************************************************************
3 
4  Copyright (c) 2016 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("scroll", "menu", "site", "field_renderers", "role", "taxonomy", "versioned_content");
35 
36 Fakoli::usingFeature("auto_form", "tree");
37 
38 Fakoli::assertRole("admin,editor");
39 
40 $menu_item = "Scrolls";
41 
42 $scroll_id = checkNumeric($_GET["scroll_id"]);
43 
44 $scroll = new Scroll();
45 $scroll->filter = new ExclusionFilter("menu_id");
46 
47 if ($scroll_id)
48 {
49  $scroll->load($scroll_id);
50  $title = "Edit Scroll Details for {$scroll->title}";
51 }
52 else
53 {
54  $title = "Add a New Scroll";
55 }
56 
57 $scroll->created_date = date("Y-m-d");
58 
59 $form = new AutoForm($scroll);
60 
61 $form->required("title", "identifier");
62 $form->regexp("identifier", "^[\\w_\\-]+$", "Identifier must consist of letters, numbers, underscores and dashes only.");
63 
64 $form->readonly("created_date");
65 $form->unique("identifier", "That identifier is already in use. Please pick a new identifier.");
66 $form->allowDelete = ($scroll_id && $scroll->countParts());
67 
69 
70 $siteSelect = new RelatedItemSelectFieldRenderer($form, "site_id", "Site", Site, "ORDER BY site_name", "site_name", "site_id");
71 
72 //VersionedContentManager::enableVersioning($form);
73 
74 
76 $tabs->page = "scroll_form";
77 
78 if ($method == "POST")
79 {
80 
81  if ($form->save())
82  {
83  if ($form->deleted)
84  {
85  redirect("/admin/scrolls");
86  }
87 
88  $tabs->queryString = "scroll_id={$form->data->scroll_id}";
89  $tabs->next();
90  }
91 }
92 
93 $redirect = "/admin/scrolls";
94 $form->button("Cancel", $redirect);
95 
96 $script .= $form->writeScript();
97 
98 $tabs->writeHTML();
99 ?>
100 <div class='tab_border'>
101 <?
102 $form->drawForm();
103 ?>
104 </div>
105 <?
106 
107 
108 ?>
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 assertRole($role, $redirect="", $message="")
Assert that the user has one of the specified roles.
Definition: core.inc:297
Definition: scroll.inc:8
static scrollTabs($key)
Definition: site.inc:40
static addTaxonomyFieldRenderers($form, $showSelectAll=true, $group=null, $limitTo=null)
$method
Pull out a simple reference to the request method.
Definition: core.inc:1573
$form
Definition: scroll_form.inc:59
$scroll
Definition: scroll_form.inc:44
$siteSelect
Definition: scroll_form.inc:70
if($method=="POST") $redirect
Definition: scroll_form.inc:93
$tabs
Definition: scroll_form.inc:75
$menu_item
Definition: scroll_form.inc:40
$scroll_id
Definition: scroll_form.inc:42
$script
Definition: scroll_form.inc:96