diff options
author | robocoder <anthon.pang@gmail.com> | 2010-06-03 01:56:22 +0400 |
---|---|---|
committer | robocoder <anthon.pang@gmail.com> | 2010-06-03 01:56:22 +0400 |
commit | 537fe948e52b8e68cdcfcefcf2162f74313b27a3 (patch) | |
tree | f10fc1897a61c012a0d849f8317f9f7601f8f889 /libs/Zend | |
parent | 7f32da1f852f3f6f4061dd0cd50521f468574cb6 (diff) |
fixes #1386 - update to ZF 1.10.5
git-svn-id: http://dev.piwik.org/svn/trunk@2259 59fd770c-687e-43c8-a1e3-f5a4ff64c105
Diffstat (limited to 'libs/Zend')
23 files changed, 675 insertions, 160 deletions
diff --git a/libs/Zend/Cache/Backend/Memcached.php b/libs/Zend/Cache/Backend/Memcached.php index 9c79522069..3c29bcce67 100644 --- a/libs/Zend/Cache/Backend/Memcached.php +++ b/libs/Zend/Cache/Backend/Memcached.php @@ -17,7 +17,7 @@ * @subpackage Zend_Cache_Backend * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Memcached.php 21535 2010-03-17 18:20:53Z mabe $ + * @version $Id: Memcached.php 22208 2010-05-20 16:59:02Z mabe $ */ @@ -224,7 +224,7 @@ class Zend_Cache_Backend_Memcached extends Zend_Cache_Backend implements Zend_Ca $result = @$this->_memcache->set($id, array($data, time(), $lifetime), $flag, $lifetime); if (count($tags) > 0) { - $this->_log("Zend_Cache_Backend_Memcached::save() : tags are unsupported by the Memcached backend"); + $this->_log(self::TAGS_UNSUPPORTED_BY_SAVE_OF_MEMCACHED_BACKEND); } return $result; diff --git a/libs/Zend/Cache/Manager.php b/libs/Zend/Cache/Manager.php index 84cbaf24db..d7f157038c 100644 --- a/libs/Zend/Cache/Manager.php +++ b/libs/Zend/Cache/Manager.php @@ -165,7 +165,7 @@ class Zend_Cache_Manager || !$this->_optionTemplates[$name]['backend']['options']['tag_cache'] instanceof Zend_Cache_Core) ) { $this->_optionTemplates[$name]['backend']['options']['tag_cache'] - = $this->getCache(self::PAGETAGCACHE ); + = $this->getCache(self::PAGETAGCACHE); } $this->_caches[$name] = Zend_Cache::factory( $this->_optionTemplates[$name]['frontend']['name'], diff --git a/libs/Zend/Db/Table/Row/Abstract.php b/libs/Zend/Db/Table/Row/Abstract.php index a4a8f8dc85..c7243eb003 100644 --- a/libs/Zend/Db/Table/Row/Abstract.php +++ b/libs/Zend/Db/Table/Row/Abstract.php @@ -17,7 +17,7 @@ * @subpackage Table * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 21102 2010-02-19 21:13:37Z ralph $ + * @version $Id: Abstract.php 22230 2010-05-21 20:59:18Z ralph $ */ /** @@ -32,7 +32,7 @@ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess +abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess, IteratorAggregate { /** @@ -642,6 +642,11 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess return $result; } + public function getIterator() + { + return new ArrayIterator((array) $this->_data); + } + /** * Returns the column/value data as an array. * diff --git a/libs/Zend/Feed/Reader.php b/libs/Zend/Feed/Reader.php index 0fb8b1206b..26bf661cdf 100644 --- a/libs/Zend/Feed/Reader.php +++ b/libs/Zend/Feed/Reader.php @@ -16,7 +16,7 @@ * @package Zend_Feed_Reader * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Reader.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Reader.php 22093 2010-05-04 12:55:06Z padraic $ */ /** @@ -286,7 +286,9 @@ class Zend_Feed_Reader // require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Feed failed to load, got response code ' . $response->getStatus()); } - return self::importString($response->getBody()); + $reader = self::importString($response->getBody()); + $reader->setOriginalSourceUri($uri); + return $reader; } } @@ -427,7 +429,7 @@ class Zend_Feed_Reader } elseif(is_string($feed) && !empty($feed)) { @ini_set('track_errors', 1); $dom = new DOMDocument; - $status = @$doc->loadXML($string); + $status = @$dom->loadXML($feed); @ini_restore('track_errors'); if (!$status) { if (!isset($php_errormsg)) { diff --git a/libs/Zend/Feed/Reader/Entry/Rss.php b/libs/Zend/Feed/Reader/Entry/Rss.php index f6911879e1..21a30a98fc 100644 --- a/libs/Zend/Feed/Reader/Entry/Rss.php +++ b/libs/Zend/Feed/Reader/Entry/Rss.php @@ -16,7 +16,7 @@ * @package Zend_Feed_Reader * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Rss.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Rss.php 22301 2010-05-26 10:15:13Z padraic $ */ /** @@ -265,22 +265,27 @@ class Zend_Feed_Reader_Entry_Rss extends Zend_Feed_Reader_EntryAbstract implemen ) { $dateModified = $this->_xpath->evaluate('string('.$this->_xpathQueryRss.'/pubDate)'); if ($dateModified) { - $dateStandards = array(Zend_Date::RSS, Zend_Date::RFC_822, - Zend_Date::RFC_2822, Zend_Date::DATES); - $date = new Zend_Date; - foreach ($dateStandards as $standard) { - try { - $date->set($dateModified, $standard); - break; - } catch (Zend_Date_Exception $e) { - if ($standard == Zend_Date::DATES) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception( - 'Could not load date due to unrecognised' - .' format (should follow RFC 822 or 2822):' - . $e->getMessage(), - 0, $e - ); + $dateModifiedParsed = strtotime($dateModified); + if ($dateModifiedParsed) { + $date = new Zend_Date($dateModifiedParsed); + } else { + $dateStandards = array(Zend_Date::RSS, Zend_Date::RFC_822, + Zend_Date::RFC_2822, Zend_Date::DATES); + $date = new Zend_Date; + foreach ($dateStandards as $standard) { + try { + $date->set($dateModified, $standard); + break; + } catch (Zend_Date_Exception $e) { + if ($standard == Zend_Date::DATES) { + // require_once 'Zend/Feed/Exception.php'; + throw new Zend_Feed_Exception( + 'Could not load date due to unrecognised' + .' format (should follow RFC 822 or 2822):' + . $e->getMessage(), + 0, $e + ); + } } } } @@ -335,8 +340,6 @@ class Zend_Feed_Reader_Entry_Rss extends Zend_Feed_Reader_EntryAbstract implemen if (!$description) { $description = null; - } else { - $description = html_entity_decode($description, ENT_QUOTES, $this->getEncoding()); } $this->_data['description'] = $description; diff --git a/libs/Zend/Feed/Reader/Extension/Atom/Entry.php b/libs/Zend/Feed/Reader/Extension/Atom/Entry.php index 41dc134a6e..1efa197787 100644 --- a/libs/Zend/Feed/Reader/Extension/Atom/Entry.php +++ b/libs/Zend/Feed/Reader/Extension/Atom/Entry.php @@ -16,7 +16,7 @@ * @package Zend_Feed_Reader * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 20507 2010-01-21 22:21:07Z padraic $ + * @version $Id: Entry.php 22301 2010-05-26 10:15:13Z padraic $ */ /** @@ -260,8 +260,6 @@ class Zend_Feed_Reader_Extension_Atom_Entry if (!$description) { $description = null; - } else { - $description = html_entity_decode($description, ENT_QUOTES, $this->getEncoding()); } $this->_data['description'] = $description; @@ -425,8 +423,6 @@ class Zend_Feed_Reader_Extension_Atom_Entry if (!$title) { $title = null; - } else { - $title = html_entity_decode($title, ENT_QUOTES, $this->getEncoding()); } $this->_data['title'] = $title; @@ -544,7 +540,7 @@ class Zend_Feed_Reader_Extension_Atom_Entry $categoryCollection[] = array( 'term' => $category->getAttribute('term'), 'scheme' => $category->getAttribute('scheme'), - 'label' => html_entity_decode($category->getAttribute('label')) + 'label' => $category->getAttribute('label') ); } } else { diff --git a/libs/Zend/Feed/Reader/Extension/Atom/Feed.php b/libs/Zend/Feed/Reader/Extension/Atom/Feed.php index 5f102ca268..3e0e2079c5 100644 --- a/libs/Zend/Feed/Reader/Extension/Atom/Feed.php +++ b/libs/Zend/Feed/Reader/Extension/Atom/Feed.php @@ -16,7 +16,7 @@ * @package Zend_Feed_Reader * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Feed.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Feed.php 22301 2010-05-26 10:15:13Z padraic $ */ /** @@ -231,8 +231,6 @@ class Zend_Feed_Reader_Extension_Atom_Feed if (!$generator) { $generator = null; - } else { - $generator = html_entity_decode($generator, ENT_QUOTES, $this->getEncoding()); } $this->_data['generator'] = $generator; @@ -295,6 +293,30 @@ class Zend_Feed_Reader_Extension_Atom_Feed } /** + * Get the feed image + * + * @return array|null + */ + public function getImage() + { + if (array_key_exists('image', $this->_data)) { + return $this->_data['image']; + } + + $imageUrl = $this->_xpath->evaluate('string(' . $this->getXpathPrefix() . '/atom:logo)'); + + if (!$imageUrl) { + $image = null; + } else { + $image = array('uri'=>$imageUrl); + } + + $this->_data['image'] = $image; + + return $this->_data['image']; + } + + /** * Get the base URI of the feed (if set). * * @return string|null @@ -442,7 +464,7 @@ class Zend_Feed_Reader_Extension_Atom_Feed $categoryCollection[] = array( 'term' => $category->getAttribute('term'), 'scheme' => $category->getAttribute('scheme'), - 'label' => html_entity_decode($category->getAttribute('label')) + 'label' => $category->getAttribute('label') ); } } else { diff --git a/libs/Zend/Feed/Reader/Extension/Content/Entry.php b/libs/Zend/Feed/Reader/Extension/Content/Entry.php index f01e0ad248..ca10f24a3b 100644 --- a/libs/Zend/Feed/Reader/Extension/Content/Entry.php +++ b/libs/Zend/Feed/Reader/Extension/Content/Entry.php @@ -16,7 +16,7 @@ * @package Zend_Feed_Reader * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Entry.php 22301 2010-05-26 10:15:13Z padraic $ */ /** @@ -48,9 +48,6 @@ class Zend_Feed_Reader_Extension_Content_Entry } else { $content = $this->_xpath->evaluate('string('.$this->getXpathPrefix().'/content:encoded)'); } - if ($content) { - $content = html_entity_decode($content, ENT_QUOTES, $this->getEncoding()); - } return $content; } diff --git a/libs/Zend/Feed/Reader/Feed/Atom.php b/libs/Zend/Feed/Reader/Feed/Atom.php index 493c3fa3a9..8199355995 100644 --- a/libs/Zend/Feed/Reader/Feed/Atom.php +++ b/libs/Zend/Feed/Reader/Feed/Atom.php @@ -16,7 +16,7 @@ * @package Zend_Feed_Reader * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Atom.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Atom.php 22108 2010-05-05 13:44:11Z padraic $ */ /** @@ -158,6 +158,16 @@ class Zend_Feed_Reader_Feed_Atom extends Zend_Feed_Reader_FeedAbstract } /** + * Get the feed lastBuild date. This is not implemented in Atom. + * + * @return string|null + */ + public function getLastBuildDate() + { + return null; + } + + /** * Get the feed description * * @return string|null @@ -278,6 +288,24 @@ class Zend_Feed_Reader_Feed_Atom extends Zend_Feed_Reader_FeedAbstract } /** + * Get feed image data + * + * @return array|null + */ + public function getImage() + { + if (array_key_exists('image', $this->_data)) { + return $this->_data['image']; + } + + $link = $this->getExtension('Atom')->getImage(); + + $this->_data['image'] = $link; + + return $this->_data['image']; + } + + /** * Get a link to the feed's XML Url * * @return string|null @@ -290,6 +318,10 @@ class Zend_Feed_Reader_Feed_Atom extends Zend_Feed_Reader_FeedAbstract $link = $this->getExtension('Atom')->getFeedLink(); + if (is_null($link) || empty($link)) { + $link = $this->getOriginalSourceUri(); + } + $this->_data['feedlink'] = $link; return $this->_data['feedlink']; diff --git a/libs/Zend/Feed/Reader/Feed/Rss.php b/libs/Zend/Feed/Reader/Feed/Rss.php index 254698ce18..bff78c3455 100644 --- a/libs/Zend/Feed/Reader/Feed/Rss.php +++ b/libs/Zend/Feed/Reader/Feed/Rss.php @@ -16,7 +16,7 @@ * @package Zend_Feed_Reader * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Rss.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Rss.php 22301 2010-05-26 10:15:13Z padraic $ */ /** @@ -226,22 +226,27 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract $dateModified = $this->_xpath->evaluate('string(/rss/channel/lastBuildDate)'); } if ($dateModified) { - $dateStandards = array(Zend_Date::RSS, Zend_Date::RFC_822, - Zend_Date::RFC_2822, Zend_Date::DATES); - $date = new Zend_Date; - foreach ($dateStandards as $standard) { - try { - $date->set($dateModified, $standard); - break; - } catch (Zend_Date_Exception $e) { - if ($standard == Zend_Date::DATES) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception( - 'Could not load date due to unrecognised' - .' format (should follow RFC 822 or 2822):' - . $e->getMessage(), - 0, $e - ); + $dateModifiedParsed = strtotime($dateModified); + if ($dateModifiedParsed) { + $date = new Zend_Date($dateModifiedParsed); + } else { + $dateStandards = array(Zend_Date::RSS, Zend_Date::RFC_822, + Zend_Date::RFC_2822, Zend_Date::DATES); + $date = new Zend_Date; + foreach ($dateStandards as $standard) { + try { + $date->set($dateModified, $standard); + break; + } catch (Zend_Date_Exception $e) { + if ($standard == Zend_Date::DATES) { + // require_once 'Zend/Feed/Exception.php'; + throw new Zend_Feed_Exception( + 'Could not load date due to unrecognised' + .' format (should follow RFC 822 or 2822):' + . $e->getMessage(), + 0, $e + ); + } } } } @@ -266,6 +271,60 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract } /** + * Get the feed lastBuild date + * + * @return Zend_Date + */ + public function getLastBuildDate() + { + if (array_key_exists('lastBuildDate', $this->_data)) { + return $this->_data['lastBuildDate']; + } + + $lastBuildDate = null; + $date = null; + + if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 && + $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) { + $lastBuildDate = $this->_xpath->evaluate('string(/rss/channel/lastBuildDate)'); + if ($lastBuildDate) { + $lastBuildDateParsed = strtotime($lastBuildDate); + if ($lastBuildDateParsed) { + $date = new Zend_Date($lastBuildDateParsed); + } else { + $dateStandards = array(Zend_Date::RSS, Zend_Date::RFC_822, + Zend_Date::RFC_2822, Zend_Date::DATES); + $date = new Zend_Date; + foreach ($dateStandards as $standard) { + try { + $date->set($lastBuildDate, $standard); + break; + } catch (Zend_Date_Exception $e) { + if ($standard == Zend_Date::DATES) { + // require_once 'Zend/Feed/Exception.php'; + throw new Zend_Feed_Exception( + 'Could not load date due to unrecognised' + .' format (should follow RFC 822 or 2822):' + . $e->getMessage(), + 0, $e + ); + } + } + } + } + } + } + + if (!$date) { + $date = null; + } + + $this->_data['lastBuildDate'] = $date; + + return $this->_data['lastBuildDate']; + } + + /** * Get the feed description * * @return string|null @@ -344,6 +403,60 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract } /** + * Get the feed image data + * + * @return array|null + */ + public function getImage() + { + if (array_key_exists('image', $this->_data)) { + return $this->_data['image']; + } + + if ($this->getType() !== Zend_Feed_Reader::TYPE_RSS_10 && + $this->getType() !== Zend_Feed_Reader::TYPE_RSS_090) { + $list = $this->_xpath->query('/rss/channel/image'); + $prefix = '/rss/channel/image[1]'; + } else { + $list = $this->_xpath->query('/rdf:RDF/rss:channel/rss:image'); + $prefix = '/rdf:RDF/rss:channel/rss:image[1]'; + } + if ($list->length > 0) { + $image = array(); + $value = $this->_xpath->evaluate('string(' . $prefix . '/url)'); + if ($value) { + $image['uri'] = $value; + } + $value = $this->_xpath->evaluate('string(' . $prefix . '/link)'); + if ($value) { + $image['link'] = $value; + } + $value = $this->_xpath->evaluate('string(' . $prefix . '/title)'); + if ($value) { + $image['title'] = $value; + } + $value = $this->_xpath->evaluate('string(' . $prefix . '/height)'); + if ($value) { + $image['height'] = $value; + } + $value = $this->_xpath->evaluate('string(' . $prefix . '/width)'); + if ($value) { + $image['width'] = $value; + } + $value = $this->_xpath->evaluate('string(' . $prefix . '/description)'); + if ($value) { + $image['description'] = $value; + } + } else { + $image = null; + } + + $this->_data['image'] = $image; + + return $this->_data['image']; + } + + /** * Get the feed language * * @return string|null @@ -430,8 +543,8 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract $link = $this->getExtension('Atom')->getFeedLink(); - if (!$link) { - $link = null; + if (is_null($link) || empty($link)) { + $link = $this->getOriginalSourceUri(); } $this->_data['feedlink'] = $link; @@ -464,9 +577,6 @@ class Zend_Feed_Reader_Feed_Rss extends Zend_Feed_Reader_FeedAbstract } else { $generator = $this->_xpath->evaluate('string(/rdf:RDF/rss:channel/atom:generator)'); } - if ($generator) { - $generator = html_entity_decode($generator, ENT_QUOTES, $this->getEncoding()); - } } if (empty($generator)) { diff --git a/libs/Zend/Feed/Reader/FeedAbstract.php b/libs/Zend/Feed/Reader/FeedAbstract.php index 89e7c1d5ba..bda9f23b46 100644 --- a/libs/Zend/Feed/Reader/FeedAbstract.php +++ b/libs/Zend/Feed/Reader/FeedAbstract.php @@ -16,7 +16,7 @@ * @package Zend_Feed_Reader * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: FeedAbstract.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: FeedAbstract.php 22093 2010-05-04 12:55:06Z padraic $ */ /** @@ -80,6 +80,13 @@ abstract class Zend_Feed_Reader_FeedAbstract implements Zend_Feed_Reader_FeedInt protected $_extensions = array(); /** + * Original Source URI (set if imported from a URI) + * + * @var string + */ + protected $_originalSourceUri = null; + + /** * Constructor * * @param DomDocument The DOM object for the feed's XML @@ -101,6 +108,29 @@ abstract class Zend_Feed_Reader_FeedAbstract implements Zend_Feed_Reader_FeedInt } /** + * Set an original source URI for the feed being parsed. This value + * is returned from getFeedLink() method if the feed does not carry + * a self-referencing URI. + * + * @param string $uri + */ + public function setOriginalSourceUri($uri) + { + $this->_originalSourceUri = $uri; + } + + /** + * Get an original source URI for the feed being parsed. Returns null if + * unset or the feed was not imported from a URI. + * + * @return string|null + */ + public function getOriginalSourceUri() + { + return $this->_originalSourceUri; + } + + /** * Get the number of feed entries. * Required by the Iterator interface. * diff --git a/libs/Zend/Feed/Writer/Entry.php b/libs/Zend/Feed/Writer/Entry.php index e8a6857cdc..01d290e6fb 100644 --- a/libs/Zend/Feed/Writer/Entry.php +++ b/libs/Zend/Feed/Writer/Entry.php @@ -16,7 +16,7 @@ * @package Zend_Feed_Writer * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Entry.php 20519 2010-01-22 14:06:24Z padraic $ + * @version $Id: Entry.php 22065 2010-04-30 14:04:57Z padraic $ */ /** @@ -592,20 +592,15 @@ class Zend_Feed_Writer_Entry } /** - * Adds an enclosure to the entry. + * Adds an enclosure to the entry. The array parameter may contain the + * keys 'uri', 'type' and 'length'. Only 'uri' is required for Atom, though the + * others must also be provided or RSS rendering (where they are required) + * will throw an Exception. * * @param array $enclosures */ public function setEnclosure(array $enclosure) { - if (!isset($enclosure['type'])) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Enclosure "type" is not set'); - } - if (!isset($enclosure['length'])) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Enclosure "length" is not set'); - } if (!isset($enclosure['uri'])) { // require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Enclosure "uri" is not set'); @@ -614,11 +609,6 @@ class Zend_Feed_Writer_Entry // require_once 'Zend/Feed/Exception.php'; throw new Zend_Feed_Exception('Enclosure "uri" is not a valid URI/IRI'); } - if ((int) $enclosure['length'] <= 0) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Enclosure "length" must be an integer' - . ' indicating the content\'s length in bytes'); - } $this->_data['enclosure'] = $enclosure; } diff --git a/libs/Zend/Feed/Writer/Feed/FeedAbstract.php b/libs/Zend/Feed/Writer/Feed/FeedAbstract.php index 6ab6e91b2c..bc2a0fa06f 100644 --- a/libs/Zend/Feed/Writer/Feed/FeedAbstract.php +++ b/libs/Zend/Feed/Writer/Feed/FeedAbstract.php @@ -206,6 +206,27 @@ class Zend_Feed_Writer_Feed_FeedAbstract } /** + * Set the feed last-build date. Ignored for Atom 1.0. + * + * @param null|integer|Zend_Date + */ + public function setLastBuildDate($date = null) + { + $zdate = null; + if (is_null($date)) { + $zdate = new Zend_Date; + } elseif (ctype_digit($date) && strlen($date) == 10) { + $zdate = new Zend_Date($date, Zend_Date::TIMESTAMP); + } elseif ($date instanceof Zend_Date) { + $zdate = $date; + } else { + // require_once 'Zend/Feed/Exception.php'; + throw new Zend_Feed_Exception('Invalid Zend_Date object or UNIX Timestamp passed as parameter'); + } + $this->_data['lastBuildDate'] = $zdate; + } + + /** * Set the feed description * * @return string|null @@ -226,24 +247,47 @@ class Zend_Feed_Writer_Feed_FeedAbstract */ public function setGenerator($name, $version = null, $uri = null) { - if (empty($name) || !is_string($name)) { - // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "name" must be a non-empty string'); - } - $generator = array('name' => $name); - if (isset($version)) { - if (empty($version) || !is_string($version)) { + if (is_array($name)) { + $data = $name; + if (empty($data['name']) || !is_string($data['name'])) { // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "version" must be a non-empty string'); + throw new Zend_Feed_Exception('Invalid parameter: "name" must be a non-empty string'); } - $generator['version'] = $version; - } - if (isset($uri)) { - if (empty($uri) || !is_string($uri) || !Zend_Uri::check($uri)) { + $generator = array('name' => $data['name']); + if (isset($data['version'])) { + if (empty($data['version']) || !is_string($data['version'])) { + // require_once 'Zend/Feed/Exception.php'; + throw new Zend_Feed_Exception('Invalid parameter: "version" must be a non-empty string'); + } + $generator['version'] = $data['version']; + } + if (isset($data['uri'])) { + if (empty($data['uri']) || !is_string($data['uri']) || !Zend_Uri::check($data['uri'])) { + // require_once 'Zend/Feed/Exception.php'; + throw new Zend_Feed_Exception('Invalid parameter: "uri" must be a non-empty string and a valid URI/IRI'); + } + $generator['uri'] = $data['uri']; + } + } else { + if (empty($name) || !is_string($name)) { // require_once 'Zend/Feed/Exception.php'; - throw new Zend_Feed_Exception('Invalid parameter: "uri" must be a non-empty string and a valid URI/IRI'); + throw new Zend_Feed_Exception('Invalid parameter: "name" must be a non-empty string'); + } + $generator = array('name' => $name); + if (isset($version)) { + if (empty($version) || !is_string($version)) { + // require_once 'Zend/Feed/Exception.php'; + throw new Zend_Feed_Exception('Invalid parameter: "version" must be a non-empty string'); + } + $generator['version'] = $version; + } + if (isset($uri)) { + if (empty($uri) || !is_string($uri) || !Zend_Uri::check($uri)) { + // require_once 'Zend/Feed/Exception.php'; + throw new Zend_Feed_Exception('Invalid parameter: "uri" must be a non-empty string and a valid URI/IRI'); + } + $generator['uri'] = $uri; } - $generator['uri'] = $uri; } $this->_data['generator'] = $generator; } @@ -251,7 +295,7 @@ class Zend_Feed_Writer_Feed_FeedAbstract /** * Set the feed ID - URI or URN (via PCRE pattern) supported * - * @return string|null + * @param string $id */ public function setId($id) { @@ -264,6 +308,25 @@ class Zend_Feed_Writer_Feed_FeedAbstract } /** + * Set a feed image (URI at minimum). Parameter is a single array with the + * required key 'uri'. When rendering as RSS, the required keys are 'uri', + * 'title' and 'link'. RSS also specifies three optional parameters 'width', + * 'height' and 'description'. Only 'uri' is required and used for Atom rendering. + * + * @param array $data + */ + public function setImage(array $data) + { + if (empty($data['uri']) || !is_string($data['uri']) + || !Zend_Uri::check($data['uri'])) { + // require_once 'Zend/Feed/Exception.php'; + throw new Zend_Feed_Exception('Invalid parameter: parameter \'uri\'' + . ' must be a non-empty string and valid URI/IRI'); + } + $this->_data['image'] = $data; + } + + /** * Set the feed language * * @return string|null @@ -280,7 +343,7 @@ class Zend_Feed_Writer_Feed_FeedAbstract /** * Set a link to the HTML source * - * @return string|null + * @param string $link */ public function setLink($link) { @@ -491,6 +554,19 @@ class Zend_Feed_Writer_Feed_FeedAbstract } /** + * Get the feed last-build date + * + * @return string|null + */ + public function getLastBuildDate() + { + if (!array_key_exists('lastBuildDate', $this->_data)) { + return null; + } + return $this->_data['lastBuildDate']; + } + + /** * Get the feed description * * @return string|null @@ -530,6 +606,19 @@ class Zend_Feed_Writer_Feed_FeedAbstract } /** + * Get the feed image URI + * + * @return array + */ + public function getImage() + { + if (!array_key_exists('image', $this->_data)) { + return null; + } + return $this->_data['image']; + } + + /** * Get the feed language * * @return string|null diff --git a/libs/Zend/Feed/Writer/Renderer/Entry/Atom.php b/libs/Zend/Feed/Writer/Renderer/Entry/Atom.php index 6e44190277..76095e89f0 100644 --- a/libs/Zend/Feed/Writer/Renderer/Entry/Atom.php +++ b/libs/Zend/Feed/Writer/Renderer/Entry/Atom.php @@ -16,7 +16,7 @@ * @package Zend_Feed_Writer * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Atom.php 20507 2010-01-21 22:21:07Z padraic $ + * @version $Id: Atom.php 22065 2010-04-30 14:04:57Z padraic $ */ /** @@ -234,8 +234,12 @@ class Zend_Feed_Writer_Renderer_Entry_Atom } $enclosure = $this->_dom->createElement('link'); $enclosure->setAttribute('rel', 'enclosure'); - $enclosure->setAttribute('type', $data['type']); - $enclosure->setAttribute('length', $data['length']); + if (isset($data['type'])) { + $enclosure->setAttribute('type', $data['type']); + } + if (isset($data['length'])) { + $enclosure->setAttribute('length', $data['length']); + } $enclosure->setAttribute('href', $data['uri']); $root->appendChild($enclosure); } @@ -337,7 +341,8 @@ class Zend_Feed_Writer_Renderer_Entry_Atom $tidy = new tidy; $config = array( 'output-xhtml' => true, - 'show-body-only' => true + 'show-body-only' => true, + 'quote-nbsp' => false ); $encoding = str_replace('-', '', $this->getEncoding()); $tidy->parseString($content, $config, $encoding); diff --git a/libs/Zend/Feed/Writer/Renderer/Entry/Rss.php b/libs/Zend/Feed/Writer/Renderer/Entry/Rss.php index d34291f4cc..74e80f5707 100644 --- a/libs/Zend/Feed/Writer/Renderer/Entry/Rss.php +++ b/libs/Zend/Feed/Writer/Renderer/Entry/Rss.php @@ -16,7 +16,7 @@ * @package Zend_Feed_Writer * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Rss.php 20241 2010-01-12 20:19:46Z padraic $ + * @version $Id: Rss.php 22065 2010-04-30 14:04:57Z padraic $ */ /** @@ -218,6 +218,37 @@ class Zend_Feed_Writer_Renderer_Entry_Rss if ((!$data || empty($data))) { return; } + if (!isset($data['type'])) { + // require_once 'Zend/Feed/Exception.php'; + $exception = new Zend_Feed_Exception('Enclosure "type" is not set'); + if (!$this->_ignoreExceptions) { + throw $exception; + } else { + $this->_exceptions[] = $exception; + return; + } + } + if (!isset($data['length'])) { + // require_once 'Zend/Feed/Exception.php'; + $exception = new Zend_Feed_Exception('Enclosure "length" is not set'); + if (!$this->_ignoreExceptions) { + throw $exception; + } else { + $this->_exceptions[] = $exception; + return; + } + } + if (isset($data['length']) && (int) $data['length'] <= 0) { + // require_once 'Zend/Feed/Exception.php'; + $exception = new Zend_Feed_Exception('Enclosure "length" must be an integer' + . ' indicating the content\'s length in bytes'); + if (!$this->_ignoreExceptions) { + throw $exception; + } else { + $this->_exceptions[] = $exception; + return; + } + } $enclosure = $this->_dom->createElement('enclosure'); $enclosure->setAttribute('type', $data['type']); $enclosure->setAttribute('length', $data['length']); diff --git a/libs/Zend/Feed/Writer/Renderer/Feed/Atom.php b/libs/Zend/Feed/Writer/Renderer/Feed/Atom.php index 964a926a89..2c88dd4298 100644 --- a/libs/Zend/Feed/Writer/Renderer/Feed/Atom.php +++ b/libs/Zend/Feed/Writer/Renderer/Feed/Atom.php @@ -16,7 +16,7 @@ * @package Zend_Feed_Writer * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Atom.php 20519 2010-01-22 14:06:24Z padraic $ + * @version $Id: Atom.php 22098 2010-05-04 18:03:29Z padraic $ */ /** @see Zend_Feed_Writer_Feed */ @@ -81,6 +81,7 @@ class Zend_Feed_Writer_Renderer_Feed_Atom $this->_setBaseUrl($this->_dom, $root); $this->_setTitle($this->_dom, $root); $this->_setDescription($this->_dom, $root); + $this->_setImage($this->_dom, $root); $this->_setDateCreated($this->_dom, $root); $this->_setDateModified($this->_dom, $root); $this->_setGenerator($this->_dom, $root); diff --git a/libs/Zend/Feed/Writer/Renderer/Feed/Atom/AtomAbstract.php b/libs/Zend/Feed/Writer/Renderer/Feed/Atom/AtomAbstract.php index f8b746b89c..254516e5b5 100644 --- a/libs/Zend/Feed/Writer/Renderer/Feed/Atom/AtomAbstract.php +++ b/libs/Zend/Feed/Writer/Renderer/Feed/Atom/AtomAbstract.php @@ -321,6 +321,25 @@ class Zend_Feed_Writer_Renderer_Feed_Atom_AtomAbstract $text = $dom->createTextNode($copyright); $copy->appendChild($text); } + + /** + * Set feed level logo (image) + * + * @param DOMDocument $dom + * @param DOMElement $root + * @return void + */ + protected function _setImage(DOMDocument $dom, DOMElement $root) + { + $image = $this->getDataContainer()->getImage(); + if (!$image) { + return; + } + $img = $dom->createElement('logo'); + $root->appendChild($img); + $text = $dom->createTextNode($image['uri']); + $img->appendChild($text); + } /** * Set date feed was created diff --git a/libs/Zend/Feed/Writer/Renderer/Feed/Rss.php b/libs/Zend/Feed/Writer/Renderer/Feed/Rss.php index 28db436f5a..07b94e7b86 100644 --- a/libs/Zend/Feed/Writer/Renderer/Feed/Rss.php +++ b/libs/Zend/Feed/Writer/Renderer/Feed/Rss.php @@ -16,7 +16,7 @@ * @package Zend_Feed_Writer * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Rss.php 20519 2010-01-22 14:06:24Z padraic $ + * @version $Id: Rss.php 22108 2010-05-05 13:44:11Z padraic $ */ /** @see Zend_Feed_Writer_Feed */ @@ -79,8 +79,10 @@ class Zend_Feed_Writer_Renderer_Feed_Rss $this->_setBaseUrl($this->_dom, $channel); $this->_setTitle($this->_dom, $channel); $this->_setDescription($this->_dom, $channel); + $this->_setImage($this->_dom, $channel); $this->_setDateCreated($this->_dom, $channel); $this->_setDateModified($this->_dom, $channel); + $this->_setLastBuildDate($this->_dom, $channel); $this->_setGenerator($this->_dom, $channel); $this->_setLink($this->_dom, $channel); $this->_setAuthors($this->_dom, $channel); @@ -312,6 +314,114 @@ class Zend_Feed_Writer_Renderer_Feed_Rss $text = $dom->createTextNode($copyright); $copy->appendChild($text); } + + /** + * Set feed channel image + * + * @param DOMDocument $dom + * @param DOMElement $root + * @return void + */ + protected function _setImage(DOMDocument $dom, DOMElement $root) + { + $image = $this->getDataContainer()->getImage(); + if (!$image) { + return; + } + if (!isset($image['title']) || empty($image['title']) + || !is_string($image['title'])) { + // require_once 'Zend/Feed/Exception.php'; + $message = 'RSS 2.0 feed images must include a title'; + $exception = new Zend_Feed_Exception($message); + if (!$this->_ignoreExceptions) { + throw $exception; + } else { + $this->_exceptions[] = $exception; + return; + } + } + if (empty($image['link']) || !is_string($image['link']) + || !Zend_Uri::check($image['link'])) { + // require_once 'Zend/Feed/Exception.php'; + $message = 'Invalid parameter: parameter \'link\'' + . ' must be a non-empty string and valid URI/IRI'; + $exception = new Zend_Feed_Exception($message); + if (!$this->_ignoreExceptions) { + throw $exception; + } else { + $this->_exceptions[] = $exception; + return; + } + } + $img = $dom->createElement('image'); + $root->appendChild($img); + $url = $dom->createElement('url'); + $text = $dom->createTextNode($image['uri']); + $url->appendChild($text); + $title = $dom->createElement('title'); + $text = $dom->createTextNode($image['title']); + $title->appendChild($text); + $link = $dom->createElement('link'); + $text = $dom->createTextNode($image['link']); + $link->appendChild($text); + $img->appendChild($url); + $img->appendChild($title); + $img->appendChild($link); + if (isset($image['height'])) { + if (!ctype_digit((string) $image['height']) || $image['height'] > 400) { + // require_once 'Zend/Feed/Exception.php'; + $message = 'Invalid parameter: parameter \'height\'' + . ' must be an integer not exceeding 400'; + $exception = new Zend_Feed_Exception($message); + if (!$this->_ignoreExceptions) { + throw $exception; + } else { + $this->_exceptions[] = $exception; + return; + } + } + $height = $dom->createElement('height'); + $text = $dom->createTextNode($image['height']); + $height->appendChild($text); + $img->appendChild($height); + } + if (isset($image['width'])) { + if (!ctype_digit((string) $image['width']) || $image['width'] > 144) { + // require_once 'Zend/Feed/Exception.php'; + $message = 'Invalid parameter: parameter \'width\'' + . ' must be an integer not exceeding 144'; + $exception = new Zend_Feed_Exception($message); + if (!$this->_ignoreExceptions) { + throw $exception; + } else { + $this->_exceptions[] = $exception; + return; + } + } + $width = $dom->createElement('width'); + $text = $dom->createTextNode($image['width']); + $width->appendChild($text); + $img->appendChild($width); + } + if (isset($image['description'])) { + if (empty($image['description']) || !is_string($image['description'])) { + // require_once 'Zend/Feed/Exception.php'; + $message = 'Invalid parameter: parameter \'description\'' + . ' must be a non-empty string'; + $exception = new Zend_Feed_Exception($message); + if (!$this->_ignoreExceptions) { + throw $exception; + } else { + $this->_exceptions[] = $exception; + return; + } + } + $desc = $dom->createElement('description'); + $text = $dom->createTextNode($image['description']); + $desc->appendChild($text); + $img->appendChild($desc); + } + } /** * Set date feed was created @@ -331,6 +441,27 @@ class Zend_Feed_Writer_Renderer_Feed_Rss ); } } + + /** + * Set date feed last build date + * + * @param DOMDocument $dom + * @param DOMElement $root + * @return void + */ + protected function _setLastBuildDate(DOMDocument $dom, DOMElement $root) + { + if(!$this->getDataContainer()->getLastBuildDate()) { + return; + } + + $lastBuildDate = $dom->createElement('lastBuildDate'); + $root->appendChild($lastBuildDate); + $text = $dom->createTextNode( + $this->getDataContainer()->getLastBuildDate()->get(Zend_Date::RSS) + ); + $lastBuildDate->appendChild($text); + } /** * Set base URL to feed links diff --git a/libs/Zend/Http/Client/Adapter/Curl.php b/libs/Zend/Http/Client/Adapter/Curl.php index 8ac364711a..4747bd898c 100644 --- a/libs/Zend/Http/Client/Adapter/Curl.php +++ b/libs/Zend/Http/Client/Adapter/Curl.php @@ -16,7 +16,7 @@ * @category Zend * @package Zend_Http * @subpackage Client_Adapter - * @version $Id: Curl.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Curl.php 22221 2010-05-21 07:00:58Z dragonbe $ * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ @@ -73,23 +73,7 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac * * @var array */ - protected $_invalidOverwritableCurlOptions = array( - CURLOPT_HTTPGET, - CURLOPT_POST, - CURLOPT_PUT, - CURLOPT_CUSTOMREQUEST, - CURLOPT_HEADER, - CURLOPT_RETURNTRANSFER, - CURLOPT_HTTPHEADER, - CURLOPT_POSTFIELDS, - CURLOPT_INFILE, - CURLOPT_INFILESIZE, - CURLOPT_PORT, - CURLOPT_MAXREDIRS, - CURLOPT_CONNECTTIMEOUT, - CURL_HTTP_VERSION_1_1, - CURL_HTTP_VERSION_1_0, - ); + protected $_invalidOverwritableCurlOptions; /** * Response gotten from server @@ -119,6 +103,23 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac // require_once 'Zend/Http/Client/Adapter/Exception.php'; throw new Zend_Http_Client_Adapter_Exception('cURL extension has to be loaded to use this Zend_Http_Client adapter.'); } + $this->_invalidOverwritableCurlOptions = array( + CURLOPT_HTTPGET, + CURLOPT_POST, + CURLOPT_PUT, + CURLOPT_CUSTOMREQUEST, + CURLOPT_HEADER, + CURLOPT_RETURNTRANSFER, + CURLOPT_HTTPHEADER, + CURLOPT_POSTFIELDS, + CURLOPT_INFILE, + CURLOPT_INFILESIZE, + CURLOPT_PORT, + CURLOPT_MAXREDIRS, + CURLOPT_CONNECTTIMEOUT, + CURL_HTTP_VERSION_1_1, + CURL_HTTP_VERSION_1_0, + ); } /** @@ -333,6 +334,11 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac $curlMethod = CURLOPT_CUSTOMREQUEST; $curlValue = "TRACE"; break; + + case Zend_Http_Client::HEAD: + $curlMethod = CURLOPT_CUSTOMREQUEST; + $curlValue = "HEAD"; + break; default: // For now, through an exception for unsupported request methods diff --git a/libs/Zend/Uri.php b/libs/Zend/Uri.php index 90d9d405c5..ad4c43ee99 100644 --- a/libs/Zend/Uri.php +++ b/libs/Zend/Uri.php @@ -16,7 +16,7 @@ * @package Zend_Uri * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Uri.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Uri.php 22083 2010-05-03 18:49:28Z shahar $ */ /** @@ -79,14 +79,16 @@ abstract class Zend_Uri * Create a new Zend_Uri object for a URI. If building a new URI, then $uri should contain * only the scheme (http, ftp, etc). Otherwise, supply $uri with the complete URI. * - * @param string $uri The URI form which a Zend_Uri instance is created + * @param string $uri The URI form which a Zend_Uri instance is created + * @param string $className The name of the class to use in order to manipulate URI * @throws Zend_Uri_Exception When an empty string was supplied for the scheme * @throws Zend_Uri_Exception When an illegal scheme is supplied * @throws Zend_Uri_Exception When the scheme is not supported + * @throws Zend_Uri_Exception When $className doesn't exist or doesn't implements Zend_Uri * @return Zend_Uri * @link http://www.faqs.org/rfcs/rfc2396.html */ - public static function factory($uri = 'http') + public static function factory($uri = 'http', $className = null) { // Separate the scheme from the scheme-specific parts $uri = explode(':', $uri, 2); @@ -104,31 +106,44 @@ abstract class Zend_Uri throw new Zend_Uri_Exception('Illegal scheme supplied, only alphanumeric characters are permitted'); } - /** - * Create a new Zend_Uri object for the $uri. If a subclass of Zend_Uri exists for the - * scheme, return an instance of that class. Otherwise, a Zend_Uri_Exception is thrown. - */ - switch ($scheme) { - case 'http': - // Break intentionally omitted - case 'https': - $className = 'Zend_Uri_Http'; - break; - - case 'mailto': - // TODO - default: - // require_once 'Zend/Uri/Exception.php'; - throw new Zend_Uri_Exception("Scheme \"$scheme\" is not supported"); - break; + if ($className === null) { + /** + * Create a new Zend_Uri object for the $uri. If a subclass of Zend_Uri exists for the + * scheme, return an instance of that class. Otherwise, a Zend_Uri_Exception is thrown. + */ + switch ($scheme) { + case 'http': + // Break intentionally omitted + case 'https': + $className = 'Zend_Uri_Http'; + break; + + case 'mailto': + // TODO + default: + // require_once 'Zend/Uri/Exception.php'; + throw new Zend_Uri_Exception("Scheme \"$scheme\" is not supported"); + break; + } } // if (!class_exists($className)) { // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($className); + // try { + // Zend_Loader::loadClass($className); + // } catch (Exception $e) { + // require_once 'Zend/Uri/Exception.php'; + // throw new Zend_Uri_Exception("\"$className\" not found"); + // } // } + $schemeHandler = new $className($scheme, $schemeSpecific); + if (! $schemeHandler instanceof Zend_Uri) { + // require_once 'Zend/Uri/Exception.php'; + throw new Zend_Uri_Exception("\"$className\" is not an instance of Zend_Uri"); + } + return $schemeHandler; } diff --git a/libs/Zend/Validate/Db/Abstract.php b/libs/Zend/Validate/Db/Abstract.php index 01bbc13e86..5811c495a9 100644 --- a/libs/Zend/Validate/Db/Abstract.php +++ b/libs/Zend/Validate/Db/Abstract.php @@ -16,7 +16,7 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Abstract.php 20412 2010-01-19 07:02:01Z thomas $ + * @version $Id: Abstract.php 22225 2010-05-21 09:12:52Z bittarman $ */ /** @@ -278,10 +278,10 @@ abstract class Zend_Validate_Db_Abstract extends Zend_Validate_Abstract */ $select = new Zend_Db_Select($this->_adapter); $select->from($this->_table, array($this->_field), $this->_schema) - ->where($this->_adapter->quoteIdentifier($this->_field).' = ?', $value); + ->where($this->_adapter->quoteIdentifier($this->_field, true).' = ?', $value); if ($this->_exclude !== null) { if (is_array($this->_exclude)) { - $select->where($this->_adapter->quoteIdentifier($this->_exclude['field']).' != ?', $this->_exclude['value']); + $select->where($this->_adapter->quoteIdentifier($this->_exclude['field'], true).' != ?', $this->_exclude['value']); } else { $select->where($this->_exclude); } diff --git a/libs/Zend/Validate/Identical.php b/libs/Zend/Validate/Identical.php index ce08faab91..7b37574050 100644 --- a/libs/Zend/Validate/Identical.php +++ b/libs/Zend/Validate/Identical.php @@ -16,7 +16,7 @@ * @package Zend_Validate * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Identical.php 20096 2010-01-06 02:05:09Z bkarwin $ + * @version $Id: Identical.php 22077 2010-05-02 13:44:46Z thomas $ */ /** @see Zend_Validate_Abstract */ @@ -42,7 +42,7 @@ class Zend_Validate_Identical extends Zend_Validate_Abstract * @var array */ protected $_messageTemplates = array( - self::NOT_SAME => "The token '%token%' does not match the given token '%value%'", + self::NOT_SAME => "The two given tokens do not match", self::MISSING_TOKEN => 'No token was provided to match against', ); @@ -59,6 +59,7 @@ class Zend_Validate_Identical extends Zend_Validate_Abstract */ protected $_tokenString; protected $_token; + protected $_strict = true; /** * Sets validator options @@ -72,16 +73,28 @@ class Zend_Validate_Identical extends Zend_Validate_Abstract $token = $token->toArray(); } - if (is_array($token) && (count($token) == 1) && array_key_exists('token', $token)) { - $token = $token['token']; - } + if (is_array($token) && array_key_exists('token', $token)) { + if (array_key_exists('strict', $token)) { + $this->setStrict($token['strict']); + } - if (null !== $token) { + $this->setToken($token['token']); + } else if (null !== $token) { $this->setToken($token); } } /** + * Retrieve token + * + * @return string + */ + public function getToken() + { + return $this->_token; + } + + /** * Set token against which to compare * * @param mixed $token @@ -95,13 +108,24 @@ class Zend_Validate_Identical extends Zend_Validate_Abstract } /** - * Retrieve token + * Returns the strict parameter * - * @return string + * @return boolean */ - public function getToken() + public function getStrict() { - return $this->_token; + return $this->_strict; + } + + /** + * Sets the strict parameter + * + * @param Zend_Validate_Identical + */ + public function setStrict($strict) + { + $this->_strict = (boolean) $strict; + return $this; } /** @@ -111,19 +135,26 @@ class Zend_Validate_Identical extends Zend_Validate_Abstract * matches that token. * * @param mixed $value + * @param array $context * @return boolean */ - public function isValid($value) + public function isValid($value, $context = null) { $this->_setValue((string) $value); - $token = $this->getToken(); + + if (($context !== null) && isset($context) && array_key_exists($this->getToken(), $context)) { + $token = $context[$this->getToken()]; + } else { + $token = $this->getToken(); + } if ($token === null) { $this->_error(self::MISSING_TOKEN); return false; } - if ($value !== $token) { + $strict = $this->getStrict(); + if (($strict && ($value !== $token)) || (!$strict && ($value != $token))) { $this->_error(self::NOT_SAME); return false; } diff --git a/libs/Zend/Version.php b/libs/Zend/Version.php index 0d233b9670..392ae3c7df 100644 --- a/libs/Zend/Version.php +++ b/libs/Zend/Version.php @@ -16,7 +16,7 @@ * @package Zend_Version * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License - * @version $Id: Version.php 21736 2010-04-02 12:05:02Z matthew $ + * @version $Id: Version.php 22304 2010-05-26 14:25:33Z matthew $ */ /** @@ -32,7 +32,7 @@ final class Zend_Version /** * Zend Framework version identification - see compareVersion() */ - const VERSION = '1.10.4'; + const VERSION = '1.10.5'; /** * Compare the specified Zend Framework version string $version |