本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
示例5: getValue
public function getValue()
{
$value = parent::getValue();
if ($value == $this->m_Hint) {
$this->m_Value = null;
return null;
}
return $value;
}
示例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;
}
示例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;
}
示例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>';
}
示例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'];
}