2erlei/app/helper/bereiche.php

102 lines
2.1 KiB
PHP

<?php
/**
* HTML-Helfer für die baseContent-Bereiche
*
* @author Matthias Viehweger <kronn@kronn.de>
* @version 0.2
* @license All Rights Reserved
*/
class bereiche {
var $indent;
var $indent_str = '';
/**
* Konstruktor
*
* @param int $indent
*/
function bereiche($indent=3) {
$this->indent = (int) $indent;
if( $this->indent == 3 ) $this->indent_str = "\t\t\t";
}
/**
* Oberen Abschluss des Bereichs ausgeben
*
* @param string $id ID des Bereichs
* @param string $title Überschrift des Bereichs
*/
function oben($id, $title) {
$html[] = '<fieldset id="'.$id.'"><h3>'.$title.'</h3>';
$html[] = ' <div class="formtop"> &nbsp; </div>';
$this->output($html);
}
/**
* Trennstrich einfügen
*/
function unterbrechung() {
$html[] = ' <div class="fieldbottom"> &nbsp; </div>';
$html[] = ' <div class="fieldstart"> &nbsp; </div>';
$this->output($html);
}
/**
* Buttons ausgeben
*
* @param string $buttons Kommaseparierte Liste der einzufügenden Buttons
*/
function buttons($buttons='') {
$html[] = ' <div class="fieldbottom"> &nbsp; </div>';
if ($buttons != '') {
needs('buttons');
$the_buttons = new buttons();
$html[] = ' <p class="formbuttons">';
$buttons = explode(',', $buttons);
foreach( $buttons as $button ) {
@list($button_method, $button_param) = explode(':', $button);
if ( method_exists($the_buttons, $button_method) ) {
$buttonhtml = $the_buttons->$button_method($button_param);
} else {
$buttonhtml = '';
}
$html[] = ' ' . $buttonhtml;
}
$js = $the_buttons->get_js();
if ( $js != '' ) {
$html[] = $js;
}
$html[] = ' </p>';
}
$this->output($html);
}
/**
* Unteren Abschluss des Bereichs ausgeben
*/
function unten() {
$html[] = ' <div class="formbottom"> &nbsp; </div>';
$html[] = '</fieldset>';
$this->output($html);
}
/**
* Ausgabe des HTML
*
* @param array $html
*/
function output($html) {
foreach( $html as $line ) {
echo $this->indent_str . $line . PHP_EOL;
}
}
}
?>