diff --git a/CommentingPlugin.php b/CommentingPlugin.php index c9557ac..e677dc4 100644 --- a/CommentingPlugin.php +++ b/CommentingPlugin.php @@ -1,9 +1,20 @@ _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) diff --git a/controllers/CommentController.php b/controllers/CommentController.php index c0895e7..e54f5a2 100644 --- a/controllers/CommentController.php +++ b/controllers/CommentController.php @@ -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; } - } \ No newline at end of file diff --git a/views/helpers/GetCommentForm.php b/views/helpers/GetCommentForm.php index c7f3556..84e264d 100644 --- a/views/helpers/GetCommentForm.php +++ b/views/helpers/GetCommentForm.php @@ -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) { diff --git a/views/public/common/comments.php b/views/public/common/comments.php index 42e440a..8a31b92 100644 --- a/views/public/common/comments.php +++ b/views/public/common/comments.php @@ -9,11 +9,11 @@ $comments)); ?> - partial('threaded-comments.php', array('comments' => $comments, 'parent_id'=>null)); ?> + partial('common/threaded-comments.php', array('comments' => $comments, 'parent_id'=>null)); ?>
- partial('comment.php', array('comment' => $comment)); ?> + partial('common/comment.php', array('comment' => $comment)); ?>
diff --git a/views/public/common/threaded-comments.php b/views/public/common/threaded-comments.php index 24767cb..2e16898 100644 --- a/views/public/common/threaded-comments.php +++ b/views/public/common/threaded-comments.php @@ -1,11 +1,11 @@ - + parent_comment_id == $parent_id): ?>
- partial('comment.php', array('comment' => $comment)); ?> + partial('common/comment.php', array('comment' => $comment)); ?>
- partial('threaded-comments.php', array('comments' => $comments, 'parent_id'=>$comment->id)); ?> + partial('common/threaded-comments.php', array('comments' => $comments, 'parent_id' => $comment->id)); ?>
- \ No newline at end of file +