Skip to content

Commit 6452ebc

Browse files
authored
Merge pull request #38 from jeremyvii/master
Conform code to single coding style
2 parents ead0f86 + e923067 commit 6452ebc

File tree

15 files changed

+626
-578
lines changed

15 files changed

+626
-578
lines changed

src/administrator/components/com_dump/controller.php

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,41 +9,47 @@
99
*/
1010
defined( '_JEXEC' ) or die( 'Restricted access' );
1111

12-
class DumpController extends JControllerLegacy{
12+
class DumpController extends JControllerLegacy
13+
{
1314

14-
function display($cachable = false, $urlparams = false) {
15-
$mainframe = JFactory::getApplication();
16-
$option = JRequest::getCmd('option');
17-
$Itemid = JRequest::getInt('Itemid');
18-
15+
function display($cachable = false, $urlparams = false)
16+
{
17+
$mainframe = JFactory::getApplication();
18+
$option = JRequest::getCmd('option');
19+
$Itemid = JRequest::getInt('Itemid');
20+
1921

20-
// we need to add these paths so the component can work in both site and administrator
21-
$this->addViewPath( JPATH_COMPONENT_ADMINISTRATOR . '/views' );
22-
$this->addModelPath( JPATH_COMPONENT_ADMINISTRATOR . '/models' );
22+
// we need to add these paths so the component can work in both site and administrator
23+
$this->addViewPath(JPATH_COMPONENT_ADMINISTRATOR . '/views');
24+
$this->addModelPath(JPATH_COMPONENT_ADMINISTRATOR . '/models');
2325

24-
$document = JFactory::getDocument();
25-
// specify the type of the view (raw for dump tree in Frontend, html for admin comp)
26-
if($mainframe->isSite()) {
27-
// specify the RAW format for the JDump Frontend menu link
28-
$viewType = "raw";
29-
} else {
30-
$viewType = $document->getType();
31-
}
32-
// get some vars
33-
$viewName = JRequest::getCmd( 'view', 'about' );
34-
$viewLayout = JRequest::getCmd( 'layout', 'default' );
26+
$document = JFactory::getDocument();
27+
// specify the type of the view (raw for dump tree in Frontend, html for admin comp)
28+
if ($mainframe->isSite())
29+
{
30+
// specify the RAW format for the JDump Frontend menu link
31+
$viewType = "raw";
32+
}
33+
else
34+
{
35+
$viewType = $document->getType();
36+
}
37+
// get some vars
38+
$viewName = JRequest::getCmd('view', 'about');
39+
$viewLayout = JRequest::getCmd('layout', 'default');
3540

36-
// get the view & set the layout
37-
$view = $this->getView( $viewName, $viewType);
38-
$view->setLayout( $viewLayout );
41+
// get the view & set the layout
42+
$view = $this->getView($viewName, $viewType);
43+
$view->setLayout($viewLayout);
3944

40-
// Get/Create the model
41-
if ( $model = $this->getModel( $viewName ) ) {
42-
// Push the model into the view (as default)
43-
$view->setModel( $model, true );
44-
}
45+
// Get/Create the model
46+
if ($model = $this->getModel($viewName))
47+
{
48+
// Push the model into the view (as default)
49+
$view->setModel($model, true);
50+
}
4551

46-
// Display the view
47-
$view->display();
48-
}
52+
// Display the view
53+
$view->display();
54+
}
4955
}

src/administrator/components/com_dump/defines.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
defined( '_JEXEC' ) or die( 'Restricted access' );
1111

1212
$mainframe = JFactory::getApplication(); $option = JRequest::getCmd('option');
13-
$phpversion = explode( '.', phpversion() );
13+
$phpversion = explode('.', phpversion());
1414

15-
define( 'DUMP_VERSION', '%%VERSION%%' );
16-
define( 'DUMP_URL', JURI::root() . 'administrator/components/com_dump/' );
15+
define('DUMP_VERSION', '%%VERSION%%');
16+
define('DUMP_URL', JURI::root() . 'administrator/components/com_dump/');

src/administrator/components/com_dump/dump.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,21 @@
1111

1212
// use JPATH_COMPONENT_ADMINISTRATOR so we can use this in both site and administrator
1313
// Defines
14-
require_once( JPATH_COMPONENT_ADMINISTRATOR . '/defines.php' );
14+
require_once(JPATH_COMPONENT_ADMINISTRATOR . '/defines.php');
1515
// Require the base controller
16-
require_once( JPATH_COMPONENT_ADMINISTRATOR . '/controller.php' );
16+
require_once(JPATH_COMPONENT_ADMINISTRATOR . '/controller.php');
1717

1818
// Require specific controller if requested
19-
if( $controller = JRequest::getCmd('controller') ) {
20-
require_once ( JPATH_COMPONENT_ADMINISTRATOR . '/controllers/' . $controller . '.php' );
19+
if ($controller = JRequest::getCmd('controller'))
20+
{
21+
require_once (JPATH_COMPONENT_ADMINISTRATOR . '/controllers/' . $controller . '.php');
2122
}
2223

2324
// Create the controller
2425
$classname = 'DumpController'.$controller;
2526
$controller = new $classname();
2627

2728
// Perform the Request task
28-
$controller->execute( JRequest::getCmd( 'task' ) );
29+
$controller->execute(JRequest::getCmd('task'));
2930

3031
$controller->redirect();
Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<extension version="3.0" type="component" method="upgrade">
3-
<name>Dump</name>
4-
<author>Mathias Verraes</author>
5-
<creationDate>%%TODAY%%</creationDate>
6-
<copyright>(c) Mathias Verraes 2006 - 2012</copyright>
7-
<license>GNU/GPL</license>
8-
<authorEmail></authorEmail>
9-
<authorUrl>https://github.com/mathiasverraes/jdump</authorUrl>
10-
<version>%%VERSION%%</version>
11-
<description>J!Dump -- Advanced print_r and var_dump replacer with DHTML tree display.</description>
12-
<files folder="components/com_dump">
13-
<filename>dump.php</filename>
14-
<folder>views</folder>
15-
</files>
16-
<administration>
17-
<files folder="administrator/components/com_dump">
18-
<filename>config.xml</filename>
19-
<filename>controller.php</filename>
20-
<filename>defines.php</filename>
21-
<filename>dump.php</filename>
22-
<filename>helper.php</filename>
23-
<filename>node.php</filename>
3+
<name>Dump</name>
4+
<author>Mathias Verraes</author>
5+
<creationDate>%%TODAY%%</creationDate>
6+
<copyright>(c) Mathias Verraes 2006 - 2012</copyright>
7+
<license>GNU/GPL</license>
8+
<authorEmail></authorEmail>
9+
<authorUrl>https://github.com/mathiasverraes/jdump</authorUrl>
10+
<version>%%VERSION%%</version>
11+
<description>J!Dump -- Advanced print_r and var_dump replacer with DHTML tree display.</description>
12+
<files folder="components/com_dump">
13+
<filename>dump.php</filename>
14+
<folder>views</folder>
15+
</files>
16+
<administration>
17+
<files folder="administrator/components/com_dump">
18+
<filename>config.xml</filename>
19+
<filename>controller.php</filename>
20+
<filename>defines.php</filename>
21+
<filename>dump.php</filename>
22+
<filename>helper.php</filename>
23+
<filename>node.php</filename>
2424
<filename>sysinfo.php</filename>
2525

26-
<folder>assets</folder>
27-
<folder>models</folder>
28-
<folder>views</folder>
29-
</files>
30-
<menu>J!Dump</menu>
31-
</administration>
26+
<folder>assets</folder>
27+
<folder>models</folder>
28+
<folder>views</folder>
29+
</files>
30+
<menu>J!Dump</menu>
31+
</administration>
3232
</extension>

src/administrator/components/com_dump/helper.php

Lines changed: 70 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -12,63 +12,65 @@
1212

1313
class DumpHelper extends JObject {
1414

15-
static function showPopup() {
16-
$mainframe = JFactory::getApplication(); $option = JRequest::getCmd('option');
17-
18-
jimport( 'joomla.application.helper' );
19-
$client = JApplicationHelper::getClientInfo($mainframe->getClientID());
20-
21-
// settings from config.xml
22-
$dumpConfig = JComponentHelper::getParams( 'com_dump' );
23-
$w = $dumpConfig->get( 'popupwidth', 500 );
24-
$h = $dumpConfig->get( 'popupheight', 500 );
25-
26-
// build the url
27-
$url = JURI::base(true).'/index.php?option=com_dump&view=tree&format=raw';
28-
29-
/* @TODO remove this and implement this in a later version using JRoute
30-
// only add Itemid in Site
31-
if ( $mainframe->isSite() ) {
32-
$url .= '&Itemid=' . DumpHelper::getComponentItemid( 'com_dump' );
33-
}
34-
*/
35-
36-
// create the javascript
37-
// We can't use $document, because it's already rendered
38-
$nl = "\n";
39-
$script = $nl. '<!-- J!Dump -->' .$nl.
40-
'<script type="text/javascript">' .$nl.
41-
'// <!--' .$nl.
42-
'window.open( "'.$url.'", "dump_'.$client->name.'", "height='.$h.',width='.$w.',toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1");' .$nl.
43-
'// -->' .$nl.
44-
'</script>' .$nl.
45-
'<!-- / J!Dump -->';
46-
47-
// add the code to the header (thanks jenscski)
48-
// JResponse::appendBody( $script );
49-
$body = JResponse::getBody();
50-
$body = str_replace('</head>', $script.'</head>', $body);
51-
JResponse::setBody($body);
52-
53-
}
15+
16+
static function showPopup()
17+
{
18+
$mainframe = JFactory::getApplication(); $option = JRequest::getCmd('option');
19+
20+
jimport('joomla.application.helper');
21+
$client = JApplicationHelper::getClientInfo($mainframe->getClientID());
22+
23+
// settings from config.xml
24+
$dumpConfig = JComponentHelper::getParams( 'com_dump' );
25+
$w = $dumpConfig->get('popupwidth', 500);
26+
$h = $dumpConfig->get('popupheight', 500);
27+
28+
// build the url
29+
$url = JURI::base(true).'/index.php?option=com_dump&view=tree&format=raw';
30+
31+
/* @TODO remove this and implement this in a later version using JRoute
32+
// only add Itemid in Site
33+
if ( $mainframe->isSite() ) {
34+
$url .= '&Itemid=' . DumpHelper::getComponentItemid( 'com_dump' );
35+
}
36+
*/
37+
38+
// create the javascript
39+
// We can't use $document, because it's already rendered
40+
$nl = "\n";
41+
$script = $nl. '<!-- J!Dump -->' .$nl.
42+
'<script type="text/javascript">' .$nl.
43+
'// <!--' .$nl.
44+
'window.open( "'.$url.'", "dump_'.$client->name.'", "height='.$h.',width='.$w.',toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1");' .$nl.
45+
'// -->' .$nl.
46+
'</script>' .$nl.
47+
'<!-- / J!Dump -->';
48+
49+
// add the code to the header (thanks jenscski)
50+
// JResponse::appendBody( $script );
51+
$body = JResponse::getBody();
52+
$body = str_replace('</head>', $script.'</head>', $body);
53+
JResponse::setBody($body);
54+
55+
}
5456

5557
/* @TODO remove this and implement this in a later version using JRoute
56-
function getComponentItemid( $option ) {
57-
jimport('joomla.application.menu');
58-
$menu = JMenu::getInstance();
59-
$components = $menu->getItems( 'type', 'component' );
60-
61-
$attribs['option'] = '';
62-
foreach( $components as $component ) {
63-
$str = str_replace( 'index.php?', '', $component->link );
64-
parse_str( $str, $attribs );
65-
if( $attribs['option'] == $option ){
66-
return $component->id;
67-
}
68-
}
69-
// if no Itemid is found (because there's no menuitem for $option), return current
70-
return $GLOBALS['Itemid'];
71-
}
58+
function getComponentItemid( $option ) {
59+
jimport('joomla.application.menu');
60+
$menu = JMenu::getInstance();
61+
$components = $menu->getItems( 'type', 'component' );
62+
63+
$attribs['option'] = '';
64+
foreach( $components as $component ) {
65+
$str = str_replace( 'index.php?', '', $component->link );
66+
parse_str( $str, $attribs );
67+
if( $attribs['option'] == $option ){
68+
return $component->id;
69+
}
70+
}
71+
// if no Itemid is found (because there's no menuitem for $option), return current
72+
return $GLOBALS['Itemid'];
73+
}
7274
*/
7375

7476

@@ -100,21 +102,23 @@ static function getSourcePath(&$trace)
100102
$path = 'File: '.str_replace(JPATH_BASE.'/', '', $trace[0]['file'])
101103
. '<br />'
102104
. 'Line: '.$trace[0]['line']
103-
. '<br />';
105+
. '<br />';
104106

105107
return $path;
106108
}
107109

108-
static function & getMaxDepth() {
109-
static $maxdepth = null;
110+
static function & getMaxDepth()
111+
{
112+
static $maxdepth = null;
110113

111-
if ( !$maxdepth ) {
112-
$dumpConfig = JComponentHelper::getParams( 'com_dump' );
113-
$maxdepth = intval( $dumpConfig->get( 'maxdepth', 5 ) );
114-
if( $maxdepth > 20 ) $maxdepth=20;
115-
if( $maxdepth < 1 ) $maxdepth=1;
116-
}
114+
if (!$maxdepth)
115+
{
116+
$dumpConfig = JComponentHelper::getParams('com_dump');
117+
$maxdepth = intval($dumpConfig->get('maxdepth', 5));
118+
if( $maxdepth > 20 ) $maxdepth = 20;
119+
if( $maxdepth < 1 ) $maxdepth = 1;
120+
}
117121

118-
return $maxdepth;
119-
}
122+
return $maxdepth;
123+
}
120124
}

src/administrator/components/com_dump/models/tree.php

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,34 @@
99
*/
1010
defined( '_JEXEC' ) or die( 'Restricted access' );
1111

12-
class DumpModelTree extends JModelLegacy {
13-
var $_nodes = array();
12+
class DumpModelTree extends JModelLegacy
13+
{
14+
var $_nodes = array();
1415

15-
function __construct() {
16-
$mainframe = JFactory::getApplication(); $option = JRequest::getCmd('option');
16+
function __construct()
17+
{
18+
$mainframe = JFactory::getApplication(); $option = JRequest::getCmd('option');
1719

18-
//get the userstate
19-
$this->_nodes = $mainframe->getUserState( 'dump.nodes' );
20-
if ( !is_array( $this->_nodes ) ) {
21-
$this->_nodes = array();
22-
}
23-
// and clear it
24-
$mainframe->setUserState( 'dump.nodes', array() );
20+
//get the userstate
21+
$this->_nodes = $mainframe->getUserState('dump.nodes');
22+
if (!is_array($this->_nodes))
23+
{
24+
$this->_nodes = array();
25+
}
26+
// and clear it
27+
$mainframe->setUserState('dump.nodes', array());
2528

26-
parent::__construct();
29+
parent::__construct();
2730

28-
}
31+
}
2932

30-
function & getNodes() {
31-
return $this->_nodes;
32-
}
33+
function & getNodes()
34+
{
35+
return $this->_nodes;
36+
}
3337

34-
function countDumps() {
35-
return count( $this->_nodes ) ;
36-
}
38+
function countDumps()
39+
{
40+
return count( $this->_nodes ) ;
41+
}
3742
}

0 commit comments

Comments
 (0)