3 * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
\r
4 * Copyright (C) 2002-2012 The Nucleus Group
\r
6 * This program is free software; you can redistribute it and/or
\r
7 * modify it under the terms of the GNU General Public License
\r
8 * as published by the Free Software Foundation; either version 2
\r
9 * of the License, or (at your option) any later version.
\r
10 * (see nucleus/documentation/index.html#license for more info)
\r
13 * @license http://nucleuscms.org/license.txt GNU General Public License
\r
14 * @copyright Copyright (C) 2002-2012 The Nucleus Group
\r
15 * @version $Id: PAGEFACTORY.php 1626 2012-01-09 15:46:54Z sakamocchi $
\r
19 * The formfactory class can be used to insert add/edit item forms into
\r
20 * admin area, bookmarklet, skins or any other places where such a form
\r
23 class PageFactory extends BaseActions
\r
26 * PageFactory::$blog
\r
27 * Reference to the blog object for which an add:edit form is created
\r
32 * PageFactory::$allowed_types
\r
33 * Allowed types of forms (bookmarklet/admin)
\r
35 private $allowed_types;
\r
38 * PageFactory::$type
\r
39 * One of the types in $allowed_types
\r
44 * PageFactory::$method
\r
50 * PageFactory::$variables
\r
51 * Info to fill out in the form (e.g. catid, itemid, ...)
\r
56 * PageFactory::$actions
\r
57 * Allowed actions (for parser)
\r
59 // TODO: move the definition of actions to the createXForm methods
\r
60 static private $defined_actions = array(
\r
93 * Creates a new PAGEFACTORY object
\r
94 * @param int $blog_id
\r
96 public function __construct($type = '', $blogid, $skin = '')
\r
99 # Call constructor of superclass first
\r
100 parent::__construct();
\r
102 if ( !$blogid && $type == 'itemedit' )
\r
104 $itemid = intRequestVar('itemid');
\r
105 $blogid = getBlogIDFromItemID($itemid);
\r
106 $item = &$manager->getItem($itemid, 1, 1);
\r
107 $manager->notify('PrepareItemForEdit', array('item' => &$item));
\r
110 $this->blog =& $manager->getBlog($blogid);
\r
112 if ( $item && $this->blog->convertBreaks() && $type == 'itemedit' )
\r
114 $item['body'] = removeBreaks($item['body']);
\r
115 $item['more'] = removeBreaks($item['more']);
\r
118 $contents = array();
\r
119 if ( $type == 'itemedit' )
\r
123 elseif ( $type == 'createitem' )
\r
126 'contents' => &$contents,
\r
127 'blog' => &$this->blog
\r
129 $manager->notify('PreAddItemForm', $data);
\r
131 $this->variables = $contents;
\r
133 $skin = new Skin($skin_id, 'AdminActions', 'AdminSkin');
\r
134 $allowed_action_types = $skin->getAllowedActionsForType($type);
\r
135 $this->actions = array_merge($skinActions, $formActions);
\r