Beispiel #1
0
 public function getNext($name = null)
 {
     $children = $this->_parent->getChildren();
     $length = count($children);
     if ($this->_position == $length - 1) {
         return null;
     }
     if (is_null($name)) {
         return $this->_parent->getChild($this->_position + 1);
     }
     $name = $this->_getCleanName($name);
     for ($i = $this->_position + 1; $i < $length; $i++) {
         if ($children[$i] instanceof AeInterface_Xml_Element && $children[$i]->getName() == $name) {
             return $children[$i];
         }
     }
     return null;
 }
Beispiel #2
0
 /**
  * Convert string to value
  *
  * Convert passed string to a valid data structure. Used to parse strings
  * created with {@link AeXml_Node::write()} method.
  *
  * @param AeXml_Node $value value to parse
  *
  * @return mixed
  */
 protected function _stringToValue(AeInterface_Xml_Element $element)
 {
     $type = $element->getAttribute('type', 'array');
     if ($type == 'array') {
         $return = array();
         foreach ($element->getChildren() as $child) {
             $name = $child->getName();
             if ($name == 'key' && $child->hasAttribute('key-name')) {
                 $name = $child->getAttribute('key-name', $name);
                 $ntype = $child->getAttribute('key-type', 'string');
                 $name = $ntype == 'integer' ? (int) $name : $name;
             }
             $return[$name] = $this->_stringToValue($child);
         }
     } else {
         if ($type == 'object') {
             $value = $element->getData();
             $value = str_replace('&null;', chr(0), $value);
             $value = str_replace('&amp;', '&', $value);
             $return = unserialize($value);
         } else {
             $value = (string) $element->getData();
             $return = null;
             switch ($type) {
                 case 'boolean':
                     $return = $value == 'true' ? true : false;
                     break;
                 case 'integer':
                     $return = (int) $value;
                     break;
                 case 'float':
                     $return = (double) $value;
                     break;
                 case 'string':
                     $return = (string) $value;
                     break;
                 case 'null':
                     $return = null;
                     break;
             }
         }
     }
     return $return;
 }