当前位置: 首页>>代码示例>>PHP>>正文


PHP HtmlElement::addChild方法代码示例

本文整理汇总了PHP中HtmlElement::addChild方法的典型用法代码示例。如果您正苦于以下问题:PHP HtmlElement::addChild方法的具体用法?PHP HtmlElement::addChild怎么用?PHP HtmlElement::addChild使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HtmlElement的用法示例。


在下文中一共展示了HtmlElement::addChild方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 public function __construct($name, $options, $selectedValue = '', $type = self::TYPE_RADIO, $validator = null)
 {
     static::$instanceCount++;
     HtmlElement::__construct('div');
     $this->validator = $validator;
     $this->type = $type;
     $this->setAttribute('name', $name);
     $selectedValues = array();
     if ($type == self::TYPE_RADIO) {
         $selectedValues = array($selectedValue);
     } else {
         $selectedValues = explode(',', $selectedValue);
     }
     $i = 0;
     foreach ($options as $key => $value) {
         $optionId = 'data-element-group-' . static::$instanceCount . '-' . $i;
         $option = new HtmlElement('input');
         $option->setAttribute('type', $this->type);
         $option->setAttribute('name', $name);
         $option->setAttribute('id', $optionId);
         $option->setAttribute('value', $value);
         if (in_array($key, $selectedValues)) {
             $option->setAttribute('checked');
         }
         $label = new HtmlElement('label');
         $label->setAttribute('for', $optionId);
         $label->addChild(new TextElement($value));
         $this->addChild($option);
         $this->addChild($label);
         $i++;
     }
 }
开发者ID:Cloudrexx,项目名称:cloudrexx,代码行数:32,代码来源:DataElementGroup.class.php

示例2: addChild

 /**
  * Add children to first fieldset
  */
 public function addChild(HtmlElement $element, HtmlElement $reference = null, $before = false)
 {
     if ($element instanceof FieldsetElement) {
         parent::addChild($element, $reference, $before);
         return;
     }
     if (!count($this->getChildren())) {
         $this->addChild(new FieldsetElement());
     }
     current($this->getChildren())->addChild($element, $reference, $before);
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:14,代码来源:FormElement.class.php

示例3: tagShort

 /**
  * Shorten string if mor that max - and outputs span with original text in title
  * @param int max | max length
  * @container
  */
 protected function tagShort($attrs)
 {
     $max = intval($attrs->max);
     $string = trim($this->body());
     $orig = $string;
     if (strlen($string) > $max) {
         $string = substr($string, 0, $max - 3) . '...';
     }
     $span = new HtmlElement('span', array('title' => $orig));
     $span->addChild(new HtmlText($string));
     return $span;
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:17,代码来源:ValueTagLib.php

示例4: tagButton

 /**
  * Renders a button. All attributes not listed below will be forwarded to the actual html element
  * @param string elm | tag type - defaults to a
  * @param string class | CSS class to apply to button 
  * @param string event | event to trigger when clicked
  * @deprecated
  * @container
  */
 protected function tagButton($attrs, $view)
 {
     if (!$attrs->elm) {
         $attrs->elm = 'a';
     }
     if (!$attrs->class) {
         $attrs->class = '';
     }
     $class = $this->evt2css($attrs->event);
     $attrs->class = trim(trim(self::CSS_BTN . ' ' . $class) . ' ' . $attrs->class);
     $elmAttr = ArrayUtil::fromObject($attrs);
     unset($elmAttr['elm']);
     unset($elmAttr['event']);
     $elm = new HtmlElement($attrs->elm, $elmAttr);
     $elm->addChild(new HtmlText(trim($this->body())));
     return $elm;
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:25,代码来源:WidgetTagLib.php

示例5: tagForm

 /**
  * Render form tags
  * @param boolean binary | if set - renders a multipart form - else a url encoded form.
  * @param string controller | if set - sets the controller of the target url for this form
  * @param string action | if set - sets the action of the target url for this form
  * @param string parms | if set - sets the parameters of the target url for this form
  * @param array|object|json data | A map of data for this form - will be propegated to fields within this form.
  * @param string method | sets the HTTP method to used (post or get) - defaults to post
  * @param string url | sets the url of the form - only used if controller is not set
  * @param string id | sets the id on the form element
  * @param string class | sets the css class for the form element
  */
 protected function tagForm($attrs, $view)
 {
     if ($attrs->binary) {
         $attrs->enctype = 'multipart/form-data';
     } else {
         $attrs->enctype = 'application/x-www-form-urlencoded ';
     }
     if (!$attrs->controller && !$attrs->action && !$attrs->parms) {
         if (!$attrs->controller) {
             $attrs->controller = Pimple::instance()->getController();
             if (!$attrs->action) {
                 $attrs->action = Pimple::instance()->getAction();
             }
         }
         $attrs->url = Url::makeLink($attrs->controller, $attrs->action, $_SERVER['QUERY_STRING']);
     } else {
         if ($attrs->action && $attrs->controller) {
             $attrs->url = Url::makeLink($attrs->controller, $attrs->action, $attrs->parms);
         }
     }
     unset($attrs->binary);
     if ($attrs->data) {
         $this->formData = $this->toObject($attrs->data);
     } else {
         $this->formData = $view->data;
     }
     $attrs->method = strtolower($attrs->method ? $attrs->method : 'post');
     $this->formMethod = $attrs->method;
     $elm = new HtmlElement('form');
     $elm->setAttribute('method', $attrs->method);
     $elm->setAttribute('enctype', $attrs->enctype);
     $elm->setAttribute('action', $attrs->url);
     if ($attrs->id) {
         $elm->setAttribute('id', $attrs->id);
     }
     if ($attrs->class) {
         $elm->setAttribute('class', $attrs->class);
     }
     $elm->addChild(new HtmlText($this->body()));
     return $elm->toHtml();
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:53,代码来源:FormTagLib.php

示例6: tagLink

 /**
  * Renders a anchor with a properly formatted url based on the parameters
  * @param string controller | the controller name - defaults to 'index'
  * @param string action | the action - defaults to 'index'
  * @param object parms | Parameters to append as GET parms to the url - defaults to most attributes on tag
  */
 protected function tagLink($attrs, $view)
 {
     $linkAttrs = new stdClass();
     $tagAttrs = new stdClass();
     if ($attrs->parms) {
         //If parms argument is found restrict url to parms, controller and action attributes
         $linkAttrs = $this->toObject($attrs->parms);
         if ($attrs->controller) {
             $linkAttrs->controller = $attrs->controller;
         }
         if ($attrs->action) {
             $linkAttrs->action = $attrs->action;
         }
         $tagAttrs = $attrs;
         unset($tagAttrs->controller);
         unset($tagAttrs->action);
         unset($tagAttrs->parms);
     } else {
         //If parms argument not present - allow only "class","style" and "title" for tag - assume rest is for url
         $tagAttrs = new stdClass();
         if ($attrs->class) {
             $tagAttrs->class = $attrs->class;
         }
         if ($attrs->style) {
             $tagAttrs->style = $attrs->style;
         }
         if ($attrs->title) {
             $tagAttrs->title = $attrs->title;
         }
         if ($attrs->rel) {
             $tagAttrs->rel = $attrs->rel;
         }
         $linkAttrs = $attrs;
         unset($linkAttrs->class);
         unset($linkAttrs->style);
         unset($linkAttrs->title);
         unset($linkAttrs->rel);
     }
     $link = $this->url($linkAttrs, $this->body(), $view);
     if (!$this->body()) {
         $this->body($link);
     }
     $tagAttrs->href = $link;
     $a = new HtmlElement('a', $tagAttrs);
     $a->addChild(new HtmlText(trim($this->body())));
     return $a;
 }
开发者ID:hofmeister,项目名称:Pimple,代码行数:53,代码来源:BasicTagLib.php


注:本文中的HtmlElement::addChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。