Completed
Pull Request — master (#6)
by
unknown
16s
created
collector/image/PhotoCollector.class.inc.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -5,9 +5,9 @@  discard block
 block discarded – undo
5 5
 final class PhotoCollector extends Collector
6 6
 {
7 7
 
8
-	public static function fetchRow($category, $photo)
9
-	{
10
-		$query = "
8
+    public static function fetchRow($category, $photo)
9
+    {
10
+        $query = "
11 11
 			SELECT
12 12
 				`photo`.`name`,
13 13
 				`photo_category`.`name` AS `category`,
@@ -24,12 +24,12 @@  discard block
 block discarded – undo
24 24
 				`photo`.`name` = '{$photo}' &&
25 25
 				`photo_category`.`name` = '{$category}'
26 26
 			LIMIT 1";
27
-		return self::run_row_query($query);
28
-	}
27
+        return self::run_row_query($query);
28
+    }
29 29
 
30
-	public static function getRow($id)
31
-	{
32
-		$query = "
30
+    public static function getRow($id)
31
+    {
32
+        $query = "
33 33
 			SELECT
34 34
 				`photo`.`name`,
35 35
 				`photo_category`.`name` AS `category`,
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 				`photo`.`photographer` = `photographer`.`id` &&
46 46
 				`photo`.`id` = '{$id}'
47 47
 			LIMIT 1";
48
-		return self::run_row_query($query);
49
-	}
48
+        return self::run_row_query($query);
49
+    }
50 50
 
51 51
 }
Please login to merge, or discard this patch.
collector/Collector.class.inc.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -5,29 +5,29 @@
 block discarded – undo
5 5
 abstract class Collector
6 6
 {
7 7
 
8
-	protected static function run_query($query)
9
-	{
10
-		return Database::select($query);
11
-	}
12
-
13
-	protected static function run_row_query($query)
14
-	{
15
-		return Database::selectRow($query);
16
-	}
17
-
18
-	protected static function get_count($query)
19
-	{
20
-		return Database::selectRow($query)->count;
21
-	}
22
-
23
-	protected static function check_exists($query)
24
-	{
25
-		return Database::selectRow($query) !== null;
26
-	}
27
-
28
-	protected static function escape($string)
29
-	{
30
-		return Database::escape($string);
31
-	}
8
+    protected static function run_query($query)
9
+    {
10
+        return Database::select($query);
11
+    }
12
+
13
+    protected static function run_row_query($query)
14
+    {
15
+        return Database::selectRow($query);
16
+    }
17
+
18
+    protected static function get_count($query)
19
+    {
20
+        return Database::selectRow($query)->count;
21
+    }
22
+
23
+    protected static function check_exists($query)
24
+    {
25
+        return Database::selectRow($query) !== null;
26
+    }
27
+
28
+    protected static function escape($string)
29
+    {
30
+        return Database::escape($string);
31
+    }
32 32
 
33 33
 }
Please login to merge, or discard this patch.
controller/Error301Controller.class.inc.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -5,13 +5,13 @@
 block discarded – undo
5 5
 class Error301Controller extends PageController
6 6
 {
7 7
 
8
-	public function __construct($uri)
9
-	{
10
-		Header::redirect($uri);
11
-		exit;
12
-	}
8
+    public function __construct($uri)
9
+    {
10
+        Header::redirect($uri);
11
+        exit;
12
+    }
13 13
 
14
-	protected function set_head_data() {}
15
-	protected function set_body_data() {}
14
+    protected function set_head_data() {}
15
+    protected function set_body_data() {}
16 16
 
17 17
 }
Please login to merge, or discard this patch.
controller/AJAXController.class.inc.php 1 patch
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -1,60 +1,60 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 Loader::load('utility', array(
4
-	'Header',
5
-	'Request'));
4
+    'Header',
5
+    'Request'));
6 6
 
7 7
 abstract class AJAXController
8 8
 {
9 9
 
10
-	private static $RESPONSE_HEADER = 'sendJSON';
10
+    private static $RESPONSE_HEADER = 'sendJSON';
11 11
 
12
-	private $response = array();
12
+    private $response = array();
13 13
 
14
-	abstract protected function set_data();
14
+    abstract protected function set_data();
15 15
 
16
-	function __construct() {}
16
+    function __construct() {}
17 17
 
18
-	public function activate()
19
-	{
20
-		call_user_func(array('Header', self::$RESPONSE_HEADER));
18
+    public function activate()
19
+    {
20
+        call_user_func(array('Header', self::$RESPONSE_HEADER));
21 21
 		
22
-		$this->set_data();
23
-		echo $this->response_as_json();
24
-	}
25
-
26
-	protected function set_response($message, $type = 'internal')
27
-	{
28
-		switch($type)
29
-		{
30
-			case 'internal' :
31
-				$this->response['internal'] = $message;
32
-			break;
33
-			case 'error' :
34
-				$this->response['error'] = $message;
35
-			default :
36
-				$this->response[$type] = $message;
37
-			break;
38
-		}
39
-	}
40
-
41
-	protected function fail_response($message)
42
-	{
43
-		$this->set_response($message, 'error');
44
-		return false;
45
-	}
46
-
47
-	protected function eject($message)
48
-	{
49
-		$this->fail_response($message);
50
-		echo $this->response_as_json();
51
-		exit();
52
-	}
53
-
54
-	private function response_as_json()
55
-	{
56
-		return json_encode($this->response);
57
-	}
22
+        $this->set_data();
23
+        echo $this->response_as_json();
24
+    }
25
+
26
+    protected function set_response($message, $type = 'internal')
27
+    {
28
+        switch($type)
29
+        {
30
+            case 'internal' :
31
+                $this->response['internal'] = $message;
32
+            break;
33
+            case 'error' :
34
+                $this->response['error'] = $message;
35
+            default :
36
+                $this->response[$type] = $message;
37
+            break;
38
+        }
39
+    }
40
+
41
+    protected function fail_response($message)
42
+    {
43
+        $this->set_response($message, 'error');
44
+        return false;
45
+    }
46
+
47
+    protected function eject($message)
48
+    {
49
+        $this->fail_response($message);
50
+        echo $this->response_as_json();
51
+        exit();
52
+    }
53
+
54
+    private function response_as_json()
55
+    {
56
+        return json_encode($this->response);
57
+    }
58 58
 
59 59
 }
60 60
 
Please login to merge, or discard this patch.
controller/home/HomeController.class.inc.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -8,58 +8,58 @@
 block discarded – undo
8 8
 final class HomeController extends DefaultPageController
9 9
 {
10 10
 
11
-	private static $TITLE = "Jacob Emerick's Home | Web Developer, Hiker, Innovator";
12
-	private static $DESCRIPTION = 'Home page for Jacob Emerick, with links to his blog, waterfall site, and other side projects';
11
+    private static $TITLE = "Jacob Emerick's Home | Web Developer, Hiker, Innovator";
12
+    private static $DESCRIPTION = 'Home page for Jacob Emerick, with links to his blog, waterfall site, and other side projects';
13 13
 
14
-	private static $KEYWORD_ARRAY = array(
15
-		'Jacob Emerick',
16
-		'jacobemerick',
17
-		'jpemeric',
18
-		'home',
19
-		'web developer',
20
-		'hiker',
21
-		'application programmer',
22
-		'innovator');
14
+    private static $KEYWORD_ARRAY = array(
15
+        'Jacob Emerick',
16
+        'jacobemerick',
17
+        'jpemeric',
18
+        'home',
19
+        'web developer',
20
+        'hiker',
21
+        'application programmer',
22
+        'innovator');
23 23
 
24
-	private static $POST_LENGTH_SHORT = 160;
25
-	private static $POST_LENGTH_LONG = 240;
24
+    private static $POST_LENGTH_SHORT = 160;
25
+    private static $POST_LENGTH_LONG = 240;
26 26
 
27
-	protected function set_head_data()
28
-	{
29
-		$this->set_title(self::$TITLE);
30
-		$this->set_description(self::$DESCRIPTION);
31
-		$this->set_keywords(self::$KEYWORD_ARRAY);
27
+    protected function set_head_data()
28
+    {
29
+        $this->set_title(self::$TITLE);
30
+        $this->set_description(self::$DESCRIPTION);
31
+        $this->set_keywords(self::$KEYWORD_ARRAY);
32 32
 		
33
-		parent::set_head_data();
34
-	}
33
+        parent::set_head_data();
34
+    }
35 35
 
36
-	protected function set_body_data()
37
-	{
38
-		$this->set_body('post_array', $this->get_recent_posts());
39
-		$this->set_body_view('Home');
36
+    protected function set_body_data()
37
+    {
38
+        $this->set_body('post_array', $this->get_recent_posts());
39
+        $this->set_body_view('Home');
40 40
 		
41
-		parent::set_body_data();
42
-	}
41
+        parent::set_body_data();
42
+    }
43 43
 
44
-	private function get_recent_posts()
45
-	{
44
+    private function get_recent_posts()
45
+    {
46 46
     global $container;
47 47
     $postRepository = new MysqlPostRepository($container['db_connection_locator']);
48 48
     $recentPosts = $postRepository->getActivePosts(3);
49 49
 
50
-		$recent_post_array = array();
51
-		foreach($recentPosts as $postResult)
52
-		{
53
-			$post = new stdclass();
54
-			$post->title = $postResult['title'];
55
-			$post->url = Loader::getRootUrl('blog') . "{$postResult['category']}/{$postResult['path']}/";
56
-			$post->category = ucwords(str_replace('-', ' ', $postResult['category']));
57
-			$post->thumb = Content::instance('FetchFirstPhoto', $postResult['body'])->activate();
58
-			$post->body = Content::instance('SmartTrim', $postResult['body'])->activate(($post->thumb !== '') ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG);
50
+        $recent_post_array = array();
51
+        foreach($recentPosts as $postResult)
52
+        {
53
+            $post = new stdclass();
54
+            $post->title = $postResult['title'];
55
+            $post->url = Loader::getRootUrl('blog') . "{$postResult['category']}/{$postResult['path']}/";
56
+            $post->category = ucwords(str_replace('-', ' ', $postResult['category']));
57
+            $post->thumb = Content::instance('FetchFirstPhoto', $postResult['body'])->activate();
58
+            $post->body = Content::instance('SmartTrim', $postResult['body'])->activate(($post->thumb !== '') ? self::$POST_LENGTH_SHORT : self::$POST_LENGTH_LONG);
59 59
 						
60
-			$recent_post_array[] = $post;
61
-		}
62
-		return $recent_post_array;
63
-	}
60
+            $recent_post_array[] = $post;
61
+        }
62
+        return $recent_post_array;
63
+    }
64 64
 
65 65
 }
Please login to merge, or discard this patch.
controller/Error303Controller.class.inc.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -5,13 +5,13 @@
 block discarded – undo
5 5
 class Error303Controller extends PageController
6 6
 {
7 7
 
8
-	public function __construct($uri)
9
-	{
10
-		Header::redirect($uri, 303);
11
-		exit;
12
-	}
8
+    public function __construct($uri)
9
+    {
10
+        Header::redirect($uri, 303);
11
+        exit;
12
+    }
13 13
 
14
-	protected function set_head_data() {}
15
-	protected function set_body_data() {}
14
+    protected function set_head_data() {}
15
+    protected function set_body_data() {}
16 16
 
17 17
 }
Please login to merge, or discard this patch.
utility/URLDecode.class.inc.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -3,35 +3,35 @@  discard block
 block discarded – undo
3 3
 class URLDecode
4 4
 {
5 5
 
6
-	private static $array = array();
6
+    private static $array = array();
7 7
 
8
-	static function init()
9
-	{
10
-		$host = $_SERVER['HTTP_HOST'];
11
-		$uri = $_SERVER['REQUEST_URI'];
12
-		self::form_url_array($host, $uri);
13
-	}
8
+    static function init()
9
+    {
10
+        $host = $_SERVER['HTTP_HOST'];
11
+        $uri = $_SERVER['REQUEST_URI'];
12
+        self::form_url_array($host, $uri);
13
+    }
14 14
 
15
-	static private function form_url_array($host, $uri)
16
-	{
17
-		$uri = substr($uri, 1);
18
-		if(strpos($uri, '?'))
19
-			$uri = substr($uri, 0, strpos($uri, '?'));
20
-		$uri_array = explode('/', $uri);
15
+    static private function form_url_array($host, $uri)
16
+    {
17
+        $uri = substr($uri, 1);
18
+        if(strpos($uri, '?'))
19
+            $uri = substr($uri, 0, strpos($uri, '?'));
20
+        $uri_array = explode('/', $uri);
21 21
 		
22
-		if(!Loader::isLive())
23
-			$host = substr($host, strpos($host, '.') + 1);
22
+        if(!Loader::isLive())
23
+            $host = substr($host, strpos($host, '.') + 1);
24 24
 		
25
-		self::$array['host'] = $host;
25
+        self::$array['host'] = $host;
26 26
 		
27 27
     if (
28
-      $host == 'www.waterfallsofthekeweenaw.com' ||
28
+        $host == 'www.waterfallsofthekeweenaw.com' ||
29 29
       $host == 'waterfallsofthekeweenaw.com'
30 30
     ) {
31
-			self::$array['site'] = 'waterfalls';
32
-		} else {
33
-			self::$array['site'] = substr($host, 0, strpos($host, '.'));
34
-		}
31
+            self::$array['site'] = 'waterfalls';
32
+        } else {
33
+            self::$array['site'] = substr($host, 0, strpos($host, '.'));
34
+        }
35 35
 
36 36
     $base = '';
37 37
     $base .= (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
@@ -40,55 +40,55 @@  discard block
 block discarded – undo
40 40
     $base .= $host;
41 41
     $base .= '/';
42 42
 
43
-		self::$array['base'] = $base;
44
-		self::$array['uri'] = '/' . implode('/', $uri_array);
43
+        self::$array['base'] = $base;
44
+        self::$array['uri'] = '/' . implode('/', $uri_array);
45 45
 		
46
-		if(end($uri_array) == '')
47
-			$uri_array = array_slice($uri_array, 0, count($uri_array) - 1);
48
-		self::$array['pieces'] = (array) $uri_array;
49
-	}
46
+        if(end($uri_array) == '')
47
+            $uri_array = array_slice($uri_array, 0, count($uri_array) - 1);
48
+        self::$array['pieces'] = (array) $uri_array;
49
+    }
50 50
 
51
-	static function getSite()
52
-	{
53
-		return self::$array['site'];
54
-	}
51
+    static function getSite()
52
+    {
53
+        return self::$array['site'];
54
+    }
55 55
 
56
-	static function getHost()
57
-	{
58
-		return self::$array['host'];
59
-	}
56
+    static function getHost()
57
+    {
58
+        return self::$array['host'];
59
+    }
60 60
 
61
-	static function getBase()
62
-	{
63
-		return self::$array['base'];
64
-	}
61
+    static function getBase()
62
+    {
63
+        return self::$array['base'];
64
+    }
65 65
 
66
-	static function getURI()
67
-	{
68
-		return self::$array['uri'];
69
-	}
66
+    static function getURI()
67
+    {
68
+        return self::$array['uri'];
69
+    }
70 70
 
71
-	static function getExtension()
72
-	{
73
-		$file = self::getPiece(-1);
74
-		if(substr($file, -1) == '/')
75
-			return false;
76
-		return substr($file, strrpos($file, '.') + 1);;
77
-	}
71
+    static function getExtension()
72
+    {
73
+        $file = self::getPiece(-1);
74
+        if(substr($file, -1) == '/')
75
+            return false;
76
+        return substr($file, strrpos($file, '.') + 1);;
77
+    }
78 78
 
79
-	static function getPiece($piece = null)
80
-	{
81
-		if(!$piece)
82
-			return self::$array['pieces'];
79
+    static function getPiece($piece = null)
80
+    {
81
+        if(!$piece)
82
+            return self::$array['pieces'];
83 83
 		
84
-		if($piece == -1)
85
-			return end(self::$array['pieces']);
84
+        if($piece == -1)
85
+            return end(self::$array['pieces']);
86 86
 		
87
-		$piece = $piece - 1;
88
-		if(array_key_exists($piece, self::$array['pieces']))
89
-			return self::$array['pieces'][$piece];
90
-		return;
91
-	}
87
+        $piece = $piece - 1;
88
+        if(array_key_exists($piece, self::$array['pieces']))
89
+            return self::$array['pieces'][$piece];
90
+        return;
91
+    }
92 92
 
93 93
 }
94 94
 
Please login to merge, or discard this patch.
utility/Database.class.inc.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -3,19 +3,19 @@  discard block
 block discarded – undo
3 3
 final class Database
4 4
 {
5 5
 
6
-	private $read_connection;
7
-	private $write_connection;
8
-	private $query_log = array();
9
-	private $query_total = array(
10
-		'count' => 0,
11
-		'time' => 0);
6
+    private $read_connection;
7
+    private $write_connection;
8
+    private $query_log = array();
9
+    private $query_total = array(
10
+        'count' => 0,
11
+        'time' => 0);
12 12
 
13
-	private $has_connection_error = false;
13
+    private $has_connection_error = false;
14 14
 
15
-	private static $instance;
15
+    private static $instance;
16 16
 
17
-	private function __construct($write_params, $read_params)
18
-	{
17
+    private function __construct($write_params, $read_params)
18
+    {
19 19
         $this->write_connection = $this->connect(
20 20
             $write_params->host,
21 21
             $write_params->user,
@@ -28,23 +28,23 @@  discard block
 block discarded – undo
28 28
             $read_params->password
29 29
         );
30 30
 
31
-		return $this;
32
-	}
31
+        return $this;
32
+    }
33 33
 
34
-	private function connect($host, $username, $password)
35
-	{
36
-		$mysqli = new mysqli($host, $username, $password);
34
+    private function connect($host, $username, $password)
35
+    {
36
+        $mysqli = new mysqli($host, $username, $password);
37 37
 		
38
-		$has_connection_error = $mysqli->connect_error;
39
-		if(isset($has_connection_error))
40
-			$this->has_connection_error = true;
38
+        $has_connection_error = $mysqli->connect_error;
39
+        if(isset($has_connection_error))
40
+            $this->has_connection_error = true;
41 41
 		
42
-		return $mysqli;
43
-	}
42
+        return $mysqli;
43
+    }
44 44
 
45
-	public static function instance()
46
-	{
47
-		if(!isset(self::$instance)) {
45
+    public static function instance()
46
+    {
47
+        if(!isset(self::$instance)) {
48 48
             global $config;
49 49
             self::$instance = new Database(
50 50
                 $config->database->master,
@@ -52,107 +52,107 @@  discard block
 block discarded – undo
52 52
             );
53 53
         }
54 54
 
55
-		return self::$instance;
56
-	}
57
-
58
-	public static function escape($string)
59
-	{
60
-		return self::instance()->read_connection->real_escape_string($string);
61
-	}
62
-
63
-	public static function select($query)
64
-	{
65
-		$start = microtime(true);
66
-		if($result = self::instance()->read_connection->query($query))
67
-		{
68
-			self::instance()->log_query($query, $start);
69
-			$array = array();
70
-			while($row = $result->fetch_object())
71
-				$array[] = $row;
72
-			$result->close();
73
-			return $array;
74
-		}
75
-		trigger_error('Could not preform query - ' . $query . ' - ' . self::instance()->read_connection->error);
76
-		return false;
77
-	}
78
-
79
-	public static function selectRow($query)
80
-	{
81
-		$result = self::select($query);
82
-		if(is_array($result))
83
-			return array_pop($result);
84
-		return false;
85
-	}
86
-
87
-	public static function execute($query)
88
-	{
89
-		$start = microtime(true);
90
-		if(self::instance()->write_connection->query($query))
91
-		{
92
-			self::instance()->log_query($query, $start);
93
-			return true;
94
-		}
95
-		trigger_error('Could not preform query - ' . $query . '-' . self::instance()->write_connection->error);
96
-		return false;
97
-	}
98
-
99
-	public static function lastInsertID()
100
-	{
101
-		$id = self::instance()->write_connection->insert_id;
102
-		if($id == 0)
103
-			return false;
104
-		return $id;
105
-	}
106
-
107
-	private function log_query($query, $start)
108
-	{
109
-		$time = (microtime(true) - $start) * 1000;
110
-		$query = array(
111
-			'sql' => $query,
112
-			'time' => $time);
113
-		array_push($this->query_log, $query);
55
+        return self::$instance;
56
+    }
57
+
58
+    public static function escape($string)
59
+    {
60
+        return self::instance()->read_connection->real_escape_string($string);
61
+    }
62
+
63
+    public static function select($query)
64
+    {
65
+        $start = microtime(true);
66
+        if($result = self::instance()->read_connection->query($query))
67
+        {
68
+            self::instance()->log_query($query, $start);
69
+            $array = array();
70
+            while($row = $result->fetch_object())
71
+                $array[] = $row;
72
+            $result->close();
73
+            return $array;
74
+        }
75
+        trigger_error('Could not preform query - ' . $query . ' - ' . self::instance()->read_connection->error);
76
+        return false;
77
+    }
78
+
79
+    public static function selectRow($query)
80
+    {
81
+        $result = self::select($query);
82
+        if(is_array($result))
83
+            return array_pop($result);
84
+        return false;
85
+    }
86
+
87
+    public static function execute($query)
88
+    {
89
+        $start = microtime(true);
90
+        if(self::instance()->write_connection->query($query))
91
+        {
92
+            self::instance()->log_query($query, $start);
93
+            return true;
94
+        }
95
+        trigger_error('Could not preform query - ' . $query . '-' . self::instance()->write_connection->error);
96
+        return false;
97
+    }
98
+
99
+    public static function lastInsertID()
100
+    {
101
+        $id = self::instance()->write_connection->insert_id;
102
+        if($id == 0)
103
+            return false;
104
+        return $id;
105
+    }
106
+
107
+    private function log_query($query, $start)
108
+    {
109
+        $time = (microtime(true) - $start) * 1000;
110
+        $query = array(
111
+            'sql' => $query,
112
+            'time' => $time);
113
+        array_push($this->query_log, $query);
114 114
 		
115
-		$this->query_total['count']++;
116
-		$this->query_total['time'] += $time;
117
-	}
118
-
119
-	private function gather_query_data()
120
-	{
121
-		$query_data = array();
122
-		foreach($this->query_log as $query)
123
-		{
124
-			$query = self::explain($query);
125
-			$query_data[] = $query;
126
-		}
127
-		return $query_data;
128
-	}
129
-
130
-	public static function explain($query)
131
-	{
132
-		$sql = 'EXPLAIN ' . $query['sql'];
115
+        $this->query_total['count']++;
116
+        $this->query_total['time'] += $time;
117
+    }
118
+
119
+    private function gather_query_data()
120
+    {
121
+        $query_data = array();
122
+        foreach($this->query_log as $query)
123
+        {
124
+            $query = self::explain($query);
125
+            $query_data[] = $query;
126
+        }
127
+        return $query_data;
128
+    }
129
+
130
+    public static function explain($query)
131
+    {
132
+        $sql = 'EXPLAIN ' . $query['sql'];
133 133
 		
134
-		if($result = self::instance()->read_connection->query($sql))
135
-		{
136
-			$row = $result->fetch_assoc();
137
-			$query['explain'] = $row;
138
-		}
134
+        if($result = self::instance()->read_connection->query($sql))
135
+        {
136
+            $row = $result->fetch_assoc();
137
+            $query['explain'] = $row;
138
+        }
139 139
 		
140
-		return $query;
141
-	}
142
-
143
-	public static function getQueryLog()
144
-	{
145
-		return self::instance()->gather_query_data();
146
-	}
147
-
148
-	public static function getQueryTotals()
149
-	{
150
-		return self::instance()->query_total;
151
-	}
152
-
153
-	public static function isConnected()
154
-	{
155
-		return !self::instance()->has_connection_error;
156
-	}
140
+        return $query;
141
+    }
142
+
143
+    public static function getQueryLog()
144
+    {
145
+        return self::instance()->gather_query_data();
146
+    }
147
+
148
+    public static function getQueryTotals()
149
+    {
150
+        return self::instance()->query_total;
151
+    }
152
+
153
+    public static function isConnected()
154
+    {
155
+        return !self::instance()->has_connection_error;
156
+    }
157 157
 
158 158
 }
Please login to merge, or discard this patch.
utility/Loader.class.inc.php 1 patch
Indentation   +160 added lines, -160 removed lines patch added patch discarded remove patch
@@ -3,175 +3,175 @@
 block discarded – undo
3 3
 final class Loader
4 4
 {
5 5
 
6
-	private $root;
7
-	private $is_live;
8
-	private $included_files = array();
9
-
10
-	private static $instance;
11
-
12
-	private function __construct()
13
-	{
14
-		$this->is_live = (isset($_SERVER['HTTP_HOST']) && substr($_SERVER['HTTP_HOST'], 0, 4) !== 'dev.');
15
-		return $this;
16
-	}
17
-
18
-	public static function instance()
19
-	{
20
-		if(!isset(self::$instance))
21
-			self::$instance = new Loader();
22
-		return self::$instance;
23
-	}
24
-
25
-	private function get_root()
26
-	{
27
-		if(!isset($this->root))
28
-		{
29
-			$current_directory = dirname(__FILE__);
30
-			$current_directory = substr($current_directory, 0, -7);
31
-			$this->root = $current_directory;
32
-		}
6
+    private $root;
7
+    private $is_live;
8
+    private $included_files = array();
9
+
10
+    private static $instance;
11
+
12
+    private function __construct()
13
+    {
14
+        $this->is_live = (isset($_SERVER['HTTP_HOST']) && substr($_SERVER['HTTP_HOST'], 0, 4) !== 'dev.');
15
+        return $this;
16
+    }
17
+
18
+    public static function instance()
19
+    {
20
+        if(!isset(self::$instance))
21
+            self::$instance = new Loader();
22
+        return self::$instance;
23
+    }
24
+
25
+    private function get_root()
26
+    {
27
+        if(!isset($this->root))
28
+        {
29
+            $current_directory = dirname(__FILE__);
30
+            $current_directory = substr($current_directory, 0, -7);
31
+            $this->root = $current_directory;
32
+        }
33 33
 		
34
-		return $this->root;
35
-	}
36
-
37
-	private function get_delimiter()
38
-	{
39
-		return (true || $this->is_live) ? '/' : '\\';
40
-	}
41
-
42
-	private function check_delimiters($path)
43
-	{
44
-		return (true || $this->is_live) ? $path : str_replace('/', '\\', $path);
45
-	}
46
-
47
-	private static function get_class_name($path)
48
-	{
49
-		$path_array = explode('/', $path);
50
-		return array_pop($path_array);
51
-	}
52
-
53
-	private static function get_extension($type)
54
-	{
55
-		switch($type)
56
-		{
57
-			case 'collector' :
58
-			case 'controller' :
59
-			case 'model' :
60
-			case 'module' :
61
-			case 'router' :
62
-			case 'utility' :
63
-				$extension = '.class.inc.php';
64
-			break;
65
-			case 'view' :
66
-				$extension = '.tpl.php';
67
-			break;
68
-		}
69
-		return $extension;
70
-	}
71
-
72
-	public static function getImagePath($type, $file)
73
-	{
74
-		$path = self::instance()->get_root();
75
-		$path .= 'public';
76
-		$path .= self::instance()->get_delimiter();
77
-		$path .= $type;
78
-		$path .= self::instance()->get_delimiter();
79
-		$path .= self::instance()->check_delimiters($file);
34
+        return $this->root;
35
+    }
36
+
37
+    private function get_delimiter()
38
+    {
39
+        return (true || $this->is_live) ? '/' : '\\';
40
+    }
41
+
42
+    private function check_delimiters($path)
43
+    {
44
+        return (true || $this->is_live) ? $path : str_replace('/', '\\', $path);
45
+    }
46
+
47
+    private static function get_class_name($path)
48
+    {
49
+        $path_array = explode('/', $path);
50
+        return array_pop($path_array);
51
+    }
52
+
53
+    private static function get_extension($type)
54
+    {
55
+        switch($type)
56
+        {
57
+            case 'collector' :
58
+            case 'controller' :
59
+            case 'model' :
60
+            case 'module' :
61
+            case 'router' :
62
+            case 'utility' :
63
+                $extension = '.class.inc.php';
64
+            break;
65
+            case 'view' :
66
+                $extension = '.tpl.php';
67
+            break;
68
+        }
69
+        return $extension;
70
+    }
71
+
72
+    public static function getImagePath($type, $file)
73
+    {
74
+        $path = self::instance()->get_root();
75
+        $path .= 'public';
76
+        $path .= self::instance()->get_delimiter();
77
+        $path .= $type;
78
+        $path .= self::instance()->get_delimiter();
79
+        $path .= self::instance()->check_delimiters($file);
80 80
 		
81
-		return $path;
82
-	}
83
-
84
-	private static function get_path($type, $file)
85
-	{
86
-		$path = self::instance()->get_root();
87
-		$path .= $type;
88
-		$path .= self::instance()->get_delimiter();
89
-		$path .= self::instance()->check_delimiters($file);
90
-		$path .= self::get_extension($type);
81
+        return $path;
82
+    }
83
+
84
+    private static function get_path($type, $file)
85
+    {
86
+        $path = self::instance()->get_root();
87
+        $path .= $type;
88
+        $path .= self::instance()->get_delimiter();
89
+        $path .= self::instance()->check_delimiters($file);
90
+        $path .= self::get_extension($type);
91 91
 		
92
-		return $path;
93
-	}
94
-
95
-	private function get_included_files()
96
-	{
97
-		return $this->included_files;
98
-	}
99
-
100
-	private function add_included_file($path)
101
-	{
102
-		$this->included_files[] = $path;
103
-	}
104
-
105
-	public static function load($type, $files, $data = array())
106
-	{
107
-		foreach((array) $files as $file)
108
-		{
109
-			$file_path = self::instance()->get_path($type, $file);
110
-			if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view')
111
-				continue;
92
+        return $path;
93
+    }
94
+
95
+    private function get_included_files()
96
+    {
97
+        return $this->included_files;
98
+    }
99
+
100
+    private function add_included_file($path)
101
+    {
102
+        $this->included_files[] = $path;
103
+    }
104
+
105
+    public static function load($type, $files, $data = array())
106
+    {
107
+        foreach((array) $files as $file)
108
+        {
109
+            $file_path = self::instance()->get_path($type, $file);
110
+            if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view')
111
+                continue;
112 112
 			
113
-			self::instance()->add_included_file($file_path);
113
+            self::instance()->add_included_file($file_path);
114 114
 			
115
-			switch($type)
116
-			{
117
-				case 'images' :
118
-				case 'scripts' :
119
-				case 'styles' :
120
-					echo file_get_contents($file_path);
121
-				break;
122
-				case 'view' :
123
-					extract($data);
124
-					include($file_path);
125
-				break;
126
-				default :
127
-					include_once($file_path);
128
-				break;
129
-			}
130
-		}
131
-	}
132
-
133
-	private static function create_reflection_class($file)
134
-	{
135
-		$class_name = self::instance()->get_class_name($file);
136
-		return new ReflectionClass($class_name);
137
-	}
138
-
139
-	public static function loadInstance($type, $file)
140
-	{
141
-		self::load($type, $file);
115
+            switch($type)
116
+            {
117
+                case 'images' :
118
+                case 'scripts' :
119
+                case 'styles' :
120
+                    echo file_get_contents($file_path);
121
+                break;
122
+                case 'view' :
123
+                    extract($data);
124
+                    include($file_path);
125
+                break;
126
+                default :
127
+                    include_once($file_path);
128
+                break;
129
+            }
130
+        }
131
+    }
132
+
133
+    private static function create_reflection_class($file)
134
+    {
135
+        $class_name = self::instance()->get_class_name($file);
136
+        return new ReflectionClass($class_name);
137
+    }
138
+
139
+    public static function loadInstance($type, $file)
140
+    {
141
+        self::load($type, $file);
142 142
 		
143
-		$reflectionObject = self::create_reflection_class($file);
143
+        $reflectionObject = self::create_reflection_class($file);
144 144
 		
145
-		if(
146
-			$reflectionObject->hasMethod('instance') &&
147
-			$reflectionObject->getMethod('instance')->isStatic())
148
-		{
149
-			return $reflectionObject->getMethod('instance')->invoke(null);
150
-		}
151
-		trigger_error("Requested class cannot be instance'd: {$type}, {$file}");
152
-	}
153
-
154
-	public static function loadNew($type, $file, $data = array())
155
-	{
156
-		self::load($type, $file);
145
+        if(
146
+            $reflectionObject->hasMethod('instance') &&
147
+            $reflectionObject->getMethod('instance')->isStatic())
148
+        {
149
+            return $reflectionObject->getMethod('instance')->invoke(null);
150
+        }
151
+        trigger_error("Requested class cannot be instance'd: {$type}, {$file}");
152
+    }
153
+
154
+    public static function loadNew($type, $file, $data = array())
155
+    {
156
+        self::load($type, $file);
157 157
 		
158
-		$reflectionObject = self::create_reflection_class($file);
158
+        $reflectionObject = self::create_reflection_class($file);
159 159
 		
160
-		if($reflectionObject->hasMethod('__construct'))
161
-			return $reflectionObject->newInstanceArgs($data);
162
-		else
163
-			return $reflectionObject->newInstance();
164
-	}
165
-
166
-	public static function getRoot()
167
-	{
168
-		return self::instance()->get_root();
169
-	}
170
-
171
-	public static function isLive()
172
-	{
173
-		return self::instance()->is_live;
174
-	}
160
+        if($reflectionObject->hasMethod('__construct'))
161
+            return $reflectionObject->newInstanceArgs($data);
162
+        else
163
+            return $reflectionObject->newInstance();
164
+    }
165
+
166
+    public static function getRoot()
167
+    {
168
+        return self::instance()->get_root();
169
+    }
170
+
171
+    public static function isLive()
172
+    {
173
+        return self::instance()->is_live;
174
+    }
175 175
 
176 176
     public static function getRootURL($site = '')
177 177
     {
Please login to merge, or discard this patch.