]> src.bluestatic.org Git - isso.git/blob - PrinterRootElementForm.php
Check that database caching is enabled before we run off and try to insert templates...
[isso.git] / PrinterRootElementForm.php
1 <?php
2 /*=====================================================================*
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright ©2002-[#]year[#] Blue Static
6 || #
7 || # This program is free software; you can redistribute it and/or modify
8 || # it under the terms of the GNU General Public License as published by
9 || # the Free Software Foundation; version [#]gpl[#] of the License.
10 || #
11 || # This program is distributed in the hope that it will be useful, but
12 || # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 || # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 || # more details.
15 || #
16 || # You should have received a copy of the GNU General Public License along
17 || # with this program; if not, write to the Free Software Foundation, Inc.,
18 || # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 || ###################################################################
20 \*=====================================================================*/
21
22 /**
23 * Printer Root Element: Form (PrinterRootElementForm.php)
24 *
25 * @package ISSO
26 */
27
28 require_once('ISSO/PrinterRootElement.php');
29
30 /**
31 * Printer Root Element: Form
32 *
33 * Represents a <form> object. This can have a parent or not: if it does,
34 * then it will be painted as a child, otherwise it will act as a root.
35 *
36 * @author Blue Static
37 * @copyright Copyright (c)2002 - [#]year[#], Blue Static
38 * @version $Revision$
39 * @package ISSO
40 *
41 */
42 class BSPrinterRootElementForm extends BSPrinterRootElement
43 {
44 /**
45 * The form's action (or the controller to respond to)
46 * @var string
47 */
48 private $controller;
49
50 /**
51 * Method to use
52 * @var string
53 */
54 private $action;
55
56 /**
57 * The form's name
58 * @var string
59 */
60 private $name;
61
62 /**
63 * This form is upload-ready
64 * @var bool
65 */
66 private $upload;
67
68 // ###################################################################
69 /**
70 * Constructor
71 */
72 public function __construct($controller, $action, $name = 'issoform')
73 {
74 $this->controller = $controller;
75 $this->action = $action;
76 $this->name = $name;
77 }
78
79 // ###################################################################
80 /**
81 * Should this form be used for upload?
82 *
83 * @param bool Upload?
84 */
85 public function setUpload($upload)
86 {
87 $this->upload = $upload;
88 }
89
90 // ###################################################################
91 /**
92 * Adds a table row into the child list
93 *
94 * @param BSPrinterElement Table element
95 */
96 public function addChild(BSPrinterElement $tr)
97 {
98 $this->children[] = $tr;
99 }
100
101 // ###################################################################
102 /**
103 * Returns the HTML for all printed children elements
104 *
105 * @return string Printed HTML
106 */
107 protected function _paintChildren()
108 {
109 $builder = '';
110
111 foreach ($this->children AS $child)
112 {
113 $builder .= "\n" . $child->paint();
114 }
115
116 return $builder;
117 }
118
119 // ###################################################################
120 /**
121 * Paints the <table>
122 *
123 * @return string Table HTML code
124 */
125 public function paint()
126 {
127 if (BSRegister::GetType('Router') AND (!defined('ISSO_ROUTER_NO_REWRITE') OR !constant('ISSO_ROUTER_NO_REWRITE')))
128 {
129 $action = $this->controller . "." . $this->action;
130 }
131 else if (BSRegister::GetType('Router'))
132 {
133 $action = 'index.php?controller=' . $this->controller . '&action=' . $this->action;
134 }
135 else
136 {
137 $action = $this->controller;
138 array_push($this->children, new BSPrinterBaseElement('hidden', 'action', $this->action));
139 }
140 return "\n<form name=\"" . $this->name . "\" action=\"$action\" method=\"post\"" . ($this->upload ? ' enctype="mime/multi-part"' : '') . ">\n" . $this->_paintChildren() . "\n</form>";
141 }
142 }
143
144 /*=====================================================================*
145 || ###################################################################
146 || # $HeadURL$
147 || # $Id$
148 || ###################################################################
149 \*=====================================================================*/
150 ?>