Completed
Push — master ( cda546...72ee7f )
by Jacob
03:25
created
utility/URLDecode.class.inc.php 1 patch
Braces   +31 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,26 +1,26 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-class URLDecode
4
-{
3
+class URLDecode
4
+{
5 5
 
6 6
 	private static $array = array();
7 7
 
8
-	static function init()
9
-	{
8
+	static function init() {
10 9
 		$host = $_SERVER['HTTP_HOST'];
11 10
 		$uri = $_SERVER['REQUEST_URI'];
12 11
 		self::form_url_array($host, $uri);
13 12
 	}
14 13
 
15
-	static private function form_url_array($host, $uri)
16
-	{
14
+	static private function form_url_array($host, $uri) {
17 15
 		$uri = substr($uri, 1);
18
-		if(strpos($uri, '?'))
19
-			$uri = substr($uri, 0, strpos($uri, '?'));
16
+		if(strpos($uri, '?')) {
17
+					$uri = substr($uri, 0, strpos($uri, '?'));
18
+		}
20 19
 		$uri_array = explode('/', $uri);
21 20
 		
22
-		if(!Loader::isLive())
23
-			$host = substr($host, strpos($host, '.') + 1);
21
+		if(!Loader::isLive()) {
22
+					$host = substr($host, strpos($host, '.') + 1);
23
+		}
24 24
 		
25 25
 		self::$array['host'] = $host;
26 26
 		
@@ -43,50 +43,49 @@  discard block
 block discarded – undo
43 43
 		self::$array['base'] = $base;
44 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);
46
+		if(end($uri_array) == '') {
47
+					$uri_array = array_slice($uri_array, 0, count($uri_array) - 1);
48
+		}
48 49
 		self::$array['pieces'] = (array) $uri_array;
49 50
 	}
50 51
 
51
-	static function getSite()
52
-	{
52
+	static function getSite() {
53 53
 		return self::$array['site'];
54 54
 	}
55 55
 
56
-	static function getHost()
57
-	{
56
+	static function getHost() {
58 57
 		return self::$array['host'];
59 58
 	}
60 59
 
61
-	static function getBase()
62
-	{
60
+	static function getBase() {
63 61
 		return self::$array['base'];
64 62
 	}
65 63
 
66
-	static function getURI()
67
-	{
64
+	static function getURI() {
68 65
 		return self::$array['uri'];
69 66
 	}
70 67
 
71
-	static function getExtension()
72
-	{
68
+	static function getExtension() {
73 69
 		$file = self::getPiece(-1);
74
-		if(substr($file, -1) == '/')
75
-			return false;
70
+		if(substr($file, -1) == '/') {
71
+					return false;
72
+		}
76 73
 		return substr($file, strrpos($file, '.') + 1);;
77 74
 	}
78 75
 
79
-	static function getPiece($piece = null)
80
-	{
81
-		if(!$piece)
82
-			return self::$array['pieces'];
76
+	static function getPiece($piece = null) {
77
+		if(!$piece) {
78
+					return self::$array['pieces'];
79
+		}
83 80
 		
84
-		if($piece == -1)
85
-			return end(self::$array['pieces']);
81
+		if($piece == -1) {
82
+					return end(self::$array['pieces']);
83
+		}
86 84
 		
87 85
 		$piece = $piece - 1;
88
-		if(array_key_exists($piece, self::$array['pieces']))
89
-			return self::$array['pieces'][$piece];
86
+		if(array_key_exists($piece, self::$array['pieces'])) {
87
+					return self::$array['pieces'][$piece];
88
+		}
90 89
 		return;
91 90
 	}
92 91
 
Please login to merge, or discard this patch.
utility/Database.class.inc.php 1 patch
Braces   +28 added lines, -38 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-final class Database
4
-{
3
+final class Database
4
+{
5 5
 
6 6
 	private $read_connection;
7 7
 	private $write_connection;
@@ -14,8 +14,7 @@  discard block
 block discarded – undo
14 14
 
15 15
 	private static $instance;
16 16
 
17
-	private function __construct($write_params, $read_params)
18
-	{
17
+	private function __construct($write_params, $read_params) {
19 18
         $this->write_connection = $this->connect(
20 19
             $write_params->host,
21 20
             $write_params->user,
@@ -31,19 +30,18 @@  discard block
 block discarded – undo
31 30
 		return $this;
32 31
 	}
33 32
 
34
-	private function connect($host, $username, $password)
35
-	{
33
+	private function connect($host, $username, $password) {
36 34
 		$mysqli = new mysqli($host, $username, $password);
37 35
 		
38 36
 		$has_connection_error = $mysqli->connect_error;
39
-		if(isset($has_connection_error))
40
-			$this->has_connection_error = true;
37
+		if(isset($has_connection_error)) {
38
+					$this->has_connection_error = true;
39
+		}
41 40
 		
42 41
 		return $mysqli;
43 42
 	}
44 43
 
45
-	public static function instance()
46
-	{
44
+	public static function instance() {
47 45
 		if(!isset(self::$instance)) {
48 46
             global $config;
49 47
             self::$instance = new Database(
@@ -55,20 +53,19 @@  discard block
 block discarded – undo
55 53
 		return self::$instance;
56 54
 	}
57 55
 
58
-	public static function escape($string)
59
-	{
56
+	public static function escape($string) {
60 57
 		return self::instance()->read_connection->real_escape_string($string);
61 58
 	}
62 59
 
63
-	public static function select($query)
64
-	{
60
+	public static function select($query) {
65 61
 		$start = microtime(true);
66 62
 		if($result = self::instance()->read_connection->query($query))
67 63
 		{
68 64
 			self::instance()->log_query($query, $start);
69 65
 			$array = array();
70
-			while($row = $result->fetch_object())
71
-				$array[] = $row;
66
+			while($row = $result->fetch_object()) {
67
+							$array[] = $row;
68
+			}
72 69
 			$result->close();
73 70
 			return $array;
74 71
 		}
@@ -76,16 +73,15 @@  discard block
 block discarded – undo
76 73
 		return false;
77 74
 	}
78 75
 
79
-	public static function selectRow($query)
80
-	{
76
+	public static function selectRow($query) {
81 77
 		$result = self::select($query);
82
-		if(is_array($result))
83
-			return array_pop($result);
78
+		if(is_array($result)) {
79
+					return array_pop($result);
80
+		}
84 81
 		return false;
85 82
 	}
86 83
 
87
-	public static function execute($query)
88
-	{
84
+	public static function execute($query) {
89 85
 		$start = microtime(true);
90 86
 		if(self::instance()->write_connection->query($query))
91 87
 		{
@@ -96,16 +92,15 @@  discard block
 block discarded – undo
96 92
 		return false;
97 93
 	}
98 94
 
99
-	public static function lastInsertID()
100
-	{
95
+	public static function lastInsertID() {
101 96
 		$id = self::instance()->write_connection->insert_id;
102
-		if($id == 0)
103
-			return false;
97
+		if($id == 0) {
98
+					return false;
99
+		}
104 100
 		return $id;
105 101
 	}
106 102
 
107
-	private function log_query($query, $start)
108
-	{
103
+	private function log_query($query, $start) {
109 104
 		$time = (microtime(true) - $start) * 1000;
110 105
 		$query = array(
111 106
 			'sql' => $query,
@@ -116,8 +111,7 @@  discard block
 block discarded – undo
116 111
 		$this->query_total['time'] += $time;
117 112
 	}
118 113
 
119
-	private function gather_query_data()
120
-	{
114
+	private function gather_query_data() {
121 115
 		$query_data = array();
122 116
 		foreach($this->query_log as $query)
123 117
 		{
@@ -127,8 +121,7 @@  discard block
 block discarded – undo
127 121
 		return $query_data;
128 122
 	}
129 123
 
130
-	public static function explain($query)
131
-	{
124
+	public static function explain($query) {
132 125
 		$sql = 'EXPLAIN ' . $query['sql'];
133 126
 		
134 127
 		if($result = self::instance()->read_connection->query($sql))
@@ -140,18 +133,15 @@  discard block
 block discarded – undo
140 133
 		return $query;
141 134
 	}
142 135
 
143
-	public static function getQueryLog()
144
-	{
136
+	public static function getQueryLog() {
145 137
 		return self::instance()->gather_query_data();
146 138
 	}
147 139
 
148
-	public static function getQueryTotals()
149
-	{
140
+	public static function getQueryTotals() {
150 141
 		return self::instance()->query_total;
151 142
 	}
152 143
 
153
-	public static function isConnected()
154
-	{
144
+	public static function isConnected() {
155 145
 		return !self::instance()->has_connection_error;
156 146
 	}
157 147
 
Please login to merge, or discard this patch.
utility/Loader.class.inc.php 1 patch
Braces   +31 added lines, -46 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-final class Loader
4
-{
3
+final class Loader
4
+{
5 5
 
6 6
 	private $root;
7 7
 	private $is_live;
@@ -9,21 +9,19 @@  discard block
 block discarded – undo
9 9
 
10 10
 	private static $instance;
11 11
 
12
-	private function __construct()
13
-	{
12
+	private function __construct() {
14 13
 		$this->is_live = (isset($_SERVER['HTTP_HOST']) && substr($_SERVER['HTTP_HOST'], 0, 4) !== 'dev.');
15 14
 		return $this;
16 15
 	}
17 16
 
18
-	public static function instance()
19
-	{
20
-		if(!isset(self::$instance))
21
-			self::$instance = new Loader();
17
+	public static function instance() {
18
+		if(!isset(self::$instance)) {
19
+					self::$instance = new Loader();
20
+		}
22 21
 		return self::$instance;
23 22
 	}
24 23
 
25
-	private function get_root()
26
-	{
24
+	private function get_root() {
27 25
 		if(!isset($this->root))
28 26
 		{
29 27
 			$current_directory = dirname(__FILE__);
@@ -34,24 +32,20 @@  discard block
 block discarded – undo
34 32
 		return $this->root;
35 33
 	}
36 34
 
37
-	private function get_delimiter()
38
-	{
35
+	private function get_delimiter() {
39 36
 		return (true || $this->is_live) ? '/' : '\\';
40 37
 	}
41 38
 
42
-	private function check_delimiters($path)
43
-	{
39
+	private function check_delimiters($path) {
44 40
 		return (true || $this->is_live) ? $path : str_replace('/', '\\', $path);
45 41
 	}
46 42
 
47
-	private static function get_class_name($path)
48
-	{
43
+	private static function get_class_name($path) {
49 44
 		$path_array = explode('/', $path);
50 45
 		return array_pop($path_array);
51 46
 	}
52 47
 
53
-	private static function get_extension($type)
54
-	{
48
+	private static function get_extension($type) {
55 49
 		switch($type)
56 50
 		{
57 51
 			case 'collector' :
@@ -69,8 +63,7 @@  discard block
 block discarded – undo
69 63
 		return $extension;
70 64
 	}
71 65
 
72
-	public static function getImagePath($type, $file)
73
-	{
66
+	public static function getImagePath($type, $file) {
74 67
 		$path = self::instance()->get_root();
75 68
 		$path .= 'public';
76 69
 		$path .= self::instance()->get_delimiter();
@@ -81,8 +74,7 @@  discard block
 block discarded – undo
81 74
 		return $path;
82 75
 	}
83 76
 
84
-	private static function get_path($type, $file)
85
-	{
77
+	private static function get_path($type, $file) {
86 78
 		$path = self::instance()->get_root();
87 79
 		$path .= $type;
88 80
 		$path .= self::instance()->get_delimiter();
@@ -92,23 +84,21 @@  discard block
 block discarded – undo
92 84
 		return $path;
93 85
 	}
94 86
 
95
-	private function get_included_files()
96
-	{
87
+	private function get_included_files() {
97 88
 		return $this->included_files;
98 89
 	}
99 90
 
100
-	private function add_included_file($path)
101
-	{
91
+	private function add_included_file($path) {
102 92
 		$this->included_files[] = $path;
103 93
 	}
104 94
 
105
-	public static function load($type, $files, $data = array())
106
-	{
95
+	public static function load($type, $files, $data = array()) {
107 96
 		foreach((array) $files as $file)
108 97
 		{
109 98
 			$file_path = self::instance()->get_path($type, $file);
110
-			if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view')
111
-				continue;
99
+			if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') {
100
+							continue;
101
+			}
112 102
 			
113 103
 			self::instance()->add_included_file($file_path);
114 104
 			
@@ -130,14 +120,12 @@  discard block
 block discarded – undo
130 120
 		}
131 121
 	}
132 122
 
133
-	private static function create_reflection_class($file)
134
-	{
123
+	private static function create_reflection_class($file) {
135 124
 		$class_name = self::instance()->get_class_name($file);
136 125
 		return new ReflectionClass($class_name);
137 126
 	}
138 127
 
139
-	public static function loadInstance($type, $file)
140
-	{
128
+	public static function loadInstance($type, $file) {
141 129
 		self::load($type, $file);
142 130
 		
143 131
 		$reflectionObject = self::create_reflection_class($file);
@@ -151,30 +139,27 @@  discard block
 block discarded – undo
151 139
 		trigger_error("Requested class cannot be instance'd: {$type}, {$file}");
152 140
 	}
153 141
 
154
-	public static function loadNew($type, $file, $data = array())
155
-	{
142
+	public static function loadNew($type, $file, $data = array()) {
156 143
 		self::load($type, $file);
157 144
 		
158 145
 		$reflectionObject = self::create_reflection_class($file);
159 146
 		
160
-		if($reflectionObject->hasMethod('__construct'))
161
-			return $reflectionObject->newInstanceArgs($data);
162
-		else
163
-			return $reflectionObject->newInstance();
147
+		if($reflectionObject->hasMethod('__construct')) {
148
+					return $reflectionObject->newInstanceArgs($data);
149
+		} else {
150
+					return $reflectionObject->newInstance();
151
+		}
164 152
 	}
165 153
 
166
-	public static function getRoot()
167
-	{
154
+	public static function getRoot() {
168 155
 		return self::instance()->get_root();
169 156
 	}
170 157
 
171
-	public static function isLive()
172
-	{
158
+	public static function isLive() {
173 159
 		return self::instance()->is_live;
174 160
 	}
175 161
 
176
-    public static function getRootURL($site = '')
177
-    {
162
+    public static function getRootURL($site = '') {
178 163
         if (strlen($site) > 0) {
179 164
             $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
180 165
             if ($site == 'waterfalls' && self::instance()->is_live) {
Please login to merge, or discard this patch.
utility/Search.class.inc.php 1 patch
Braces   +15 added lines, -20 removed lines patch added patch discarded remove patch
@@ -1,49 +1,44 @@  discard block
 block discarded – undo
1 1
 <?
2 2
 
3
-final class Search
4
-{
3
+final class Search
4
+{
5 5
 
6 6
 	private $query;
7 7
 	private $result;
8 8
 	private $weight;
9 9
 
10
-	function __construct()
11
-	{
10
+	function __construct() {
12 11
 		return $this;
13 12
 	}
14 13
 
15
-	public function setQuery($query)
16
-	{
14
+	public function setQuery($query) {
17 15
 		$this->query = $query;
18 16
 		return $this;
19 17
 	}
20 18
 
21
-	public function setResult($array)
22
-	{
19
+	public function setResult($array) {
23 20
 		$this->result = $array;
24 21
 		return $this;
25 22
 	}
26 23
 
27
-	public function setWeight($weight)
28
-	{
24
+	public function setWeight($weight) {
29 25
 		$this->weight = $weight;
30 26
 		return $this;
31 27
 	}
32 28
 
33
-	public static function instance()
34
-	{
29
+	public static function instance() {
35 30
 		$reflection = new ReflectionClass('Search');
36 31
 		return $reflection->newInstance();
37 32
 	}
38 33
 
39
-	public function perform()
40
-	{
34
+	public function perform() {
41 35
 		$weighted_array = array();
42 36
 		foreach($this->result as $row)
43 37
 		{
44 38
 			$weight = $this->get_search_weight($row);
45
-			if($weight > 0)
46
-				$weighted_array[$row['id']] = $weight;
39
+			if($weight > 0) {
40
+							$weighted_array[$row['id']] = $weight;
41
+			}
47 42
 		}
48 43
 		arsort($weighted_array);
49 44
 		
@@ -52,15 +47,15 @@  discard block
 block discarded – undo
52 47
 		{
53 48
 			foreach($this->result as $row)
54 49
 			{
55
-				if($row['id'] == $id)
56
-					$final_array[] = $row;
50
+				if($row['id'] == $id) {
51
+									$final_array[] = $row;
52
+				}
57 53
 			}
58 54
 		}
59 55
 		return $final_array;
60 56
 	}
61 57
 
62
-	private function get_search_weight($row)
63
-	{
58
+	private function get_search_weight($row) {
64 59
 		$weight = 0;
65 60
 		foreach($this->weight as $weight_array)
66 61
 		{
Please login to merge, or discard this patch.
utility/content/URLSafeContent.class.inc.php 1 patch
Braces   +3 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,11 +2,10 @@
 block discarded – undo
2 2
 
3 3
 Loader::load('utility', 'Content');
4 4
 
5
-class URLSafeContent extends Content
6
-{
5
+class URLSafeContent extends Content
6
+{
7 7
 
8
-	protected function execute()
9
-	{
8
+	protected function execute() {
10 9
 		$this->content = strtolower(str_replace(' ', '-', $this->content));
11 10
 	}
12 11
 
Please login to merge, or discard this patch.
utility/content/MarkupCodeContent.class.inc.php 1 patch
Braces   +8 added lines, -10 removed lines patch added patch discarded remove patch
@@ -2,16 +2,16 @@  discard block
 block discarded – undo
2 2
 
3 3
 Loader::load('utility', 'Content');
4 4
 
5
-final class MarkupCodeContent extends Content
6
-{
5
+final class MarkupCodeContent extends Content
6
+{
7 7
 
8 8
 	private static $MARKUP_DELIMITER = '@<pre( rel="(.*?)")?>(.*?)</pre>@s';
9 9
 
10
-	protected function execute($title = '')
11
-	{
10
+	protected function execute($title = '') {
12 11
 		preg_match_all(self::$MARKUP_DELIMITER, $this->content, $matches);
13
-		if(count($matches[1]) == 0)
14
-			return;
12
+		if(count($matches[1]) == 0) {
13
+					return;
14
+		}
15 15
 		
16 16
 		foreach($matches[3] as $key => $match)
17 17
 		{
@@ -25,8 +25,7 @@  discard block
 block discarded – undo
25 25
 		return;
26 26
 	}
27 27
 
28
-	private function wrap_in_list($content)
29
-	{
28
+	private function wrap_in_list($content) {
30 29
 		$content_array = explode("\n", $content);
31 30
 		
32 31
 		foreach($content_array as $key => $row)
@@ -44,8 +43,7 @@  discard block
 block discarded – undo
44 43
 		return $content;
45 44
 	}
46 45
 
47
-	private function highlight_code($content, $type)
48
-	{
46
+	private function highlight_code($content, $type) {
49 47
 		switch($type)
50 48
 		{
51 49
 			default :
Please login to merge, or discard this patch.
utility/content/SmartTrimContent.class.inc.php 1 patch
Braces   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 Loader::load('utility', 'Content');
4 4
 
5
-class SmartTrimContent extends Content
6
-{
5
+class SmartTrimContent extends Content
6
+{
7 7
 
8 8
 	private static $EXCLUDE_TAGS = array(
9 9
 		'a',
@@ -24,8 +24,7 @@  discard block
 block discarded – undo
24 24
 
25 25
 	private $is_trimmed;
26 26
 
27
-	protected function execute()
28
-	{
27
+	protected function execute() {
29 28
 		$args = func_get_args();
30 29
 		if(count($args) < 1)
31 30
 		{
@@ -33,37 +32,38 @@  discard block
 block discarded – undo
33 32
 			return;
34 33
 		}
35 34
 		
36
-		if(count($args) == 2)
37
-			$etc = $args[1];
38
-		else
39
-			$etc = self::$ETC;
35
+		if(count($args) == 2) {
36
+					$etc = $args[1];
37
+		} else {
38
+					$etc = self::$ETC;
39
+		}
40 40
 		
41 41
 		$length = $args[0];
42 42
 		
43
-		if($length < strlen($this->content))
44
-			$this->trim_string($length);
45
-        else
46
-            $etc = '';
43
+		if($length < strlen($this->content)) {
44
+					$this->trim_string($length);
45
+		} else {
46
+                    $etc = '';
47
+        }
47 48
 		$this->check_exclude_tags();
48 49
 		$this->close_tags($etc);
49 50
 	}
50 51
 
51
-	private function trim_string($length)
52
-	{
52
+	private function trim_string($length) {
53 53
 		$content = $this->trim_html_string($this->content, $length);
54 54
 		
55 55
 		$last_right_bracket_position = strripos($content, self::$RIGHT_BRACKET);
56 56
 		$last_left_bracket_position = strripos($content, self::$LEFT_BRACKET);
57
-		if($last_left_bracket_position > $last_right_bracket_position)
58
-			$content = substr($content, 0, $last_left_bracket_position);
57
+		if($last_left_bracket_position > $last_right_bracket_position) {
58
+					$content = substr($content, 0, $last_left_bracket_position);
59
+		}
59 60
 		$content = trim($content);
60 61
 		
61 62
 		$this->content = $content;
62 63
 		$this->is_trimmed = true;
63 64
 	}
64 65
 
65
-	private function trim_html_string($content, $length)
66
-	{
66
+	private function trim_html_string($content, $length) {
67 67
 		$content = preg_replace(self::$PHOTO_PLACEHOLDER_MATCH, '', $content);
68 68
 		preg_match_all(self::$HTML_TAG_PATTERN, $content, $matches, PREG_OFFSET_CAPTURE);
69 69
 		$content = strip_tags($content);
@@ -76,20 +76,21 @@  discard block
 block discarded – undo
76 76
 		foreach($matches[0] as $match)
77 77
 		{
78 78
 			$max_length += strlen($match[0]);
79
-			if($max_length <= $match[1])
80
-				break;
79
+			if($max_length <= $match[1]) {
80
+							break;
81
+			}
81 82
 			
82 83
 			$content = substr($content, 0, $match[1]) . $match[0] . substr($content, $match[1]);
83 84
 		}
84 85
 		
85
-		if(substr($content, -7) == '</p><p>')
86
-			$content = substr($content, 0, -7);
86
+		if(substr($content, -7) == '</p><p>') {
87
+					$content = substr($content, 0, -7);
88
+		}
87 89
 		
88 90
 		return $content;
89 91
 	}
90 92
 
91
-	private function check_exclude_tags()
92
-	{
93
+	private function check_exclude_tags() {
93 94
 		$content = $this->content;
94 95
 		$tags_preg = $this->get_tags_preg(self::$EXCLUDE_TAGS);
95 96
 		preg_match_all($tags_preg, $content, $matches, PREG_OFFSET_CAPTURE);
@@ -105,8 +106,7 @@  discard block
 block discarded – undo
105 106
 		$this->content = $content;
106 107
 	}
107 108
 
108
-	private function close_tags($etc)
109
-	{
109
+	private function close_tags($etc) {
110 110
 		$content = $this->content;
111 111
 		$tags_preg = $this->get_tags_preg(self::$INCLUDE_TAGS);
112 112
 		preg_match_all($tags_preg, $content, $matches);
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
 			{
119 119
 				$key = array_search($tag, $open_tags);
120 120
 				unset($open_tags[$key]);
121
-			}
122
-			else
123
-				$open_tags[] = $tag;
121
+			} else {
122
+							$open_tags[] = $tag;
123
+			}
124 124
 		}
125 125
 		
126 126
 		$open_tags = array_reverse($open_tags);
@@ -128,19 +128,19 @@  discard block
 block discarded – undo
128 128
 		{
129 129
 			foreach($open_tags as $key => $open_tag)
130 130
 			{
131
-				if($key == count($open_tags) - 1)
132
-					$content .= $etc;
131
+				if($key == count($open_tags) - 1) {
132
+									$content .= $etc;
133
+				}
133 134
 				$content .= "</{$open_tag}>";
134 135
 			}
135
-		}
136
-		else
137
-			$content .= $etc;
136
+		} else {
137
+					$content .= $etc;
138
+		}
138 139
 		
139 140
 		$this->content = $content;
140 141
 	}
141 142
 
142
-	private function get_tags_preg($tag_array)
143
-	{
143
+	private function get_tags_preg($tag_array) {
144 144
 		return '@</?(' . implode('|', $tag_array) . ')@';
145 145
 	}
146 146
 
Please login to merge, or discard this patch.
utility/content/CleanCommentContent.class.inc.php 1 patch
Braces   +16 added lines, -22 removed lines patch added patch discarded remove patch
@@ -2,8 +2,8 @@  discard block
 block discarded – undo
2 2
 
3 3
 Loader::load('utility', 'Content');
4 4
 
5
-final class CleanCommentContent extends Content
6
-{
5
+final class CleanCommentContent extends Content
6
+{
7 7
 
8 8
 	private static $LINK_PATTERN = '@<a.*href=["\']([^"\']*)["\'].*>(.*)</a>@i';
9 9
 	private static $BOLD_PATTERN = '@<b.*>(.*)</b>@i';
@@ -22,8 +22,7 @@  discard block
 block discarded – undo
22 22
 
23 23
 	private $replacement_array = array();
24 24
 
25
-	protected function execute()
26
-	{
25
+	protected function execute() {
27 26
 		$this->process_element(self::$CODE_PATTERN, self::$CODE_REPLACE);
28 27
 		$this->process_element(self::$LINK_PATTERN, self::$LINK_REPLACE);
29 28
 		$this->process_element(self::$ITALIC_PATTERN, self::$ITALIC_REPLACE);
@@ -36,12 +35,12 @@  discard block
 block discarded – undo
36 35
 		$this->replace_element_patterns();
37 36
 	}
38 37
 
39
-	private function process_element($pattern, $replace)
40
-	{
38
+	private function process_element($pattern, $replace) {
41 39
 		$match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER);
42 40
 		
43
-		if($match_count < 1)
44
-			return;
41
+		if($match_count < 1) {
42
+					return;
43
+		}
45 44
 		
46 45
 		foreach($matches as $match)
47 46
 		{
@@ -54,13 +53,11 @@  discard block
 block discarded – undo
54 53
 		}
55 54
 	}
56 55
 
57
-	private function create_placeholder($text)
58
-	{
56
+	private function create_placeholder($text) {
59 57
 		return md5($text . rand());
60 58
 	}
61 59
 
62
-	private function create_full_match_pattern($text)
63
-	{
60
+	private function create_full_match_pattern($text) {
64 61
 		$pattern = '';
65 62
 		$pattern .= '@';
66 63
 		$pattern .= preg_quote($text, '@');
@@ -70,17 +67,16 @@  discard block
 block discarded – undo
70 67
 		return $pattern;
71 68
 	}
72 69
 
73
-	private function strip_extra_tags()
74
-	{
70
+	private function strip_extra_tags() {
75 71
 		$this->content = strip_tags($this->content);
76 72
 	}
77 73
 
78
-	private function link_unlinked_urls($pattern, $replace)
79
-	{
74
+	private function link_unlinked_urls($pattern, $replace) {
80 75
 		$match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER);
81 76
 		
82
-		if($match_count < 1)
83
-			return;
77
+		if($match_count < 1) {
78
+					return;
79
+		}
84 80
 		
85 81
 		foreach($matches as $match)
86 82
 		{
@@ -92,13 +88,11 @@  discard block
 block discarded – undo
92 88
 		}
93 89
 	}
94 90
 
95
-	private function add_line_breaks()
96
-	{
91
+	private function add_line_breaks() {
97 92
 		$this->content = preg_replace(self::$LINE_BREAK_PATTERN, self::$LINE_BREAK_REPLACE, $this->content);
98 93
 	}
99 94
 
100
-	private function replace_element_patterns()
101
-	{
95
+	private function replace_element_patterns() {
102 96
 		foreach($this->replacement_array as $key => $replace)
103 97
 		{
104 98
 			$this->content = str_replace($key, $replace, $this->content);
Please login to merge, or discard this patch.
utility/content/FetchFirstPhotoContent.class.inc.php 1 patch
Braces   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -2,30 +2,28 @@  discard block
 block discarded – undo
2 2
 
3 3
 Loader::load('utility', 'Content');
4 4
 
5
-final class FetchFirstPhotoContent extends Content
6
-{
5
+final class FetchFirstPhotoContent extends Content
6
+{
7 7
 
8 8
 	private static $PHOTO_PLACEHOLDER_MATCH = '@{{photo="(.*)"}}@';
9 9
 	private static $IMAGE_NODE = '<img src="%sphoto/%s/%s-size-%s.%s" height="%d" width="%d" alt="%s" />';
10 10
 	private static $DEFAULT_RETURN = '';
11 11
 
12
-	protected function execute($is_absolute = false, $size = 'thumb')
13
-	{
14
-		if(preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1)
15
-			$this->content = $this->get_thumb($match[1], $is_absolute, $size);
16
-		else
17
-			$this->content = self::$DEFAULT_RETURN;
12
+	protected function execute($is_absolute = false, $size = 'thumb') {
13
+		if(preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1) {
14
+					$this->content = $this->get_thumb($match[1], $is_absolute, $size);
15
+		} else {
16
+					$this->content = self::$DEFAULT_RETURN;
17
+		}
18 18
 		return;
19 19
 	}
20 20
 
21
-	private function get_file_path($category, $photo, $size, $extension)
22
-	{
21
+	private function get_file_path($category, $photo, $size, $extension) {
23 22
 		$path = "{$category}/{$photo}-size-{$size}.{$extension}";
24 23
 		return Loader::getImagePath('photo', $path);
25 24
 	}
26 25
 
27
-	private function get_thumb($string, $is_absolute, $size)
28
-	{
26
+	private function get_thumb($string, $is_absolute, $size) {
29 27
 		list($category, $file_name) = explode('/', $string);
30 28
 		list($photo, $extension) = explode('.', $file_name);
31 29
 		
@@ -34,16 +32,18 @@  discard block
 block discarded – undo
34 32
 		
35 33
 		Loader::load('collector', 'image/PhotoCollector');
36 34
 		$photo_result = PhotoCollector::fetchRow($category, $photo);
37
-		if($photo_result == false)
38
-			return '';
35
+		if($photo_result == false) {
36
+					return '';
37
+		}
39 38
 		
40 39
 		$height = $file_size[1];
41 40
 		$width = $file_size[0];
42 41
 		$description = $photo_result->description;
43 42
 		
44 43
 		$domain = '/';
45
-		if($is_absolute)
46
-			$domain = Loader::getRootURL(URLDecode::getSite());
44
+		if($is_absolute) {
45
+					$domain = Loader::getRootURL(URLDecode::getSite());
46
+		}
47 47
 
48 48
 		return sprintf(self::$IMAGE_NODE, $domain, $category, $photo, $size, $extension, $height, $width, $description);
49 49
 	}
Please login to merge, or discard this patch.