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


PHP Xml::build方法代码示例

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


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

示例1: parseRss

 public function parseRss()
 {
     $channel = Xml::toArray(Xml::build($this->args[0])->channel);
     $items = $channel['channel']['item'];
     $list = $this->PinterestPin->find('list', array('fields' => array('id', 'guid')));
     $data = array();
     foreach ($items as $item) {
         if (!in_array($item['guid'], $list)) {
             $html = file_get_html($item['guid']);
             $image = $html->find('img.pinImage', 0);
             if (is_object($image)) {
                 $data[] = array('guid' => $item['guid'], 'title' => $item['title'], 'image' => $image->attr['src'], 'description' => strip_tags($item['description']), 'created' => date('Y-m-d H:i:s', strtotime($item['pubDate'])));
             }
         }
     }
     if (!empty($data)) {
         if ($this->PinterestPin->saveAll($data)) {
             $this->out(__d('pinterest', '<success>All records saved sucesfully.</success>'));
             return true;
         } else {
             $this->err(__d('pinterest', 'Cannot save records.'));
             return false;
         }
     }
     $this->out(__d('pinterest', '<warning>No records saved.</warning>'));
 }
开发者ID:adderall,项目名称:CakePHP-Pinterest-Plugin,代码行数:26,代码来源:PinterestShell.php

示例2: view_development

 /**
  * @param string $feedID
  * @return array|bool|null
  */
 public function view_development($feedID = '')
 {
     if ($feedID != '') {
         if (Configure::read('globals.developmentfeed.' . $feedID) != null) {
             $feedDetails = Configure::read('globals.developmentfeed.' . $feedID);
             $this->feedURL = $feedDetails[0];
         } else {
             return false;
         }
     }
     $parsedXML = Xml::build($this->feedURL);
     // xml to array conversion
     $this->rssItem = Xml::toArray($parsedXML);
     //pr($this->rssItem);
     $feedInfo = $this->rssItem['feed'];
     $data = $this->rssItem['feed']['entry'];
     //pr($feedInfo);
     //pr($data);
     if ($this->request->is('requested')) {
         return array($feedInfo, $data);
     } else {
         $this->set('feedInfo', $feedInfo);
         $this->set('data', $data);
     }
     return null;
 }
开发者ID:sh1omi,项目名称:xlrstats-web-v3,代码行数:30,代码来源:FeedsController.php

示例3: serializeXmlToArray

 /**
  * Serialize to array data from xml
  *
  * @param array $url url
  * @return array Xml serialize array data
  */
 public function serializeXmlToArray($url)
 {
     $xmlData = Xml::toArray(Xml::build($url));
     // rssの種類によってタグ名が異なる
     if (isset($xmlData['feed'])) {
         $items = Hash::get($xmlData, 'feed.entry');
         $dateKey = 'published';
         $linkKey = 'link.@href';
         $summaryKey = 'summary';
     } elseif (Hash::get($xmlData, 'rss.@version') === '2.0') {
         $items = Hash::get($xmlData, 'rss.channel.item');
         $dateKey = 'pubDate';
         $linkKey = 'link';
         $summaryKey = 'description';
     } else {
         $items = Hash::get($xmlData, 'RDF.item');
         $dateKey = 'dc:date';
         $linkKey = 'link';
         $summaryKey = 'description';
     }
     if (!isset($items[0]) && is_array($items)) {
         $items = array($items);
     }
     $data = array();
     foreach ($items as $item) {
         $date = new DateTime($item[$dateKey]);
         $summary = Hash::get($item, $summaryKey);
         $data[] = array('title' => $item['title'], 'link' => Hash::get($item, $linkKey), 'summary' => $summary ? strip_tags($summary) : '', 'last_updated' => $date->format('Y-m-d H:i:s'), 'serialize_value' => serialize($item));
     }
     return $data;
 }
开发者ID:Onasusweb,项目名称:RssReaders,代码行数:37,代码来源:RssReaderItem.php

示例4: xml2Config

    /**
     * Parses XML files into config files
     * @access public 
     * @static
     * @param string $path 
     *
     */
    public static function xml2Config($path){
        
        foreach(scandir($path) as $file){
            $ext = pathinfo($file, PATHINFO_EXTENSION);

            //Skip file if it's not XML
            if(strtolower($ext) !== 'xml') {
                continue;
            }
            
            if(is_file($path . DS . $file)){
                
                $xmlData = Xml::toArray(Xml::build($path . DS . $file));
                
                $outFile = 
                    ROOT . DS . APP_DIR . DS . 'Config' . DS . 'Includes' . DS . str_replace('.xml', '.php', $file);
                
                $configureString = "<?php\n";

                foreach($xmlData['root'] as $key => $value){
                    $val = empty($value['value'])?$value['default']:$value['value'];
                    $decoded = htmlspecialchars_decode($val, ENT_QUOTES);
                    $configureString .= "Configure::write('{$value['name']}', {$decoded});\n";
                }
                
                file_put_contents ($outFile , $configureString);
            }
            
        }
        
    }
开发者ID:42northgroup,项目名称:42Viral,代码行数:38,代码来源:Parser.php

示例5: wordpress

 public function wordpress()
 {
     if ($this->request->is('post')) {
         /*
          * validate file upload
          */
         $this->CloggyValidation->set($this->request->data['CloggyBlogImport']);
         $this->CloggyValidation->validate = array('wordpress_xml' => array('ext' => array('rule' => array('extension', array('xml')), 'message' => __d('cloggy', 'You must upload xml file'))));
         if ($this->CloggyValidation->validates()) {
             /*
              * setup import files
              */
             $this->__CloggyFileUpload->settings(array('allowed_types' => array('xml'), 'field' => 'wordpress_xml', 'data_model' => 'CloggyBlogImport', 'folder_dest_path' => APP . 'Plugin' . DS . 'Cloggy' . DS . 'webroot' . DS . 'uploads' . DS . 'CloggyBlog' . DS . 'import' . DS));
             //upload xml
             $this->__CloggyFileUpload->proceedUpload();
             //check error upload
             $checkUploadError = $this->__CloggyFileUpload->isError();
             /*
              * if error then back to original view
              * if not then render new view, continue with download and import
              * data and files
              */
             if ($checkUploadError) {
                 $this->set('error', $this->__CloggyFileUpload->getErrorMsg());
             } else {
                 $xmlUploadedData = $this->__CloggyFileUpload->getUploadedData();
                 $xmlFile = $xmlUploadedData['dirname'] . DS . $xmlUploadedData['basename'];
                 //read wordpress xml data
                 $xml = Xml::toArray(Xml::build($xmlFile));
                 /*
                  * if option enabled
                  */
                 if (isset($this->request->data['CloggyBlogImport']['wordpress_import_options'])) {
                     $this->__CloggyBlogImport->setupOptions($this->request->data['CloggyBlogImport']['wordpress_import_options']);
                 }
                 //setup imported data
                 $this->__CloggyBlogImport->setupData($xml);
                 //genereate adapter
                 $this->__CloggyBlogImport->generate();
                 /*
                  * check if given data is valid based on adapter
                  */
                 $checkValidData = $this->__CloggyBlogImport->isValidImportedData();
                 if ($checkValidData) {
                     $checkImport = $this->__CloggyBlogImport->import();
                     if ($checkImport) {
                         $this->Session->setFlash(__d('cloggy', 'Data imported'), 'default', array(), 'success');
                     }
                 } else {
                     $this->set('error', __d('cloggy', 'Given data is not valid.'));
                 }
             }
         } else {
             $this->set('errors', $this->CloggyValidation->validationErrors);
         }
     }
     $this->set('title_for_layout', __d('cloggy', 'Import Post From Wordpress'));
 }
开发者ID:simaostephanie,项目名称:Cloggy,代码行数:58,代码来源:CloggyBlogImportController.php

示例6: admin_add

 function admin_add()
 {
     $Http = new HttpSocket();
     $response = $Http->get('https://www.google.com/accounts/o8/site-xrds?hd=' . $this->__getDomain());
     $response = Set::reverse(Xml::build($response->body));
     $endpoint = $response['XRDS']['XRD']['Service'][0]['URI'];
     $query = array('openid.mode' => 'checkid_setup', 'openid.ns' => 'http://specs.openid.net/auth/2.0', 'openid.return_to' => Router::url(array('plugin' => 'google_session', 'controller' => 'google_session', 'action' => 'callback', 'admin' => true), true), 'openid.ui.mode' => 'popup', 'openid.ns.ax' => 'http://openid.net/srv/ax/1.0', 'openid.ax.mode' => 'fetch_request', 'openid.ax.required' => 'email,firstname,lastname', 'openid.ax.type.email' => 'http://schema.openid.net/contact/email', 'openid.ax.type.firstname' => 'http://axschema.org/namePerson/first', 'openid.ax.type.lastname' => 'http://axschema.org/namePerson/last', 'openid.claimed_id' => 'http://specs.openid.net/auth/2.0/identifier_select', 'openid.identity' => 'http://specs.openid.net/auth/2.0/identifier_select', 'hq' => $this->__getDomain());
     $this->redirect($endpoint . (strpos($endpoint, '?') ? '&' : '?') . http_build_query($query));
 }
开发者ID:rodrigorm,项目名称:google_session,代码行数:9,代码来源:GoogleSessionController.php

示例7: _parseXml

 /**
  * Parse xml
  *
  * @return array
  */
 protected static function _parseXml($file)
 {
     $xml = Xml::build($file);
     $res = Xml::toArray($xml);
     if (!empty($res['xss']['attack'])) {
         return (array) $res['xss']['attack'];
     }
     return [];
 }
开发者ID:ByMyHandsOnly,项目名称:BMHO_Web,代码行数:14,代码来源:HazardLib.php

示例8: __construct

 /**
  * Constructor
  * 
  * @param array $config
  * @param HttpSourceConnection $Connection
  * @throws RuntimeException
  */
 public function __construct($config = array(), HttpSourceConnection $Connection = null)
 {
     parent::__construct($config, $Connection);
     $this->setDecoder('text/html', function (HttpSocketResponse $HttpSocketResponse) {
         $Xml = Xml::build((string) $HttpSocketResponse);
         $response = Xml::toArray($Xml);
         return $response;
     }, true);
 }
开发者ID:imsamurai,项目名称:cakephp-sms-fly-datasource,代码行数:16,代码来源:SMSFlySource.php

示例9: getPrototypes

 public function getPrototypes()
 {
     $searchdirs['App'] = APP . 'View';
     $searchdirs['Basic'] = CakePlugin::path('Muffin');
     foreach (CakePlugin::loaded() as $plugin) {
         if ($plugin != 'Muffin') {
             $searchdirs[$plugin] = CakePlugin::path($plugin) . 'View';
         }
     }
     $configs = array();
     foreach ($searchdirs as $plugin => $searchdir) {
         $dir = new Folder($searchdir, false);
         if ($files = $dir->findRecursive('config.xml')) {
             $configs = Hash::merge($configs, array($plugin => $files));
         }
     }
     $prototypes = array();
     foreach ($configs as $plugin => $configFiles) {
         $i = 0;
         foreach ($configFiles as $configFile) {
             $xml = Xml::build($configFile);
             $items = $xml->xpath('menu/item');
             if (!is_array($items) || empty($items)) {
                 continue;
             }
             foreach ($items as $item) {
                 $item = Xml::toArray($item);
                 if (empty($item['item']['@label'])) {
                     continue;
                 }
                 if (!isset($item['item']['@id']) || empty($item['item']['@id'])) {
                     $id = ucfirst(Inflector::variable($item['item']['@label']));
                 } else {
                     $id = $item['item']['@id'];
                 }
                 $fields = array();
                 foreach ($item['item']['field'] as $key => $field) {
                     foreach ($field as $name => $value) {
                         $name = str_replace('@', '', $name);
                         $fields[$key][$name] = $value;
                     }
                 }
                 $prototypes[$plugin][$i]['Link']['id'] = $id;
                 $prototypes[$plugin][$i]['Link']['priority'] = !empty($item['item']['@priority']) ? $item['item']['@priority'] : '10';
                 $prototypes[$plugin][$i]['Link']['model'] = !empty($item['item']['@model']) ? $item['item']['@model'] : '';
                 $prototypes[$plugin][$i]['Link']['label'] = $item['item']['@label'];
                 $prototypes[$plugin][$i]['Field'] = $fields;
                 $i++;
             }
         }
     }
     foreach ($prototypes as $plugin => $section) {
         $prototypes[$plugin] = Hash::sort($section, '{n}.Link.priority', 'asc');
     }
     return $prototypes;
 }
开发者ID:mindforce,项目名称:cakephp-front-engine,代码行数:56,代码来源:LinksComponent.php

示例10: genericDataExtractor

 public function genericDataExtractor($data)
 {
     $output = array();
     $method = $data['method'];
     $result = $this->http->{$method}($data['url'], $data['data'], $data['request']);
     if ($result->body != "") {
         $xmlArray = Xml::toArray(Xml::build($result->body));
         $output['result'] = Hash::extract($xmlArray, $data['path']);
         $output['array'] = $xmlArray;
     }
     return $output;
 }
开发者ID:raghavb1,项目名称:overseer_ravello,代码行数:12,代码来源:Ravello.php

示例11: testByAtom

 /**
  * Expect RssReaderItem->serializeXmlToArray() by atom format
  *
  * @return void
  */
 public function testByAtom()
 {
     $url = APP . 'Plugin' . DS . 'RssReaders' . DS . 'Test' . DS . 'Fixture' . DS . 'rss_atom.xml';
     //テスト実施
     $result = $this->RssReaderItem->serializeXmlToArray($url);
     //期待値
     $xmlData = Xml::toArray(Xml::build($url));
     $items = Hash::get($xmlData, 'feed.entry');
     $serializeValue = isset($items[0]) && is_array($items[0]) ? $items[0] : $items;
     $expected = array(array('title' => 'content title', 'link' => 'http://example.com/1.html', 'summary' => 'content description', 'last_updated' => '2015-03-13 17:07:41', 'serialize_value' => serialize($serializeValue)));
     $this->assertEquals($result, $expected);
 }
开发者ID:Onasusweb,项目名称:RssReaders,代码行数:17,代码来源:RssReaderItemSerializeXmlToArrayTest.php

示例12: getTweets

 public function getTweets($q)
 {
     App::uses('Xml', 'Utility');
     $output = array();
     $this->searchURL = 'http://search.twitter.com/search.atom?page=' . $this->settings['page'] . '&lang=' . $this->settings['lang'] . '&rpp=' . $this->settings['rpp'] . '&q=';
     $ch = curl_init($this->searchURL . urlencode($q));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
     $response = curl_exec($ch);
     $xmlResult = Xml::toArray(Xml::build($response));
     curl_close($ch);
     return $xmlResult;
 }
开发者ID:huanjian,项目名称:mythesis,代码行数:13,代码来源:MyTwitterComponent.php

示例13: testRenderWithoutViewMultiple

 /**
  * Test render with an array in _serialize
  *
  * @return void
  */
 public function testRenderWithoutViewMultiple()
 {
     $Request = new CakeRequest();
     $Response = new CakeResponse();
     $Controller = new Controller($Request, $Response);
     $data = array('no' => 'nope', 'user' => 'fake', 'list' => array('item1', 'item2'));
     $Controller->set($data);
     $Controller->set('_serialize', array('no', 'user'));
     $View = new XmlView($Controller);
     $output = $View->render(false);
     $expected = array('response' => array('no' => $data['no'], 'user' => $data['user']));
     $this->assertIdentical(Xml::build($expected)->asXML(), $output);
     $this->assertIdentical('application/xml', $Response->type());
 }
开发者ID:MrGrigorev,项目名称:reserva-de-salas,代码行数:19,代码来源:XmlViewTest.php

示例14: __construct

 public function __construct($id = false, $table = null, $ds = null)
 {
     parent::__construct($id, $table, $ds);
     $datasource = ConnectionManager::getDataSource($this->useDbConfig);
     //$datasource = ConnectionManager::loadDataSource('SalesforceSource');
     if ($datasource->_baseConfig['dynamic_mode']) {
         $this->_schema = $datasource->getSchema($this->name);
     } else {
         if (!empty($datasource->_baseConfig['my_wsdl'])) {
             $wsdl = APP . "Config" . DS . $datasource->_baseConfig['my_wsdl'];
         } else {
             $wsdl = App::Path('Vendor')[0] . 'salesforce/soapclient/' . $datasource->_baseConfig['standard_wsdl'];
         }
         $database_fields = Xml::toArray(Xml::build($wsdl));
         $schemas = $database_fields['definitions']['types']['schema'][0]['complexType'];
         $this_wsdl_schema = array();
         foreach ($schemas as $schema) {
             if ($schema['@name'] == $this->name) {
                 $this_wsdl_schema = $schema['complexContent']['extension']['sequence']['element'];
                 break;
             }
         }
         $names = Hash::extract($this_wsdl_schema, '{n}.@name');
         $types = Hash::extract($this_wsdl_schema, '{n}.@type');
         $new_array = array('Id' => array('type' => 'string', 'length' => 16));
         $n = 0;
         $type_name = "";
         foreach ($names as $name) {
             if (substr($types[$n], 0, 3) != "ens") {
                 //we dont want type of ens
                 if (substr($types[$n], 4) != "QueryResult") {
                     //Or this
                     if (substr($types[$n], 4) == "int") {
                         $type_name = "integer";
                     } elseif (substr($types[$n], 4) == "boolean") {
                         $type_name = "boolean";
                     } elseif (substr($types[$n], 4) == "dateTime" || substr($types[$n], 4) == "date") {
                         $type_name = "datetime";
                     } else {
                         $type_name = "string";
                     }
                     $new_array[$name] = array('type' => $type_name, 'length' => 255);
                 }
             }
             $n++;
         }
         $this->_schema = $new_array;
     }
     return true;
 }
开发者ID:richardvella,项目名称:Salesforce-Enterprise-API-CakePHP-2.x-Plugin,代码行数:50,代码来源:Salesforce.php

示例15: getPluginData

 /**
  * Get plugin information
  *
  * @return array
  */
 public static function getPluginData()
 {
     $dir = new Folder(APP . 'Plugin');
     $files = $dir->read(true, ['empty']);
     $plugins = [];
     foreach ($files[0] as $folder) {
         $file = new File(APP . 'Plugin' . DS . $folder . DS . 'Config' . DS . 'info.xml');
         if ($file->exists()) {
             $fileContent = $file->read();
             $plugin = Xml::toArray(Xml::build($fileContent));
             $plugins[$folder] = $plugin['plugin'];
         }
     }
     return $plugins;
 }
开发者ID:hurad,项目名称:hurad,代码行数:20,代码来源:HuradPlugin.php


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