Skip to content

Commit 6f611b0

Browse files
committed
Merge branch 'yireo-patch-1' into develop
2 parents c4603b1 + 875c5c0 commit 6f611b0

File tree

2 files changed

+50
-10
lines changed

2 files changed

+50
-10
lines changed

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
joomla-catcher
2+
==============
3+
4+
Catcher is a bundle of plugins and a library for catching and debug Joomla! events.
5+
6+
## Installation
7+
8+
### Composer
9+
10+
You can install this package using [Composer](https://getcomposer.org/). Create a `composer.json` file inside the root directory of your Joomla! site containing the following code:
11+
12+
```
13+
{
14+
"require": {
15+
"nooku/pkg_catcher": "dev-master"
16+
},
17+
"minimum-stability": "dev"
18+
}
19+
```
20+
21+
Run composer install.
22+
23+
### Phing
24+
25+
For convenience, a [phing](http://www.phing.info/) script for building the package is also available under the `/scripts/build` folder of the repo.
26+
27+
After building it, the package may be installed using the Joomla! extension manager.
28+
29+
## Usage
30+
31+
After the package is installed, make sure to enable the plugins and configure them to catch and report events.

packages/lib_catcher/plugin/abstract.php

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,30 @@ protected function _reportEvent($event, $config = array())
4242

4343
if (in_array($event, $events))
4444
{
45-
$message = '<div class="well">';
45+
$output = '<div class="well">';
4646

4747
$args = $config['message']['parameters'];
48+
4849
array_unshift($args, $config['message']['text']);
49-
$message .= call_user_func_array(array('JText', 'sprintf'), $args);
50+
51+
$message = call_user_func_array(array('JText', 'sprintf'), $args);
52+
53+
$output .= $message;
5054

5155
if (isset($config['new']))
5256
{
5357
if ($config['new']) {
54-
$message .= '<br/>' . JText::_('LIB_CATCHER_ITEM_NEW');
58+
$output .= '<br/>' . JText::_('LIB_CATCHER_ITEM_NEW');
5559
} else {
56-
$message .= '<br/>' . JText::_('LIB_CATCHER_ITEM_NOT_NEW');
60+
$output .= '<br/>' . JText::_('LIB_CATCHER_ITEM_NOT_NEW');
5761
}
5862
}
5963

6064
if ($this->params->get('show_data') && ($data = $this->_renderData($config['data'])))
6165
{
6266
$signature = sprintf('%s_%s', $event, md5($data . microtime()));
6367

64-
$message .= '<br/><div class="panel-group" id="accordion">
68+
$output .= '<br/><div class="panel-group" id="accordion">
6569
<div class="panel panel-default">
6670
<div class="panel-heading">
6771
<h5 class="panel-title" style="margin: 0px;">
@@ -74,14 +78,19 @@ protected function _reportEvent($event, $config = array())
7478
<div id="' . $signature . '" class="panel-collapse collapse">
7579
<div class="panel-body" style="word-break: break-all;">';
7680

77-
$message .= $data;
81+
$output .= $data;
7882

79-
$message .= '</div></div></div></div>';
83+
$output .= '</div></div></div></div>';
8084
}
8185

82-
$message .= '</div>';
86+
$output .= '</div>';
87+
88+
JFactory::getApplication()->enqueueMessage($output, 'warning');
8389

84-
JFactory::getApplication()->enqueueMessage($message, 'warning');
90+
// Add a log entry.
91+
jimport('joomla.log.log');
92+
JLog::addLogger(array('text_file' => 'catcher.php'), JLog::ALL, array('catcher'));
93+
JLog::add(strip_tags($message), JLog::DEBUG, 'catcher');
8594
}
8695
}
8796

@@ -139,4 +148,4 @@ protected function _renderData($data, $level = 0)
139148

140149
return $output;
141150
}
142-
}
151+
}

0 commit comments

Comments
 (0)