Skip to content

Commit f65a34a

Browse files
committed
Initial commit.
0 parents  commit f65a34a

30 files changed

+2907
-0
lines changed

.gitignore

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# OS
2+
.DS_Store
3+
Thumbs.db
4+
5+
# IDEs
6+
.buildpath
7+
.project
8+
.settings/
9+
.build/
10+
.external*/
11+
.idea/
12+
nbproject/
13+
14+
# composer related
15+
vendor/
16+
17+
# build
18+
build/

.travis.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
language: php
2+
php:
3+
- "5.3"
4+
- "5.4"
5+
- "5.5"
6+
env:
7+
global:
8+
matrix:
9+
- CONTAO_VERSION=~2.11.0
10+
- CONTAO_VERSION=~3.1.0
11+
- CONTAO_VERSION=~3.2.0
12+
- CONTAO_VERSION=~3.3.0
13+
14+
install:
15+
- composer require contao/core $CONTAO_VERSION --prefer-dist --dev
16+
- composer install --prefer-dist --dev
17+
18+
script: ant -keep-going

build.xml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0"?>
2+
<project name="contao-debugger" default="test">
3+
<target name="phpunit">
4+
<exec dir="${basedir}" executable="vendor/bin/phpunit" failonerror="true" />
5+
</target>
6+
7+
<target name="phpcs">
8+
<exec dir="${basedir}" executable="vendor/bin/phpcs" failonerror="true">
9+
<arg line="--standard=${basedir}/vendor/metamodels/php-coding-standard/MetaModels/ruleset.xml ${basedir}/src"/>
10+
</exec>
11+
</target>
12+
13+
<target name="test" depends="phpunit,phpcs"/>
14+
</project>

composer.json

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name":"cyberspectrum/contao-debugger",
3+
"description":"General purpose debugger integration for Contao",
4+
"keywords":["contao", "debugger"],
5+
"type":"contao-module",
6+
"homepage":"http://www.cyberspectrum.de/",
7+
"license":"LGPL-3.0+",
8+
"authors": [
9+
{
10+
"name":"Christian Schiffler",
11+
"email":"[email protected]",
12+
"homepage":"http://www.cyberspectrum.de",
13+
"role":"Developer"
14+
}
15+
],
16+
"require": {
17+
"php":">=5.3",
18+
"contao/core": ">=3.1,<=3.3",
19+
"contao-community-alliance/composer-plugin": "~2.0",
20+
"maximebf/debugbar": "1.9@dev"
21+
},
22+
"require-dev": {
23+
"metamodels/php-coding-standard": "*",
24+
"pdepend/pdepend": "1.1.*",
25+
"phpunit/phpunit": ">=3.7.10,<4-dev",
26+
"phpmd/phpmd": "1.5"
27+
},
28+
"autoload": {
29+
"psr-0": {
30+
"CyberSpectrum\\ContaoDebugger\\": "src"
31+
}
32+
},
33+
"extra":{
34+
"contao": {
35+
"sources": {
36+
"contao": "system/modules/debug"
37+
}
38+
},
39+
"branch-alias": {
40+
"dev-master": "1.0.x-dev"
41+
}
42+
},
43+
"minimum-stability": "dev"
44+
}

contao/assets/.htaccess

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<IfModule !mod_authz_core.c>
2+
Order allow,deny
3+
Allow from all
4+
</IfModule>
5+
<IfModule mod_authz_core.c>
6+
Require all granted
7+
</IfModule>

contao/assets/icons.png

500 Bytes
Loading

contao/assets/logo.png

1.33 KB
Loading

contao/assets/php-icon.png

3.54 KB
Loading

contao/config/autoload.ini

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
;;
2+
; List modules which are required to be loaded beforehand
3+
;;
4+
requires[] = "core"
5+
6+
;;
7+
; Configure what you want the autoload creator to register
8+
;;
9+
register_namespaces = false
10+
register_classes = false
11+
register_templates = false

contao/config/autoload.php

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<?php
2+
/**
3+
* Contao Debugger
4+
*
5+
* Copyright (c) 2014 Christian Schiffler
6+
*
7+
* @package ContaoDebugger
8+
* @author Christian Schiffler <[email protected]>
9+
* @copyright 2014 CyberSpectrum
10+
* @license LGPL-3+
11+
* @filesource
12+
*/

contao/config/config.php

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
/**
3+
* Contao Debugger
4+
*
5+
* Copyright (c) 2014 Christian Schiffler
6+
*
7+
* @package ContaoDebugger
8+
* @author Christian Schiffler <[email protected]>
9+
* @copyright 2014 CyberSpectrum
10+
* @license LGPL-3+
11+
* @filesource
12+
*/
13+
14+
define('CONTAO_DEBUGGER_DEBUG_EVENTS', true);
15+
//define('CONTAO_DEBUGGER_DEBUG_PROFILING', true);
16+
17+
if (defined('CONTAO_DEBUGGER_DEBUG_EVENTS') && CONTAO_DEBUGGER_DEBUG_EVENTS)
18+
{
19+
$GLOBALS['TL_EVENTS']['ContaoCommunityAlliance\Contao\EventDispatcher\Event\CreateEventDispatcher'][] =
20+
'CyberSpectrum\ContaoDebugger\Events\DebuggedEventDispatcher::register';
21+
};
22+
23+
$GLOBALS['debugger-panels']['database'] = function($debugger)
24+
{
25+
return new \CyberSpectrum\ContaoDebugger\DebugBar\DataCollector\ContaoSQLCollector($debugger['time']);
26+
};
27+
28+
$GLOBALS['debugger'] = CyberSpectrum\ContaoDebugger\Debugger::boot();

contao/data/.htaccess

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<IfModule mod_authz_core.c>
2+
Require all granted
3+
</IfModule>
4+
<IfModule !mod_authz_core.c>
5+
Order Deny,Allow
6+
Allow from all
7+
</IfModule>

contao/data/retrieve.php

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
/**
3+
* Contao Debugger
4+
*
5+
* Copyright (c) 2014 Christian Schiffler
6+
*
7+
* @package ContaoDebugger
8+
* @author Christian Schiffler <[email protected]>
9+
* @copyright 2014 CyberSpectrum
10+
* @license LGPL-3+
11+
* @filesource
12+
*/
13+
14+
define('TL_MODE', 'BE');
15+
16+
// Search the initialize.php.
17+
$dir = dirname($_SERVER['SCRIPT_FILENAME']);
18+
19+
while ($dir != '.' && $dir != '/' && !is_file($dir . '/system/initialize.php'))
20+
{
21+
$dir = dirname($dir);
22+
}
23+
24+
if (!is_file($dir . '/system/initialize.php'))
25+
{
26+
echo 'Could not find initialize.php, where is Contao?';
27+
exit;
28+
}
29+
30+
require_once $dir . '/system/initialize.php';
31+
32+
// @codingStandardsIgnoreStart - We want to access the $_GET array.
33+
if (isset($_GET['asset']))
34+
{
35+
\CyberSpectrum\ContaoDebugger\Debugger::generateAsset($_GET['asset']);
36+
return;
37+
}
38+
// @codingStandardsIgnoreEnd
39+
\CyberSpectrum\ContaoDebugger\Debugger::getPersisted();

phpunit.xml.dist

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
syntaxCheck="false"
12+
bootstrap="tests/bootstrap.php"
13+
>
14+
<testsuites>
15+
<testsuite name="generic-comments tests">
16+
<directory>./tests/</directory>
17+
</testsuite>
18+
</testsuites>
19+
20+
<groups>
21+
<exclude>
22+
<group>slow</group>
23+
</exclude>
24+
</groups>
25+
26+
<filter>
27+
<whitelist>
28+
<directory>./src/</directory>
29+
</whitelist>
30+
</filter>
31+
</phpunit>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
<?php
2+
/**
3+
* Contao Debugger
4+
*
5+
* Copyright (c) 2014 Christian Schiffler
6+
*
7+
* @package ContaoDebugger
8+
* @author Christian Schiffler <[email protected]>
9+
* @copyright 2014 CyberSpectrum
10+
* @license LGPL-3+
11+
* @filesource
12+
*/
13+
14+
namespace CyberSpectrum\ContaoDebugger\Database;
15+
16+
use CyberSpectrum\ContaoDebugger\DebugBar\DataCollector\ContaoSQLCollector;
17+
18+
/**
19+
* Debugger delegator for Contao Database.
20+
*/
21+
class DatabaseDebugger extends \ArrayObject
22+
{
23+
/**
24+
* The database collector in use.
25+
*
26+
* @var ContaoSQLCollector
27+
*/
28+
protected $collector = null;
29+
30+
/**
31+
* Attach the debugger to the Contao Database.
32+
*
33+
* @param ContaoSQLCollector $collector The SQL collector to use.
34+
*
35+
* @return void
36+
*/
37+
public static function attach(ContaoSQLCollector $collector = null)
38+
{
39+
static $attached;
40+
41+
if (isset($attached))
42+
{
43+
return;
44+
}
45+
46+
$watcher = new self($collector);
47+
48+
$reflection = new \ReflectionClass('\Database');
49+
$property = $reflection->getProperty('arrInstances');
50+
$property->setAccessible(true);
51+
$property->setValue($watcher);
52+
53+
$reflection = new \ReflectionClass('\Contao\Database');
54+
$property = $reflection->getProperty('arrInstances');
55+
$property->setAccessible(true);
56+
$property->setValue($watcher);
57+
58+
$attached = true;
59+
}
60+
61+
/**
62+
* Log a statement.
63+
*
64+
* @param array $info The information.
65+
*
66+
* @return void
67+
*/
68+
public function addStatement($info)
69+
{
70+
if ($this->collector)
71+
{
72+
$this->collector->addStatement($info);
73+
}
74+
}
75+
76+
/**
77+
* Create a new instance.
78+
*
79+
* @param ContaoSQLCollector $collector The SQL collector to use.
80+
*/
81+
public function __construct(ContaoSQLCollector $collector = null)
82+
{
83+
parent::__construct(array(), (self::STD_PROP_LIST | self::ARRAY_AS_PROPS));
84+
$this->collector = $collector;
85+
}
86+
87+
/**
88+
* Get an offset in the array object.
89+
*
90+
* @param string $index The hash key of the database to be fetched.
91+
*
92+
* @return mixed
93+
*/
94+
public function offsetGet($index)
95+
{
96+
$val = parent::offsetGet($index);
97+
return $val;
98+
}
99+
100+
/**
101+
* Set an offset in the array object.
102+
*
103+
* @param string $index The hash key of the database to be set.
104+
*
105+
* @param \Database $newVal The new Database instance.
106+
*
107+
* @return void
108+
*/
109+
public function offsetSet($index, $newVal)
110+
{
111+
$val = new DatabaseDelegator($newVal, $this);
112+
113+
parent::offsetSet($index, $val);
114+
}
115+
116+
/**
117+
* Returns whether the requested database connection exists.
118+
*
119+
* @param string $index The hash key of the database to be checked.
120+
*
121+
* @return bool true if the requested database exists, otherwise false.
122+
*/
123+
public function offsetExists($index)
124+
{
125+
$val = parent::offsetExists($index);
126+
return $val;
127+
}
128+
129+
/**
130+
* Unregister the database with the given hash key.
131+
*
132+
* @param string $index The hash key of the database to be checked.
133+
*
134+
* @return void
135+
*/
136+
// @codingStandardsIgnoreStart - The override is not useless, we need it for the phpDoc.
137+
public function offsetUnset($index)
138+
{
139+
parent::offsetUnset($index);
140+
}
141+
// @codingStandardsIgnoreEnd
142+
}

0 commit comments

Comments
 (0)