]>
src.bluestatic.org Git - isso.git/blob - printer.php
2 /*=====================================================================*\
3 || ###################################################################
4 || # Blue Static ISSO Framework
5 || # Copyright ©2002-[#]year[#] 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 [#]gpl[#] 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 \*=====================================================================*/
29 require_once('ISSO/PrinterElement.php');
30 require_once('ISSO/PrinterBaseElement.php');
31 require_once('ISSO/PrinterLabelElement.php');
32 require_once('ISSO/PrinterRootElement.php');
33 require_once('ISSO/PrinterRootElementPage.php');
34 require_once('ISSO/PrinterRootElementTable.php');
35 require_once('ISSO/PrinterRootElementForm.php');
36 require_once('ISSO/PrinterTableElement.php');
41 * This framework generates standard HTML through various functions. The purpose
42 * is generally so that things like the admin system can be created without templates.
45 * ISSO_PRINTER_DONE_HEADER - An internal constant that is used to check to see
46 * if the page header has already been printed
47 * ISSO_PRINTER_HIDE_SETUP - Will stop the page footer data (copyright and debug
48 * box) from being printed
49 * ISSO_PRINTER_NO_NAVIGATION - Do not show the navigation frame from ISSO.Printer.Navigation
52 * @copyright Copyright ©2002 - [#]year[#], Blue Static
62 private $page_start_hook = ':=NO METHOD=:';
64 // ###################################################################
66 * Creates a redirect to another page; constructs the header and footer
67 * (therefore execution stops)
69 * @param string Location to redirect to
70 * @param string Redirect message to be shown
71 * @param array An aray of POST variables to send through on the redirect
73 public function redirect($location, $message = null, $postvars = array())
76 <script type="text/javascript">
82 setTimeout("redirect()", timeout);
91 ' . ($postvars ? 'document.forms.postvars.submit();' : 'window.location = "' . $location . '";') . '
97 if (!defined('ISSO_PRINTER_NO_NAVIGATION'))
99 define('ISSO_PRINTER_NO_NAVIGATION', 1);
102 $this->page_start(_('Redirect'));
106 $this->form_start($location, null, false, 'postvars');
108 foreach ($postvars AS $key => $value)
110 $this->form_hidden_field($key, $value);
116 $redir = sprintf(_('Please wait to be redirected. If you are not redirected in a few seconds, click <a href="%1$s">here</a>.'), $location);
118 if ($message == null)
120 $showmessage = $redir;
124 $showmessage = '<blockquote>' . $message . '</blockquote>';
125 $showmessage .= "\n<p>" . $redir . "</p>";
129 $this->page_message(_('Redirect'), $showmessage, $override);
131 $this->page_code($js);
136 // ###################################################################
138 * Produces an entire page layout that asks the user whether or not
139 * they want to perform X action and provides a link to the YES and NO
142 * @param string Message that asks if they want to do X
143 * @param string Location to go for YES
144 * @param string DO action to pass
145 * @param array Hidden parameters to pass to the next page
147 public function confirm($message, $location, $action, $params)
149 if (!defined('ISSO_PRINTER_NO_NAVIGATION'))
151 define('ISSO_PRINTER_NO_NAVIGATION', 1);
154 $this->page_start(_('Confirm'));
156 $this->form_start($location, $action);
157 foreach ($params AS $key => $value)
159 $this->form_hidden_field($key, $value);
162 $this->table_start(true, '75%');
163 $this->table_head(_('Confirm'), 1);
164 $this->row_span("<blockquote>$message</blockquote>", ':swap:', 'left', 1);
165 $this->row_submit('<input type="button" class="button" name="no" value=" ' . _('No') . ' " onclick="history.back(1); return false;" />', _('Yes'), '');
173 // ###################################################################
175 * Throws a fatal error; constructs the header and footer
177 * @param string Error messsage text
179 public function error($message)
181 if (!defined('ISSO_PRINTER_NO_NAVIGATION'))
183 define('ISSO_PRINTER_NO_NAVIGATION', 1);
186 $this->page_start(_('Error'));
187 $this->page_message(_('Error'), $message);
193 // ###################################################################
195 * A block function that produces a table with a message in it. This
196 * does not print the header and footer.
198 * @param string The title of the message (appears at the top of the block)
199 * @param string Content of the message
200 * @param bool Override the message: control the entire output (no <blockquote>)?
202 public function page_message($title, $message, $overridemessage = false)
204 $this->table_start(true, '75%');
205 $this->table_head($title, 1);
206 $this->row_span(($overridemessage ? $message : "<blockquote>$message</blockquote>"), ':swap:', 'left', 1);
210 // ###################################################################
212 * Creates a table row with a <textarea> as the value column
214 * @param string Label text
215 * @param string Name of the <textarea>
216 * @param string Value of the <textarea>
217 * @param integer Colspan attribute
218 * @param integer Number of rows in the <textarea>
219 * @param integer Number of colums in the <textarea>
220 * @param bool Whether or not to use monospacing font
221 * @param string Extra style attributes to apply to the <textarea>
223 public function row_textarea($label, $name, $value = '', $colspan = 2, $rows = 7, $cols = 50, $code = false, $style = '')
225 $this->row_text($label, "<textarea name=\"$name\" class=\"" . ($code ? 'code' : 'input') . "\" rows=\"$rows\" cols=\"$cols\"" . ($style ? ' style="' . $style . '"' : '') . ">$value</textarea>", 'top', $colspan);
228 // ###################################################################
230 * Adds a name-value pair to an array that is constructed into a
233 * @param string Text displayed for the option
234 * @param string Value of the option
235 * @param bool Whether or not to select this particluar option
237 public function list_item($name, $value, $selected = false)
241 $listitem["$value"] = array('name' => $name, 'selected' => $selected);
244 // ###################################################################
246 * Assembles a <select> table row from list_item() items
248 * @param string Label text
249 * @param string Name of the <select>
250 * @param integer Colspan attribute
252 public function row_list($label, $name, $colspan = 2)
256 foreach ($listitem AS $value => $option)
258 $optionlist .= "\n\t
<option value
=\"$value\"" . ($option['selected'] == true ? ' selected="selected
"' : '') . ">$option[name
]</option
>";
263 $this->row_text($label, "\n
<select
class=\"button\" name
=\"$name\">$optionlist\n</select
>\n", $colspan);
266 // ###################################################################
268 * Assembles a list of checkboxes from list_item() items
270 * @param string Label text
271 * @param string Name of the <input>s
272 * @param integer Colspan attribute
274 public function row_checkbox($label, $name, $colspan = 2)
278 foreach ($listitem AS $value => $box)
280 $optionlist[] = "\n\t
<input type
=\"checkbox\"
class=\"button\" name
=\"{$name
}[]\" value
=\"$value\"" . ($box['selected'] == true ? ' checked="checked
"' : '') . " /> $box[name
]";
285 $this->row_text($label, "\n
" . implode('<br />', $optionlist) . "\n
", $colspan);
289 /*=====================================================================*\
290 || ###################################################################
293 || ###################################################################
294 \*=====================================================================*/