Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #188 from janich/master

+ [#186] Events: onKContentPrepare implemented in more views + better support
  • Loading branch information...
commit 9b136a28a67c9b80e1b2ce1e8549bd6378847d52 2 parents 8118fad + d1dbc1b
@mahagr mahagr authored
View
23 administrator/components/com_kunena/install/plugins/plg_system_kunena/kunena.php
@@ -78,13 +78,22 @@ public function onKunenaContentPrepare($context, &$items, &$params, $page = 0) {
// Object KunenaForumTopic
case 'kunena.topic':
-
- if ( in_array('title', $jcontentevent_target) ) {
- $this->runJoomlaContentEvent( &$items->subject, &$params, &$page );
+ $items = array( $items );
+
+ // Array of KunenaForumTopic
+ case 'kunena.topics':
+ if ( !is_array( $items )) {
+ break;
}
- if ( in_array('body', $jcontentevent_target) ) {
- $this->runJoomlaContentEvent( &$items->first_post_message, &$params, &$page );
- $this->runJoomlaContentEvent( &$items->last_post_message, &$params, &$page );
+ // Run events on all objects
+ foreach ( $items as $item ) {
+ if ( in_array('title', $jcontentevent_target) ) {
+ $this->runJoomlaContentEvent( $item->subject, $params, $page );
+ }
+ if ( in_array('body', $jcontentevent_target) ) {
+ $this->runJoomlaContentEvent( $item->first_post_message, $params, $page );
+ $this->runJoomlaContentEvent( $item->last_post_message, $params, $page );
+ }
}
break;
@@ -191,4 +200,4 @@ public function onUserAfterSave($user, $isnew, $success, $msg) {
}
*/
}
-}
+}
View
12 components/com_kunena/views/category/view.html.php
@@ -332,6 +332,18 @@ function displayCategories() {
function displayRows() {
$lasttopic = NULL;
$this->position = 0;
+
+ // Run events
+ $params = new JParameter( '' );
+ $params->set('ksource', 'kunena');
+ $params->set('kunena_view', 'category');
+ $params->set('kunena_layout', 'default');
+
+ $dispatcher = JDispatcher::getInstance();
+ JPluginHelper::importPlugin('kunena');
+
+ $dispatcher->trigger('onKunenaContentPrepare', array ('kunena.topics', &$this->topics, &$params, 0));
+
foreach ( $this->topics as $this->topic ) {
$this->position++;
$usertype = $this->me->getType($this->category->id, true);
View
12 components/com_kunena/views/search/view.html.php
@@ -92,6 +92,18 @@ function displaySearchResults() {
function displayRows() {
$this->row(true);
+
+ // Run events
+ $params = new JParameter( '' );
+ $params->set('ksource', 'kunena');
+ $params->set('kunena_view', 'search');
+ $params->set('kunena_layout', 'default');
+
+ $dispatcher = JDispatcher::getInstance();
+ JPluginHelper::importPlugin('kunena');
+
+ $dispatcher->trigger('onKunenaContentPrepare', array ('kunena.messages', &$this->results, &$params, 0));
+
foreach ($this->results as $this->message) {
$this->topic = $this->message->getTopic();
$this->category = $this->message->getCategory();
View
38 components/com_kunena/views/topic/view.html.php
@@ -61,10 +61,12 @@ function displayDefault($tpl = null) {
$messages =& $this->get ( 'Messages' ) ;
$totals = $this->get ( 'Total' );
-
+
// Run events
$params = new JParameter( '' );
$params->set('ksource', 'kunena');
+ $params->set('kunena_view', 'topic');
+ $params->set('kunena_layout', 'default');
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('kunena');
@@ -256,6 +258,17 @@ protected function DisplayReply($tpl = null) {
$this->topic = $parent->getTopic();
}
+ // Run events
+ $params = new JParameter( '' );
+ $params->set('ksource', 'kunena');
+ $params->set('kunena_view', 'topic');
+ $params->set('kunena_layout', 'reply');
+
+ $dispatcher = JDispatcher::getInstance();
+ JPluginHelper::importPlugin('kunena');
+
+ $dispatcher->trigger('onKunenaContentPrepare', array ('kunena.topic', $this->topic, &$params, 0));
+
if (!$parent->authorise('reply')) {
$app = JFactory::getApplication();
$app->enqueueMessage ( $parent->getError(), 'notice' );
@@ -300,6 +313,18 @@ protected function displayEdit($tpl = null) {
if ($this->config->topicicons && $this->topic->authorise('edit', null, false)) {
$this->topicIcons = $this->template->getTopicIcons(false, $saved ? $saved['icon_id'] : $this->topic->icon_id);
}
+
+ // Run events
+ $params = new JParameter( '' );
+ $params->set('ksource', 'kunena');
+ $params->set('kunena_view', 'topic');
+ $params->set('kunena_layout', 'reply');
+
+ $dispatcher = JDispatcher::getInstance();
+ JPluginHelper::importPlugin('kunena');
+
+ $dispatcher->trigger('onKunenaContentPrepare', array ('kunena.topic', &$this->topic, &$params, 0));
+
$this->title = JText::_ ( 'COM_KUNENA_POST_EDIT' ) . ' ' . $this->topic->subject;
$this->action = 'edit';
@@ -826,6 +851,17 @@ function displayThreadHistory() {
}
KunenaUserHelper::loadUsers($userlist);
+ // Run events
+ $params = new JParameter( '' );
+ $params->set('ksource', 'kunena');
+ $params->set('kunena_view', 'topic');
+ $params->set('kunena_layout', 'history');
+
+ $dispatcher = JDispatcher::getInstance();
+ JPluginHelper::importPlugin('kunena');
+
+ $dispatcher->trigger('onKunenaContentPrepare', array ('kunena.messages', &$this->history, &$params, 0));
+
echo $this->loadTemplateFile ( 'history' );
}
Please sign in to comment.
Something went wrong with that request. Please try again.