CMS  Version 3.9
bookmark_popup.inc
Go to the documentation of this file.
1 <?php
2 Fakoli::using("bookmark");
3 Fakoli::usingFeature("auto_form");
4 
5 $bookmark_id = checkNumeric($_GET["bookmark_id"]);
6 
7 $url = $_GET["url"];
8 $title = htmlSafe($_GET["title"]);
9 
11 
12 if ($bookmark_id)
13 {
14  $bookmark->load($bookmark_id);
15 }
16 else
17 {
18  $bookmark->url = $url;
19  $bookmark->title = $title;
20  $bookmark->user_id = $user->get($user->getPrimaryKey());
21 }
22 
23 $form = new AutoForm($bookmark, "POST", "/action/bookmark/bookmark_popup?bookmark_id={$bookmark_id}", "Bookmark_form");
24 $form->ajaxSubmit("function(result) {BookmarkManager.handleResponse(result);}", "function() {document.id('{$form->id}_error').set('text','Failed to communicate with server'); }");
25 
26 if (Settings::getValue("bookmark", "show_url"))
27 {
28  $form->readonly("url");
29 }
30 else
31 {
32  $form->hide("url");
33 }
34 
35 $form->required("title");
36 $form->hide("user_id");
37 $form->allowDelete = true;
38 
39 $categorySelect = new SelectFieldRenderer($form, "category", "Category");
40 $categorySelect->allowAddEntry();
41 
42 if ($method == "POST")
43 {
44  $_POST["user_id"] = $user->get($user->getPrimaryKey());
45 
46  if ($form->save())
47  {
48  Fakoli::end("OK");
49  }
50 }
51 
52 $script .= $form->writeScript();
53 $form->drawForm();
54 ?>
$_POST["owner_id"]
Definition: blog_form.inc:54
$bookmark_id
$bookmark
$url
$title
if($method=="POST") $script
$categorySelect
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 getValue($component, $name)
Retrieve the value of the specified Setting.
Definition: settings.inc:104
global $user
$method
Pull out a simple reference to the request method.
Definition: core.inc:1573