Completed
Push — master ( a1f655...a0345d )
by Jacob
08:14
created
public/waterfalls/index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $namespace = 'waterfalls';
4
-require_once __DIR__ . '/../../bootstrap.php';
4
+require_once __DIR__.'/../../bootstrap.php';
5 5
 
6 6
 // route
7 7
 Loader::loadInstance('router', 'Router');
Please login to merge, or discard this patch.
public/home/index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $namespace = 'home';
4
-require_once __DIR__ . '/../../bootstrap.php';
4
+require_once __DIR__.'/../../bootstrap.php';
5 5
 
6 6
 // route
7 7
 Loader::loadInstance('router', 'Router');
Please login to merge, or discard this patch.
public/blog/index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $namespace = 'blog';
4
-require_once __DIR__ . '/../../bootstrap.php';
4
+require_once __DIR__.'/../../bootstrap.php';
5 5
 
6 6
 // route
7 7
 Loader::loadInstance('router', 'Router');
Please login to merge, or discard this patch.
public/portfolio/index.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 $namespace = 'portfolio';
4
-require_once __DIR__ . '/../../bootstrap.php';
4
+require_once __DIR__.'/../../bootstrap.php';
5 5
 
6 6
 // route
7 7
 Loader::loadInstance('router', 'Router');
Please login to merge, or discard this patch.
utility/content/ImperialUnitContent.class.inc.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -26,16 +26,16 @@  discard block
 block discarded – undo
26 26
         
27 27
         switch ($type) {
28 28
             case 'full miles' :
29
-                $this->content = number_format(round($number / (12 * 3 * 1760))) . ' miles';
29
+                $this->content = number_format(round($number / (12 * 3 * 1760))).' miles';
30 30
                 break;
31 31
             case 'tenth miles' :
32
-                $this->content = round($number / (12 * 3 * 1760), 1) . ' miles';
32
+                $this->content = round($number / (12 * 3 * 1760), 1).' miles';
33 33
                 break;
34 34
             case 'yards' :
35
-                $this->content = number_format(round($number / (12 * 3))) . ' yards';
35
+                $this->content = number_format(round($number / (12 * 3))).' yards';
36 36
                 break;
37 37
             case 'feet' :
38
-                $this->content = number_format(round($number / 12)) . "'";
38
+                $this->content = number_format(round($number / 12))."'";
39 39
                 break;
40 40
             case 'inches' :
41 41
                 $feet = floor($number / 12);
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
                 }
50 50
                 
51 51
                 $this->content = '';
52
-                $this->content .= number_format($feet) . "'";
52
+                $this->content .= number_format($feet)."'";
53 53
                 if (isset($inches) && $inches > 0) {
54 54
                     $this->content .= " {$inches}\"";
55 55
                 }
Please login to merge, or discard this patch.
Braces   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -2,11 +2,11 @@
 block discarded – undo
2 2
 
3 3
 Loader::load('utility', 'Content');
4 4
 
5
-final class ImperialUnitContent extends Content
6
-{
5
+final class ImperialUnitContent extends Content
6
+{
7 7
 
8
-    protected function execute($type = '')
9
-    {
8
+    protected function execute($type = '')
9
+    {
10 10
         $number = floatval($this->content);
11 11
         $number *= 39.37; // convert to inches
12 12
         
Please login to merge, or discard this patch.
utility/content/CleanCommentContent.class.inc.php 4 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -40,10 +40,10 @@  discard block
 block discarded – undo
40 40
 	{
41 41
 		$match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER);
42 42
 		
43
-		if($match_count < 1)
43
+		if ($match_count < 1)
44 44
 			return;
45 45
 		
46
-		foreach($matches as $match)
46
+		foreach ($matches as $match)
47 47
 		{
48 48
 			$full_match = array_shift($match);
49 49
 			$placeholder = $this->create_placeholder($full_match);
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
 	private function create_placeholder($text)
58 58
 	{
59
-		return md5($text . rand());
59
+		return md5($text.rand());
60 60
 	}
61 61
 
62 62
 	private function create_full_match_pattern($text)
@@ -79,10 +79,10 @@  discard block
 block discarded – undo
79 79
 	{
80 80
 		$match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER);
81 81
 		
82
-		if($match_count < 1)
82
+		if ($match_count < 1)
83 83
 			return;
84 84
 		
85
-		foreach($matches as $match)
85
+		foreach ($matches as $match)
86 86
 		{
87 87
 			$full_match = array_shift($match);
88 88
 			$full_match_pattern = $this->create_full_match_pattern($full_match);
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 
100 100
 	private function replace_element_patterns()
101 101
 	{
102
-		foreach($this->replacement_array as $key => $replace)
102
+		foreach ($this->replacement_array as $key => $replace)
103 103
 		{
104 104
 			$this->content = str_replace($key, $replace, $this->content);
105 105
 		}
Please login to merge, or discard this patch.
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -5,104 +5,104 @@
 block discarded – undo
5 5
 final class CleanCommentContent extends Content
6 6
 {
7 7
 
8
-	private static $LINK_PATTERN = '@<a.*href=["\']([^"\']*)["\'].*>(.*)</a>@i';
9
-	private static $BOLD_PATTERN = '@<b.*>(.*)</b>@i';
10
-	private static $ITALIC_PATTERN = '@<i.*>(.*)</i>@i';
11
-	private static $CODE_PATTERN = '@<pre[^>]*>(.*)</pre>@is';
8
+    private static $LINK_PATTERN = '@<a.*href=["\']([^"\']*)["\'].*>(.*)</a>@i';
9
+    private static $BOLD_PATTERN = '@<b.*>(.*)</b>@i';
10
+    private static $ITALIC_PATTERN = '@<i.*>(.*)</i>@i';
11
+    private static $CODE_PATTERN = '@<pre[^>]*>(.*)</pre>@is';
12 12
 
13
-	private static $LINK_REPLACE = '<a href="%s" rel="nofollow" target="_blank">%s</a>';
14
-	private static $BOLD_REPLACE = '<b>%s</b>';
15
-	private static $ITALIC_REPLACE = '<i>%s</i>';
16
-	private static $CODE_REPLACE = '<pre>%s</pre>';
13
+    private static $LINK_REPLACE = '<a href="%s" rel="nofollow" target="_blank">%s</a>';
14
+    private static $BOLD_REPLACE = '<b>%s</b>';
15
+    private static $ITALIC_REPLACE = '<i>%s</i>';
16
+    private static $CODE_REPLACE = '<pre>%s</pre>';
17 17
 
18
-	private static $URL_PATTERN = '@(https?://[a-z0-9\.-]+\.[a-z]{2,6}[^\s]*[^\.,\?\!;\s]+)@i';
19
-	private static $LINE_BREAK_PATTERN = '@([\r\n]+)@';
18
+    private static $URL_PATTERN = '@(https?://[a-z0-9\.-]+\.[a-z]{2,6}[^\s]*[^\.,\?\!;\s]+)@i';
19
+    private static $LINE_BREAK_PATTERN = '@([\r\n]+)@';
20 20
 
21
-	private static $LINE_BREAK_REPLACE = '<br />';
21
+    private static $LINE_BREAK_REPLACE = '<br />';
22 22
 
23
-	private $replacement_array = array();
23
+    private $replacement_array = array();
24 24
 
25
-	protected function execute()
26
-	{
27
-		$this->process_element(self::$CODE_PATTERN, self::$CODE_REPLACE);
28
-		$this->process_element(self::$LINK_PATTERN, self::$LINK_REPLACE);
29
-		$this->process_element(self::$ITALIC_PATTERN, self::$ITALIC_REPLACE);
30
-		$this->process_element(self::$BOLD_PATTERN, self::$BOLD_REPLACE);
25
+    protected function execute()
26
+    {
27
+        $this->process_element(self::$CODE_PATTERN, self::$CODE_REPLACE);
28
+        $this->process_element(self::$LINK_PATTERN, self::$LINK_REPLACE);
29
+        $this->process_element(self::$ITALIC_PATTERN, self::$ITALIC_REPLACE);
30
+        $this->process_element(self::$BOLD_PATTERN, self::$BOLD_REPLACE);
31 31
 		
32
-		$this->strip_extra_tags();
32
+        $this->strip_extra_tags();
33 33
 		
34
-		$this->link_unlinked_urls(self::$URL_PATTERN, self::$LINK_REPLACE);
35
-		$this->add_line_breaks();
36
-		$this->replace_element_patterns();
37
-	}
38
-
39
-	private function process_element($pattern, $replace)
40
-	{
41
-		$match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER);
34
+        $this->link_unlinked_urls(self::$URL_PATTERN, self::$LINK_REPLACE);
35
+        $this->add_line_breaks();
36
+        $this->replace_element_patterns();
37
+    }
38
+
39
+    private function process_element($pattern, $replace)
40
+    {
41
+        $match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER);
42 42
 		
43
-		if($match_count < 1)
44
-			return;
43
+        if($match_count < 1)
44
+            return;
45 45
 		
46
-		foreach($matches as $match)
47
-		{
48
-			$full_match = array_shift($match);
49
-			$placeholder = $this->create_placeholder($full_match);
50
-			$full_match_pattern = $this->create_full_match_pattern($full_match);
46
+        foreach($matches as $match)
47
+        {
48
+            $full_match = array_shift($match);
49
+            $placeholder = $this->create_placeholder($full_match);
50
+            $full_match_pattern = $this->create_full_match_pattern($full_match);
51 51
 			
52
-			$this->content = preg_replace($full_match_pattern, $placeholder, $this->content, 1);
53
-			$this->replacement_array[$placeholder] = vsprintf($replace, $match);
54
-		}
55
-	}
56
-
57
-	private function create_placeholder($text)
58
-	{
59
-		return md5($text . rand());
60
-	}
61
-
62
-	private function create_full_match_pattern($text)
63
-	{
64
-		$pattern = '';
65
-		$pattern .= '@';
66
-		$pattern .= preg_quote($text, '@');
67
-		$pattern .= '@';
68
-		$pattern .= 'i';
52
+            $this->content = preg_replace($full_match_pattern, $placeholder, $this->content, 1);
53
+            $this->replacement_array[$placeholder] = vsprintf($replace, $match);
54
+        }
55
+    }
56
+
57
+    private function create_placeholder($text)
58
+    {
59
+        return md5($text . rand());
60
+    }
61
+
62
+    private function create_full_match_pattern($text)
63
+    {
64
+        $pattern = '';
65
+        $pattern .= '@';
66
+        $pattern .= preg_quote($text, '@');
67
+        $pattern .= '@';
68
+        $pattern .= 'i';
69 69
 		
70
-		return $pattern;
71
-	}
70
+        return $pattern;
71
+    }
72 72
 
73
-	private function strip_extra_tags()
74
-	{
75
-		$this->content = strip_tags($this->content);
76
-	}
73
+    private function strip_extra_tags()
74
+    {
75
+        $this->content = strip_tags($this->content);
76
+    }
77 77
 
78
-	private function link_unlinked_urls($pattern, $replace)
79
-	{
80
-		$match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER);
78
+    private function link_unlinked_urls($pattern, $replace)
79
+    {
80
+        $match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER);
81 81
 		
82
-		if($match_count < 1)
83
-			return;
82
+        if($match_count < 1)
83
+            return;
84 84
 		
85
-		foreach($matches as $match)
86
-		{
87
-			$full_match = array_shift($match);
88
-			$full_match_pattern = $this->create_full_match_pattern($full_match);
89
-			$replace = sprintf($replace, $match[0], $match[0]);
85
+        foreach($matches as $match)
86
+        {
87
+            $full_match = array_shift($match);
88
+            $full_match_pattern = $this->create_full_match_pattern($full_match);
89
+            $replace = sprintf($replace, $match[0], $match[0]);
90 90
 			
91
-			$this->content = preg_replace($full_match_pattern, $replace, $this->content, 1);
92
-		}
93
-	}
94
-
95
-	private function add_line_breaks()
96
-	{
97
-		$this->content = preg_replace(self::$LINE_BREAK_PATTERN, self::$LINE_BREAK_REPLACE, $this->content);
98
-	}
99
-
100
-	private function replace_element_patterns()
101
-	{
102
-		foreach($this->replacement_array as $key => $replace)
103
-		{
104
-			$this->content = str_replace($key, $replace, $this->content);
105
-		}
106
-	}
91
+            $this->content = preg_replace($full_match_pattern, $replace, $this->content, 1);
92
+        }
93
+    }
94
+
95
+    private function add_line_breaks()
96
+    {
97
+        $this->content = preg_replace(self::$LINE_BREAK_PATTERN, self::$LINE_BREAK_REPLACE, $this->content);
98
+    }
99
+
100
+    private function replace_element_patterns()
101
+    {
102
+        foreach($this->replacement_array as $key => $replace)
103
+        {
104
+            $this->content = str_replace($key, $replace, $this->content);
105
+        }
106
+    }
107 107
 
108 108
 }
109 109
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +24 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,8 @@  discard block
 block discarded – undo
22 22
 
23 23
 	private $replacement_array = array();
24 24
 
25
-	protected function execute()
26
-	{
25
+	protected function execute()
26
+	{
27 27
 		$this->process_element(self::$CODE_PATTERN, self::$CODE_REPLACE);
28 28
 		$this->process_element(self::$LINK_PATTERN, self::$LINK_REPLACE);
29 29
 		$this->process_element(self::$ITALIC_PATTERN, self::$ITALIC_REPLACE);
@@ -36,12 +36,13 @@  discard block
 block discarded – undo
36 36
 		$this->replace_element_patterns();
37 37
 	}
38 38
 
39
-	private function process_element($pattern, $replace)
40
-	{
39
+	private function process_element($pattern, $replace)
40
+	{
41 41
 		$match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER);
42 42
 		
43
-		if($match_count < 1)
44
-			return;
43
+		if($match_count < 1) {
44
+					return;
45
+		}
45 46
 		
46 47
 		foreach($matches as $match)
47 48
 		{
@@ -54,13 +55,13 @@  discard block
 block discarded – undo
54 55
 		}
55 56
 	}
56 57
 
57
-	private function create_placeholder($text)
58
-	{
58
+	private function create_placeholder($text)
59
+	{
59 60
 		return md5($text . rand());
60 61
 	}
61 62
 
62
-	private function create_full_match_pattern($text)
63
-	{
63
+	private function create_full_match_pattern($text)
64
+	{
64 65
 		$pattern = '';
65 66
 		$pattern .= '@';
66 67
 		$pattern .= preg_quote($text, '@');
@@ -70,17 +71,18 @@  discard block
 block discarded – undo
70 71
 		return $pattern;
71 72
 	}
72 73
 
73
-	private function strip_extra_tags()
74
-	{
74
+	private function strip_extra_tags()
75
+	{
75 76
 		$this->content = strip_tags($this->content);
76 77
 	}
77 78
 
78
-	private function link_unlinked_urls($pattern, $replace)
79
-	{
79
+	private function link_unlinked_urls($pattern, $replace)
80
+	{
80 81
 		$match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER);
81 82
 		
82
-		if($match_count < 1)
83
-			return;
83
+		if($match_count < 1) {
84
+					return;
85
+		}
84 86
 		
85 87
 		foreach($matches as $match)
86 88
 		{
@@ -92,13 +94,13 @@  discard block
 block discarded – undo
92 94
 		}
93 95
 	}
94 96
 
95
-	private function add_line_breaks()
96
-	{
97
+	private function add_line_breaks()
98
+	{
97 99
 		$this->content = preg_replace(self::$LINE_BREAK_PATTERN, self::$LINE_BREAK_REPLACE, $this->content);
98 100
 	}
99 101
 
100
-	private function replace_element_patterns()
101
-	{
102
+	private function replace_element_patterns()
103
+	{
102 104
 		foreach($this->replacement_array as $key => $replace)
103 105
 		{
104 106
 			$this->content = str_replace($key, $replace, $this->content);
Please login to merge, or discard this patch.
Doc Comments   +8 added lines patch added patch discarded remove patch
@@ -36,6 +36,10 @@  discard block
 block discarded – undo
36 36
 		$this->replace_element_patterns();
37 37
 	}
38 38
 
39
+	/**
40
+	 * @param string $pattern
41
+	 * @param string $replace
42
+	 */
39 43
 	private function process_element($pattern, $replace)
40 44
 	{
41 45
 		$match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER);
@@ -75,6 +79,10 @@  discard block
 block discarded – undo
75 79
 		$this->content = strip_tags($this->content);
76 80
 	}
77 81
 
82
+	/**
83
+	 * @param string $pattern
84
+	 * @param string $replace
85
+	 */
78 86
 	private function link_unlinked_urls($pattern, $replace)
79 87
 	{
80 88
 		$match_count = preg_match_all($pattern, $this->content, $matches, PREG_SET_ORDER);
Please login to merge, or discard this patch.
utility/content/SmartTrimContent.class.inc.php 4 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -27,20 +27,20 @@  discard block
 block discarded – undo
27 27
 	protected function execute()
28 28
 	{
29 29
 		$args = func_get_args();
30
-		if(count($args) < 1)
30
+		if (count($args) < 1)
31 31
 		{
32 32
 			trigger_error('Someone called SmartTrimContent w/o defining a length... bad!');
33 33
 			return;
34 34
 		}
35 35
 		
36
-		if(count($args) == 2)
36
+		if (count($args) == 2)
37 37
 			$etc = $args[1];
38 38
 		else
39 39
 			$etc = self::$ETC;
40 40
 		
41 41
 		$length = $args[0];
42 42
 		
43
-		if($length < strlen($this->content))
43
+		if ($length < strlen($this->content))
44 44
 			$this->trim_string($length);
45 45
         else
46 46
             $etc = '';
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
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)
57
+		if ($last_left_bracket_position > $last_right_bracket_position)
58 58
 			$content = substr($content, 0, $last_left_bracket_position);
59 59
 		$content = trim($content);
60 60
 		
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
 		$content = current($content);
74 74
 		
75 75
 		$max_length = $length;
76
-		foreach($matches[0] as $match)
76
+		foreach ($matches[0] as $match)
77 77
 		{
78 78
 			$max_length += strlen($match[0]);
79
-			if($max_length <= $match[1])
79
+			if ($max_length <= $match[1])
80 80
 				break;
81 81
 			
82
-			$content = substr($content, 0, $match[1]) . $match[0] . substr($content, $match[1]);
82
+			$content = substr($content, 0, $match[1]).$match[0].substr($content, $match[1]);
83 83
 		}
84 84
 		
85
-		if(substr($content, -7) == '</p><p>')
85
+		if (substr($content, -7) == '</p><p>')
86 86
 			$content = substr($content, 0, -7);
87 87
 		
88 88
 		return $content;
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
 		$tags_preg = $this->get_tags_preg(self::$EXCLUDE_TAGS);
95 95
 		preg_match_all($tags_preg, $content, $matches, PREG_OFFSET_CAPTURE);
96 96
 		
97
-		if(count($matches[1]) % 2 == 1)
97
+		if (count($matches[1]) % 2 == 1)
98 98
 		{
99 99
 			$cut_tag = end($matches[1]);
100 100
 			$cut_tag_position = $cut_tag[1] - 1;
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 		preg_match_all($tags_preg, $content, $matches);
113 113
 		$open_tags = array();
114 114
 		
115
-		foreach($matches[1] as $tag)
115
+		foreach ($matches[1] as $tag)
116 116
 		{
117
-			if(in_array($tag, $open_tags))
117
+			if (in_array($tag, $open_tags))
118 118
 			{
119 119
 				$key = array_search($tag, $open_tags);
120 120
 				unset($open_tags[$key]);
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
 		}
125 125
 		
126 126
 		$open_tags = array_reverse($open_tags);
127
-		if(count($open_tags) > 0)
127
+		if (count($open_tags) > 0)
128 128
 		{
129
-			foreach($open_tags as $key => $open_tag)
129
+			foreach ($open_tags as $key => $open_tag)
130 130
 			{
131
-				if($key == count($open_tags) - 1)
131
+				if ($key == count($open_tags) - 1)
132 132
 					$content .= $etc;
133 133
 				$content .= "</{$open_tag}>";
134 134
 			}
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 
142 142
 	private function get_tags_preg($tag_array)
143 143
 	{
144
-		return '@</?(' . implode('|', $tag_array) . ')@';
144
+		return '@</?('.implode('|', $tag_array).')@';
145 145
 	}
146 146
 
147 147
 }
Please login to merge, or discard this patch.
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -5,143 +5,143 @@
 block discarded – undo
5 5
 class SmartTrimContent extends Content
6 6
 {
7 7
 
8
-	private static $EXCLUDE_TAGS = array(
9
-		'a',
10
-		'div',
11
-		'h4',
12
-		'pre');
13
-	private static $INCLUDE_TAGS = array(
14
-		'li',
15
-		'ol',
16
-		'p',
17
-		'ul');
18
-	private static $PHOTO_PLACEHOLDER_MATCH = '/{{photo="(.*)"}}/';
19
-	private static $HTML_TAG_PATTERN = '/<[^>]+>/';
20
-	private static $CUT_MARKER = '/*/ CUT HERE /*/';
21
-	private static $RIGHT_BRACKET = '>';
22
-	private static $LEFT_BRACKET = '<';
23
-	private static $ETC = '&hellip;';
8
+    private static $EXCLUDE_TAGS = array(
9
+        'a',
10
+        'div',
11
+        'h4',
12
+        'pre');
13
+    private static $INCLUDE_TAGS = array(
14
+        'li',
15
+        'ol',
16
+        'p',
17
+        'ul');
18
+    private static $PHOTO_PLACEHOLDER_MATCH = '/{{photo="(.*)"}}/';
19
+    private static $HTML_TAG_PATTERN = '/<[^>]+>/';
20
+    private static $CUT_MARKER = '/*/ CUT HERE /*/';
21
+    private static $RIGHT_BRACKET = '>';
22
+    private static $LEFT_BRACKET = '<';
23
+    private static $ETC = '&hellip;';
24 24
 
25
-	private $is_trimmed;
25
+    private $is_trimmed;
26 26
 
27
-	protected function execute()
28
-	{
29
-		$args = func_get_args();
30
-		if(count($args) < 1)
31
-		{
32
-			trigger_error('Someone called SmartTrimContent w/o defining a length... bad!');
33
-			return;
34
-		}
27
+    protected function execute()
28
+    {
29
+        $args = func_get_args();
30
+        if(count($args) < 1)
31
+        {
32
+            trigger_error('Someone called SmartTrimContent w/o defining a length... bad!');
33
+            return;
34
+        }
35 35
 		
36
-		if(count($args) == 2)
37
-			$etc = $args[1];
38
-		else
39
-			$etc = self::$ETC;
36
+        if(count($args) == 2)
37
+            $etc = $args[1];
38
+        else
39
+            $etc = self::$ETC;
40 40
 		
41
-		$length = $args[0];
41
+        $length = $args[0];
42 42
 		
43
-		if($length < strlen($this->content))
44
-			$this->trim_string($length);
43
+        if($length < strlen($this->content))
44
+            $this->trim_string($length);
45 45
         else
46 46
             $etc = '';
47
-		$this->check_exclude_tags();
48
-		$this->close_tags($etc);
49
-	}
47
+        $this->check_exclude_tags();
48
+        $this->close_tags($etc);
49
+    }
50 50
 
51
-	private function trim_string($length)
52
-	{
53
-		$content = $this->trim_html_string($this->content, $length);
51
+    private function trim_string($length)
52
+    {
53
+        $content = $this->trim_html_string($this->content, $length);
54 54
 		
55
-		$last_right_bracket_position = strripos($content, self::$RIGHT_BRACKET);
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);
59
-		$content = trim($content);
55
+        $last_right_bracket_position = strripos($content, self::$RIGHT_BRACKET);
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);
59
+        $content = trim($content);
60 60
 		
61
-		$this->content = $content;
62
-		$this->is_trimmed = true;
63
-	}
61
+        $this->content = $content;
62
+        $this->is_trimmed = true;
63
+    }
64 64
 
65
-	private function trim_html_string($content, $length)
66
-	{
67
-		$content = preg_replace(self::$PHOTO_PLACEHOLDER_MATCH, '', $content);
68
-		preg_match_all(self::$HTML_TAG_PATTERN, $content, $matches, PREG_OFFSET_CAPTURE);
69
-		$content = strip_tags($content);
65
+    private function trim_html_string($content, $length)
66
+    {
67
+        $content = preg_replace(self::$PHOTO_PLACEHOLDER_MATCH, '', $content);
68
+        preg_match_all(self::$HTML_TAG_PATTERN, $content, $matches, PREG_OFFSET_CAPTURE);
69
+        $content = strip_tags($content);
70 70
 		
71
-		$content = wordwrap($content, $length, self::$CUT_MARKER);
72
-		$content = explode(self::$CUT_MARKER, $content);
73
-		$content = current($content);
71
+        $content = wordwrap($content, $length, self::$CUT_MARKER);
72
+        $content = explode(self::$CUT_MARKER, $content);
73
+        $content = current($content);
74 74
 		
75
-		$max_length = $length;
76
-		foreach($matches[0] as $match)
77
-		{
78
-			$max_length += strlen($match[0]);
79
-			if($max_length <= $match[1])
80
-				break;
75
+        $max_length = $length;
76
+        foreach($matches[0] as $match)
77
+        {
78
+            $max_length += strlen($match[0]);
79
+            if($max_length <= $match[1])
80
+                break;
81 81
 			
82
-			$content = substr($content, 0, $match[1]) . $match[0] . substr($content, $match[1]);
83
-		}
82
+            $content = substr($content, 0, $match[1]) . $match[0] . substr($content, $match[1]);
83
+        }
84 84
 		
85
-		if(substr($content, -7) == '</p><p>')
86
-			$content = substr($content, 0, -7);
85
+        if(substr($content, -7) == '</p><p>')
86
+            $content = substr($content, 0, -7);
87 87
 		
88
-		return $content;
89
-	}
88
+        return $content;
89
+    }
90 90
 
91
-	private function check_exclude_tags()
92
-	{
93
-		$content = $this->content;
94
-		$tags_preg = $this->get_tags_preg(self::$EXCLUDE_TAGS);
95
-		preg_match_all($tags_preg, $content, $matches, PREG_OFFSET_CAPTURE);
91
+    private function check_exclude_tags()
92
+    {
93
+        $content = $this->content;
94
+        $tags_preg = $this->get_tags_preg(self::$EXCLUDE_TAGS);
95
+        preg_match_all($tags_preg, $content, $matches, PREG_OFFSET_CAPTURE);
96 96
 		
97
-		if(count($matches[1]) % 2 == 1)
98
-		{
99
-			$cut_tag = end($matches[1]);
100
-			$cut_tag_position = $cut_tag[1] - 1;
101
-			$content = substr($content, 0, $cut_tag_position);
102
-		}
103
-		$content = trim($content);
97
+        if(count($matches[1]) % 2 == 1)
98
+        {
99
+            $cut_tag = end($matches[1]);
100
+            $cut_tag_position = $cut_tag[1] - 1;
101
+            $content = substr($content, 0, $cut_tag_position);
102
+        }
103
+        $content = trim($content);
104 104
 		
105
-		$this->content = $content;
106
-	}
105
+        $this->content = $content;
106
+    }
107 107
 
108
-	private function close_tags($etc)
109
-	{
110
-		$content = $this->content;
111
-		$tags_preg = $this->get_tags_preg(self::$INCLUDE_TAGS);
112
-		preg_match_all($tags_preg, $content, $matches);
113
-		$open_tags = array();
108
+    private function close_tags($etc)
109
+    {
110
+        $content = $this->content;
111
+        $tags_preg = $this->get_tags_preg(self::$INCLUDE_TAGS);
112
+        preg_match_all($tags_preg, $content, $matches);
113
+        $open_tags = array();
114 114
 		
115
-		foreach($matches[1] as $tag)
116
-		{
117
-			if(in_array($tag, $open_tags))
118
-			{
119
-				$key = array_search($tag, $open_tags);
120
-				unset($open_tags[$key]);
121
-			}
122
-			else
123
-				$open_tags[] = $tag;
124
-		}
115
+        foreach($matches[1] as $tag)
116
+        {
117
+            if(in_array($tag, $open_tags))
118
+            {
119
+                $key = array_search($tag, $open_tags);
120
+                unset($open_tags[$key]);
121
+            }
122
+            else
123
+                $open_tags[] = $tag;
124
+        }
125 125
 		
126
-		$open_tags = array_reverse($open_tags);
127
-		if(count($open_tags) > 0)
128
-		{
129
-			foreach($open_tags as $key => $open_tag)
130
-			{
131
-				if($key == count($open_tags) - 1)
132
-					$content .= $etc;
133
-				$content .= "</{$open_tag}>";
134
-			}
135
-		}
136
-		else
137
-			$content .= $etc;
126
+        $open_tags = array_reverse($open_tags);
127
+        if(count($open_tags) > 0)
128
+        {
129
+            foreach($open_tags as $key => $open_tag)
130
+            {
131
+                if($key == count($open_tags) - 1)
132
+                    $content .= $etc;
133
+                $content .= "</{$open_tag}>";
134
+            }
135
+        }
136
+        else
137
+            $content .= $etc;
138 138
 		
139
-		$this->content = $content;
140
-	}
139
+        $this->content = $content;
140
+    }
141 141
 
142
-	private function get_tags_preg($tag_array)
143
-	{
144
-		return '@</?(' . implode('|', $tag_array) . ')@';
145
-	}
142
+    private function get_tags_preg($tag_array)
143
+    {
144
+        return '@</?(' . implode('|', $tag_array) . ')@';
145
+    }
146 146
 
147 147
 }
Please login to merge, or discard this patch.
Braces   +42 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,8 @@  discard block
 block discarded – undo
24 24
 
25 25
 	private $is_trimmed;
26 26
 
27
-	protected function execute()
28
-	{
27
+	protected function execute()
28
+	{
29 29
 		$args = func_get_args();
30 30
 		if(count($args) < 1)
31 31
 		{
@@ -33,37 +33,40 @@  discard block
 block discarded – undo
33 33
 			return;
34 34
 		}
35 35
 		
36
-		if(count($args) == 2)
37
-			$etc = $args[1];
38
-		else
39
-			$etc = self::$ETC;
36
+		if(count($args) == 2) {
37
+					$etc = $args[1];
38
+		} else {
39
+					$etc = self::$ETC;
40
+		}
40 41
 		
41 42
 		$length = $args[0];
42 43
 		
43
-		if($length < strlen($this->content))
44
-			$this->trim_string($length);
45
-        else
46
-            $etc = '';
44
+		if($length < strlen($this->content)) {
45
+					$this->trim_string($length);
46
+		} else {
47
+                    $etc = '';
48
+        }
47 49
 		$this->check_exclude_tags();
48 50
 		$this->close_tags($etc);
49 51
 	}
50 52
 
51
-	private function trim_string($length)
52
-	{
53
+	private function trim_string($length)
54
+	{
53 55
 		$content = $this->trim_html_string($this->content, $length);
54 56
 		
55 57
 		$last_right_bracket_position = strripos($content, self::$RIGHT_BRACKET);
56 58
 		$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);
59
+		if($last_left_bracket_position > $last_right_bracket_position) {
60
+					$content = substr($content, 0, $last_left_bracket_position);
61
+		}
59 62
 		$content = trim($content);
60 63
 		
61 64
 		$this->content = $content;
62 65
 		$this->is_trimmed = true;
63 66
 	}
64 67
 
65
-	private function trim_html_string($content, $length)
66
-	{
68
+	private function trim_html_string($content, $length)
69
+	{
67 70
 		$content = preg_replace(self::$PHOTO_PLACEHOLDER_MATCH, '', $content);
68 71
 		preg_match_all(self::$HTML_TAG_PATTERN, $content, $matches, PREG_OFFSET_CAPTURE);
69 72
 		$content = strip_tags($content);
@@ -76,20 +79,22 @@  discard block
 block discarded – undo
76 79
 		foreach($matches[0] as $match)
77 80
 		{
78 81
 			$max_length += strlen($match[0]);
79
-			if($max_length <= $match[1])
80
-				break;
82
+			if($max_length <= $match[1]) {
83
+							break;
84
+			}
81 85
 			
82 86
 			$content = substr($content, 0, $match[1]) . $match[0] . substr($content, $match[1]);
83 87
 		}
84 88
 		
85
-		if(substr($content, -7) == '</p><p>')
86
-			$content = substr($content, 0, -7);
89
+		if(substr($content, -7) == '</p><p>') {
90
+					$content = substr($content, 0, -7);
91
+		}
87 92
 		
88 93
 		return $content;
89 94
 	}
90 95
 
91
-	private function check_exclude_tags()
92
-	{
96
+	private function check_exclude_tags()
97
+	{
93 98
 		$content = $this->content;
94 99
 		$tags_preg = $this->get_tags_preg(self::$EXCLUDE_TAGS);
95 100
 		preg_match_all($tags_preg, $content, $matches, PREG_OFFSET_CAPTURE);
@@ -105,8 +110,8 @@  discard block
 block discarded – undo
105 110
 		$this->content = $content;
106 111
 	}
107 112
 
108
-	private function close_tags($etc)
109
-	{
113
+	private function close_tags($etc)
114
+	{
110 115
 		$content = $this->content;
111 116
 		$tags_preg = $this->get_tags_preg(self::$INCLUDE_TAGS);
112 117
 		preg_match_all($tags_preg, $content, $matches);
@@ -118,9 +123,9 @@  discard block
 block discarded – undo
118 123
 			{
119 124
 				$key = array_search($tag, $open_tags);
120 125
 				unset($open_tags[$key]);
121
-			}
122
-			else
123
-				$open_tags[] = $tag;
126
+			} else {
127
+							$open_tags[] = $tag;
128
+			}
124 129
 		}
125 130
 		
126 131
 		$open_tags = array_reverse($open_tags);
@@ -128,19 +133,20 @@  discard block
 block discarded – undo
128 133
 		{
129 134
 			foreach($open_tags as $key => $open_tag)
130 135
 			{
131
-				if($key == count($open_tags) - 1)
132
-					$content .= $etc;
136
+				if($key == count($open_tags) - 1) {
137
+									$content .= $etc;
138
+				}
133 139
 				$content .= "</{$open_tag}>";
134 140
 			}
135
-		}
136
-		else
137
-			$content .= $etc;
141
+		} else {
142
+					$content .= $etc;
143
+		}
138 144
 		
139 145
 		$this->content = $content;
140 146
 	}
141 147
 
142
-	private function get_tags_preg($tag_array)
143
-	{
148
+	private function get_tags_preg($tag_array)
149
+	{
144 150
 		return '@</?(' . implode('|', $tag_array) . ')@';
145 151
 	}
146 152
 
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -62,6 +62,9 @@
 block discarded – undo
62 62
 		$this->is_trimmed = true;
63 63
 	}
64 64
 
65
+	/**
66
+	 * @param string $content
67
+	 */
65 68
 	private function trim_html_string($content, $length)
66 69
 	{
67 70
 		$content = preg_replace(self::$PHOTO_PLACEHOLDER_MATCH, '', $content);
Please login to merge, or discard this patch.
utility/URLDecode.class.inc.php 4 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -15,11 +15,11 @@  discard block
 block discarded – undo
15 15
 	static private function form_url_array($host, $uri)
16 16
 	{
17 17
 		$uri = substr($uri, 1);
18
-		if(strpos($uri, '?'))
18
+		if (strpos($uri, '?'))
19 19
 			$uri = substr($uri, 0, strpos($uri, '?'));
20 20
 		$uri_array = explode('/', $uri);
21 21
 		
22
-		if(!Loader::isLive())
22
+		if (!Loader::isLive())
23 23
 			$host = substr($host, strpos($host, '.') + 1);
24 24
 		
25 25
 		self::$array['host'] = $host;
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
     $base .= '/';
42 42
 
43 43
 		self::$array['base'] = $base;
44
-		self::$array['uri'] = '/' . implode('/', $uri_array);
44
+		self::$array['uri'] = '/'.implode('/', $uri_array);
45 45
 		
46
-		if(end($uri_array) == '')
46
+		if (end($uri_array) == '')
47 47
 			$uri_array = array_slice($uri_array, 0, count($uri_array) - 1);
48 48
 		self::$array['pieces'] = (array) $uri_array;
49 49
 	}
@@ -71,21 +71,21 @@  discard block
 block discarded – undo
71 71
 	static function getExtension()
72 72
 	{
73 73
 		$file = self::getPiece(-1);
74
-		if(substr($file, -1) == '/')
74
+		if (substr($file, -1) == '/')
75 75
 			return false;
76
-		return substr($file, strrpos($file, '.') + 1);;
76
+		return substr($file, strrpos($file, '.') + 1); ;
77 77
 	}
78 78
 
79 79
 	static function getPiece($piece = null)
80 80
 	{
81
-		if(!$piece)
81
+		if (!$piece)
82 82
 			return self::$array['pieces'];
83 83
 		
84
-		if($piece == -1)
84
+		if ($piece == -1)
85 85
 			return end(self::$array['pieces']);
86 86
 		
87 87
 		$piece = $piece - 1;
88
-		if(array_key_exists($piece, self::$array['pieces']))
88
+		if (array_key_exists($piece, self::$array['pieces']))
89 89
 			return self::$array['pieces'][$piece];
90 90
 		return;
91 91
 	}
Please login to merge, or discard this 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.
Braces   +39 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,26 +1,28 @@  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()
9
+	{
10 10
 		$host = $_SERVER['HTTP_HOST'];
11 11
 		$uri = $_SERVER['REQUEST_URI'];
12 12
 		self::form_url_array($host, $uri);
13 13
 	}
14 14
 
15
-	static private function form_url_array($host, $uri)
16
-	{
15
+	static private function form_url_array($host, $uri)
16
+	{
17 17
 		$uri = substr($uri, 1);
18
-		if(strpos($uri, '?'))
19
-			$uri = substr($uri, 0, strpos($uri, '?'));
18
+		if(strpos($uri, '?')) {
19
+					$uri = substr($uri, 0, strpos($uri, '?'));
20
+		}
20 21
 		$uri_array = explode('/', $uri);
21 22
 		
22
-		if(!Loader::isLive())
23
-			$host = substr($host, strpos($host, '.') + 1);
23
+		if(!Loader::isLive()) {
24
+					$host = substr($host, strpos($host, '.') + 1);
25
+		}
24 26
 		
25 27
 		self::$array['host'] = $host;
26 28
 		
@@ -43,50 +45,55 @@  discard block
 block discarded – undo
43 45
 		self::$array['base'] = $base;
44 46
 		self::$array['uri'] = '/' . implode('/', $uri_array);
45 47
 		
46
-		if(end($uri_array) == '')
47
-			$uri_array = array_slice($uri_array, 0, count($uri_array) - 1);
48
+		if(end($uri_array) == '') {
49
+					$uri_array = array_slice($uri_array, 0, count($uri_array) - 1);
50
+		}
48 51
 		self::$array['pieces'] = (array) $uri_array;
49 52
 	}
50 53
 
51
-	static function getSite()
52
-	{
54
+	static function getSite()
55
+	{
53 56
 		return self::$array['site'];
54 57
 	}
55 58
 
56
-	static function getHost()
57
-	{
59
+	static function getHost()
60
+	{
58 61
 		return self::$array['host'];
59 62
 	}
60 63
 
61
-	static function getBase()
62
-	{
64
+	static function getBase()
65
+	{
63 66
 		return self::$array['base'];
64 67
 	}
65 68
 
66
-	static function getURI()
67
-	{
69
+	static function getURI()
70
+	{
68 71
 		return self::$array['uri'];
69 72
 	}
70 73
 
71
-	static function getExtension()
72
-	{
74
+	static function getExtension()
75
+	{
73 76
 		$file = self::getPiece(-1);
74
-		if(substr($file, -1) == '/')
75
-			return false;
77
+		if(substr($file, -1) == '/') {
78
+					return false;
79
+		}
76 80
 		return substr($file, strrpos($file, '.') + 1);;
77 81
 	}
78 82
 
79
-	static function getPiece($piece = null)
80
-	{
81
-		if(!$piece)
82
-			return self::$array['pieces'];
83
+	static function getPiece($piece = null)
84
+	{
85
+		if(!$piece) {
86
+					return self::$array['pieces'];
87
+		}
83 88
 		
84
-		if($piece == -1)
85
-			return end(self::$array['pieces']);
89
+		if($piece == -1) {
90
+					return end(self::$array['pieces']);
91
+		}
86 92
 		
87 93
 		$piece = $piece - 1;
88
-		if(array_key_exists($piece, self::$array['pieces']))
89
-			return self::$array['pieces'][$piece];
94
+		if(array_key_exists($piece, self::$array['pieces'])) {
95
+					return self::$array['pieces'][$piece];
96
+		}
90 97
 		return;
91 98
 	}
92 99
 
Please login to merge, or discard this patch.
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -48,6 +48,9 @@  discard block
 block discarded – undo
48 48
 		self::$array['pieces'] = (array) $uri_array;
49 49
 	}
50 50
 
51
+	/**
52
+	 * @return string
53
+	 */
51 54
 	static function getSite()
52 55
 	{
53 56
 		return self::$array['site'];
@@ -76,6 +79,9 @@  discard block
 block discarded – undo
76 79
 		return substr($file, strrpos($file, '.') + 1);;
77 80
 	}
78 81
 
82
+	/**
83
+	 * @param integer $piece
84
+	 */
79 85
 	static function getPiece($piece = null)
80 86
 	{
81 87
 		if(!$piece)
Please login to merge, or discard this patch.
utility/Loader.class.inc.php 4 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@  discard block
 block discarded – undo
17 17
 
18 18
 	public static function instance()
19 19
 	{
20
-		if(!isset(self::$instance))
20
+		if (!isset(self::$instance))
21 21
 			self::$instance = new Loader();
22 22
 		return self::$instance;
23 23
 	}
24 24
 
25 25
 	private function get_root()
26 26
 	{
27
-		if(!isset($this->root))
27
+		if (!isset($this->root))
28 28
 		{
29 29
 			$current_directory = dirname(__FILE__);
30 30
 			$current_directory = substr($current_directory, 0, -7);
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
 	private static function get_extension($type)
54 54
 	{
55
-		switch($type)
55
+		switch ($type)
56 56
 		{
57 57
 			case 'collector' :
58 58
 			case 'controller' :
@@ -104,15 +104,15 @@  discard block
 block discarded – undo
104 104
 
105 105
 	public static function load($type, $files, $data = array())
106 106
 	{
107
-		foreach((array) $files as $file)
107
+		foreach ((array) $files as $file)
108 108
 		{
109 109
 			$file_path = self::instance()->get_path($type, $file);
110
-			if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view')
110
+			if (in_array($file_path, self::instance()->get_included_files()) && $type !== 'view')
111 111
 				continue;
112 112
 			
113 113
 			self::instance()->add_included_file($file_path);
114 114
 			
115
-			switch($type)
115
+			switch ($type)
116 116
 			{
117 117
 				case 'images' :
118 118
 				case 'scripts' :
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 		
143 143
 		$reflectionObject = self::create_reflection_class($file);
144 144
 		
145
-		if(
145
+		if (
146 146
 			$reflectionObject->hasMethod('instance') &&
147 147
 			$reflectionObject->getMethod('instance')->isStatic())
148 148
 		{
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 		
158 158
 		$reflectionObject = self::create_reflection_class($file);
159 159
 		
160
-		if($reflectionObject->hasMethod('__construct'))
160
+		if ($reflectionObject->hasMethod('__construct'))
161 161
 			return $reflectionObject->newInstanceArgs($data);
162 162
 		else
163 163
 			return $reflectionObject->newInstance();
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
             if ($site == 'waterfalls' && self::instance()->is_live) {
181 181
                 return "{$protocol}://www.waterfallsofthekeweenaw.com/";
182 182
             } else {
183
-                return $protocol . '://' . (self::instance()->is_live ? '' : 'dev.') . $site . '.jacobemerick.com/';
183
+                return $protocol.'://'.(self::instance()->is_live ? '' : 'dev.').$site.'.jacobemerick.com/';
184 184
             }
185 185
         }
186 186
         return '/';
Please login to merge, or discard this 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.
Braces   +49 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,22 @@  discard block
 block discarded – undo
9 9
 
10 10
 	private static $instance;
11 11
 
12
-	private function __construct()
13
-	{
12
+	private function __construct()
13
+	{
14 14
 		$this->is_live = (isset($_SERVER['HTTP_HOST']) && substr($_SERVER['HTTP_HOST'], 0, 4) !== 'dev.');
15 15
 		return $this;
16 16
 	}
17 17
 
18
-	public static function instance()
19
-	{
20
-		if(!isset(self::$instance))
21
-			self::$instance = new Loader();
18
+	public static function instance()
19
+	{
20
+		if(!isset(self::$instance)) {
21
+					self::$instance = new Loader();
22
+		}
22 23
 		return self::$instance;
23 24
 	}
24 25
 
25
-	private function get_root()
26
-	{
26
+	private function get_root()
27
+	{
27 28
 		if(!isset($this->root))
28 29
 		{
29 30
 			$current_directory = dirname(__FILE__);
@@ -34,24 +35,24 @@  discard block
 block discarded – undo
34 35
 		return $this->root;
35 36
 	}
36 37
 
37
-	private function get_delimiter()
38
-	{
38
+	private function get_delimiter()
39
+	{
39 40
 		return (true || $this->is_live) ? '/' : '\\';
40 41
 	}
41 42
 
42
-	private function check_delimiters($path)
43
-	{
43
+	private function check_delimiters($path)
44
+	{
44 45
 		return (true || $this->is_live) ? $path : str_replace('/', '\\', $path);
45 46
 	}
46 47
 
47
-	private static function get_class_name($path)
48
-	{
48
+	private static function get_class_name($path)
49
+	{
49 50
 		$path_array = explode('/', $path);
50 51
 		return array_pop($path_array);
51 52
 	}
52 53
 
53
-	private static function get_extension($type)
54
-	{
54
+	private static function get_extension($type)
55
+	{
55 56
 		switch($type)
56 57
 		{
57 58
 			case 'collector' :
@@ -69,8 +70,8 @@  discard block
 block discarded – undo
69 70
 		return $extension;
70 71
 	}
71 72
 
72
-	public static function getImagePath($type, $file)
73
-	{
73
+	public static function getImagePath($type, $file)
74
+	{
74 75
 		$path = self::instance()->get_root();
75 76
 		$path .= 'public';
76 77
 		$path .= self::instance()->get_delimiter();
@@ -81,8 +82,8 @@  discard block
 block discarded – undo
81 82
 		return $path;
82 83
 	}
83 84
 
84
-	private static function get_path($type, $file)
85
-	{
85
+	private static function get_path($type, $file)
86
+	{
86 87
 		$path = self::instance()->get_root();
87 88
 		$path .= $type;
88 89
 		$path .= self::instance()->get_delimiter();
@@ -92,23 +93,24 @@  discard block
 block discarded – undo
92 93
 		return $path;
93 94
 	}
94 95
 
95
-	private function get_included_files()
96
-	{
96
+	private function get_included_files()
97
+	{
97 98
 		return $this->included_files;
98 99
 	}
99 100
 
100
-	private function add_included_file($path)
101
-	{
101
+	private function add_included_file($path)
102
+	{
102 103
 		$this->included_files[] = $path;
103 104
 	}
104 105
 
105
-	public static function load($type, $files, $data = array())
106
-	{
106
+	public static function load($type, $files, $data = array())
107
+	{
107 108
 		foreach((array) $files as $file)
108 109
 		{
109 110
 			$file_path = self::instance()->get_path($type, $file);
110
-			if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view')
111
-				continue;
111
+			if(in_array($file_path, self::instance()->get_included_files()) && $type !== 'view') {
112
+							continue;
113
+			}
112 114
 			
113 115
 			self::instance()->add_included_file($file_path);
114 116
 			
@@ -130,14 +132,14 @@  discard block
 block discarded – undo
130 132
 		}
131 133
 	}
132 134
 
133
-	private static function create_reflection_class($file)
134
-	{
135
+	private static function create_reflection_class($file)
136
+	{
135 137
 		$class_name = self::instance()->get_class_name($file);
136 138
 		return new ReflectionClass($class_name);
137 139
 	}
138 140
 
139
-	public static function loadInstance($type, $file)
140
-	{
141
+	public static function loadInstance($type, $file)
142
+	{
141 143
 		self::load($type, $file);
142 144
 		
143 145
 		$reflectionObject = self::create_reflection_class($file);
@@ -151,30 +153,31 @@  discard block
 block discarded – undo
151 153
 		trigger_error("Requested class cannot be instance'd: {$type}, {$file}");
152 154
 	}
153 155
 
154
-	public static function loadNew($type, $file, $data = array())
155
-	{
156
+	public static function loadNew($type, $file, $data = array())
157
+	{
156 158
 		self::load($type, $file);
157 159
 		
158 160
 		$reflectionObject = self::create_reflection_class($file);
159 161
 		
160
-		if($reflectionObject->hasMethod('__construct'))
161
-			return $reflectionObject->newInstanceArgs($data);
162
-		else
163
-			return $reflectionObject->newInstance();
162
+		if($reflectionObject->hasMethod('__construct')) {
163
+					return $reflectionObject->newInstanceArgs($data);
164
+		} else {
165
+					return $reflectionObject->newInstance();
166
+		}
164 167
 	}
165 168
 
166
-	public static function getRoot()
167
-	{
169
+	public static function getRoot()
170
+	{
168 171
 		return self::instance()->get_root();
169 172
 	}
170 173
 
171
-	public static function isLive()
172
-	{
174
+	public static function isLive()
175
+	{
173 176
 		return self::instance()->is_live;
174 177
 	}
175 178
 
176
-    public static function getRootURL($site = '')
177
-    {
179
+    public static function getRootURL($site = '')
180
+    {
178 181
         if (strlen($site) > 0) {
179 182
             $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
180 183
             if ($site == 'waterfalls' && self::instance()->is_live) {
Please login to merge, or discard this patch.
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -69,6 +69,9 @@  discard block
 block discarded – undo
69 69
 		return $extension;
70 70
 	}
71 71
 
72
+	/**
73
+	 * @param string $type
74
+	 */
72 75
 	public static function getImagePath($type, $file)
73 76
 	{
74 77
 		$path = self::instance()->get_root();
@@ -151,6 +154,9 @@  discard block
 block discarded – undo
151 154
 		trigger_error("Requested class cannot be instance'd: {$type}, {$file}");
152 155
 	}
153 156
 
157
+	/**
158
+	 * @param string $type
159
+	 */
154 160
 	public static function loadNew($type, $file, $data = array())
155 161
 	{
156 162
 		self::load($type, $file);
Please login to merge, or discard this patch.