Ejemplo n.º 1
0
 /**
  * Convert an Array to XML
  * @param string $node_name - name of the root node to be converted
  * @param array $arr - aray to be converterd
  * @return DomDocument
  */
 public static function createXML($node_name, $arr = array())
 {
     $xml = self::getXMLRoot();
     $xml->appendChild(self::convert($node_name, $arr));
     self::$xml = null;
     // clear the xml node in the class for 2nd time use.
     return $xml;
 }
Ejemplo n.º 2
0
 /**
  * Get the reviews data map coordinates
  */
 public static function getXMLDataMap($locale = 1)
 {
     $data = array();
     $j = 0;
     $translator = Shineisp_Registry::getInstance()->Zend_Translate;
     $records = Doctrine_Query::create()->from('Reviews r')->leftJoin('r.Products p')->leftJoin("p.ProductsData pd WITH pd.language_id = {$locale}")->where("active = ?", true)->andWhere('latitude <> ?', "")->andWhere('longitude <> ?', "")->execute(array(), Doctrine_Core::HYDRATE_ARRAY);
     foreach ($records as $record) {
         $text = "<div id=\"mycontent\">";
         $text .= "<div id=\"bodyContent\">";
         $text .= "<h4><a href=\"/" . $record['Products']['uri'] . ".html\">" . $record['Products']['ProductsData'][0]['name'] . "</a></h4>";
         for ($i = 0; $i < $record['stars']; $i++) {
             $text .= "*";
         }
         $text .= "<br/><br/>" . $record['review'] . "<br/>";
         $text .= "<p><b>inviato da " . $record['nick'] . "</b> il " . Shineisp_Commons_Utilities::formatDateOut($record['publishedat']) . "</p>";
         $text .= "</div></div>";
         $data['marker'][$j]['@attributes'] = array('lat' => $record['latitude'], 'lng' => $record['longitude']);
         $data['marker'][$j]['text']['@cdata'] = $text;
         $j++;
     }
     $customers = Addresses::getMapCoords();
     foreach ($customers as $record) {
         if (!empty($record['company'])) {
             $text = "";
             #$text = "<div id=\"mycontent\">";
             #$text .= "<div id=\"bodyContent\">";
             #$text .= "<p>". $translator->_('%s has choosen our company as I.T. partners', "<b>" . $record['company']. "</b>") . "</p>";
             #$text .= "</div></div>";
             $data['marker'][$j]['@attributes'] = array('lat' => $record['latitude'], 'lng' => $record['longitude'], 'icontype' => "purple");
             $data['marker'][$j]['text']['@cdata'] = $text;
             $j++;
         }
     }
     $xml = Shineisp_Commons_Array2XML::createXML('markers', $data);
     $xml->save(PUBLIC_PATH . "/documents/reviews.xml");
     return true;
 }