CMS  Version 3.9
snippet_form.inc
Go to the documentation of this file.
1 <?php
2 Fakoli::using("html_editor");
3 
4 $snippet_id = checkNumeric($_GET["snippet_id"]);
5 
6 $snippet = new Snippet();
7 
8 if ($snippet_id)
9 {
10  $snippet->load($snippet_id);
11 }
12 else
13 {
14  $snippet->user_id = $user->getPrimaryKeyValue();
15 }
16 
17 $form = new AutoForm($snippet, "POST", "/action/html_editor/snippet_form?snippet_id={$snippet_id}");
18 $form->ajaxSubmit("function(result) { new SnippetManager().snippetSaved(result); }");
19 $form->required("snippet_name", "description");
20 $form->hide("user_id");
21 
22 if ($method == "POST")
23 {
24  if ($form->save())
25  {
26  Fakoli::end($form->data->snippet_id);
27  }
28  else
29  {
30  Fakoli::end($form->msg);
31  }
32 }
33 
34 $script .= $form->writeScript();
35 $form->drawForm();
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
global $user
$method
Pull out a simple reference to the request method.
Definition: core.inc:1573
$form
$snippet
Definition: snippet_form.inc:6
$snippet_id
Definition: snippet_form.inc:4
if($method=="POST") $script