CMS  Version 3.9
scroll_part_form.inc
Go to the documentation of this file.
1 <?php
2 Fakoli::using("scroll", "field_renderers");
3 
4 $menu_item = "Scrolls";
5 
6 $scroll_id = checkNumeric($_GET["scroll_id"]);
7 $scroll_part_id = checkNumeric($_GET["scroll_part_id"]);
8 $content_type = checkIdentifier($_GET["content_type"]);
9 
10 if ($scroll_part_id)
11 {
12  $part = new ScrollPart($scroll_part_id);
13  if ($scroll_id != $part->scroll_id)
14  {
15  throw new FakoliException("Parameter Mismatch");
16  }
17 }
18 else
19 {
20  if (!$scroll_id)
21  {
22  throw new FakoliException("Scroll Mismatch");
23  }
24 
25  if ($content_type != 'HTML' && $content_type != 'Code')
26  {
27  throw new Exception("Invalid Content Type");
28  }
29 
30  $part = new ScrollPart();
31  $part->scroll_id = $scroll_id;
32  $part->content_type = $content_type;
33 }
34 
35 $form = new AutoForm($part);
36 $form->allowDelete = true;
37 
38 $scrollSelect = $form->related(Scroll, "", "{title}", "scroll_id", "Scroll");
39 $form->alias("css_class", "CSS Class");
40 $form->readonly("content_type", "scroll_id");
41 
43 
44 $form->onInsertPreProcess = function($form)
45 {
46  $form->data->sort_order = Query::create(ScrollPart, "WHERE scroll_id=:s")
47  ->bind(":s", $form->data->scroll_id)
48  ->executeValue("MAX(sort_order) + 1");
49 };
50 
51 $tabs = ScrollManager::scrollTabs($part->scroll_id);
52 $tabs->page = "scroll_parts";
53 
54 if ($part->content_type == "HTML")
55 {
56  $form->hide("php_code_file");
57 }
58 else
59 {
60  $form->hide("content");
61  $codeSelect = new CodeFileSelectFieldRenderer($form, "php_code_file", "PHP Code File", "modules");
62 }
63 
64 if ($method == "POST")
65 {
66  if ($form->save())
67  {
68  Fakoli::notify("Changes Saved");
69  }
70 }
71 
72 $script .= $form->writeScript();
73 
74 $tabs->writeHTML();
75 ?>
76 <div class='tab_border'>
77 <?php
78 $form->drawForm();
79 ?>
80 </div>
FakoliException is the base exception class for all Fakoli errors.
Definition: core.inc:53
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
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
Definition: scroll.inc:8
static scrollTabs($key)
$method
Pull out a simple reference to the request method.
Definition: core.inc:1573
$scroll_part_id
$scrollSelect
$menu_item
$content_type
$scroll_id
$codeSelect
if($method=="POST") $script