Ejemplo n.º 1
0
Archivo: RssDas.php Proyecto: psagi/sdo
 /**
  * To XML
  *
  * @param SDO $sdo SDO
  *
  * @return string
  */
 public static function toXml($sdo)
 {
     $type = $sdo->getTypeName();
     $xmldas = self::getXmlDas();
     $xdoc = $xmldas->createDocument('', $type, $sdo);
     $xmlstr = $xmldas->saveString($xdoc);
     return $xmlstr;
 }
Ejemplo n.º 2
0
Archivo: index.php Proyecto: rik/tuxedo
        return $fallback['prevent_global_fallback'];
    } else {
        return false;
    }
}
// if we don't have an os, make it windows, playing the odds
if (empty($_GET['os'])) {
    $_GET['os'] = 'win';
}
// do we even have a product?
if (!empty($_GET['product'])) {
    // clean in os and product strings
    $os_name = trim(strtolower($_GET['os']));
    $product_name = trim(strtolower($_GET['product']));
    require_once LIB . '/sdo.php';
    $sdo = new SDO();
    // if we got a language, query for it, otherwise get US English
    if (!empty($_GET['lang'])) {
        $where_lang = $_GET['lang'];
    } else {
        $where_lang = 'en-US';
    }
    // get OS ID
    $os_id = $sdo->name_to_id('mirror_os', 'id', 'name', $os_name);
    // get product for this language (if applicable)
    $buf = $sdo->get_one("\n        SELECT prod.id FROM mirror_products AS prod\n        LEFT JOIN mirror_product_langs AS langs ON (prod.id = langs.product_id)\n        WHERE prod.name LIKE '%s'\n        AND (langs.language LIKE '%s' OR langs.language IS NULL)", array($product_name, $where_lang), MYSQL_NUM);
    if (!empty($buf[0])) {
        $product_id = $buf[0];
    } else {
        $product_id = null;
    }
Ejemplo n.º 3
0
Archivo: Das.php Proyecto: psagi/sdo
 /**
  * Makes the decision on how the PHP object should be copied
  * and recurse as necessary
  *
  * @param string $item_name Name
  * @param string $item      Item
  * @param SDO    $sdo       SDO
  *
  * @return null
  */
 protected function decodeToSDOTyped($item_name, $item, $sdo)
 {
     $item_type = $this->gettype($item);
     // SCA::$logger->log( "Typed - Name: " . $item_name .  " Type: ". $item_type . "\n");
     if ($item_type == "object") {
         $new_sdo = $sdo->createDataObject($item_name);
         $this->decodeObjectToSDOTyped($item, $new_sdo);
     } else {
         if ($item_type == "array") {
             //$new_sdo = $sdo->createDataObject($item_name);
             $this->decodeArrayToSDOTyped($item_name, $item, $sdo);
         } else {
             $sdo[$item_name] = $item;
         }
     }
 }
Ejemplo n.º 4
0
Archivo: Proxy.php Proyecto: psagi/sdo
 /**
  * NOTE: there is a problem with this process - it generates the elements
  * as attributes with values rather than elements, so when they are unpacked on the other side and converted back to an sdo, the values are lost and only the 'attributes' are part of the sdo.
  *
  * @param SDO   $sdo SDO
  * @param mixed $xsd XSD
  *
  * @return mixed
  */
 protected function toXml($sdo, $xsd = null)
 {
     SCA::$logger->log("Entering");
     try {
         $type = $sdo->getTypeName();
         $xmldas = SDO_DAS_XML::create(dirname(__FILE__) . '/Atom1.0.xsd');
         /*
         //Because the atom format is extensible, if the sdo contains an extended version of the entry type, then we will need to add the types belonging to the sdo we've just received. Code here for this is commented out for now, and the assumed solution is that the client would provide the xsd for the extended entry, so that we can add the types from it to the Atom model.
         //Without an xsd supplied, if you try to create an xml doc from an sdo which has properties that arent in the das, SDO will try to handle what it receives by making the properties in the sdo attributes in the xml doc (rather than elements) but it should probably be throwing an error instead. Working on testcases to explore this behaviour further and raise a defect around this.
         //so the question is how do we get the types for the sdo? Going to have to ask for the location of an xsd to be passed in with the sdo, at least for first version of this code.
         //TODO need to make sure we are finding the xsd however they express the path information.
         //$xmldas->addTypes($xsd);
         */
         $xdoc = $xmldas->createDocument('', $type, $sdo);
         $xmlstr = $xmldas->saveString($xdoc);
         return $xmlstr;
     } catch (Exception $e) {
         return $e->getMessage();
     }
 }
Ejemplo n.º 5
0
 /**
  * To XML
  *
  * @param SDO $sdo SDO
  *
  * @return mixed
  */
 protected function toXml($sdo)
 {
     try {
         //get the type of the sdo eg. 'Contact', to avoid using 'BOGUS'
         $type = $sdo->getTypeName();
         SCA::$logger->log("type is {$type}");
         $xmldas = SDO_DAS_XML::create(dirname(__FILE__) . '/Atom1.0.xsd');
         $xdoc = $xmldas->createDocument('', $type, $sdo);
         $xmlstr = $xmldas->saveString($xdoc);
         return $xmlstr;
     } catch (Exception $e) {
         SCA::$logger->log("Found exception in AtomServer: " . $e->getMessage() . "\n");
         return $e->getMessage();
     }
 }
Ejemplo n.º 6
0
Archivo: Server.php Proyecto: psagi/sdo
 /**
  * To XML
  *
  * @param SDO $sdo SDO
  *
  * @return mixed
  */
 protected function toXml($sdo)
 {
     try {
         $type = $sdo->getTypeName();
         $xdoc = $this->xml_das->createDocument('', $type, $sdo);
         $xmlstr = $this->xml_das->saveString($xdoc);
         return $xmlstr;
     } catch (Exception $e) {
         SCA::$logger->log("Found exception in SCA_Bindings_restrpc_Server " . "converting sdo to xml" . $e->getMessage() . "\n");
         return $e->getMessage();
     }
 }