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


PHP Element::getName方法代码示例

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


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

示例1: addElement

 /**
  * Add an element
  * @param \Foundation\Form\Element
  */
 public function addElement(Element $element)
 {
     if (array_key_exists($element->getName(), $this->form->getElements())) {
         $message = 'An element with the name ' . $element->getName() . ' already exists in this form';
         throw new \Foundation\Exception($message);
     }
     $this->elements[$element->getName()] = $element;
 }
开发者ID:jazzee,项目名称:foundation,代码行数:12,代码来源:Field.php

示例2: build

 /**
  * @param Element $element
  * @param \DOMNode $node
  */
 protected function build(Element $element, \DOMNode $node)
 {
     $dom = $this->getEngine();
     if ($element->getValue() instanceof Collection) {
         $newElement = $dom->createElement($element->getName());
         foreach ($element->getValue()->getElements() as $child) {
             $this->build($child, $newElement);
         }
     } else {
         $newElement = $dom->createElement($element->getName(), $element->getValue()->getValue());
     }
     foreach ($element->getAttributes()->getValues() as $attr => $value) {
         $newElement->setAttribute($attr, $value);
     }
     $node->appendChild($newElement);
 }
开发者ID:boyhagemann,项目名称:html,代码行数:20,代码来源:Renderer.php

示例3: testGetName

 /**
  * @covers Xoops\Form\Element::getName
  * @todo   Implement testGetName().
  */
 public function testGetName()
 {
     $name = 'name';
     $this->object->setName($name);
     $value = $this->object->getName();
     $this->assertSame($name, $value);
 }
开发者ID:RanLee,项目名称:XoopsCore,代码行数:11,代码来源:ElementTest.php

示例4: testConstructorWithNameOnly

 /** Tests for {@link Element::__construct}. */
 public function testConstructorWithNameOnly()
 {
     $e = new Element('html');
     $this->assertSame('html', $e->getName(), 'Element name created wrong.');
     $this->assertTrue(is_array($e->getAttributes()), 'Default Element attributes not created as array.');
     $this->assertSame(0, count($e->getAttributes()), 'Default Element attributes not created as empty array.');
     $this->assertTrue(is_array($e->getChildren()), 'Default Element children not created as array.');
     $this->assertSame(0, count($e->getChildren()), 'Element Element children not created as empty array.');
 }
开发者ID:kwebble,项目名称:hadroton,代码行数:10,代码来源:ElementTest.php

示例5: formatTagPrefix

 /**
  * 開始タグまたは空要素タグの共通部分を書式化します.
  * @param  Element $element 書式化対象の要素
  * @return string           "<elementName ... "
  */
 protected final function formatTagPrefix(Element $element)
 {
     $tag = "<";
     $tag .= $element->getName();
     foreach ($element->getAttributes() as $name => $value) {
         $tag .= " ";
         $tag .= $value === null ? $this->formatBooleanAttribute($name) : $this->formatAttribute($name, $value);
     }
     return $tag;
 }
开发者ID:trashtoy,项目名称:peach2,代码行数:15,代码来源:AbstractRenderer.php

示例6: createHtml

 /** Returns a HTML representation of an element and its child nodes.
  * @param   Element                $element            the element to generate as HTML.
  * @return  string                                     the HTML. */
 public function createHtml($element)
 {
     $data = array_reduce($element->getChildren(), function ($carry, $child) {
         return $carry . $child->toHtml();
     }, '');
     $allAttributes = [];
     foreach ($element->getAttributes() as $name => $value) {
         $allAttributes[] = sprintf(static::ATTRIBUTE_TEMPLATE, htmlspecialchars($name, ENT_COMPAT), htmlspecialchars($value, ENT_COMPAT));
     }
     if (0 === count($allAttributes)) {
         $attributes = '';
     } else {
         $attributes = ' ' . implode(' ', $allAttributes);
     }
     if (in_array($element->getName(), static::VOID_ELEMENTS)) {
         $html = sprintf(static::VOID_ELEMENT_TEMPLATE, $element->getName(), $attributes);
     } else {
         $html = sprintf(static::ELEMENT_TEMPLATE, $element->getName(), $attributes, $data);
     }
     return $html;
 }
开发者ID:kwebble,项目名称:hadroton,代码行数:24,代码来源:HtmlGenerator.php

示例7: startElement

 public function startElement(Element $element)
 {
     $this->xmlWriter->startElement($element->getName());
     $attr = $element->getAttr();
     foreach ($attr as $k => $v) {
         $this->xmlWriter->startAttribute($k);
         $this->xmlWriter->text($v);
         $this->xmlWriter->endAttribute();
     }
     if ('' !== $element->getText()) {
         $this->xmlWriter->text($element->getText());
     }
 }
开发者ID:maximfisyuk,项目名称:price-writer,代码行数:13,代码来源:ElementWriter.php

示例8: __construct

 /**
  * Construct new validation object
  *
  * @internal
  * @param Element $objField
  * @param array $arrValidationRules
  * @param array $arrErrorHandlers
  */
 public function __construct(Element $objField, array $arrValidationRules = array(), array $arrErrorHandlers = array())
 {
     foreach ($arrValidationRules as $key => $value) {
         $property = strtolower("__" . $key);
         if (property_exists($this, $property)) {
             $this->{$property} = $value;
         }
     }
     foreach ($arrErrorHandlers as $key => $value) {
         $property = strtolower("__" . $key . "error");
         if (property_exists($this, $property)) {
             $this->{$property} = $value;
         }
     }
     $this->__field = $objField;
     $this->__type = $objField->getType();
     $this->__fieldname = str_replace("[]", "", $objField->getName());
     $this->__fieldhint = $objField->getHint();
     // Store the default required state in a seperate property.
     // This way, we're able to reset back to default settings at any given time.
     $this->__defaultRequired = $this->__required;
 }
开发者ID:BTHUNTERCN,项目名称:validformbuilder,代码行数:30,代码来源:FieldValidator.php

示例9: fieldAsHtml

 /**
  * Generates HTML output for the given field object and its child elements
  *
  * @internal
  * @param Element $objField The Element class-based object to parse
  * @param boolean $hideEmpty Set to true to hide empty field values from the overview. Defaults to false.
  * @param integer $intDynamicCount The dynamic counter for the current Element being parsed
  * @return string Generated HTML
  */
 private function fieldAsHtml($objField, $hideEmpty = false, $intDynamicCount = 0)
 {
     $strReturn = "";
     $strFieldName = $objField->getName();
     $strLabel = $objField->getShortLabel();
     // Passing 'true' gets the short label if available.
     $varValue = $intDynamicCount > 0 ? $objField->getValue($intDynamicCount) : $objField->getValue();
     $strValue = is_array($varValue) ? implode(", ", $varValue) : $varValue;
     if (!empty($strValue) && $hideEmpty || !$hideEmpty && !is_null($strValue)) {
         if (get_class($objField) == "ValidFormBuilder\\Hidden" && $objField->isDynamicCounter()) {
             return $strReturn;
         } else {
             switch ($objField->getType()) {
                 case static::VFORM_BOOLEAN:
                     $strValue = $strValue == 1 ? "yes" : "no";
                     break;
             }
             if (empty($strLabel) && empty($strValue)) {
                 // *** Skip the field.
             } else {
                 $strValue = nl2br($strValue);
                 $strValue = htmlspecialchars($strValue, ENT_QUOTES);
                 $strReturn .= "<tr class=\"vf__field_value\">";
                 $strReturn .= "<td valign=\"top\" style=\"padding-right: 20px\" class=\"vf__field\">" . ($strReturn .= $strLabel . ($strReturn .= "</td>" . ($strReturn .= "<td valign=\"top\" class=\"vf__value\">" . ($strReturn .= "<strong>" . $strValue . "</strong>" . ($strReturn .= "</td>\n")))));
                 $strReturn .= "</tr>";
             }
         }
     }
     return $strReturn;
 }
开发者ID:SLivio,项目名称:validformbuilder,代码行数:39,代码来源:ValidForm.php

示例10: addElement

 /**
  * Add an element to the array of elements we will be validating. Use the elements name as the array key for access
  * @param  $element
  * @return \fieldset 
  */
 public function addElement($element)
 {
     if (!$element instanceof ElementInterface) {
         if (!is_array($element)) {
             throw new \Exception('Element must be an array or interface ElementInterface');
         }
         $element = new Element($this->formbuilder, $element);
     }
     $this->_elements[$element->getAttribute('key') ?: $element->getName()] = $element;
     return $this;
 }
开发者ID:joegreen0991,项目名称:laraform,代码行数:16,代码来源:Fieldset.php

示例11: radio

 /**
  * Radio element type
  * @param Element $element
  * @param $fieldHtml
  * @throws \Exception
  */
 protected static function radio(Element &$element, &$fieldHtml)
 {
     $name = $element->getName();
     $id = $element->getId();
     $value = $element->getValue();
     if ($element->getType() == self::TYPE_MULTICHECKBOX && !is_array($value)) {
         $value = array();
     }
     $options = $element->getProperties('options');
     if (!is_array($options)) {
         throw new \Exception("Options for field type '{$element->getType()}' must be given as array.");
     }
     //classes
     $class = $element->getProperties('class');
     if (!is_array($class)) {
         $class = array();
     }
     $attributes = $element->getProperties('attributes');
     $extraAttributes = '';
     if (is_array($attributes)) {
         foreach ($attributes as $attr => $val) {
             if (is_string($attr)) {
                 $extraAttributes .= sprintf('%s="%s" ', $attr, $val);
             } else {
                 $extraAttributes .= sprintf('%s ', $val);
             }
         }
     }
     foreach ($options as $option => $lbl) {
         $optionAttributes = $extraAttributes;
         //does this option have its own settings?
         if (is_array($lbl)) {
             $optionSettings = $lbl;
             if (!isset($optionSettings['label'])) {
                 throw new \Exception("A label has not been set for one of the arrayed options for field - " . $element->getName(true));
             }
             $lbl = $optionSettings['label'];
             if (isset($optionSettings['attributes']) && is_array($optionSettings['attributes'])) {
                 foreach ($optionSettings['attributes'] as $attr => $val) {
                     if (is_string($attr)) {
                         $optionAttributes .= sprintf('%s="%s" ', $attr, $val);
                     } else {
                         $optionAttributes .= sprintf('%s ', $val);
                     }
                 }
             }
         }
         $labelHtml = self::$templates['label'];
         $labelHtml = str_replace('{{id}}', "{$id}_{$option}", $labelHtml);
         $labelHtml = str_replace('{{text}}', $lbl, $labelHtml);
         if ($element->getType() == self::TYPE_RADIO) {
             $field = self::$templates[self::TYPE_RADIO];
             $field = str_replace('{{name}}', $name, $field);
             $field = str_replace('{{value}}', 'value="' . $option . '" ' . ($option == $value ? ' checked="checked"' : ''), $field);
         } else {
             if ($element->getType() == self::TYPE_MULTICHECKBOX) {
                 $field = self::$templates[self::TYPE_CHECKBOX];
                 $field = str_replace('{{name}}', "{$name}[]", $field);
                 $field = str_replace('{{value}}', 'value="' . $option . '" ' . (in_array($option, $value) ? ' checked="checked"' : ''), $field);
             }
         }
         $field = str_replace('{{id}}', "{$id}_{$option}", $field);
         $field = str_replace('{{class}}', implode(' ', $class), $field);
         $field = str_replace('{{attributes}}', $optionAttributes, $field);
         $field .= ' ' . $labelHtml;
         $options[$option] = "<div>{$field}</div>";
     }
     $fieldHtml = '<div>' . implode('', $options) . '</div>';
 }
开发者ID:mncedim,项目名称:htmlform,代码行数:75,代码来源:Element.php

示例12: parseBody

 public function parseBody(Element $node)
 {
     $nodeName = $node->getName();
     do {
         if ($this->current() != "<" || $nodeName == "script" && !$this->equal("</script>")) {
             $text = "";
             while ($this->current() != "<" || $nodeName == "script" && !$this->equal("</script>")) {
                 $text .= $this->current();
                 $this->next();
             }
             if (trim($text)) {
                 $textNode = new Text($text);
                 $node->addChild($textNode);
             }
         } elseif ($this->current() == "<" && $this->getNext() != "/") {
             $childNode = $this->parseNode();
             $node->addChild($childNode);
         } else {
             $this->next(2);
             $endName = $this->parseName();
             if ($endName != $nodeName) {
                 echo "unexpected end of '{$endName}', {$nodeName} expected at {$this->ccline}:{$this->ccpos}\n";
                 $this->back(strlen("</{$endName}"));
             } else {
                 $this->skipWhiteSpaces();
                 $this->next();
             }
             break;
         }
     } while (true);
 }
开发者ID:mipxtx,项目名称:htmlparser,代码行数:31,代码来源:StringParser.php


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