Example #1
0
 /**
  * Constructor
  *
  * Attempts to load the correct layout xml file
  *
  * @param string $name
  * @return object
  */
 public function __construct($name = null)
 {
     if (pathinfo($name, PATHINFO_EXTENSION)) {
         $this->path = $name;
         $this->name = pathinfo($name, PATHINFO_FILENAME);
     } else {
         $this->path = $this->_zula->getDir('config') . '/layouts/' . $name . '.xml';
         $this->name = $name;
     }
     if (Registry::has('sql')) {
         // Find the regex for this layout
         $pdoSt = $this->_sql->prepare('SELECT regex FROM {PREFIX}layouts WHERE name = ?');
         $pdoSt->execute(array($name));
         if ($regex = $pdoSt->fetchColumn()) {
             $this->regex = $regex;
         }
         $pdoSt->closeCursor();
     }
     // Load the DomDocument (or create if needed)
     $this->dom = new DomDocument('1.0', 'UTF-8');
     $this->dom->preserveWhiteSpace = false;
     $this->dom->formatOutput = true;
     if (is_file($this->path)) {
         $this->dom->load($this->path);
     } else {
         $this->dom->appendChild($this->dom->createElement('controllers'));
     }
 }
Example #2
0
 /**
  * Convert object to XML.
  * 
  * @param object $doc DOMDocument
  * @param object $parent DOMElement
  * @param string $nodeName name of the node you want to convert to
  * @param array $arrayToConvert array (or 2d array) you are trying to convert
  *
  * Adds one or more properly formatted xml nodes to the parent
  */
 public function appendChildren($doc, $parent, $nodeName, $arrayToConvert)
 {
     if (array_key_exists($nodeName, $arrayToConvert)) {
         //one object was sent.
         $elem = $doc->createElement($nodeName, $arrayToConvert[$nodeName]);
         $parent->appendChild($elem);
         foreach ($arrayToConvert as $key => $val) {
             if ($key != $nodeName) {
                 $attrName = $doc->createAttribute($key);
                 $elem->appendChild($attrName);
                 $attrVal = $doc->createTextNode($val);
                 $attrName->appendChild($attrVal);
             }
         }
     } else {
         //array of objects was sent
         foreach ($arrayToConvert as $key => $val) {
             $elem = $doc->createElement($nodeName, $val[$nodeName]);
             $parent->appendChild($elem);
             foreach ($val as $attrName => $attrVal) {
                 if ($attrName != $nodeName) {
                     $attribute = $doc->createAttribute($attrName);
                     $elem->appendChild($attribute);
                     $attributevalue = $doc->createTextNode($attrVal);
                     $attribute->appendChild($attributevalue);
                 }
             }
         }
     }
 }
Example #3
0
 /**
  * create new model
  *
  * @param    array
  * @param    object
  */
 public function __construct($node, $session = null)
 {
     $this->dom = new DOMDocument();
     $ebay = new DOMElement('eBay');
     $ebay = $this->dom->appendChild($ebay);
     $pf = new DOMElement('ProductFinders');
     $pf = $ebay->appendChild($pf);
     $newNode = $this->dom->importNode($node, true);
     $pf->appendChild($newNode);
 }
Example #4
0
 /**
  * Converts the place to properly formatted XML.
  * 
  * @param object $doc DOMDocument object
  * @param object $root DOMDocument root
  */
 public function toXML($doc, $root)
 {
     $place = $doc->createElement('place');
     if ($this->point != null) {
         $place->appendChild($doc->createElement('point', $this->point));
     }
     if ($this->elev != null) {
         $place->appendChild($doc->createElement('elev', $this->elev));
     }
     if ($this->floor != null) {
         $place->appendChild($doc->createElement('floor', $this->floor));
     }
     if ($this->featuretypetag != null) {
         $place->appendChild($doc->createElement('featuretypetag', $this->featuretypetag));
     }
     if ($this->featurename != null) {
         $place->appendChild($doc->createElement('featurename', $this->featurename));
     }
     if ($this->relationshiptag != null) {
         $place->appendChild($doc->createElement('relationshiptag', $this->relationshiptag));
     }
     if ($place->hasChildNodes()) {
         $root->appendChild($place);
     }
 }
Example #5
0
 /**
  * Adding the Items to the RSS Feed.
  *
  * @access public
  * @param array $aItems
  * @return object this
  */
 public function addItem($aItems)
 {
     // Create an item
     $oItem = $this->createElement('item');
     foreach ($aItems as $sElement => $sValue) {
         switch ($sElement) {
             // Create the sub elements here
             case 'image':
             case 'skipHour':
             case 'skipDay':
                 $oIm = $this->createElement('image');
                 $this->_oChannel->appendChild($oIm);
                 foreach ($aValue as $sSubElement => $sSubValue) {
                     $oSub = $this->createElement($sSubElement, $sSubValue);
                     $oIm->appendChild($oSub);
                 }
                 break;
             case 'title':
             case 'pubDate':
             case 'link':
             case 'description':
             case 'copyright':
             case 'managingEditor':
             case 'webMaster':
             case 'lastbuildDate':
             case 'category':
             case 'generator':
             case 'docs':
             case 'language':
             case 'cloud':
             case 'ttl':
             case 'rating':
             case 'textInput':
             case 'source':
                 $oItem->appendChild($this->createElement($sElement, $sValue));
                 break;
         }
     }
     // Append the item to the channel
     $this->_oChannel->appendChild($oItem);
     // Allow chaining with $this
     return $this;
 }
Example #6
0
 /**
  * 
  * @param object $node
  * @param string $name
  * @param string $value Default is NULL
  * @return object
  */
 function xmlAddAttribute($node, $name, $value = NULL)
 {
     $dom = $node->ownerDocument;
     $attribute = $dom->createAttribute($name);
     $node->appendChild($attribute);
     if ($value != NULL) {
         $attribute_value = $dom->createTextNode($value);
         $attribute->appendChild($attribute_value);
     }
     return $node;
 }
Example #7
0
 /**
  * Converts the place to properly formatted XML..
  * 
  * @param object $doc DOMDocument object
  * @param object $root DOMDocument root
  */
 public function toXML($doc, $root)
 {
     $payload = $doc->createElement('payload');
     if ($this->title != null) {
         $payload->appendChild($doc->createElement('title', $this->title));
     }
     if ($this->body != null) {
         $payload->appendChild($doc->createElement('body', $this->body));
     }
     if ($this->mediaURL != null) {
         $doc->appendChildren($doc, $payload, "mediaURL", $this->mediaURL);
     }
     $payload->appendChild($doc->createElement('raw', $this->raw));
     if ($payload->hasChildNodes()) {
         $root->appendChild($payload);
     }
 }
 /**
  * Append a single snippet item to the document
  * @param array $snippet
  */
 protected function do_item($snippet)
 {
     $item = $this->dom->createElement('snippet');
     $item = $this->root->appendChild($item);
     foreach ($snippet as $field_name => $field_value) {
         /*  Don't export certain fields */
         if (in_array($field_name, $this->exclude_fields)) {
             continue;
         }
         /* Create a new element for each field */
         $field = $this->dom->createElement($field_name);
         $field = $item->appendChild($field);
         /* Add the field's content */
         $value = $this->dom->createTextNode($field_value);
         $value = $field->appendChild($value);
     }
 }
Example #9
0
 /**
  * Setter for the node's value. Automatically uses CDATA when needed
  *
  * @access	protected
  * @param	mixed		Value
  * @return	void
  */
 protected function __set_value($value)
 {
     foreach ($this->element->childNodes as $child) {
         $this->element->removeChild($child);
     }
     // It could be that the passed value is an array
     if (is_array($value)) {
         foreach ($value as $node_name => $node_value) {
             $this->add_node($node_name, $node_value);
         }
         return;
     }
     // Figure out whether to use CDATA or not
     if (strpos($value, '<') !== false || strpos($value, '>') !== false || strpos($value, '&') !== false) {
         $text_node = $this->document->createCDATASection($value);
     } else {
         $text_node = $this->document->createTextNode($value);
     }
     $this->element->appendChild($text_node);
 }
Example #10
0
 /**
  * Recursive method to create childs from array
  *
  * @param object $dom Handler to DOMDocument
  * @param object $node Handler to DOMElement (child)
  * @param array $data Array of data to append to the $node.
  * @param string $format Either 'attribute' or 'tags'.  This determines where nested keys go.
  * @return void
  */
 protected static function _fromArray($dom, $node, &$data, $format)
 {
     if (empty($data) || !is_array($data)) {
         return;
     }
     foreach ($data as $key => $value) {
         if (is_string($key)) {
             if (!is_array($value)) {
                 if (is_bool($value)) {
                     $value = (int) $value;
                 } elseif ($value === null) {
                     $value = '';
                 }
                 $isNamespace = strpos($key, 'xmlns:');
                 $nsUri = null;
                 if ($isNamespace !== false) {
                     $node->setAttributeNS('http://www.w3.org/2000/xmlns/', $key, $value);
                     continue;
                 }
                 if ($key[0] !== '@' && $format === 'tags') {
                     $child = $dom->createElement($key, $value);
                     $node->appendChild($child);
                 } else {
                     if ($key[0] === '@') {
                         $key = substr($key, 1);
                     }
                     $attribute = $dom->createAttribute($key);
                     $attribute->appendChild($dom->createTextNode($value));
                     $node->appendChild($attribute);
                 }
             } else {
                 if ($key[0] === '@') {
                     throw new XmlException(__('Invalid array'));
                 }
                 if (array_keys($value) === range(0, count($value) - 1)) {
                     // List
                     foreach ($value as $item) {
                         $data = compact('dom', 'node', 'key', 'format');
                         $data['value'] = $item;
                         self::__createChild($data);
                     }
                 } else {
                     // Struct
                     self::__createChild(compact('dom', 'node', 'key', 'value', 'format'));
                 }
             }
         } else {
             throw new XmlException(__('Invalid array'));
         }
     }
 }
Example #11
0
 /**
  * Create the service node
  *
  * @return void
  */
 protected function createWSDL_service()
 {
     /*
     	    <service name="myService">
     	        <port name="myServicePort" binding="typens:myServiceBinding">
     	            <soap:address location="http://dschini.org/test1.php"/>
     	        </port>
     	    </service>
     */
     $service = $this->wsdl->createElement('service');
     $service->setAttribute('name', $this->classname);
     $port = $this->wsdl->createElement('port');
     $port->setAttribute('name', $this->classname . 'Port');
     $port->setAttribute('binding', 'typens:' . $this->classname . 'Binding');
     $adress = $this->wsdl->createElement('soap:address');
     $adress->setAttribute('location', $this->protocol . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
     $port->appendChild($adress);
     $service->appendChild($port);
     $this->wsdl_definitions->appendChild($service);
 }
Example #12
0
 /**
  * Retreives the output of this object.
  *
  * @return void
  *
  * @author     Benoit Grégoire <*****@*****.**>
  * @author     Francois Proulx <*****@*****.**>
  * @author     Max Horváth <*****@*****.**>
  * @copyright  2004-2006 Benoit Grégoire, Technologies Coeus inc.
  * @copyright  2004-2006 Francois Proulx, Technologies Coeus inc.
  * @copyright  2006 Max Horváth, Horvath Web Consulting
  */
 public function getOutput()
 {
     $db = AbstractDb::getObject();
     // Root node
     $_rss = $this->_xmldoc->createElement("rss");
     $this->_xmldoc->appendChild($_rss);
     $_rss->setAttribute('version', '2.0');
     // channel
     $_channel = $this->_xmldoc->createElement("channel");
     $_rss->appendChild($_channel);
     /*
      * Required channel elements
      */
     // title
     $_title = $this->_xmldoc->createElement("title");
     $_title = $_channel->appendChild($_title);
     $_textNode = $this->_xmldoc->createTextNode($this->_network->getName() . ": " . _("Newest Hotspots"));
     $_title->appendChild($_textNode);
     // link
     $_link = $this->_xmldoc->createElement("link");
     $_channel->appendChild($_link);
     $_textNode = $this->_xmldoc->createTextNode($this->_network->getWebSiteURL());
     $_link->appendChild($_textNode);
     // description
     $_description = $this->_xmldoc->createElement("description");
     $_channel->appendChild($_description);
     $_textNode = $this->_xmldoc->createTextNode(_("List of the most recent Hotspots opened by the network: ") . $this->_network->getName());
     $_description->appendChild($_textNode);
     /*
      * Optional channel elements
      */
     // language
     $_language = $this->_xmldoc->createElement("language");
     $_channel->appendChild($_language);
     if (User::getCurrentUser() != null) {
         $_textNode = $this->_xmldoc->createTextNode(substr(User::getCurrentUser()->getPreferedLocale(), 0, 5));
     } else {
         $_textNode = $this->_xmldoc->createTextNode("en-US");
     }
     $_language->appendChild($_textNode);
     // copyright
     $_copyright = $this->_xmldoc->createElement("copyright");
     $_channel->appendChild($_copyright);
     $_textNode = $this->_xmldoc->createTextNode(_("Copyright ") . $this->_network->getName());
     $_copyright->appendChild($_textNode);
     // webMaster
     if ($this->_network->getTechSupportEmail() != "") {
         $_webMaster = $this->_xmldoc->createElement("webMaster");
         $_channel->appendChild($_webMaster);
         $_textNode = $this->_xmldoc->createTextNode($this->_network->getTechSupportEmail());
         $_webMaster->appendChild($_textNode);
     }
     // pubDate
     $_pubDate = $this->_xmldoc->createElement("pubDate");
     $_channel->appendChild($_pubDate);
     $_textNode = $this->_xmldoc->createTextNode(gmdate("D, d M Y H:i:s \\G\\M\\T", time()));
     $_pubDate->appendChild($_textNode);
     /**
      * lastBuildDate
      *
      * <lastBuildDate> -- The date-time the last time the content of the
      * channel changed.
      *
      * Make a request through the database for the latest modification date
      * of an object.
      *
      * @todo The latest modification date of an object should be an
      *       object property
      */
     $db->execSqlUniqueRes("SELECT EXTRACT(epoch FROM MAX(creation_date)) as date_last_hotspot_opened FROM nodes WHERE network_id = '" . $db->escapeString($this->_network->getId()) . "' AND (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE')", $_lastHotspotRow, false);
     $_lastBuildDate = $this->_xmldoc->createElement("lastBuildDate");
     $_channel->appendChild($_lastBuildDate);
     $_textNode = $this->_xmldoc->createTextNode(gmdate("D, d M Y H:i:s \\G\\M\\T", $_lastHotspotRow['date_last_hotspot_opened']));
     $_lastBuildDate->appendChild($_textNode);
     // generator
     $_generator = $this->_xmldoc->createElement("generator");
     $_channel->appendChild($_generator);
     $_textNode = $this->_xmldoc->createTextNode(WIFIDOG_NAME . " " . WIFIDOG_VERSION);
     $_generator->appendChild($_textNode);
     // docs
     $_docs = $this->_xmldoc->createElement("docs");
     $_channel->appendChild($_docs);
     $_textNode = $this->_xmldoc->createTextNode("http://blogs.law.harvard.edu/tech/rss");
     $_docs->appendChild($_textNode);
     // image
     /*if (defined('NETWORK_LOGO_NAME') && file_exists(WIFIDOG_ABS_FILE_PATH . "local_content/common/" . constant('NETWORK_LOGO_NAME'))) {
                 $_image = $this->_xmldoc->createElement("image");
                 $_channel->appendChild($_image);
     
                 // title
                 $_title = $this->_xmldoc->createElement("title");
                 $_image->appendChild($_title);
                 $_textNode = $this->_xmldoc->createTextNode($this->_network->getName() . ": " . _("Newest Hotspots"));
                 $_title->appendChild($_textNode);
     
                 // url
                 $_url = $this->_xmldoc->createElement("url");
                 $_image->appendChild($_url);
                 $_textNode = $this->_xmldoc->createTextNode(COMMON_CONTENT_URL . NETWORK_LOGO_NAME);
                 $_url->appendChild($_textNode);
     
                 // link
                 $_link = $this->_xmldoc->createElement("link");
                 $_image->appendChild($_link);
                 $_textNode = $this->_xmldoc->createTextNode($this->_network->getWebSiteURL());
                 $_link->appendChild($_textNode);
     
                 $_imageSize = @getimagesize(WIFIDOG_ABS_FILE_PATH . "local_content/common/" . NETWORK_LOGO_NAME);
     
                 if ($_imageSize) {
                     // width
                     $_width = $this->_xmldoc->createElement("width");
                     $_image->appendChild($_width);
                     $_textNode = $this->_xmldoc->createTextNode($_imageSize[0]);
                     $_width->appendChild($_textNode);
     
                     // height
                     $_height = $this->_xmldoc->createElement("height");
                     $_image->appendChild($_height);
                     $_textNode = $this->_xmldoc->createTextNode($_imageSize[1]);
                     $_height->appendChild($_textNode);
                 }
     
                 // description
                 $_description = $this->_xmldoc->createElement("description");
                 $_image->appendChild($_description);
                 $_textNode = $this->_xmldoc->createTextNode(_("List of the most recent Hotspots opened by the network: ") . $this->_network->getName());
                 $_description->appendChild($_textNode);
             }*/
     // Node details
     if ($this->_nodes) {
         foreach ($this->_nodes as $_nodeData) {
             $_node = Node::getObject($_nodeData['node_id']);
             $this->_network = $_node->getNetwork();
             $_hotspot = $this->_xmldoc->createElement("item");
             $_hotspot = $_channel->appendChild($_hotspot);
             // Hotspot name
             $_hotspotName = $this->_xmldoc->createElement("title", htmlspecialchars($_node->getName(), ENT_QUOTES));
             $_hotspot->appendChild($_hotspotName);
             // Hotspot Website URL
             if ($_node->getWebSiteURL() != "") {
                 $_hotspotUrl = $this->_xmldoc->createElement("link", htmlspecialchars($_node->getWebSiteURL(), ENT_QUOTES));
                 $_hotspot->appendChild($_hotspotUrl);
             }
             // Hotspot name
             $_hotspotDesc = $this->_xmldoc->createElement("description");
             $_hotspot->appendChild($_hotspotDesc);
             $_descriptionText = '<p>';
             // Hotspot global status
             if ($_node->getDeploymentStatus() != 'NON_WIFIDOG_NODE') {
                 if ($_nodeData['is_up'] == 't') {
                     $_descriptionText .= "<img src='" . COMMON_IMAGES_URL . "HotspotStatus/up.gif' alt='up' />";
                 } else {
                     $_descriptionText .= "<img src='" . COMMON_IMAGES_URL . "HotspotStatus/down.gif' alt='down' />";
                 }
             }
             // Description
             if ($_node->getDescription() != "") {
                 $_descriptionText .= htmlspecialchars($_node->getDescription(), ENT_QUOTES);
             }
             $_descriptionText .= '</p>';
             $_descriptionText .= '<p>';
             $_descriptionText .= _("Address") . ": ";
             // Civic number
             if ($_node->getCivicNumber() != "") {
                 $_descriptionText .= $_node->getCivicNumber() . ", ";
             }
             // Street address
             if ($_node->getStreetName() != "") {
                 $_descriptionText .= htmlspecialchars($_node->getStreetName(), ENT_QUOTES) . ", ";
             }
             // City
             if ($_node->getCity() != "") {
                 $_descriptionText .= htmlspecialchars($_node->getCity(), ENT_QUOTES) . ", ";
             }
             // Province
             if ($_node->getProvince() != "") {
                 $_descriptionText .= htmlspecialchars($_node->getProvince(), ENT_QUOTES) . ", ";
             }
             // Postal code
             if ($_node->getPostalCode() != "") {
                 $_descriptionText .= $_node->getPostalCode() . ", ";
             }
             // Country
             if ($_node->getCountry() != "") {
                 $_descriptionText .= htmlspecialchars($_node->getCountry(), ENT_QUOTES);
             }
             // Map Url
             if ($_node->getMapURL() != "") {
                 $_descriptionText .= " <a href='" . $_node->getMapURL() . "'>" . _("See Map") . "</a>";
             }
             // Mass transit info
             if ($_node->getTransitInfo() != "") {
                 $_descriptionText .= "<br />";
                 $_descriptionText .= htmlspecialchars($_node->getTransitInfo(), ENT_QUOTES);
             }
             $_descriptionText .= "</p>";
             if ($_node->getEmail() != "" || $_node->getTelephone() != "") {
                 $_descriptionText .= "<p>";
                 $_descriptionText .= _("Contact") . ": ";
                 // Contact e-mail
                 if ($_node->getEmail() != "") {
                     $_descriptionText .= "<br /><a href='mailto:" . $_node->getEmail() . "'>" . $_node->getEmail() . "</a>";
                 }
                 // Contact phone
                 if ($_node->getTelephone() != "") {
                     $_descriptionText .= "<br />" . $_node->getTelephone();
                 }
                 $_descriptionText .= "</p>";
             }
             $_hotspotDesc->appendChild($this->_xmldoc->createTextNode($_descriptionText));
             // guid
             if ($_node->getWebSiteURL() != "") {
                 $_guid = $this->_xmldoc->createElement("guid");
                 $_guid->setAttribute('isPermaLink', 'false');
                 $_hotspot->appendChild($_guid);
                 $_textNode = $this->_xmldoc->createTextNode(htmlspecialchars($_node->getWebSiteURL(), ENT_QUOTES));
                 $_guid->appendChild($_textNode);
             }
             // pubDate
             $_hotspotOpeningDate = $this->_xmldoc->createElement("pubDate", gmdate("D, d M Y H:i:s \\G\\M\\T", $_nodeData['creation_date_epoch']));
             $_hotspot->appendChild($_hotspotOpeningDate);
         }
     }
     echo $this->_xmldoc->saveXML();
 }
Example #13
0
 /**
  * Merges nodes of newly added menu xml file
  *
  * @param object $oDomElemTo   merge target
  * @param object $oDomElemFrom merge source
  * @param object $oXPathTo     node path
  * @param object $oDomDocTo    node to append child
  * @param string $sQueryStart  node query
  */
 protected function _mergeNodes($oDomElemTo, $oDomElemFrom, $oXPathTo, $oDomDocTo, $sQueryStart)
 {
     foreach ($oDomElemFrom->childNodes as $oFromNode) {
         if ($oFromNode->nodeType === XML_ELEMENT_NODE) {
             $sFromAttrName = $oFromNode->getAttribute('id');
             $sFromNodeName = $oFromNode->tagName;
             // find current item
             $sQuery = "{$sQueryStart}/{$sFromNodeName}[@id='{$sFromAttrName}']";
             $oCurNode = $oXPathTo->query($sQuery);
             // if not found - append
             if ($oCurNode->length == 0) {
                 $oDomElemTo->appendChild($oDomDocTo->importNode($oFromNode, true));
             } else {
                 $oCurNode = $oCurNode->item(0);
                 // if found copy all attributes and check childnodes
                 $this->_copyAttributes($oCurNode, $oFromNode);
                 if ($oFromNode->childNodes->length) {
                     $this->_mergeNodes($oCurNode, $oFromNode, $oXPathTo, $oDomDocTo, $sQuery);
                 }
             }
         }
     }
 }
Example #14
0
 /**
  * Displays the output of this object.
  *
  * @return void
  *
  * @author     Benoit Gregoire <*****@*****.**>
  * @author     Francois Proulx <*****@*****.**>
  * @author     Max Horváth <*****@*****.**>
  * @author     Joe Bowser <*****@*****.**>
  * @copyright  2004-2006 Benoit Gregoire, Technologies Coeus inc.
  * @copyright  2004-2006 Francois Proulx, Technologies Coeus inc.
  * @copyright  2006 Max Horváth, Horvath Web Consulting
  * @copyright  2006 Joe Bowser
  */
 public function getOutput()
 {
     $_kml = $this->_xmldoc->createElement("kml");
     $_kml->setAttribute('xmlns', 'http://earth.google.com/kml/2.0');
     $this->_xmldoc->appendChild($_kml);
     // Document
     $_document = $this->_xmldoc->createElement("Document");
     $_kml->appendChild($_document);
     /*
      * Style Elements (Up Nodes)
      */
     $_style_up = $this->_xmldoc->createElement("Style");
     $_style_up->setAttribute('id', 'node_up');
     $_document->appendChild($_style_up);
     $_iconStyle = $this->_xmldoc->createElement("IconStyle");
     $_style_up->appendChild($_iconStyle);
     /* Since scale is the same, we only have to define it once */
     $_scale = $this->_xmldoc->createElement("scale");
     $_iconStyle->appendChild($_scale);
     $_textNode = $this->_xmldoc->createTextNode("0.5");
     $_scale->appendChild($_textNode);
     $_icon = $this->_xmldoc->createElement("Icon");
     $_iconStyle->appendChild($_icon);
     $_href = $this->_xmldoc->createElement("href");
     $_icon->appendChild($_href);
     $_textNode = $this->_xmldoc->createTextNode(BASE_URL_PATH . "images/HotspotStatusMap/up.png");
     $_href->appendChild($_textNode);
     /*
      * Style Elements (Down Nodes)
      */
     $_style_down = $this->_xmldoc->createElement("Style");
     $_style_down->setAttribute('id', 'node_down');
     $_document->appendChild($_style_down);
     $_iconStyle = $this->_xmldoc->createElement("IconStyle");
     $_style_down->appendChild($_iconStyle);
     $_scale = $this->_xmldoc->createElement("scale");
     $_iconStyle->appendChild($_scale);
     $_textNode = $this->_xmldoc->createTextNode("0.5");
     $_scale->appendChild($_textNode);
     $_iconStyle->appendChild($_scale);
     $_icon = $this->_xmldoc->createElement("Icon");
     $_iconStyle->appendChild($_icon);
     $_href = $this->_xmldoc->createElement("href");
     $_icon->appendChild($_href);
     $_textNode = $this->_xmldoc->createTextNode(BASE_URL_PATH . "images/HotspotStatusMap/down.png");
     $_href->appendChild($_textNode);
     /*
      * Style Elements (Unknown Nodes)
      */
     $_style_unknown = $this->_xmldoc->createElement("Style");
     $_style_unknown->setAttribute('id', 'node_unknown');
     $_document->appendChild($_style_unknown);
     $_iconStyle = $this->_xmldoc->createElement("IconStyle");
     $_style_unknown->appendChild($_iconStyle);
     $_scale = $this->_xmldoc->createElement("scale");
     $_iconStyle->appendChild($_scale);
     $_textNode = $this->_xmldoc->createTextNode("0.5");
     $_scale->appendChild($_textNode);
     $_icon = $this->_xmldoc->createElement("Icon");
     $_iconStyle->appendChild($_icon);
     $_href = $this->_xmldoc->createElement("href");
     $_icon->appendChild($_href);
     $_textNode = $this->_xmldoc->createTextNode(BASE_URL_PATH . "images/HotspotStatusMap/unknown.png");
     $_href->appendChild($_textNode);
     /*
      * Creating the Folder
      */
     $_folder = $this->_xmldoc->createElement("Folder");
     $_document->appendChild($_folder);
     $_name = $this->_xmldoc->createElement("name");
     $_folder->appendChild($_name);
     $_textNode = $this->_xmldoc->createTextNode($this->_network->getName());
     $_name->appendChild($_textNode);
     /*
      * Creating the Placemarks (Nodes)
      */
     if ($this->_nodes) {
         foreach ($this->_nodes as $_nodeData) {
             $_node = Node::getObject($_nodeData['node_id']);
             $this->_network = $_node->getNetwork();
             $_placemark = $this->_xmldoc->createElement("Placemark");
             $_folder->appendChild($_placemark);
             // Hotspot name
             $_hotspotName = $this->_xmldoc->createElement("name", htmlspecialchars($_node->getName(), ENT_QUOTES));
             $_placemark->appendChild($_hotspotName);
             $_html_data = "<b>" . _("Address") . ":</b><br />" . $_node->getCivicNumber() . " " . $_node->getStreetName() . "<br />" . $_node->getCity() . "," . $_node->getProvince() . "<br />" . $_node->getCountry() . "<br />" . $_node->getPostalCode() . "<br /><br /> <b>" . _("URL") . ":</b> <a href='" . $_node->getWebSiteURL() . "'>" . $_node->getWebSiteURL() . "</a> <br /> <b> " . _("Email") . ":</b> <a href='mailto:" . $_node->getEmail() . "'>" . $_node->getEmail() . "</a>";
             // Creating the description node with the data from it
             $_description = $this->_xmldoc->createElement("description");
             $_placemark->appendChild($_description);
             $_cdata = $this->_xmldoc->createCDATASection($_html_data);
             $_description->appendChild($_cdata);
             // Description data goes here
             $_point = $this->_xmldoc->createElement("Point");
             $_placemark->appendChild($_point);
             // Get GIS Location
             $_gis_loc = $_node->getGisLocation();
             $_gis_string = $_gis_loc->getLongitude() . "," . $_gis_loc->getLatitude() . "," . $_gis_loc->getAltitude();
             $_coordinates = $this->_xmldoc->createElement("coordinates", $_gis_string);
             // Hotspot global status
             if ($_node->getDeploymentStatus() != 'NON_WIFIDOG_NODE') {
                 if ($_nodeData['is_up'] == 't') {
                     $_styleURL = $this->_xmldoc->createElement("styleURL", "#node_up");
                 } else {
                     $_styleURL = $this->_xmldoc->createElement("styleURL", "#node_down");
                 }
             } else {
                 $_styleURL = $this->_xmldoc->createElement("styleURL", "#node_unknown");
             }
             $_point->appendChild($_coordinates);
         }
     }
     echo $this->_xmldoc->saveXML();
 }
Example #15
0
 /**
  * Builds and attaches relations to an item-level element (item or search)
  *
  * @param  object $element DOMElement for the item or search
  * @param  array  $relations associative array of relations to attach
  */
 protected function attachRelations(&$element, &$relations)
 {
     // create the relations element
     $relations_element = $this->dom->createElement('relations');
     $element->appendChild($relations_element);
     foreach ($relations as $relation) {
         // create the relation element
         $relation_element = $this->dom->createElement('relation');
         $relations_element->appendChild($relation_element);
         // if the id isn't set (creating a new relation)
         // and the action isn't set
         // then set the action to create
         if (empty($relation['id']) && empty($relation['action'])) {
             $relation['action'] = Services_WorkXpress::RELATION_ACTION_CREATE;
         }
         // set the action
         $relation_element->setAttribute('action', $relation['action']);
         // set the relation type id
         $relation_element->setAttribute('relation_type_id', $relation['relation_type_id']);
         // set the reference
         if (!empty($relation['reference'])) {
             $relation_element->setAttribute('reference', $relation['reference']);
         }
         // set proper attributes depending on if we're creating, recycling,
         // or deleting the relationship
         switch ($relation['action']) {
             case Services_WorkXpress::RELATION_ACTION_CREATE:
                 // set the item type id
                 if (!empty($relation['item_type_id'])) {
                     $relation_element->setAttribute('item_type_id', $relation['item_type_id']);
                 }
                 // set the related item side
                 if (!empty($relation['related_item_side'])) {
                     $relation_element->setAttribute('related_item_side', $relation['related_item_side']);
                 }
                 // set the related item type id
                 if (!empty($relation['related_item_type_id'])) {
                     $relation_element->setAttribute('related_item_type_id', $relation['related_item_type_id']);
                 }
                 // set the related item id
                 if (!empty($relation['related_item_id'])) {
                     $relation_element->setAttribute('related_item_id', $relation['related_item_id']);
                 }
                 break;
             case Services_WorkXpress::RELATION_ACTION_DELETE:
             case Services_WorkXpress::RELATION_ACTION_RECYCLE:
                 // set the id
                 if (!empty($relation['id'])) {
                     $relation_element->setAttribute('id', $relation['id']);
                 }
                 break;
         }
         // end switch $relation['action']
     }
     // end foreach - loop through the relations
     return true;
 }
Example #16
0
 /**
  * @access 	protected
  * @param 	string			$type					
  * @param 	string			$element				
  * @param 	string			$str					
  * @param 	object			$parent					
  * @return 	object									
  */
 protected function _addElement($type, $element, $str = null, $parent = null)
 {
     try {
         if ($str) {
             $new = $this->core->createElementNS($this->nameSpaces[$type], $type . ':' . $element, Fonction::checkString($str));
         } else {
             $new = $this->core->createElementNS($this->nameSpaces[$type], $type . ':' . $element);
         }
         if (!$parent) {
             $this->root->appendChild($new);
         } else {
             $parent->appendChild($new);
         }
         return $new;
     } catch (Exception $e) {
         throw $e;
     }
 }
Example #17
0
 /**
  * Método para enviar para o CobreDireto
  *
  * Valida todas as informações e envia para o CobreDireto, já redirecionando para a URL do CobreDireto
  *
  **/
 public function pagar()
 {
     self::configuraBehavior();
     if (is_object($this->payment_data)) {
         $this->payOrder->appendChild($this->payment_data);
     }
     self::configuraConsumidor();
     $this->request->appendChild($this->payOrder);
     parent::initCobreDireto('payOrder');
     if ($this->xml->status != 0) {
         die('<strong>Erro:</strong> ' . $this->xml->msg);
     } else {
         header('Location: ' . $this->xml->bpag_data->url);
     }
 }
Example #18
0
 /**
  * Create an attribute on an XML element (tag)
  * 
  * @param  string $attribute Name of attribute
  * @param  string $value     Value of attribute
  * @param  object $bind XML element to add the text to
  * @return null
  */
 public function createAttribute($attribute, $value, $bind)
 {
     $attr = $this->dom->createAttribute($attribute);
     $attr->value = $value;
     $bind->appendChild($attr);
 }
 /**
  * parse tree ready for insertion into sitemap DB
  *
  * @param string $n 
  * @param object $dom 
  * @param object $child 
  * @param array $items 
  * @return void
  * @author Andy Bennett
  */
 private static function save_parse($n, &$dom, &$child, $items)
 {
     $arr = array('txt' => 'title', 'id' => 'url');
     $element = $dom->createElement($n);
     foreach ($items as $k => $item) {
         if ($k != 'items') {
             if (isset($arr[$k])) {
                 $f = 'translate_' . $k;
                 $item = self::$f($item);
                 if ($item == '') {
                     continue;
                 }
                 $k = $arr[$k];
             }
             $att = $dom->createAttribute($k);
             $att->appendChild($dom->createTextNode($item));
             $element->appendChild($att);
         } else {
             foreach ($item as $sub) {
                 self::save_parse('item', $dom, $element, $sub);
             }
         }
     }
     $child->appendChild($element);
 }
Example #20
0
 /**
  * Builds and attaches relations to an item element
  *
  * @param  object $element DOMElement for the item
  * @param  array  $relations associative array of relations to attach
  */
 protected function attachRelations(&$element, &$relations)
 {
     // create the relations element
     $relations_element = $this->dom->createElement('relations');
     $element->appendChild($relations_element);
     foreach ($relations as $relation) {
         // create the relation element
         $relation_element = $this->dom->createElement('relation');
         $relations_element->appendChild($relation_element);
         // set the relation type id
         $relation_element->setAttribute('relation_type_id', $relation['relation_type_id']);
         // set the related item side
         $relation_element->setAttribute('related_item_side', $relation['related_item_side']);
         // set the related item type id
         $relation_element->setAttribute('related_item_type_id', $relation['related_item_type_id']);
         // set the related item id
         $relation_element->setAttribute('related_item_id', $relation['related_item_id']);
         // set the reference
         if (!empty($relation['reference'])) {
             $relation_element->setAttribute('reference', $relation['reference']);
         }
     }
     // end foreach - loop through the relations
     return true;
 }
Example #21
0
 /**
  * Retreives the output of this object.
  *
  * @param bool $return_object If true this function only returns the DOM object
  *
  * @return string The XML output
  *
  * @author     Benoit Grégoire <*****@*****.**>
  * @author     Francois Proulx <*****@*****.**>
  * @author     Max Horváth <*****@*****.**>
  * @copyright  2004-2006 Benoit Grégoire, Technologies Coeus inc.
  * @copyright  2004-2006 Francois Proulx, Technologies Coeus inc.
  * @copyright  2006 Max Horváth, Horvath Web Consulting
  */
 public function getOutput($return_object = false)
 {
     // Root node
     $_hotspotStatusRootNode = $this->_xmldoc->createElement("wifidogHotspotsStatus");
     $_hotspotStatusRootNode->setAttribute('version', '1.0');
     $this->_xmldoc->appendChild($_hotspotStatusRootNode);
     // Document metadata
     $_documentGendateNode = $this->_xmldoc->createElement("generationDateTime", gmdate("Y-m-d\\Th:m:s\\Z"));
     $_hotspotStatusRootNode->appendChild($_documentGendateNode);
     // Network metadata
     $_networkMetadataNode = $this->_xmldoc->createElement("networkMetadata");
     $_networkMetadataNode = $_hotspotStatusRootNode->appendChild($_networkMetadataNode);
     $_networkUriNode = $this->_xmldoc->createElement("networkUri", htmlspecialchars($this->_network->getWebSiteURL(), ENT_QUOTES));
     $_networkMetadataNode->appendChild($_networkUriNode);
     $_networkNameNode = $this->_xmldoc->createElement("name", htmlspecialchars($this->_network->getName(), ENT_QUOTES));
     $_networkMetadataNode->appendChild($_networkNameNode);
     $_networkUrlNode = $this->_xmldoc->createElement("websiteUrl", htmlspecialchars($this->_network->getWebSiteURL(), ENT_QUOTES));
     $_networkMetadataNode->appendChild($_networkUrlNode);
     $_email = $this->_network->getTechSupportEmail();
     if (!empty($email)) {
         $_networkEmailNode = $this->_xmldoc->createElement("techSupportEmail", $_email);
         $_networkMetadataNode->appendChild($_networkEmailNode);
     }
     $_nodesCountNode = $this->_xmldoc->createElement("hotspotsCount", count($this->_nodes));
     $_networkMetadataNode->appendChild($_nodesCountNode);
     $_networkValidUsersNode = $this->_xmldoc->createElement("validSubscribedUsersCount", $this->_network->getNumValidUsers());
     $_networkMetadataNode->appendChild($_networkValidUsersNode);
     // Get number of online users
     $_networkOnlineUsersNode = $this->_xmldoc->createElement("onlineUsersCount", $this->_network->getNumOnlineUsers());
     $_networkMetadataNode->appendChild($_networkOnlineUsersNode);
     // Node details
     if ($this->_nodes) {
         // Hotspots metadata
         $_hotspotsMetadataNode = $this->_xmldoc->createElement("hotspots");
         $_hotspotsMetadataNode = $_hotspotStatusRootNode->appendChild($_hotspotsMetadataNode);
         foreach ($this->_nodes as $_nodeData) {
             $_node = Node::getObject($_nodeData['node_id']);
             $this->_network = $_node->getNetwork();
             $_hotspot = $this->_xmldoc->createElement("hotspot");
             $_hotspot = $_hotspotsMetadataNode->appendChild($_hotspot);
             // Hotspot ID
             $_hotspotId = $this->_xmldoc->createElement("hotspotId", $_node->getId());
             $_hotspot->appendChild($_hotspotId);
             // Hotspot name
             $_hotspotName = $this->_xmldoc->createElement("name", htmlspecialchars($_node->getName(), ENT_QUOTES));
             $_hotspot->appendChild($_hotspotName);
             /**
              * (1..n) A Hotspot has many node
              *
              * WARNING For now, we are simply duplicating the hotspot data in node
              * Until wifidog implements full abstractiong hotspot vs nodes.
              */
             $_nodes = $this->_xmldoc->createElement("nodes");
             $_hotspot->appendChild($_nodes);
             $_nodeMetadataNode = $this->_xmldoc->createElement("node");
             $_nodes->appendChild($_nodeMetadataNode);
             // Node ID
             $_nodeId = $this->_xmldoc->createElement("nodeId", $_node->getId());
             $_nodeMetadataNode->appendChild($_nodeId);
             // Online Users
             $_nodeUserNum = $this->_xmldoc->createElement("numOnlineUsers", $_node->GetNumOnlineUsers());
             $_nodeMetadataNode->appendChild($_nodeUserNum);
             $_nodeCreationDate = $this->_xmldoc->createElement("creationDate", $_node->getCreationDate());
             $_nodeMetadataNode->appendChild($_nodeCreationDate);
             if ($_node->getDeploymentStatus() != 'NON_WIFIDOG_NODE') {
                 if ($_nodeData['is_up'] == 't') {
                     $_nodeStatus = $this->_xmldoc->createElement("status", "up");
                 } else {
                     $_nodeStatus = $this->_xmldoc->createElement("status", "down");
                 }
                 $_nodeMetadataNode->appendChild($_nodeStatus);
             }
             if (($_gisData = $_node->getGisLocation()) !== null) {
                 $_nodeGis = $this->_xmldoc->createElement("gisLatLong");
                 $_nodeGis->setAttribute("lat", $_gisData->getLatitude());
                 $_nodeGis->setAttribute("long", $_gisData->getLongitude());
                 $_nodeMetadataNode->appendChild($_nodeGis);
             }
             // Hotspot opening date ( for now it's called creation_date )
             $_hotspotOpeningDate = $this->_xmldoc->createElement("openingDate", $_node->getCreationDate());
             $_hotspot->appendChild($_hotspotOpeningDate);
             // Hotspot Website URL
             if ($_node->getWebSiteURL() != "") {
                 $_hotspotUrl = $this->_xmldoc->createElement("webSiteUrl", htmlspecialchars($_node->getWebSiteURL(), ENT_QUOTES));
                 $_hotspot->appendChild($_hotspotUrl);
             }
             // Hotspot global status
             if ($_node->getDeploymentStatus() != 'NON_WIFIDOG_NODE') {
                 if ($_nodeData['is_up'] == 't') {
                     $_hotspotStatus = $this->_xmldoc->createElement("globalStatus", "100");
                 } else {
                     $_hotspotStatus = $this->_xmldoc->createElement("globalStatus", "0");
                 }
                 $_hotspot->appendChild($_hotspotStatus);
             }
             // Description
             if ($_node->getDescription() != "") {
                 $_hotspotDesc = $this->_xmldoc->createElement("description", htmlspecialchars($_node->getDescription(), ENT_QUOTES));
                 $_hotspot->appendChild($_hotspotDesc);
             }
             // Map Url
             if ($_node->getMapURL() != "") {
                 $_hotspotMapUrl = $this->_xmldoc->createElement("mapUrl", htmlspecialchars($_node->getMapURL(), ENT_QUOTES));
                 $_hotspot->appendChild($_hotspotMapUrl);
             }
             // Mass transit info
             if ($_node->getTransitInfo() != "") {
                 $_hotspotTransit = $this->_xmldoc->createElement("massTransitInfo", htmlspecialchars($_node->getTransitInfo(), ENT_QUOTES));
                 $_hotspot->appendChild($_hotspotTransit);
             }
             // Contact e-mail
             if ($_node->getEmail() != "") {
                 $_hotspotContactEmail = $this->_xmldoc->createElement("contactEmail", $_node->getEmail());
                 $_hotspot->appendChild($_hotspotContactEmail);
             }
             // Contact phone
             if ($_node->getTelephone() != "") {
                 $_hotspotContactPhone = $this->_xmldoc->createElement("contactPhoneNumber", $_node->getTelephone());
                 $_hotspot->appendChild($_hotspotContactPhone);
             }
             // Civic number
             if ($_node->getCivicNumber() != "") {
                 $_hotspotCivicNr = $this->_xmldoc->createElement("civicNumber", $_node->getCivicNumber());
                 $_hotspot->appendChild($_hotspotCivicNr);
             }
             // Street address
             if ($_node->getStreetName() != "") {
                 $_hotspotStreet = $this->_xmldoc->createElement("streetAddress", htmlspecialchars($_node->getStreetName(), ENT_QUOTES));
                 $_hotspot->appendChild($_hotspotStreet);
             }
             // City
             if ($_node->getCity() != "") {
                 $_hotspotCity = $this->_xmldoc->createElement("city", htmlspecialchars($_node->getCity(), ENT_QUOTES));
                 $_hotspot->appendChild($_hotspotCity);
             }
             // Province
             if ($_node->getProvince() != "") {
                 $_hotspotProvince = $this->_xmldoc->createElement("province", htmlspecialchars($_node->getProvince(), ENT_QUOTES));
                 $_hotspot->appendChild($_hotspotProvince);
             }
             // Postal code
             if ($_node->getPostalCode() != "") {
                 $_hotspotPostalCode = $this->_xmldoc->createElement("postalCode", $_node->getPostalCode());
                 $_hotspot->appendChild($_hotspotPostalCode);
             }
             // Country
             if ($_node->getCountry() != "") {
                 $_hotspotCountry = $this->_xmldoc->createElement("country", htmlspecialchars($_node->getCountry(), ENT_QUOTES));
                 $_hotspot->appendChild($_hotspotCountry);
             }
             // Long / Lat
             if (($_gisData = $_node->getGisLocation()) !== null) {
                 $_hotspotGis = $this->_xmldoc->createElement("gisCenterLatLong");
                 $_hotspotGis->setAttribute("lat", $_gisData->getLatitude());
                 $_hotspotGis->setAttribute("long", $_gisData->getLongitude());
                 $_hotspotGis->setAttribute("show", $_node->showOnMap());
                 $_hotspot->appendChild($_hotspotGis);
             }
         }
     }
     if ($return_object) {
         return $this->_xmldoc;
     } else {
         echo $this->_xmldoc->saveXML();
     }
 }
 /**
  * Append a new child-element to any parent which have been newly created
  * and returns it to the main application (to make it possible to add childelement)
  *
  * @param object $parentName
  * @param string $tagName
  * @param string $txtNode
  * @return object $child
  */
 public function appendParentChild($parentName, $tagName)
 {
     // create element
     $child = $this->dom->createElement($tagName);
     // append to the parent
     $child = $parentName->appendChild($child);
     // returning the child to the main application
     return $child;
 }
Example #23
0
 /**
  * Create Education Metadata (How To)
  *
  * @param object $met
  * @param DOMDocument $doc
  * @param object $xmlnode
  * @return DOMNode
  */
 public function create_metadata_educational($met, DOMDocument &$doc, $xmlnode)
 {
     $nd = $doc->createElementNS($this->ccnamespaces['lom'], 'educational');
     $nd2 = $doc->createElementNS($this->ccnamespaces['lom'], 'intendedEndUserRole');
     $nd3 = $doc->createElementNS($this->ccnamespaces['voc'], 'vocabulary');
     $xmlnode->appendChild($nd);
     $nd->appendChild($nd2);
     $nd2->appendChild($nd3);
     foreach ($met->arrayeducational as $name => $value) {
         !is_array($value) ? $value = array($value) : null;
         foreach ($value as $v) {
             $nd4 = $doc->createElementNS($this->ccnamespaces['voc'], $name, $v[0]);
             $nd3->appendChild($nd4);
         }
     }
     return $nd;
 }
 /**
  * Builds and attaches rules to an item-level element (item or search)
  *
  * @param  object $element DOMElement for the item or search
  * @param  array  $rules associative array of rules to attach
  */
 protected function attachRules(&$element, &$rules)
 {
     // create the rules element
     $rules_element = $this->dom->createElement('rules');
     $element->appendChild($rules_element);
     // set the log_debug flag
     if (!empty($rules['log_debug'])) {
         $rules_element->setAttribute('log_debug', $rules['log_debug']);
     }
     foreach ($rules as $rule) {
         // the element needs to be an array to be a child
         if (!is_array($rule)) {
             continue;
         }
         // create the rule element
         $rule_element = $this->dom->createElement('rule');
         $rules_element->appendChild($rule_element);
         // set the type
         $rule_element->setAttribute('type', $rule['type']);
         switch ($rule['type']) {
             case Services_WorkXpress::RULE_TYPE_RULE:
                 // set the id
                 $rule_element->setAttribute('id', $rule['id']);
                 break;
             case Services_WorkXpress::RULE_TYPE_EXECUTION_POINT:
                 // set the execution point
                 $rule_element->setAttribute('point', $rule['point']);
                 break;
         }
         // end switch $rule['type']
     }
     // end foreach - loop through the rules
     return true;
 }
Example #25
0
 /**
  * Add new elements to DomDocument
  *
  * @access private
  * @param object $dom DomDocument
  * @param array $array elements ('title' => 'value')
  * @param object $node parent node
  * @return void
  */
 private function newDomElements(&$dom, $array, &$node)
 {
     foreach ($array as $k => $v) {
         if ($v == NULL) {
             $nnode = $dom->createElement($k);
         } else {
             if (is_array($v)) {
                 foreach ($v as $key => $value) {
                     $nnode = $dom->createElement($key, $value);
                 }
             } else {
                 $nnode = $dom->createElement($k, $v);
             }
         }
         $node->appendChild($nnode);
     }
 }
Example #26
0
 /**
  * Add a {@link http://www.w3.org/TR/wsdl#_soap:binding SOAP binding} element to a Binding element
  *
  * @param object $binding A binding XML_Tree_Node returned by {@link function addBinding}
  * @param string $style binding style, possible values are "rpc" (the default) and "document"
  * @param string $transport Transport method (defaults to HTTP)
  * @return boolean
  */
 public function addSoapBinding($binding, $style = 'rpc', $transport = 'http://schemas.xmlsoap.org/soap/http')
 {
     $soap_binding = $this->_dom->createElement('soap:binding');
     $soap_binding->setAttribute('style', $style);
     $soap_binding->setAttribute('transport', $transport);
     $binding->appendChild($soap_binding);
     return $soap_binding;
 }
Example #27
0
 /**
  * Parses object or array and converts it to XML.
  *
  * @todo   Validate $key (would it create too much overhead?)
  *
  * @param object $obj   Object to parse. In theory arrays will work if keys are not integers.
  * @param object $top   Toplevel DOM object
  * @param bool   $cdata Creates CDATASection if true
  */
 protected function objectToNode($obj, $top, $cdata)
 {
     foreach ($obj as $key => $val) {
         if (is_array($val) || is_object($val) && $val instanceof ArrayAccess) {
             foreach ($val as $v) {
                 $item = $this->dom->createElement($key);
                 if (is_object($v)) {
                     $this->objectToNode($v, $item, $cdata);
                 } elseif ($cdata) {
                     $item->appendChild($this->dom->createCDATASection($v));
                 } elseif (is_string($v) || is_int($v)) {
                     $item->appendChild($this->dom->createTextNode($v));
                 }
                 $top->appendChild($item);
             }
         } elseif (is_object($val)) {
             if (is_numeric($key)) {
                 $item = $this->dom->createElement($top->nodeName);
             } else {
                 $item = $this->dom->createElement($key);
             }
             $this->objectToNode($val, $item, $cdata);
             $top->appendChild($item);
         } else {
             $item = $this->dom->createElement($key);
             if ($cdata) {
                 $item->appendChild($this->dom->createCDATASection($val));
             } else {
                 $item->appendChild($this->dom->createTextNode($val));
             }
             $top->appendChild($item);
         }
     }
 }