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


PHP Tag::setAttributes方法代码示例

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


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

示例1: setProgress

 /**
  * @param bool|int $progress
  */
 public function setProgress($progress)
 {
     $this->progress = $progress;
     if ($progress !== false) {
         $this->bar->setAttributes(['style' => 'width: ' . $this->progress . '%;']);
         $this->setAttributes(['aria-valuenow' => $this->progress]);
     } else {
         $this->removeAttributes(['aria-valuenow']);
     }
     $this->toggleClasses(['oo-ui-progressBarWidget-indeterminate'], $progress === false);
 }
开发者ID:oojs,项目名称:oojs-ui,代码行数:14,代码来源:ProgressBarWidget.php

示例2: setAccessKey

 /**
  * Set access key.
  *
  * @param string $accessKey Tag's access key, use empty string to remove
  * @return $this
  */
 public function setAccessKey($accessKey)
 {
     $accessKey = is_string($accessKey) && strlen($accessKey) ? $accessKey : null;
     if ($this->accessKey !== $accessKey) {
         if ($accessKey !== null) {
             $this->accessKeyed->setAttributes(['accesskey' => $accessKey]);
         } else {
             $this->accessKeyed->removeAttributes(['accesskey']);
         }
         $this->accessKey = $accessKey;
     }
     return $this;
 }
开发者ID:oojs,项目名称:oojs-ui,代码行数:19,代码来源:AccessKeyedElement.php

示例3: getInputElement

 protected function getInputElement($config)
 {
     $type = in_array($config['type'], array('button', 'submit', 'reset')) ? $config['type'] : 'button';
     $input = new Tag($config['useInputTag'] ? 'input' : 'button');
     $input->setAttributes(array('type' => $type));
     return $input;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:7,代码来源:ButtonInputWidget.php

示例4: setOptions

 /**
  * Set the options available for this input.
  *
  * @param array[] $options Array of menu options in the format
  *   `array( 'data' => …, 'label' => … )`
  * @chainable
  */
 public function setOptions($options)
 {
     $value = $this->getValue();
     $isValueAvailable = false;
     $this->options = array();
     // Rebuild the dropdown menu
     $this->input->clearContent();
     foreach ($options as $opt) {
         $optValue = $this->cleanUpValue($opt['data']);
         $option = new Tag('option');
         $option->setAttributes(array('value' => $optValue));
         $option->appendContent(isset($opt['label']) ? $opt['label'] : $optValue);
         if ($value === $optValue) {
             $isValueAvailable = true;
         }
         $this->options[] = $option;
         $this->input->appendContent($option);
     }
     // Restore the previous value, or reset to something sensible
     if ($isValueAvailable) {
         // Previous value is still available
         $this->setValue($value);
     } else {
         // No longer valid, reset
         if (count($options)) {
             $this->setValue($options[0]['data']);
         }
     }
     return $this;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:37,代码来源:DropdownInputWidget.php

示例5: _test_should_store_zero_strings_as_intergers

 public function _test_should_store_zero_strings_as_intergers()
 {
     $Tag = new Tag(array('name' => 'Ticket #21'));
     $this->assertTrue($Tag->save());
     $this->assertEqual($Tag->get('score'), 100);
     $Tag->setAttributes(array('score' => '0'));
     $this->assertTrue($Tag->save());
     $Tag = $Tag->find($Tag->id);
     $this->assertIdentical($Tag->get('score'), 0);
 }
开发者ID:bermi,项目名称:akelos,代码行数:10,代码来源:type_casting.php

示例6: testCreate

 public function testCreate()
 {
     $tag = new Tag();
     $tag->setAttributes(array('name' => 'Apple', 'category' => 1));
     $this->assertTrue($tag->save());
     $tag2 = Tag::model()->findByPk($tag->id);
     $this->assertNotNull($tag2);
     $this->assertEquals($tag->name, $tag2->name);
     $this->assertEquals($tag->category, $tag2->category);
     $this->assertEquals(1, $tag2->frequency);
     $this->assertTrue(time() - $tag2->create_time <= 1);
 }
开发者ID:reedboat,项目名称:TagProject,代码行数:12,代码来源:TagTest.php

示例7: setDisabled

 public function setDisabled($state)
 {
     parent::setDisabled($state);
     if (isset($this->input)) {
         if ($this->isDisabled()) {
             $this->input->setAttributes(['disabled' => 'disabled']);
         } else {
             $this->input->removeAttributes(['disabled']);
         }
     }
     return $this;
 }
开发者ID:oojs,项目名称:oojs-ui,代码行数:12,代码来源:InputWidget.php

示例8: initializeButtonElement

 /**
  * @param array $config Configuration options
  * @param boolean $config['framed'] Render button with a frame (default: true)
  */
 public function initializeButtonElement(array $config = [])
 {
     // Properties
     if (!$this instanceof Element) {
         throw new Exception("ButtonElement trait can only be used on Element instances");
     }
     $target = isset($config['button']) ? $config['button'] : new Tag('a');
     $this->button = $target;
     // Initialization
     $this->addClasses(['oo-ui-buttonElement']);
     $this->button->addClasses(['oo-ui-buttonElement-button']);
     $this->toggleFramed(isset($config['framed']) ? $config['framed'] : true);
     // Add `role="button"` on `<a>` elements, where it's needed
     if (strtolower($this->button->getTag()) === 'a') {
         $this->button->setAttributes(['role' => 'button']);
     }
     $this->registerConfigCallback(function (&$config) {
         if ($this->framed !== true) {
             $config['framed'] = $this->framed;
         }
     });
 }
开发者ID:oojs,项目名称:oojs-ui,代码行数:26,代码来源:ButtonElement.php

示例9: testAttributes

 public function testAttributes()
 {
     $tag = new Tag('a');
     $this->assertNull($tag->getAttribute('href'));
     $this->assertNull($tag->href);
     $tag->href = "#";
     $this->assertSame('#', $tag->href);
     $this->assertSame('#', $tag->getAttribute('href'));
     $this->assertSame(array('href' => '#'), $tag->getAttributes());
     $tag->setAttribute('href', 'javascript:void(0)');
     $this->assertSame('javascript:void(0)', $tag->href);
     $this->assertSame('javascript:void(0)', $tag->getAttribute('href'));
     $this->assertSame(array('href' => 'javascript:void(0)'), $tag->getAttributes());
     $tag->setAttributes(array('href' => ''));
     $this->assertSame('', $tag->href);
     $this->assertSame('', $tag->getAttribute('href'));
     $this->assertSame(array('href' => ''), $tag->getAttributes());
     $tag->addClass('link');
     $this->assertSame('link', $tag->class);
     $tag->addClass('link-external');
     $this->assertSame('link link-external', $tag->class);
     $tag->removeClass('link');
     $this->assertSame('link-external', $tag->class);
 }
开发者ID:xmlscript,项目名称:php-html-element,代码行数:24,代码来源:TagTest.php

示例10: getInputElement

 protected function getInputElement($config)
 {
     $input = new Tag('input');
     $input->setAttributes(array('type' => 'radio'));
     return $input;
 }
开发者ID:Sedles,项目名称:WikiToLearn,代码行数:6,代码来源:RadioInputWidget.php

示例11: getInputElement

 protected function getInputElement($config)
 {
     if (isset($config['multiline']) && $config['multiline']) {
         return new Tag('textarea');
     } else {
         $type = in_array($config['type'], array('text', 'password', 'search', 'email', 'url')) ? $config['type'] : 'text';
         $input = new Tag('input');
         $input->setAttributes(array('type' => $type));
         return $input;
     }
 }
开发者ID:prtksxna,项目名称:uw-prototype,代码行数:11,代码来源:TextInputWidget.php

示例12: getInputElement

 protected function getInputElement($config)
 {
     $input = new Tag($config['useInputTag'] ? 'input' : 'button');
     $input->setAttributes(array('type' => $config['type']));
     return $input;
 }
开发者ID:Sedles,项目名称:WikiToLearn,代码行数:6,代码来源:ButtonInputWidget.php

示例13: getInputElement

 protected function getInputElement($config)
 {
     if (isset($config['multiline']) && $config['multiline']) {
         return new Tag('textarea');
     } else {
         $input = new Tag('input');
         $input->setAttributes(array('type' => $this->getSaneType($config)));
         return $input;
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:10,代码来源:TextInputWidget.php


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