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


PHP Element::getProperties方法代码示例

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


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

示例1: encode

 private function encode(Element $element)
 {
     $chromosomeLength = count($element->getProperties());
     $this->elementId = $element->getId();
     $this->elementName = $element->getCssTag();
     $newChromosome = new SplFixedArray($chromosomeLength);
     $chromosomeIndex = 0;
     foreach ($element->getProperties() as $property) {
         $newChromosome[$chromosomeIndex] = $property->getRandomValue();
         $chromosomeIndex++;
     }
     return $newChromosome;
 }
开发者ID:alexspit,项目名称:IGA_Prototype,代码行数:13,代码来源:Individual.php

示例2: decode

 function decode($id, Individual $individual, Element $element)
 {
     $cssCode = "{$element->getCssTag()}#individual{$id} {" . PHP_EOL;
     $chromosome = $individual->getChromosome()->toArray();
     $geneIndex = 0;
     foreach ($element->getProperties() as $property) {
         if ($property->getCssName() == "font-family") {
             $cssCode .= "{$property->getCssName()} : '{$property->getValue($chromosome[$geneIndex])}', serif; ";
         } else {
             $cssCode .= "{$property->getCssName()} : {$property->getValue($chromosome[$geneIndex])}; ";
         }
         $geneIndex++;
     }
     $cssCode .= "}";
     return $cssCode;
 }
开发者ID:alexspit,项目名称:IGA_Prototype,代码行数:16,代码来源:GeneticAlgorithm.php

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


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