diff --git a/protected/modules_core/comment/CommentModule.php b/protected/modules_core/comment/CommentModule.php index ab7faf82cf..3a357aa1fb 100644 --- a/protected/modules_core/comment/CommentModule.php +++ b/protected/modules_core/comment/CommentModule.php @@ -6,14 +6,16 @@ * @package humhub.modules_core.comment * @since 0.5 */ -class CommentModule extends CWebModule { +class CommentModule extends CWebModule +{ /** * On content deletion make sure to delete all its comments * * @param CEvent $event */ - public static function onContentDelete($event) { + public static function onContentDelete($event) + { foreach (Comment::model()->findAllByAttributes(array('object_model' => get_class($event->sender), 'object_id' => $event->sender->id)) as $comment) { $comment->delete(); @@ -25,7 +27,8 @@ class CommentModule extends CWebModule { * * @param CEvent $event */ - public static function onUserDelete($event) { + public static function onUserDelete($event) + { foreach (Comment::model()->findAllByAttributes(array('created_by' => $event->sender->id)) as $comment) { $comment->delete(); @@ -38,7 +41,8 @@ class CommentModule extends CWebModule { * * @param CEvent $event */ - public static function onIntegrityCheck($event) { + public static function onIntegrityCheck($event) + { $integrityChecker = $event->sender; $integrityChecker->showTestHeadline("Validating Comment Module (" . Comment::model()->count() . " entries)"); @@ -59,13 +63,9 @@ class CommentModule extends CWebModule { * * @param CEvent $event */ - public static function onWallEntryLinksInit($event) { - - $event->sender->addWidget('application.modules_core.comment.widgets.CommentLinkWidget', array( - 'modelName' => $event->sender->object->content->object_model, - 'modelId' => $event->sender->object->content->object_id, - ), array('sortOrder' => 10) - ); + public static function onWallEntryLinksInit($event) + { + $event->sender->addWidget('application.modules_core.comment.widgets.CommentLinkWidget', array('object' => $event->sender->object), array('sortOrder' => 10)); } /** @@ -73,13 +73,9 @@ class CommentModule extends CWebModule { * * @param CEvent $event */ - public static function onWallEntryAddonInit($event) { - - $event->sender->addWidget('application.modules_core.comment.widgets.CommentsWidget', array( - 'modelName' => $event->sender->object->content->object_model, - 'modelId' => $event->sender->object->content->object_id, - ), array('sortOrder' => 20) - ); + public static function onWallEntryAddonInit($event) + { + $event->sender->addWidget('application.modules_core.comment.widgets.CommentsWidget', array('object' => $event->sender->object), array('sortOrder' => 20)); } -} \ No newline at end of file +} diff --git a/protected/modules_core/comment/controllers/CommentController.php b/protected/modules_core/comment/controllers/CommentController.php index 55321588eb..6a81ae73a1 100644 --- a/protected/modules_core/comment/controllers/CommentController.php +++ b/protected/modules_core/comment/controllers/CommentController.php @@ -6,7 +6,8 @@ * @package humhub.modules_core.comment.controllers * @since 0.5 */ -class CommentController extends Controller { +class CommentController extends Controller +{ // Used by loadTargetModel() to avoid multiple loading private $cachedLoadedTarget = null; @@ -14,7 +15,8 @@ class CommentController extends Controller { /** * @return array action filters */ - public function filters() { + public function filters() + { return array( 'accessControl', // perform access control for CRUD operations ); @@ -25,7 +27,8 @@ class CommentController extends Controller { * This method is used by the 'accessControl' filter. * @return array access control rules */ - public function accessRules() { + public function accessRules() + { return array( array('allow', // allow authenticated user to perform 'create' and 'update' actions 'users' => array('@'), @@ -42,7 +45,8 @@ class CommentController extends Controller { * * @return type */ - private function loadTargetModel() { + private function loadTargetModel() + { // Fast lane if ($this->cachedLoadedTarget != null) @@ -83,7 +87,8 @@ class CommentController extends Controller { /** * Returns a List of all Comments belong to this Model */ - public function actionShow() { + public function actionShow() + { $target = $this->loadTargetModel(); @@ -101,10 +106,31 @@ class CommentController extends Controller { Yii::app()->end(); } + public function actionShowPopup() + { + + $target = $this->loadTargetModel(); + + $output = ""; + + // Get new current comments + $comments = Comment::model()->findAllByAttributes(array('object_model' => get_class($target), 'object_id' => $target->id)); + + foreach ($comments as $comment) { + $output .= $this->widget('application.modules_core.comment.widgets.ShowCommentWidget', array('comment' => $comment), true); + } + + + $id = get_class($target) . "_" . $target->id; + $this->renderPartial('show', array('object' => $target, 'output' => $output, 'id' => $id), false, true); + + } + /** * Handles AJAX Post Request to submit new Comment */ - public function actionPost() { + public function actionPost() + { $this->forcePostRequest(); $target = $this->loadTargetModel(); @@ -151,7 +177,8 @@ class CommentController extends Controller { * Handles AJAX Request for Comment Deletion. * Currently this is only allowed for the Comment Owner. */ - public function actionDelete() { + public function actionDelete() + { $this->forcePostRequest(); $target = $this->loadTargetModel(); @@ -175,4 +202,4 @@ class CommentController extends Controller { return $this->actionShow(); } -} \ No newline at end of file +} diff --git a/protected/modules_core/comment/views/comment/show.php b/protected/modules_core/comment/views/comment/show.php new file mode 100644 index 0000000000..1af08140df --- /dev/null +++ b/protected/modules_core/comment/views/comment/show.php @@ -0,0 +1,47 @@ + + - -
- - - + widget('application.modules_core.comment.widgets.CommentFormWidget', array('object' => $object)); ?> - - - 'newCommentForm_' . $id, 'rows' => '1', 'class' => 'form-control autosize commentForm', 'placeholder' => 'Write a new comment...')); ?> - - widget('application.widgets.MentionWidget', array( - 'element' => '#newCommentForm_' . $id, - )); - - ?> - - "function() { - $('#newCommentForm_" . $id . "').blur(); - }", - 'success' => "function(html) { - $('#comments_area_" . $id . "').html(html); - $('#newCommentForm_" . $id . "').val('').trigger('autosize.resize'); - $.fn.mention.reset('#newCommentForm_" . $id . "'); - - }", - ), array( - 'id' => "comment_create_post_" . $id, - 'class' => 'btn btn-small btn-primary', - 'style' => 'position: absolute; top: -3000px; left: -3000px;', - ) - ); - ?> - - -
\ No newline at end of file diff --git a/protected/modules_core/comment/widgets/views/commentsLink.php b/protected/modules_core/comment/widgets/views/commentsLink.php deleted file mode 100644 index 25c348fc0b..0000000000 --- a/protected/modules_core/comment/widgets/views/commentsLink.php +++ /dev/null @@ -1,16 +0,0 @@ - "$('#comment_" . $id . "').show();$('#newCommentForm_" . $id . "').focus();return false;")); -?> diff --git a/protected/modules_core/comment/widgets/views/form.php b/protected/modules_core/comment/widgets/views/form.php new file mode 100644 index 0000000000..8f08465bbc --- /dev/null +++ b/protected/modules_core/comment/widgets/views/form.php @@ -0,0 +1,81 @@ + + + + +
+ + + + + + 'newCommentForm_' . $id, 'rows' => '1', 'class' => 'form-control autosize commentForm', 'placeholder' => 'Write a new comment...')); ?> + + widget('application.widgets.MentionWidget', array( + 'element' => '#newCommentForm_' . $id, + )); + ?> + + "function() { + $('#newCommentForm_" . $id . "').blur(); + }", + 'success' => "function(html) { + + $('#comments_area_" . $id . "').html(html); + $('#newCommentForm_" . $id . "').val('').trigger('autosize.resize'); + $.fn.mention.reset('#newCommentForm_" . $id . "'); + + }", + ), array( + 'id' => "comment_create_post_" . $id, + 'class' => 'btn btn-small btn-primary', + 'style' => 'position: absolute; top: -3000px; left: -3000px;', + ) + ); + ?> + + + +
+ + \ No newline at end of file diff --git a/protected/modules_core/comment/widgets/views/link.php b/protected/modules_core/comment/widgets/views/link.php new file mode 100644 index 0000000000..5f324c45fd --- /dev/null +++ b/protected/modules_core/comment/widgets/views/link.php @@ -0,0 +1,23 @@ + + + + Comments (getCommentsCount(); ?>) + + "$('#comment_" . $id . "').show();$('#newCommentForm_" . $id . "').focus();return false;")); ?> + \ No newline at end of file diff --git a/protected/modules_core/comment/widgets/views/showComment.php b/protected/modules_core/comment/widgets/views/showComment.php index 47c969a7be..2c708ce948 100644 --- a/protected/modules_core/comment/widgets/views/showComment.php +++ b/protected/modules_core/comment/widgets/views/showComment.php @@ -9,47 +9,40 @@ * @since 0.5 */ ?> -
- - 40x40 - +
+ + 40x40 + -
-

displayName; ?> created_at); ?>

- - message); - //print nl2br($comment->message); - ?> - +
+

displayName; ?> created_at); ?>

+ + message); + ?> + - + -
- canDelete()) { - $deleteUrl = CHtml::normalizeUrl(array('//comment/comment/delete', 'model' => $comment->object_model, 'id' => $comment->object_id, 'cid' => $comment->id)); - echo HHtml::ajaxLink(Yii::t('base', 'Delete'), $deleteUrl, array( - 'type' => 'POST', - 'data' => array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken), - 'success' => "function(html) { - $('#comments_area_" . $comment->object_model . "_" . $comment->object_id . "').html(html); - }", +
+ canDelete()) { + $deleteUrl = CHtml::normalizeUrl(array('//comment/comment/delete', 'model' => $comment->object_model, 'id' => $comment->object_id, 'cid' => $comment->id)); + echo HHtml::ajaxLink(Yii::t('base', 'Delete'), $deleteUrl, array( + 'type' => 'POST', + 'data' => array(Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken), + 'success' => "function(html) { $('#comments_area_" . $comment->object_model . "_" . $comment->object_id . "').html(html); }", ), array( - 'id' => "comment_delete_link" . $comment->id + 'id' => "comment_delete_link" . $comment->id ) - ); - echo " - "; - } - ?> + ); + echo " - "; + } + ?> - getController()->widget('application.modules_core.like.widgets.LikeLinkWidget', array('object' => $comment)); ?> -
+ getController()->widget('application.modules_core.like.widgets.LikeLinkWidget', array('object' => $comment)); ?>
-
- -getController()->widget('application.modules_core.like.widgets.ShowLikesWidget', array('object' => $comment)); -?> \ No newline at end of file +
+
diff --git a/protected/modules_core/space/SpaceControllerBehavior.php b/protected/modules_core/space/SpaceControllerBehavior.php index 94a568a86f..4cfb69f922 100644 --- a/protected/modules_core/space/SpaceControllerBehavior.php +++ b/protected/modules_core/space/SpaceControllerBehavior.php @@ -69,6 +69,16 @@ class SpaceControllerBehavior extends CBehavior { return $space; } + + public function createContainerUrl($route, $params = array(), $ampersand = '&') { + + if (!isset($params['sguid'])) { + $params['sguid'] = $this->getSpace()->guid; + } + + return $this->owner->createUrl($route, $params, $ampersand); + } + } ?>