2 /*=====================================================================*
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright (c)2005-2008 Blue Static
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 2 of the License.
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
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 \*=====================================================================*/
23 * Printer Root Element: Form (PrinterRootElementForm.php)
28 require_once(ISSO
. '/PrinterRootElement.php');
31 * Printer Root Element: Form
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.
37 * @copyright Copyright (c)2005 - 2008, Blue Static
41 class BSPrinterRootElementForm
extends BSPrinterRootElement
44 * The form's action (or the controller to respond to)
62 * This form is upload-ready
67 // ###################################################################
71 public function __construct($controller, $action, $name = 'issoform')
73 $this->controller
= $controller;
74 $this->action
= $action;
79 * Makes a new instance of the object in a static fashion
83 public static function make()
85 $obj = new ReflectionClass(__CLASS__
);
86 $args = func_get_args();
87 return $obj->newInstanceArgs($args);
90 // ###################################################################
92 * Should this form be used for upload?
96 * @return fluent interface
98 public function setUpload($upload)
100 $this->upload
= $upload;
104 // ###################################################################
106 * Adds a table row into the child list
108 * @param BSPrinterElement Table element
110 * @return fluent interface
112 public function addChild(BSPrinterElement
$tr)
114 $this->children
[] = $tr;
118 // ###################################################################
120 * Returns the HTML for all printed children elements
122 * @return string Printed HTML
124 protected function _paintChildren()
128 foreach ($this->children
as $child)
130 $builder .= "\n" . $child->paint();
136 // ###################################################################
140 * @return string Table HTML code
142 public function paint()
144 array_push($this->children
, new BSPrinterBaseElement('hidden', 'action', $this->action
));
146 return "\n<form name=\"" . $this->name
. "\" action=\"" . $this->controller
. "\" method=\"post\"" . ($this->upload ?
' enctype="mime/multi-part"' : '') . ">\n" . $this->_paintChildren() . "\n</form>";