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


PHP Element::getValue方法代码示例

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


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

示例1: render

 private function render(\DOMDocument $doc, Element $element, $parent = null)
 {
     if ($element instanceof \tarcisio\svg\SVG) {
         $svgs = $doc->getElementsByTagName('svg');
         $svg = $svgs->item(0);
         $svg->setAttribute('width', $element->width);
         $svg->setAttribute('height', $element->height);
         $svg->setAttribute('viewBox', "0 0 {$element->width} {$element->height}");
         $gs = $doc->getElementsByTagName('g');
         $g = $gs->item(0);
         foreach ($element->getChildren() as $ch) {
             $this->render($doc, $ch, $g);
         }
         return $doc;
     }
     if (!is_null($element->getTitle())) {
         $element->appendChild(new Title('', $element->getTitle()));
     }
     $e = $doc->createElement($element->getElementName());
     $parent->appendChild($e);
     foreach ($element->getAttributes() as $k => $v) {
         if (!is_null($v)) {
             $e->setAttribute($k, $v);
         }
     }
     if (!is_null($element->getValue())) {
         $e->nodeValue = $element->getValue();
     }
     foreach ($element->getChildren() as $ch) {
         $this->render($doc, $ch, $e);
     }
     return $doc;
 }
开发者ID:tarcisio,项目名称:svg,代码行数:33,代码来源:Builder.php

示例2: isValid

 /**
  * @param mixed  $value
  * @param string $message
  * @return boolean
  */
 public function isValid($value, &$messages = array())
 {
     if ($value != $this->compare->getValue()) {
         $messages[] = $this->getErrorMessage(self::ERR_NOT_EQUAL);
         return false;
     }
     return true;
 }
开发者ID:klawd-prime,项目名称:lean,代码行数:13,代码来源:validator.php

示例3: testGetValue

 /**
  * @covers Xoops\Form\Element::getValue
  */
 public function testGetValue()
 {
     $name = 'name';
     $this->object->setValue($name);
     $value = $this->object->getValue();
     $this->assertSame($name, $value);
     $names = array('name1', 'name2');
     $this->object->setValue($names);
     $value = $this->object->getValue();
     $tmp = $names;
     array_unshift($tmp, $name);
     $this->assertSame($tmp, $value);
 }
开发者ID:RanLee,项目名称:XoopsCore,代码行数:16,代码来源:ElementTest.php

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

示例5: getValue

 public function getValue()
 {
     $value = parent::getValue();
     if ($value == $this->m_Hint) {
         $this->m_Value = null;
         return null;
     }
     return $value;
 }
开发者ID:Why-Not-Sky,项目名称:cubi-ng,代码行数:9,代码来源:InputElement.php

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

示例7: getValue

 /**
  * Get checkbox value
  *
  * See {@link \ValidFormBuilder\Element::getValue()}
  *
  * @internal
  * @see \ValidFormBuilder\Element::getValue()
  */
 public function getValue($intDynamicPosition = 0)
 {
     $varValue = parent::getValue($intDynamicPosition);
     return strlen($varValue) > 0 && $varValue !== 0 ? true : false;
 }
开发者ID:BTHUNTERCN,项目名称:validformbuilder,代码行数:13,代码来源:Checkbox.php

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

示例9: element

 /**
  * Render an element
  *
  * @param Element  $element  Form element
  *
  * @return string
  */
 public static function element(Element $element)
 {
     $meta = $element->getMeta();
     $html = $element instanceof Select ? self::options($element->getOptions(), array_flip((array) $element->getValue())) : $meta['html'];
     return $meta['before'] . self::tag($element->getTag(), $element->getAttributes(), $html) . $meta['after'];
 }
开发者ID:mrjulio,项目名称:spartan-php,代码行数:13,代码来源:Render.php


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