本文整理汇总了PHP中Zend_Feed_Element类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Feed_Element类的具体用法?PHP Zend_Feed_Element怎么用?PHP Zend_Feed_Element使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Feed_Element类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __get
/**
* Map variable access onto the underlying entry representation.
*
* Get-style access returns a Zend_Feed_Element representing the
* child element accessed. To get string values, use method syntax
* with the __call() overriding.
*
* @param string $var The property to access.
* @return mixed
*/
public function __get($var)
{
$nodes = $this->_children($var);
$length = count($nodes);
if ($length == 1) {
return new Zend_Feed_Element($nodes[0]);
} elseif ($length > 1) {
return array_map(create_function('$e', 'return new Zend_Feed_Element($e);'), $nodes);
} else {
// When creating anonymous nodes for __set chaining, don't
// call appendChild() on them. Instead we pass the current
// element to them as an extra reference; the child is
// then responsible for appending itself when it is
// actually set. This way "if ($foo->bar)" doesn't create
// a phantom "bar" element in our tree.
if (strpos($var, ':') !== false) {
list($ns, $elt) = explode(':', $var, 2);
$node = $this->_element->ownerDocument->createElementNS(Zend_Feed::lookupNamespace($ns), $elt);
} else {
$node = $this->_element->ownerDocument->createElement($var);
}
$node = new Zend_Feed_Element($node);
$node->setParent($this);
return $node;
}
}
开发者ID:vojtajina,项目名称:sitellite,代码行数:36,代码来源:Element.php
示例2: _mapAttachment
/**
* Maps Zotero attachments to Omeka files, et al.
*
* @param Zend_Feed_Element
* @param bool Flag indicating that this is a top-level attachment.
*/
protected function _mapAttachment(Zend_Feed_Element $element, $topLevelAttachment = false)
{
if (!$topLevelAttachment) {
$this->_elementTexts['Zotero']['Attachment Title'][] = array('text' => $element->title(), 'html' => false);
$urlXpath = '//default:tr[@class="url"]/default:td';
if ($url = $this->_contentXpath($element->content, $urlXpath, true)) {
$this->_elementTexts['Zotero']['Attachment URL'][] = array('text' => $url, 'html' => false);
// If a attachment that is not top-level has no URL, still assign it
// a placeholder to maintain relationships between the "Attachment
// Title" and "Attachment Url" elements.
} else {
$this->_elementTexts['Zotero']['Attachment URL'][] = array('text' => '[No URL]', 'html' => false);
}
}
// The Zotero API will not return a file unless a private key exists, so
// prevent unnecessary requests.
if (!$this->_privateKey) {
return;
}
// Get the file URLs.
$method = "{$this->_libraryType}ItemFile";
$urls = $this->_client->{$method}($this->_libraryId, $element->key());
// Not all attachments have corresponding files in Amazon S3, so return
// those that do not.
if (!$urls['s3']) {
return;
}
// Name the file.
$uri = Zend_Uri::factory($urls['s3']);
// Set the original filename as the basename of the URL path.
$name = urldecode(basename($uri->getPath()));
// Set the file metadata.
$this->_fileMetadata['files'][] = array('source' => $urls['zotero'], 'name' => $name, 'metadata' => array('Dublin Core' => array('Title' => array(array('text' => $element->title(), 'html' => false)), 'Identifier' => array(array('text' => $url, 'html' => false)))));
}
开发者ID:rshiggin,项目名称:omeka-custom-exhibit,代码行数:40,代码来源:ImportProcess.php
示例3: __construct
/**
* The Zend_Feed_EntryAbstract constructor takes the URI of the feed the entry
* is part of, and optionally an XML construct (usually a
* SimpleXMLElement, but it can be an XML string or a DOMNode as
* well) that contains the contents of the entry.
*/
public function __construct($uri = null, $element = null)
{
$this->_uri = $uri;
if (!$element instanceof DOMElement) {
if ($element) {
// Load the feed as an XML DOMDocument object
@ini_set('track_errors', 1);
$doc = new DOMDocument();
$success = @$feedDOMDocument->loadXML($element);
@ini_restore('track_errors');
if (!$success) {
throw new Zend_Feed_Exception("DOMDocument cannot parse XML: {$php_errormsg}");
}
$element = $doc->getElementsByTagName($this->_rootElement)->item(0);
if (!$element) {
throw new Zend_Feed_Exception('No root <' . $this->_rootElement . '> element found, cannot parse feed.');
}
} else {
$doc = new DOMDocument('1.0', 'utf-8');
if ($this->_rootNamespace !== null) {
$element = $doc->createElementNS(Zend_Feed::lookupNamespace($this->_rootNamespace), $this->_rootElement);
} else {
$element = $doc->createElement($this->_rootElement);
}
}
}
parent::__construct($element);
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:34,代码来源:EntryAbstract.php
示例4: ensureAppended
/**
* Appends this element to its parent if necessary.
*
* @return void
*/
protected function ensureAppended()
{
if (!$this->_appended) {
$this->_parentElement->getDOM()->appendChild($this->_element);
$this->_appended = true;
$this->_parentElement->ensureAppended();
}
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:13,代码来源:Element.php
示例5: __construct
/**
* Zend_Feed_Entry_Abstract constructor
*
* The Zend_Feed_Entry_Abstract constructor takes the URI of the feed the entry
* is part of, and optionally an XML construct (usually a
* SimpleXMLElement, but it can be an XML string or a DOMNode as
* well) that contains the contents of the entry.
*
* @param string $uri
* @param SimpleXMLElement|DOMNode|string $element
* @return void
* @throws Zend_Feed_Exception
*/
public function __construct($uri = null, $element = null)
{
if (!$element instanceof DOMElement) {
if ($element) {
// Load the feed as an XML DOMDocument object
@ini_set('track_errors', 1);
$doc = new DOMDocument();
$doc = @Zend_Xml_Security::scan($element, $doc);
@ini_restore('track_errors');
if (!$doc) {
// prevent the class to generate an undefined variable notice (ZF-2590)
if (!isset($php_errormsg)) {
if (function_exists('xdebug_is_enabled')) {
$php_errormsg = '(error message not available, when XDebug is running)';
} else {
$php_errormsg = '(error message not available)';
}
}
/**
* @see Zend_Feed_Exception
*/
throw new Zend_Feed_Exception("DOMDocument cannot parse XML: {$php_errormsg}");
}
$element = $doc->getElementsByTagName($this->_rootElement)->item(0);
if (!$element) {
/**
* @see Zend_Feed_Exception
*/
throw new Zend_Feed_Exception('No root <' . $this->_rootElement . '> element found, cannot parse feed.');
}
} else {
$doc = new DOMDocument('1.0', 'utf-8');
if ($this->_rootNamespace !== null) {
$element = $doc->createElementNS(Zend_Feed::lookupNamespace($this->_rootNamespace), $this->_rootElement);
} else {
$element = $doc->createElement($this->_rootElement);
}
}
}
parent::__construct($element);
}
开发者ID:trigoesrodrigo,项目名称:icingaweb2,代码行数:54,代码来源:Abstract.php
示例6: __get
/**
* Make accessing individual elements of the feed easier.
*
* @param string $var The property to access.
*/
public function __get($var)
{
switch ($var) {
case 'entry':
// fall through to the next case
// fall through to the next case
case 'entries':
// fall through to the next case
// fall through to the next case
case 'item':
// fall through to the next case
// fall through to the next case
case 'items':
return $this;
case 'service.feed':
// fall through to the next case
// fall through to the next case
case 'service.post':
foreach ($this->_element->childNodes as $child) {
if ($child->localName == 'link' && $child->getAttribute('rel') == $var) {
return $child->getAttribute('href');
}
}
return null;
default:
return parent::__get($var);
}
}
开发者ID:jorgenils,项目名称:zend-framework,代码行数:33,代码来源:Abstract.php
注:本文中的Zend_Feed_Element类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论