Example #1
0
 function numeric($setToPrim = NULL, $setToAlt = NULL)
 {
     $setTo = is_null($setToPrim) ? $setToAlt : $setToPrim;
     if (!is_null($setTo)) {
         if (!is_null($this->xtext)) {
             return _MiniXMLError("MiniXMLElement::numeric() Can't set numeric for element with text.");
         } elseif (!is_numeric($setTo)) {
             return _MiniXMLError("MiniXMLElement::numeric() Must pass a NUMERIC value to set numeric for element.");
         }
         if (MINIXML_DEBUG > 0) {
             _MiniXMLLog("Setting numeric value of node to '{$setTo}'");
         }
         $this->xnumeric = $setTo;
     }
     return $this->xnumeric;
 }
Example #2
0
 function &parent(&$setParent)
 {
     if (!is_null($setParent)) {
         /* Parents can only be MiniXMLElement objects */
         if (!method_exists($setParent, 'MiniXMLTreeComponent')) {
             return _MiniXMLError("MiniXMLTreeComponent::parent(): Must pass an instance derived from " . "MiniXMLTreeComponent to set.");
         }
         $this->xparent = $setParent;
     }
     return $this->xparent;
 }
Example #3
0
 function fromArray(&$init, $params = NULL)
 {
     $this->init();
     if (!is_array($init)) {
         return _MiniXMLError("MiniXMLDoc::fromArray(): Must Pass an ARRAY to initialize from");
     }
     if (!is_array($params)) {
         $params = array();
     }
     if ($params["attributes"] && is_array($params["attributes"])) {
         $attribs = array();
         foreach ($params["attributes"] as $attribName => $value) {
             if (!(array_key_exists($attribName, $attribs) && is_array($attribs[$attribName]))) {
                 $attribs[$attribName] = array();
             }
             if (is_array($value)) {
                 foreach ($value as $v) {
                     if (array_key_exists($v, $attribs[$attribName])) {
                         $attribs[$attribName][$v]++;
                     } else {
                         $attribs[$attribName][$v] = 1;
                     }
                 }
             } else {
                 if (array_key_exists($value, $attribs[$attribName])) {
                     $attribs[$attribName][$value]++;
                 } else {
                     $attribs[$attribName][$value] = 1;
                 }
             }
         }
         // completely replace old attributes by our optimized array
         $params["attributes"] = $attribs;
     } else {
         $params["attributes"] = array();
     }
     foreach ($init as $keyname => $value) {
         $sub = $this->_fromArray_getExtractSub($value);
         $this->{$sub}($keyname, $value, $this->xxmlDoc, $params);
     }
     return $this->xxmlDoc->numChildren();
 }
 function &appendNode(&$node)
 {
     if (is_null($node)) {
         return _MiniXMLError("MiniXMLElement::appendNode() need to pass a non-NULL MiniXMLNode.");
     }
     if (!method_exists($node, 'MiniXMLNode')) {
         return _MiniXMLError("MiniXMLElement::appendNode() must pass a MiniXMLNode object to appendNode.");
     }
     if (MINIXML_AUTOSETPARENT) {
         if ($this->xparent == $node) {
             return _MiniXMLError("MiniXMLElement::appendnode() Tryng to append parent {$cname} as node of " . $this->xname);
         }
         $node->parent($this);
     }
     $idx = $this->xnumChildren++;
     $this->xchildren[$idx] = $node;
     return $this->xchildren[$idx];
 }