Fixed a bug with the Singleton freeze/thaw, added an RSS feed Viewer and changed the pagination to include the word 'page' in the URL.

git-svn-id: http://svn.cleancode.org/svn/pickles@41 4d10bc64-7434-11dc-a737-d2d0f8310089
This commit is contained in:
Josh Sherman 2008-09-03 04:09:07 +00:00
parent 7c1b477731
commit f4a0ab7e4f
5 changed files with 86 additions and 24 deletions

View file

@ -28,7 +28,6 @@ class Config extends Singleton {
// @todo no hardcoded paths!
$file = '/var/www/josh/pickles/config/' . $site . '.xml';
if (!isset($this->file) || $this->file != $file) {
if (file_exists($file)) {
$this->file = $file;
@ -54,7 +53,6 @@ class Config extends Singleton {
}
}
}
}
}

View file

@ -98,8 +98,6 @@ class Controller extends Object {
$this->viewer = Viewer::factory($this->model);
$this->viewer->display();
}
//var_dump($name, $this->session, $_SESSION, $_SERVER);
}
/*

59
classes/Viewer/RSS.php Normal file
View file

@ -0,0 +1,59 @@
<?php
class Viewer_RSS extends Viewer_Common {
public function display() {
$config = Config::getInstance();
$data = $this->model->getData();
if (isset($data['channel'])) {
$channel = $config->rss[$data['channel']];
if (isset($data['items'])) {
$items = $data['items'];
}
else {
// Error - no items
}
}
else {
// Error - no channel specified
}
header('Content-type: application/rss+xml; charset=UTF-8');
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<rss version="2.0">
<channel>
<title><?=$channel['title'];?></title>
<link>http://<?=$_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];?></link>
<description><?=$channel['description'];?></description>
<category><?=$channel['category'];?></category>
<language><?=$channel['language'] ? $channel['language'] : 'en-us';?></language>
<?php
if (is_array($items)) {
foreach ($items as $key => $item) {
$date = date('r', strtotime($item['date']));
if ($key == 0) {
echo "<lastBuildDate>{$date}</lastBuildDate>";
}
?>
<item>
<title><?=$item['title'];?></title>
<link><?=$item['link'];?></link>
<description><![CDATA[<?=$item['description'];?>]]></description>
<author><?=$item['author'];?></author>
<pubDate><?=$date;?></pubDate>
<guid><?=$item['guid'];?></guid>
</item>
<?php
}
}
?>
</channel>
</rss>
<?php
}
}
?>

View file

@ -31,4 +31,11 @@
<recipient>joshsherman@gmail.com</recipient>
</recipients>
</contact>
<rss>
<releases>
<title>Very Nice Noise Releases</title>
<description>Very Nice Noise is primarily a netlabel, which means that we offer music that is available exclusively through free MP3 downloads, and we will eventually start releasing the occasional CD-R and DVD-R releases as well. All MP3 releases on this site are free for you to download and distribute as you wish, as long as it it not done for profit. The label was started to help give more control back to the talented artists of the noise "music" community by way of faster turn around times on releases, no file type restrictions (if you want to release in the less popular OGG format, that's cool with us) and by giving artists the ability to maintain their own artist profile on the site. Our genre focus, as our name suggests is noise (harsh noise, drone, glitch, power electronics and the like).</description>
<category>Music</category>
</releases>
</rss>
</config>

View file

@ -32,13 +32,13 @@ function smarty_function_pagination($params, &$smarty) {
$pagination .= '</span>';
*/
$pagination .= $current != 1 ? '<a href="/' . $section . '/' . ($current - 1) . '">' . $prev . '</a>' : '<span class="prev">' . $prev . '</span>';
$pagination .= $current != 1 ? '<a href="/' . $section . '/page/' . ($current - 1) . '">' . $prev . '</a>' : '<span class="prev">' . $prev . '</span>';
for ($i = 1; $i <= $total; $i++) {
$pagination .= $i != $current ? '<a href="/' . $section . '/' . $i . '">' . $i . '</a>' : '<span class="current">' . $i . '</span>';
$pagination .= $i != $current ? '<a href="/' . $section . '/page/' . $i . '">' . $i . '</a>' : '<span class="current">' . $i . '</span>';
}
$pagination .= $current != $total ? '<a href="/' . $section . '/' . ($current + 1) . '">' . $next . '</a>' : '<span class="next">' . $next . '</span>';
$pagination .= $current != $total ? '<a href="/' . $section . '/page/' . ($current + 1) . '">' . $next . '</a>' : '<span class="next">' . $next . '</span>';
/*
$pagination .= ' <span class="pagination">';