CMS  Version 3.9
content_properties_json.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 
8 $sectionContent->fromJSON($_REQUEST["data"]);
9 
10 $form = new AutoForm($sectionContent, "POST", "/action/section/content_properties_json?save=1", "SectionContent_form");
11 $form->ajaxSubmit("function(result) {sectionContentPropertyManager.propertiesChanged(result);}");
12 $form->button("Cancel", "sectionContentPropertyManager.cancel()", null, true);
13 
14 $form->hide("section_id", "identifier");
15 
16 $form->customSaveHandler = function($form)
17 {
18  // No direct save to database from this form
19  return true;
20 };
21 
22 $templateSelect = new TemplateSelectFieldRenderer($form, "template", "Template", "none");
23 $roleList = new CheckListFieldRenderer($form, "role", "Role", SiteRole::getRolesArray());
25 if ($permissionsList) $permissionsList->colspan = 2;
26 
27 $form->submitLabel = "Update Properties";
28 
29 if ($method == "POST")
30 {
31  if ($form->save())
32  {
33  Fakoli::JSONreturn($form->data, false);
34  }
35  else
36  {
37  Fakoli::JSONerror($form->msg, false);
38  }
39 }
40 
41 echo $form->writeScript();
42 $form->drawForm();
43 ?>
static usingFeature()
Uses the specified framework feature(s).
Definition: core.inc:388
static JSONerror($error, $sendType=true)
Return an error code to the client in JSON format, as an object with the single property 'error'.
Definition: core.inc:1180
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
static JSONreturn($object, $sendType=true, $wrap=true)
Return a DataItem to the client in JSON format.
Definition: core.inc:1160
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
$method
Pull out a simple reference to the request method.
Definition: core.inc:1573