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


PHP XMLParser::parseTextStruct方法代码示例

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


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

示例1: parseEmails

 /**
  * Parse into structures the XML contents of an email data file.
  * @param $contents string
  * @return array
  */
 function parseEmails($contents)
 {
     $parser = new XMLParser();
     $result = $parser->parseTextStruct($contents, array('email_text', 'subject', 'body'));
     $parser->destroy();
     return $result;
 }
开发者ID:laelnasan,项目名称:UTFPR-ojs,代码行数:12,代码来源:genEmailUpdates.php

示例2: solrQuery

 function solrQuery(&$xmlDoc)
 {
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $this->getSetting('solrUrl') . '/update');
     curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-type:text/xml; charset=utf-8"));
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, XMLCustomWriter::getXml($xmlDoc));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $data = curl_exec($ch);
     if (curl_errno($ch)) {
         curl_close($ch);
         fatalError('CURL Error: ' . curl_error($ch));
     } else {
         curl_close($ch);
         $xmlParser = new XMLParser();
         $result = null;
         @($result =& $xmlParser->parseTextStruct($data, array("int")));
         if ($result) {
             foreach ($result as $nodeSet) {
                 foreach ($nodeSet as $node) {
                     if (isset($node['attributes']['name']) && $node['attributes']['name'] == 'status' && $node['value'] == 0) {
                         return true;
                     }
                 }
             }
         }
         return false;
     }
 }
开发者ID:ramonsodoma,项目名称:harvester,代码行数:30,代码来源:ZendSearchPlugin.inc.php

示例3: searchResults

 /**
  * Display search results.
  */
 function searchResults()
 {
     ZendSearchHandler::setupTemplate();
     $plugin =& PluginRegistry::getPlugin('generic', 'ZendSearchPlugin');
     $isUsingSolr = $plugin->isUsingSolr();
     if ($isUsingSolr) {
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $plugin->getSetting('solrUrl') . '/select');
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_TIMEOUT, 10);
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
         curl_setopt($ch, CURLOPT_ENCODING, '');
         curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
         curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, 0);
         curl_setopt($ch, CURLOPT_POST, 1);
         $query = '';
     } else {
         $index =& $plugin->getIndex();
         $query = new Zend_Search_Lucene_Search_Query_Boolean();
     }
     $q = Request::getUserVar('q');
     if (!empty($q)) {
         if ($isUsingSolr) {
             $query .= 'text:"' . ZendSearchHandler::luceneEscape($q) . '" ';
         } else {
             $query->addSubquery(Zend_Search_Lucene_Search_QueryParser::parse($q));
         }
     }
     $searchFormElementDao =& DAORegistry::getDAO('SearchFormElementDAO');
     $searchFormElements =& $searchFormElementDao->getSearchFormElements();
     while ($searchFormElement =& $searchFormElements->next()) {
         $searchFormElementId = $searchFormElement->getSearchFormElementId();
         $symbolic = $searchFormElement->getSymbolic();
         switch ($searchFormElement->getType()) {
             case SEARCH_FORM_ELEMENT_TYPE_SELECT:
             case SEARCH_FORM_ELEMENT_TYPE_STRING:
                 $term = Request::getUserVar($symbolic);
                 if (!empty($term)) {
                     if ($isUsingSolr) {
                         $query .= $symbolic . ':"' . ZendSearchHandler::luceneEscape($term) . '" ';
                     } else {
                         $query->addSubquery(new Zend_Search_Lucene_Search_Query_Term(new Zend_Search_Lucene_Index_Term($term, $symbolic)), true);
                     }
                 }
                 break;
             case SEARCH_FORM_ELEMENT_TYPE_DATE:
                 $from = Request::getUserDateVar($symbolic . '-from');
                 $to = Request::getUserDateVar($symbolic . '-to');
                 if (!empty($from) && !empty($to)) {
                     if ($isUsingSolr) {
                         $query .= $symbolic . ':[' . strftime('%Y-%m-%dT%H:%M:%SZ', $from) . ' TO ' . strftime('%Y-%m-%dT%H:%M:%SZ', $to) . '] ';
                     } else {
                         $fromTerm = new Zend_Search_Lucene_Index_Term($from, $symbolic);
                         $toTerm = new Zend_Search_Lucene_Index_Term($to, $symbolic);
                         $query->addSubquery(new Zend_Search_Lucene_Search_Query_Range($fromTerm, $toTerm, true), true);
                     }
                 }
                 break;
             default:
                 fatalError('Unknown element type!');
         }
         unset($searchFormElement);
     }
     $rangeInfo =& PKPHandler::getRangeInfo('results');
     if ($isUsingSolr) {
         $itemsPerPage = Config::getVar('interface', 'items_per_page');
         curl_setopt($ch, CURLOPT_POSTFIELDS, 'q=' . trim(urlencode($query)) . '&rows=' . urlencode($itemsPerPage) . ($rangeInfo ? '&start=' . $rangeInfo->getPage() * $itemsPerPage : ''));
         $data = curl_exec($ch);
         $xmlParser = new XMLParser();
         $result = null;
         $numFound = 0;
         @($result =& $xmlParser->parseTextStruct($data, array('str', 'result')));
         $recordIds = array();
         if ($result) {
             foreach ($result as $nodeSet) {
                 foreach ($nodeSet as $node) {
                     if (isset($node['attributes']['name']) && $node['attributes']['name'] == 'id') {
                         $recordIds[] = $node['value'];
                     } elseif (isset($node['attributes']['numFound'])) {
                         $numFound = $node['attributes']['numFound'];
                     }
                 }
             }
         }
         $plugin->import('SolrResultIterator');
         $resultsIterator =& SolrResultIterator::fromRangeInfo($recordIds, $numFound, $rangeInfo);
         unset($recordIds);
     } else {
         $resultsArray = $index->find($query);
         $plugin->import('ZendSearchResultIterator');
         $resultsIterator =& ZendSearchResultIterator::fromRangeInfo($resultsArray, $rangeInfo);
         unset($resultsArray);
     }
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign_by_ref('recordDao', DAORegistry::getDAO('RecordDAO'));
     $templateMgr->assign_by_ref('results', $resultsIterator);
     $templateMgr->assign_by_ref('q', $q);
//.........这里部分代码省略.........
开发者ID:jalperin,项目名称:harvester,代码行数:101,代码来源:ZendSearchHandler.inc.php


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