当前位置: 首页>>代码示例>>PHP>>正文


PHP XML_Unserializer::setOption方法代码示例

本文整理汇总了PHP中XML_Unserializer::setOption方法的典型用法代码示例。如果您正苦于以下问题:PHP XML_Unserializer::setOption方法的具体用法?PHP XML_Unserializer::setOption怎么用?PHP XML_Unserializer::setOption使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XML_Unserializer的用法示例。


在下文中一共展示了XML_Unserializer::setOption方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testUtf8ToIso

 /**
  * Test unserializing from UTF-8 to ISO-8859-1
  */
 public function testUtf8ToIso()
 {
     $u = new XML_Unserializer();
     $u->setOption(XML_UNSERIALIZER_OPTION_ENCODING_SOURCE, 'UTF-8');
     $u->setOption(XML_UNSERIALIZER_OPTION_ENCODING_TARGET, 'ISO-8859-1');
     $xml = '<xml>' . utf8_encode('A string containing ü ä Ãê') . '</xml>';
     $u->unserialize($xml);
     $this->assertEquals('A string containing ü ä Ãê', $u->getUnserializedData());
 }
开发者ID:quangbt2005,项目名称:vhost-kis,代码行数:12,代码来源:Unserializer_Option_Encodings_TestCase.php

示例2: testSetterMethod

 /**
  * Test unserializing with a setter method
  */
 public function testSetterMethod()
 {
     $u = new XML_Unserializer();
     $u->setOption(XML_UNSERIALIZER_OPTION_COMPLEXTYPE, 'object');
     $u->setOption(XML_UNSERIALIZER_OPTION_DEFAULT_CLASS, 'Foo');
     $xml = '<SetterExample><foo>tomato</foo></SetterExample>';
     $u->unserialize($xml);
     $result = new SetterExample();
     $result->setFoo('tomato');
     $this->assertEquals($result, $u->getUnserializedData());
 }
开发者ID:pear,项目名称:xml_serializer,代码行数:14,代码来源:Unserializer_ObjectsTest.php

示例3: testIndexed

 /**
  * Test unserializing an indexed array
  */
 public function testIndexed()
 {
     $u = new XML_Unserializer();
     $u->setOption(XML_UNSERIALIZER_OPTION_COMPLEXTYPE, 'array');
     $xml = '<xml><foo>bar</foo><foo>tomato</foo></xml>';
     $u->unserialize($xml);
     $this->assertEquals(array('foo' => array('bar', 'tomato')), $u->getUnserializedData());
 }
开发者ID:pear,项目名称:xml_serializer,代码行数:11,代码来源:Unserializer_ArraysTest.php

示例4: testFloat

 /**
  * Test unserializing a float
  */
 public function testFloat()
 {
     $u = new XML_Unserializer();
     $u->setOption(XML_UNSERIALIZER_OPTION_GUESS_TYPES, true);
     $xml = '<xml>453.54553</xml>';
     $u->unserialize($xml);
     $this->assertEquals(453.54553, $u->getUnserializedData());
     $xml = '<xml>-1.47</xml>';
     $u->unserialize($xml);
     $this->assertEquals(-1.47, $u->getUnserializedData());
 }
开发者ID:pear,项目名称:xml_serializer,代码行数:14,代码来源:Unserializer_Option_GuessTypesTest.php

示例5: randomPerson

function randomPerson()
{
    $dir = 'collectedData';
    $files = glob($dir . '/*.*');
    $file = array_rand($files);
    $us = new XML_Unserializer();
    $options = array(XML_UNSERIALIZER_OPTION_TAG_MAP => array('util' => 'XML_Util'), XML_UNSERIALIZER_OPTION_ATTRIBUTE_CLASS => '_classname');
    $us->setOptions($options);
    $us->setOption(XML_UNSERIALIZER_OPTION_COMPLEXTYPE, 'object');
    $result = $us->unserialize($files[$file], true);
    return $us->_unserializedData;
}
开发者ID:sakonet,项目名称:kunstquiz,代码行数:12,代码来源:random.php

示例6: testKeep

    /**
     * Test keep behaviour
     */
    public function testKeep()
    {
        $u = new XML_Unserializer();
        $u->setOption(XML_UNSERIALIZER_OPTION_WHITESPACE, XML_UNSERIALIZER_WHITESPACE_KEEP);
        $u->unserialize($this->xml);
        $expected = array('string' => '

    This XML
    document
    contains
    line breaks.

   ');
        $this->assertEquals($expected, $u->getUnserializedData());
    }
开发者ID:pear,项目名称:xml_serializer,代码行数:18,代码来源:Unserializer_Option_WhitespaceTest.php

示例7: Decode

 public static function Decode($XMLResponse, &$isFault)
 {
     $responseXML = null;
     try {
         if (empty($XMLResponse)) {
             throw new Exception("Given Response is not a valid SOAP response.");
         }
         $xmlDoc = new XMLReader();
         $res = $xmlDoc->XML($XMLResponse);
         if ($res) {
             $xmlDoc->read();
             $responseXML = $xmlDoc->readOuterXml();
             $xmlDOM = new DOMDocument();
             $xmlDOM->loadXML($responseXML);
             $isFault = trim(strtoupper($xmlDoc->localName)) == self::$FaultMessage;
             if ($isFault) {
                 $xmlDOM->loadXML($xmlDoc->readOuterXml());
             }
             switch ($xmlDoc->nodeType) {
                 case XMLReader::ELEMENT:
                     $nodeName = $xmlDoc->localName;
                     $prefix = $xmlDoc->prefix;
                     if (class_exists($nodeName)) {
                         $xmlNodes = $xmlDOM->getElementsByTagName($nodeName);
                         foreach ($xmlNodes as $xmlNode) {
                             //$xmlNode->prefix = "";
                             $xmlNode->setAttribute("_class", $nodeName);
                             $xmlNode->setAttribute("_type", "object");
                         }
                     }
                     break;
             }
             $responseXML = $xmlDOM->saveXML();
             $unserializer = new XML_Unserializer();
             $unserializer->setOption(XML_UNSERIALIZER_OPTION_COMPLEXTYPE, 'object');
             $res = $unserializer->unserialize($responseXML, false);
             if ($res) {
                 $responseXML = $unserializer->getUnserializedData();
             }
             $xmlDoc->close();
         } else {
             throw new Exception("Given Response is not a valid XML response.");
         }
     } catch (Exception $ex) {
         throw new Exception("Error occurred while XML decoding");
     }
     return $responseXML;
 }
开发者ID:christopherreay,项目名称:freeFreeCrowdfunding_ignitiondeck_crowdfunding,代码行数:48,代码来源:XMLEncoder.php

示例8: showReport

 function showReport($report)
 {
     if (isset($report)) {
         $xml = new \XML_Unserializer();
         $xml->setOption(XML_UNSERIALIZER_OPTION_ATTRIBUTES_PARSE, TRUE);
         $xml->unserialize(__ROOT__ . "/reports/" . $report . ".xml", TRUE);
         if (\PEAR::isError($xml)) {
             die("ERROR: XML : Report Name: " . $report . " : MSG: " . $xml->getMessage());
         }
         $this->XML = $xml->getUnserializedData();
         if (\PEAR::isError($xml)) {
             die("ERROR: XML : Report Name: " . $report . " : MSG: " . $xml->getMessage());
         }
         //Now get the tags we need to show the report info
         foreach ($this->XML as $key => $value) {
             switch ($key) {
                 case 'title':
                     $value = str_replace("\n", "<br>", $value);
                     echo "<br><h1>{$value}</h1>\n";
                     break;
                 case 'description':
                     $value = str_replace("\n", "<br>", $value);
                     echo "<p>{$value}</p>\n";
                     break;
             }
         }
     }
     echo "<br><h1>Previous Report Runs:</h1><br>\n";
     if (isset($report)) {
         $sql = "SELECT * from reporting.report_log\n\t\t\t\tWHERE report_name='" . $report . "'\n\t\t\t\tORDER by report_startts desc";
     } else {
         $sql = "SELECT * from reporting.report_log\n\t\t\t\tORDER by report_startts desc\n\t\t\t\tLIMIT 50";
     }
     $result = run_sql($this->db, $sql);
     echo "\n<table class='log' width='1000px'>\n";
     echo "<tr>\n";
     if ($report == '') {
         echo "<th width='15%'>&nbsp;Report Name</th>\n";
         echo "<th width='20%'>&nbsp;Time Stamp</th>\n";
         echo "<th width='50%'>&nbsp;Parameters</th>\n";
         echo "<th width='15%'>&nbsp;Status</th>\n";
     } else {
         echo "<th width='20%'>&nbsp;Time Stamp</th>\n";
         echo "<th width='65%'>&nbsp;Parameters</th>\n";
         echo "<th width='15%'>&nbsp;Status</th>\n";
         echo "</tr>\n";
     }
     while ($row = db_fetch_assoc($result[0])) {
         echo "<tr>";
         if ($report == '') {
             echo "<td><a href='report_view.php?_report=" . $row['report_name'] . "'>" . $row['report_name'] . "</a></td>\n";
             echo "<td><a href='report_log.php?_report=" . $row['report_name'] . "&_cache=" . $row['report_startts'] . "'>" . $row['report_startts'] . "</a></td>\n";
         } else {
             echo "<td><a href='report_log.php?_report=" . $report . "&_cache=" . $row['report_startts'] . "'>" . $row['report_startts'] . "</a></td>\n";
         }
         echo "<td>" . $row['report_parms'] . "</td>\n";
         if ($row['report_code'] == 0) {
             echo "<td style='{background-color: yellowgreen; vertical-align: top}'>Complete</td></tr>\n";
         } elseif ($row['report_code'] == 4) {
             echo "<td style='background-color: orange; {vertical-align: top}'>Running</td></tr>\n";
         }
     }
     echo "</table>\n";
 }
开发者ID:rjevansatari,项目名称:Analytics,代码行数:64,代码来源:Report_View.php

示例9: Decode

 public static function Decode($SOAPResponse, &$isSOAPFault)
 {
     $responseXML = "";
     try {
         if (empty($SOAPResponse)) {
             throw new Exception("Given Response is not a valid SOAP response.");
         }
         $xmlDoc = new XMLReader();
         $res = $xmlDoc->XML($SOAPResponse);
         if ($res) {
             while (trim(strtoupper($xmlDoc->localName)) != self::$SOAPBody) {
                 $isNotEnd = $xmlDoc->read();
                 if (!$isNotEnd) {
                     break;
                 }
             }
             if (!$isNotEnd) {
                 $isSOAPFault = true;
                 $soapFault = new FaultMessage();
                 $errorData = new ErrorData();
                 $errorData->errorId = 'Given Response is not a valid SOAP response.';
                 $errorData->message = 'Given Response is not a valid SOAP response.';
                 $soapFault->error = $errorData;
                 return $soapFault;
             }
             $responseXML = $xmlDoc->readInnerXml();
             $xmlDOM = new DOMDocument();
             $xmlDOM->loadXML($responseXML);
             $count = 0;
             $xmlDoc->read();
             $isSOAPFault = trim(strtoupper($xmlDoc->localName)) == self::$SOAPFault;
             if ($isSOAPFault) {
                 while (trim(strtoupper($xmlDoc->localName)) != self::$SOAPFaultMessage) {
                     $isNotEnd = $xmlDoc->read();
                     if (!$isNotEnd) {
                         break;
                     }
                 }
                 $xmlDOM->loadXML($xmlDoc->readOuterXml());
             }
             switch ($xmlDoc->nodeType) {
                 case XMLReader::ELEMENT:
                     $nodeName = $xmlDoc->localName;
                     $prefix = $xmlDoc->prefix;
                     if (class_exists($nodeName)) {
                         $xmlNodes = $xmlDOM->getElementsByTagName($nodeName);
                         foreach ($xmlNodes as $xmlNode) {
                             //$xmlNode->prefix = "";
                             $xmlNode->setAttribute("_class", $nodeName);
                             $xmlNode->setAttribute("_type", "object");
                         }
                     }
                     break;
             }
             $responseXML = $xmlDOM->saveXML();
             $unserializer = new XML_Unserializer();
             $unserializer->setOption(XML_UNSERIALIZER_OPTION_COMPLEXTYPE, 'object');
             $res = $unserializer->unserialize($responseXML, false);
             if ($res) {
                 $responseXML = $unserializer->getUnserializedData();
             }
             $xmlDoc->close();
         } else {
             throw new Exception("Given Response is not a valid SOAP response.");
         }
     } catch (Exception $ex) {
         throw $ex;
         throw new Exception("Error occurred while Soap decoding: " . $ex->getMessage());
     }
     return $responseXML;
 }
开发者ID:jobinpankajan,项目名称:WeGive,代码行数:71,代码来源:SOAPEncoder.php

示例10: date

 function __construct($name, $parms)
 {
     $this->reportName = $name;
     $this->setReportTitle();
     $this->csv = $this->reportName . "_" . date('Ymdhis') . ".csv";
     // Parse the report
     $xml = new \XML_Unserializer();
     $xml->setOption(XML_UNSERIALIZER_OPTION_ATTRIBUTES_PARSE, TRUE);
     $xml->unserialize(__ROOT__ . "/reports/" . $this->reportName . ".xml", TRUE);
     if (\PEAR::isError($xml)) {
         die("ERROR: XML : Report Name: " . $this->reportName . " : MSG: " . $xml->getMessage());
     }
     $this->XML = $xml->getUnserializedData();
     if (\PEAR::isError($xml)) {
         die("ERROR: XML : Report Name: " . $this->reportName . " : MSG: " . $xml->getMessage());
     }
     // Check if it has a query
     if (!isset($this->XML['query'])) {
         die("ERROR: XML : Report Name: " . $this->reportName . " : MSG: This report has no query");
     } else {
         $this->batch = FALSE;
         foreach ($this->XML as $key => $value) {
             switch ($key) {
                 case 'query':
                     if (isset($value[0])) {
                         foreach ($value as $index => $query) {
                             $q = new Query($query);
                             $q->setReportName($name);
                             $t = new Table($query);
                             $t->csv = $this->csv;
                             $t->reportName = $this->reportName;
                             $this->queries[$q->name] = $q;
                             $this->tables[$t->name] = $t;
                         }
                     } else {
                         $q = new Query($value);
                         $q->setReportName($name);
                         $t = new Table($value);
                         $t->csv = $this->csv;
                         $t->reportName = $this->reportName;
                         $this->queries[$q->name] = $q;
                         $this->tables[$t->name] = $t;
                     }
                     break;
                 case 'chart':
                     if (isset($value[0])) {
                         foreach ($value as $index => $chart) {
                             $c = new Chart($chart);
                             $this->charts[$c->name] = $c;
                         }
                     } else {
                         $c = new Chart($value);
                         $this->charts[$c->name] = $c;
                     }
                     break;
                 case 'title':
                     $this->title = $value;
                     break;
                 case 'description':
                     $this->description = $value;
                     break;
                 case 'row':
                     if (isset($value[0])) {
                         foreach ($value as $index => $format) {
                             $f = new Format($format);
                             $this->formats[$f->columnName] = $f;
                         }
                     } else {
                         $f = new Format($value);
                         $this->formats[$f->columnName] = $f;
                     }
                     break;
                 case 'column':
                     if (isset($value[0])) {
                         foreach ($value as $index => $format) {
                             $f = new Format($format);
                             $this->formats[$f->columnName] = $f;
                         }
                     } else {
                         $f = new Format($value);
                         $this->formats[$f->columnName] = $f;
                     }
                     break;
                 case 'parm':
                     $this->parms = new ReportParms($this->XML['parm']);
                     $this->parms->setReportName($name);
                     break;
                 case 'batch':
                     $this->batch = TRUE;
                     break;
             }
         }
     }
     foreach ($this->tables as $key => $value) {
         $value->formats = $this->formats;
     }
     if (isset($this->charts)) {
         foreach ($this->charts as $key => $value) {
             $value->formats = $this->formats;
         }
//.........这里部分代码省略.........
开发者ID:rjevansatari,项目名称:Analytics,代码行数:101,代码来源:Report_Class.php

示例11: viewList

 /**
  * 一覧表示
  */
 private function viewList(sfWebRequest $request, sfWebBrowser $b, $module_name)
 {
     $options = array('complexType' => 'array', 'parseAttributes' => TRUE);
     $Unserializer = new XML_Unserializer();
     $Unserializer->setOption('parseAttributes', TRUE);
     $status = $Unserializer->unserialize($b->getResponseText());
     $this->list = $Unserializer->getUnserializedData();
     //検索結果が一件の場合
     if (count($this->list['Response']['Placemark']) >= 1 && $this->list['Response']['Placemark']['id']) {
         sfApplicationConfiguration::getActive()->loadHelpers('geocodeParser');
         $result = geocodeParser($this->list['Response']['Placemark']);
         $this->display_address = $result['address'];
         $request->setParameter('address', $result['address']);
         $request->setParameter('lon', $result['lon']);
         $request->setParameter('lat', $result['lat']);
         $this->setTemplate($module_name);
     } else {
         $this->module_name = $module_name;
         $this->setTemplate('searchList');
     }
 }
开发者ID:pontuyo,项目名称:takutomo-mixi-appli,代码行数:24,代码来源:actions.class.php

示例12: loadValues

 /**
  * 連想配列の取得
  *
  * <pre>
  * PHPの連想配列を指定すればそのまま、ファイルパスを指定すれば
  * 設定ファイルから読み込み連想配列として渡します。
  * またURLのクエリー形式も使用できます。
  * BEARで広く使われています。BEARの全てのクラスのコンストラクタ
  * (シングルトン含む)、リソースへの引数、
  * オプションにこの連想配列フォーマットが使われます。
  *
  * array -- 連想配列としてオプションが入力されます
  *
  * string -- ファイルから拡張子によりフォーマットが異なります
  *  URLクエリー形式 ?foo1=bar1&hoge=fugaのようなフォーマットを連想配列にします
  *  *.ini iniフォーマット
  *  *.xml XMLフォーマット
  *  *.php phpのdefineが連想配列として読み込まれます
  *  *.yml yamlファイル
  *
  * $options
  * 'extention' string オーバーロード拡張子
  * </pre>
  *
  * @param mixed $target  ターゲット ファイルパス,URLなど
  * @param array $options オプション
  *
  * @return array
  *
  * @see http://pear.php.net/manual/ja/package.configuration.config.php
  * @see BEAR/test/files/example.ini
  * @see BEAR/test/files/example.xml
  * @see BEAR/test/files/example.php
  * @throws BEAR_Exception
  */
 public static function loadValues($target, $options = array())
 {
     if (!is_file((string) $target)) {
         // arrayならそのまま
         if (is_array($target) || is_object($target)) {
             return (array) $target;
         }
         // false | null なら 設定な
         if (!$target) {
             return null;
         }
         // クエリーがあるときはクエリーをパースした連想配列を返す
         $parseUrl = parse_url($target);
         if (isset($parseUrl['query'])) {
             $options = array();
             parse_str($parseUrl['query'], $options);
             return $options;
         } else {
             return null;
         }
     } else {
         $cache = self::factory('BEAR_Cache');
         $cache->setLife(BEAR_Cache::LIFE_UNLIMITED);
         $key = $target . filemtime($target);
         $cacheResult = $cache->get($key);
         if ($cacheResult) {
             return $cacheResult;
         }
         // PEAR::Configを使って設定ファイルをパース
         $pathinfo = pathinfo($target);
         // 相対パスなら絶対パスに (/:linux :win)
         $target = substr($target, 0, 1) == '/' || substr($target, 1, 1) == ':' ? $target : _BEAR_APP_HOME . '/App/Ro/' . $target;
         $extension = isset($options['extention']) ? $options['extention'] : $pathinfo['extension'];
         switch ($extension) {
             case 'yml':
                 if (function_exists('syck_load')) {
                     $content = file_get_contents($target);
                     $yaml = syck_load($content);
                 } else {
                     include_once 'BEAR/vendors/spyc-0.2.5/spyc.php';
                     $yaml = Spyc::YAMLLoad($target);
                 }
                 $cache->set($key, $yaml);
                 return $yaml;
             case 'csv':
                 $conf = File_CSV::discoverFormat($target);
                 $csv = array();
                 while ($fields = File_CSV::read($target, $conf)) {
                     array_push($csv, $fields);
                 }
                 $result = $cache->set($key, $csv);
                 return $csv;
             case 'ini':
                 $parse = 'inicommented';
                 break;
             case 'xml':
                 $unserializer = new XML_Unserializer();
                 $unserializer->setOption('parseAttributes', true);
                 $xml = file_get_contents($target);
                 $unserializer->unserialize($xml);
                 $result = $unserializer->getUnserializedData();
                 return $result;
                 break;
             case 'php':
                 $parse = 'PHPConstants';
//.........这里部分代码省略.........
开发者ID:ryo88c,项目名称:BEAR.Saturday,代码行数:101,代码来源:BEAR.php


注:本文中的XML_Unserializer::setOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。