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


PHP Convert::raw2htmlid方法代码示例

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


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

示例1: generateFieldID

 /**
  * Generate the field ID value
  *
  * @param FormField
  *
  * @return string
  */
 public function generateFieldID($field)
 {
     if ($form = $field->getForm()) {
         return sprintf("%s_%s", $this->generateFormID($form), Convert::raw2htmlid($field->getName()));
     }
     return Convert::raw2htmlid($field->getName());
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:14,代码来源:FormTemplateHelper.php

示例2: __construct

 /**
  * @param string $name Identifier
  * @param string|Tab|TabSet $titleOrTab Natural language title of the tabset, or first tab.
  * If its left out, the class uses {@link FormField::name_to_label()} to produce a title
  * from the {@link $name} parameter.
  * @param Tab|TabSet ...$tabs All further parameters are inserted as children into the TabSet
  */
 public function __construct($name, $titleOrTab = null, $tabs = null)
 {
     if (!is_string($name)) {
         throw new InvalidArgumentException('Invalid string parameter for $name');
     }
     // Get following arguments
     $tabs = func_get_args();
     array_shift($tabs);
     // Detect title from second argument, if it is a string
     if ($titleOrTab && is_string($titleOrTab)) {
         $title = $titleOrTab;
         array_shift($tabs);
     } else {
         $title = static::name_to_label($name);
     }
     // Normalise children list
     if (count($tabs) === 1 && (is_array($tabs[0]) || $tabs[0] instanceof FieldList)) {
         $tabs = $tabs[0];
     }
     // Ensure tabs are assigned to this tabset
     if ($tabs) {
         foreach ($tabs as $tab) {
             if ($tab instanceof Tab || $tab instanceof TabSet) {
                 $tab->setTabSet($this);
             } else {
                 throw new InvalidArgumentException("TabSet can only contain instances of other Tab or Tabsets");
             }
         }
     }
     parent::__construct($tabs);
     // Assign name and title (not assigned by parent constructor)
     $this->setName($name);
     $this->setTitle($title);
     $this->setID(Convert::raw2htmlid($name));
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:42,代码来源:TabSet.php

示例3: testRaw2HtmlID

 /**
  * Tests {@link Convert::raw2htmlid()}
  */
 public function testRaw2HtmlID()
 {
     $val1 = 'test test 123';
     $this->assertEquals('test_test_123', Convert::raw2htmlid($val1));
     $val1 = 'test[test][123]';
     $this->assertEquals('test_test_123', Convert::raw2htmlid($val1));
     $val1 = '[test[[test]][123]]';
     $this->assertEquals('test_test_123', Convert::raw2htmlid($val1));
 }
开发者ID:congaaids,项目名称:silverstripe-framework,代码行数:12,代码来源:ConvertTest.php

示例4: getOptions

 /**
  * Gets the list of options to render in this formfield
  * 
  * @return ArrayList
  */
 public function getOptions()
 {
     $selectedValues = $this->getValueArray();
     $defaultItems = $this->getDefaultItems();
     // Generate list of options to display
     $odd = 0;
     $formID = $this->ID();
     $options = new ArrayList();
     foreach ($this->getSource() as $itemValue => $title) {
         $itemID = Convert::raw2htmlid("{$formID}_{$itemValue}");
         $odd = ($odd + 1) % 2;
         $extraClass = $odd ? 'odd' : 'even';
         $extraClass .= ' val' . preg_replace('/[^a-zA-Z0-9\\-\\_]/', '_', $itemValue);
         $itemChecked = in_array($itemValue, $selectedValues) || in_array($itemValue, $defaultItems);
         $itemDisabled = $this->isDisabled() || in_array($itemValue, $defaultItems);
         $options->push(new ArrayData(array('ID' => $itemID, 'Class' => $extraClass, 'Name' => "{$this->name}[{$itemValue}]", 'Value' => $itemValue, 'Title' => $title, 'isChecked' => $itemChecked, 'isDisabled' => $itemDisabled)));
     }
     $this->extend('updateGetOptions', $options);
     return $options;
 }
开发者ID:guttmann,项目名称:silverstripe-framework,代码行数:25,代码来源:CheckboxSetField.php

示例5: __construct

 /**
  * @uses FormField::name_to_label()
  *
  * @param string $name Identifier of the tab, without characters like dots or spaces
  * @param string|FormField $titleOrField Natural language title of the tabset, or first tab.
  * If its left out, the class uses {@link FormField::name_to_label()} to produce a title
  * from the {@link $name} parameter.
  * @param FormField ...$fields All following parameters are inserted as children to this tab
  */
 public function __construct($name, $titleOrField = null, $fields = null)
 {
     if (!is_string($name)) {
         throw new InvalidArgumentException('Invalid string parameter for $name');
     }
     // Get following arguments
     $fields = func_get_args();
     array_shift($fields);
     // Detect title from second argument, if it is a string
     if ($titleOrField && is_string($titleOrField)) {
         $title = $titleOrField;
         array_shift($fields);
     } else {
         $title = static::name_to_label($name);
     }
     // Remaining arguments are child fields
     parent::__construct($fields);
     // Assign name and title (not assigned by parent constructor)
     $this->setName($name);
     $this->setTitle($title);
     $this->setID(Convert::raw2htmlid($name));
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:31,代码来源:Tab.php

示例6: getOptionClass

 /**
  * Get extra classes for each item in the list
  *
  * @param string $value Value of this item
  * @param bool $odd If this item is odd numbered in the list
  * @return string
  */
 protected function getOptionClass($value, $odd)
 {
     $oddClass = $odd ? 'odd' : 'even';
     $valueClass = ' val' . Convert::raw2htmlid($value);
     return $oddClass . $valueClass;
 }
开发者ID:guttmann,项目名称:silverstripe-framework,代码行数:13,代码来源:OptionsetField.php


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