openrat-cms

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

commit d21e3ad19c99059d45694e956d8dab94aef9fa07
parent 7ad79115bf42a48f3df36a8f0571ea13337487e7
Author: Jan Dankert <devnull@localhost>
Date:   Fri,  1 Dec 2017 23:46:02 +0100

Komponente "link" umgestellt auf eine Klasse.

Diffstat:
themes/default/include/html/link/Link.class.php | 169+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
themes/default/include/html/link/link-begin.inc.php | 63---------------------------------------------------------------
themes/default/include/html/link/link-end.inc.php | 2--
3 files changed, 169 insertions(+), 65 deletions(-)

diff --git a/themes/default/include/html/link/Link.class.php b/themes/default/include/html/link/Link.class.php @@ -0,0 +1,169 @@ +<?php + +/** + * Erzeugt einen HTML-Link. + * + * @author dankert + * + */ +class LinkComponent extends Component +{ + + public $var1; + + public $var2; + + public $var3; + + public $var4; + + public $var5; + + public $value1; + + public $value2; + + public $value3; + + public $value4; + + public $value5; + + public $target; + + public $type; + + public $action; + + public $subaction; + + public $title; + + public $class; + + public $url; + + public $config; + + public $id; + + public $accesskey; + + public $name; + + public $anchor; + + public $frame = '_self'; + + public $modal = false; + + /** + * Link-Beginn + * {@inheritDoc} + * @see Component::begin() + */ + public function begin() + { + echo '<a'; + + if (! empty($this->class)) + echo ' class="' . $this->htmlvalue($this->class) . '"'; + + if (! empty($this->title)) + echo ' title="' . $this->htmlvalue($this->title) . '"'; + + if (! empty($this->accesskey)) + echo ' accesskey="' . $this->htmlvalue($this->accesskey) . '"'; + + if (! empty($this->frame)) + echo ' target="' . $this->htmlvalue($this->frame) . '"'; + + if (! empty($this->name)) + echo ' date-name="' . $this->htmlvalue($this->name) . '" name="' . $this->htmlvalue($this->name) . '"'; + + if (! empty($this->url)) + echo ' data-url="' . $this->htmlvalue($this->url) . '"'; + + if (! empty($this->type)) + echo ' data-type="' . $this->htmlvalue($this->type) . '"'; + + if (! empty($this->action)) + echo ' data-action="' . $this->htmlvalue($this->action) . '"'; + else + echo ' data-action="<?php echo OR_ACTION ?>"'; + + if (! empty($this->subaction)) + echo ' data-method="' . $this->htmlvalue($this->subaction) . '"'; + else + echo ' data-method="<?php echo OR_METHOD ?>"'; + + if (! empty($this->id)) + echo ' data-id="' . $this->htmlvalue($this->id) . '"'; + else + echo ' data-id="<?php echo OR_ID ?>"'; + + switch ($this->type) + { + case 'post': + + // Zusammenbau eines einzeligen JSON-Strings. + // Aufpassen: Keine doppelten Hochkommas, keine Zeilenumbrüche. + echo ' data-data="{'; + + echo "&quot;action&quot;:&quot;"; + if (! empty($this->action)) + echo $this->htmlvalue($this->action); + else + echo "<?php echo OR_ACTION ?>"; + echo "&quot;,"; + + echo "&quot;subaction&quot;:&quot;"; + if (! empty($this->subaction)) + echo $this->htmlvalue($this->subaction); + else + echo "<?php echo OR_METHOD ?>"; + echo "&quot;,"; + + echo "&quot;id&quot;:&quot;"; + if (! empty($this->id)) + echo $this->htmlvalue($this->id); + else + echo "<?php echo OR_ID ?>"; + echo "&quot;,"; + + echo '&quot;'.REQ_PARAM_TOKEN . "&quot;:&quot;" . '<?php echo token() ?>' . "&quot;,"; + + if (! empty($this->var1)) + echo "&quot;var1&quot;:&quot;" . $this->htmlvalue($this->value1) . "&quot;,"; + if (! empty($this->var2)) + echo "&quot;var2&quot;:&quot;" . $this->htmlvalue($this->value2) . "&quot;,"; + if (! empty($this->var3)) + echo "&quot;var3&quot;:&quot;" . $this->htmlvalue($this->value3) . "&quot;,"; + if (! empty($this->var4)) + echo "&quot;var4&quot;:&quot;" . $this->htmlvalue($this->value4) . "&quot;,"; + if (! empty($this->var5)) + echo "&quot;var5&quot;:&quot;" . $this->htmlvalue($this->value5) . "&quot;,"; + + echo "&quot;none&quot;:&quot;0&quot;}\""; + + break; + + case 'html': + + echo ' href="' . $this->htmlvalue($this->url) . '"'; + break; + + default: + echo ' href="' . 'javascript:void(0);' . '"'; + } + + echo '>'; + } + + public function end() + { + echo '</a> +'; + } +} +?> diff --git a/themes/default/include/html/link/link-begin.inc.php b/themes/default/include/html/link/link-begin.inc.php @@ -1,62 +0,0 @@ -<?php - $params = array(); - #IF-ATTR var1# - $params[$attr_var1]=$attr_value1; - #END-IF - #IF-ATTR var2# - $params[$attr_var2]=$attr_value2; - #END-IF - #IF-ATTR var3# - $params[$attr_var3]=$attr_value3; - #END-IF - #IF-ATTR var4# - $params[$attr_var4]=$attr_value4; - #END-IF - #IF-ATTR var5# - $params[$attr_var5]=$attr_value5; - #END-IF - - #IF-ATTR class# - #ELSE - $attr_class=''; - #END-IF - - #IF-ATTR url# - #ELSE - $attr_url=''; - #END-IF - - #IF-ATTR title# - #ELSE - $attr_title = ''; - #END-IF - - $tmp_url = ''; - - #IF-ATTR target# - $params[REQ_PARAM_TARGET] = $attr_target; - #ELSE - $attr_target = $view; - #END-IF - - //$tmp_url = Html::url($attr_action,$attr_subaction,!empty($attr_id)?$attr_id:$this->getRequestId(),$params); - $tmp_href = 'javascript:void(0);'; - switch( $attr_type ) - { - case 'post': - $json = new JSON(); - $tmp_data = $json->encode( array('action'=>!empty($attr_action)?$attr_action:$this->actionName,'subaction'=>!empty($attr_subaction)?$attr_subaction:$this->subActionName,'id'=>!empty($attr_id)?$attr_id:$this->getRequestId()) - +array(REQ_PARAM_TOKEN=>token()) - +$params ); - $tmp_data = str_replace("\n",'',str_replace('"','&quot;',$tmp_data)); - break; - case 'html'; - $tmp_href = $attr_url; - default: - $tmp_data = ''; - } - -// if ( substr($tmp_url,0,10) != 'javascript' ) -// $tmp_url = "javascript:loadViewByName('".$attr_target."','".$tmp_url.(isset($attr_anchor)?'#'.$attr_anchor:'')."'); return false;"; - -?><a data-url="<?php echo $attr_url ?>" target="<?php echo $attr_frame ?>"<?php if (isset($attr_name)) { ?> data-name="<?php echo $attr_name ?>" name="<?php echo $attr_name ?>"<?php }else{ ?> href="<?php echo $tmp_href ?>" <?php } ?> class="<?php echo $attr_class ?>" data-id="<?php echo @$attr_id ?>" data-type="<?php echo $attr_type ?>" data-action="<?php echo @$attr_action ?>" data-method="<?php echo @$attr_subaction ?>" data-data="<?php echo $tmp_data ?>" <?php if (isset($attr_accesskey)) echo ' accesskey="'.$attr_accesskey.'"' ?> title="<?php echo encodeHtml($attr_title) ?>">- \ No newline at end of file diff --git a/themes/default/include/html/link/link-end.inc.php b/themes/default/include/html/link/link-end.inc.php @@ -1 +0,0 @@ -</a>- \ No newline at end of file