Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adapted paths according to the previous commit.
Browse files Browse the repository at this point in the history
Daniel-KM committed Sep 25, 2014
1 parent 940a960 commit 052d3bb
Showing 5 changed files with 48 additions and 23 deletions.
35 changes: 29 additions & 6 deletions CommentingPlugin.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
<?php

define('COMMENTING_PLUGIN_DIR', PLUGIN_DIR . '/Commenting');

/**
* CommentingPlugin class
*
* @copyright Copyright 2011-2013 Roy Rosenzweig Center for History and New Media
* @license http://www.gnu.org/licenses/gpl-3.0.txt GNU GPLv3
* @package Commenting
*/

/**
* Commenting plugin.
*/
class CommentingPlugin extends Omeka_Plugin_AbstractPlugin
{
/**
* @var array Hooks for the plugin.
*/
protected $_hooks = array(
'install',
'uninstall',
@@ -19,6 +30,9 @@ class CommentingPlugin extends Omeka_Plugin_AbstractPlugin
'initialize'
);

/**
* @var array Filters for the plugin.
*/
protected $_filters = array(
'admin_navigation_main',
'search_record_types',
@@ -54,6 +68,9 @@ public function setUp()
parent::setUp();
}

/**
* Install the plugin.
*/
public function hookInstall()
{
$db = $this->_db;
@@ -140,6 +157,8 @@ public function hookUninstall()
$db = get_db();
$sql = "DROP TABLE IF EXISTS `$db->Comment`";
$db->query($sql);

$this->_uninstallOptions();
}

public function hookPublicHead()
@@ -177,11 +196,13 @@ public static function showComments($args = array())
$view = get_view();
}

$view->addHelperPath(COMMENTING_PLUGIN_DIR . '/helpers', 'Commenting_View_Helper_');
$options = array('threaded'=> get_option('commenting_threaded'), 'approved'=>true);

$comments = isset($args['comments']) ? $args['comments'] : $view->getComments($options);
echo $view->partial('comments.php', array('comments'=>$comments, 'threaded'=>$options['threaded']));
echo $view->partial('common/comments.php', array(
'comments' => $comments,
'threaded' => $options['threaded'],
));
}

if( (get_option('commenting_allow_public') == 1)
@@ -220,7 +241,9 @@ public function hookConfig($args)

public function hookConfigForm()
{
include COMMENTING_PLUGIN_DIR . '/config_form.php';
echo get_view()->partial(
'plugins/commenting-config-form.php'
);
}

public function hookDefineAcl($args)
20 changes: 11 additions & 9 deletions controllers/CommentController.php
Original file line number Diff line number Diff line change
@@ -4,7 +4,9 @@ class Commenting_CommentController extends Omeka_Controller_AbstractActionContro
{
protected $_browseRecordsPerPage = 10;


/**
* Controller-wide initialization. Sets the underlying model to use.
*/
public function init()
{
$this->_helper->db->setDefaultModelName('Comment');
@@ -49,7 +51,7 @@ public function addAction()
$comment->user_id = $user->id;
}
$comment->flagged = 0;
$form = $this->getForm();
$form = $this->_getForm();
$valid = $form->isValid($this->getRequest()->getPost());
if(!$valid) {
$destination .= "#comment-form";
@@ -178,7 +180,8 @@ public function updateFlaggedAction()
$this->_helper->json($response);
}

public function flagAction() {
public function flagAction()
{
$commentId = $_POST['id'];
$comment = $this->_helper->db->getTable('Comment')->find($commentId);
$comment->flagged = true;
@@ -188,7 +191,8 @@ public function flagAction() {
$this->_helper->json($response);
}

public function unflagAction() {
public function unflagAction()
{
$commentId = $_POST['id'];
$comment = $this->_helper->db->getTable('Comment')->find($commentId);
$comment->flagged = 0;
@@ -215,12 +219,10 @@ private function emailFlagged($comment)
}

}


private function getForm()
private function _getForm()
{
require_once(COMMENTING_PLUGIN_DIR . '/CommentForm.php');
return new Commenting_CommentForm();
require_once dirname(dirname(__FILE__)) . '/forms/CommentForm.php';
return new Commenting_CommentForm;
}

}
2 changes: 1 addition & 1 deletion views/helpers/GetCommentForm.php
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ class Commenting_View_Helper_GetCommentForm extends Zend_View_Helper_Abstract
public function getCommentForm()
{
if( (get_option('commenting_allow_public') == 1) || is_allowed('Commenting_Comment', 'add') ) {
require_once(COMMENTING_PLUGIN_DIR . '/CommentForm.php');
require_once dirname(dirname(dirname(__FILE__))) . '/forms/CommentForm.php';
$commentSession = new Zend_Session_Namespace('commenting');
$form = new Commenting_CommentForm();
if($commentSession->post) {
4 changes: 2 additions & 2 deletions views/public/common/comments.php
Original file line number Diff line number Diff line change
@@ -9,11 +9,11 @@
<?php echo fire_plugin_hook('commenting_prepend_to_comments', array('comments' =>$comments)); ?>

<?php if($threaded) :?>
<?php echo $this->partial('threaded-comments.php', array('comments' => $comments, 'parent_id'=>null)); ?>
<?php echo $this->partial('common/threaded-comments.php', array('comments' => $comments, 'parent_id'=>null)); ?>
<?php else: ?>
<?php foreach($comments as $comment): ?>
<div id="comment-<?php echo $comment->id; ?>" class='comment'>
<?php echo $this->partial('comment.php', array('comment' => $comment)); ?>
<?php echo $this->partial('common/comment.php', array('comment' => $comment)); ?>
</div>
<?php endforeach; ?>
<?php endif; ?>
10 changes: 5 additions & 5 deletions views/public/common/threaded-comments.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php
foreach($comments as $comment) : ?>
<?php
foreach($comments as $comment) : ?>
<?php if($comment->parent_comment_id == $parent_id): ?>
<div id="comment-<?php echo $comment->id; ?>" class='comment'>
<?php echo $this->partial('comment.php', array('comment' => $comment)); ?>
<?php echo $this->partial('common/comment.php', array('comment' => $comment)); ?>
<div class='comment-children'>
<?php echo $this->partial('threaded-comments.php', array('comments' => $comments, 'parent_id'=>$comment->id)); ?>
<?php echo $this->partial('common/threaded-comments.php', array('comments' => $comments, 'parent_id' => $comment->id)); ?>
</div>
</div>
<?php endif; ?>
<?php endforeach; ?>
<?php endforeach; ?>

0 comments on commit 052d3bb

Please sign in to comment.