|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00036 abstract class Zend_Service_Technorati_Result 00037 { 00044 protected $_fields; 00045 00052 protected $_dom; 00053 00060 protected $_xpath; 00061 00062 00070 public function __construct(DomElement $dom) 00071 { 00072 $this->_xpath = new DOMXPath($dom->ownerDocument); 00073 $this->_dom = $dom; 00074 00075 // default fields for all search results 00076 $fields = array(); 00077 00078 // merge with child's object fields 00079 $this->_fields = array_merge($this->_fields, $fields); 00080 00081 // add results to appropriate fields 00082 foreach($this->_fields as $phpName => $xmlName) { 00083 $query = "./$xmlName/text()"; 00084 $node = $this->_xpath->query($query, $this->_dom); 00085 if ($node->length == 1) { 00086 $this->{$phpName} = (string) $node->item(0)->data; 00087 } 00088 } 00089 } 00090 00096 protected function _parseWeblog() 00097 { 00098 // weblog object field 00099 $result = $this->_xpath->query('./weblog', $this->_dom); 00100 if ($result->length == 1) { 00104 require_once 'Zend/Service/Technorati/Weblog.php'; 00105 $this->_weblog = new Zend_Service_Technorati_Weblog($result->item(0)); 00106 } else { 00107 $this->_weblog = null; 00108 } 00109 } 00110 00117 public function getXml() 00118 { 00119 return $this->_dom->ownerDocument->saveXML($this->_dom); 00120 } 00121 }