This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e4bb29b
commit 9ff5361
Showing
9 changed files
with
260 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
<?php | ||
/** | ||
* @version $Id$ | ||
* @package Appleseed.Components | ||
* @subpackage Comments | ||
* @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' ); | ||
|
||
/** Comments Component Controller | ||
* | ||
* Comments Component Controller Class | ||
* | ||
* @package Appleseed.Components | ||
* @subpackage Comments | ||
*/ | ||
class cCommentsCommentsController extends cController { | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @access public | ||
*/ | ||
public function __construct ( ) { | ||
parent::__construct( ); | ||
} | ||
|
||
function Display ( $pView = null, $pData = array ( ) ) { | ||
|
||
$this->_Current = $this->Talk ( 'User', 'Current' ); | ||
$this->_Focus = $this->Talk ( 'User', 'Focus' ); | ||
|
||
$Context = $pData['Context']; | ||
$Context_FK = $pData['Id']; | ||
|
||
if ( ( !$Context ) || ( !$Context_FK ) ) { | ||
// Display error loading comments | ||
$this->View = $this->GetView ( 'error' ); | ||
$this->View->Display ( ); | ||
|
||
return ( true ); | ||
} | ||
|
||
$this->View = $this->GetView ( ); | ||
|
||
$this->Model = $this->GetModel ( ); | ||
|
||
$this->Comments = $this->Model->Load ( $Context, $Context_FK ); | ||
|
||
$ol = $this->View->Find ( '.comments', 0); | ||
|
||
$row = $this->View->Copy ( '.comments' )->Find ( 'ol', 0 ); | ||
|
||
$rowOriginal = $row->outertext; | ||
|
||
$ol->innertext = ''; | ||
|
||
foreach ( $this->Comments as $c => $comment ) { | ||
if ( $comment['Parent_ID'] ) continue; | ||
|
||
$row = new cHTML (); | ||
$row->Load ( $rowOriginal ); | ||
|
||
$this->_PrepComment ( $row, $comment ); | ||
|
||
if ( $Children = $this->_GetChildren ( $comment['Entry_PK'] ) ) { | ||
$row->Find ( '.nesting', 0 )->innertext = $this->_BuildChildren ( $comment['Entry_PK'], $Children, $rowOriginal ); | ||
} | ||
|
||
$ol->innertext .= $row->outertext; | ||
unset ( $row ); | ||
} | ||
|
||
$this->View->Display(); | ||
|
||
return ( true ); | ||
} | ||
|
||
private function _GetChildren ( $pParent ) { | ||
|
||
$children = array ( ); | ||
|
||
foreach ( $this->Comments as $c => $comment ) { | ||
if ( $comment['Parent_ID'] == $pParent ) { | ||
$children[] = $comment; | ||
} | ||
} | ||
|
||
if ( count ( $children ) == 0 ) return ( false ); | ||
|
||
return ( $children ); | ||
} | ||
|
||
private function _BuildChildren ( $pParent, $pChildren, $pOriginal ) { | ||
|
||
$return = ''; | ||
|
||
foreach ( $pChildren as $c => $child ) { | ||
if ( $child['Parent_ID'] != $pParent ) continue; | ||
|
||
$row = new cHTML (); | ||
$row->Load ( $pOriginal ); | ||
|
||
$row->Find ( 'ol', 0 )->class = 'comments nested'; | ||
|
||
$this->_PrepComment ( $row, $child ); | ||
|
||
if ( $Children = $this->_GetChildren ( $child['Entry_PK'] ) ) { | ||
$row->Find ( '.nesting', 0 )->innertext .= $this->_BuildChildren ( $child['Entry_PK'], $Children, $pOriginal ); | ||
} | ||
|
||
$return .= $row->outertext; | ||
|
||
unset ( $row ); | ||
|
||
} | ||
|
||
return ( $return ); | ||
} | ||
|
||
private function _PrepComment ( $pRow, $pItem ) { | ||
|
||
if ( $pItem['Status'] != 1 ) { | ||
$this->_PrepDeletedComment ( $pRow, $pItem ); | ||
return ( true ); | ||
} | ||
|
||
list ( $username, $domain ) = explode ( '@', $pItem['Owner'] ); | ||
$data = array ( 'username' => $username, 'domain' => $domain, 'width' => 32, 'height' => 32 ); | ||
$pRow->Find ( '.comment-icon', 0 )->src = $this->GetSys ( 'Event' )->Trigger ( 'On', 'User', 'Icon', $data ); | ||
|
||
$pRow->Find ( '.comment-body', 0 )->innertext = $this->GetSys ( 'Render' )->Format ( $pItem['Body'] ); | ||
$pRow->Find ( '.stamp', 0 )->innertext = $this->GetSys ( 'Date' )->Format ( $pItem['Created'] ); | ||
|
||
$pRow->Find ( '.comment-user-link', 0 )->rel = $pItem['Owner']; | ||
$pRow->Find ( '.comment-user-link', 0 )->innertext = $pItem['Owner']; | ||
|
||
$data = array ( 'account' => $pItem['Owner'], 'source' => ASD_DOMAIN ); | ||
$OwnerLink = $this->GetSys ( 'Event' )->Trigger ( 'Create', 'User', 'Link', $data ); | ||
$pRow->Find ( '.comment-user-link', 0 )->href = $OwnerLink; | ||
$pRow->Find ( '.comment-icon-link', 0 )->href = $OwnerLink; | ||
|
||
if ( ( $this->_Current->Account == $this->_Focus->Account ) or ( $this->_Current->Account == $pItem['Owner'] ) ) { | ||
$pRow->Find ( '.delete', 0 )->href = ""; | ||
} else { | ||
$pRow->Find ( '.delete-area', 0 )->outertext = ""; | ||
} | ||
|
||
return ( true ); | ||
} | ||
|
||
private function _PrepDeletedComment ( $pRow, $pItem ) { | ||
$pRow->Find ( '.comment-body', 0 )->innertext = __ ( 'Deleted Comment' ); | ||
$pRow->Find ( '.comments', 0 )->class .= ' deleted '; | ||
$pRow->Find ( '.delete-area', 0 )->outertext = ''; | ||
$pRow->Find ( '.reply-area', 0 )->outertext = ''; | ||
$pRow->Find ( '.stamp', 0 )->outertext = ''; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
DELETED_COMMENT="This comment has been deleted" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
/** | ||
* @version $Id$ | ||
* @package Appleseed.Components | ||
* @subpackage Comments | ||
* @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' ); | ||
|
||
/** Comments Component Model | ||
* | ||
* Comments Component Model Class | ||
* | ||
* @package Appleseed.Components | ||
* @subpackage Comments | ||
*/ | ||
class cCommentsModel extends cModel { | ||
|
||
protected $_Tablename = "CommentEntries"; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @access public | ||
*/ | ||
public function __construct ( $pTables = null ) { | ||
parent::__construct( $pTables ); | ||
} | ||
|
||
public function Load ( $pContext, $pId ) { | ||
|
||
$this->Retrieve ( array ( 'Context' => $pContext, 'Context_FK' => $pId ) ); | ||
|
||
if ( $this->Get ( 'Total' ) == 0 ) return ( false ); | ||
|
||
$result = array (); | ||
|
||
while ( $this->Fetch ( ) ) { | ||
$items[] = $this->Get ( 'Data' ) ; | ||
} | ||
|
||
return ( $items ); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<h1>Read Comments</h1> | ||
<ol class="comments outer"> | ||
<li> | ||
<div class="comment"> | ||
<div class="comment-icon-area"> | ||
<a class="comment-icon-link" href="#"><img class="comment-icon" src="" alt="Commenter Icon" /></a> | ||
</div> | ||
<div class="comment-content"> | ||
<div class="comment-area"> | ||
<a class="comment-user-link" href="#"></a> | ||
<span class="comment-body"></span> | ||
</div> | ||
<abbr class="stamp"></abbr> | ||
<nav> | ||
<ul> | ||
<li class="delete-area"><button class="delete">Delete</button></li> | ||
<li class="reply-area"><button class="reply">Reply</button></li> | ||
</ul> | ||
</nav> | ||
</div> | ||
</div> | ||
</li> | ||
<li class='nesting'></li> | ||
</ol> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<h1>Read Comments</h1> | ||
<p class='error'>Error Loading Comments</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ | |
<section class="comments"></section> | ||
</section> | ||
|
||
<section class="comments"></section> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters