svn: /phd/trunk/phpdotnet/phd/Package/ Generic/TocFeed.php PEAR/TocFeed.php
| From: | Christian Weiske | Date: | Tue, 13 Oct 2009 17:14:55 +0000 |
| Subject: | svn: /phd/trunk/phpdotnet/phd/Package/ Generic/TocFeed.php PEAR/TocFeed.php | ||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-5140@lists.php.net to get a copy of this message | ||
cweiske Tue, 13 Oct 2009 17:14:55 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=289617
Log:
Make feed location configurable, link feed to self
Changed paths:
U phd/trunk/phpdotnet/phd/Package/Generic/TocFeed.php
U phd/trunk/phpdotnet/phd/Package/PEAR/TocFeed.php
Modified: phd/trunk/phpdotnet/phd/Package/Generic/TocFeed.php
===================================================================
--- phd/trunk/phpdotnet/phd/Package/Generic/TocFeed.php 2009-10-13 11:46:54 UTC (rev 289616)
+++ phd/trunk/phpdotnet/phd/Package/Generic/TocFeed.php 2009-10-13 17:14:55 UTC (rev 289617)
@@ -67,15 +67,26 @@
protected $targetExt = '.htm';
/**
- * Base URI for links from atom feed to chunks.
+ * Base URI for links from atom feed to chunks (HTML files).
*
* Inheriting classes should change this if neccessary.
*
* @var string
* @usedby createTargetLink()
+ */
+ protected $targetBaseUri = null;
+
+ /**
+ * Base URI for the feed files themselves.
+ *
+ * Inheriting classes should change this if neccessary.
+ * If this variable is not set, __construct() sets
+ * it to $targetBaseUri
+ *
+ * @var string
* @usedby createLink()
*/
- protected $targetBaseUri = '';
+ protected $feedBaseUri = null;
/**
* Author string used in atom feed files.
@@ -129,6 +140,9 @@
$this->setChunked(true);
$this->setExt('atom');
$this->date = date('c');
+ if ($this->feedBaseUri === null) {
+ $this->feedBaseUri = $this->targetBaseUri;
+ }
}
@@ -375,20 +389,23 @@
*/
public function header($id)
{
- $title = htmlspecialchars($this->getLongDescription($id));
- $date = $this->date;
- $lang = Config::language();
- $link = $this->createLink($id);
- $author = htmlspecialchars($this->author);
- $atomid = $this->idprefix . 'file/' . $id;
+ $title = htmlspecialchars($this->getLongDescription($id));
+ $date = $this->date;
+ $lang = Config::language();
+ $selflink = $this->createLink($id);
+ $htmllink = $this->createTargetLink($id);
+ $author = htmlspecialchars($this->author);
+ $atomid = $this->idprefix . 'file/' . $id;
return <<<XML
<?xml version="1.0" encoding="utf-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom"
xml:lang="{$lang}">
<title>{$title}</title>
- <link href="{$link}" />
<updated>{$date}</updated>
<id>{$atomid}</id>
+ <link rel="self" type="application/atom+xml" href="{$selflink}"
/>
+ <link rel="alternate" type="text/html" href="{$htmllink}" />
+ <generator uri="http://doc.php.net/phd/">PhD</generator>
<author>
<name>{$author}</name>
</author>
@@ -467,7 +484,7 @@
* to overwrite this method to return full absolute URIs,
* or modify $targetBaseUri.
*
- * @param string $for Chunk ID
+ * @param string $id Chunk ID
* @param string &$desc Description of link, to be filled if neccessary.
* Not used here.
* @param integer $type Format of description, Format::SDESC or
@@ -478,28 +495,28 @@
*
* @uses $targetBaseUri
*/
- public function createLink($for, &$desc = null, $type = Format::SDESC)
+ public function createLink($id, &$desc = null, $type = Format::SDESC)
{
- return $this->targetBaseUri . $for . '.' . $this->ext;
+ return $this->feedBaseUri . $id . '.' . $this->ext;
}
/**
- * Create external link from Atom feed to given chunk ID.
+ * Create external link from Atom feed to given chunk ID (HTML).
*
* Every class inheriting from this one should
* to overwrite this method to return full absolute URIs,
* or modify $targetBaseUri and $targetExt.
*
- * @param string $for Chunk ID
+ * @param string $id Chunk ID
*
* @return string Absolute URI to chunk
*
* @uses $targetBaseUri
* @uses $targetExt
*/
- public function createTargetLink($for)
+ public function createTargetLink($id)
{
- return $this->targetBaseUri. $for . $this->targetExt;
+ return $this->targetBaseUri. $id . $this->targetExt;
}
}
Modified: phd/trunk/phpdotnet/phd/Package/PEAR/TocFeed.php
===================================================================
--- phd/trunk/phpdotnet/phd/Package/PEAR/TocFeed.php 2009-10-13 11:46:54 UTC (rev 289616)
+++ phd/trunk/phpdotnet/phd/Package/PEAR/TocFeed.php 2009-10-13 17:14:55 UTC (rev 289617)
@@ -41,11 +41,22 @@
*
* @var string
* @usedby createTargetLink()
- * @usedby createLink()
*/
protected $targetBaseUri = 'http://pear.php.net/manual/{language}/';
/**
+ * Base URI for the feed files themselves.
+ *
+ * Inheriting classes should change this if neccessary.
+ * If this variable is not set, __construct() sets
+ * it to $targetBaseUri
+ *
+ * @var string
+ * @usedby createLink()
+ */
+ protected $feedBaseUri = 'http://pear.php.net/manual/{language}/feeds/';
+
+ /**
* Author string used in atom feed files.
*
* Inheriting classes should change this.
@@ -79,12 +90,12 @@
parent::__construct();
$language = Config::language();
- $this->targetBaseUri = str_replace(
- '{language}', $language, $this->targetBaseUri
- );
- $this->idprefix = str_replace(
- '{language}', $language, $this->idprefix
- );
+ $variables = array('targetBaseUri', 'feedBaseUri',
'idprefix');
+ foreach ($variables as $varname) {
+ $this->$varname = str_replace(
+ '{language}', $language, $this->$varname
+ );
+ }
}
}