Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Added public RSS feeds for user journals
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelchisari authored and The Appleseed Project committed Dec 5, 2010
1 parent d9a388b commit 797f0c4
Show file tree
Hide file tree
Showing 8 changed files with 682 additions and 1 deletion.
3 changes: 3 additions & 0 deletions components/journal/controllers/entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,8 @@ private function _PrepMessage ( ) {

return ( true );
}

public function RSS ( ) {
}

}
75 changes: 75 additions & 0 deletions components/journal/controllers/rss.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?php
/**
* @version $Id$
* @package Appleseed.Components
* @subpackage Journal
* @copyright Copyright (C) 2004 - 2010 Michael Chisari. All rights reserved.
* @link http://opensource.appleseedproject.org
* @license GNU General Public License version 2.0 (See LICENSE.txt)
*/

// Restrict direct access
defined( 'APPLESEED' ) or die( 'Direct Access Denied' );

/** Journal Component Controller
*
* Journal Component RSS Controller Class
*
* @package Appleseed.Components
* @subpackage Journal
*/
class cJournalRSSController extends cController {

/**
* Constructor
*
* @access public
*/
public function __construct ( ) {
parent::__construct( );
}

public function Display ( $pView = null, $pData = array ( ) ) {

$this->_Current = $this->Talk ( 'User', 'Current' );
$this->_Focus = $this->Talk ( 'User', 'Focus' );

$this->View = $this->GetView ( "entries" );

$this->Model = $this->GetModel();

if ( !$this->Model->Everybody ( $this->_Focus->Id, array ( 'start' => 0, 'step' => 20 ) ) ) {
return ( false );
}

$RSS = $this->GetSys ( 'RSS' );

$RSSTitle = __ ( 'RSS Feed Title', array ( 'fullname' => $this->_Focus->Fullname, 'domain' => ASD_DOMAIN ) );

$RSSDescription = $this->_Focus->Description;
$RSSUrl = 'http://' . ASD_DOMAIN . '/profile/' . $this->_Focus->Username . '/journal/';
$RSS->Create ( $RSSTitle, $RSSDescription, $RSSUrl );

while ( $this->Model->Fetch() ) {
$Item = $this->Model->Get ( 'Title' );
$Description = $this->GetSys ( 'Render' )->Format ( $this->Model->Get ( 'Body' ) );
$Created = $this->Model->Get ( 'Created' );

$Author = $this->_Focus->Fullname;

$Url = 'http://' . ASD_DOMAIN . '/profile/' . $this->_Focus->Username . '/journal/' . strtolower ( str_replace ( ' ', '-', $this->Model->Get ( 'Title' ) ) );
$Guid = 'http://' . ASD_DOMAIN . '/profile/' . $this->_Focus->Username . '/journal/' . $this->Model->Get ( 'Identifier' );

$RSS->Open ( $Item, $Description, $Url );
$RSS->Element ( 'guid', $Guid );
$RSS->Element ( 'author', $Author );
$RSS->Element ( 'pubDate', date("D, d M Y H:i:s e", strtotime ( $Created ) ) );
$RSS->Close ( );
}

echo $RSS->Output() ;

return ( true );
}

}
4 changes: 3 additions & 1 deletion components/journal/languages/en-US/journal.lang
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ BACK_TO_ENTRIES="&larr; journal entries"
LOGIN_TO_SEE_THIS_PAGE="You must log in to see this page."

EDIT_CANCELLED="Your changes have been cancelled"
ITEM_SAVED="Your journal entry has been saved"
ITEM_SAVED="Your journal entry has been saved"

RSS_FEED_TITLE="%fullname$s's Journal on %domain$s"
32 changes: 32 additions & 0 deletions components/journal/models/journal.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,36 @@ public function Entries ( $pUserId, $pLimit ) {
return ( true );
}

/*
* Retrieve entries which are available to everybody (for RSS feeds )
*
*/
public function Everybody ( $pUserId, $pLimit ) {
eval ( GLOBALS );

// $this->Retrieve ( array ( 'Owner_FK' => $pUserId ), 'Created DESC', $pLimit );

$start = $pLimit['start'] ? $pLimit['start'] : 0;
$limit = $pLimit['limit'] ? $pLimit['limit'] : 10;

$this->Privacy = new cModel('PrivacySettings');

// We're not logged in, so search for Everybody
$criteria = array ( 'User_FK' => $pUserId, 'Everybody' => true );

$this->Privacy->Retrieve ( $criteria );

// No identifiers were found, which means no entries were found.
if ( $this->Privacy->Get ( 'Total' ) == 0 ) return ( false );

while ( $this->Privacy->Fetch() ) {
$Identifiers[] = $this->Privacy->Get ( 'Identifier' );
}

$this->Retrieve ( array ( 'Owner_FK' => $pUserId, 'Identifier' => '()' . implode ( ',', $Identifiers ) ), 'Created DESC', $pLimit );

return ( true );
}


}
24 changes: 24 additions & 0 deletions components/journal/views/rss.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<section id="profile-journal">
<p class="entries-message"></p>
<a class="add">Add New</a>
<a class="rss">RSS Feed</a>
<nav class="pagination">
</nav>
<ul class="journal-entries">
<li class="summary">
<article>
<h2> <span class="title"><a class="title-link"></a></span> <abbr class="created"></abbr> </h2>
<div class="body"></div>
<nav class="actions">
<a class="comments">0 Comments</a>
<a class="readmore">Read More</a>
</nav>
</article>
</li>
</ul>
<nav class="pagination">
</nav>
</section>
1 change: 1 addition & 0 deletions foundations/default/profile/journal/rss.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php $zApp->Components->Go ( "journal", "rss", "rss" ); ?>

0 comments on commit 797f0c4

Please sign in to comment.