@@ -133,6 +133,10 @@ |
||
133 | 133 | $this->addURL('about/', date('Y-01-01'), self::$ABOUT_PAGE_CHANGEFREQ, self::$ABOUT_PAGE_RANK); |
134 | 134 | } |
135 | 135 | |
136 | + /** |
|
137 | + * @param integer $items_per_page |
|
138 | + * @param string $type |
|
139 | + */ |
|
136 | 140 | private function add_paginated_pages($count, $items_per_page, $base_url, $type) |
137 | 141 | { |
138 | 142 | switch($type) { |
@@ -1,13 +1,13 @@ discard block |
||
1 | 1 | <? |
2 | 2 | |
3 | 3 | Loader::load('collector', array( |
4 | - 'waterfall/CompanionCollector', |
|
5 | - 'waterfall/CountyCollector', |
|
6 | - 'waterfall/LogCollector', |
|
7 | - 'waterfall/LogTagCollector', |
|
8 | - 'waterfall/PeriodCollector', |
|
9 | - 'waterfall/WatercourseCollector', |
|
10 | - 'waterfall/WaterfallCollector', |
|
4 | + 'waterfall/CompanionCollector', |
|
5 | + 'waterfall/CountyCollector', |
|
6 | + 'waterfall/LogCollector', |
|
7 | + 'waterfall/LogTagCollector', |
|
8 | + 'waterfall/PeriodCollector', |
|
9 | + 'waterfall/WatercourseCollector', |
|
10 | + 'waterfall/WaterfallCollector', |
|
11 | 11 | )); |
12 | 12 | Loader::load('controller', '/SitemapController'); |
13 | 13 | Loader::load('utility', 'Content'); |
@@ -15,143 +15,143 @@ discard block |
||
15 | 15 | final class WaterfallSitemapController extends SitemapController |
16 | 16 | { |
17 | 17 | |
18 | - private static $HOME_PAGE_RANK = .9; |
|
19 | - |
|
20 | - private static $WATERFALL_LISTING_RANK = .3; |
|
21 | - private static $WATERFALL_COUNTY_LISTING_RANK = .6; |
|
22 | - private static $WATERFALL_WATERCOURSE_LISTING_RANK = .6; |
|
23 | - private static $WATERFALL_LISTING_SUBPAGES_RANK = .1; |
|
24 | - private static $WATERFALL_PAGE_RANK = .8; |
|
25 | - |
|
26 | - private static $MAP_PAGE_RANK = .6; |
|
27 | - |
|
28 | - private static $LOG_LISTING_RANK = .3; |
|
29 | - private static $LOG_COMPANION_LISTING_RANK = .3; |
|
30 | - private static $LOG_PERIOD_LISTING_RANK = .3; |
|
31 | - private static $LOG_LISTING_SUBPAGES_RANK = .1; |
|
32 | - private static $LOG_PAGE_RANK = .7; |
|
33 | - |
|
34 | - private static $ABOUT_PAGE_RANK = .6; |
|
35 | - |
|
36 | - |
|
37 | - private static $HOME_PAGE_CHANGEFREQ = 'daily'; |
|
38 | - |
|
39 | - private static $WATERFALL_LISTING_CHANGEFREQ = 'monthly'; |
|
40 | - private static $WATERFALL_COUNTY_LISTING_CHANGEFREQ = 'monthly'; |
|
41 | - private static $WATERFALL_WATERCOURSE_LISTING_CHANGEFREQ = 'monthly'; |
|
42 | - private static $WATERFALL_LISTING_SUBPAGES_CHANGEFREQ = 'monthly'; |
|
43 | - private static $WATERFALL_PAGE_CHANGEFREQ = 'weekly'; |
|
44 | - |
|
45 | - private static $MAP_PAGE_CHANGEFREQ = 'monthly'; |
|
46 | - |
|
47 | - private static $LOG_LISTING_CHANGEFREQ = 'weekly'; |
|
48 | - private static $LOG_COMPANION_LISTING_CHANGEFREQ = 'monthly'; |
|
49 | - private static $LOG_PERIOD_LISTING_CHANGEFREQ = 'monthly'; |
|
50 | - private static $LOG_LISTING_SUBPAGES_CHANGEFREQ = 'monthly'; |
|
51 | - private static $LOG_PAGE_CHANGEFREQ = 'weekly'; |
|
52 | - |
|
53 | - private static $ABOUT_PAGE_CHANGEFREQ = 'yearly'; |
|
54 | - |
|
55 | - |
|
56 | - private static $WATERFALLS_PER_LISTING = 24; |
|
57 | - private static $WATERFALLS_PER_COUNTY_LISTING = 12; |
|
58 | - private static $WATERFALLS_PER_WATERCOURSE_LISTING = 12; |
|
59 | - |
|
60 | - private static $LOGS_PER_LISTING = 10; |
|
61 | - private static $LOGS_PER_COMPANION_LISTING = 10; |
|
62 | - private static $LOGS_PER_PERIOD_LISTING = 10; |
|
63 | - |
|
64 | - protected function set_data() |
|
65 | - { |
|
66 | - $this->add_home_pages(); |
|
67 | - $this->add_waterfall_pages(); |
|
68 | - $this->add_map_pages(); |
|
69 | - $this->add_log_pages(); |
|
70 | - $this->add_about_pages(); |
|
71 | - } |
|
72 | - |
|
73 | - private function add_home_pages() |
|
74 | - { |
|
75 | - $this->addURL('', date('Y-m-d'), self::$HOME_PAGE_CHANGEFREQ, self::$HOME_PAGE_RANK); |
|
76 | - } |
|
77 | - |
|
78 | - private function add_waterfall_pages() |
|
79 | - { |
|
80 | - $this->addURL('falls/', date('Y-m-01'), self::$WATERFALL_LISTING_CHANGEFREQ, self::$WATERFALL_LISTING_RANK); |
|
81 | - $count = WaterfallCollector::getListCount(); |
|
82 | - $this->add_paginated_pages($count, self::$WATERFALLS_PER_LISTING, 'falls', 'waterfall'); |
|
83 | - |
|
84 | - $county_list = CountyCollector::getCountyList(); |
|
85 | - foreach ($county_list as $county) { |
|
86 | - $this->addURL("{$county->alias}/", date('Y-m-01'), self::$WATERFALL_COUNTY_LISTING_CHANGEFREQ, self::$WATERFALL_COUNTY_LISTING_RANK); |
|
87 | - $this->add_paginated_pages($county->count, self::$WATERFALLS_PER_COUNTY_LISTING, $county->alias, 'waterfall'); |
|
88 | - } |
|
89 | - |
|
90 | - $watercourse_list = WatercourseCollector::getWatercourseList(); |
|
91 | - foreach ($watercourse_list as $watercourse) { |
|
92 | - $this->addURL("{$watercourse->alias}/", date('Y-m-01'), self::$WATERFALL_WATERCOURSE_LISTING_CHANGEFREQ, self::$WATERFALL_WATERCOURSE_LISTING_RANK); |
|
93 | - $this->add_paginated_pages($watercourse->count, self::$WATERFALLS_PER_WATERCOURSE_LISTING, $watercourse->alias, 'waterfall'); |
|
94 | - } |
|
95 | - |
|
96 | - $waterfall_list = WaterfallCollector::getList(500); |
|
97 | - foreach ($waterfall_list as $waterfall) { |
|
98 | - $this->addURL("{$waterfall->watercourse_alias}/{$waterfall->waterfall_alias}/", date('Y-m-d', strtotime('last Monday')), self::$WATERFALL_PAGE_CHANGEFREQ, self::$WATERFALL_PAGE_RANK); |
|
99 | - } |
|
100 | - } |
|
101 | - |
|
102 | - private function add_map_pages() |
|
103 | - { |
|
104 | - $this->addURL('map/', date('Y-m-01'), self::$MAP_PAGE_CHANGEFREQ, self::$MAP_PAGE_RANK); |
|
105 | - } |
|
106 | - |
|
107 | - private function add_log_pages() |
|
108 | - { |
|
109 | - $this->addURL('journal/', date('Y-m-d', strtotime('last Monday')), self::$LOG_LISTING_CHANGEFREQ, self::$LOG_LISTING_RANK); |
|
110 | - $count = LogCollector::getListCount(); |
|
111 | - $this->add_paginated_pages($count, self::$LOGS_PER_LISTING, 'journal', 'log'); |
|
112 | - |
|
113 | - $companion_list = CompanionCollector::getCompanionList(); |
|
114 | - foreach ($companion_list as $companion) { |
|
115 | - $this->addURL("companion/{$companion->alias}/", date('Y-m-01'), self::$LOG_COMPANION_LISTING_CHANGEFREQ, self::$LOG_COMPANION_LISTING_RANK); |
|
116 | - $this->add_paginated_pages($companion->count, self::$LOGS_PER_COMPANION_LISTING, "companion/{$companion->alias}", 'log'); |
|
117 | - } |
|
118 | - |
|
119 | - $period_list = PeriodCollector::getPeriodList(); |
|
120 | - foreach ($period_list as $period) { |
|
121 | - $this->addURL("period/{$period->alias}/", date('Y-m-01'), self::$LOG_PERIOD_LISTING_CHANGEFREQ, self::$LOG_PERIOD_LISTING_RANK); |
|
122 | - $this->add_paginated_pages($period->count, self::$LOGS_PER_PERIOD_LISTING, "period/{$period->alias}", 'log'); |
|
123 | - } |
|
124 | - |
|
125 | - $log_list = LogCollector::getList(500); |
|
126 | - foreach ($log_list as $log) { |
|
127 | - $this->addURL("journal/{$log->alias}/", date('Y-m-d', strtotime('last Monday')), self::$LOG_PAGE_CHANGEFREQ, self::$LOG_PAGE_RANK); |
|
128 | - } |
|
129 | - } |
|
130 | - |
|
131 | - private function add_about_pages() |
|
132 | - { |
|
133 | - $this->addURL('about/', date('Y-01-01'), self::$ABOUT_PAGE_CHANGEFREQ, self::$ABOUT_PAGE_RANK); |
|
134 | - } |
|
135 | - |
|
136 | - private function add_paginated_pages($count, $items_per_page, $base_url, $type) |
|
137 | - { |
|
138 | - switch($type) { |
|
139 | - case 'waterfall': |
|
140 | - $lastmod = date('Y-m-01'); |
|
141 | - $changefreq = self::$WATERFALL_LISTING_SUBPAGES_CHANGEFREQ; |
|
142 | - $rank = self::$WATERFALL_LISTING_SUBPAGES_RANK; |
|
143 | - break; |
|
144 | - case 'log': |
|
145 | - $lastmod = date('Y-m-01'); |
|
146 | - $changefreq = self::$LOG_LISTING_SUBPAGES_CHANGEFREQ; |
|
147 | - $rank = self::$LOG_LISTING_SUBPAGES_RANK; |
|
148 | - break; |
|
149 | - } |
|
150 | - |
|
151 | - for($i = 2; (($i - 1) * $items_per_page) < $count; $i++) { |
|
152 | - $this->addURL("{$base_url}/{$i}/", $lastmod, $changefreq, $rank); |
|
153 | - } |
|
154 | - } |
|
18 | + private static $HOME_PAGE_RANK = .9; |
|
19 | + |
|
20 | + private static $WATERFALL_LISTING_RANK = .3; |
|
21 | + private static $WATERFALL_COUNTY_LISTING_RANK = .6; |
|
22 | + private static $WATERFALL_WATERCOURSE_LISTING_RANK = .6; |
|
23 | + private static $WATERFALL_LISTING_SUBPAGES_RANK = .1; |
|
24 | + private static $WATERFALL_PAGE_RANK = .8; |
|
25 | + |
|
26 | + private static $MAP_PAGE_RANK = .6; |
|
27 | + |
|
28 | + private static $LOG_LISTING_RANK = .3; |
|
29 | + private static $LOG_COMPANION_LISTING_RANK = .3; |
|
30 | + private static $LOG_PERIOD_LISTING_RANK = .3; |
|
31 | + private static $LOG_LISTING_SUBPAGES_RANK = .1; |
|
32 | + private static $LOG_PAGE_RANK = .7; |
|
33 | + |
|
34 | + private static $ABOUT_PAGE_RANK = .6; |
|
35 | + |
|
36 | + |
|
37 | + private static $HOME_PAGE_CHANGEFREQ = 'daily'; |
|
38 | + |
|
39 | + private static $WATERFALL_LISTING_CHANGEFREQ = 'monthly'; |
|
40 | + private static $WATERFALL_COUNTY_LISTING_CHANGEFREQ = 'monthly'; |
|
41 | + private static $WATERFALL_WATERCOURSE_LISTING_CHANGEFREQ = 'monthly'; |
|
42 | + private static $WATERFALL_LISTING_SUBPAGES_CHANGEFREQ = 'monthly'; |
|
43 | + private static $WATERFALL_PAGE_CHANGEFREQ = 'weekly'; |
|
44 | + |
|
45 | + private static $MAP_PAGE_CHANGEFREQ = 'monthly'; |
|
46 | + |
|
47 | + private static $LOG_LISTING_CHANGEFREQ = 'weekly'; |
|
48 | + private static $LOG_COMPANION_LISTING_CHANGEFREQ = 'monthly'; |
|
49 | + private static $LOG_PERIOD_LISTING_CHANGEFREQ = 'monthly'; |
|
50 | + private static $LOG_LISTING_SUBPAGES_CHANGEFREQ = 'monthly'; |
|
51 | + private static $LOG_PAGE_CHANGEFREQ = 'weekly'; |
|
52 | + |
|
53 | + private static $ABOUT_PAGE_CHANGEFREQ = 'yearly'; |
|
54 | + |
|
55 | + |
|
56 | + private static $WATERFALLS_PER_LISTING = 24; |
|
57 | + private static $WATERFALLS_PER_COUNTY_LISTING = 12; |
|
58 | + private static $WATERFALLS_PER_WATERCOURSE_LISTING = 12; |
|
59 | + |
|
60 | + private static $LOGS_PER_LISTING = 10; |
|
61 | + private static $LOGS_PER_COMPANION_LISTING = 10; |
|
62 | + private static $LOGS_PER_PERIOD_LISTING = 10; |
|
63 | + |
|
64 | + protected function set_data() |
|
65 | + { |
|
66 | + $this->add_home_pages(); |
|
67 | + $this->add_waterfall_pages(); |
|
68 | + $this->add_map_pages(); |
|
69 | + $this->add_log_pages(); |
|
70 | + $this->add_about_pages(); |
|
71 | + } |
|
72 | + |
|
73 | + private function add_home_pages() |
|
74 | + { |
|
75 | + $this->addURL('', date('Y-m-d'), self::$HOME_PAGE_CHANGEFREQ, self::$HOME_PAGE_RANK); |
|
76 | + } |
|
77 | + |
|
78 | + private function add_waterfall_pages() |
|
79 | + { |
|
80 | + $this->addURL('falls/', date('Y-m-01'), self::$WATERFALL_LISTING_CHANGEFREQ, self::$WATERFALL_LISTING_RANK); |
|
81 | + $count = WaterfallCollector::getListCount(); |
|
82 | + $this->add_paginated_pages($count, self::$WATERFALLS_PER_LISTING, 'falls', 'waterfall'); |
|
83 | + |
|
84 | + $county_list = CountyCollector::getCountyList(); |
|
85 | + foreach ($county_list as $county) { |
|
86 | + $this->addURL("{$county->alias}/", date('Y-m-01'), self::$WATERFALL_COUNTY_LISTING_CHANGEFREQ, self::$WATERFALL_COUNTY_LISTING_RANK); |
|
87 | + $this->add_paginated_pages($county->count, self::$WATERFALLS_PER_COUNTY_LISTING, $county->alias, 'waterfall'); |
|
88 | + } |
|
89 | + |
|
90 | + $watercourse_list = WatercourseCollector::getWatercourseList(); |
|
91 | + foreach ($watercourse_list as $watercourse) { |
|
92 | + $this->addURL("{$watercourse->alias}/", date('Y-m-01'), self::$WATERFALL_WATERCOURSE_LISTING_CHANGEFREQ, self::$WATERFALL_WATERCOURSE_LISTING_RANK); |
|
93 | + $this->add_paginated_pages($watercourse->count, self::$WATERFALLS_PER_WATERCOURSE_LISTING, $watercourse->alias, 'waterfall'); |
|
94 | + } |
|
95 | + |
|
96 | + $waterfall_list = WaterfallCollector::getList(500); |
|
97 | + foreach ($waterfall_list as $waterfall) { |
|
98 | + $this->addURL("{$waterfall->watercourse_alias}/{$waterfall->waterfall_alias}/", date('Y-m-d', strtotime('last Monday')), self::$WATERFALL_PAGE_CHANGEFREQ, self::$WATERFALL_PAGE_RANK); |
|
99 | + } |
|
100 | + } |
|
101 | + |
|
102 | + private function add_map_pages() |
|
103 | + { |
|
104 | + $this->addURL('map/', date('Y-m-01'), self::$MAP_PAGE_CHANGEFREQ, self::$MAP_PAGE_RANK); |
|
105 | + } |
|
106 | + |
|
107 | + private function add_log_pages() |
|
108 | + { |
|
109 | + $this->addURL('journal/', date('Y-m-d', strtotime('last Monday')), self::$LOG_LISTING_CHANGEFREQ, self::$LOG_LISTING_RANK); |
|
110 | + $count = LogCollector::getListCount(); |
|
111 | + $this->add_paginated_pages($count, self::$LOGS_PER_LISTING, 'journal', 'log'); |
|
112 | + |
|
113 | + $companion_list = CompanionCollector::getCompanionList(); |
|
114 | + foreach ($companion_list as $companion) { |
|
115 | + $this->addURL("companion/{$companion->alias}/", date('Y-m-01'), self::$LOG_COMPANION_LISTING_CHANGEFREQ, self::$LOG_COMPANION_LISTING_RANK); |
|
116 | + $this->add_paginated_pages($companion->count, self::$LOGS_PER_COMPANION_LISTING, "companion/{$companion->alias}", 'log'); |
|
117 | + } |
|
118 | + |
|
119 | + $period_list = PeriodCollector::getPeriodList(); |
|
120 | + foreach ($period_list as $period) { |
|
121 | + $this->addURL("period/{$period->alias}/", date('Y-m-01'), self::$LOG_PERIOD_LISTING_CHANGEFREQ, self::$LOG_PERIOD_LISTING_RANK); |
|
122 | + $this->add_paginated_pages($period->count, self::$LOGS_PER_PERIOD_LISTING, "period/{$period->alias}", 'log'); |
|
123 | + } |
|
124 | + |
|
125 | + $log_list = LogCollector::getList(500); |
|
126 | + foreach ($log_list as $log) { |
|
127 | + $this->addURL("journal/{$log->alias}/", date('Y-m-d', strtotime('last Monday')), self::$LOG_PAGE_CHANGEFREQ, self::$LOG_PAGE_RANK); |
|
128 | + } |
|
129 | + } |
|
130 | + |
|
131 | + private function add_about_pages() |
|
132 | + { |
|
133 | + $this->addURL('about/', date('Y-01-01'), self::$ABOUT_PAGE_CHANGEFREQ, self::$ABOUT_PAGE_RANK); |
|
134 | + } |
|
135 | + |
|
136 | + private function add_paginated_pages($count, $items_per_page, $base_url, $type) |
|
137 | + { |
|
138 | + switch($type) { |
|
139 | + case 'waterfall': |
|
140 | + $lastmod = date('Y-m-01'); |
|
141 | + $changefreq = self::$WATERFALL_LISTING_SUBPAGES_CHANGEFREQ; |
|
142 | + $rank = self::$WATERFALL_LISTING_SUBPAGES_RANK; |
|
143 | + break; |
|
144 | + case 'log': |
|
145 | + $lastmod = date('Y-m-01'); |
|
146 | + $changefreq = self::$LOG_LISTING_SUBPAGES_CHANGEFREQ; |
|
147 | + $rank = self::$LOG_LISTING_SUBPAGES_RANK; |
|
148 | + break; |
|
149 | + } |
|
150 | + |
|
151 | + for($i = 2; (($i - 1) * $items_per_page) < $count; $i++) { |
|
152 | + $this->addURL("{$base_url}/{$i}/", $lastmod, $changefreq, $rank); |
|
153 | + } |
|
154 | + } |
|
155 | 155 | |
156 | 156 | } |
157 | 157 |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | |
136 | 136 | private function add_paginated_pages($count, $items_per_page, $base_url, $type) |
137 | 137 | { |
138 | - switch($type) { |
|
138 | + switch ($type) { |
|
139 | 139 | case 'waterfall': |
140 | 140 | $lastmod = date('Y-m-01'); |
141 | 141 | $changefreq = self::$WATERFALL_LISTING_SUBPAGES_CHANGEFREQ; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | break; |
149 | 149 | } |
150 | 150 | |
151 | - for($i = 2; (($i - 1) * $items_per_page) < $count; $i++) { |
|
151 | + for ($i = 2; (($i - 1) * $items_per_page) < $count; $i++) { |
|
152 | 152 | $this->addURL("{$base_url}/{$i}/", $lastmod, $changefreq, $rank); |
153 | 153 | } |
154 | 154 | } |
@@ -24,6 +24,11 @@ |
||
24 | 24 | return Loader::getImagePath('photo', $path); |
25 | 25 | } |
26 | 26 | |
27 | + /** |
|
28 | + * @param string $string |
|
29 | + * @param boolean $is_absolute |
|
30 | + * @param string $size |
|
31 | + */ |
|
27 | 32 | private function get_thumb($string, $is_absolute, $size) |
28 | 33 | { |
29 | 34 | list($category, $file_name) = explode('/', $string); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | |
12 | 12 | protected function execute($is_absolute = false, $size = 'thumb') |
13 | 13 | { |
14 | - if(preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1) |
|
14 | + if (preg_match(self::$PHOTO_PLACEHOLDER_MATCH, $this->content, $match) === 1) |
|
15 | 15 | $this->content = $this->get_thumb($match[1], $is_absolute, $size); |
16 | 16 | else |
17 | 17 | $this->content = self::$DEFAULT_RETURN; |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | Loader::load('collector', 'image/PhotoCollector'); |
36 | 36 | $photo_result = PhotoCollector::fetchRow($category, $photo); |
37 | - if($photo_result == false) |
|
37 | + if ($photo_result == false) |
|
38 | 38 | return ''; |
39 | 39 | |
40 | 40 | $height = $file_size[1]; |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $description = $photo_result->description; |
43 | 43 | |
44 | 44 | $domain = '/'; |
45 | - if($is_absolute) |
|
45 | + if ($is_absolute) |
|
46 | 46 | $domain = Loader::getRootUrl(); |
47 | 47 | |
48 | 48 | return sprintf(self::$IMAGE_NODE, $domain, $category, $photo, $size, $extension, $height, $width, $description); |
@@ -11,10 +11,11 @@ discard block |
||
11 | 11 | |
12 | 12 | protected function execute($is_absolute = false, $size = 'thumb') |
13 | 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; |
|
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; |
|
18 | + } |
|
18 | 19 | return; |
19 | 20 | } |
20 | 21 | |
@@ -34,16 +35,18 @@ discard block |
||
34 | 35 | |
35 | 36 | Loader::load('collector', 'image/PhotoCollector'); |
36 | 37 | $photo_result = PhotoCollector::fetchRow($category, $photo); |
37 | - if($photo_result == false) |
|
38 | - return ''; |
|
38 | + if($photo_result == false) { |
|
39 | + return ''; |
|
40 | + } |
|
39 | 41 | |
40 | 42 | $height = $file_size[1]; |
41 | 43 | $width = $file_size[0]; |
42 | 44 | $description = $photo_result->description; |
43 | 45 | |
44 | 46 | $domain = '/'; |
45 | - if($is_absolute) |
|
46 | - $domain = Loader::getRootUrl(); |
|
47 | + if($is_absolute) { |
|
48 | + $domain = Loader::getRootUrl(); |
|
49 | + } |
|
47 | 50 | |
48 | 51 | return sprintf(self::$IMAGE_NODE, $domain, $category, $photo, $size, $extension, $height, $width, $description); |
49 | 52 | } |
@@ -25,6 +25,9 @@ discard block |
||
25 | 25 | return; |
26 | 26 | } |
27 | 27 | |
28 | + /** |
|
29 | + * @param string $content |
|
30 | + */ |
|
28 | 31 | private function wrap_in_list($content) |
29 | 32 | { |
30 | 33 | $content_array = explode("\n", $content); |
@@ -44,6 +47,9 @@ discard block |
||
44 | 47 | return $content; |
45 | 48 | } |
46 | 49 | |
50 | + /** |
|
51 | + * @param string $type |
|
52 | + */ |
|
47 | 53 | private function highlight_code($content, $type) |
48 | 54 | { |
49 | 55 | switch($type) |
@@ -10,10 +10,10 @@ discard block |
||
10 | 10 | protected function execute($title = '') |
11 | 11 | { |
12 | 12 | preg_match_all(self::$MARKUP_DELIMITER, $this->content, $matches); |
13 | - if(count($matches[1]) == 0) |
|
13 | + if (count($matches[1]) == 0) |
|
14 | 14 | return; |
15 | 15 | |
16 | - foreach($matches[3] as $key => $match) |
|
16 | + foreach ($matches[3] as $key => $match) |
|
17 | 17 | { |
18 | 18 | $replacement = $match; |
19 | 19 | $replacement = $this->wrap_in_list($replacement); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | { |
30 | 30 | $content_array = explode("\n", $content); |
31 | 31 | |
32 | - foreach($content_array as $key => $row) |
|
32 | + foreach ($content_array as $key => $row) |
|
33 | 33 | { |
34 | 34 | $new_row = ($key % 2 == 0) ? '<li class="even">' : '<li class="odd">'; |
35 | 35 | $new_row .= '<p>'; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | |
47 | 47 | private function highlight_code($content, $type) |
48 | 48 | { |
49 | - switch($type) |
|
49 | + switch ($type) |
|
50 | 50 | { |
51 | 51 | default : |
52 | 52 | return $content; |
@@ -10,8 +10,9 @@ |
||
10 | 10 | protected function execute($title = '') |
11 | 11 | { |
12 | 12 | preg_match_all(self::$MARKUP_DELIMITER, $this->content, $matches); |
13 | - if(count($matches[1]) == 0) |
|
14 | - return; |
|
13 | + if(count($matches[1]) == 0) { |
|
14 | + return; |
|
15 | + } |
|
15 | 16 | |
16 | 17 | foreach($matches[3] as $key => $match) |
17 | 18 | { |
@@ -62,6 +62,9 @@ |
||
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); |
@@ -42,8 +42,8 @@ |
||
42 | 42 | |
43 | 43 | if($length < strlen($this->content)) |
44 | 44 | $this->trim_string($length); |
45 | - else |
|
46 | - $etc = ''; |
|
45 | + else |
|
46 | + $etc = ''; |
|
47 | 47 | $this->check_exclude_tags(); |
48 | 48 | $this->close_tags($etc); |
49 | 49 | } |
@@ -27,20 +27,20 @@ discard block |
||
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 |
||
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 |
||
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 | 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 |
||
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 |
||
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 |
||
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 | } |
@@ -33,17 +33,19 @@ discard block |
||
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 | } |
@@ -54,8 +56,9 @@ discard block |
||
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; |
@@ -76,14 +79,16 @@ discard block |
||
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 | } |
@@ -118,9 +123,9 @@ discard block |
||
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,13 +133,14 @@ discard block |
||
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 | } |
@@ -14,9 +14,20 @@ discard block |
||
14 | 14 | $this->class_new = $class_name; |
15 | 15 | } |
16 | 16 | |
17 | + /** |
|
18 | + * @return string |
|
19 | + */ |
|
17 | 20 | abstract protected function getName(); |
18 | 21 | abstract protected function getDuration(); |
22 | + |
|
23 | + /** |
|
24 | + * @return string|null |
|
25 | + */ |
|
19 | 26 | abstract protected function getDomain(); |
27 | + |
|
28 | + /** |
|
29 | + * @return string|null |
|
30 | + */ |
|
20 | 31 | abstract protected function getPath(); |
21 | 32 | |
22 | 33 | public function setValue($value) |
@@ -28,6 +39,9 @@ discard block |
||
28 | 39 | return $this; |
29 | 40 | } |
30 | 41 | |
42 | + /** |
|
43 | + * @return string|null |
|
44 | + */ |
|
31 | 45 | public function getValue() |
32 | 46 | { |
33 | 47 | if(!$this->is_loaded) |
@@ -118,6 +132,9 @@ discard block |
||
118 | 132 | return $set_cookie; |
119 | 133 | } |
120 | 134 | |
135 | + /** |
|
136 | + * @param string $class_name |
|
137 | + */ |
|
121 | 138 | public static function instance($class_name) |
122 | 139 | { |
123 | 140 | return Loader::loadNew('utility', "cookie/{$class_name}Cookie", (array) $class_name); |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | |
22 | 22 | public function setValue($value) |
23 | 23 | { |
24 | - if(!$this->is_loaded) |
|
24 | + if (!$this->is_loaded) |
|
25 | 25 | $this->load(); |
26 | 26 | |
27 | 27 | $this->value = $value; |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | public function getValue() |
32 | 32 | { |
33 | - if(!$this->is_loaded) |
|
33 | + if (!$this->is_loaded) |
|
34 | 34 | $this->load(); |
35 | 35 | return $this->value; |
36 | 36 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | |
43 | 43 | public function exists() |
44 | 44 | { |
45 | - if(!$this->is_loaded) |
|
45 | + if (!$this->is_loaded) |
|
46 | 46 | $this->load(); |
47 | 47 | return $this->exists; |
48 | 48 | } |
@@ -50,10 +50,10 @@ discard block |
||
50 | 50 | private final function load() |
51 | 51 | { |
52 | 52 | $name = $this->getName(); |
53 | - if(isset($_COOKIE[$name])) |
|
53 | + if (isset($_COOKIE[$name])) |
|
54 | 54 | $value = $_COOKIE[$name]; |
55 | 55 | |
56 | - if(isset($value)) |
|
56 | + if (isset($value)) |
|
57 | 57 | { |
58 | 58 | $this->value = $value; |
59 | 59 | $this->exists = true; |
@@ -66,13 +66,13 @@ discard block |
||
66 | 66 | |
67 | 67 | public final function save() |
68 | 68 | { |
69 | - if(!$this->check_values()) |
|
69 | + if (!$this->check_values()) |
|
70 | 70 | { |
71 | 71 | Debugger::error('Attempt to create a cookie without all of the values being set!'); |
72 | 72 | return false; |
73 | 73 | } |
74 | 74 | |
75 | - if(!$this->set_cookie()) |
|
75 | + if (!$this->set_cookie()) |
|
76 | 76 | { |
77 | 77 | Debugger::log('There was a problem saving the cookie.'); |
78 | 78 | return false; |
@@ -84,23 +84,23 @@ discard block |
||
84 | 84 | private final function check_values() |
85 | 85 | { |
86 | 86 | $name = $this->getName(); |
87 | - if(empty($name) || strlen($name) < 1) |
|
87 | + if (empty($name) || strlen($name) < 1) |
|
88 | 88 | return false; |
89 | 89 | |
90 | 90 | $value = $this->getValue(); |
91 | - if(!isset($value) || strlen($value) < 1) |
|
91 | + if (!isset($value) || strlen($value) < 1) |
|
92 | 92 | return false; |
93 | 93 | |
94 | 94 | $expiration = $this->getExpiration(); |
95 | - if(!isset($expiration) || !is_int($expiration)) |
|
95 | + if (!isset($expiration) || !is_int($expiration)) |
|
96 | 96 | return false; |
97 | 97 | |
98 | 98 | $domain = $this->getDomain(); |
99 | - if(!isset($domain) || strlen($domain) < 1) |
|
99 | + if (!isset($domain) || strlen($domain) < 1) |
|
100 | 100 | return false; |
101 | 101 | |
102 | 102 | $path = $this->getPath(); |
103 | - if(!isset($path) || strlen($path) < 1) |
|
103 | + if (!isset($path) || strlen($path) < 1) |
|
104 | 104 | return false; |
105 | 105 | |
106 | 106 | return true; |
@@ -21,8 +21,9 @@ discard block |
||
21 | 21 | |
22 | 22 | public function setValue($value) |
23 | 23 | { |
24 | - if(!$this->is_loaded) |
|
25 | - $this->load(); |
|
24 | + if(!$this->is_loaded) { |
|
25 | + $this->load(); |
|
26 | + } |
|
26 | 27 | |
27 | 28 | $this->value = $value; |
28 | 29 | return $this; |
@@ -30,8 +31,9 @@ discard block |
||
30 | 31 | |
31 | 32 | public function getValue() |
32 | 33 | { |
33 | - if(!$this->is_loaded) |
|
34 | - $this->load(); |
|
34 | + if(!$this->is_loaded) { |
|
35 | + $this->load(); |
|
36 | + } |
|
35 | 37 | return $this->value; |
36 | 38 | } |
37 | 39 | |
@@ -42,24 +44,26 @@ discard block |
||
42 | 44 | |
43 | 45 | public function exists() |
44 | 46 | { |
45 | - if(!$this->is_loaded) |
|
46 | - $this->load(); |
|
47 | + if(!$this->is_loaded) { |
|
48 | + $this->load(); |
|
49 | + } |
|
47 | 50 | return $this->exists; |
48 | 51 | } |
49 | 52 | |
50 | 53 | private final function load() |
51 | 54 | { |
52 | 55 | $name = $this->getName(); |
53 | - if(isset($_COOKIE[$name])) |
|
54 | - $value = $_COOKIE[$name]; |
|
56 | + if(isset($_COOKIE[$name])) { |
|
57 | + $value = $_COOKIE[$name]; |
|
58 | + } |
|
55 | 59 | |
56 | 60 | if(isset($value)) |
57 | 61 | { |
58 | 62 | $this->value = $value; |
59 | 63 | $this->exists = true; |
60 | - } |
|
61 | - else |
|
62 | - $this->exists = false; |
|
64 | + } else { |
|
65 | + $this->exists = false; |
|
66 | + } |
|
63 | 67 | |
64 | 68 | $this->is_loaded = true; |
65 | 69 | } |
@@ -84,24 +88,29 @@ discard block |
||
84 | 88 | private final function check_values() |
85 | 89 | { |
86 | 90 | $name = $this->getName(); |
87 | - if(empty($name) || strlen($name) < 1) |
|
88 | - return false; |
|
91 | + if(empty($name) || strlen($name) < 1) { |
|
92 | + return false; |
|
93 | + } |
|
89 | 94 | |
90 | 95 | $value = $this->getValue(); |
91 | - if(!isset($value) || strlen($value) < 1) |
|
92 | - return false; |
|
96 | + if(!isset($value) || strlen($value) < 1) { |
|
97 | + return false; |
|
98 | + } |
|
93 | 99 | |
94 | 100 | $expiration = $this->getExpiration(); |
95 | - if(!isset($expiration) || !is_int($expiration)) |
|
96 | - return false; |
|
101 | + if(!isset($expiration) || !is_int($expiration)) { |
|
102 | + return false; |
|
103 | + } |
|
97 | 104 | |
98 | 105 | $domain = $this->getDomain(); |
99 | - if(!isset($domain) || strlen($domain) < 1) |
|
100 | - return false; |
|
106 | + if(!isset($domain) || strlen($domain) < 1) { |
|
107 | + return false; |
|
108 | + } |
|
101 | 109 | |
102 | 110 | $path = $this->getPath(); |
103 | - if(!isset($path) || strlen($path) < 1) |
|
104 | - return false; |
|
111 | + if(!isset($path) || strlen($path) < 1) { |
|
112 | + return false; |
|
113 | + } |
|
105 | 114 | |
106 | 115 | return true; |
107 | 116 | } |
@@ -7,6 +7,9 @@ |
||
7 | 7 | |
8 | 8 | abstract public function activate(); |
9 | 9 | |
10 | + /** |
|
11 | + * @param string $value |
|
12 | + */ |
|
10 | 13 | protected function error($value) |
11 | 14 | { |
12 | 15 | trigger_error("Cron failed: {$value}"); |
@@ -59,6 +59,9 @@ discard block |
||
59 | 59 | $this->add_posts($youtube_result, 'youtube'); |
60 | 60 | } |
61 | 61 | |
62 | + /** |
|
63 | + * @param string $type |
|
64 | + */ |
|
62 | 65 | private function remove_existing($result, $type) |
63 | 66 | { |
64 | 67 | foreach($result as $key => $row) |
@@ -70,6 +73,9 @@ discard block |
||
70 | 73 | return $result; |
71 | 74 | } |
72 | 75 | |
76 | + /** |
|
77 | + * @param string $type |
|
78 | + */ |
|
73 | 79 | private function add_posts($result, $type) |
74 | 80 | { |
75 | 81 | foreach($result as $row) |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | |
62 | 62 | private function remove_existing($result, $type) |
63 | 63 | { |
64 | - foreach($result as $key => $row) |
|
64 | + foreach ($result as $key => $row) |
|
65 | 65 | { |
66 | 66 | $stream_result = ActivityCollector::getPostByFields($row->id, $type); |
67 | - if($stream_result) |
|
67 | + if ($stream_result) |
|
68 | 68 | unset($result[$key]); |
69 | 69 | } |
70 | 70 | return $result; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | |
73 | 73 | private function add_posts($result, $type) |
74 | 74 | { |
75 | - foreach($result as $row) |
|
75 | + foreach ($result as $row) |
|
76 | 76 | { |
77 | 77 | $query = sprintf(self::$QUERY, $type, $row->id, $row->date); |
78 | 78 | Database::execute($query); |
@@ -64,8 +64,9 @@ |
||
64 | 64 | foreach($result as $key => $row) |
65 | 65 | { |
66 | 66 | $stream_result = ActivityCollector::getPostByFields($row->id, $type); |
67 | - if($stream_result) |
|
68 | - unset($result[$key]); |
|
67 | + if($stream_result) { |
|
68 | + unset($result[$key]); |
|
69 | + } |
|
69 | 70 | } |
70 | 71 | return $result; |
71 | 72 | } |
@@ -239,6 +239,9 @@ |
||
239 | 239 | return $text; |
240 | 240 | } |
241 | 241 | |
242 | + /** |
|
243 | + * @param string $type |
|
244 | + */ |
|
242 | 245 | private function get_replace_text($entity_type, $entity, $type) |
243 | 246 | { |
244 | 247 | switch($entity_type) |
@@ -20,21 +20,21 @@ |
||
20 | 20 | private static $USER_MENTION_LINK = '<a href="https://twitter.com/%1$s" rel="nofollow" target="_blank" title="%2$s (%1$s) on Twitter">@%1$s</a>'; |
21 | 21 | private static $MEDIA_LINK = '<a class="photo" href="%s" rel="nofollow" target="_blank" title="%s"><img src="%s:%s" alt="%s" height="%s" width="%s" /></a>'; |
22 | 22 | |
23 | - private $consumer_key; |
|
24 | - private $consumer_secret; |
|
25 | - private $access_token; |
|
26 | - private $access_secret; |
|
23 | + private $consumer_key; |
|
24 | + private $consumer_secret; |
|
25 | + private $access_token; |
|
26 | + private $access_secret; |
|
27 | 27 | |
28 | 28 | private $json; |
29 | 29 | |
30 | 30 | public function __construct() |
31 | 31 | { |
32 | - global $config; |
|
32 | + global $config; |
|
33 | 33 | |
34 | - $this->consumer_key = $config->twitter->consumer_key; |
|
35 | - $this->consumer_secret = $config->twitter->consumer_secret; |
|
36 | - $this->access_token = $config->twitter->access_token; |
|
37 | - $this->access_secret = $config->twitter->access_secret; |
|
34 | + $this->consumer_key = $config->twitter->consumer_key; |
|
35 | + $this->consumer_secret = $config->twitter->consumer_secret; |
|
36 | + $this->access_token = $config->twitter->access_token; |
|
37 | + $this->access_secret = $config->twitter->access_secret; |
|
38 | 38 | |
39 | 39 | $json = $this->get_data(); |
40 | 40 |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | private $oauth_array; |
84 | 84 | private function get_oauth_array() |
85 | 85 | { |
86 | - if(!isset($this->oauth_array)) |
|
86 | + if (!isset($this->oauth_array)) |
|
87 | 87 | { |
88 | 88 | $this->oauth_array = array( |
89 | 89 | 'screen_name' => self::$SCREEN_NAME, |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | { |
117 | 117 | $encoded_array = array(); |
118 | 118 | ksort($array); |
119 | - foreach($array as $key => $value) |
|
119 | + foreach ($array as $key => $value) |
|
120 | 120 | { |
121 | 121 | $value = rawurlencode($value); |
122 | 122 | $value = ($wrap_values) ? '"' . $value . '"' : $value; |
@@ -127,27 +127,27 @@ discard block |
||
127 | 127 | |
128 | 128 | public function activate() |
129 | 129 | { |
130 | - if(!$this->json) |
|
130 | + if (!$this->json) |
|
131 | 131 | return $this->error('Could not connect to twitter json feed.'); |
132 | 132 | |
133 | 133 | $count = 0; |
134 | - foreach($this->json as $status) |
|
134 | + foreach ($this->json as $status) |
|
135 | 135 | { |
136 | 136 | $text = Database::escape($status->text); |
137 | 137 | $date = date('Y-m-d H:i:s', strtotime($status->created_at)); |
138 | 138 | |
139 | 139 | $tweet_result = TwitterCollector::getTweetByFields($date, $text); |
140 | - if($tweet_result !== null) |
|
140 | + if ($tweet_result !== null) |
|
141 | 141 | { |
142 | 142 | $favorites = (int) $status->favorite_count; |
143 | - if($favorites != 0 && $tweet_result->favorites != $favorites) |
|
143 | + if ($favorites != 0 && $tweet_result->favorites != $favorites) |
|
144 | 144 | { |
145 | 145 | $query = sprintf(self::$UPDATE_FAVORITES_QUERY, $favorites, $tweet_result->id); |
146 | 146 | Database::execute($query); |
147 | 147 | } |
148 | 148 | |
149 | 149 | $retweets = (int) $status->retweet_count; |
150 | - if($retweets != 0 && $tweet_result->retweets != $retweets) |
|
150 | + if ($retweets != 0 && $tweet_result->retweets != $retweets) |
|
151 | 151 | { |
152 | 152 | $query = sprintf(self::$UPDATE_RETWEETS_QUERY, $retweets, $tweet_result->id); |
153 | 153 | Database::execute($query); |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | { |
158 | 158 | $twitter_id = (string) $status->id_str; |
159 | 159 | |
160 | - if(isset($status->retweeted_status)) |
|
160 | + if (isset($status->retweeted_status)) |
|
161 | 161 | { |
162 | 162 | $text_formatted = $this->get_formatted($status->retweeted_status->text, $status->retweeted_status->entities); |
163 | 163 | $text_formatted_full = $this->get_formatted($status->retweeted_status->text, $status->retweeted_status->entities, 'full'); |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | |
201 | 201 | private function get_source($source) |
202 | 202 | { |
203 | - if(stristr($source, 'tweetdeck')) |
|
203 | + if (stristr($source, 'tweetdeck')) |
|
204 | 204 | return 'tweetdeck'; |
205 | - if(stristr($source, 'windows phone')) |
|
205 | + if (stristr($source, 'windows phone')) |
|
206 | 206 | return 'phone'; |
207 | 207 | else |
208 | 208 | return ''; |
@@ -211,9 +211,9 @@ discard block |
||
211 | 211 | private function get_formatted($text, $entities, $type = 'short') |
212 | 212 | { |
213 | 213 | $holder = array(); |
214 | - foreach($entities as $entity_type => $entity_collection) |
|
214 | + foreach ($entities as $entity_type => $entity_collection) |
|
215 | 215 | { |
216 | - foreach($entity_collection as $entity) |
|
216 | + foreach ($entity_collection as $entity) |
|
217 | 217 | { |
218 | 218 | $start = $entity->indices[0]; |
219 | 219 | $end = $entity->indices[1]; |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | |
229 | 229 | krsort($holder); |
230 | 230 | |
231 | - foreach($holder as $entity) |
|
231 | + foreach ($holder as $entity) |
|
232 | 232 | { |
233 | 233 | $text = mb_substr($text, 0, $entity->start, 'UTF-8') . $entity->replace . mb_substr($text, $entity->end, 5000, 'UTF-8'); |
234 | 234 | } |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | |
242 | 242 | private function get_replace_text($entity_type, $entity, $type) |
243 | 243 | { |
244 | - switch($entity_type) |
|
244 | + switch ($entity_type) |
|
245 | 245 | { |
246 | 246 | case 'hashtags' : |
247 | 247 | $replace = sprintf(self::$HASHTAG_LINK, $entity->text); |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | $replace = sprintf(self::$USER_MENTION_LINK, $entity->screen_name, $entity->name); |
254 | 254 | break; |
255 | 255 | case 'media' : |
256 | - if($type == 'full') |
|
256 | + if ($type == 'full') |
|
257 | 257 | $replace = sprintf(self::$MEDIA_LINK, $entity->url, $entity->display_url, $entity->media_url, 'large', 'Photo from Twitter', $entity->sizes->large->h, $entity->sizes->large->w); |
258 | 258 | else |
259 | 259 | $replace = sprintf(self::$URL_LINK, $entity->url, $entity->expanded_url, $entity->display_url); |
@@ -127,8 +127,9 @@ discard block |
||
127 | 127 | |
128 | 128 | public function activate() |
129 | 129 | { |
130 | - if(!$this->json) |
|
131 | - return $this->error('Could not connect to twitter json feed.'); |
|
130 | + if(!$this->json) { |
|
131 | + return $this->error('Could not connect to twitter json feed.'); |
|
132 | + } |
|
132 | 133 | |
133 | 134 | $count = 0; |
134 | 135 | foreach($this->json as $status) |
@@ -152,8 +153,7 @@ discard block |
||
152 | 153 | $query = sprintf(self::$UPDATE_RETWEETS_QUERY, $retweets, $tweet_result->id); |
153 | 154 | Database::execute($query); |
154 | 155 | } |
155 | - } |
|
156 | - else |
|
156 | + } else |
|
157 | 157 | { |
158 | 158 | $twitter_id = (string) $status->id_str; |
159 | 159 | |
@@ -164,8 +164,7 @@ discard block |
||
164 | 164 | |
165 | 165 | $text_formatted = $this->prepend_original_user($status->retweeted_status->user, $text_formatted); |
166 | 166 | $text_formatted_full = $this->prepend_original_user($status->retweeted_status->user, $text_formatted_full); |
167 | - } |
|
168 | - else |
|
167 | + } else |
|
169 | 168 | { |
170 | 169 | $text_formatted = $this->get_formatted($status->text, $status->entities); |
171 | 170 | $text_formatted_full = $this->get_formatted($status->text, $status->entities, 'full'); |
@@ -200,12 +199,14 @@ discard block |
||
200 | 199 | |
201 | 200 | private function get_source($source) |
202 | 201 | { |
203 | - if(stristr($source, 'tweetdeck')) |
|
204 | - return 'tweetdeck'; |
|
205 | - if(stristr($source, 'windows phone')) |
|
206 | - return 'phone'; |
|
207 | - else |
|
208 | - return ''; |
|
202 | + if(stristr($source, 'tweetdeck')) { |
|
203 | + return 'tweetdeck'; |
|
204 | + } |
|
205 | + if(stristr($source, 'windows phone')) { |
|
206 | + return 'phone'; |
|
207 | + } else { |
|
208 | + return ''; |
|
209 | + } |
|
209 | 210 | } |
210 | 211 | |
211 | 212 | private function get_formatted($text, $entities, $type = 'short') |
@@ -253,10 +254,11 @@ discard block |
||
253 | 254 | $replace = sprintf(self::$USER_MENTION_LINK, $entity->screen_name, $entity->name); |
254 | 255 | break; |
255 | 256 | case 'media' : |
256 | - if($type == 'full') |
|
257 | - $replace = sprintf(self::$MEDIA_LINK, $entity->url, $entity->display_url, $entity->media_url, 'large', 'Photo from Twitter', $entity->sizes->large->h, $entity->sizes->large->w); |
|
258 | - else |
|
259 | - $replace = sprintf(self::$URL_LINK, $entity->url, $entity->expanded_url, $entity->display_url); |
|
257 | + if($type == 'full') { |
|
258 | + $replace = sprintf(self::$MEDIA_LINK, $entity->url, $entity->display_url, $entity->media_url, 'large', 'Photo from Twitter', $entity->sizes->large->h, $entity->sizes->large->w); |
|
259 | + } else { |
|
260 | + $replace = sprintf(self::$URL_LINK, $entity->url, $entity->expanded_url, $entity->display_url); |
|
261 | + } |
|
260 | 262 | break; |
261 | 263 | default : |
262 | 264 | $replace = ''; |
@@ -28,6 +28,9 @@ |
||
28 | 28 | return self::$instance; |
29 | 29 | } |
30 | 30 | |
31 | + /** |
|
32 | + * @param string $message |
|
33 | + */ |
|
31 | 34 | public static function log($message) |
32 | 35 | { |
33 | 36 | self::instance()->console->logError('Gah, this is using Debugger::log()!'); |
@@ -18,8 +18,8 @@ discard block |
||
18 | 18 | private function __construct() |
19 | 19 | { |
20 | 20 | $this->console = new Console(); |
21 | - $this->profiler = new PhpQuickProfiler(); |
|
22 | - $this->profiler->setConsole($this->console); |
|
21 | + $this->profiler = new PhpQuickProfiler(); |
|
22 | + $this->profiler->setConsole($this->console); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public static function instance() |
@@ -82,29 +82,29 @@ discard block |
||
82 | 82 | |
83 | 83 | public static function display() |
84 | 84 | { |
85 | - if ($_COOKIE['debugger'] == 'display' && self::instance()->display) { |
|
86 | - $pdo = ''; |
|
87 | - global $container; |
|
88 | - if (!empty($container) && !empty($container['db_connection_locator'])) { |
|
89 | - $pdo = $container['db_connection_locator']->getRead(); |
|
90 | - } |
|
91 | - if (!empty($pdo)) { |
|
92 | - $profiles = $pdo->getProfiler()->getProfiles(); |
|
93 | - $profiles = array_filter($profiles, function ($profile) { |
|
94 | - return $profile['function'] == 'perform'; |
|
95 | - }); |
|
96 | - $profiles = array_map(function ($profile) { |
|
97 | - return array( |
|
98 | - 'sql' => trim(preg_replace('/\s+/', ' ', $profile['statement'])), |
|
99 | - 'parameters' => $profile['bind_values'], |
|
100 | - 'time' => $profile['duration'] |
|
101 | - ); |
|
102 | - }, $profiles); |
|
103 | - self::instance()->profiler->setProfiledQueries($profiles); |
|
104 | - } |
|
105 | - self::instance()->profiler->setDisplay(new Particletree\Pqp\Display()); |
|
106 | - self::instance()->profiler->display($pdo); |
|
107 | - } |
|
85 | + if ($_COOKIE['debugger'] == 'display' && self::instance()->display) { |
|
86 | + $pdo = ''; |
|
87 | + global $container; |
|
88 | + if (!empty($container) && !empty($container['db_connection_locator'])) { |
|
89 | + $pdo = $container['db_connection_locator']->getRead(); |
|
90 | + } |
|
91 | + if (!empty($pdo)) { |
|
92 | + $profiles = $pdo->getProfiler()->getProfiles(); |
|
93 | + $profiles = array_filter($profiles, function ($profile) { |
|
94 | + return $profile['function'] == 'perform'; |
|
95 | + }); |
|
96 | + $profiles = array_map(function ($profile) { |
|
97 | + return array( |
|
98 | + 'sql' => trim(preg_replace('/\s+/', ' ', $profile['statement'])), |
|
99 | + 'parameters' => $profile['bind_values'], |
|
100 | + 'time' => $profile['duration'] |
|
101 | + ); |
|
102 | + }, $profiles); |
|
103 | + self::instance()->profiler->setProfiledQueries($profiles); |
|
104 | + } |
|
105 | + self::instance()->profiler->setDisplay(new Particletree\Pqp\Display()); |
|
106 | + self::instance()->profiler->display($pdo); |
|
107 | + } |
|
108 | 108 | } |
109 | 109 | |
110 | 110 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | |
9 | 9 | private static $UNKNOWN_ERROR_FILE = 'Unknown File'; |
10 | 10 | private static $UNKNOWN_ERROR_LINE = 'Unknown Line'; |
11 | - private static $UNKNOWN_ERROR_CONTEXT = 'Unknown Context'; |
|
11 | + private static $UNKNOWN_ERROR_CONTEXT = 'Unknown Context'; |
|
12 | 12 | |
13 | 13 | private $profiler; |
14 | 14 | private $display = true; |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | |
25 | 25 | public static function instance() |
26 | 26 | { |
27 | - if(!isset(self::$instance)) |
|
27 | + if (!isset(self::$instance)) |
|
28 | 28 | self::$instance = new Debugger(); |
29 | 29 | return self::$instance; |
30 | 30 | } |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | |
53 | 53 | public static function internal_error($code, $string, $file = null, $line = null, $context = null) |
54 | 54 | { |
55 | - if($file == null) |
|
55 | + if ($file == null) |
|
56 | 56 | $file = self::$UNKNOWN_ERROR_FILE; |
57 | - if($line == null) |
|
57 | + if ($line == null) |
|
58 | 58 | $line = self::$UNKNOWN_ERROR_LINE; |
59 | - if($context == null) |
|
59 | + if ($context == null) |
|
60 | 60 | $context = self::$UNKNOWN_ERROR_CONTEXT; |
61 | 61 | |
62 | 62 | self::instance()->console->logError(new Exception($string), "{$string}... TYPE: {$code}"); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | { |
69 | 69 | $error = error_get_last(); |
70 | 70 | |
71 | - if(isset($error)) |
|
71 | + if (isset($error)) |
|
72 | 72 | self::internal_error($error['type'], $error['message'], $error['file'], $error['line']); |
73 | 73 | |
74 | 74 | self::display(); |
@@ -90,10 +90,10 @@ discard block |
||
90 | 90 | } |
91 | 91 | if (!empty($pdo)) { |
92 | 92 | $profiles = $pdo->getProfiler()->getProfiles(); |
93 | - $profiles = array_filter($profiles, function ($profile) { |
|
93 | + $profiles = array_filter($profiles, function($profile) { |
|
94 | 94 | return $profile['function'] == 'perform'; |
95 | 95 | }); |
96 | - $profiles = array_map(function ($profile) { |
|
96 | + $profiles = array_map(function($profile) { |
|
97 | 97 | return array( |
98 | 98 | 'sql' => trim(preg_replace('/\s+/', ' ', $profile['statement'])), |
99 | 99 | 'parameters' => $profile['bind_values'], |
@@ -24,8 +24,9 @@ discard block |
||
24 | 24 | |
25 | 25 | public static function instance() |
26 | 26 | { |
27 | - if(!isset(self::$instance)) |
|
28 | - self::$instance = new Debugger(); |
|
27 | + if(!isset(self::$instance)) { |
|
28 | + self::$instance = new Debugger(); |
|
29 | + } |
|
29 | 30 | return self::$instance; |
30 | 31 | } |
31 | 32 | |
@@ -52,12 +53,15 @@ discard block |
||
52 | 53 | |
53 | 54 | public static function internal_error($code, $string, $file = null, $line = null, $context = null) |
54 | 55 | { |
55 | - if($file == null) |
|
56 | - $file = self::$UNKNOWN_ERROR_FILE; |
|
57 | - if($line == null) |
|
58 | - $line = self::$UNKNOWN_ERROR_LINE; |
|
59 | - if($context == null) |
|
60 | - $context = self::$UNKNOWN_ERROR_CONTEXT; |
|
56 | + if($file == null) { |
|
57 | + $file = self::$UNKNOWN_ERROR_FILE; |
|
58 | + } |
|
59 | + if($line == null) { |
|
60 | + $line = self::$UNKNOWN_ERROR_LINE; |
|
61 | + } |
|
62 | + if($context == null) { |
|
63 | + $context = self::$UNKNOWN_ERROR_CONTEXT; |
|
64 | + } |
|
61 | 65 | |
62 | 66 | self::instance()->console->logError(new Exception($string), "{$string}... TYPE: {$code}"); |
63 | 67 | |
@@ -68,8 +72,9 @@ discard block |
||
68 | 72 | { |
69 | 73 | $error = error_get_last(); |
70 | 74 | |
71 | - if(isset($error)) |
|
72 | - self::internal_error($error['type'], $error['message'], $error['file'], $error['line']); |
|
75 | + if(isset($error)) { |
|
76 | + self::internal_error($error['type'], $error['message'], $error['file'], $error['line']); |
|
77 | + } |
|
73 | 78 | |
74 | 79 | self::display(); |
75 | 80 | return true; |