Permalink
Browse files

добавил rss-ленту со списком последних проектов

  • Loading branch information...
1 parent 62c3bb5 commit 96f1eb35bed8ce59af67a555da71107d45ea40e4 @FladeX committed Jan 7, 2012
@@ -3,5 +3,6 @@
# default values
all:
- projects_per_page: 5
- last_viewed_projects: 3
+ projects_per_page: 5 # количество проектов на страницу на главной сайта
+ last_viewed_projects: 3 # количество проектов в списке последних просмотров
+ rss_projects_count: 10 # количество проектов в rss-ленте
@@ -0,0 +1,13 @@
+<?php use_helper('Text') ?>
+<?php foreach ($projects as $i => $project): ?>
+ <?php if ($i < sfConfig::get('app_rss_projects_count')): ?>
+ <entry>
+ <title><?php echo $project->getTitle() ?></title>
+ <link href="<?php echo url_for('projects_show', $project, true) ?>" />
+ <id><?php echo sha1($project->getId()) ?></id>
+ <updated><?php echo gmstrftime('%Y-%m-%dT%H:%M:%SZ', $project->getDateTimeObject('created_at')->format('U')) ?></updated>
+ <summary><?php echo $project->getText() ?></summary>
+ <author><name><?php echo $project->getAuthorId() ?></name></author>
+ </entry>
+ <?php endif; ?>
+<?php endforeach ?>
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+ <title>Posting.ru</title>
+ <subtitle>Проекты</subtitle>
+ <link href="<?php echo url_for('projects', array('sf_format' => 'atom'), true) ?>" rel="self" />
+ <link href="<?php echo url_for('homepage', true) ?>" />
+ <updated><?php echo gmstrftime('%Y-%m-%dT%H:%M:%SZ', Doctrine_Core::getTable('projects')->getLatestProjects()->getDateTimeObject('created_at')->format('U')) ?></updated>
+ <author><name>Posting.ru</name></author>
+ <id><?php echo sha1(url_for('projects', array('sf_format' => 'atom'), true)) ?></id>
+
+ <?php include_partial('projects/list', array('projects' => $projects)) ?>
+
+</feed>
@@ -104,7 +104,7 @@
<div class="sidebarBlock">
<div id="feedBlock" >
- <a href="#">RSS-лента</a>
+ <a href="<?php echo url_for('projects', array('sf_format' => 'atom')) ?>">RSS-лента</a>
</div>
</div>
@@ -7,6 +7,7 @@
<?php include_stylesheets() ?>
<title><?php if (!include_slot('title')): ?>Posting.ru<?php endif; ?></title>
<link rel="shortcut icon" href="/favicon.ico" />
+<link rel="alternate" type="application/atom+xml" title="Проекты" href="<?php echo url_for('projects', array('sf_format' => 'atom'), true) ?>" />
</head>
<body>
@@ -51,4 +51,13 @@ public function addActiveProjectsQuery(Doctrine_Query $q = null)
return $q;
}
+
+ public function getLatestProjects()
+ {
+ $q = Doctrine_Query::create()
+ ->from('projects p');
+ $this->addActiveProjectsQuery($q);
+
+ return $q->fetchOne();
+ }
}

0 comments on commit 96f1eb3

Please sign in to comment.