CMS  Version 3.9
content_properties.inc
Go to the documentation of this file.
1 <?php
2 Fakoli::using("section", "field_renderers", "role");
3 Fakoli::usingFeature("auto_form");
4 
5 Fakoli::assertRole("admin");
6 
7 $scope = $_GET["scope"];
8 $ids = checkNumeric($_GET["section_content_id"]);
9 
10 $qs = "section_content_id[]=".implode("&section_content_id[]=", $_GET["section_content_id"]);
11 
13 $filter = new InclusionFilter("section_content_id");
14 
15 if ($scope == "template" || $scope == "all")
16 {
17  $filter->add("template");
18 
19 }
20 
21 if ($scope == "role" || $scope == "all")
22 {
23  $filter->add("role");
24 }
25 
26 if ($scope == "permissions" || $scope == "all")
27 {
28  $filter->add("permissions");
29 }
30 
31 if ($scope == "ssl" || $scope == "all")
32 {
33  $filter->add("use_SSL");
34 }
35 
36 if ($scope == "override_page_title" || $scope == "all")
37 {
38  $filter->add("override_page_title");
39 }
40 
41 if ($scope == "body_class" || $scope == "all")
42 {
43  $filter->add("body_class");
44 }
45 
47 
48 // Default dialog to properties for first selected item
49 $sectionContent->load($ids[0]);
50 
51 $form = new AutoForm($sectionContent, "POST", "/action/section/content_properties?$qs&scope=$scope", "SectionContent_form");
52 $form->ajaxSubmit("function(result) {sectionContentManager.propertiesChanged(result);}", "function() {document.id('{$form->id}_error').set('text','Failed to communicate with server'); }");
53 $form->button("Cancel", "sectionContentManager.cancel()", null, true);
54 
55 
56 if ($scope == "template" || $scope == "all")
57 {
58  $templateSelect = new TemplateSelectFieldRenderer($form, "template", "Template", "none");
59 }
60 
61 if ($scope == "role" || $scope == "all")
62 {
63  $roleList = new CheckListFieldRenderer($form, "role", "Role", SiteRole::getRolesArray());
64 }
65 
66 if ($scope == "permissions" || $scope == "all")
67 {
68  $permissionsList = Settings::createPermissionsFieldRenderer($form, "permissions", "Permissions");
69  if ($permissionsList) $permissionsList->colspan = 2;
70 }
71 
72 $form->submitLabel = "Update Properties";
73 
74 if ($method == "POST")
75 {
76  $sectionContent->fromPOST();
77 
78  if ($scope == "role" || $scope == "all")
79  {
80  $sectionContent->role = isset($_POST["role"]) ? implode(",", $_POST["role"]) : "";
81  }
82 
83  if ($scope == "permissions" || $scope == "all")
84  {
85  $sectionContent->permissions = isset($_POST["permissions"]) ? implode(",", $_POST["permissions"]) : "";
86  }
87 
88  $form->postProcessFields($sectionContent->primary_key, $filter);
89 
90  foreach($ids as $id)
91  {
92  $sectionContent->section_content_id = $id;
93  $sectionContent->save();
94  }
95 
96  Fakoli::end("OK");
97  return;
98 }
99 
100 echo $form->writeScript();
101 $form->drawForm();
102 ?>
$_POST["owner_id"]
Definition: blog_form.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 end($message="")
Use this method to terminate execution of a script instead of using the php keywords exit() or die().
Definition: core.inc:1149
static assertRole($role, $redirect="", $message="")
Assert that the user has one of the specified roles.
Definition: core.inc:297
static createPermissionsFieldRenderer($form, $field, $label="")
Definition: settings.inc:343
static getRolesArray()
Retrieves the array of roles and their names for the current site for use in a CMS form.
Definition: role.inc:75
$sectionContent
$method
Pull out a simple reference to the request method.
Definition: core.inc:1573
foreach($permissions as $p) $permissionsList