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


PHP HtmlElement::setAttribute方法代码示例

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


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

示例1: smarty_block_menuItem

/**
 * Smarty block plugin, for generating page menu item
 * This block must always be called in pageMenu block context
 *
 * @param array $params
 * @param Smarty $smarty
 * @param $repeat
 *
 * <code>
 *	{pageMenu id="menu"}
 *		{menuItem}
 *			{menuCaption}Click Me{/menuCaption}
 *			{menuAction}http://click.me.com{/menuAction} 
 *		{/menuItem}
 *		{menuItem}
 *			{menuCaption}Another menu item{/menuCaption}
 *			{pageAction}alert('Somebody clicked on me too!'){/menuAction} 
 *		{/menuItem}
 *  {/pageMenu}
 * </code>
 *
 * @package application.helper.smarty
 * @author Integry Systems
 */
function smarty_block_menuItem($params, $content, LiveCartSmarty $smarty, &$repeat)
{
    if ($repeat) {
        $smarty->clear_assign('menuCaption');
        $smarty->clear_assign('menuAction');
        $smarty->clear_assign('menuPageAction');
    } else {
        $item = new HtmlElement('a');
        if ($smarty->get_template_vars('menuAction')) {
            $href = $smarty->get_template_vars('menuAction');
        } else {
            if ($smarty->get_template_vars('menuPageAction')) {
                $onClick = $smarty->get_template_vars('menuPageAction');
                $href = '#';
                $item->setAttribute('onClick', $onClick . '; return false;');
            }
        }
        $item->setAttribute('href', $href);
        // EXPERIMENTAL - set access key for menu item
        $caption = $smarty->get_template_vars('menuCaption');
        if (FALSE != strpos($caption, '&&')) {
            $p = strpos($caption, '&&');
            $accessKey = substr($caption, $p + 2, 1);
            $item->setAttribute('accessKey', $accessKey);
            $caption = substr($caption, 0, $p + 3) . '</span>' . substr($caption, $p + 3);
            $caption = substr($caption, 0, $p) . '<span class="accessKey">' . substr($caption, $p + 2);
        }
        $item->setContent($caption);
        $smarty->append('pageMenuItems', $item->render());
    }
}
开发者ID:saiber,项目名称:www,代码行数:55,代码来源:block.menuItem.php

示例2: smarty_block_pageMenu

/**
 * Smarty block plugin, for generating page menus
 *
 * @param array $params
 * @param Smarty $smarty
 * @param $repeat
 *
 * <code>
 *	{pageMenu id="menu"}
 *		{menuItem}
 *			{menuCaption}Click Me{/menuCaption}
 *			{menuAction}http://click.me.com{/menuAction} 
 *		{/menuItem}
 *		{menuItem}
 *			{menuCaption}Another menu item{/menuCaption}
 *			{pageAction}alert('Somebody clicked on me too!'){/menuAction}
 *		{/menuItem}
 *  {/pageMenu}
 * </code>
 *
 * @return string Menu HTML code
 * @package application.helper.smarty
 * @author Integry Systems
 */
function smarty_block_pageMenu($params, $content, LiveCartSmarty $smarty, &$repeat)
{
    if ($repeat) {
        $smarty->clear_assign('pageMenuItems');
    } else {
        $items = $smarty->get_template_vars('pageMenuItems');
        $menuDiv = new HtmlElement('div');
        $menuDiv->setAttribute('id', $params['id']);
        $menuDiv->setAttribute('tabIndex', 1);
        $menuDiv->setContent(implode(' | ', $items));
        return $menuDiv->render();
    }
}
开发者ID:saiber,项目名称:www,代码行数:37,代码来源:block.pageMenu.php

示例3: __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

示例4: setLabel

 function setLabel($label_text, $attributes = array())
 {
     $label = new HtmlElement('label', null, true);
     $label->setAttribute('class', 'phaxsi_label');
     $label->setAttributes($attributes);
     $label->innerHTML = $label_text;
     $this->label = $label;
 }
开发者ID:RNKushwaha022,项目名称:orange-php,代码行数:8,代码来源:textlist.input.php

示例5: getData

 public function getData()
 {
     $listHtml = array('<ul>');
     $li = new HtmlElement('li');
     foreach ($this->content as $key => $value) {
         $li->setAttribute('id', $key);
         $li->setContent($value);
         $listHtml[] = $li->render();
     }
     $listHtml[] = '</ul>';
     return implode("\n", $listHtml);
 }
开发者ID:saiber,项目名称:www,代码行数:12,代码来源:AutoCompleteResponse.php

示例6: 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

示例7: render

 public function render()
 {
     global $_CORELANG;
     // if no child with name input and type submit is present, add one
     $hasSubmit = false;
     foreach ($this->getChildren() as $child) {
         if ($child->getName() == 'input' && $child->getAttribute('type') == 'submit') {
             $hasSubmit = true;
             break;
         }
     }
     if (!$hasSubmit && $this->addButtons) {
         $submitDiv = new FieldsetElement();
         $submitDiv->setAttribute('class', 'actions');
         $submit = new HtmlElement('input');
         $submit->setAttribute('type', 'submit');
         $submit->setAttribute('value', $_CORELANG['TXT_SAVE']);
         $submitDiv->addChild($submit);
         if (!empty($this->cancelUrl)) {
             $cancel = new HtmlElement('input');
             $cancel->setAttribute('type', 'button');
             $cancel->setAttribute('value', $_CORELANG['TXT_CANCEL']);
             $cancel->setAttribute('onclick', 'location.href="' . $this->cancelUrl . '&csrf=' . \Cx\Core\Csrf\Controller\Csrf::code() . '"');
             $submitDiv->addChild($cancel);
         }
         $this->addChild($submitDiv);
     }
     return parent::render();
 }
开发者ID:Niggu,项目名称:cloudrexx,代码行数:29,代码来源:FormElement.class.php


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