cvs: pear /XML_Feed_Parser/Parser Atom.php RSS2Element.php
| From: | James Stewart | Date: | Sun, 16 Oct 2005 22:50:02 +0000 |
| Subject: | cvs: pear /XML_Feed_Parser/Parser Atom.php RSS2Element.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-35629@lists.php.net to get a copy of this message | ||
jystewart Sun Oct 16 18:50:02 2005 EDT
Modified files:
/pear/XML_Feed_Parser/Parser Atom.php RSS2Element.php
Log:
Removed redundant @todo note from Atom.php
Implement ispermalink check in getGuid for RSS2 elements
Made methods in RSS2Element.php protected (we want everything to go through __call())
http://cvs.php.net/diff.php/pear/XML_Feed_Parser/Parser/Atom.php?r1=1.5&r2=1.6&ty=u
Index: pear/XML_Feed_Parser/Parser/Atom.php
diff -u pear/XML_Feed_Parser/Parser/Atom.php:1.5 pear/XML_Feed_Parser/Parser/Atom.php:1.6
--- pear/XML_Feed_Parser/Parser/Atom.php:1.5 Sun Oct 16 10:28:27 2005
+++ pear/XML_Feed_Parser/Parser/Atom.php Sun Oct 16 18:49:59 2005
@@ -17,7 +17,7 @@
* @author James Stewart <james@jystewart.net>
* @copyright 2005 James Stewart <james@jystewart.net>
* @license http://www.gnu.org/copyleft/lesser.html GNU LGPL
2.1
- * @version CVS: $Id: Atom.php,v 1.5 2005/10/16 14:28:27 jystewart Exp $
+ * @version CVS: $Id: Atom.php,v 1.6 2005/10/16 22:49:59 jystewart Exp $
* @link http://dev.jystewart.net/XML_Feed_Parser/
*/
@@ -32,7 +32,6 @@
* @author James Stewart <james@jystewart.net>
* @version Release: @package_version@
* @package XML_Feed_Parser
- * @todo Improve attribute access
*/
class XML_Feed_Parser_Atom extends XML_Feed_Parser_Type
{
http://cvs.php.net/diff.php/pear/XML_Feed_Parser/Parser/RSS2Element.php?r1=1.2&r2=1.3&ty=u
Index: pear/XML_Feed_Parser/Parser/RSS2Element.php
diff -u pear/XML_Feed_Parser/Parser/RSS2Element.php:1.2
pear/XML_Feed_Parser/Parser/RSS2Element.php:1.3
--- pear/XML_Feed_Parser/Parser/RSS2Element.php:1.2 Sat Oct 15 11:06:22 2005
+++ pear/XML_Feed_Parser/Parser/RSS2Element.php Sun Oct 16 18:49:59 2005
@@ -17,7 +17,7 @@
* @author James Stewart <james@jystewart.net>
* @copyright 2005 James Stewart <james@jystewart.net>
* @license http://www.gnu.org/copyleft/lesser.html GNU LGPL
2.1
- * @version CVS: $Id: RSS2Element.php,v 1.2 2005/10/15 15:06:22 jystewart Exp $
+ * @version CVS: $Id: RSS2Element.php,v 1.3 2005/10/16 22:49:59 jystewart Exp $
* @link http://dev.jystewart.net/XML_Feed_Parser/
*/
@@ -78,18 +78,29 @@
}
/**
- * guid is the closest RSS2 has to atom's ID. It is usually but not always a URI.
- * The one attribute that RSS2 can posess is 'ispermalink' which specifies whether
- * the guid is itself dereferencable. Use of guid is not obligatory, but is
- * advisable.
+ * guid is the closest RSS2 has to atom's ID. It is usually but not always a
+ * URI. The one attribute that RSS2 can posess is 'ispermalink' which specifies
+ * whether the guid is itself dereferencable. Use of guid is not obligatory,
+ * but is advisable. To get the guid you would call $item->id() (for atom
+ * compatibility) or $item->guid(). To check if this guid is a permalink call
+ * $item->guid("ispermalink").
*
- * @todo Implement ispermalink support
- * @return string the guid
+ * @param string $method - the method name being called
+ * @param array $params - parameters required
+ * @return string the guid or value of ispermalink
*/
- function getGuid()
+ protected function getGuid($method, $params)
{
- if ($this->model->getElementsByTagName('guid')->length > 0) {
- return
$this->model->getElementsByTagName('guid')->item(0)->nodeValue;
+ $attribute = (isset($params[0]) and $params[0] == 'ispermalink') ?
+ true : false;
+ $tag = $this->model->getElementsByTagName('guid');
+ if ($tag->length > 0) {
+ if ($ispermalink) {
+ if ($tag->hasAttribute("ispermalink")) {
+ return $tag->getAttribute("ispermalink");
+ }
+ }
+ return $tag->item(0)->nodeValue;
}
return false;
}
@@ -102,7 +113,7 @@
* @param int offset
* @return array|false
*/
- function getEnclosure($offset = 0)
+ protected function getEnclosure($offset = 0)
{
$encs = $this->model->getElementsByTagName('enclosure');
if ($encs->length >= $offset) {
@@ -128,7 +139,7 @@
*
* @return array|false
*/
- function getSource()
+ protected function getSource()
{
$get = $this->model->getElementsByTagName('source');
if ($get->length) {