openrat-cms

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit f2da747163e18c5f27a2dff648c8d40724d43cd7
parent d37255f8a38c23ee8d48819c2b3e48978f0fc1e0
Author: Jan Dankert <devnull@localhost>
Date:   Wed, 29 Nov 2017 00:55:20 +0100

Weiter die Template-Includes durch Klassen ersetzt.

Diffstat:
themes/default/include/html/Component.class.php | 35+++++++++++++++++++++++++++++++++--
themes/default/include/html/date/Date.class.php | 2+-
themes/default/include/html/date/date.inc.php | 6------
themes/default/include/html/else/Else.class.php | 18++++++++++++++++++
themes/default/include/html/else/else-begin.inc.php | 3---
themes/default/include/html/else/else-end.inc.php | 4----
themes/default/include/html/focus/Focus.class.php | 26++++++++++++++++++++++++++
themes/default/include/html/focus/focus-begin.inc.php | 6------
themes/default/include/html/form/form-begin.inc.php | 70----------------------------------------------------------------------
themes/default/include/html/form/form-end.inc.php | 16----------------
themes/default/include/html/group/Group.class.php | 39+++++++++++++++++++++++++++++++++++++++
themes/default/include/html/group/group-begin.inc.php | 7-------
themes/default/include/html/group/group-end.inc.php | 5-----
themes/default/include/html/if/If.class.php | 50++++++++++++++++++++++++++++++++++++++++++++++++++
themes/default/include/html/if/if-begin.inc.php | 67-------------------------------------------------------------------
themes/default/include/html/if/if-end.inc.php | 4----
themes/default/include/html/set/Set.class.php | 6+++---
17 files changed, 170 insertions(+), 194 deletions(-)

diff --git a/themes/default/include/html/Component.class.php b/themes/default/include/html/Component.class.php @@ -3,6 +3,18 @@ abstract class Component { + private $depth; + + public function getDepth() + { + return $this->depth; + } + + public function setDepth($depth) + { + $this->depth = $depth; + } + /** * Gets the beginning of this component. * @return string @@ -35,6 +47,19 @@ abstract class Component {} + protected function varname($value) + { + $erg = $this->value($value); + + // Für statische Texte muss kein PHP-Abschnitt geoeffnet werden. + if (substr($erg,0,1) == "'" && strpos($erg,'$')===FALSE ) + return substr($erg,1,-1); + else + return $erg; + } + + + protected function htmlvalue($value) { $erg = $this->value($value); @@ -42,8 +67,8 @@ abstract class Component // Für statische Texte muss kein PHP-Abschnitt geoeffnet werden. if (substr($erg,0,1) == "'" && strpos($erg,'$')===FALSE ) return substr($erg,1,-1); - else - return '<'.'?php echo '.$erg.' ?>'; + else + return '<'.'?php echo '.$erg.' ?>'; } @@ -106,6 +131,12 @@ abstract class Component } } + + protected function include( $file ) + { + echo "include_once( OR_THEMES_DIR.'default/include/html/date/".$file."');"; + + } } diff --git a/themes/default/include/html/date/Date.class.php b/themes/default/include/html/date/Date.class.php @@ -8,7 +8,7 @@ class DateComponent extends Component { $date = $this->date; - include_once( OR_THEMES_DIR.'default/include/html/date/date.inc.php'); + $this->include( 'component-date.php'); echo '<?php component_date('.$this->value($this->date).') ?>'; } } diff --git a/themes/default/include/html/date/date.inc.php b/themes/default/include/html/date/date.inc.php @@ -1,5 +0,0 @@ -<?php - -readfile(OR_THEMES_DIR.'default/include/html/date/component-date.php'); - -?>- \ No newline at end of file diff --git a/themes/default/include/html/else/Else.class.php b/themes/default/include/html/else/Else.class.php @@ -0,0 +1,17 @@ +<?php + +class ElseComponent extends Component +{ + + public function begin() + { + echo '<?php if(!$if'.$this->getDepth().'){?>'; + } + + + public function end() { + echo '<?php } ?>'; + } +} + +?>+ \ No newline at end of file diff --git a/themes/default/include/html/else/else-begin.inc.php b/themes/default/include/html/else/else-begin.inc.php @@ -1,2 +0,0 @@ -<?php if (!$attr_tmp_last_exec) { ?> -/* Ignore: */ <?php } ?>- \ No newline at end of file diff --git a/themes/default/include/html/else/else-end.inc.php b/themes/default/include/html/else/else-end.inc.php @@ -1,3 +0,0 @@ -/* Ignore: */ <?php { ?> -<?php } -unset($attr_tmp_last_exec) ?>- \ No newline at end of file diff --git a/themes/default/include/html/focus/Focus.class.php b/themes/default/include/html/focus/Focus.class.php @@ -0,0 +1,25 @@ +<?php + +class FocusComponent extends Component +{ + + public function begin() + { + /* + echo <<<'HTML' +<script name="JavaScript" type="text/javascript"><!-- +// Auskommentiert, da JQuery sonst abbricht und die Success-Function des LoadEvents nicht mehr ausführt. +//document.forms[0].<?php echo $attr_field ?>.focus(); +//document.forms[0].<?php echo $attr_field ?>.select(); +// --> +</script> +HTML; + */ + } + + + public function end() { + } +} + +?>+ \ No newline at end of file diff --git a/themes/default/include/html/focus/focus-begin.inc.php b/themes/default/include/html/focus/focus-begin.inc.php @@ -1,6 +0,0 @@ -<script name="JavaScript" type="text/javascript"><!-- -// Auskommentiert, da JQuery sonst abbricht und die Success-Function des LoadEvents nicht mehr ausführt. -//document.forms[0].<?php echo $attr_field ?>.focus(); -//document.forms[0].<?php echo $attr_field ?>.select(); -// --> -</script> diff --git a/themes/default/include/html/form/form-begin.inc.php b/themes/default/include/html/form/form-begin.inc.php @@ -1,69 +0,0 @@ -<?php - #IF-ATTR action# - #ELSE - $attr_action = $actionName; - #END-IF - #IF-ATTR subaction# - #ELSE - $attr_subaction = $targetSubActionName; - #END-IF - #IF-ATTR id# - #ELSE - $attr_id = $this->getRequestId(); - #END-IF - - #IF-ATTR label# - $attr_tmp_ok_label = $attr_label; - #ELSE - $attr_tmp_ok_label = lang('BUTTON_OK'); - #END-IF - - $attr_tmp_show_cancel = $attr_cancel; - $attr_tmp_visible = $attr_visible; - - if ($this->isEditable()) - { - if ($this->isEditMode()) - { - $attr_method = 'POST'; - } - else - { - $attr_method = 'GET'; - $attr_subaction = $subActionName; - } - } - - switch( $attr_type ) - { - case 'upload': - $attr_tmp_submitFunction = ''; - break; - default: - $attr_tmp_submitFunction = 'formSubmit( $(this) ); return false;'; - } - -?><form name="<?php echo $attr_name ?>" - target="<?php echo $attr_target ?>" - action="" - data-method="<?php echo $attr_subaction ?>" - data-action="<?php echo $attr_action ?>" - data-id="<?php echo $requestId ?>" - method="<?php echo $attr_method ?>" - enctype="<?php echo $attr_enctype ?>" - class="<?php echo $attr_action ?>" - data-async="<?php echo $attr_async?'true':'false' ?>" - data-autosave="<?php echo $attr_autosave?'true':'false' ?>" - onSubmit="<?php echo $attr_tmp_submitFunction ?>"><input type="submit" class="invisible" /> - -<?php if ($this->isEditable() && !$this->isEditMode()) { ?> -<input type="hidden" name="mode" value="edit" /> -<?php } ?> - -<input type="hidden" name="<?php echo REQ_PARAM_TOKEN ?>" value="<?php echo token() ?>" /> -<input type="hidden" name="<?php echo REQ_PARAM_ACTION ?>" value="<?php echo $this->actionName ?>" /> -<input type="hidden" name="<?php echo REQ_PARAM_SUBACTION ?>" value="<?php echo empty($attr_subaction)?$this->subActionName:$attr_subaction ?>" /> -<input type="hidden" name="<?php echo REQ_PARAM_ID ?>" value="<?php echo $this->getRequestId() ?>" /><?php - if ( $conf['interface']['url_sessionid'] ) - echo '<input type="hidden" name="'.session_name().'" value="'.session_id().'" />'."\n"; -?>- \ No newline at end of file diff --git a/themes/default/include/html/form/form-end.inc.php b/themes/default/include/html/form/form-end.inc.php @@ -1,16 +0,0 @@ - -<!-- Ignore: --><form> - -<div class="bottom"> - <div class="command <?php echo $attr_tmp_visible?'visible':'xinvisible' ?>"> - - <input type="button" class="submit ok" value="<?php echo $attr_tmp_ok_label ?>" onclick="$(this).closest('div.sheet').find('form').submit(); " /> - - <!-- Cancel-Button nicht anzeigen, wenn cancel==false. --> - <?php if ($attr_tmp_show_cancel) { ?> - <input type="button" class="submit cancel" value="<?php echo lang('CANCEL') ?>" onclick="$('div#dialog').hide(); $('div#filler').fadeOut(500); $(this).closest('div.panel').find('ul.views > li.active').click();" /> - <?php } ?> - </div> -</div> - -</form> diff --git a/themes/default/include/html/group/Group.class.php b/themes/default/include/html/group/Group.class.php @@ -0,0 +1,38 @@ +<?php + +class GroupComponent extends Component +{ + + public $open = true; + public $show = true; + public $title; + public $icon; + + public function begin() + { + echo '<fieldset'; + echo ' class="'; + echo '<?php echo '.$this->value($this->open).'?" open":"" ?>'; + echo '<?php echo '.$this->value($this->show).'?" show":"" ?>'; + echo '">'; + + if ( !empty($this->title)) + { + echo '<legend>'; + if ( !empty($this->icon)) + echo '<img src="/themes/default/images/icon/method/'.$this->htmlvalue($this->icon).'.svg" />'; + + echo '<div class="arrow-right closed" /><div class="arrow-down open" />'; + echo $this->htmlvalue($this->title); + echo '</legend>'; + } + echo '<div>'; + } + + + public function end() { + echo '</div></fieldset>'; + } +} + +?>+ \ No newline at end of file diff --git a/themes/default/include/html/group/group-begin.inc.php b/themes/default/include/html/group/group-begin.inc.php @@ -1,6 +0,0 @@ -<?php -?><fieldset class="<?php echo $attr_open?'open':'' ?> <?php echo $attr_show?'show':'' ?>"><?php if(isset($attr_title)) { ?><legend><?php if(isset($attr_icon)) { ?>&nbsp;&nbsp;<img src="<?php echo $image_dir.'icon_'.$attr_icon.IMG_ICON_EXT ?>" align="left" border="0" /><?php } ?><div class="arrow-right closed" /><div class="arrow-down open" />&nbsp;&nbsp;<?php echo encodeHtml($attr_title) ?>&nbsp;&nbsp;</legend><?php } ?><div> - - - -<!-- Ignored: --></div></fieldset>- \ No newline at end of file diff --git a/themes/default/include/html/group/group-end.inc.php b/themes/default/include/html/group/group-end.inc.php @@ -1,4 +0,0 @@ -<!-- Ignore: --><fieldset><div> - - -</div></fieldset>- \ No newline at end of file diff --git a/themes/default/include/html/if/If.class.php b/themes/default/include/html/if/If.class.php @@ -0,0 +1,49 @@ +<?php + +class IfComponent extends Component +{ + public $true; + public $false; + public $contains; + public $value; + public $empty; + public $lessthan; + public $greaterthan; + public $present; + public $not; + + + public function begin() + { + echo <<<'HTML' +HTML; + + echo '<?php $if'.$this->getDepth().'='.(empty($this->not)?'':'!').'('; + if ( !empty($this->true )) + echo $this->value($this->true); + elseif (! empty($this->false)) + echo '!' . $this->value($this->false); + elseif (! empty($this->contains)) + echo 'in_array('.$this->value($this->value).',explode(",",'.$this->value($this->contains).')'; + elseif (! empty($this->equals)) + echo '' . $this->value($this->value).'=='.$this->value($this->equals); + elseif (strlen($this->lessthan)>0) + echo 'intval(' . $this->value($this->lessthan).')>intval('.$this->value($this->value).')'; + elseif (strlen($this->greaterthan)>0) + echo 'intval(' . $this->value($this->greaterthan).')<intval('.$this->value($this->value).')'; + elseif (! empty($this->present)) + echo '!empty(' . $this->value($this->present).')'; + elseif (! empty($this->empty)) + echo 'empty(' . $this->value($this->empty).')'; + else + throw new LogicException("Element 'if' has not enough parameters."); + + echo '); if($if'.$this->getDepth().'){?>'; + } + + public function end() { + echo '<?php } ?>'; + } +} + +?>+ \ No newline at end of file diff --git a/themes/default/include/html/if/if-begin.inc.php b/themes/default/include/html/if/if-begin.inc.php @@ -1,66 +0,0 @@ -<?php - -#IF-ATTR true# - // Wahr-Vergleich - if (gettype($attr_true) === '' && gettype($attr_true) === '1') - $attr_tmp_exec = $$attr_true == true; - else - $attr_tmp_exec = $attr_true == true; -#END-IF# - -#IF-ATTR false# - if (gettype($attr_false) === '' && gettype($attr_false) === '1') - $attr_tmp_exec = $$attr_false == false; - else - $attr_tmp_exec = $attr_false == false; - -#END-IF# - -#IF-ATTR contains# - // Inhalt-Vergleich mit Wertliste - $attr_tmp_exec = in_array($attr_value,explode(',',$attr_contains)); -#END-IF# - -#IF-ATTR equals# - $attr_tmp_exec = $attr_equals == $attr_value; -#END-IF# - -#IF-ATTR lessthan# - // Inhalt-Vergleich - $attr_tmp_exec = intval($attr_lessthan) > intval($attr_value); -#END-IF# - -#IF-ATTR greaterthan# - $attr_tmp_exec = intval($attr_greaterthan) < intval($attr_value); -#END-IF# - - -#IF-ATTR empty# - if ( !isset($$attr_empty) ) - $attr_tmp_exec = empty($attr_empty); - elseif ( is_array($$attr_empty) ) - $attr_tmp_exec = (count($$attr_empty)==0); - elseif ( is_bool($$attr_empty) ) - $attr_tmp_exec = true; - else - $attr_tmp_exec = empty( $$attr_empty ); -#END-IF# - - -#IF-ATTR present# - $attr_tmp_exec = isset($$attr_present); -#END-IF# - - -#IF-ATTR not# - $attr_tmp_exec = !$attr_tmp_exec; -#END-IF# - - // Fuer eine eventuelle ELSE-Bedingung merken wir uns den Status. - $attr_tmp_last_exec = $attr_tmp_exec; - - if ( $attr_tmp_exec ) - { -?> - -/* THIS LINE WILL BE IGNORED */ <?php } ?>- \ No newline at end of file diff --git a/themes/default/include/html/if/if-end.inc.php b/themes/default/include/html/if/if-end.inc.php @@ -1,3 +0,0 @@ -/* THIS LINE WILL BE IGNORED */ <?php { ?> - -<?php } ?>- \ No newline at end of file diff --git a/themes/default/include/html/set/Set.class.php b/themes/default/include/html/set/Set.class.php @@ -11,13 +11,13 @@ class SetComponent extends Component if (!empty($this->value)) { if (!empty($this->key)) - echo '<?php $'.$this->value($this->var).'= '.$this->value($this->value).'['.$this->value($this->key).']; ?>'; + echo '<?php $'.$this->varname($this->var).'= '.$this->value($this->value).'['.$this->value($this->key).']; ?>'; else - echo '<?php $'.$this->value($this->var).'= '.$this->value($this->value).'; ?>'; + echo '<?php $'.$this->varname($this->var).'= '.$this->value($this->value).'; ?>'; } else { // Unset - echo '<?php unset($'.$this->value($this->var).') ?>'; + echo '<?php unset($'.$this->varname($this->var).') ?>'; } } }