/** * Construct the XML * * @access public * @since 1.0.8 */ public function constructXML() { $this->_xmlToolBox->startTag("Cookie"); $cookies = $_COOKIE; foreach($cookies as $name => $content) { $cookie = new SLS_Cookie($name); $cookieParams = $cookie->getParams(); if (!empty($cookieParams)) { $this->_xmlToolBox->startTag("item",array("name" => $name)); $this->_xmlToolBox->startTag("params"); foreach($cookieParams as $key => $value) { if (empty($value)) $value = "null"; if (is_object($value)) $value = SLS_String::printArray(SLS_String::objectToArray($value)); else if (is_array($value)) $value = SLS_String::printArray($value); $this->_xmlToolBox->startTag("param"); $this->_xmlToolBox->addFullTag("name", $key, true); $this->_xmlToolBox->addFullTag("value", $value, true); $this->_xmlToolBox->endTag("param"); } $this->_xmlToolBox->endTag("params"); $this->_xmlToolBox->endTag("item"); } } $this->_xmlToolBox->endTag("Cookie"); }
/** * Format XML for a given recordsets collection * * @access public * @param SLS_XMLToolbox $xml current controller's XML * @param array $recordsets array of PDO recordsets * @param array $options transformations on some columns - delimited by ":". each function can be methods of SLS' classes or php standard function * <code> * // Complete example * $newss = $news->searchModels("news",array("user","article_category")); * $xml = $news->pdoToXML($xml,$newss,array("news_excerpt" => array("php:strip_tags","SLS_String:trimStringToLength:100"), * "news_date" => array("SLS_Date:getDate:FULL_LITTERAL_TIME","php:ucwords"), * "news_photo" => "SLS_String:getUrlFileImg:_0", * "news_pdf" => "SLS_String:getUrlFile", * "news_title" => "php:trim") * , "all_news/news"); * </code> * @param string $nodeName the root node of your model, by default it's your classname in lowercase * @return SLS_XMLToolbox $xml current controller's XML updated * @see SLS_FrontModel::getParams * @see SLS_FrontModel::toXML * @since 1.0.8 */ public function pdoToXML($xml,$recordsets,$options=array(),$nodeNames="") { $nodeName = (SLS_String::contains($nodeNames,"/")) ? SLS_String::substrAfterLastDelimiter($nodeNames,"/") : ""; $nodeNames = (SLS_String::contains($nodeNames,"/")) ? SLS_String::substrBeforeFirstDelimiter($nodeNames,"/") : strtolower($this->getTable())."s"; $xml->startTag($nodeNames); for($i=0 ; $i<$count=count($recordsets) ; $i++) $xml = $this->toXML($xml,$options,array(),$nodeName,SLS_String::objectToArray($recordsets[$i])); $xml->endTag($nodeNames); return $xml; }