@@ -110,7 +110,7 @@ |
||
110 | 110 | /** |
111 | 111 | * RSS Module configurations |
112 | 112 | * |
113 | - * @return void |
|
113 | + * @return Object|null |
|
114 | 114 | */ |
115 | 115 | function procRssAdminInsertModuleConfig() |
116 | 116 | { |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /* Copyright (C) NAVER <http://www.navercorp.com> */ |
3 | 3 | /** |
4 | - * The admin controller class of the rss module |
|
5 | - * |
|
6 | - * @author NAVER ([email protected]) |
|
7 | - */ |
|
4 | + * The admin controller class of the rss module |
|
5 | + * |
|
6 | + * @author NAVER ([email protected]) |
|
7 | + */ |
|
8 | 8 | class rssAdminController extends rss |
9 | 9 | { |
10 | 10 | /** |
@@ -27,41 +27,41 @@ discard block |
||
27 | 27 | $total_config = $oModuleModel->getModuleConfig('rss'); |
28 | 28 | |
29 | 29 | $config_vars = Context::getRequestVars(); |
30 | - $config_vars->feed_document_count = (int)$config_vars->feed_document_count; |
|
30 | + $config_vars->feed_document_count = (int) $config_vars->feed_document_count; |
|
31 | 31 | |
32 | - if(!$config_vars->use_total_feed) $alt_message = 'msg_invalid_request'; |
|
33 | - if(!in_array($config_vars->use_total_feed, array('Y','N'))) $config_vars->open_rss = 'Y'; |
|
32 | + if (!$config_vars->use_total_feed) $alt_message = 'msg_invalid_request'; |
|
33 | + if (!in_array($config_vars->use_total_feed, array('Y', 'N'))) $config_vars->open_rss = 'Y'; |
|
34 | 34 | |
35 | - if($config_vars->image || $config_vars->del_image) |
|
35 | + if ($config_vars->image || $config_vars->del_image) |
|
36 | 36 | { |
37 | 37 | $image_obj = $config_vars->image; |
38 | 38 | $config_vars->image = $total_config->image; |
39 | 39 | // Get a variable for the delete request |
40 | - if($config_vars->del_image == 'Y' || $image_obj) |
|
40 | + if ($config_vars->del_image == 'Y' || $image_obj) |
|
41 | 41 | { |
42 | 42 | FileHandler::removeFile($config_vars->image); |
43 | 43 | $config_vars->image = ''; |
44 | 44 | $total_config->image = ''; |
45 | 45 | } |
46 | 46 | // Ignore if the file is not the one which has been successfully uploaded |
47 | - if($image_obj['tmp_name'] && is_uploaded_file($image_obj['tmp_name']) && checkUploadedFile($image_obj['tmp_name'])) |
|
47 | + if ($image_obj['tmp_name'] && is_uploaded_file($image_obj['tmp_name']) && checkUploadedFile($image_obj['tmp_name'])) |
|
48 | 48 | { |
49 | 49 | // Ignore if the file is not an image (swf is accepted ~) |
50 | 50 | $image_obj['name'] = Context::convertEncodingStr($image_obj['name']); |
51 | 51 | |
52 | - if(!preg_match("/\.(jpg|jpeg|gif|png)$/i", $image_obj['name'])) $alt_message = 'msg_rss_invalid_image_format'; |
|
52 | + if (!preg_match("/\.(jpg|jpeg|gif|png)$/i", $image_obj['name'])) $alt_message = 'msg_rss_invalid_image_format'; |
|
53 | 53 | else |
54 | 54 | { |
55 | 55 | // Upload the file to a path |
56 | 56 | $path = './files/attach/images/rss/'; |
57 | 57 | // Create a directory |
58 | - if(!FileHandler::makeDir($path)) $alt_message = 'msg_error_occured'; |
|
58 | + if (!FileHandler::makeDir($path)) $alt_message = 'msg_error_occured'; |
|
59 | 59 | else |
60 | 60 | { |
61 | - $filename = $path.$image_obj['name']; |
|
61 | + $filename = $path . $image_obj['name']; |
|
62 | 62 | |
63 | 63 | // Move the file |
64 | - if(!move_uploaded_file($image_obj['tmp_name'], $filename)) $alt_message = 'msg_error_occured'; |
|
64 | + if (!move_uploaded_file($image_obj['tmp_name'], $filename)) $alt_message = 'msg_error_occured'; |
|
65 | 65 | else |
66 | 66 | { |
67 | 67 | $config_vars->image = $filename; |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | } |
71 | 71 | } |
72 | 72 | } |
73 | - if(!$config_vars->image && $config_vars->del_image != 'Y') $config_vars->image = $total_config->image; |
|
73 | + if (!$config_vars->image && $config_vars->del_image != 'Y') $config_vars->image = $total_config->image; |
|
74 | 74 | |
75 | 75 | $output = $this->setFeedConfig($config_vars); |
76 | 76 | |
77 | - if(!$alt_message) $alt_message = 'success_updated'; |
|
77 | + if (!$alt_message) $alt_message = 'success_updated'; |
|
78 | 78 | |
79 | 79 | $alt_message = Context::getLang($alt_message); |
80 | 80 | $this->setMessage($alt_message, 'info'); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $originConfig = $oModuleModel->getModuleConfig('rss'); |
97 | 97 | |
98 | 98 | // Get a variable for the delete request |
99 | - if($delImage == 'Y') |
|
99 | + if ($delImage == 'Y') |
|
100 | 100 | { |
101 | 101 | FileHandler::removeFile($originConfig->image); |
102 | 102 | |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | $feedCopyrightList = $config_vars->feed_copyright; |
123 | 123 | $targetModuleSrl = $config_vars->target_module_srl; |
124 | 124 | |
125 | - if($targetModuleSrl && !is_array($openRssList)) |
|
125 | + if ($targetModuleSrl && !is_array($openRssList)) |
|
126 | 126 | { |
127 | 127 | $openRssList = array($targetModuleSrl => $openRssList); |
128 | 128 | $openTotalFeedList = array($targetModuleSrl => $openTotalFeedList); |
@@ -130,16 +130,16 @@ discard block |
||
130 | 130 | $feedCopyrightList = array($targetModuleSrl => $feedCopyrightList); |
131 | 131 | } |
132 | 132 | |
133 | - if(is_array($openRssList)) |
|
133 | + if (is_array($openRssList)) |
|
134 | 134 | { |
135 | - foreach($openRssList AS $module_srl=>$open_rss) |
|
135 | + foreach ($openRssList AS $module_srl=>$open_rss) |
|
136 | 136 | { |
137 | - if(!$module_srl || !$open_rss) |
|
137 | + if (!$module_srl || !$open_rss) |
|
138 | 138 | { |
139 | 139 | return new Object(-1, 'msg_invalid_request'); |
140 | 140 | } |
141 | 141 | |
142 | - if(!in_array($open_rss, array('Y','H','N'))) $open_rss = 'N'; |
|
142 | + if (!in_array($open_rss, array('Y', 'H', 'N'))) $open_rss = 'N'; |
|
143 | 143 | |
144 | 144 | $this->setRssModuleConfig($module_srl, $open_rss, $openTotalFeedList[$module_srl], $feedDescriptionList[$module_srl], $feedCopyrightList[$module_srl]); |
145 | 145 | } |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | function setFeedConfig($config) |
162 | 162 | { |
163 | 163 | $oModuleController = getController('module'); |
164 | - $oModuleController->insertModuleConfig('rss',$config); |
|
164 | + $oModuleController->insertModuleConfig('rss', $config); |
|
165 | 165 | return new Object(); |
166 | 166 | } |
167 | 167 | |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | $config = new stdClass; |
182 | 182 | $config->open_rss = $open_rss; |
183 | 183 | $config->open_total_feed = $open_total_feed; |
184 | - if($feed_description != 'N') { $config->feed_description = $feed_description; } |
|
185 | - if($feed_copyright != 'N') { $config->feed_copyright = $feed_copyright; } |
|
186 | - $oModuleController->insertModulePartConfig('rss',$module_srl,$config); |
|
184 | + if ($feed_description != 'N') { $config->feed_description = $feed_description; } |
|
185 | + if ($feed_copyright != 'N') { $config->feed_copyright = $feed_copyright; } |
|
186 | + $oModuleController->insertModulePartConfig('rss', $module_srl, $config); |
|
187 | 187 | return new Object(); |
188 | 188 | } |
189 | 189 | } |
@@ -29,8 +29,12 @@ discard block |
||
29 | 29 | $config_vars = Context::getRequestVars(); |
30 | 30 | $config_vars->feed_document_count = (int)$config_vars->feed_document_count; |
31 | 31 | |
32 | - if(!$config_vars->use_total_feed) $alt_message = 'msg_invalid_request'; |
|
33 | - if(!in_array($config_vars->use_total_feed, array('Y','N'))) $config_vars->open_rss = 'Y'; |
|
32 | + if(!$config_vars->use_total_feed) { |
|
33 | + $alt_message = 'msg_invalid_request'; |
|
34 | + } |
|
35 | + if(!in_array($config_vars->use_total_feed, array('Y','N'))) { |
|
36 | + $config_vars->open_rss = 'Y'; |
|
37 | + } |
|
34 | 38 | |
35 | 39 | if($config_vars->image || $config_vars->del_image) |
36 | 40 | { |
@@ -49,20 +53,23 @@ discard block |
||
49 | 53 | // Ignore if the file is not an image (swf is accepted ~) |
50 | 54 | $image_obj['name'] = Context::convertEncodingStr($image_obj['name']); |
51 | 55 | |
52 | - if(!preg_match("/\.(jpg|jpeg|gif|png)$/i", $image_obj['name'])) $alt_message = 'msg_rss_invalid_image_format'; |
|
53 | - else |
|
56 | + if(!preg_match("/\.(jpg|jpeg|gif|png)$/i", $image_obj['name'])) { |
|
57 | + $alt_message = 'msg_rss_invalid_image_format'; |
|
58 | + } else |
|
54 | 59 | { |
55 | 60 | // Upload the file to a path |
56 | 61 | $path = './files/attach/images/rss/'; |
57 | 62 | // Create a directory |
58 | - if(!FileHandler::makeDir($path)) $alt_message = 'msg_error_occured'; |
|
59 | - else |
|
63 | + if(!FileHandler::makeDir($path)) { |
|
64 | + $alt_message = 'msg_error_occured'; |
|
65 | + } else |
|
60 | 66 | { |
61 | 67 | $filename = $path.$image_obj['name']; |
62 | 68 | |
63 | 69 | // Move the file |
64 | - if(!move_uploaded_file($image_obj['tmp_name'], $filename)) $alt_message = 'msg_error_occured'; |
|
65 | - else |
|
70 | + if(!move_uploaded_file($image_obj['tmp_name'], $filename)) { |
|
71 | + $alt_message = 'msg_error_occured'; |
|
72 | + } else |
|
66 | 73 | { |
67 | 74 | $config_vars->image = $filename; |
68 | 75 | } |
@@ -70,11 +77,15 @@ discard block |
||
70 | 77 | } |
71 | 78 | } |
72 | 79 | } |
73 | - if(!$config_vars->image && $config_vars->del_image != 'Y') $config_vars->image = $total_config->image; |
|
80 | + if(!$config_vars->image && $config_vars->del_image != 'Y') { |
|
81 | + $config_vars->image = $total_config->image; |
|
82 | + } |
|
74 | 83 | |
75 | 84 | $output = $this->setFeedConfig($config_vars); |
76 | 85 | |
77 | - if(!$alt_message) $alt_message = 'success_updated'; |
|
86 | + if(!$alt_message) { |
|
87 | + $alt_message = 'success_updated'; |
|
88 | + } |
|
78 | 89 | |
79 | 90 | $alt_message = Context::getLang($alt_message); |
80 | 91 | $this->setMessage($alt_message, 'info'); |
@@ -139,7 +150,9 @@ discard block |
||
139 | 150 | return new Object(-1, 'msg_invalid_request'); |
140 | 151 | } |
141 | 152 | |
142 | - if(!in_array($open_rss, array('Y','H','N'))) $open_rss = 'N'; |
|
153 | + if(!in_array($open_rss, array('Y','H','N'))) { |
|
154 | + $open_rss = 'N'; |
|
155 | + } |
|
143 | 156 | |
144 | 157 | $this->setRssModuleConfig($module_srl, $open_rss, $openTotalFeedList[$module_srl], $feedDescriptionList[$module_srl], $feedCopyrightList[$module_srl]); |
145 | 158 | } |
@@ -98,6 +98,7 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * @brief Delete IP |
100 | 100 | * Remove the IP address which was previously registered as a spammers |
101 | + * @param string $ipaddress |
|
101 | 102 | */ |
102 | 103 | function deleteIP($ipaddress) |
103 | 104 | { |
@@ -111,6 +112,7 @@ discard block |
||
111 | 112 | /** |
112 | 113 | * @brief Register the spam word |
113 | 114 | * The post, which contains the newly registered spam word, should be considered as a spam |
115 | + * @param string $word_list |
|
114 | 116 | */ |
115 | 117 | function insertWord($word_list) |
116 | 118 | { |
@@ -141,6 +143,7 @@ discard block |
||
141 | 143 | /** |
142 | 144 | * @brief Remove the spam word |
143 | 145 | * Remove the word which was previously registered as a spam word |
146 | + * @param string $word |
|
144 | 147 | */ |
145 | 148 | function deleteWord($word) |
146 | 149 | { |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /* Copyright (C) NAVER <http://www.navercorp.com> */ |
3 | 3 | /** |
4 | - * @class spamfilterAdminController |
|
5 | - * @author NAVER ([email protected]) |
|
6 | - * @brief The admin controller class of the spamfilter module |
|
7 | - */ |
|
4 | + * @class spamfilterAdminController |
|
5 | + * @author NAVER ([email protected]) |
|
6 | + * @brief The admin controller class of the spamfilter module |
|
7 | + */ |
|
8 | 8 | class spamfilterAdminController extends spamfilter |
9 | 9 | { |
10 | 10 | /** |
@@ -17,15 +17,15 @@ discard block |
||
17 | 17 | function procSpamfilterAdminInsertConfig() |
18 | 18 | { |
19 | 19 | // Get the default information |
20 | - $argsConfig = Context::gets('limits','check_trackback'); |
|
20 | + $argsConfig = Context::gets('limits', 'check_trackback'); |
|
21 | 21 | $flag = Context::get('flag'); |
22 | 22 | //interval, limit_count |
23 | - if($argsConfig->check_trackback!='Y') $argsConfig->check_trackback = 'N'; |
|
24 | - if($argsConfig->limits!='Y') $argsConfig->limits = 'N'; |
|
23 | + if ($argsConfig->check_trackback != 'Y') $argsConfig->check_trackback = 'N'; |
|
24 | + if ($argsConfig->limits != 'Y') $argsConfig->limits = 'N'; |
|
25 | 25 | // Create and insert the module Controller object |
26 | 26 | $oModuleController = getController('module'); |
27 | - $moduleConfigOutput = $oModuleController->insertModuleConfig('spamfilter',$argsConfig); |
|
28 | - if(!$moduleConfigOutput->toBool()) return $moduleConfigOutput; |
|
27 | + $moduleConfigOutput = $oModuleController->insertModuleConfig('spamfilter', $argsConfig); |
|
28 | + if (!$moduleConfigOutput->toBool()) return $moduleConfigOutput; |
|
29 | 29 | |
30 | 30 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminConfigBlock'); |
31 | 31 | $this->setRedirectUrl($returnUrl); |
@@ -36,13 +36,13 @@ discard block |
||
36 | 36 | //스팸IP 추가 |
37 | 37 | $ipaddress_list = Context::get('ipaddress_list'); |
38 | 38 | $oSpamfilterController = getController('spamfilter'); |
39 | - if($ipaddress_list) |
|
39 | + if ($ipaddress_list) |
|
40 | 40 | { |
41 | 41 | $output = $oSpamfilterController->insertIP($ipaddress_list); |
42 | - if(!$output->toBool() && !$output->get('fail_list')) return $output; |
|
42 | + if (!$output->toBool() && !$output->get('fail_list')) return $output; |
|
43 | 43 | |
44 | - if($output->get('fail_list')) $message_fail = '<em>'.sprintf(Context::getLang('msg_faillist'),$output->get('fail_list')).'</em>'; |
|
45 | - $this->setMessage(Context::getLang('success_registed').$message_fail); |
|
44 | + if ($output->get('fail_list')) $message_fail = '<em>' . sprintf(Context::getLang('msg_faillist'), $output->get('fail_list')) . '</em>'; |
|
45 | + $this->setMessage(Context::getLang('success_registed') . $message_fail); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | |
@@ -54,13 +54,13 @@ discard block |
||
54 | 54 | { |
55 | 55 | //스팸 키워드 추가 |
56 | 56 | $word_list = Context::get('word_list'); |
57 | - if($word_list) |
|
57 | + if ($word_list) |
|
58 | 58 | { |
59 | 59 | $output = $this->insertWord($word_list); |
60 | - if(!$output->toBool() && !$output->get('fail_list')) return $output; |
|
60 | + if (!$output->toBool() && !$output->get('fail_list')) return $output; |
|
61 | 61 | |
62 | - if($output->get('fail_list')) $message_fail = '<em>'.sprintf(Context::getLang('msg_faillist'),$output->get('fail_list')).'</em>'; |
|
63 | - $this->setMessage(Context::getLang('success_registed').$message_fail); |
|
62 | + if ($output->get('fail_list')) $message_fail = '<em>' . sprintf(Context::getLang('msg_faillist'), $output->get('fail_list')) . '</em>'; |
|
63 | + $this->setMessage(Context::getLang('success_registed') . $message_fail); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminDeniedWordList'); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | function procSpamfilterAdminDeleteDeniedIP() |
74 | 74 | { |
75 | 75 | $ipAddressList = Context::get('ipaddress'); |
76 | - if($ipAddressList) $this->deleteIP($ipAddressList); |
|
76 | + if ($ipAddressList) $this->deleteIP($ipAddressList); |
|
77 | 77 | |
78 | 78 | $this->setMessage(Context::getLang('success_deleted')); |
79 | 79 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | $this->setMessage(Context::getLang('success_deleted')); |
93 | 93 | |
94 | - $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminDeniedWordList','active','word'); |
|
94 | + $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminDeniedWordList', 'active', 'word'); |
|
95 | 95 | return $this->setRedirectUrl($returnUrl); |
96 | 96 | } |
97 | 97 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | */ |
102 | 102 | function deleteIP($ipaddress) |
103 | 103 | { |
104 | - if(!$ipaddress) return; |
|
104 | + if (!$ipaddress) return; |
|
105 | 105 | |
106 | 106 | $args = new stdClass; |
107 | 107 | $args->ipaddress = $ipaddress; |
@@ -115,26 +115,26 @@ discard block |
||
115 | 115 | function insertWord($word_list) |
116 | 116 | { |
117 | 117 | |
118 | - $word_list = str_replace("\r","",$word_list); |
|
119 | - $word_list = explode("\n",$word_list); |
|
118 | + $word_list = str_replace("\r", "", $word_list); |
|
119 | + $word_list = explode("\n", $word_list); |
|
120 | 120 | |
121 | - foreach($word_list as $word) |
|
121 | + foreach ($word_list as $word) |
|
122 | 122 | { |
123 | - if(!preg_match("/^(.{2,40}[\r\n]+)*.{2,40}$/", $word)) |
|
123 | + if (!preg_match("/^(.{2,40}[\r\n]+)*.{2,40}$/", $word)) |
|
124 | 124 | { |
125 | 125 | return new Object(-1, 'msg_invalid'); |
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | 129 | $fail_word = ''; |
130 | - foreach($word_list as $word) |
|
130 | + foreach ($word_list as $word) |
|
131 | 131 | { |
132 | 132 | $args = new stdClass; |
133 | - if(trim($word)) $args->word = $word; |
|
133 | + if (trim($word)) $args->word = $word; |
|
134 | 134 | $output = executeQuery('spamfilter.insertDeniedWord', $args); |
135 | - if(!$output->toBool()) $fail_word .= $word.'<br />'; |
|
135 | + if (!$output->toBool()) $fail_word .= $word . '<br />'; |
|
136 | 136 | } |
137 | - $output->add('fail_list',$fail_word); |
|
137 | + $output->add('fail_list', $fail_word); |
|
138 | 138 | return $output; |
139 | 139 | } |
140 | 140 | |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | function deleteWord($word) |
146 | 146 | { |
147 | - if(!$word) return; |
|
147 | + if (!$word) return; |
|
148 | 148 | $args = new stdClass; |
149 | 149 | $args->word = $word; |
150 | 150 | return executeQuery('spamfilter.deleteDeniedWord', $args); |
@@ -20,12 +20,18 @@ discard block |
||
20 | 20 | $argsConfig = Context::gets('limits','check_trackback'); |
21 | 21 | $flag = Context::get('flag'); |
22 | 22 | //interval, limit_count |
23 | - if($argsConfig->check_trackback!='Y') $argsConfig->check_trackback = 'N'; |
|
24 | - if($argsConfig->limits!='Y') $argsConfig->limits = 'N'; |
|
23 | + if($argsConfig->check_trackback!='Y') { |
|
24 | + $argsConfig->check_trackback = 'N'; |
|
25 | + } |
|
26 | + if($argsConfig->limits!='Y') { |
|
27 | + $argsConfig->limits = 'N'; |
|
28 | + } |
|
25 | 29 | // Create and insert the module Controller object |
26 | 30 | $oModuleController = getController('module'); |
27 | 31 | $moduleConfigOutput = $oModuleController->insertModuleConfig('spamfilter',$argsConfig); |
28 | - if(!$moduleConfigOutput->toBool()) return $moduleConfigOutput; |
|
32 | + if(!$moduleConfigOutput->toBool()) { |
|
33 | + return $moduleConfigOutput; |
|
34 | + } |
|
29 | 35 | |
30 | 36 | $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispSpamfilterAdminConfigBlock'); |
31 | 37 | $this->setRedirectUrl($returnUrl); |
@@ -39,9 +45,13 @@ discard block |
||
39 | 45 | if($ipaddress_list) |
40 | 46 | { |
41 | 47 | $output = $oSpamfilterController->insertIP($ipaddress_list); |
42 | - if(!$output->toBool() && !$output->get('fail_list')) return $output; |
|
48 | + if(!$output->toBool() && !$output->get('fail_list')) { |
|
49 | + return $output; |
|
50 | + } |
|
43 | 51 | |
44 | - if($output->get('fail_list')) $message_fail = '<em>'.sprintf(Context::getLang('msg_faillist'),$output->get('fail_list')).'</em>'; |
|
52 | + if($output->get('fail_list')) { |
|
53 | + $message_fail = '<em>'.sprintf(Context::getLang('msg_faillist'),$output->get('fail_list')).'</em>'; |
|
54 | + } |
|
45 | 55 | $this->setMessage(Context::getLang('success_registed').$message_fail); |
46 | 56 | } |
47 | 57 | |
@@ -57,9 +67,13 @@ discard block |
||
57 | 67 | if($word_list) |
58 | 68 | { |
59 | 69 | $output = $this->insertWord($word_list); |
60 | - if(!$output->toBool() && !$output->get('fail_list')) return $output; |
|
70 | + if(!$output->toBool() && !$output->get('fail_list')) { |
|
71 | + return $output; |
|
72 | + } |
|
61 | 73 | |
62 | - if($output->get('fail_list')) $message_fail = '<em>'.sprintf(Context::getLang('msg_faillist'),$output->get('fail_list')).'</em>'; |
|
74 | + if($output->get('fail_list')) { |
|
75 | + $message_fail = '<em>'.sprintf(Context::getLang('msg_faillist'),$output->get('fail_list')).'</em>'; |
|
76 | + } |
|
63 | 77 | $this->setMessage(Context::getLang('success_registed').$message_fail); |
64 | 78 | } |
65 | 79 | |
@@ -73,7 +87,9 @@ discard block |
||
73 | 87 | function procSpamfilterAdminDeleteDeniedIP() |
74 | 88 | { |
75 | 89 | $ipAddressList = Context::get('ipaddress'); |
76 | - if($ipAddressList) $this->deleteIP($ipAddressList); |
|
90 | + if($ipAddressList) { |
|
91 | + $this->deleteIP($ipAddressList); |
|
92 | + } |
|
77 | 93 | |
78 | 94 | $this->setMessage(Context::getLang('success_deleted')); |
79 | 95 | |
@@ -101,7 +117,9 @@ discard block |
||
101 | 117 | */ |
102 | 118 | function deleteIP($ipaddress) |
103 | 119 | { |
104 | - if(!$ipaddress) return; |
|
120 | + if(!$ipaddress) { |
|
121 | + return; |
|
122 | + } |
|
105 | 123 | |
106 | 124 | $args = new stdClass; |
107 | 125 | $args->ipaddress = $ipaddress; |
@@ -130,9 +148,13 @@ discard block |
||
130 | 148 | foreach($word_list as $word) |
131 | 149 | { |
132 | 150 | $args = new stdClass; |
133 | - if(trim($word)) $args->word = $word; |
|
151 | + if(trim($word)) { |
|
152 | + $args->word = $word; |
|
153 | + } |
|
134 | 154 | $output = executeQuery('spamfilter.insertDeniedWord', $args); |
135 | - if(!$output->toBool()) $fail_word .= $word.'<br />'; |
|
155 | + if(!$output->toBool()) { |
|
156 | + $fail_word .= $word.'<br />'; |
|
157 | + } |
|
136 | 158 | } |
137 | 159 | $output->add('fail_list',$fail_word); |
138 | 160 | return $output; |
@@ -144,7 +166,9 @@ discard block |
||
144 | 166 | */ |
145 | 167 | function deleteWord($word) |
146 | 168 | { |
147 | - if(!$word) return; |
|
169 | + if(!$word) { |
|
170 | + return; |
|
171 | + } |
|
148 | 172 | $args = new stdClass; |
149 | 173 | $args->word = $word; |
150 | 174 | return executeQuery('spamfilter.deleteDeniedWord', $args); |
@@ -161,6 +161,8 @@ |
||
161 | 161 | /** |
162 | 162 | * @brief IP registration |
163 | 163 | * The registered IP address is considered as a spammer |
164 | + * @param string $ipaddress_list |
|
165 | + * @param string $description |
|
164 | 166 | */ |
165 | 167 | function insertIP($ipaddress_list, $description = null) |
166 | 168 | { |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /* Copyright (C) NAVER <http://www.navercorp.com> */ |
3 | 3 | /** |
4 | - * @class spamfilterController |
|
5 | - * @author NAVER ([email protected]) |
|
6 | - * @brief The controller class for the spamfilter module |
|
7 | - */ |
|
4 | + * @class spamfilterController |
|
5 | + * @author NAVER ([email protected]) |
|
6 | + * @brief The controller class for the spamfilter module |
|
7 | + */ |
|
8 | 8 | class spamfilterController extends spamfilter |
9 | 9 | { |
10 | 10 | /** |
@@ -27,25 +27,25 @@ discard block |
||
27 | 27 | */ |
28 | 28 | function triggerInsertDocument(&$obj) |
29 | 29 | { |
30 | - if($_SESSION['avoid_log']) return new Object(); |
|
30 | + if ($_SESSION['avoid_log']) return new Object(); |
|
31 | 31 | // Check the login status, login information, and permission |
32 | 32 | $is_logged = Context::get('is_logged'); |
33 | 33 | $logged_info = Context::get('logged_info'); |
34 | 34 | $grant = Context::get('grant'); |
35 | 35 | // In case logged in, check if it is an administrator |
36 | - if($is_logged) |
|
36 | + if ($is_logged) |
|
37 | 37 | { |
38 | - if($logged_info->is_admin == 'Y') return new Object(); |
|
39 | - if($grant->manager) return new Object(); |
|
38 | + if ($logged_info->is_admin == 'Y') return new Object(); |
|
39 | + if ($grant->manager) return new Object(); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | $oFilterModel = getModel('spamfilter'); |
43 | 43 | // Check if the IP is prohibited |
44 | 44 | $output = $oFilterModel->isDeniedIP(); |
45 | - if(!$output->toBool()) return $output; |
|
45 | + if (!$output->toBool()) return $output; |
|
46 | 46 | // Check if there is a ban on the word |
47 | 47 | $text = ''; |
48 | - if($is_logged) |
|
48 | + if ($is_logged) |
|
49 | 49 | { |
50 | 50 | $text = $obj->title . ' ' . $obj->content . ' ' . $obj->tags; |
51 | 51 | } |
@@ -54,12 +54,12 @@ discard block |
||
54 | 54 | $text = $obj->title . ' ' . $obj->content . ' ' . $obj->nick_name . ' ' . $obj->homepage . ' ' . $obj->tags; |
55 | 55 | } |
56 | 56 | $output = $oFilterModel->isDeniedWord($text); |
57 | - if(!$output->toBool()) return $output; |
|
57 | + if (!$output->toBool()) return $output; |
|
58 | 58 | // Check the specified time beside the modificaiton time |
59 | - if($obj->document_srl == 0) |
|
59 | + if ($obj->document_srl == 0) |
|
60 | 60 | { |
61 | 61 | $output = $oFilterModel->checkLimited(); |
62 | - if(!$output->toBool()) return $output; |
|
62 | + if (!$output->toBool()) return $output; |
|
63 | 63 | } |
64 | 64 | // Save a log |
65 | 65 | $this->insertLog(); |
@@ -72,25 +72,25 @@ discard block |
||
72 | 72 | */ |
73 | 73 | function triggerInsertComment(&$obj) |
74 | 74 | { |
75 | - if($_SESSION['avoid_log']) return new Object(); |
|
75 | + if ($_SESSION['avoid_log']) return new Object(); |
|
76 | 76 | // Check the login status, login information, and permission |
77 | 77 | $is_logged = Context::get('is_logged'); |
78 | 78 | $logged_info = Context::get('logged_info'); |
79 | 79 | $grant = Context::get('grant'); |
80 | 80 | // In case logged in, check if it is an administrator |
81 | - if($is_logged) |
|
81 | + if ($is_logged) |
|
82 | 82 | { |
83 | - if($logged_info->is_admin == 'Y') return new Object(); |
|
84 | - if($grant->manager) return new Object(); |
|
83 | + if ($logged_info->is_admin == 'Y') return new Object(); |
|
84 | + if ($grant->manager) return new Object(); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | $oFilterModel = getModel('spamfilter'); |
88 | 88 | // Check if the IP is prohibited |
89 | 89 | $output = $oFilterModel->isDeniedIP(); |
90 | - if(!$output->toBool()) return $output; |
|
90 | + if (!$output->toBool()) return $output; |
|
91 | 91 | // Check if there is a ban on the word |
92 | 92 | $text = ''; |
93 | - if($is_logged) |
|
93 | + if ($is_logged) |
|
94 | 94 | { |
95 | 95 | $text = $obj->content; |
96 | 96 | } |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | $text = $obj->content . ' ' . $obj->nick_name . ' ' . $obj->homepage; |
100 | 100 | } |
101 | 101 | $output = $oFilterModel->isDeniedWord($text); |
102 | - if(!$output->toBool()) return $output; |
|
102 | + if (!$output->toBool()) return $output; |
|
103 | 103 | // If the specified time check is not modified |
104 | - if(!$obj->__isupdate) |
|
104 | + if (!$obj->__isupdate) |
|
105 | 105 | { |
106 | 106 | $output = $oFilterModel->checkLimited(); |
107 | - if(!$output->toBool()) return $output; |
|
107 | + if (!$output->toBool()) return $output; |
|
108 | 108 | } |
109 | 109 | unset($obj->__isupdate); |
110 | 110 | // Save a log |
@@ -118,32 +118,32 @@ discard block |
||
118 | 118 | */ |
119 | 119 | function triggerInsertTrackback(&$obj) |
120 | 120 | { |
121 | - if($_SESSION['avoid_log']) return new Object(); |
|
121 | + if ($_SESSION['avoid_log']) return new Object(); |
|
122 | 122 | |
123 | 123 | $oFilterModel = getModel('spamfilter'); |
124 | 124 | // Confirm if the trackbacks have been added more than once to your document |
125 | 125 | $output = $oFilterModel->isInsertedTrackback($obj->document_srl); |
126 | - if(!$output->toBool()) return $output; |
|
126 | + if (!$output->toBool()) return $output; |
|
127 | 127 | |
128 | 128 | // Check if the IP is prohibited |
129 | 129 | $output = $oFilterModel->isDeniedIP(); |
130 | - if(!$output->toBool()) return $output; |
|
130 | + if (!$output->toBool()) return $output; |
|
131 | 131 | // Check if there is a ban on the word |
132 | 132 | $text = $obj->blog_name . ' ' . $obj->title . ' ' . $obj->excerpt . ' ' . $obj->url; |
133 | 133 | $output = $oFilterModel->isDeniedWord($text); |
134 | - if(!$output->toBool()) return $output; |
|
134 | + if (!$output->toBool()) return $output; |
|
135 | 135 | // Start Filtering |
136 | 136 | $oTrackbackModel = getModel('trackback'); |
137 | 137 | $oTrackbackController = getController('trackback'); |
138 | 138 | |
139 | - list($ipA,$ipB,$ipC,$ipD) = explode('.',$_SERVER['REMOTE_ADDR']); |
|
140 | - $ipaddress = $ipA.'.'.$ipB.'.'.$ipC; |
|
139 | + list($ipA, $ipB, $ipC, $ipD) = explode('.', $_SERVER['REMOTE_ADDR']); |
|
140 | + $ipaddress = $ipA . '.' . $ipB . '.' . $ipC; |
|
141 | 141 | // In case the title and the blog name are indentical, investigate the IP address of the last 6 hours, delete and ban it. |
142 | - if($obj->title == $obj->excerpt) |
|
142 | + if ($obj->title == $obj->excerpt) |
|
143 | 143 | { |
144 | - $oTrackbackController->deleteTrackbackSender(60*60*6, $ipaddress, $obj->url, $obj->blog_name, $obj->title, $obj->excerpt); |
|
145 | - $this->insertIP($ipaddress.'.*', 'AUTO-DENIED : trackback.insertTrackback'); |
|
146 | - return new Object(-1,'msg_alert_trackback_denied'); |
|
144 | + $oTrackbackController->deleteTrackbackSender(60 * 60 * 6, $ipaddress, $obj->url, $obj->blog_name, $obj->title, $obj->excerpt); |
|
145 | + $this->insertIP($ipaddress . '.*', 'AUTO-DENIED : trackback.insertTrackback'); |
|
146 | + return new Object(-1, 'msg_alert_trackback_denied'); |
|
147 | 147 | } |
148 | 148 | // If trackbacks have been registered by one C-class IP address more than once for the last 30 minutes, ban the IP address and delete all the posts |
149 | 149 | /* 호스팅 환경을 감안하여 일단 이 부분은 동작하지 않도록 주석 처리 |
@@ -165,24 +165,24 @@ discard block |
||
165 | 165 | function insertIP($ipaddress_list, $description = null) |
166 | 166 | { |
167 | 167 | $regExr = "/^((\d{1,3}(?:.(\d{1,3}|\*)){3})\s*(\/\/(.*)\s*)?)*\s*$/"; |
168 | - if(!preg_match($regExr,$ipaddress_list)) return new Object(-1, 'msg_invalid'); |
|
169 | - $ipaddress_list = str_replace("\r","",$ipaddress_list); |
|
170 | - $ipaddress_list = explode("\n",$ipaddress_list); |
|
171 | - foreach($ipaddress_list as $ipaddressValue) |
|
168 | + if (!preg_match($regExr, $ipaddress_list)) return new Object(-1, 'msg_invalid'); |
|
169 | + $ipaddress_list = str_replace("\r", "", $ipaddress_list); |
|
170 | + $ipaddress_list = explode("\n", $ipaddress_list); |
|
171 | + foreach ($ipaddress_list as $ipaddressValue) |
|
172 | 172 | { |
173 | 173 | $args = new stdClass(); |
174 | - preg_match("/(\d{1,3}(?:.(\d{1,3}|\*)){3})\s*(\/\/(.*)\s*)?/",$ipaddressValue,$matches); |
|
175 | - if($ipaddress=trim($matches[1])) |
|
174 | + preg_match("/(\d{1,3}(?:.(\d{1,3}|\*)){3})\s*(\/\/(.*)\s*)?/", $ipaddressValue, $matches); |
|
175 | + if ($ipaddress = trim($matches[1])) |
|
176 | 176 | { |
177 | 177 | $args->ipaddress = $ipaddress; |
178 | - if(!$description && $matches[4]) $args->description = $matches[4]; |
|
178 | + if (!$description && $matches[4]) $args->description = $matches[4]; |
|
179 | 179 | else $args->description = $description; |
180 | 180 | } |
181 | 181 | $output = executeQuery('spamfilter.insertDeniedIP', $args); |
182 | - if(!$output->toBool()) $fail_list .= $ipaddress.'<br/>'; |
|
182 | + if (!$output->toBool()) $fail_list .= $ipaddress . '<br/>'; |
|
183 | 183 | } |
184 | 184 | |
185 | - $output->add('fail_list',$fail_list); |
|
185 | + $output->add('fail_list', $fail_list); |
|
186 | 186 | return $output; |
187 | 187 | } |
188 | 188 | |
@@ -191,22 +191,22 @@ discard block |
||
191 | 191 | */ |
192 | 192 | function triggerSendMessage(&$obj) |
193 | 193 | { |
194 | - if($_SESSION['avoid_log']) return new Object(); |
|
194 | + if ($_SESSION['avoid_log']) return new Object(); |
|
195 | 195 | |
196 | 196 | $logged_info = Context::get('logged_info'); |
197 | - if($logged_info->is_admin == 'Y') return new Object(); |
|
197 | + if ($logged_info->is_admin == 'Y') return new Object(); |
|
198 | 198 | |
199 | 199 | $oFilterModel = getModel('spamfilter'); |
200 | 200 | // Check if the IP is prohibited |
201 | 201 | $output = $oFilterModel->isDeniedIP(); |
202 | - if(!$output->toBool()) return $output; |
|
202 | + if (!$output->toBool()) return $output; |
|
203 | 203 | // Check if there is a ban on the word |
204 | 204 | $text = $obj->title . ' ' . $obj->content; |
205 | 205 | $output = $oFilterModel->isDeniedWord($text); |
206 | - if(!$output->toBool()) return $output; |
|
206 | + if (!$output->toBool()) return $output; |
|
207 | 207 | // Check the specified time |
208 | 208 | $output = $oFilterModel->checkLimited(TRUE); |
209 | - if(!$output->toBool()) return $output; |
|
209 | + if (!$output->toBool()) return $output; |
|
210 | 210 | // Save a log |
211 | 211 | $this->insertLog(); |
212 | 212 |
@@ -27,7 +27,9 @@ discard block |
||
27 | 27 | */ |
28 | 28 | function triggerInsertDocument(&$obj) |
29 | 29 | { |
30 | - if($_SESSION['avoid_log']) return new Object(); |
|
30 | + if($_SESSION['avoid_log']) { |
|
31 | + return new Object(); |
|
32 | + } |
|
31 | 33 | // Check the login status, login information, and permission |
32 | 34 | $is_logged = Context::get('is_logged'); |
33 | 35 | $logged_info = Context::get('logged_info'); |
@@ -35,31 +37,40 @@ discard block |
||
35 | 37 | // In case logged in, check if it is an administrator |
36 | 38 | if($is_logged) |
37 | 39 | { |
38 | - if($logged_info->is_admin == 'Y') return new Object(); |
|
39 | - if($grant->manager) return new Object(); |
|
40 | + if($logged_info->is_admin == 'Y') { |
|
41 | + return new Object(); |
|
42 | + } |
|
43 | + if($grant->manager) { |
|
44 | + return new Object(); |
|
45 | + } |
|
40 | 46 | } |
41 | 47 | |
42 | 48 | $oFilterModel = getModel('spamfilter'); |
43 | 49 | // Check if the IP is prohibited |
44 | 50 | $output = $oFilterModel->isDeniedIP(); |
45 | - if(!$output->toBool()) return $output; |
|
51 | + if(!$output->toBool()) { |
|
52 | + return $output; |
|
53 | + } |
|
46 | 54 | // Check if there is a ban on the word |
47 | 55 | $text = ''; |
48 | 56 | if($is_logged) |
49 | 57 | { |
50 | 58 | $text = $obj->title . ' ' . $obj->content . ' ' . $obj->tags; |
51 | - } |
|
52 | - else |
|
59 | + } else |
|
53 | 60 | { |
54 | 61 | $text = $obj->title . ' ' . $obj->content . ' ' . $obj->nick_name . ' ' . $obj->homepage . ' ' . $obj->tags; |
55 | 62 | } |
56 | 63 | $output = $oFilterModel->isDeniedWord($text); |
57 | - if(!$output->toBool()) return $output; |
|
64 | + if(!$output->toBool()) { |
|
65 | + return $output; |
|
66 | + } |
|
58 | 67 | // Check the specified time beside the modificaiton time |
59 | 68 | if($obj->document_srl == 0) |
60 | 69 | { |
61 | 70 | $output = $oFilterModel->checkLimited(); |
62 | - if(!$output->toBool()) return $output; |
|
71 | + if(!$output->toBool()) { |
|
72 | + return $output; |
|
73 | + } |
|
63 | 74 | } |
64 | 75 | // Save a log |
65 | 76 | $this->insertLog(); |
@@ -72,7 +83,9 @@ discard block |
||
72 | 83 | */ |
73 | 84 | function triggerInsertComment(&$obj) |
74 | 85 | { |
75 | - if($_SESSION['avoid_log']) return new Object(); |
|
86 | + if($_SESSION['avoid_log']) { |
|
87 | + return new Object(); |
|
88 | + } |
|
76 | 89 | // Check the login status, login information, and permission |
77 | 90 | $is_logged = Context::get('is_logged'); |
78 | 91 | $logged_info = Context::get('logged_info'); |
@@ -80,31 +93,40 @@ discard block |
||
80 | 93 | // In case logged in, check if it is an administrator |
81 | 94 | if($is_logged) |
82 | 95 | { |
83 | - if($logged_info->is_admin == 'Y') return new Object(); |
|
84 | - if($grant->manager) return new Object(); |
|
96 | + if($logged_info->is_admin == 'Y') { |
|
97 | + return new Object(); |
|
98 | + } |
|
99 | + if($grant->manager) { |
|
100 | + return new Object(); |
|
101 | + } |
|
85 | 102 | } |
86 | 103 | |
87 | 104 | $oFilterModel = getModel('spamfilter'); |
88 | 105 | // Check if the IP is prohibited |
89 | 106 | $output = $oFilterModel->isDeniedIP(); |
90 | - if(!$output->toBool()) return $output; |
|
107 | + if(!$output->toBool()) { |
|
108 | + return $output; |
|
109 | + } |
|
91 | 110 | // Check if there is a ban on the word |
92 | 111 | $text = ''; |
93 | 112 | if($is_logged) |
94 | 113 | { |
95 | 114 | $text = $obj->content; |
96 | - } |
|
97 | - else |
|
115 | + } else |
|
98 | 116 | { |
99 | 117 | $text = $obj->content . ' ' . $obj->nick_name . ' ' . $obj->homepage; |
100 | 118 | } |
101 | 119 | $output = $oFilterModel->isDeniedWord($text); |
102 | - if(!$output->toBool()) return $output; |
|
120 | + if(!$output->toBool()) { |
|
121 | + return $output; |
|
122 | + } |
|
103 | 123 | // If the specified time check is not modified |
104 | 124 | if(!$obj->__isupdate) |
105 | 125 | { |
106 | 126 | $output = $oFilterModel->checkLimited(); |
107 | - if(!$output->toBool()) return $output; |
|
127 | + if(!$output->toBool()) { |
|
128 | + return $output; |
|
129 | + } |
|
108 | 130 | } |
109 | 131 | unset($obj->__isupdate); |
110 | 132 | // Save a log |
@@ -118,20 +140,28 @@ discard block |
||
118 | 140 | */ |
119 | 141 | function triggerInsertTrackback(&$obj) |
120 | 142 | { |
121 | - if($_SESSION['avoid_log']) return new Object(); |
|
143 | + if($_SESSION['avoid_log']) { |
|
144 | + return new Object(); |
|
145 | + } |
|
122 | 146 | |
123 | 147 | $oFilterModel = getModel('spamfilter'); |
124 | 148 | // Confirm if the trackbacks have been added more than once to your document |
125 | 149 | $output = $oFilterModel->isInsertedTrackback($obj->document_srl); |
126 | - if(!$output->toBool()) return $output; |
|
150 | + if(!$output->toBool()) { |
|
151 | + return $output; |
|
152 | + } |
|
127 | 153 | |
128 | 154 | // Check if the IP is prohibited |
129 | 155 | $output = $oFilterModel->isDeniedIP(); |
130 | - if(!$output->toBool()) return $output; |
|
156 | + if(!$output->toBool()) { |
|
157 | + return $output; |
|
158 | + } |
|
131 | 159 | // Check if there is a ban on the word |
132 | 160 | $text = $obj->blog_name . ' ' . $obj->title . ' ' . $obj->excerpt . ' ' . $obj->url; |
133 | 161 | $output = $oFilterModel->isDeniedWord($text); |
134 | - if(!$output->toBool()) return $output; |
|
162 | + if(!$output->toBool()) { |
|
163 | + return $output; |
|
164 | + } |
|
135 | 165 | // Start Filtering |
136 | 166 | $oTrackbackModel = getModel('trackback'); |
137 | 167 | $oTrackbackController = getController('trackback'); |
@@ -165,7 +195,9 @@ discard block |
||
165 | 195 | function insertIP($ipaddress_list, $description = null) |
166 | 196 | { |
167 | 197 | $regExr = "/^((\d{1,3}(?:.(\d{1,3}|\*)){3})\s*(\/\/(.*)\s*)?)*\s*$/"; |
168 | - if(!preg_match($regExr,$ipaddress_list)) return new Object(-1, 'msg_invalid'); |
|
198 | + if(!preg_match($regExr,$ipaddress_list)) { |
|
199 | + return new Object(-1, 'msg_invalid'); |
|
200 | + } |
|
169 | 201 | $ipaddress_list = str_replace("\r","",$ipaddress_list); |
170 | 202 | $ipaddress_list = explode("\n",$ipaddress_list); |
171 | 203 | foreach($ipaddress_list as $ipaddressValue) |
@@ -175,11 +207,16 @@ discard block |
||
175 | 207 | if($ipaddress=trim($matches[1])) |
176 | 208 | { |
177 | 209 | $args->ipaddress = $ipaddress; |
178 | - if(!$description && $matches[4]) $args->description = $matches[4]; |
|
179 | - else $args->description = $description; |
|
210 | + if(!$description && $matches[4]) { |
|
211 | + $args->description = $matches[4]; |
|
212 | + } else { |
|
213 | + $args->description = $description; |
|
214 | + } |
|
180 | 215 | } |
181 | 216 | $output = executeQuery('spamfilter.insertDeniedIP', $args); |
182 | - if(!$output->toBool()) $fail_list .= $ipaddress.'<br/>'; |
|
217 | + if(!$output->toBool()) { |
|
218 | + $fail_list .= $ipaddress.'<br/>'; |
|
219 | + } |
|
183 | 220 | } |
184 | 221 | |
185 | 222 | $output->add('fail_list',$fail_list); |
@@ -191,22 +228,32 @@ discard block |
||
191 | 228 | */ |
192 | 229 | function triggerSendMessage(&$obj) |
193 | 230 | { |
194 | - if($_SESSION['avoid_log']) return new Object(); |
|
231 | + if($_SESSION['avoid_log']) { |
|
232 | + return new Object(); |
|
233 | + } |
|
195 | 234 | |
196 | 235 | $logged_info = Context::get('logged_info'); |
197 | - if($logged_info->is_admin == 'Y') return new Object(); |
|
236 | + if($logged_info->is_admin == 'Y') { |
|
237 | + return new Object(); |
|
238 | + } |
|
198 | 239 | |
199 | 240 | $oFilterModel = getModel('spamfilter'); |
200 | 241 | // Check if the IP is prohibited |
201 | 242 | $output = $oFilterModel->isDeniedIP(); |
202 | - if(!$output->toBool()) return $output; |
|
243 | + if(!$output->toBool()) { |
|
244 | + return $output; |
|
245 | + } |
|
203 | 246 | // Check if there is a ban on the word |
204 | 247 | $text = $obj->title . ' ' . $obj->content; |
205 | 248 | $output = $oFilterModel->isDeniedWord($text); |
206 | - if(!$output->toBool()) return $output; |
|
249 | + if(!$output->toBool()) { |
|
250 | + return $output; |
|
251 | + } |
|
207 | 252 | // Check the specified time |
208 | 253 | $output = $oFilterModel->checkLimited(TRUE); |
209 | - if(!$output->toBool()) return $output; |
|
254 | + if(!$output->toBool()) { |
|
255 | + return $output; |
|
256 | + } |
|
210 | 257 | // Save a log |
211 | 258 | $this->insertLog(); |
212 | 259 |
@@ -49,6 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | /** |
51 | 51 | * @brief document_srl the import tag |
52 | + * @param stdClass $obj |
|
52 | 53 | */ |
53 | 54 | function getDocumentSrlByTag($obj) |
54 | 55 | { |
@@ -70,6 +71,7 @@ discard block |
||
70 | 71 | |
71 | 72 | /** |
72 | 73 | * @brief document used in the import tag |
74 | + * @param stdClass $obj |
|
73 | 75 | */ |
74 | 76 | function getDocumentsTagList($obj) |
75 | 77 | { |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /* Copyright (C) NAVER <http://www.navercorp.com> */ |
3 | 3 | /** |
4 | - * @class tagModel |
|
5 | - * @author NAVER ([email protected]) |
|
6 | - * @brief tag model class of the module |
|
7 | - */ |
|
4 | + * @class tagModel |
|
5 | + * @author NAVER ([email protected]) |
|
6 | + * @brief tag model class of the module |
|
7 | + */ |
|
8 | 8 | class tagModel extends tag |
9 | 9 | { |
10 | 10 | /** |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function getTagList($obj) |
22 | 22 | { |
23 | - if($obj->mid) |
|
23 | + if ($obj->mid) |
|
24 | 24 | { |
25 | 25 | $oModuleModel = getModel('module'); |
26 | 26 | $obj->module_srl = $oModuleModel->getModuleSrlByMid($obj->mid); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | // Module_srl passed the array may be a check whether the array |
31 | 31 | $args = new stdClass; |
32 | - if(is_array($obj->module_srl)) |
|
32 | + if (is_array($obj->module_srl)) |
|
33 | 33 | { |
34 | 34 | $args->module_srl = implode(',', $obj->module_srl); |
35 | 35 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | $args->count = $obj->sort_index; |
43 | 43 | |
44 | 44 | $output = executeQueryArray('tag.getTagList', $args); |
45 | - if(!$output->toBool()) return $output; |
|
45 | + if (!$output->toBool()) return $output; |
|
46 | 46 | |
47 | 47 | return $output; |
48 | 48 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | function getDocumentSrlByTag($obj) |
54 | 54 | { |
55 | 55 | $args = new stdClass; |
56 | - if(is_array($obj->module_srl)) |
|
56 | + if (is_array($obj->module_srl)) |
|
57 | 57 | { |
58 | 58 | $args->module_srl = implode(',', $obj->module_srl); |
59 | 59 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | function getDocumentsTagList($obj) |
75 | 75 | { |
76 | 76 | $args = new stdClass; |
77 | - if(is_array($obj->document_srl)) |
|
77 | + if (is_array($obj->document_srl)) |
|
78 | 78 | { |
79 | 79 | $args->document_srl = implode(',', $obj->document_srl); |
80 | 80 | } |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | } |
85 | 85 | |
86 | 86 | $output = executeQueryArray('tag.getDocumentsTagList', $args); |
87 | - if(!$output->toBool()) return $output; |
|
87 | + if (!$output->toBool()) return $output; |
|
88 | 88 | |
89 | 89 | return $output; |
90 | 90 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | function getTagWithUsedList($obj) |
96 | 96 | { |
97 | 97 | $args = new stdClass; |
98 | - if(is_array($obj->module_srl)) |
|
98 | + if (is_array($obj->module_srl)) |
|
99 | 99 | { |
100 | 100 | $args->module_srl = implode(',', $obj->module_srl); |
101 | 101 | } |
@@ -108,9 +108,9 @@ discard block |
||
108 | 108 | $output = $this->getDocumentSrlByTag($args); |
109 | 109 | $document_srl = array(); |
110 | 110 | |
111 | - if($output->data) |
|
111 | + if ($output->data) |
|
112 | 112 | { |
113 | - foreach($output->data as $k => $v) $document_srl[] = $v->document_srl; |
|
113 | + foreach ($output->data as $k => $v) $document_srl[] = $v->document_srl; |
|
114 | 114 | } |
115 | 115 | unset($args); |
116 | 116 |
@@ -32,8 +32,7 @@ discard block |
||
32 | 32 | if(is_array($obj->module_srl)) |
33 | 33 | { |
34 | 34 | $args->module_srl = implode(',', $obj->module_srl); |
35 | - } |
|
36 | - else |
|
35 | + } else |
|
37 | 36 | { |
38 | 37 | $args->module_srl = $obj->module_srl; |
39 | 38 | } |
@@ -42,7 +41,9 @@ discard block |
||
42 | 41 | $args->count = $obj->sort_index; |
43 | 42 | |
44 | 43 | $output = executeQueryArray('tag.getTagList', $args); |
45 | - if(!$output->toBool()) return $output; |
|
44 | + if(!$output->toBool()) { |
|
45 | + return $output; |
|
46 | + } |
|
46 | 47 | |
47 | 48 | return $output; |
48 | 49 | } |
@@ -56,8 +57,7 @@ discard block |
||
56 | 57 | if(is_array($obj->module_srl)) |
57 | 58 | { |
58 | 59 | $args->module_srl = implode(',', $obj->module_srl); |
59 | - } |
|
60 | - else |
|
60 | + } else |
|
61 | 61 | { |
62 | 62 | $args->module_srl = $obj->module_srl; |
63 | 63 | } |
@@ -77,14 +77,15 @@ discard block |
||
77 | 77 | if(is_array($obj->document_srl)) |
78 | 78 | { |
79 | 79 | $args->document_srl = implode(',', $obj->document_srl); |
80 | - } |
|
81 | - else |
|
80 | + } else |
|
82 | 81 | { |
83 | 82 | $args->document_srl = $obj->document_srl; |
84 | 83 | } |
85 | 84 | |
86 | 85 | $output = executeQueryArray('tag.getDocumentsTagList', $args); |
87 | - if(!$output->toBool()) return $output; |
|
86 | + if(!$output->toBool()) { |
|
87 | + return $output; |
|
88 | + } |
|
88 | 89 | |
89 | 90 | return $output; |
90 | 91 | } |
@@ -98,8 +99,7 @@ discard block |
||
98 | 99 | if(is_array($obj->module_srl)) |
99 | 100 | { |
100 | 101 | $args->module_srl = implode(',', $obj->module_srl); |
101 | - } |
|
102 | - else |
|
102 | + } else |
|
103 | 103 | { |
104 | 104 | $args->module_srl = $obj->module_srl; |
105 | 105 | } |
@@ -110,7 +110,9 @@ discard block |
||
110 | 110 | |
111 | 111 | if($output->data) |
112 | 112 | { |
113 | - foreach($output->data as $k => $v) $document_srl[] = $v->document_srl; |
|
113 | + foreach($output->data as $k => $v) { |
|
114 | + $document_srl[] = $v->document_srl; |
|
115 | + } |
|
114 | 116 | } |
115 | 117 | unset($args); |
116 | 118 |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | /** |
40 | 40 | * Empty trash |
41 | 41 | * @param array trashSrls |
42 | - * @return Object |
|
42 | + * @return Object|null |
|
43 | 43 | */ |
44 | 44 | function procTrashAdminEmptyTrash() |
45 | 45 | { |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | |
128 | 128 | /** |
129 | 129 | * Restore content object |
130 | - * @return void|Object |
|
130 | + * @return Object|null |
|
131 | 131 | */ |
132 | 132 | function procTrashAdminRestore() |
133 | 133 | { |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | |
184 | 184 | /** |
185 | 185 | * Set trash list to Context |
186 | - * @return void|Object |
|
186 | + * @return Object|null |
|
187 | 187 | */ |
188 | 188 | function procTrashAdminGetList() |
189 | 189 | { |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | */ |
18 | 18 | function insertTrash($obj) |
19 | 19 | { |
20 | - if(!Context::get('is_logged')) |
|
20 | + if (!Context::get('is_logged')) |
|
21 | 21 | { |
22 | 22 | return new Object(-1, 'msg_not_permitted'); |
23 | 23 | } |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | $oTrashVO = new TrashVO(); |
28 | 28 | $oTrashVO = &$obj; |
29 | 29 | |
30 | - if(!$oTrashVO->getTrashSrl()) $oTrashVO->setTrashSrl(getNextSequence()); |
|
31 | - if(!is_string($oTrashVO->getSerializedObject())) $oTrashVO->setSerializedObject(serialize($oTrashVO->getSerializedObject())); |
|
30 | + if (!$oTrashVO->getTrashSrl()) $oTrashVO->setTrashSrl(getNextSequence()); |
|
31 | + if (!is_string($oTrashVO->getSerializedObject())) $oTrashVO->setSerializedObject(serialize($oTrashVO->getSerializedObject())); |
|
32 | 32 | $oTrashVO->setIpaddress($_SERVER['REMOTE_ADDR']); |
33 | 33 | $oTrashVO->setRemoverSrl($logged_info->member_srl); |
34 | 34 | $oTrashVO->setRegdate(date('YmdHis')); |
@@ -49,17 +49,17 @@ discard block |
||
49 | 49 | $tmpTrashSrls = Context::get('cart'); |
50 | 50 | |
51 | 51 | $trashSrls = array(); |
52 | - if($isAll != 'true') |
|
52 | + if ($isAll != 'true') |
|
53 | 53 | { |
54 | - if(is_array($tmpTrashSrls)) $trashSrls = $tmpTrashSrls; |
|
54 | + if (is_array($tmpTrashSrls)) $trashSrls = $tmpTrashSrls; |
|
55 | 55 | else $trashSrls = explode('|@|', $tmpTrashSrls); |
56 | 56 | } |
57 | 57 | |
58 | 58 | //module relation data delete... |
59 | 59 | $output = $this->_relationDataDelete($isAll, $trashSrls); |
60 | - if(!$output->toBool()) return new Object(-1, $output->message); |
|
60 | + if (!$output->toBool()) return new Object(-1, $output->message); |
|
61 | 61 | |
62 | - if(!$this->_emptyTrash($trashSrls)) return new Object(-1, $lang->fail_empty); |
|
62 | + if (!$this->_emptyTrash($trashSrls)) return new Object(-1, $lang->fail_empty); |
|
63 | 63 | |
64 | 64 | $this->setMessage('success_deleted', 'info'); |
65 | 65 | |
@@ -76,17 +76,17 @@ discard block |
||
76 | 76 | function _relationDataDelete($isAll, &$trashSrls) |
77 | 77 | { |
78 | 78 | $oTrashModel = getModel('trash'); |
79 | - if($isAll == 'true') |
|
79 | + if ($isAll == 'true') |
|
80 | 80 | { |
81 | 81 | $output = $oTrashModel->getTrashAllList(array()); |
82 | - if(!$output->toBool()) |
|
82 | + if (!$output->toBool()) |
|
83 | 83 | { |
84 | 84 | return new Object(-1, $output->message); |
85 | 85 | } |
86 | 86 | |
87 | - if(is_array($output->data)) |
|
87 | + if (is_array($output->data)) |
|
88 | 88 | { |
89 | - foreach($output->data as $value) |
|
89 | + foreach ($output->data as $value) |
|
90 | 90 | { |
91 | 91 | $trashSrls[] = $value->getTrashSrl(); |
92 | 92 | } |
@@ -97,29 +97,29 @@ discard block |
||
97 | 97 | $args = new stdClass(); |
98 | 98 | $args->trashSrl = $trashSrls; |
99 | 99 | $output = $oTrashModel->getTrashList($args); |
100 | - if(!$output->toBool()) |
|
100 | + if (!$output->toBool()) |
|
101 | 101 | { |
102 | 102 | return new Object(-1, $output->message); |
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | - if(is_array($output->data)) |
|
106 | + if (is_array($output->data)) |
|
107 | 107 | { |
108 | - foreach($output->data as $oTrashVO) |
|
108 | + foreach ($output->data as $oTrashVO) |
|
109 | 109 | { |
110 | 110 | //class file check |
111 | 111 | $classPath = ModuleHandler::getModulePath($oTrashVO->getOriginModule()); |
112 | - if(!is_dir(FileHandler::getRealPath($classPath))) return new Object(-1, 'not exist restore module directory'); |
|
112 | + if (!is_dir(FileHandler::getRealPath($classPath))) return new Object(-1, 'not exist restore module directory'); |
|
113 | 113 | |
114 | 114 | $classFile = sprintf('%s%s.admin.controller.php', $classPath, $oTrashVO->getOriginModule()); |
115 | 115 | $classFile = FileHandler::getRealPath($classFile); |
116 | - if(!file_exists($classFile)) return new Object(-1, 'not exist restore module class file'); |
|
116 | + if (!file_exists($classFile)) return new Object(-1, 'not exist restore module class file'); |
|
117 | 117 | |
118 | 118 | $oAdminController = getAdminController($oTrashVO->getOriginModule()); |
119 | - if(!method_exists($oAdminController, 'emptyTrash')) return new Object(-1, 'not exist restore method in module class file'); |
|
119 | + if (!method_exists($oAdminController, 'emptyTrash')) return new Object(-1, 'not exist restore method in module class file'); |
|
120 | 120 | |
121 | 121 | $output2 = $oAdminController->emptyTrash($oTrashVO->getSerializedObject()); |
122 | - if(!$output2->toBool()) return new Object(-1, $output2->message); |
|
122 | + if (!$output2->toBool()) return new Object(-1, $output2->message); |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | return new Object(0, $lang->success_deleted); |
@@ -134,33 +134,33 @@ discard block |
||
134 | 134 | global $lang; |
135 | 135 | $trashSrlList = Context::get('cart'); |
136 | 136 | |
137 | - if(is_array($trashSrlList)) |
|
137 | + if (is_array($trashSrlList)) |
|
138 | 138 | { |
139 | 139 | // begin transaction |
140 | 140 | $oDB = &DB::getInstance(); |
141 | 141 | $oDB->begin(); |
142 | 142 | // eache restore method call in each classfile |
143 | - foreach($trashSrlList as $value) |
|
143 | + foreach ($trashSrlList as $value) |
|
144 | 144 | { |
145 | 145 | $oTrashModel = getModel('trash'); |
146 | 146 | $output = $oTrashModel->getTrash($value); |
147 | - if(!$output->toBool()) return new Object(-1, $output->message); |
|
147 | + if (!$output->toBool()) return new Object(-1, $output->message); |
|
148 | 148 | |
149 | 149 | //class file check |
150 | 150 | $classPath = ModuleHandler::getModulePath($output->data->getOriginModule()); |
151 | - if(!is_dir(FileHandler::getRealPath($classPath))) return new Object(-1, 'not exist restore module directory'); |
|
151 | + if (!is_dir(FileHandler::getRealPath($classPath))) return new Object(-1, 'not exist restore module directory'); |
|
152 | 152 | |
153 | 153 | $classFile = sprintf('%s%s.admin.controller.php', $classPath, $output->data->getOriginModule()); |
154 | 154 | $classFile = FileHandler::getRealPath($classFile); |
155 | - if(!file_exists($classFile)) return new Object(-1, 'not exist restore module class file'); |
|
155 | + if (!file_exists($classFile)) return new Object(-1, 'not exist restore module class file'); |
|
156 | 156 | |
157 | 157 | $oAdminController = getAdminController($output->data->getOriginModule()); |
158 | - if(!method_exists($oAdminController, 'restoreTrash')) return new Object(-1, 'not exist restore method in module class file'); |
|
158 | + if (!method_exists($oAdminController, 'restoreTrash')) return new Object(-1, 'not exist restore method in module class file'); |
|
159 | 159 | |
160 | 160 | $originObject = unserialize($output->data->getSerializedObject()); |
161 | 161 | $output = $oAdminController->restoreTrash($originObject); |
162 | 162 | |
163 | - if(!$output->toBool()) |
|
163 | + if (!$output->toBool()) |
|
164 | 164 | { |
165 | 165 | $oDB->rollback(); |
166 | 166 | return new Object(-1, $output->message); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | } |
169 | 169 | |
170 | 170 | // restore object delete in trash box |
171 | - if(!$this->_emptyTrash($trashSrlList)) { |
|
171 | + if (!$this->_emptyTrash($trashSrlList)) { |
|
172 | 172 | $oDB->rollback(); |
173 | 173 | return new Object(-1, $lang->fail_empty); |
174 | 174 | } |
@@ -187,11 +187,11 @@ discard block |
||
187 | 187 | */ |
188 | 188 | function procTrashAdminGetList() |
189 | 189 | { |
190 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
190 | + if (!Context::get('is_logged')) return new Object(-1, 'msg_not_permitted'); |
|
191 | 191 | $trashSrls = Context::get('trash_srls'); |
192 | - if($trashSrls) $trashSrlList = explode(',', $trashSrls); |
|
192 | + if ($trashSrls) $trashSrlList = explode(',', $trashSrls); |
|
193 | 193 | |
194 | - if(count($trashSrlList) > 0) |
|
194 | + if (count($trashSrlList) > 0) |
|
195 | 195 | { |
196 | 196 | $oTrashModel = getModel('trash'); |
197 | 197 | $args = new stdClass(); |
@@ -218,11 +218,11 @@ discard block |
||
218 | 218 | */ |
219 | 219 | function _emptyTrash($trashSrls) |
220 | 220 | { |
221 | - if(!is_array($trashSrls)) return false; |
|
221 | + if (!is_array($trashSrls)) return false; |
|
222 | 222 | $args = new stdClass(); |
223 | 223 | $args->trashSrls = $trashSrls; |
224 | 224 | $output = executeQuery('trash.deleteTrash', $args); |
225 | - if(!$output->toBool()) return false; |
|
225 | + if (!$output->toBool()) return false; |
|
226 | 226 | |
227 | 227 | return true; |
228 | 228 | } |
@@ -27,8 +27,12 @@ discard block |
||
27 | 27 | $oTrashVO = new TrashVO(); |
28 | 28 | $oTrashVO = &$obj; |
29 | 29 | |
30 | - if(!$oTrashVO->getTrashSrl()) $oTrashVO->setTrashSrl(getNextSequence()); |
|
31 | - if(!is_string($oTrashVO->getSerializedObject())) $oTrashVO->setSerializedObject(serialize($oTrashVO->getSerializedObject())); |
|
30 | + if(!$oTrashVO->getTrashSrl()) { |
|
31 | + $oTrashVO->setTrashSrl(getNextSequence()); |
|
32 | + } |
|
33 | + if(!is_string($oTrashVO->getSerializedObject())) { |
|
34 | + $oTrashVO->setSerializedObject(serialize($oTrashVO->getSerializedObject())); |
|
35 | + } |
|
32 | 36 | $oTrashVO->setIpaddress($_SERVER['REMOTE_ADDR']); |
33 | 37 | $oTrashVO->setRemoverSrl($logged_info->member_srl); |
34 | 38 | $oTrashVO->setRegdate(date('YmdHis')); |
@@ -51,15 +55,22 @@ discard block |
||
51 | 55 | $trashSrls = array(); |
52 | 56 | if($isAll != 'true') |
53 | 57 | { |
54 | - if(is_array($tmpTrashSrls)) $trashSrls = $tmpTrashSrls; |
|
55 | - else $trashSrls = explode('|@|', $tmpTrashSrls); |
|
58 | + if(is_array($tmpTrashSrls)) { |
|
59 | + $trashSrls = $tmpTrashSrls; |
|
60 | + } else { |
|
61 | + $trashSrls = explode('|@|', $tmpTrashSrls); |
|
62 | + } |
|
56 | 63 | } |
57 | 64 | |
58 | 65 | //module relation data delete... |
59 | 66 | $output = $this->_relationDataDelete($isAll, $trashSrls); |
60 | - if(!$output->toBool()) return new Object(-1, $output->message); |
|
67 | + if(!$output->toBool()) { |
|
68 | + return new Object(-1, $output->message); |
|
69 | + } |
|
61 | 70 | |
62 | - if(!$this->_emptyTrash($trashSrls)) return new Object(-1, $lang->fail_empty); |
|
71 | + if(!$this->_emptyTrash($trashSrls)) { |
|
72 | + return new Object(-1, $lang->fail_empty); |
|
73 | + } |
|
63 | 74 | |
64 | 75 | $this->setMessage('success_deleted', 'info'); |
65 | 76 | |
@@ -91,8 +102,7 @@ discard block |
||
91 | 102 | $trashSrls[] = $value->getTrashSrl(); |
92 | 103 | } |
93 | 104 | } |
94 | - } |
|
95 | - else |
|
105 | + } else |
|
96 | 106 | { |
97 | 107 | $args = new stdClass(); |
98 | 108 | $args->trashSrl = $trashSrls; |
@@ -109,17 +119,25 @@ discard block |
||
109 | 119 | { |
110 | 120 | //class file check |
111 | 121 | $classPath = ModuleHandler::getModulePath($oTrashVO->getOriginModule()); |
112 | - if(!is_dir(FileHandler::getRealPath($classPath))) return new Object(-1, 'not exist restore module directory'); |
|
122 | + if(!is_dir(FileHandler::getRealPath($classPath))) { |
|
123 | + return new Object(-1, 'not exist restore module directory'); |
|
124 | + } |
|
113 | 125 | |
114 | 126 | $classFile = sprintf('%s%s.admin.controller.php', $classPath, $oTrashVO->getOriginModule()); |
115 | 127 | $classFile = FileHandler::getRealPath($classFile); |
116 | - if(!file_exists($classFile)) return new Object(-1, 'not exist restore module class file'); |
|
128 | + if(!file_exists($classFile)) { |
|
129 | + return new Object(-1, 'not exist restore module class file'); |
|
130 | + } |
|
117 | 131 | |
118 | 132 | $oAdminController = getAdminController($oTrashVO->getOriginModule()); |
119 | - if(!method_exists($oAdminController, 'emptyTrash')) return new Object(-1, 'not exist restore method in module class file'); |
|
133 | + if(!method_exists($oAdminController, 'emptyTrash')) { |
|
134 | + return new Object(-1, 'not exist restore method in module class file'); |
|
135 | + } |
|
120 | 136 | |
121 | 137 | $output2 = $oAdminController->emptyTrash($oTrashVO->getSerializedObject()); |
122 | - if(!$output2->toBool()) return new Object(-1, $output2->message); |
|
138 | + if(!$output2->toBool()) { |
|
139 | + return new Object(-1, $output2->message); |
|
140 | + } |
|
123 | 141 | } |
124 | 142 | } |
125 | 143 | return new Object(0, $lang->success_deleted); |
@@ -144,18 +162,26 @@ discard block |
||
144 | 162 | { |
145 | 163 | $oTrashModel = getModel('trash'); |
146 | 164 | $output = $oTrashModel->getTrash($value); |
147 | - if(!$output->toBool()) return new Object(-1, $output->message); |
|
165 | + if(!$output->toBool()) { |
|
166 | + return new Object(-1, $output->message); |
|
167 | + } |
|
148 | 168 | |
149 | 169 | //class file check |
150 | 170 | $classPath = ModuleHandler::getModulePath($output->data->getOriginModule()); |
151 | - if(!is_dir(FileHandler::getRealPath($classPath))) return new Object(-1, 'not exist restore module directory'); |
|
171 | + if(!is_dir(FileHandler::getRealPath($classPath))) { |
|
172 | + return new Object(-1, 'not exist restore module directory'); |
|
173 | + } |
|
152 | 174 | |
153 | 175 | $classFile = sprintf('%s%s.admin.controller.php', $classPath, $output->data->getOriginModule()); |
154 | 176 | $classFile = FileHandler::getRealPath($classFile); |
155 | - if(!file_exists($classFile)) return new Object(-1, 'not exist restore module class file'); |
|
177 | + if(!file_exists($classFile)) { |
|
178 | + return new Object(-1, 'not exist restore module class file'); |
|
179 | + } |
|
156 | 180 | |
157 | 181 | $oAdminController = getAdminController($output->data->getOriginModule()); |
158 | - if(!method_exists($oAdminController, 'restoreTrash')) return new Object(-1, 'not exist restore method in module class file'); |
|
182 | + if(!method_exists($oAdminController, 'restoreTrash')) { |
|
183 | + return new Object(-1, 'not exist restore method in module class file'); |
|
184 | + } |
|
159 | 185 | |
160 | 186 | $originObject = unserialize($output->data->getSerializedObject()); |
161 | 187 | $output = $oAdminController->restoreTrash($originObject); |
@@ -187,9 +213,13 @@ discard block |
||
187 | 213 | */ |
188 | 214 | function procTrashAdminGetList() |
189 | 215 | { |
190 | - if(!Context::get('is_logged')) return new Object(-1,'msg_not_permitted'); |
|
216 | + if(!Context::get('is_logged')) { |
|
217 | + return new Object(-1,'msg_not_permitted'); |
|
218 | + } |
|
191 | 219 | $trashSrls = Context::get('trash_srls'); |
192 | - if($trashSrls) $trashSrlList = explode(',', $trashSrls); |
|
220 | + if($trashSrls) { |
|
221 | + $trashSrlList = explode(',', $trashSrls); |
|
222 | + } |
|
193 | 223 | |
194 | 224 | if(count($trashSrlList) > 0) |
195 | 225 | { |
@@ -198,8 +228,7 @@ discard block |
||
198 | 228 | $args->trashSrl = $trashSrlList; |
199 | 229 | $output = $oTrashModel->getTrashList($args); |
200 | 230 | $trashList = $output->data; |
201 | - } |
|
202 | - else |
|
231 | + } else |
|
203 | 232 | { |
204 | 233 | global $lang; |
205 | 234 | $trashList = array(); |
@@ -218,11 +247,15 @@ discard block |
||
218 | 247 | */ |
219 | 248 | function _emptyTrash($trashSrls) |
220 | 249 | { |
221 | - if(!is_array($trashSrls)) return false; |
|
250 | + if(!is_array($trashSrls)) { |
|
251 | + return false; |
|
252 | + } |
|
222 | 253 | $args = new stdClass(); |
223 | 254 | $args->trashSrls = $trashSrls; |
224 | 255 | $output = executeQuery('trash.deleteTrash', $args); |
225 | - if(!$output->toBool()) return false; |
|
256 | + if(!$output->toBool()) { |
|
257 | + return false; |
|
258 | + } |
|
226 | 259 | |
227 | 260 | return true; |
228 | 261 | } |
@@ -1,13 +1,13 @@ |
||
1 | 1 | <?php |
2 | 2 | /* Copyright (C) NAVER <http://www.navercorp.com> */ |
3 | 3 | /** |
4 | - * trashAdminController class |
|
5 | - * trash admin the module's controller class |
|
6 | - * |
|
7 | - * @author NAVER ([email protected]) |
|
8 | - * @package /modules/trash |
|
9 | - * @version 0.1 |
|
10 | - */ |
|
4 | + * trashAdminController class |
|
5 | + * trash admin the module's controller class |
|
6 | + * |
|
7 | + * @author NAVER ([email protected]) |
|
8 | + * @package /modules/trash |
|
9 | + * @version 0.1 |
|
10 | + */ |
|
11 | 11 | class trashAdminController extends trash |
12 | 12 | { |
13 | 13 | /** |
@@ -696,6 +696,9 @@ |
||
696 | 696 | return $GLOBALS['_xe_loaded_widgets_'][$widget]; |
697 | 697 | } |
698 | 698 | |
699 | + /** |
|
700 | + * @param boolean $javascript_mode |
|
701 | + */ |
|
699 | 702 | function compileWidgetStyle($widgetStyle,$widget,$widget_content_body, $args, $javascript_mode) |
700 | 703 | { |
701 | 704 | if(!$widgetStyle) return $widget_content_body; |
@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /* Copyright (C) NAVER <http://www.navercorp.com> */ |
3 | 3 | /** |
4 | - * @class widgetController |
|
5 | - * @author NAVER ([email protected]) |
|
6 | - * @brief Controller class for widget modules |
|
7 | - */ |
|
4 | + * @class widgetController |
|
5 | + * @author NAVER ([email protected]) |
|
6 | + * @brief Controller class for widget modules |
|
7 | + */ |
|
8 | 8 | class widgetController extends widget |
9 | 9 | { |
10 | 10 | // The results are not widget modify/delete and where to use the flag for |
@@ -34,13 +34,13 @@ discard block |
||
34 | 34 | $oModuleModel = getModel('module'); |
35 | 35 | $skin_info = $oModuleModel->loadSkinInfo($path, $skin); |
36 | 36 | |
37 | - for($i=0;$i<count($skin_info->colorset);$i++) |
|
37 | + for ($i = 0; $i < count($skin_info->colorset); $i++) |
|
38 | 38 | { |
39 | 39 | $colorset = sprintf('%s|@|%s', $skin_info->colorset[$i]->name, $skin_info->colorset[$i]->title); |
40 | 40 | $colorset_list[] = $colorset; |
41 | 41 | } |
42 | 42 | |
43 | - if(count($colorset_list)) $colorsets = implode("\n", $colorset_list); |
|
43 | + if (count($colorset_list)) $colorsets = implode("\n", $colorset_list); |
|
44 | 44 | $this->add('colorset_list', $colorsets); |
45 | 45 | } |
46 | 46 | |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | function procWidgetGenerateCode() |
51 | 51 | { |
52 | 52 | $widget = Context::get('selected_widget'); |
53 | - if(!$widget) return new Object(-1,'msg_invalid_request'); |
|
54 | - if(!Context::get('skin')) return new Object(-1,Context::getLang('msg_widget_skin_is_null')); |
|
53 | + if (!$widget) return new Object(-1, 'msg_invalid_request'); |
|
54 | + if (!Context::get('skin')) return new Object(-1, Context::getLang('msg_widget_skin_is_null')); |
|
55 | 55 | |
56 | 56 | $attribute = $this->arrangeWidgetVars($widget, Context::getRequestVars(), $vars); |
57 | 57 | |
58 | - $widget_code = sprintf('<img class="zbxe_widget_output" widget="%s" %s />', $widget, implode(' ',$attribute)); |
|
58 | + $widget_code = sprintf('<img class="zbxe_widget_output" widget="%s" %s />', $widget, implode(' ', $attribute)); |
|
59 | 59 | // Code output |
60 | 60 | $this->add('widget_code', $widget_code); |
61 | 61 | } |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | function procWidgetGenerateCodeInPage() |
67 | 67 | { |
68 | 68 | $widget = Context::get('selected_widget'); |
69 | - if(!$widget) return new Object(-1,'msg_invalid_request'); |
|
69 | + if (!$widget) return new Object(-1, 'msg_invalid_request'); |
|
70 | 70 | |
71 | - if(!in_array($widget,array('widgetBox','widgetContent')) && !Context::get('skin')) return new Object(-1,Context::getLang('msg_widget_skin_is_null')); |
|
71 | + if (!in_array($widget, array('widgetBox', 'widgetContent')) && !Context::get('skin')) return new Object(-1, Context::getLang('msg_widget_skin_is_null')); |
|
72 | 72 | |
73 | 73 | $attribute = $this->arrangeWidgetVars($widget, Context::getRequestVars(), $vars); |
74 | 74 | // Wanted results |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | |
90 | 90 | $this->setLayoutPath('./common/tpl'); |
91 | 91 | $this->setLayoutFile('default_layout.html'); |
92 | - $this->setTemplatePath($this->module_path.'tpl'); |
|
92 | + $this->setTemplatePath($this->module_path . 'tpl'); |
|
93 | 93 | $this->setTemplateFile("top_refresh.html"); |
94 | 94 | } |
95 | 95 | |
@@ -107,28 +107,28 @@ discard block |
||
107 | 107 | $err = 0; |
108 | 108 | $oLayoutModel = getModel('layout'); |
109 | 109 | $layout_info = $oLayoutModel->getLayout($module_srl); |
110 | - if(!$layout_info || $layout_info->type != 'faceoff') $err++; |
|
110 | + if (!$layout_info || $layout_info->type != 'faceoff') $err++; |
|
111 | 111 | // Destination Information Wanted page module |
112 | 112 | $oModuleModel = getModel('module'); |
113 | 113 | $columnList = array('module_srl', 'module'); |
114 | 114 | $page_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
115 | - if(!$page_info->module_srl || $page_info->module != 'page') $err++; |
|
115 | + if (!$page_info->module_srl || $page_info->module != 'page') $err++; |
|
116 | 116 | |
117 | - if($err > 1) return new Object(-1,'msg_invalid_request'); |
|
117 | + if ($err > 1) return new Object(-1, 'msg_invalid_request'); |
|
118 | 118 | // Check permissions |
119 | 119 | $is_logged = Context::get('is_logged'); |
120 | 120 | $logged_info = Context::get('logged_info'); |
121 | 121 | $user_group = $logged_info->group_list; |
122 | 122 | $is_admin = false; |
123 | - if(count($user_group)&&count($page_info->grants['manager'])) |
|
123 | + if (count($user_group) && count($page_info->grants['manager'])) |
|
124 | 124 | { |
125 | 125 | $manager_group = $page_info->grants['manager']; |
126 | - foreach($user_group as $group_srl => $group_info) |
|
126 | + foreach ($user_group as $group_srl => $group_info) |
|
127 | 127 | { |
128 | - if(in_array($group_srl, $manager_group)) $is_admin = true; |
|
128 | + if (in_array($group_srl, $manager_group)) $is_admin = true; |
|
129 | 129 | } |
130 | 130 | } |
131 | - if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) return new Object(-1,'msg_not_permitted'); |
|
131 | + if (!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) return new Object(-1, 'msg_not_permitted'); |
|
132 | 132 | // Enter post |
133 | 133 | $oDocumentModel = getModel('document'); |
134 | 134 | $oDocumentController = getController('document'); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $obj->document_srl = $document_srl; |
140 | 140 | |
141 | 141 | $oDocument = $oDocumentModel->getDocument($obj->document_srl, true); |
142 | - if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl) |
|
142 | + if ($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl) |
|
143 | 143 | { |
144 | 144 | $output = $oDocumentController->updateDocument($oDocument, $obj); |
145 | 145 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | $obj->document_srl = $output->get('document_srl'); |
150 | 150 | } |
151 | 151 | // Stop when an error occurs |
152 | - if(!$output->toBool()) return $output; |
|
152 | + if (!$output->toBool()) return $output; |
|
153 | 153 | // Return results |
154 | 154 | $this->add('document_srl', $obj->document_srl); |
155 | 155 | } |
@@ -167,30 +167,30 @@ discard block |
||
167 | 167 | $oDocumentAdminController = getAdminController('document'); |
168 | 168 | |
169 | 169 | $oDocument = $oDocumentModel->getDocument($document_srl, true); |
170 | - if(!$oDocument->isExists()) return new Object(-1,'msg_invalid_request'); |
|
170 | + if (!$oDocument->isExists()) return new Object(-1, 'msg_invalid_request'); |
|
171 | 171 | $module_srl = $oDocument->get('module_srl'); |
172 | 172 | // Destination Information Wanted page module |
173 | 173 | $oModuleModel = getModel('module'); |
174 | 174 | $columnList = array('module_srl', 'module'); |
175 | 175 | $page_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
176 | - if(!$page_info->module_srl || $page_info->module != 'page') return new Object(-1,'msg_invalid_request'); |
|
176 | + if (!$page_info->module_srl || $page_info->module != 'page') return new Object(-1, 'msg_invalid_request'); |
|
177 | 177 | // Check permissions |
178 | 178 | $is_logged = Context::get('is_logged'); |
179 | 179 | $logged_info = Context::get('logged_info'); |
180 | 180 | $user_group = $logged_info->group_list; |
181 | 181 | $is_admin = false; |
182 | - if(count($user_group)&&count($page_info->grants['manager'])) |
|
182 | + if (count($user_group) && count($page_info->grants['manager'])) |
|
183 | 183 | { |
184 | 184 | $manager_group = $page_info->grants['manager']; |
185 | - foreach($user_group as $group_srl => $group_info) |
|
185 | + foreach ($user_group as $group_srl => $group_info) |
|
186 | 186 | { |
187 | - if(in_array($group_srl, $manager_group)) $is_admin = true; |
|
187 | + if (in_array($group_srl, $manager_group)) $is_admin = true; |
|
188 | 188 | } |
189 | 189 | } |
190 | - if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) return new Object(-1,'msg_not_permitted'); |
|
190 | + if (!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) return new Object(-1, 'msg_not_permitted'); |
|
191 | 191 | |
192 | - $output = $oDocumentAdminController->copyDocumentModule(array($oDocument->get('document_srl')), $oDocument->get('module_srl'),0); |
|
193 | - if(!$output->toBool()) return $output; |
|
192 | + $output = $oDocumentAdminController->copyDocumentModule(array($oDocument->get('document_srl')), $oDocument->get('module_srl'), 0); |
|
193 | + if (!$output->toBool()) return $output; |
|
194 | 194 | // Return results |
195 | 195 | $copied_srls = $output->get('copied_srls'); |
196 | 196 | $this->add('document_srl', $copied_srls[$oDocument->get('document_srl')]); |
@@ -208,29 +208,29 @@ discard block |
||
208 | 208 | $oDocumentController = getController('document'); |
209 | 209 | |
210 | 210 | $oDocument = $oDocumentModel->getDocument($document_srl, true); |
211 | - if(!$oDocument->isExists()) return new Object(); |
|
211 | + if (!$oDocument->isExists()) return new Object(); |
|
212 | 212 | $module_srl = $oDocument->get('module_srl'); |
213 | 213 | // Destination Information Wanted page module |
214 | 214 | $oModuleModel = getModel('module'); |
215 | 215 | $page_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
216 | - if(!$page_info->module_srl || $page_info->module != 'page') return new Object(-1,'msg_invalid_request'); |
|
216 | + if (!$page_info->module_srl || $page_info->module != 'page') return new Object(-1, 'msg_invalid_request'); |
|
217 | 217 | // Check permissions |
218 | 218 | $is_logged = Context::get('is_logged'); |
219 | 219 | $logged_info = Context::get('logged_info'); |
220 | 220 | $user_group = $logged_info->group_list; |
221 | 221 | $is_admin = false; |
222 | - if(count($user_group)&&count($page_info->grants['manager'])) |
|
222 | + if (count($user_group) && count($page_info->grants['manager'])) |
|
223 | 223 | { |
224 | 224 | $manager_group = $page_info->grants['manager']; |
225 | - foreach($user_group as $group_srl => $group_info) |
|
225 | + foreach ($user_group as $group_srl => $group_info) |
|
226 | 226 | { |
227 | - if(in_array($group_srl, $manager_group)) $is_admin = true; |
|
227 | + if (in_array($group_srl, $manager_group)) $is_admin = true; |
|
228 | 228 | } |
229 | 229 | } |
230 | - if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) return new Object(-1,'msg_not_permitted'); |
|
230 | + if (!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) return new Object(-1, 'msg_not_permitted'); |
|
231 | 231 | |
232 | 232 | $output = $oDocumentController->deleteDocument($oDocument->get('document_srl'), true); |
233 | - if(!$output->toBool()) return $output; |
|
233 | + if (!$output->toBool()) return $output; |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | /** |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | function triggerWidgetCompile(&$content) |
249 | 249 | { |
250 | - if(Context::getResponseMethod()!='HTML') return new Object(); |
|
250 | + if (Context::getResponseMethod() != 'HTML') return new Object(); |
|
251 | 251 | $content = $this->transWidgetCode($content, $this->layout_javascript_mode); |
252 | 252 | return new Object(); |
253 | 253 | } |
@@ -263,9 +263,9 @@ discard block |
||
263 | 263 | // Check whether to include information about editing |
264 | 264 | $this->javascript_mode = $javascript_mode; |
265 | 265 | // Widget code box change |
266 | - $content = preg_replace_callback('!<div([^\>]*)widget=([^\>]*?)\><div><div>((<img.*?>)*)!is', array($this,'transWidgetBox'), $content); |
|
266 | + $content = preg_replace_callback('!<div([^\>]*)widget=([^\>]*?)\><div><div>((<img.*?>)*)!is', array($this, 'transWidgetBox'), $content); |
|
267 | 267 | // Widget code information byeogyeong |
268 | - $content = preg_replace_callback('!<img([^\>]*)widget=([^\>]*?)\>!is', array($this,'transWidget'), $content); |
|
268 | + $content = preg_replace_callback('!<img([^\>]*)widget=([^\>]*?)\>!is', array($this, 'transWidget'), $content); |
|
269 | 269 | |
270 | 270 | return $content; |
271 | 271 | } |
@@ -280,11 +280,11 @@ discard block |
||
280 | 280 | $oXmlParser = new XmlParser(); |
281 | 281 | $xml_doc = $oXmlParser->parse(trim($buff)); |
282 | 282 | |
283 | - if($xml_doc->img) $vars = $xml_doc->img->attrs; |
|
283 | + if ($xml_doc->img) $vars = $xml_doc->img->attrs; |
|
284 | 284 | else $vars = $xml_doc->attrs; |
285 | 285 | |
286 | 286 | $widget = $vars->widget; |
287 | - if(!$widget) return $matches[0]; |
|
287 | + if (!$widget) return $matches[0]; |
|
288 | 288 | unset($vars->widget); |
289 | 289 | |
290 | 290 | return $this->execute($widget, $vars, $this->javascript_mode); |
@@ -295,13 +295,13 @@ discard block |
||
295 | 295 | */ |
296 | 296 | function transWidgetBox($matches) |
297 | 297 | { |
298 | - $buff = preg_replace('/<div><div>(.*)$/i','</div>',$matches[0]); |
|
298 | + $buff = preg_replace('/<div><div>(.*)$/i', '</div>', $matches[0]); |
|
299 | 299 | $oXmlParser = new XmlParser(); |
300 | 300 | $xml_doc = $oXmlParser->parse($buff); |
301 | 301 | |
302 | 302 | $vars = $xml_doc->div->attrs; |
303 | 303 | $widget = $vars->widget; |
304 | - if(!$widget) return $matches[0]; |
|
304 | + if (!$widget) return $matches[0]; |
|
305 | 305 | unset($vars->widget); |
306 | 306 | |
307 | 307 | $vars->widgetbox_content = $matches[3]; |
@@ -322,28 +322,28 @@ discard block |
||
322 | 322 | $oXmlParser = new XmlParser(); |
323 | 323 | |
324 | 324 | $cnt = count($matches[1]); |
325 | - for($i=0;$i<$cnt;$i++) |
|
325 | + for ($i = 0; $i < $cnt; $i++) |
|
326 | 326 | { |
327 | 327 | $buff = $matches[0][$i]; |
328 | 328 | $xml_doc = $oXmlParser->parse(trim($buff)); |
329 | 329 | |
330 | 330 | $args = $xml_doc->img->attrs; |
331 | - if(!$args) continue; |
|
331 | + if (!$args) continue; |
|
332 | 332 | // If you are not caching path |
333 | 333 | $widget = $args->widget; |
334 | 334 | $sequence = $args->widget_sequence; |
335 | 335 | $cache = $args->widget_cache; |
336 | - if(!$sequence || !$cache) continue; |
|
336 | + if (!$sequence || !$cache) continue; |
|
337 | 337 | |
338 | - if(count($args)) |
|
338 | + if (count($args)) |
|
339 | 339 | { |
340 | - foreach($args as $k => $v) $args->{$k} = urldecode($v); |
|
340 | + foreach ($args as $k => $v) $args->{$k} = urldecode($v); |
|
341 | 341 | } |
342 | 342 | // If the cache file for each language widget regeneration |
343 | - foreach($lang_list as $lang_type => $val) |
|
343 | + foreach ($lang_list as $lang_type => $val) |
|
344 | 344 | { |
345 | 345 | $cache_file = sprintf('%s%d.%s.cache', $this->cache_path, $sequence, $lang_type); |
346 | - if(!file_exists($cache_file)) continue; |
|
346 | + if (!file_exists($cache_file)) continue; |
|
347 | 347 | $this->getCache($widget, $args, $lang_type, true); |
348 | 348 | } |
349 | 349 | } |
@@ -355,7 +355,7 @@ discard block |
||
355 | 355 | function getCache($widget, $args, $lang_type = null, $ignore_cache = false) |
356 | 356 | { |
357 | 357 | // If the specified language specifies the current language |
358 | - if(!$lang_type) $lang_type = Context::getLangType(); |
|
358 | + if (!$lang_type) $lang_type = Context::getLangType(); |
|
359 | 359 | // widget, the cache number and cache values are set |
360 | 360 | $widget_sequence = $args->widget_sequence; |
361 | 361 | $widget_cache = $args->widget_cache; |
@@ -363,10 +363,10 @@ discard block |
||
363 | 363 | /** |
364 | 364 | * Even if the cache number and value of the cache and return it to extract data |
365 | 365 | */ |
366 | - if(!$ignore_cache && (!$widget_cache || !$widget_sequence)) |
|
366 | + if (!$ignore_cache && (!$widget_cache || !$widget_sequence)) |
|
367 | 367 | { |
368 | 368 | $oWidget = $this->getWidgetObject($widget); |
369 | - if(!$oWidget || !method_exists($oWidget, 'proc')) return; |
|
369 | + if (!$oWidget || !method_exists($oWidget, 'proc')) return; |
|
370 | 370 | |
371 | 371 | $widget_content = $oWidget->proc($args); |
372 | 372 | $oModuleController = getController('module'); |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | } |
376 | 376 | |
377 | 377 | $oCacheHandler = CacheHandler::getInstance('template'); |
378 | - if($oCacheHandler->isSupport()) |
|
378 | + if ($oCacheHandler->isSupport()) |
|
379 | 379 | { |
380 | 380 | $key = 'widget_cache:' . $widget_sequence; |
381 | 381 | |
@@ -383,7 +383,7 @@ discard block |
||
383 | 383 | $cache_body = preg_replace('@<\!--#Meta:@', '<!--Meta:', $cache_body); |
384 | 384 | } |
385 | 385 | |
386 | - if($cache_body) |
|
386 | + if ($cache_body) |
|
387 | 387 | { |
388 | 388 | return $cache_body; |
389 | 389 | } |
@@ -396,11 +396,11 @@ discard block |
||
396 | 396 | // Wanted cache file |
397 | 397 | $cache_file = sprintf('%s%d.%s.cache', $this->cache_path, $widget_sequence, $lang_type); |
398 | 398 | // If the file exists in the cache, the file validation |
399 | - if(!$ignore_cache && file_exists($cache_file)) |
|
399 | + if (!$ignore_cache && file_exists($cache_file)) |
|
400 | 400 | { |
401 | 401 | $filemtime = filemtime($cache_file); |
402 | 402 | // Should be modified compared to the time of the cache or in the future if creating more than widget.controller.php file a return value of the cache |
403 | - if($filemtime + $widget_cache * 60 > $_SERVER['REQUEST_TIME'] && $filemtime > filemtime(_XE_PATH_.'modules/widget/widget.controller.php')) |
|
403 | + if ($filemtime + $widget_cache * 60 > $_SERVER['REQUEST_TIME'] && $filemtime > filemtime(_XE_PATH_ . 'modules/widget/widget.controller.php')) |
|
404 | 404 | { |
405 | 405 | $cache_body = FileHandler::readFile($cache_file); |
406 | 406 | $cache_body = preg_replace('@<\!--#Meta:@', '<!--Meta:', $cache_body); |
@@ -409,18 +409,18 @@ discard block |
||
409 | 409 | } |
410 | 410 | } |
411 | 411 | // cache update and cache renewal of the file mtime |
412 | - if(!$oCacheHandler->isSupport()) |
|
412 | + if (!$oCacheHandler->isSupport()) |
|
413 | 413 | { |
414 | 414 | touch($cache_file); |
415 | 415 | } |
416 | 416 | |
417 | 417 | $oWidget = $this->getWidgetObject($widget); |
418 | - if(!$oWidget || !method_exists($oWidget,'proc')) return; |
|
418 | + if (!$oWidget || !method_exists($oWidget, 'proc')) return; |
|
419 | 419 | |
420 | 420 | $widget_content = $oWidget->proc($args); |
421 | 421 | $oModuleController = getController('module'); |
422 | 422 | $oModuleController->replaceDefinedLangCode($widget_content); |
423 | - if($oCacheHandler->isSupport()) |
|
423 | + if ($oCacheHandler->isSupport()) |
|
424 | 424 | { |
425 | 425 | $oCacheHandler->put($key, $widget_content, $widget_cache * 60); |
426 | 426 | } |
@@ -442,16 +442,16 @@ discard block |
||
442 | 442 | function execute($widget, $args, $javascript_mode = false, $escaped = true) |
443 | 443 | { |
444 | 444 | // Save for debug run-time widget |
445 | - if(__DEBUG__==3) $start = getMicroTime(); |
|
445 | + if (__DEBUG__ == 3) $start = getMicroTime(); |
|
446 | 446 | $before = microtime(true); |
447 | 447 | // urldecode the value of args haejum |
448 | 448 | $object_vars = get_object_vars($args); |
449 | - if(count($object_vars)) |
|
449 | + if (count($object_vars)) |
|
450 | 450 | { |
451 | - foreach($object_vars as $key => $val) |
|
451 | + foreach ($object_vars as $key => $val) |
|
452 | 452 | { |
453 | - if(in_array($key, array('widgetbox_content','body','class','style','widget_sequence','widget','widget_padding_left','widget_padding_top','widget_padding_bottom','widget_padding_right','widgetstyle','document_srl'))) continue; |
|
454 | - if($escaped) $args->{$key} = utf8RawUrlDecode($val); |
|
453 | + if (in_array($key, array('widgetbox_content', 'body', 'class', 'style', 'widget_sequence', 'widget', 'widget_padding_left', 'widget_padding_top', 'widget_padding_bottom', 'widget_padding_right', 'widgetstyle', 'document_srl'))) continue; |
|
454 | + if ($escaped) $args->{$key} = utf8RawUrlDecode($val); |
|
455 | 455 | } |
456 | 456 | } |
457 | 457 | |
@@ -460,14 +460,14 @@ discard block |
||
460 | 460 | * Widgets widgetContent/widgetBox Wanted If you are not content |
461 | 461 | */ |
462 | 462 | $widget_content = ''; |
463 | - if($widget != 'widgetContent' && $widget != 'widgetBox') |
|
463 | + if ($widget != 'widgetContent' && $widget != 'widgetBox') |
|
464 | 464 | { |
465 | - if(!is_dir(sprintf(_XE_PATH_.'widgets/%s/',$widget))) return; |
|
465 | + if (!is_dir(sprintf(_XE_PATH_ . 'widgets/%s/', $widget))) return; |
|
466 | 466 | // Hold the contents of the widget parameter |
467 | 467 | $widget_content = $this->getCache($widget, $args); |
468 | 468 | } |
469 | 469 | |
470 | - if($widget == 'widgetBox') |
|
470 | + if ($widget == 'widgetBox') |
|
471 | 471 | { |
472 | 472 | $widgetbox_content = $args->widgetbox_content; |
473 | 473 | } |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | * Wanted specified by the administrator of the widget style |
477 | 477 | */ |
478 | 478 | // Sometimes the wrong code, background-image: url (none) can be heard but none in this case, the request for the url so unconditionally Removed |
479 | - $style = preg_replace('/url\((.+)(\/?)none\)/is','', $args->style); |
|
479 | + $style = preg_replace('/url\((.+)(\/?)none\)/is', '', $args->style); |
|
480 | 480 | // Find a style statement that based on the internal margin dropping pre-change |
481 | 481 | $widget_padding_left = $args->widget_padding_left; |
482 | 482 | $widget_padding_right = $args->widget_padding_right; |
@@ -492,18 +492,18 @@ discard block |
||
492 | 492 | $widget_content_body = ''; |
493 | 493 | $widget_content_footer = ''; |
494 | 494 | // If general call is given on page styles should return immediately dreamin ' |
495 | - if(!$javascript_mode) |
|
495 | + if (!$javascript_mode) |
|
496 | 496 | { |
497 | - if($args->id) $args->id = ' id="'.$args->id.'" '; |
|
498 | - switch($widget) |
|
497 | + if ($args->id) $args->id = ' id="' . $args->id . '" '; |
|
498 | + switch ($widget) |
|
499 | 499 | { |
500 | 500 | // If a direct orthogonal addition information |
501 | 501 | case 'widgetContent' : |
502 | - if($args->document_srl) |
|
502 | + if ($args->document_srl) |
|
503 | 503 | { |
504 | 504 | $oDocumentModel = getModel('document'); |
505 | 505 | $oDocument = $oDocumentModel->getDocument($args->document_srl); |
506 | - $body = $oDocument->getContent(false,false,false, false); |
|
506 | + $body = $oDocument->getContent(false, false, false, false); |
|
507 | 507 | } |
508 | 508 | else |
509 | 509 | { |
@@ -513,21 +513,21 @@ discard block |
||
513 | 513 | $oEditorController = getController('editor'); |
514 | 514 | $body = $oEditorController->transComponent($body); |
515 | 515 | |
516 | - $widget_content_header = sprintf('<div class="xe_content xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s"><div style="%s">', $args->id, $style, $inner_style); |
|
516 | + $widget_content_header = sprintf('<div class="xe_content xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s"><div style="%s">', $args->id, $style, $inner_style); |
|
517 | 517 | $widget_content_body = $body; |
518 | 518 | $widget_content_footer = '</div></div>'; |
519 | 519 | |
520 | 520 | break; |
521 | 521 | // If the widget box; it could |
522 | 522 | case 'widgetBox' : |
523 | - $widget_content_header = sprintf('<div class="xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s;"><div style="%s"><div>', $args->id, $style, $inner_style); |
|
523 | + $widget_content_header = sprintf('<div class="xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s;"><div style="%s"><div>', $args->id, $style, $inner_style); |
|
524 | 524 | $widget_content_body = $widgetbox_content; |
525 | 525 | |
526 | 526 | break; |
527 | 527 | // If the General wijetil |
528 | 528 | default : |
529 | - $widget_content_header = sprintf('<div class="xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s">',$args->id,$style); |
|
530 | - $widget_content_body = sprintf('<div style="*zoom:1;%s">%s</div>', $inner_style,$widget_content); |
|
529 | + $widget_content_header = sprintf('<div class="xe-widget-wrapper ' . $args->css_class . '" %sstyle="%s">', $args->id, $style); |
|
530 | + $widget_content_body = sprintf('<div style="*zoom:1;%s">%s</div>', $inner_style, $widget_content); |
|
531 | 531 | $widget_content_footer = '</div>'; |
532 | 532 | break; |
533 | 533 | } |
@@ -535,15 +535,15 @@ discard block |
||
535 | 535 | } |
536 | 536 | else |
537 | 537 | { |
538 | - switch($widget) |
|
538 | + switch ($widget) |
|
539 | 539 | { |
540 | 540 | // If a direct orthogonal addition information |
541 | 541 | case 'widgetContent' : |
542 | - if($args->document_srl) |
|
542 | + if ($args->document_srl) |
|
543 | 543 | { |
544 | 544 | $oDocumentModel = getModel('document'); |
545 | 545 | $oDocument = $oDocumentModel->getDocument($args->document_srl); |
546 | - $body = $oDocument->getContent(false,false,false); |
|
546 | + $body = $oDocument->getContent(false, false, false); |
|
547 | 547 | } |
548 | 548 | else |
549 | 549 | { |
@@ -551,12 +551,12 @@ discard block |
||
551 | 551 | } |
552 | 552 | // by args |
553 | 553 | $attribute = array(); |
554 | - if($args) |
|
554 | + if ($args) |
|
555 | 555 | { |
556 | - foreach($args as $key => $val) |
|
556 | + foreach ($args as $key => $val) |
|
557 | 557 | { |
558 | - if(in_array($key, array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget','widgetstyle','document_srl'))) continue; |
|
559 | - if(strpos($val,'|@|')>0) $val = str_replace('|@|',',',$val); |
|
558 | + if (in_array($key, array('class', 'style', 'widget_padding_top', 'widget_padding_right', 'widget_padding_bottom', 'widget_padding_left', 'widget', 'widgetstyle', 'document_srl'))) continue; |
|
559 | + if (strpos($val, '|@|') > 0) $val = str_replace('|@|', ',', $val); |
|
560 | 560 | $attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
561 | 561 | } |
562 | 562 | } |
@@ -564,44 +564,44 @@ discard block |
||
564 | 564 | $oWidgetController = getController('widget'); |
565 | 565 | |
566 | 566 | $widget_content_header = sprintf( |
567 | - '<div class="xe_content widgetOutput ' . $args->css_class . '" widgetstyle="%s" style="%s" widget_padding_left="%s" widget_padding_right="%s" widget_padding_top="%s" widget_padding_bottom="%s" widget="widgetContent" document_srl="%d" %s>'. |
|
568 | - '<div class="widgetResize"></div>'. |
|
569 | - '<div class="widgetResizeLeft"></div>'. |
|
570 | - '<div class="widgetBorder">'. |
|
571 | - '<div style="%s">',$args->widgetstyle, |
|
567 | + '<div class="xe_content widgetOutput ' . $args->css_class . '" widgetstyle="%s" style="%s" widget_padding_left="%s" widget_padding_right="%s" widget_padding_top="%s" widget_padding_bottom="%s" widget="widgetContent" document_srl="%d" %s>' . |
|
568 | + '<div class="widgetResize"></div>' . |
|
569 | + '<div class="widgetResizeLeft"></div>' . |
|
570 | + '<div class="widgetBorder">' . |
|
571 | + '<div style="%s">', $args->widgetstyle, |
|
572 | 572 | $style, |
573 | 573 | $args->widget_padding_left, $args->widget_padding_right, $args->widget_padding_top, $args->widget_padding_bottom, |
574 | 574 | $args->document_srl, |
575 | - implode(' ',$attribute), |
|
575 | + implode(' ', $attribute), |
|
576 | 576 | $inner_style); |
577 | 577 | |
578 | 578 | $widget_content_body = $body; |
579 | - $widget_content_footer = sprintf('</div>'. |
|
580 | - '</div>'. |
|
581 | - '<div class="widgetContent" style="display:none;width:1px;height:1px;overflow:hidden;">%s</div>'. |
|
582 | - '</div>',base64_encode($body)); |
|
579 | + $widget_content_footer = sprintf('</div>' . |
|
580 | + '</div>' . |
|
581 | + '<div class="widgetContent" style="display:none;width:1px;height:1px;overflow:hidden;">%s</div>' . |
|
582 | + '</div>', base64_encode($body)); |
|
583 | 583 | |
584 | 584 | break; |
585 | 585 | // If the widget box; it could |
586 | 586 | case 'widgetBox' : |
587 | 587 | // by args |
588 | 588 | $attribute = array(); |
589 | - if($args) |
|
589 | + if ($args) |
|
590 | 590 | { |
591 | - foreach($args as $key => $val) |
|
591 | + foreach ($args as $key => $val) |
|
592 | 592 | { |
593 | - if(in_array($key, array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget','widgetstyle','document_srl'))) continue; |
|
594 | - if(!is_numeric($val) && (!is_string($val) || strlen($val)==0)) continue; |
|
595 | - if(strpos($val,'|@|')>0) $val = str_replace('|@|',',',$val); |
|
593 | + if (in_array($key, array('class', 'style', 'widget_padding_top', 'widget_padding_right', 'widget_padding_bottom', 'widget_padding_left', 'widget', 'widgetstyle', 'document_srl'))) continue; |
|
594 | + if (!is_numeric($val) && (!is_string($val) || strlen($val) == 0)) continue; |
|
595 | + if (strpos($val, '|@|') > 0) $val = str_replace('|@|', ',', $val); |
|
596 | 596 | $attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
597 | 597 | } |
598 | 598 | } |
599 | 599 | |
600 | 600 | $widget_content_header = sprintf( |
601 | - '<div class="widgetOutput ' . $args->css_class . '" widgetstyle="%s" widget="widgetBox" style="%s;" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" %s >'. |
|
602 | - '<div class="widgetBoxResize"></div>'. |
|
603 | - '<div class="widgetBoxResizeLeft"></div>'. |
|
604 | - '<div class="widgetBoxBorder"><div class="nullWidget" style="%s">',$args->widgetstyle,$style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left,implode(' ',$attribute),$inner_style); |
|
601 | + '<div class="widgetOutput ' . $args->css_class . '" widgetstyle="%s" widget="widgetBox" style="%s;" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" %s >' . |
|
602 | + '<div class="widgetBoxResize"></div>' . |
|
603 | + '<div class="widgetBoxResizeLeft"></div>' . |
|
604 | + '<div class="widgetBoxBorder"><div class="nullWidget" style="%s">', $args->widgetstyle, $style, $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, implode(' ', $attribute), $inner_style); |
|
605 | 605 | |
606 | 606 | $widget_content_body = $widgetbox_content; |
607 | 607 | |
@@ -610,26 +610,26 @@ discard block |
||
610 | 610 | default : |
611 | 611 | // by args |
612 | 612 | $attribute = array(); |
613 | - if($args) |
|
613 | + if ($args) |
|
614 | 614 | { |
615 | - $allowed_key = array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget'); |
|
616 | - foreach($args as $key => $val) |
|
615 | + $allowed_key = array('class', 'style', 'widget_padding_top', 'widget_padding_right', 'widget_padding_bottom', 'widget_padding_left', 'widget'); |
|
616 | + foreach ($args as $key => $val) |
|
617 | 617 | { |
618 | - if(in_array($key, $allowed_key)) continue; |
|
619 | - if(!is_numeric($val) && (!is_string($val) || strlen($val)==0)) continue; |
|
620 | - if(strpos($val,'|@|')>0) $val = str_replace('|@|',',',$val); |
|
618 | + if (in_array($key, $allowed_key)) continue; |
|
619 | + if (!is_numeric($val) && (!is_string($val) || strlen($val) == 0)) continue; |
|
620 | + if (strpos($val, '|@|') > 0) $val = str_replace('|@|', ',', $val); |
|
621 | 621 | $attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
622 | 622 | } |
623 | 623 | } |
624 | 624 | |
625 | - $widget_content_header = sprintf('<div class="widgetOutput ' . $args->css_class . '" widgetstyle="%s" style="%s" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" widget="%s" %s >'. |
|
626 | - '<div class="widgetResize"></div>'. |
|
627 | - '<div class="widgetResizeLeft"></div>'. |
|
628 | - '<div class="widgetBorder">',$args->widgetstyle,$style, |
|
625 | + $widget_content_header = sprintf('<div class="widgetOutput ' . $args->css_class . '" widgetstyle="%s" style="%s" widget_padding_top="%s" widget_padding_right="%s" widget_padding_bottom="%s" widget_padding_left="%s" widget="%s" %s >' . |
|
626 | + '<div class="widgetResize"></div>' . |
|
627 | + '<div class="widgetResizeLeft"></div>' . |
|
628 | + '<div class="widgetBorder">', $args->widgetstyle, $style, |
|
629 | 629 | $widget_padding_top, $widget_padding_right, $widget_padding_bottom, $widget_padding_left, |
630 | - $widget, implode(' ',$attribute)); |
|
630 | + $widget, implode(' ', $attribute)); |
|
631 | 631 | |
632 | - $widget_content_body = sprintf('<div style="%s">%s</div>',$inner_style, $widget_content); |
|
632 | + $widget_content_body = sprintf('<div style="%s">%s</div>', $inner_style, $widget_content); |
|
633 | 633 | |
634 | 634 | $widget_content_footer = '</div></div>'; |
635 | 635 | |
@@ -637,11 +637,11 @@ discard block |
||
637 | 637 | } |
638 | 638 | } |
639 | 639 | // Compile the widget style. |
640 | - if($args->widgetstyle) $widget_content_body = $this->compileWidgetStyle($args->widgetstyle,$widget, $widget_content_body, $args, $javascript_mode); |
|
640 | + if ($args->widgetstyle) $widget_content_body = $this->compileWidgetStyle($args->widgetstyle, $widget, $widget_content_body, $args, $javascript_mode); |
|
641 | 641 | |
642 | 642 | $output = $widget_content_header . $widget_content_body . $widget_content_footer; |
643 | 643 | // Debug widget creation time information added to the results |
644 | - if(__DEBUG__==3) $GLOBALS['__widget_excute_elapsed__'] += getMicroTime() - $start; |
|
644 | + if (__DEBUG__ == 3) $GLOBALS['__widget_excute_elapsed__'] += getMicroTime() - $start; |
|
645 | 645 | |
646 | 646 | $after = microtime(true); |
647 | 647 | |
@@ -662,32 +662,32 @@ discard block |
||
662 | 662 | */ |
663 | 663 | function getWidgetObject($widget) |
664 | 664 | { |
665 | - if(!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $widget)) |
|
665 | + if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $widget)) |
|
666 | 666 | { |
667 | 667 | return Context::getLang('msg_invalid_request'); |
668 | 668 | } |
669 | 669 | |
670 | - if(!$GLOBALS['_xe_loaded_widgets_'][$widget]) |
|
670 | + if (!$GLOBALS['_xe_loaded_widgets_'][$widget]) |
|
671 | 671 | { |
672 | 672 | // Finding the location of a widget |
673 | 673 | $oWidgetModel = getModel('widget'); |
674 | 674 | $path = $oWidgetModel->getWidgetPath($widget); |
675 | 675 | // If you do not find the class file error output widget (html output) |
676 | 676 | $class_file = sprintf('%s%s.class.php', $path, $widget); |
677 | - if(!file_exists($class_file)) return sprintf(Context::getLang('msg_widget_is_not_exists'), $widget); |
|
677 | + if (!file_exists($class_file)) return sprintf(Context::getLang('msg_widget_is_not_exists'), $widget); |
|
678 | 678 | // Widget classes include |
679 | 679 | require_once($class_file); |
680 | 680 | |
681 | 681 | // Creating Objects |
682 | - if(!class_exists($widget, false)) |
|
682 | + if (!class_exists($widget, false)) |
|
683 | 683 | { |
684 | 684 | return sprintf(Context::getLang('msg_widget_object_is_null'), $widget); |
685 | 685 | } |
686 | 686 | |
687 | 687 | $oWidget = new $widget(); |
688 | - if(!is_object($oWidget)) return sprintf(Context::getLang('msg_widget_object_is_null'), $widget); |
|
688 | + if (!is_object($oWidget)) return sprintf(Context::getLang('msg_widget_object_is_null'), $widget); |
|
689 | 689 | |
690 | - if(!method_exists($oWidget, 'proc')) return sprintf(Context::getLang('msg_widget_proc_is_null'), $widget); |
|
690 | + if (!method_exists($oWidget, 'proc')) return sprintf(Context::getLang('msg_widget_proc_is_null'), $widget); |
|
691 | 691 | |
692 | 692 | $oWidget->widget_path = $path; |
693 | 693 | |
@@ -696,31 +696,31 @@ discard block |
||
696 | 696 | return $GLOBALS['_xe_loaded_widgets_'][$widget]; |
697 | 697 | } |
698 | 698 | |
699 | - function compileWidgetStyle($widgetStyle,$widget,$widget_content_body, $args, $javascript_mode) |
|
699 | + function compileWidgetStyle($widgetStyle, $widget, $widget_content_body, $args, $javascript_mode) |
|
700 | 700 | { |
701 | - if(!$widgetStyle) return $widget_content_body; |
|
701 | + if (!$widgetStyle) return $widget_content_body; |
|
702 | 702 | |
703 | 703 | $oWidgetModel = getModel('widget'); |
704 | 704 | // Bring extra_var widget style tie |
705 | 705 | $widgetstyle_info = $oWidgetModel->getWidgetStyleInfo($widgetStyle); |
706 | - if(!$widgetstyle_info) return $widget_content_body; |
|
706 | + if (!$widgetstyle_info) return $widget_content_body; |
|
707 | 707 | |
708 | 708 | $widgetstyle_extra_var = new stdClass(); |
709 | 709 | $widgetstyle_extra_var_key = get_object_vars($widgetstyle_info); |
710 | - if(count($widgetstyle_extra_var_key['extra_var'])) |
|
710 | + if (count($widgetstyle_extra_var_key['extra_var'])) |
|
711 | 711 | { |
712 | - foreach($widgetstyle_extra_var_key['extra_var'] as $key => $val) |
|
712 | + foreach ($widgetstyle_extra_var_key['extra_var'] as $key => $val) |
|
713 | 713 | { |
714 | - $widgetstyle_extra_var->{$key} = $args->{$key}; |
|
714 | + $widgetstyle_extra_var->{$key} = $args->{$key}; |
|
715 | 715 | } |
716 | 716 | } |
717 | 717 | Context::set('widgetstyle_extra_var', $widgetstyle_extra_var); |
718 | 718 | // #18994272 오타를 수정했으나 하위 호환성을 위해 남겨둠 - deprecated |
719 | 719 | Context::set('widgetstyle_extar_var', $widgetstyle_extra_var); |
720 | 720 | |
721 | - if($javascript_mode && $widget=='widgetBox') |
|
721 | + if ($javascript_mode && $widget == 'widgetBox') |
|
722 | 722 | { |
723 | - Context::set('widget_content', '<div class="widget_inner">'.$widget_content_body.'</div>'); |
|
723 | + Context::set('widget_content', '<div class="widget_inner">' . $widget_content_body . '</div>'); |
|
724 | 724 | } |
725 | 725 | else |
726 | 726 | { |
@@ -742,7 +742,7 @@ discard block |
||
742 | 742 | $oWidgetModel = getModel('widget'); |
743 | 743 | $widget_info = $oWidgetModel->getWidgetInfo($widget); |
744 | 744 | |
745 | - if(!$vars) |
|
745 | + if (!$vars) |
|
746 | 746 | { |
747 | 747 | $vars = new stdClass(); |
748 | 748 | } |
@@ -753,31 +753,31 @@ discard block |
||
753 | 753 | |
754 | 754 | $vars->skin = trim($request_vars->skin); |
755 | 755 | $vars->colorset = trim($request_vars->colorset); |
756 | - $vars->widget_sequence = (int)($request_vars->widget_sequence); |
|
757 | - $vars->widget_cache = (int)($request_vars->widget_cache); |
|
756 | + $vars->widget_sequence = (int) ($request_vars->widget_sequence); |
|
757 | + $vars->widget_cache = (int) ($request_vars->widget_cache); |
|
758 | 758 | $vars->style = trim($request_vars->style); |
759 | 759 | $vars->widget_padding_left = trim($request_vars->widget_padding_left); |
760 | 760 | $vars->widget_padding_right = trim($request_vars->widget_padding_right); |
761 | 761 | $vars->widget_padding_top = trim($request_vars->widget_padding_top); |
762 | 762 | $vars->widget_padding_bottom = trim($request_vars->widget_padding_bottom); |
763 | - $vars->document_srl= trim($request_vars->document_srl); |
|
763 | + $vars->document_srl = trim($request_vars->document_srl); |
|
764 | 764 | |
765 | - if(count($widget_info->extra_var)) |
|
765 | + if (count($widget_info->extra_var)) |
|
766 | 766 | { |
767 | - foreach($widget_info->extra_var as $key=>$val) |
|
767 | + foreach ($widget_info->extra_var as $key=>$val) |
|
768 | 768 | { |
769 | 769 | $vars->{$key} = trim($request_vars->{$key}); |
770 | 770 | } |
771 | 771 | } |
772 | 772 | // If the widget style |
773 | - if($request_vars->widgetstyle) |
|
773 | + if ($request_vars->widgetstyle) |
|
774 | 774 | { |
775 | 775 | $widgetStyle_info = $oWidgetModel->getWidgetStyleInfo($request_vars->widgetstyle); |
776 | - if(count($widgetStyle_info->extra_var)) |
|
776 | + if (count($widgetStyle_info->extra_var)) |
|
777 | 777 | { |
778 | - foreach($widgetStyle_info->extra_var as $key=>$val) |
|
778 | + foreach ($widgetStyle_info->extra_var as $key=>$val) |
|
779 | 779 | { |
780 | - if($val->type =='color' || $val->type =='text' || $val->type =='select' || $val->type =='filebox' || $val->type == 'textarea') |
|
780 | + if ($val->type == 'color' || $val->type == 'text' || $val->type == 'select' || $val->type == 'filebox' || $val->type == 'textarea') |
|
781 | 781 | { |
782 | 782 | $vars->{$key} = trim($request_vars->{$key}); |
783 | 783 | } |
@@ -785,23 +785,23 @@ discard block |
||
785 | 785 | } |
786 | 786 | } |
787 | 787 | |
788 | - if($vars->widget_sequence) |
|
788 | + if ($vars->widget_sequence) |
|
789 | 789 | { |
790 | 790 | $cache_file = sprintf('%s%d.%s.cache', $this->cache_path, $vars->widget_sequence, Context::getLangType()); |
791 | 791 | FileHandler::removeFile($cache_file); |
792 | 792 | } |
793 | 793 | |
794 | - if($vars->widget_cache>0) $vars->widget_sequence = getNextSequence(); |
|
794 | + if ($vars->widget_cache > 0) $vars->widget_sequence = getNextSequence(); |
|
795 | 795 | |
796 | 796 | $attribute = array(); |
797 | - foreach($vars as $key => $val) |
|
797 | + foreach ($vars as $key => $val) |
|
798 | 798 | { |
799 | - if(!$val) |
|
799 | + if (!$val) |
|
800 | 800 | { |
801 | 801 | unset($vars->{$key}); |
802 | 802 | continue; |
803 | 803 | } |
804 | - if(strpos($val,'|@|') > 0) $val = str_replace('|@|', ',', $val); |
|
804 | + if (strpos($val, '|@|') > 0) $val = str_replace('|@|', ',', $val); |
|
805 | 805 | $vars->{$key} = Context::convertEncodingStr($val); |
806 | 806 | $attribute[] = sprintf('%s="%s"', $key, htmlspecialchars(Context::convertEncodingStr($val), ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
807 | 807 | } |
@@ -40,7 +40,9 @@ discard block |
||
40 | 40 | $colorset_list[] = $colorset; |
41 | 41 | } |
42 | 42 | |
43 | - if(count($colorset_list)) $colorsets = implode("\n", $colorset_list); |
|
43 | + if(count($colorset_list)) { |
|
44 | + $colorsets = implode("\n", $colorset_list); |
|
45 | + } |
|
44 | 46 | $this->add('colorset_list', $colorsets); |
45 | 47 | } |
46 | 48 | |
@@ -50,8 +52,12 @@ discard block |
||
50 | 52 | function procWidgetGenerateCode() |
51 | 53 | { |
52 | 54 | $widget = Context::get('selected_widget'); |
53 | - if(!$widget) return new Object(-1,'msg_invalid_request'); |
|
54 | - if(!Context::get('skin')) return new Object(-1,Context::getLang('msg_widget_skin_is_null')); |
|
55 | + if(!$widget) { |
|
56 | + return new Object(-1,'msg_invalid_request'); |
|
57 | + } |
|
58 | + if(!Context::get('skin')) { |
|
59 | + return new Object(-1,Context::getLang('msg_widget_skin_is_null')); |
|
60 | + } |
|
55 | 61 | |
56 | 62 | $attribute = $this->arrangeWidgetVars($widget, Context::getRequestVars(), $vars); |
57 | 63 | |
@@ -66,9 +72,13 @@ discard block |
||
66 | 72 | function procWidgetGenerateCodeInPage() |
67 | 73 | { |
68 | 74 | $widget = Context::get('selected_widget'); |
69 | - if(!$widget) return new Object(-1,'msg_invalid_request'); |
|
75 | + if(!$widget) { |
|
76 | + return new Object(-1,'msg_invalid_request'); |
|
77 | + } |
|
70 | 78 | |
71 | - if(!in_array($widget,array('widgetBox','widgetContent')) && !Context::get('skin')) return new Object(-1,Context::getLang('msg_widget_skin_is_null')); |
|
79 | + if(!in_array($widget,array('widgetBox','widgetContent')) && !Context::get('skin')) { |
|
80 | + return new Object(-1,Context::getLang('msg_widget_skin_is_null')); |
|
81 | + } |
|
72 | 82 | |
73 | 83 | $attribute = $this->arrangeWidgetVars($widget, Context::getRequestVars(), $vars); |
74 | 84 | // Wanted results |
@@ -107,14 +117,20 @@ discard block |
||
107 | 117 | $err = 0; |
108 | 118 | $oLayoutModel = getModel('layout'); |
109 | 119 | $layout_info = $oLayoutModel->getLayout($module_srl); |
110 | - if(!$layout_info || $layout_info->type != 'faceoff') $err++; |
|
120 | + if(!$layout_info || $layout_info->type != 'faceoff') { |
|
121 | + $err++; |
|
122 | + } |
|
111 | 123 | // Destination Information Wanted page module |
112 | 124 | $oModuleModel = getModel('module'); |
113 | 125 | $columnList = array('module_srl', 'module'); |
114 | 126 | $page_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
115 | - if(!$page_info->module_srl || $page_info->module != 'page') $err++; |
|
127 | + if(!$page_info->module_srl || $page_info->module != 'page') { |
|
128 | + $err++; |
|
129 | + } |
|
116 | 130 | |
117 | - if($err > 1) return new Object(-1,'msg_invalid_request'); |
|
131 | + if($err > 1) { |
|
132 | + return new Object(-1,'msg_invalid_request'); |
|
133 | + } |
|
118 | 134 | // Check permissions |
119 | 135 | $is_logged = Context::get('is_logged'); |
120 | 136 | $logged_info = Context::get('logged_info'); |
@@ -125,10 +141,14 @@ discard block |
||
125 | 141 | $manager_group = $page_info->grants['manager']; |
126 | 142 | foreach($user_group as $group_srl => $group_info) |
127 | 143 | { |
128 | - if(in_array($group_srl, $manager_group)) $is_admin = true; |
|
144 | + if(in_array($group_srl, $manager_group)) { |
|
145 | + $is_admin = true; |
|
146 | + } |
|
129 | 147 | } |
130 | 148 | } |
131 | - if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) return new Object(-1,'msg_not_permitted'); |
|
149 | + if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) { |
|
150 | + return new Object(-1,'msg_not_permitted'); |
|
151 | + } |
|
132 | 152 | // Enter post |
133 | 153 | $oDocumentModel = getModel('document'); |
134 | 154 | $oDocumentController = getController('document'); |
@@ -142,14 +162,15 @@ discard block |
||
142 | 162 | if($oDocument->isExists() && $oDocument->document_srl == $obj->document_srl) |
143 | 163 | { |
144 | 164 | $output = $oDocumentController->updateDocument($oDocument, $obj); |
145 | - } |
|
146 | - else |
|
165 | + } else |
|
147 | 166 | { |
148 | 167 | $output = $oDocumentController->insertDocument($obj); |
149 | 168 | $obj->document_srl = $output->get('document_srl'); |
150 | 169 | } |
151 | 170 | // Stop when an error occurs |
152 | - if(!$output->toBool()) return $output; |
|
171 | + if(!$output->toBool()) { |
|
172 | + return $output; |
|
173 | + } |
|
153 | 174 | // Return results |
154 | 175 | $this->add('document_srl', $obj->document_srl); |
155 | 176 | } |
@@ -167,13 +188,17 @@ discard block |
||
167 | 188 | $oDocumentAdminController = getAdminController('document'); |
168 | 189 | |
169 | 190 | $oDocument = $oDocumentModel->getDocument($document_srl, true); |
170 | - if(!$oDocument->isExists()) return new Object(-1,'msg_invalid_request'); |
|
191 | + if(!$oDocument->isExists()) { |
|
192 | + return new Object(-1,'msg_invalid_request'); |
|
193 | + } |
|
171 | 194 | $module_srl = $oDocument->get('module_srl'); |
172 | 195 | // Destination Information Wanted page module |
173 | 196 | $oModuleModel = getModel('module'); |
174 | 197 | $columnList = array('module_srl', 'module'); |
175 | 198 | $page_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl, $columnList); |
176 | - if(!$page_info->module_srl || $page_info->module != 'page') return new Object(-1,'msg_invalid_request'); |
|
199 | + if(!$page_info->module_srl || $page_info->module != 'page') { |
|
200 | + return new Object(-1,'msg_invalid_request'); |
|
201 | + } |
|
177 | 202 | // Check permissions |
178 | 203 | $is_logged = Context::get('is_logged'); |
179 | 204 | $logged_info = Context::get('logged_info'); |
@@ -184,13 +209,19 @@ discard block |
||
184 | 209 | $manager_group = $page_info->grants['manager']; |
185 | 210 | foreach($user_group as $group_srl => $group_info) |
186 | 211 | { |
187 | - if(in_array($group_srl, $manager_group)) $is_admin = true; |
|
212 | + if(in_array($group_srl, $manager_group)) { |
|
213 | + $is_admin = true; |
|
214 | + } |
|
188 | 215 | } |
189 | 216 | } |
190 | - if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) return new Object(-1,'msg_not_permitted'); |
|
217 | + if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) { |
|
218 | + return new Object(-1,'msg_not_permitted'); |
|
219 | + } |
|
191 | 220 | |
192 | 221 | $output = $oDocumentAdminController->copyDocumentModule(array($oDocument->get('document_srl')), $oDocument->get('module_srl'),0); |
193 | - if(!$output->toBool()) return $output; |
|
222 | + if(!$output->toBool()) { |
|
223 | + return $output; |
|
224 | + } |
|
194 | 225 | // Return results |
195 | 226 | $copied_srls = $output->get('copied_srls'); |
196 | 227 | $this->add('document_srl', $copied_srls[$oDocument->get('document_srl')]); |
@@ -208,12 +239,16 @@ discard block |
||
208 | 239 | $oDocumentController = getController('document'); |
209 | 240 | |
210 | 241 | $oDocument = $oDocumentModel->getDocument($document_srl, true); |
211 | - if(!$oDocument->isExists()) return new Object(); |
|
242 | + if(!$oDocument->isExists()) { |
|
243 | + return new Object(); |
|
244 | + } |
|
212 | 245 | $module_srl = $oDocument->get('module_srl'); |
213 | 246 | // Destination Information Wanted page module |
214 | 247 | $oModuleModel = getModel('module'); |
215 | 248 | $page_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl); |
216 | - if(!$page_info->module_srl || $page_info->module != 'page') return new Object(-1,'msg_invalid_request'); |
|
249 | + if(!$page_info->module_srl || $page_info->module != 'page') { |
|
250 | + return new Object(-1,'msg_invalid_request'); |
|
251 | + } |
|
217 | 252 | // Check permissions |
218 | 253 | $is_logged = Context::get('is_logged'); |
219 | 254 | $logged_info = Context::get('logged_info'); |
@@ -224,13 +259,19 @@ discard block |
||
224 | 259 | $manager_group = $page_info->grants['manager']; |
225 | 260 | foreach($user_group as $group_srl => $group_info) |
226 | 261 | { |
227 | - if(in_array($group_srl, $manager_group)) $is_admin = true; |
|
262 | + if(in_array($group_srl, $manager_group)) { |
|
263 | + $is_admin = true; |
|
264 | + } |
|
228 | 265 | } |
229 | 266 | } |
230 | - if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) return new Object(-1,'msg_not_permitted'); |
|
267 | + if(!$is_admin && !$is_logged && $logged_info->is_admin != 'Y' && !$oModuleModel->isSiteAdmin($logged_info) && !(is_array($page_info->admin_id) && in_array($logged_info->user_id, $page_info->admin_id))) { |
|
268 | + return new Object(-1,'msg_not_permitted'); |
|
269 | + } |
|
231 | 270 | |
232 | 271 | $output = $oDocumentController->deleteDocument($oDocument->get('document_srl'), true); |
233 | - if(!$output->toBool()) return $output; |
|
272 | + if(!$output->toBool()) { |
|
273 | + return $output; |
|
274 | + } |
|
234 | 275 | } |
235 | 276 | |
236 | 277 | /** |
@@ -247,7 +288,9 @@ discard block |
||
247 | 288 | */ |
248 | 289 | function triggerWidgetCompile(&$content) |
249 | 290 | { |
250 | - if(Context::getResponseMethod()!='HTML') return new Object(); |
|
291 | + if(Context::getResponseMethod()!='HTML') { |
|
292 | + return new Object(); |
|
293 | + } |
|
251 | 294 | $content = $this->transWidgetCode($content, $this->layout_javascript_mode); |
252 | 295 | return new Object(); |
253 | 296 | } |
@@ -280,11 +323,16 @@ discard block |
||
280 | 323 | $oXmlParser = new XmlParser(); |
281 | 324 | $xml_doc = $oXmlParser->parse(trim($buff)); |
282 | 325 | |
283 | - if($xml_doc->img) $vars = $xml_doc->img->attrs; |
|
284 | - else $vars = $xml_doc->attrs; |
|
326 | + if($xml_doc->img) { |
|
327 | + $vars = $xml_doc->img->attrs; |
|
328 | + } else { |
|
329 | + $vars = $xml_doc->attrs; |
|
330 | + } |
|
285 | 331 | |
286 | 332 | $widget = $vars->widget; |
287 | - if(!$widget) return $matches[0]; |
|
333 | + if(!$widget) { |
|
334 | + return $matches[0]; |
|
335 | + } |
|
288 | 336 | unset($vars->widget); |
289 | 337 | |
290 | 338 | return $this->execute($widget, $vars, $this->javascript_mode); |
@@ -301,7 +349,9 @@ discard block |
||
301 | 349 | |
302 | 350 | $vars = $xml_doc->div->attrs; |
303 | 351 | $widget = $vars->widget; |
304 | - if(!$widget) return $matches[0]; |
|
352 | + if(!$widget) { |
|
353 | + return $matches[0]; |
|
354 | + } |
|
305 | 355 | unset($vars->widget); |
306 | 356 | |
307 | 357 | $vars->widgetbox_content = $matches[3]; |
@@ -328,22 +378,30 @@ discard block |
||
328 | 378 | $xml_doc = $oXmlParser->parse(trim($buff)); |
329 | 379 | |
330 | 380 | $args = $xml_doc->img->attrs; |
331 | - if(!$args) continue; |
|
381 | + if(!$args) { |
|
382 | + continue; |
|
383 | + } |
|
332 | 384 | // If you are not caching path |
333 | 385 | $widget = $args->widget; |
334 | 386 | $sequence = $args->widget_sequence; |
335 | 387 | $cache = $args->widget_cache; |
336 | - if(!$sequence || !$cache) continue; |
|
388 | + if(!$sequence || !$cache) { |
|
389 | + continue; |
|
390 | + } |
|
337 | 391 | |
338 | 392 | if(count($args)) |
339 | 393 | { |
340 | - foreach($args as $k => $v) $args->{$k} = urldecode($v); |
|
394 | + foreach($args as $k => $v) { |
|
395 | + $args->{$k} = urldecode($v); |
|
396 | + } |
|
341 | 397 | } |
342 | 398 | // If the cache file for each language widget regeneration |
343 | 399 | foreach($lang_list as $lang_type => $val) |
344 | 400 | { |
345 | 401 | $cache_file = sprintf('%s%d.%s.cache', $this->cache_path, $sequence, $lang_type); |
346 | - if(!file_exists($cache_file)) continue; |
|
402 | + if(!file_exists($cache_file)) { |
|
403 | + continue; |
|
404 | + } |
|
347 | 405 | $this->getCache($widget, $args, $lang_type, true); |
348 | 406 | } |
349 | 407 | } |
@@ -355,7 +413,9 @@ discard block |
||
355 | 413 | function getCache($widget, $args, $lang_type = null, $ignore_cache = false) |
356 | 414 | { |
357 | 415 | // If the specified language specifies the current language |
358 | - if(!$lang_type) $lang_type = Context::getLangType(); |
|
416 | + if(!$lang_type) { |
|
417 | + $lang_type = Context::getLangType(); |
|
418 | + } |
|
359 | 419 | // widget, the cache number and cache values are set |
360 | 420 | $widget_sequence = $args->widget_sequence; |
361 | 421 | $widget_cache = $args->widget_cache; |
@@ -366,7 +426,9 @@ discard block |
||
366 | 426 | if(!$ignore_cache && (!$widget_cache || !$widget_sequence)) |
367 | 427 | { |
368 | 428 | $oWidget = $this->getWidgetObject($widget); |
369 | - if(!$oWidget || !method_exists($oWidget, 'proc')) return; |
|
429 | + if(!$oWidget || !method_exists($oWidget, 'proc')) { |
|
430 | + return; |
|
431 | + } |
|
370 | 432 | |
371 | 433 | $widget_content = $oWidget->proc($args); |
372 | 434 | $oModuleController = getController('module'); |
@@ -386,8 +448,7 @@ discard block |
||
386 | 448 | if($cache_body) |
387 | 449 | { |
388 | 450 | return $cache_body; |
389 | - } |
|
390 | - else |
|
451 | + } else |
|
391 | 452 | { |
392 | 453 | /** |
393 | 454 | * Cache number and cache values are set so that the cache file should call |
@@ -415,7 +476,9 @@ discard block |
||
415 | 476 | } |
416 | 477 | |
417 | 478 | $oWidget = $this->getWidgetObject($widget); |
418 | - if(!$oWidget || !method_exists($oWidget,'proc')) return; |
|
479 | + if(!$oWidget || !method_exists($oWidget,'proc')) { |
|
480 | + return; |
|
481 | + } |
|
419 | 482 | |
420 | 483 | $widget_content = $oWidget->proc($args); |
421 | 484 | $oModuleController = getController('module'); |
@@ -423,8 +486,7 @@ discard block |
||
423 | 486 | if($oCacheHandler->isSupport()) |
424 | 487 | { |
425 | 488 | $oCacheHandler->put($key, $widget_content, $widget_cache * 60); |
426 | - } |
|
427 | - else |
|
489 | + } else |
|
428 | 490 | { |
429 | 491 | FileHandler::writeFile($cache_file, $widget_content); |
430 | 492 | } |
@@ -442,7 +504,9 @@ discard block |
||
442 | 504 | function execute($widget, $args, $javascript_mode = false, $escaped = true) |
443 | 505 | { |
444 | 506 | // Save for debug run-time widget |
445 | - if(__DEBUG__==3) $start = getMicroTime(); |
|
507 | + if(__DEBUG__==3) { |
|
508 | + $start = getMicroTime(); |
|
509 | + } |
|
446 | 510 | $before = microtime(true); |
447 | 511 | // urldecode the value of args haejum |
448 | 512 | $object_vars = get_object_vars($args); |
@@ -450,8 +514,12 @@ discard block |
||
450 | 514 | { |
451 | 515 | foreach($object_vars as $key => $val) |
452 | 516 | { |
453 | - if(in_array($key, array('widgetbox_content','body','class','style','widget_sequence','widget','widget_padding_left','widget_padding_top','widget_padding_bottom','widget_padding_right','widgetstyle','document_srl'))) continue; |
|
454 | - if($escaped) $args->{$key} = utf8RawUrlDecode($val); |
|
517 | + if(in_array($key, array('widgetbox_content','body','class','style','widget_sequence','widget','widget_padding_left','widget_padding_top','widget_padding_bottom','widget_padding_right','widgetstyle','document_srl'))) { |
|
518 | + continue; |
|
519 | + } |
|
520 | + if($escaped) { |
|
521 | + $args->{$key} = utf8RawUrlDecode($val); |
|
522 | + } |
|
455 | 523 | } |
456 | 524 | } |
457 | 525 | |
@@ -462,7 +530,9 @@ discard block |
||
462 | 530 | $widget_content = ''; |
463 | 531 | if($widget != 'widgetContent' && $widget != 'widgetBox') |
464 | 532 | { |
465 | - if(!is_dir(sprintf(_XE_PATH_.'widgets/%s/',$widget))) return; |
|
533 | + if(!is_dir(sprintf(_XE_PATH_.'widgets/%s/',$widget))) { |
|
534 | + return; |
|
535 | + } |
|
466 | 536 | // Hold the contents of the widget parameter |
467 | 537 | $widget_content = $this->getCache($widget, $args); |
468 | 538 | } |
@@ -494,7 +564,9 @@ discard block |
||
494 | 564 | // If general call is given on page styles should return immediately dreamin ' |
495 | 565 | if(!$javascript_mode) |
496 | 566 | { |
497 | - if($args->id) $args->id = ' id="'.$args->id.'" '; |
|
567 | + if($args->id) { |
|
568 | + $args->id = ' id="'.$args->id.'" '; |
|
569 | + } |
|
498 | 570 | switch($widget) |
499 | 571 | { |
500 | 572 | // If a direct orthogonal addition information |
@@ -504,8 +576,7 @@ discard block |
||
504 | 576 | $oDocumentModel = getModel('document'); |
505 | 577 | $oDocument = $oDocumentModel->getDocument($args->document_srl); |
506 | 578 | $body = $oDocument->getContent(false,false,false, false); |
507 | - } |
|
508 | - else |
|
579 | + } else |
|
509 | 580 | { |
510 | 581 | $body = base64_decode($args->body); |
511 | 582 | } |
@@ -532,8 +603,7 @@ discard block |
||
532 | 603 | break; |
533 | 604 | } |
534 | 605 | // Edit page is called when a widget if you add the code for handling |
535 | - } |
|
536 | - else |
|
606 | + } else |
|
537 | 607 | { |
538 | 608 | switch($widget) |
539 | 609 | { |
@@ -544,8 +614,7 @@ discard block |
||
544 | 614 | $oDocumentModel = getModel('document'); |
545 | 615 | $oDocument = $oDocumentModel->getDocument($args->document_srl); |
546 | 616 | $body = $oDocument->getContent(false,false,false); |
547 | - } |
|
548 | - else |
|
617 | + } else |
|
549 | 618 | { |
550 | 619 | $body = base64_decode($args->body); |
551 | 620 | } |
@@ -555,8 +624,12 @@ discard block |
||
555 | 624 | { |
556 | 625 | foreach($args as $key => $val) |
557 | 626 | { |
558 | - if(in_array($key, array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget','widgetstyle','document_srl'))) continue; |
|
559 | - if(strpos($val,'|@|')>0) $val = str_replace('|@|',',',$val); |
|
627 | + if(in_array($key, array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget','widgetstyle','document_srl'))) { |
|
628 | + continue; |
|
629 | + } |
|
630 | + if(strpos($val,'|@|')>0) { |
|
631 | + $val = str_replace('|@|',',',$val); |
|
632 | + } |
|
560 | 633 | $attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
561 | 634 | } |
562 | 635 | } |
@@ -590,9 +663,15 @@ discard block |
||
590 | 663 | { |
591 | 664 | foreach($args as $key => $val) |
592 | 665 | { |
593 | - if(in_array($key, array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget','widgetstyle','document_srl'))) continue; |
|
594 | - if(!is_numeric($val) && (!is_string($val) || strlen($val)==0)) continue; |
|
595 | - if(strpos($val,'|@|')>0) $val = str_replace('|@|',',',$val); |
|
666 | + if(in_array($key, array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget','widgetstyle','document_srl'))) { |
|
667 | + continue; |
|
668 | + } |
|
669 | + if(!is_numeric($val) && (!is_string($val) || strlen($val)==0)) { |
|
670 | + continue; |
|
671 | + } |
|
672 | + if(strpos($val,'|@|')>0) { |
|
673 | + $val = str_replace('|@|',',',$val); |
|
674 | + } |
|
596 | 675 | $attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
597 | 676 | } |
598 | 677 | } |
@@ -615,9 +694,15 @@ discard block |
||
615 | 694 | $allowed_key = array('class','style','widget_padding_top','widget_padding_right','widget_padding_bottom','widget_padding_left','widget'); |
616 | 695 | foreach($args as $key => $val) |
617 | 696 | { |
618 | - if(in_array($key, $allowed_key)) continue; |
|
619 | - if(!is_numeric($val) && (!is_string($val) || strlen($val)==0)) continue; |
|
620 | - if(strpos($val,'|@|')>0) $val = str_replace('|@|',',',$val); |
|
697 | + if(in_array($key, $allowed_key)) { |
|
698 | + continue; |
|
699 | + } |
|
700 | + if(!is_numeric($val) && (!is_string($val) || strlen($val)==0)) { |
|
701 | + continue; |
|
702 | + } |
|
703 | + if(strpos($val,'|@|')>0) { |
|
704 | + $val = str_replace('|@|',',',$val); |
|
705 | + } |
|
621 | 706 | $attribute[] = sprintf('%s="%s"', $key, htmlspecialchars($val, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
622 | 707 | } |
623 | 708 | } |
@@ -637,11 +722,15 @@ discard block |
||
637 | 722 | } |
638 | 723 | } |
639 | 724 | // Compile the widget style. |
640 | - if($args->widgetstyle) $widget_content_body = $this->compileWidgetStyle($args->widgetstyle,$widget, $widget_content_body, $args, $javascript_mode); |
|
725 | + if($args->widgetstyle) { |
|
726 | + $widget_content_body = $this->compileWidgetStyle($args->widgetstyle,$widget, $widget_content_body, $args, $javascript_mode); |
|
727 | + } |
|
641 | 728 | |
642 | 729 | $output = $widget_content_header . $widget_content_body . $widget_content_footer; |
643 | 730 | // Debug widget creation time information added to the results |
644 | - if(__DEBUG__==3) $GLOBALS['__widget_excute_elapsed__'] += getMicroTime() - $start; |
|
731 | + if(__DEBUG__==3) { |
|
732 | + $GLOBALS['__widget_excute_elapsed__'] += getMicroTime() - $start; |
|
733 | + } |
|
645 | 734 | |
646 | 735 | $after = microtime(true); |
647 | 736 | |
@@ -674,7 +763,9 @@ discard block |
||
674 | 763 | $path = $oWidgetModel->getWidgetPath($widget); |
675 | 764 | // If you do not find the class file error output widget (html output) |
676 | 765 | $class_file = sprintf('%s%s.class.php', $path, $widget); |
677 | - if(!file_exists($class_file)) return sprintf(Context::getLang('msg_widget_is_not_exists'), $widget); |
|
766 | + if(!file_exists($class_file)) { |
|
767 | + return sprintf(Context::getLang('msg_widget_is_not_exists'), $widget); |
|
768 | + } |
|
678 | 769 | // Widget classes include |
679 | 770 | require_once($class_file); |
680 | 771 | |
@@ -685,9 +776,13 @@ discard block |
||
685 | 776 | } |
686 | 777 | |
687 | 778 | $oWidget = new $widget(); |
688 | - if(!is_object($oWidget)) return sprintf(Context::getLang('msg_widget_object_is_null'), $widget); |
|
779 | + if(!is_object($oWidget)) { |
|
780 | + return sprintf(Context::getLang('msg_widget_object_is_null'), $widget); |
|
781 | + } |
|
689 | 782 | |
690 | - if(!method_exists($oWidget, 'proc')) return sprintf(Context::getLang('msg_widget_proc_is_null'), $widget); |
|
783 | + if(!method_exists($oWidget, 'proc')) { |
|
784 | + return sprintf(Context::getLang('msg_widget_proc_is_null'), $widget); |
|
785 | + } |
|
691 | 786 | |
692 | 787 | $oWidget->widget_path = $path; |
693 | 788 | |
@@ -698,12 +793,16 @@ discard block |
||
698 | 793 | |
699 | 794 | function compileWidgetStyle($widgetStyle,$widget,$widget_content_body, $args, $javascript_mode) |
700 | 795 | { |
701 | - if(!$widgetStyle) return $widget_content_body; |
|
796 | + if(!$widgetStyle) { |
|
797 | + return $widget_content_body; |
|
798 | + } |
|
702 | 799 | |
703 | 800 | $oWidgetModel = getModel('widget'); |
704 | 801 | // Bring extra_var widget style tie |
705 | 802 | $widgetstyle_info = $oWidgetModel->getWidgetStyleInfo($widgetStyle); |
706 | - if(!$widgetstyle_info) return $widget_content_body; |
|
803 | + if(!$widgetstyle_info) { |
|
804 | + return $widget_content_body; |
|
805 | + } |
|
707 | 806 | |
708 | 807 | $widgetstyle_extra_var = new stdClass(); |
709 | 808 | $widgetstyle_extra_var_key = get_object_vars($widgetstyle_info); |
@@ -721,8 +820,7 @@ discard block |
||
721 | 820 | if($javascript_mode && $widget=='widgetBox') |
722 | 821 | { |
723 | 822 | Context::set('widget_content', '<div class="widget_inner">'.$widget_content_body.'</div>'); |
724 | - } |
|
725 | - else |
|
823 | + } else |
|
726 | 824 | { |
727 | 825 | Context::set('widget_content', $widget_content_body); |
728 | 826 | } |
@@ -791,7 +889,9 @@ discard block |
||
791 | 889 | FileHandler::removeFile($cache_file); |
792 | 890 | } |
793 | 891 | |
794 | - if($vars->widget_cache>0) $vars->widget_sequence = getNextSequence(); |
|
892 | + if($vars->widget_cache>0) { |
|
893 | + $vars->widget_sequence = getNextSequence(); |
|
894 | + } |
|
795 | 895 | |
796 | 896 | $attribute = array(); |
797 | 897 | foreach($vars as $key => $val) |
@@ -801,7 +901,9 @@ discard block |
||
801 | 901 | unset($vars->{$key}); |
802 | 902 | continue; |
803 | 903 | } |
804 | - if(strpos($val,'|@|') > 0) $val = str_replace('|@|', ',', $val); |
|
904 | + if(strpos($val,'|@|') > 0) { |
|
905 | + $val = str_replace('|@|', ',', $val); |
|
906 | + } |
|
805 | 907 | $vars->{$key} = Context::convertEncodingStr($val); |
806 | 908 | $attribute[] = sprintf('%s="%s"', $key, htmlspecialchars(Context::convertEncodingStr($val), ENT_COMPAT | ENT_HTML401, 'UTF-8', false)); |
807 | 909 | } |
@@ -27,6 +27,11 @@ discard block |
||
27 | 27 | |
28 | 28 | // recursive glob |
29 | 29 | // On Windows glob() is case-sensitive. |
30 | + |
|
31 | + /** |
|
32 | + * @param string $sDir |
|
33 | + * @param integer $nFlags |
|
34 | + */ |
|
30 | 35 | public function globr($sDir, $sPattern, $nFlags = NULL) |
31 | 36 | { |
32 | 37 | // Get the list of all matching files currently in the |
@@ -129,6 +134,9 @@ discard block |
||
129 | 134 | $this->markTestIncomplete('XML Schema Language files should be fixed first.'); |
130 | 135 | } |
131 | 136 | |
137 | + /** |
|
138 | + * @param integer $err_code |
|
139 | + */ |
|
132 | 140 | public function invoke_testInvalidXmlFiles($filename, $err_code, $args = '') |
133 | 141 | { |
134 | 142 | $cmd = $this->validator_cmd . ' '. $args . ' ' . escapeshellarg($filename); |
@@ -166,6 +174,9 @@ discard block |
||
166 | 174 | return $this->invoke_testInvalidXmlFiles($filename, self::RETCODE_BUILTIN_CHECKS); |
167 | 175 | } |
168 | 176 | |
177 | + /** |
|
178 | + * @param string $dir_name |
|
179 | + */ |
|
169 | 180 | public function getDirFilesList($dir_name) |
170 | 181 | { |
171 | 182 | $output = array(); |
@@ -2,33 +2,33 @@ discard block |
||
2 | 2 | /* Copyright (C) NAVER <http://www.navercorp.com> */ |
3 | 3 | |
4 | 4 | if (!defined('__DIR__')) |
5 | - define('__DIR__', realpath(dirname(__FILE__))); |
|
5 | + define('__DIR__', realpath(dirname(__FILE__))); |
|
6 | 6 | |
7 | 7 | /** The tests here are meant only for the built-in checks in validator.php, |
8 | 8 | and not for the entire syntax expressed by the .xsd files. */ |
9 | 9 | class XmlQueriesTest extends PHPUnit_Framework_TestCase |
10 | 10 | { |
11 | - // taken from validator.php |
|
11 | + // taken from validator.php |
|
12 | 12 | |
13 | - const RETCODE_VALIDATOR_INTERNAL = 60; |
|
14 | - const RETCODE_GENERIC_XML_SYNTAX = 50; |
|
15 | - const RETCODE_QUERY_ELEMENT = 40; |
|
16 | - const RETCODE_XSD_VALIDATION = 30; |
|
17 | - const RETCODE_BUILTIN_CHECKS = 20; |
|
18 | - const RETCODE_DB_SCHEMA_MATCH =10; // no schema match is currently implemented. |
|
19 | - const RETCODE_SUCCESS = 0; |
|
13 | + const RETCODE_VALIDATOR_INTERNAL = 60; |
|
14 | + const RETCODE_GENERIC_XML_SYNTAX = 50; |
|
15 | + const RETCODE_QUERY_ELEMENT = 40; |
|
16 | + const RETCODE_XSD_VALIDATION = 30; |
|
17 | + const RETCODE_BUILTIN_CHECKS = 20; |
|
18 | + const RETCODE_DB_SCHEMA_MATCH =10; // no schema match is currently implemented. |
|
19 | + const RETCODE_SUCCESS = 0; |
|
20 | 20 | |
21 | - public $validator_cmd; |
|
21 | + public $validator_cmd; |
|
22 | 22 | |
23 | - public function setUp() |
|
24 | - { |
|
23 | + public function setUp() |
|
24 | + { |
|
25 | 25 | $this->validator_cmd = "php " . escapeshellarg(__DIR__ . '/../validate.php') . " "; |
26 | - } |
|
26 | + } |
|
27 | 27 | |
28 | - // recursive glob |
|
29 | - // On Windows glob() is case-sensitive. |
|
30 | - public function globr($sDir, $sPattern, $nFlags = NULL) |
|
31 | - { |
|
28 | + // recursive glob |
|
29 | + // On Windows glob() is case-sensitive. |
|
30 | + public function globr($sDir, $sPattern, $nFlags = NULL) |
|
31 | + { |
|
32 | 32 | // Get the list of all matching files currently in the |
33 | 33 | // directory. |
34 | 34 | |
@@ -41,25 +41,25 @@ discard block |
||
41 | 41 | |
42 | 42 | foreach ($aDirs as $sSubDir) |
43 | 43 | { |
44 | - if ($sSubDir != '.' && $sSubDir != '..') |
|
45 | - { |
|
44 | + if ($sSubDir != '.' && $sSubDir != '..') |
|
45 | + { |
|
46 | 46 | $aSubFiles = $this->globr($sSubDir, $sPattern, $nFlags); |
47 | 47 | $aFiles = array_merge($aFiles, $aSubFiles); |
48 | - } |
|
48 | + } |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | // return merged array with all (recursive) files |
52 | 52 | return $aFiles; |
53 | - } |
|
53 | + } |
|
54 | 54 | |
55 | - /** Tests all XML Query and Schema Language files (in all modules/addons/widgets) in XE */ |
|
56 | - public function invoke_testReleasedXMLLangFiles |
|
55 | + /** Tests all XML Query and Schema Language files (in all modules/addons/widgets) in XE */ |
|
56 | + public function invoke_testReleasedXMLLangFiles |
|
57 | 57 | ( |
58 | - $released_files, |
|
59 | - $expected_return_code, |
|
60 | - $validator_args = '' |
|
58 | + $released_files, |
|
59 | + $expected_return_code, |
|
60 | + $validator_args = '' |
|
61 | 61 | ) |
62 | - { |
|
62 | + { |
|
63 | 63 | // this file is in tools/dbxml_validator/tests |
64 | 64 | $xe_dir = __DIR__ . '/../../..'; |
65 | 65 | |
@@ -70,67 +70,67 @@ discard block |
||
70 | 70 | $xml_files = array(); |
71 | 71 | |
72 | 72 | foreach ($released_files as $released_file_mask) |
73 | - $xml_files = |
|
73 | + $xml_files = |
|
74 | 74 | array_merge |
75 | 75 | ( |
76 | - $xml_files, |
|
77 | - $this->globr |
|
76 | + $xml_files, |
|
77 | + $this->globr |
|
78 | 78 | ( |
79 | - $xe_dir, |
|
80 | - $released_file_mask, |
|
81 | - GLOB_NOSORT | GLOB_NOESCAPE | GLOB_ERR |
|
79 | + $xe_dir, |
|
80 | + $released_file_mask, |
|
81 | + GLOB_NOSORT | GLOB_NOESCAPE | GLOB_ERR |
|
82 | 82 | ) |
83 | 83 | ); |
84 | 84 | |
85 | 85 | while ($cnt < count($xml_files)) |
86 | 86 | { |
87 | - $cmd = $this->validator_cmd . $validator_args; |
|
87 | + $cmd = $this->validator_cmd . $validator_args; |
|
88 | 88 | |
89 | - // Validate 50 files at once |
|
90 | - foreach (array_slice($xml_files, $cnt, 50) as $xml_file) |
|
89 | + // Validate 50 files at once |
|
90 | + foreach (array_slice($xml_files, $cnt, 50) as $xml_file) |
|
91 | 91 | $cmd .= " " . escapeshellarg($xml_file); |
92 | 92 | |
93 | - exec($cmd . ' 2>&1', $validator_output, $return_code); |
|
93 | + exec($cmd . ' 2>&1', $validator_output, $return_code); |
|
94 | 94 | |
95 | - $output_text = trim(trim(implode("\n", $validator_output)), "\n"); |
|
95 | + $output_text = trim(trim(implode("\n", $validator_output)), "\n"); |
|
96 | 96 | |
97 | - // Validator should not crash/exit-with-an-error. |
|
98 | - $this->assertLessThanOrEqual |
|
97 | + // Validator should not crash/exit-with-an-error. |
|
98 | + $this->assertLessThanOrEqual |
|
99 | 99 | ( |
100 | - $expected_return_code, |
|
101 | - $return_code, |
|
102 | - "{$cmd}\n\n{$output_text}\nValidator returned code {$return_code}." |
|
100 | + $expected_return_code, |
|
101 | + $return_code, |
|
102 | + "{$cmd}\n\n{$output_text}\nValidator returned code {$return_code}." |
|
103 | 103 | ); |
104 | 104 | |
105 | - $cnt += 50; |
|
105 | + $cnt += 50; |
|
106 | + } |
|
106 | 107 | } |
107 | - } |
|
108 | 108 | |
109 | - public function testReleasedXMLQueryLangFiles() |
|
110 | - { |
|
109 | + public function testReleasedXMLQueryLangFiles() |
|
110 | + { |
|
111 | 111 | $this->invoke_testReleasedXMLLangFiles |
112 | - ( |
|
112 | + ( |
|
113 | 113 | array('queries/*.xml', 'xml_query/*.xml'), |
114 | 114 | self::RETCODE_QUERY_ELEMENT |
115 | - ); |
|
115 | + ); |
|
116 | 116 | |
117 | 117 | $this->markTestIncomplete('XML Query Language files should be fixed first.'); |
118 | - } |
|
118 | + } |
|
119 | 119 | |
120 | - public function testReleasedXMLSchemaLangFiles() |
|
121 | - { |
|
120 | + public function testReleasedXMLSchemaLangFiles() |
|
121 | + { |
|
122 | 122 | $this->invoke_testReleasedXMLLangFiles |
123 | - ( |
|
123 | + ( |
|
124 | 124 | array('schemas/*.xml'), |
125 | 125 | self::RETCODE_BUILTIN_CHECKS, |
126 | 126 | ' --schema-language' |
127 | - ); |
|
127 | + ); |
|
128 | 128 | |
129 | 129 | $this->markTestIncomplete('XML Schema Language files should be fixed first.'); |
130 | - } |
|
130 | + } |
|
131 | 131 | |
132 | - public function invoke_testInvalidXmlFiles($filename, $err_code, $args = '') |
|
133 | - { |
|
132 | + public function invoke_testInvalidXmlFiles($filename, $err_code, $args = '') |
|
133 | + { |
|
134 | 134 | $cmd = $this->validator_cmd . ' '. $args . ' ' . escapeshellarg($filename); |
135 | 135 | $validator_output = array(); |
136 | 136 | $return_code = 0; |
@@ -141,88 +141,88 @@ discard block |
||
141 | 141 | |
142 | 142 | // Validator should not crash/exit-with-an-error. |
143 | 143 | $this->assertEquals |
144 | - ( |
|
144 | + ( |
|
145 | 145 | $err_code, |
146 | 146 | $return_code, |
147 | 147 | "{$cmd}\n{$output_text}\nValidator returned code {$return_code}." |
148 | - ); |
|
148 | + ); |
|
149 | 149 | |
150 | 150 | // Validator should output some error on the test files |
151 | 151 | $basefilename = basename($filename); |
152 | 152 | $this->assertNotEmpty($output_text, "Error reporting failed for {$basefilename} validation."); |
153 | 153 | |
154 | - } |
|
154 | + } |
|
155 | 155 | |
156 | - public function testInvalidQueryId() |
|
157 | - { |
|
156 | + public function testInvalidQueryId() |
|
157 | + { |
|
158 | 158 | return $this->invoke_testInvalidXmlFiles(__DIR__.'/data/wrongQueryId.xml', self::RETCODE_QUERY_ELEMENT); |
159 | - } |
|
159 | + } |
|
160 | 160 | |
161 | - /** |
|
162 | - * @dataProvider getFilesList |
|
163 | - */ |
|
164 | - public function testInvalidXMLQueryFiles($filename) |
|
165 | - { |
|
161 | + /** |
|
162 | + * @dataProvider getFilesList |
|
163 | + */ |
|
164 | + public function testInvalidXMLQueryFiles($filename) |
|
165 | + { |
|
166 | 166 | return $this->invoke_testInvalidXmlFiles($filename, self::RETCODE_BUILTIN_CHECKS); |
167 | - } |
|
167 | + } |
|
168 | 168 | |
169 | - public function getDirFilesList($dir_name) |
|
170 | - { |
|
169 | + public function getDirFilesList($dir_name) |
|
170 | + { |
|
171 | 171 | $output = array(); |
172 | 172 | |
173 | 173 | $dir = opendir(__DIR__ . '/' . $dir_name); |
174 | 174 | |
175 | 175 | if ($dir) |
176 | 176 | { |
177 | - $entry = readdir($dir); |
|
177 | + $entry = readdir($dir); |
|
178 | 178 | |
179 | - while ($entry !== FALSE) |
|
180 | - { |
|
179 | + while ($entry !== FALSE) |
|
180 | + { |
|
181 | 181 | $fname = __DIR__ . '/' . $dir_name .'/' . $entry; |
182 | 182 | |
183 | 183 | if (!is_dir($fname)&& $entry != 'wrongQueryId.xml') |
184 | - $output[] = array($fname); |
|
184 | + $output[] = array($fname); |
|
185 | 185 | |
186 | 186 | $entry = readdir($dir); |
187 | - } |
|
187 | + } |
|
188 | 188 | |
189 | - closedir($dir); |
|
189 | + closedir($dir); |
|
190 | 190 | } |
191 | 191 | else |
192 | - $this->assertFalse(TRUE); |
|
192 | + $this->assertFalse(TRUE); |
|
193 | 193 | |
194 | - return $output; |
|
195 | - } |
|
194 | + return $output; |
|
195 | + } |
|
196 | 196 | |
197 | - public function getFilesList() |
|
198 | - { |
|
197 | + public function getFilesList() |
|
198 | + { |
|
199 | 199 | return $this->getDirFilesList('data'); |
200 | - } |
|
200 | + } |
|
201 | 201 | |
202 | - public function getSchemaFilesList() |
|
203 | - { |
|
202 | + public function getSchemaFilesList() |
|
203 | + { |
|
204 | 204 | return $this->getDirFilesList('data/schema'); |
205 | - } |
|
205 | + } |
|
206 | 206 | |
207 | - public function getSchemaWarningFilesList() |
|
208 | - { |
|
207 | + public function getSchemaWarningFilesList() |
|
208 | + { |
|
209 | 209 | return $this->getDirFilesList('data/schema/warnings'); |
210 | - } |
|
210 | + } |
|
211 | 211 | |
212 | - /** |
|
213 | - * @dataProvider getSchemaFilesList |
|
214 | - */ |
|
215 | - public function testInvalidXMLSchemaFiles($filename) |
|
216 | - { |
|
212 | + /** |
|
213 | + * @dataProvider getSchemaFilesList |
|
214 | + */ |
|
215 | + public function testInvalidXMLSchemaFiles($filename) |
|
216 | + { |
|
217 | 217 | return $this->invoke_testInvalidXmlFiles($filename, self::RETCODE_BUILTIN_CHECKS, '--schema-language'); |
218 | - } |
|
218 | + } |
|
219 | 219 | |
220 | - /** |
|
221 | - * @dataProvider getSchemaWarningFilesList |
|
222 | - */ |
|
223 | - public function testWarningXMLSchemaFiles($filename) |
|
224 | - { |
|
220 | + /** |
|
221 | + * @dataProvider getSchemaWarningFilesList |
|
222 | + */ |
|
223 | + public function testWarningXMLSchemaFiles($filename) |
|
224 | + { |
|
225 | 225 | return $this->invoke_testInvalidXmlFiles($filename, self::RETCODE_SUCCESS, '--schema-language'); |
226 | - } |
|
226 | + } |
|
227 | 227 | } |
228 | 228 |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | const RETCODE_GENERIC_XML_SYNTAX = 50; |
15 | 15 | const RETCODE_QUERY_ELEMENT = 40; |
16 | 16 | const RETCODE_XSD_VALIDATION = 30; |
17 | - const RETCODE_BUILTIN_CHECKS = 20; |
|
18 | - const RETCODE_DB_SCHEMA_MATCH =10; // no schema match is currently implemented. |
|
17 | + const RETCODE_BUILTIN_CHECKS = 20; |
|
18 | + const RETCODE_DB_SCHEMA_MATCH = 10; // no schema match is currently implemented. |
|
19 | 19 | const RETCODE_SUCCESS = 0; |
20 | 20 | |
21 | 21 | public $validator_cmd; |
@@ -53,8 +53,7 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | /** Tests all XML Query and Schema Language files (in all modules/addons/widgets) in XE */ |
56 | - public function invoke_testReleasedXMLLangFiles |
|
57 | - ( |
|
56 | + public function invoke_testReleasedXMLLangFiles( |
|
58 | 57 | $released_files, |
59 | 58 | $expected_return_code, |
60 | 59 | $validator_args = '' |
@@ -71,11 +70,9 @@ discard block |
||
71 | 70 | |
72 | 71 | foreach ($released_files as $released_file_mask) |
73 | 72 | $xml_files = |
74 | - array_merge |
|
75 | - ( |
|
73 | + array_merge( |
|
76 | 74 | $xml_files, |
77 | - $this->globr |
|
78 | - ( |
|
75 | + $this->globr( |
|
79 | 76 | $xe_dir, |
80 | 77 | $released_file_mask, |
81 | 78 | GLOB_NOSORT | GLOB_NOESCAPE | GLOB_ERR |
@@ -95,8 +92,7 @@ discard block |
||
95 | 92 | $output_text = trim(trim(implode("\n", $validator_output)), "\n"); |
96 | 93 | |
97 | 94 | // Validator should not crash/exit-with-an-error. |
98 | - $this->assertLessThanOrEqual |
|
99 | - ( |
|
95 | + $this->assertLessThanOrEqual( |
|
100 | 96 | $expected_return_code, |
101 | 97 | $return_code, |
102 | 98 | "{$cmd}\n\n{$output_text}\nValidator returned code {$return_code}." |
@@ -108,8 +104,7 @@ discard block |
||
108 | 104 | |
109 | 105 | public function testReleasedXMLQueryLangFiles() |
110 | 106 | { |
111 | - $this->invoke_testReleasedXMLLangFiles |
|
112 | - ( |
|
107 | + $this->invoke_testReleasedXMLLangFiles( |
|
113 | 108 | array('queries/*.xml', 'xml_query/*.xml'), |
114 | 109 | self::RETCODE_QUERY_ELEMENT |
115 | 110 | ); |
@@ -119,8 +114,7 @@ discard block |
||
119 | 114 | |
120 | 115 | public function testReleasedXMLSchemaLangFiles() |
121 | 116 | { |
122 | - $this->invoke_testReleasedXMLLangFiles |
|
123 | - ( |
|
117 | + $this->invoke_testReleasedXMLLangFiles( |
|
124 | 118 | array('schemas/*.xml'), |
125 | 119 | self::RETCODE_BUILTIN_CHECKS, |
126 | 120 | ' --schema-language' |
@@ -131,7 +125,7 @@ discard block |
||
131 | 125 | |
132 | 126 | public function invoke_testInvalidXmlFiles($filename, $err_code, $args = '') |
133 | 127 | { |
134 | - $cmd = $this->validator_cmd . ' '. $args . ' ' . escapeshellarg($filename); |
|
128 | + $cmd = $this->validator_cmd . ' ' . $args . ' ' . escapeshellarg($filename); |
|
135 | 129 | $validator_output = array(); |
136 | 130 | $return_code = 0; |
137 | 131 | |
@@ -140,8 +134,7 @@ discard block |
||
140 | 134 | $output_text = trim(trim(implode("\n", $validator_output)), "\n"); |
141 | 135 | |
142 | 136 | // Validator should not crash/exit-with-an-error. |
143 | - $this->assertEquals |
|
144 | - ( |
|
137 | + $this->assertEquals( |
|
145 | 138 | $err_code, |
146 | 139 | $return_code, |
147 | 140 | "{$cmd}\n{$output_text}\nValidator returned code {$return_code}." |
@@ -155,7 +148,7 @@ discard block |
||
155 | 148 | |
156 | 149 | public function testInvalidQueryId() |
157 | 150 | { |
158 | - return $this->invoke_testInvalidXmlFiles(__DIR__.'/data/wrongQueryId.xml', self::RETCODE_QUERY_ELEMENT); |
|
151 | + return $this->invoke_testInvalidXmlFiles(__DIR__ . '/data/wrongQueryId.xml', self::RETCODE_QUERY_ELEMENT); |
|
159 | 152 | } |
160 | 153 | |
161 | 154 | /** |
@@ -178,9 +171,9 @@ discard block |
||
178 | 171 | |
179 | 172 | while ($entry !== FALSE) |
180 | 173 | { |
181 | - $fname = __DIR__ . '/' . $dir_name .'/' . $entry; |
|
174 | + $fname = __DIR__ . '/' . $dir_name . '/' . $entry; |
|
182 | 175 | |
183 | - if (!is_dir($fname)&& $entry != 'wrongQueryId.xml') |
|
176 | + if (!is_dir($fname) && $entry != 'wrongQueryId.xml') |
|
184 | 177 | $output[] = array($fname); |
185 | 178 | |
186 | 179 | $entry = readdir($dir); |
@@ -1,8 +1,9 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* Copyright (C) NAVER <http://www.navercorp.com> */ |
3 | 3 | |
4 | -if (!defined('__DIR__')) |
|
5 | - define('__DIR__', realpath(dirname(__FILE__))); |
|
4 | +if (!defined('__DIR__')) { |
|
5 | + define('__DIR__', realpath(dirname(__FILE__))); |
|
6 | +} |
|
6 | 7 | |
7 | 8 | /** The tests here are meant only for the built-in checks in validator.php, |
8 | 9 | and not for the entire syntax expressed by the .xsd files. */ |
@@ -69,8 +70,8 @@ discard block |
||
69 | 70 | $cmd = $this->validator_cmd; |
70 | 71 | $xml_files = array(); |
71 | 72 | |
72 | - foreach ($released_files as $released_file_mask) |
|
73 | - $xml_files = |
|
73 | + foreach ($released_files as $released_file_mask) { |
|
74 | + $xml_files = |
|
74 | 75 | array_merge |
75 | 76 | ( |
76 | 77 | $xml_files, |
@@ -80,15 +81,17 @@ discard block |
||
80 | 81 | $released_file_mask, |
81 | 82 | GLOB_NOSORT | GLOB_NOESCAPE | GLOB_ERR |
82 | 83 | ) |
83 | - ); |
|
84 | + ); |
|
85 | + } |
|
84 | 86 | |
85 | 87 | while ($cnt < count($xml_files)) |
86 | 88 | { |
87 | 89 | $cmd = $this->validator_cmd . $validator_args; |
88 | 90 | |
89 | 91 | // Validate 50 files at once |
90 | - foreach (array_slice($xml_files, $cnt, 50) as $xml_file) |
|
91 | - $cmd .= " " . escapeshellarg($xml_file); |
|
92 | + foreach (array_slice($xml_files, $cnt, 50) as $xml_file) { |
|
93 | + $cmd .= " " . escapeshellarg($xml_file); |
|
94 | + } |
|
92 | 95 | |
93 | 96 | exec($cmd . ' 2>&1', $validator_output, $return_code); |
94 | 97 | |
@@ -180,16 +183,17 @@ discard block |
||
180 | 183 | { |
181 | 184 | $fname = __DIR__ . '/' . $dir_name .'/' . $entry; |
182 | 185 | |
183 | - if (!is_dir($fname)&& $entry != 'wrongQueryId.xml') |
|
184 | - $output[] = array($fname); |
|
186 | + if (!is_dir($fname)&& $entry != 'wrongQueryId.xml') { |
|
187 | + $output[] = array($fname); |
|
188 | + } |
|
185 | 189 | |
186 | 190 | $entry = readdir($dir); |
187 | 191 | } |
188 | 192 | |
189 | 193 | closedir($dir); |
190 | - } |
|
191 | - else |
|
192 | - $this->assertFalse(TRUE); |
|
194 | + } else { |
|
195 | + $this->assertFalse(TRUE); |
|
196 | + } |
|
193 | 197 | |
194 | 198 | return $output; |
195 | 199 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | @return |
174 | 174 | @param $xml_file |
175 | 175 | @param $node |
176 | - @param $child_tag |
|
176 | + @param string $child_tag |
|
177 | 177 | */ |
178 | 178 | function checkDuplicateDescendants($xml_file, $node, $child_tag) |
179 | 179 | { |
@@ -199,13 +199,13 @@ discard block |
||
199 | 199 | messages. |
200 | 200 | @param $node |
201 | 201 | The XML node with the children to be checked. |
202 | - @param $child_tags |
|
202 | + @param string[] $child_tags |
|
203 | 203 | Array with tag names for the children elements |
204 | - @param $attr_tags |
|
204 | + @param string[] $attr_tags |
|
205 | 205 | Array with names of attributes to be checked. If multiple attributes |
206 | 206 | are given, than the first one that is present on a child is included |
207 | 207 | in the check. |
208 | - @param $key |
|
208 | + @param boolean $key |
|
209 | 209 | True if child elements are required to expose at least one of the |
210 | 210 | attribute. False if only the child nodes with some of the |
211 | 211 | attributes present are to be checked. |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | @return |
490 | 490 | @param $xml_file |
491 | 491 | @param $container_element |
492 | - @param $child_tag |
|
492 | + @param string $child_tag |
|
493 | 493 | */ |
494 | 494 | function checkVarContentsValidation |
495 | 495 | ( |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | @param $line_no |
91 | 91 | @param $message |
92 | 92 | @access |
93 | - */ |
|
93 | + */ |
|
94 | 94 | public function __construct($file, $line_no, $message) |
95 | 95 | { |
96 | 96 | parent::__construct("{$file}({$line_no}):\n\t$message"); |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | @developer |
113 | 113 | @return |
114 | 114 | @access |
115 | - */ |
|
115 | + */ |
|
116 | 116 | public function __destruct() |
117 | 117 | { |
118 | 118 | libxml_clear_errors(); |
@@ -834,8 +834,7 @@ discard block |
||
834 | 834 | |
835 | 835 | @brief |
836 | 836 | @developer |
837 | - |
|
838 | - */ |
|
837 | + */ |
|
839 | 838 | class RestoreWorkDir |
840 | 839 | { |
841 | 840 | protected $dirname; |
@@ -845,7 +844,7 @@ discard block |
||
845 | 844 | @developer |
846 | 845 | @return |
847 | 846 | @access |
848 | - */ |
|
847 | + */ |
|
849 | 848 | public function __destruct() |
850 | 849 | { |
851 | 850 | try |
@@ -868,7 +867,7 @@ discard block |
||
868 | 867 | @developer |
869 | 868 | @return |
870 | 869 | @access |
871 | - */ |
|
870 | + */ |
|
872 | 871 | public function __construct() |
873 | 872 | { |
874 | 873 | $this->dirname = getcwd(); |
@@ -1113,7 +1112,7 @@ discard block |
||
1113 | 1112 | @return |
1114 | 1113 | @access |
1115 | 1114 | @param $val |
1116 | - */ |
|
1115 | + */ |
|
1117 | 1116 | public function code($val = -1) |
1118 | 1117 | { |
1119 | 1118 | if($val == -1) |
@@ -1135,7 +1134,7 @@ discard block |
||
1135 | 1134 | @return |
1136 | 1135 | @access |
1137 | 1136 | @param $val |
1138 | - */ |
|
1137 | + */ |
|
1139 | 1138 | public function push($val) |
1140 | 1139 | { |
1141 | 1140 | $this->save = $this->exit_code; |
@@ -1147,7 +1146,7 @@ discard block |
||
1147 | 1146 | @developer |
1148 | 1147 | @access |
1149 | 1148 | @return |
1150 | - */ |
|
1149 | + */ |
|
1151 | 1150 | public function pop() |
1152 | 1151 | { |
1153 | 1152 | $this->exit_code = $this->save; |
@@ -1160,7 +1159,7 @@ discard block |
||
1160 | 1159 | @return |
1161 | 1160 | @access |
1162 | 1161 | @param $val |
1163 | - */ |
|
1162 | + */ |
|
1164 | 1163 | public function __construct($val = 0) |
1165 | 1164 | { |
1166 | 1165 | $this->save = self::RETCODE_VALIDATOR_INTERNAL; |
@@ -1181,7 +1180,7 @@ discard block |
||
1181 | 1180 | @developer |
1182 | 1181 | @access |
1183 | 1182 | @return |
1184 | - */ |
|
1183 | + */ |
|
1185 | 1184 | public function __destruct() |
1186 | 1185 | { |
1187 | 1186 | if($this->file_name) |
@@ -1196,7 +1195,7 @@ discard block |
||
1196 | 1195 | @access |
1197 | 1196 | @return |
1198 | 1197 | @param $file_name |
1199 | - */ |
|
1198 | + */ |
|
1200 | 1199 | public function __construct($file_name) |
1201 | 1200 | { |
1202 | 1201 | $this->file_name = $file_name; |
@@ -1439,7 +1438,7 @@ discard block |
||
1439 | 1438 | |
1440 | 1439 | @brief |
1441 | 1440 | @developer |
1442 | - */ |
|
1441 | + */ |
|
1443 | 1442 | class Context |
1444 | 1443 | { |
1445 | 1444 | protected static $db_info = NULL; |
@@ -1449,7 +1448,7 @@ discard block |
||
1449 | 1448 | @developer |
1450 | 1449 | @return |
1451 | 1450 | @access |
1452 | - */ |
|
1451 | + */ |
|
1453 | 1452 | public static function isInstalled() |
1454 | 1453 | { |
1455 | 1454 | return TRUE; |
@@ -1460,7 +1459,7 @@ discard block |
||
1460 | 1459 | @developer |
1461 | 1460 | @return |
1462 | 1461 | @access |
1463 | - */ |
|
1462 | + */ |
|
1464 | 1463 | public static function getLangType() |
1465 | 1464 | { |
1466 | 1465 | return 'en'; |
@@ -1471,7 +1470,7 @@ discard block |
||
1471 | 1470 | @developer |
1472 | 1471 | @return |
1473 | 1472 | @access |
1474 | - */ |
|
1473 | + */ |
|
1475 | 1474 | public static function getLang() |
1476 | 1475 | { |
1477 | 1476 | return 'en'; |
@@ -1482,7 +1481,7 @@ discard block |
||
1482 | 1481 | @developer |
1483 | 1482 | @return |
1484 | 1483 | @access |
1485 | - */ |
|
1484 | + */ |
|
1486 | 1485 | public static function getDBType() |
1487 | 1486 | { |
1488 | 1487 | if(self::$db_info) |
@@ -1501,7 +1500,7 @@ discard block |
||
1501 | 1500 | @return |
1502 | 1501 | @access |
1503 | 1502 | @param $db_info |
1504 | - */ |
|
1503 | + */ |
|
1505 | 1504 | public static function setDBInfo($db_info) |
1506 | 1505 | { |
1507 | 1506 | self::$db_info = $db_info; |
@@ -1512,7 +1511,7 @@ discard block |
||
1512 | 1511 | @developer |
1513 | 1512 | @return |
1514 | 1513 | @access |
1515 | - */ |
|
1514 | + */ |
|
1516 | 1515 | public static function getDBInfo() |
1517 | 1516 | { |
1518 | 1517 | return self::$db_info; |
@@ -1524,7 +1523,7 @@ discard block |
||
1524 | 1523 | @return |
1525 | 1524 | @access |
1526 | 1525 | @param $str |
1527 | - */ |
|
1526 | + */ |
|
1528 | 1527 | public static function convertEncodingStr($str) |
1529 | 1528 | { |
1530 | 1529 | return $str; |
@@ -1535,7 +1534,7 @@ discard block |
||
1535 | 1534 | @developer |
1536 | 1535 | @return |
1537 | 1536 | @access |
1538 | - */ |
|
1537 | + */ |
|
1539 | 1538 | public static function setNoDBInfo() |
1540 | 1539 | { |
1541 | 1540 | $db_info = (object)NULL; |
@@ -1562,7 +1561,7 @@ discard block |
||
1562 | 1561 | @developer |
1563 | 1562 | @access |
1564 | 1563 | @return |
1565 | - */ |
|
1564 | + */ |
|
1566 | 1565 | public static function setMysqlDBInfo() |
1567 | 1566 | { |
1568 | 1567 | $db_info = (object)NULL; |
@@ -1604,7 +1603,7 @@ discard block |
||
1604 | 1603 | @developer |
1605 | 1604 | @return |
1606 | 1605 | @access |
1607 | - */ |
|
1606 | + */ |
|
1608 | 1607 | public static function setMysqliDBInfo() |
1609 | 1608 | { |
1610 | 1609 | $db_info = (object)NULL; |
@@ -1646,7 +1645,7 @@ discard block |
||
1646 | 1645 | @developer |
1647 | 1646 | @return |
1648 | 1647 | @access |
1649 | - */ |
|
1648 | + */ |
|
1650 | 1649 | public static function setCubridDBInfo() |
1651 | 1650 | { |
1652 | 1651 | $db_info = (object)NULL; |
@@ -1688,7 +1687,7 @@ discard block |
||
1688 | 1687 | @developer |
1689 | 1688 | @return |
1690 | 1689 | @access |
1691 | - */ |
|
1690 | + */ |
|
1692 | 1691 | public static function setMssqlDBInfo() |
1693 | 1692 | { |
1694 | 1693 | $db_info = (object)NULL; |
@@ -1729,7 +1728,7 @@ discard block |
||
1729 | 1728 | /** |
1730 | 1729 | @brief |
1731 | 1730 | @developer |
1732 | - */ |
|
1731 | + */ |
|
1733 | 1732 | class Any_prop_obj_base |
1734 | 1733 | { |
1735 | 1734 | /** |
@@ -1738,7 +1737,7 @@ discard block |
||
1738 | 1737 | @return |
1739 | 1738 | @param $property |
1740 | 1739 | @access |
1741 | - */ |
|
1740 | + */ |
|
1742 | 1741 | public function __get($property) |
1743 | 1742 | { |
1744 | 1743 | return NULL; |
@@ -1748,7 +1747,7 @@ discard block |
||
1748 | 1747 | /** |
1749 | 1748 | @brief |
1750 | 1749 | @developer |
1751 | - */ |
|
1750 | + */ |
|
1752 | 1751 | class LangArgFilterErrorMessage |
1753 | 1752 | { |
1754 | 1753 | /** |
@@ -1757,7 +1756,7 @@ discard block |
||
1757 | 1756 | @return |
1758 | 1757 | @param $property |
1759 | 1758 | @access |
1760 | - */ |
|
1759 | + */ |
|
1761 | 1760 | public function __get($property) |
1762 | 1761 | { |
1763 | 1762 | return 'Argument filter error'; |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | { |
96 | 96 | parent::__construct("{$file}({$line_no}):\n\t$message"); |
97 | 97 | |
98 | - $this->xml_file = $file; |
|
98 | + $this->xml_file = $file; |
|
99 | 99 | $this->xml_line_no = $line_no; |
100 | 100 | $this->xml_message = $message; |
101 | 101 | } |
@@ -133,21 +133,21 @@ discard block |
||
133 | 133 | |
134 | 134 | $libXmlErrors = libxml_get_errors(); |
135 | 135 | |
136 | - if(count($libXmlErrors)) |
|
136 | + if (count($libXmlErrors)) |
|
137 | 137 | { |
138 | - if(!$filename) |
|
138 | + if (!$filename) |
|
139 | 139 | { |
140 | 140 | $filename = $libXmlErrors[0]->file; |
141 | 141 | } |
142 | 142 | |
143 | 143 | $msg = ''; |
144 | 144 | |
145 | - foreach($libXmlErrors as $libXmlError) |
|
145 | + foreach ($libXmlErrors as $libXmlError) |
|
146 | 146 | { |
147 | 147 | $msg .= "{$libXmlError->file}({$libXmlError->line}):\n\t {$libXmlError->message}"; |
148 | 148 | } |
149 | 149 | |
150 | - if($throw_error) |
|
150 | + if ($throw_error) |
|
151 | 151 | { |
152 | 152 | throw new ErrorMessage($msg); |
153 | 153 | } |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | } |
159 | 159 | else |
160 | 160 | { |
161 | - if($throw_error) |
|
161 | + if ($throw_error) |
|
162 | 162 | { |
163 | 163 | throw new ErrorMessage('Schema validation failed.'); |
164 | 164 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | { |
180 | 180 | $children = $node->getElementsByTagName($child_tag); |
181 | 181 | |
182 | - if($children->length > 1) |
|
182 | + if ($children->length > 1) |
|
183 | 183 | { |
184 | 184 | throw |
185 | 185 | new XmlSchemaError( |
@@ -217,21 +217,21 @@ discard block |
||
217 | 217 | { |
218 | 218 | $key_values = array(); |
219 | 219 | |
220 | - foreach($node->childNodes as $child_node) |
|
220 | + foreach ($node->childNodes as $child_node) |
|
221 | 221 | { |
222 | - if($child_node->nodeType == XML_ELEMENT_NODE |
|
222 | + if ($child_node->nodeType == XML_ELEMENT_NODE |
|
223 | 223 | && |
224 | 224 | in_array($child_node->tagName, $child_tags)) |
225 | 225 | { |
226 | 226 | $key_value = NULL; |
227 | 227 | |
228 | - foreach($attr_tags as $attr_tag) |
|
228 | + foreach ($attr_tags as $attr_tag) |
|
229 | 229 | { |
230 | - if($child_node->hasAttribute($attr_tag)) |
|
230 | + if ($child_node->hasAttribute($attr_tag)) |
|
231 | 231 | { |
232 | 232 | $key_value = $child_node->getAttribute($attr_tag); |
233 | 233 | |
234 | - if(array_key_exists($key_value, $key_values)) |
|
234 | + if (array_key_exists($key_value, $key_values)) |
|
235 | 235 | { |
236 | 236 | throw |
237 | 237 | new XmlSchemaError( |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | } |
247 | 247 | } |
248 | 248 | |
249 | - if(!$key_value && $key) |
|
249 | + if (!$key_value && $key) |
|
250 | 250 | { |
251 | 251 | throw |
252 | 252 | new XmlSchemaError( |
@@ -282,19 +282,19 @@ discard block |
||
282 | 282 | $table_name = NULL; |
283 | 283 | $join_type = NULL; |
284 | 284 | |
285 | - if($table_element->hasAttribute('name')) |
|
285 | + if ($table_element->hasAttribute('name')) |
|
286 | 286 | { |
287 | 287 | $table_name = $table_element->getAttribute('name'); |
288 | 288 | } |
289 | 289 | |
290 | - if($table_element->hasAttribute('type')) |
|
290 | + if ($table_element->hasAttribute('type')) |
|
291 | 291 | { |
292 | 292 | $join_type = $table_element->getAttribute('type'); |
293 | 293 | } |
294 | 294 | |
295 | - if($table_element->getAttribute('query') == 'true') |
|
295 | + if ($table_element->getAttribute('query') == 'true') |
|
296 | 296 | { |
297 | - if($table_name !== NULL) |
|
297 | + if ($table_name !== NULL) |
|
298 | 298 | { |
299 | 299 | throw |
300 | 300 | new XmlSchemaError( |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | ); |
305 | 305 | } |
306 | 306 | |
307 | - if($join_type !== NULL) |
|
307 | + if ($join_type !== NULL) |
|
308 | 308 | { |
309 | 309 | throw |
310 | 310 | new XmlSchemaError( |
@@ -322,9 +322,9 @@ discard block |
||
322 | 322 | // check contents for a select list or a table-specification |
323 | 323 | $has_query_clauses = FALSE; |
324 | 324 | |
325 | - foreach($table_element->childNodes as $query_clause) |
|
325 | + foreach ($table_element->childNodes as $query_clause) |
|
326 | 326 | { |
327 | - if($query_clause->nodeType == XML_ELEMENT_NODE |
|
327 | + if ($query_clause->nodeType == XML_ELEMENT_NODE |
|
328 | 328 | && |
329 | 329 | ( |
330 | 330 | $query_clause->tagName == 'columns' |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | } |
336 | 336 | } |
337 | 337 | |
338 | - if(!$has_query_clauses) |
|
338 | + if (!$has_query_clauses) |
|
339 | 339 | { |
340 | 340 | throw |
341 | 341 | new XmlSchemaError( |
@@ -351,17 +351,17 @@ discard block |
||
351 | 351 | { |
352 | 352 | // base table or view |
353 | 353 | |
354 | - if($join_type !== NULL) |
|
354 | + if ($join_type !== NULL) |
|
355 | 355 | { |
356 | 356 | $has_conditions_element = FALSE; |
357 | 357 | |
358 | - foreach($table_element->childNodes as $child_node) |
|
358 | + foreach ($table_element->childNodes as $child_node) |
|
359 | 359 | { |
360 | - if($child_node->nodeType == XML_ELEMENT_NODE) |
|
360 | + if ($child_node->nodeType == XML_ELEMENT_NODE) |
|
361 | 361 | { |
362 | - if($child_node->tagName == 'conditions') |
|
362 | + if ($child_node->tagName == 'conditions') |
|
363 | 363 | { |
364 | - if($has_conditions_element) |
|
364 | + if ($has_conditions_element) |
|
365 | 365 | { |
366 | 366 | throw |
367 | 367 | new XmlSchemaError( |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | } |
388 | 388 | } |
389 | 389 | |
390 | - if(!$has_conditions_element) |
|
390 | + if (!$has_conditions_element) |
|
391 | 391 | { |
392 | 392 | throw |
393 | 393 | new XmlSchemaError( |
@@ -399,9 +399,9 @@ discard block |
||
399 | 399 | } |
400 | 400 | else |
401 | 401 | { |
402 | - foreach($table_element->childNodes as $child_node) |
|
402 | + foreach ($table_element->childNodes as $child_node) |
|
403 | 403 | { |
404 | - if($child_node->nodeType == XML_ELEMENT_NODE) |
|
404 | + if ($child_node->nodeType == XML_ELEMENT_NODE) |
|
405 | 405 | { |
406 | 406 | throw |
407 | 407 | new XmlSchemaError( |
@@ -429,26 +429,25 @@ discard block |
||
429 | 429 | */ |
430 | 430 | function checkTablesClause($xml_file, $tables_element) |
431 | 431 | { |
432 | - checkUniqueKey |
|
433 | - ( |
|
432 | + checkUniqueKey( |
|
434 | 433 | $xml_file, |
435 | 434 | $tables_element, |
436 | - array('table'), // child elements to be checked |
|
437 | - array('alias', 'name'), // attributes to be checked |
|
435 | + array('table'), // child elements to be checked |
|
436 | + array('alias', 'name'), // attributes to be checked |
|
438 | 437 | TRUE // attributes are required |
439 | 438 | ); |
440 | 439 | |
441 | - foreach($tables_element->childNodes as $table) |
|
440 | + foreach ($tables_element->childNodes as $table) |
|
442 | 441 | { |
443 | - if($table->nodeType == XML_ELEMENT_NODE |
|
442 | + if ($table->nodeType == XML_ELEMENT_NODE |
|
444 | 443 | && |
445 | 444 | $table->tagName == 'table') |
446 | 445 | { |
447 | 446 | checkTableExpression($xml_file, $table); |
448 | 447 | |
449 | - if($table->getAttribute('query') == 'true') |
|
448 | + if ($table->getAttribute('query') == 'true') |
|
450 | 449 | { |
451 | - validate_select_query($xml_file, $table); // recursive call |
|
450 | + validate_select_query($xml_file, $table); // recursive call |
|
452 | 451 | } |
453 | 452 | } |
454 | 453 | } |
@@ -470,12 +469,11 @@ discard block |
||
470 | 469 | */ |
471 | 470 | function checkSelectListClause($xml_file, $columns_element) |
472 | 471 | { |
473 | - checkUniqueKey |
|
474 | - ( |
|
472 | + checkUniqueKey( |
|
475 | 473 | $xml_file, |
476 | 474 | $columns_element, |
477 | - array('column', 'query'), // child elements |
|
478 | - array('alias', 'name'), // attributes |
|
475 | + array('column', 'query'), // child elements |
|
476 | + array('alias', 'name'), // attributes |
|
479 | 477 | FALSE // ignore if no attributes present |
480 | 478 | ); |
481 | 479 | } |
@@ -491,8 +489,7 @@ discard block |
||
491 | 489 | @param $container_element |
492 | 490 | @param $child_tag |
493 | 491 | */ |
494 | -function checkVarContentsValidation |
|
495 | - ( |
|
492 | +function checkVarContentsValidation( |
|
496 | 493 | $xml_file, |
497 | 494 | $container_element, |
498 | 495 | $child_tag |
@@ -503,23 +500,22 @@ discard block |
||
503 | 500 | |
504 | 501 | static |
505 | 502 | $var_attrs = |
506 | - array |
|
507 | - ( |
|
503 | + array( |
|
508 | 504 | 'filter', 'notnull', 'minlength', |
509 | 505 | 'maxlength' |
510 | 506 | ); |
511 | 507 | |
512 | - foreach($container_element->childNodes as $child_node) |
|
508 | + foreach ($container_element->childNodes as $child_node) |
|
513 | 509 | { |
514 | - if($child_node->nodeType == XML_ELEMENT_NODE |
|
510 | + if ($child_node->nodeType == XML_ELEMENT_NODE |
|
515 | 511 | && |
516 | 512 | $child_node->tagName == $child_tag) |
517 | 513 | { |
518 | - if(!$child_node->hasAttribute($key_attr)) |
|
514 | + if (!$child_node->hasAttribute($key_attr)) |
|
519 | 515 | { |
520 | - foreach($var_attrs as $var_attr) |
|
516 | + foreach ($var_attrs as $var_attr) |
|
521 | 517 | { |
522 | - if($child_node->hasAttribute($var_attr)) |
|
518 | + if ($child_node->hasAttribute($var_attr)) |
|
523 | 519 | { |
524 | 520 | throw |
525 | 521 | new XmlSchemaError( |
@@ -551,9 +547,9 @@ discard block |
||
551 | 547 | $has_var_attribute = $condition->hasAttribute('var') || $condition->hasAttribute('default'); |
552 | 548 | $query_line_no = -1; |
553 | 549 | |
554 | - foreach($condition->childNodes as $query_node) |
|
550 | + foreach ($condition->childNodes as $query_node) |
|
555 | 551 | { |
556 | - if($query_node->nodeType == XML_ELEMENT_NODE |
|
552 | + if ($query_node->nodeType == XML_ELEMENT_NODE |
|
557 | 553 | && |
558 | 554 | $query_node->tagName == 'query') |
559 | 555 | { |
@@ -564,7 +560,7 @@ discard block |
||
564 | 560 | } |
565 | 561 | } |
566 | 562 | |
567 | - if($child_query_node && $has_var_attribute) |
|
563 | + if ($child_query_node && $has_var_attribute) |
|
568 | 564 | { |
569 | 565 | throw |
570 | 566 | new XmlSchemaError( |
@@ -574,7 +570,7 @@ discard block |
||
574 | 570 | ); |
575 | 571 | } |
576 | 572 | |
577 | - if(!($child_query_node || $has_var_attribute)) |
|
573 | + if (!($child_query_node || $has_var_attribute)) |
|
578 | 574 | { |
579 | 575 | throw |
580 | 576 | new XmlSchemaError( |
@@ -601,18 +597,18 @@ discard block |
||
601 | 597 | { |
602 | 598 | $first_child = TRUE; |
603 | 599 | |
604 | - foreach($conditions->childNodes as $child_node) |
|
600 | + foreach ($conditions->childNodes as $child_node) |
|
605 | 601 | { |
606 | - if($child_node->nodeType == XML_ELEMENT_NODE) |
|
602 | + if ($child_node->nodeType == XML_ELEMENT_NODE) |
|
607 | 603 | { |
608 | 604 | // check for 'pipe' attribute |
609 | - if($first_child) |
|
605 | + if ($first_child) |
|
610 | 606 | { |
611 | 607 | $first_child = FALSE; |
612 | 608 | } |
613 | 609 | else |
614 | 610 | { |
615 | - if(!$child_node->hasAttribute('pipe')) |
|
611 | + if (!$child_node->hasAttribute('pipe')) |
|
616 | 612 | { |
617 | 613 | throw |
618 | 614 | new XmlSchemaError( |
@@ -626,19 +622,19 @@ discard block |
||
626 | 622 | } |
627 | 623 | |
628 | 624 | // recurse in condition groups/queries |
629 | - if($child_node->tagName == 'group') |
|
625 | + if ($child_node->tagName == 'group') |
|
630 | 626 | { |
631 | 627 | checkConditionsGroup($xml_file, $child_node); |
632 | 628 | } |
633 | 629 | else |
634 | 630 | { |
635 | - if($child_node->tagName == 'query') |
|
631 | + if ($child_node->tagName == 'query') |
|
636 | 632 | { |
637 | 633 | validate_select_query($xml_file, $child_node); |
638 | 634 | } |
639 | 635 | else |
640 | 636 | { |
641 | - if($child_node->tagName == 'condition') |
|
637 | + if ($child_node->tagName == 'condition') |
|
642 | 638 | { |
643 | 639 | checkConditionElement($xml_file, $child_node); |
644 | 640 | } |
@@ -664,12 +660,11 @@ discard block |
||
664 | 660 | */ |
665 | 661 | function checkNavigationClauses($xml_file, $navigation_element) |
666 | 662 | { |
667 | - foreach(array('list_count', 'page_count', 'page') |
|
663 | + foreach (array('list_count', 'page_count', 'page') |
|
668 | 664 | as |
669 | 665 | $navigation_el) |
670 | 666 | { |
671 | - checkDuplicateDescendants |
|
672 | - ( |
|
667 | + checkDuplicateDescendants( |
|
673 | 668 | $xml_file, |
674 | 669 | $navigation_element, |
675 | 670 | $navigation_el |
@@ -693,11 +688,11 @@ discard block |
||
693 | 688 | */ |
694 | 689 | function validate_select_query($xml_file, $query_element) |
695 | 690 | { |
696 | - foreach($query_element->childNodes as $select_clause) |
|
691 | + foreach ($query_element->childNodes as $select_clause) |
|
697 | 692 | { |
698 | - if($select_clause->nodeType == XML_ELEMENT_NODE) |
|
693 | + if ($select_clause->nodeType == XML_ELEMENT_NODE) |
|
699 | 694 | { |
700 | - switch($select_clause->tagName) |
|
695 | + switch ($select_clause->tagName) |
|
701 | 696 | { |
702 | 697 | case 'columns': |
703 | 698 | checkSelectListClause($xml_file, $select_clause); |
@@ -728,11 +723,11 @@ discard block |
||
728 | 723 | */ |
729 | 724 | function validate_update_query($xml_file, $query_element) |
730 | 725 | { |
731 | - foreach($query_element->childNodes as $update_clause) |
|
726 | + foreach ($query_element->childNodes as $update_clause) |
|
732 | 727 | { |
733 | - if($update_clause->nodeType == XML_ELEMENT_NODE) |
|
728 | + if ($update_clause->nodeType == XML_ELEMENT_NODE) |
|
734 | 729 | { |
735 | - switch($update_clause->tagName) |
|
730 | + switch ($update_clause->tagName) |
|
736 | 731 | { |
737 | 732 | case 'tables': |
738 | 733 | checkTablesClause($xml_file, $update_clause); |
@@ -755,11 +750,11 @@ discard block |
||
755 | 750 | */ |
756 | 751 | function validate_delete_query($xml_file, $query_element) |
757 | 752 | { |
758 | - foreach($query_element->childNodes as $delete_clause) |
|
753 | + foreach ($query_element->childNodes as $delete_clause) |
|
759 | 754 | { |
760 | - if($delete_clause->nodeType == XML_ELEMENT_NODE) |
|
755 | + if ($delete_clause->nodeType == XML_ELEMENT_NODE) |
|
761 | 756 | { |
762 | - switch($delete_clause->tagName) |
|
757 | + switch ($delete_clause->tagName) |
|
763 | 758 | { |
764 | 759 | case 'conditions': |
765 | 760 | checkConditionsGroup($xml_file, $delete_clause); |
@@ -778,11 +773,11 @@ discard block |
||
778 | 773 | */ |
779 | 774 | function validate_insert_select_query($xml_file, $query_element) |
780 | 775 | { |
781 | - foreach($query_element->childNodes as $statement_clause) |
|
776 | + foreach ($query_element->childNodes as $statement_clause) |
|
782 | 777 | { |
783 | - if($statement_clause->nodeType == XML_ELEMENT_NODE) |
|
778 | + if ($statement_clause->nodeType == XML_ELEMENT_NODE) |
|
784 | 779 | { |
785 | - switch($statement_clause->tagName) |
|
780 | + switch ($statement_clause->tagName) |
|
786 | 781 | { |
787 | 782 | case 'query': |
788 | 783 | validate_select_query($xml_file, $statement_clause); |
@@ -793,8 +788,7 @@ discard block |
||
793 | 788 | } |
794 | 789 | |
795 | 790 | $validate_query_type = |
796 | - array |
|
797 | - ( |
|
791 | + array( |
|
798 | 792 | // 'insert' => |
799 | 793 | // there is currently nothing special to check |
800 | 794 | // for a plain insert, all the needed checks |
@@ -818,13 +812,13 @@ discard block |
||
818 | 812 | |
819 | 813 | $action = $query_element->getAttribute('action'); |
820 | 814 | |
821 | - if(array_key_exists($action, $validate_query_type)) |
|
815 | + if (array_key_exists($action, $validate_query_type)) |
|
822 | 816 | { |
823 | 817 | $validate_query_type[$action]($xml_file, $query_element); |
824 | 818 | } |
825 | 819 | } |
826 | 820 | |
827 | -if(strpos(PHP_SAPI, 'cli') !== FALSE |
|
821 | +if (strpos(PHP_SAPI, 'cli') !== FALSE |
|
828 | 822 | || |
829 | 823 | strpos(PHP_SAPI, 'cgi') !== FALSE) |
830 | 824 | { |
@@ -857,7 +851,7 @@ discard block |
||
857 | 851 | print "Failed to restore working dir {$this->dirname}."; |
858 | 852 | } |
859 | 853 | |
860 | - if(!$success) |
|
854 | + if (!$success) |
|
861 | 855 | { |
862 | 856 | print "Failed to restore working dir {$this->dirname}."; |
863 | 857 | } |
@@ -873,7 +867,7 @@ discard block |
||
873 | 867 | { |
874 | 868 | $this->dirname = getcwd(); |
875 | 869 | |
876 | - if(!$this->dirname) |
|
870 | + if (!$this->dirname) |
|
877 | 871 | { |
878 | 872 | throw new ErrorMessage("Failed to get current directory."); |
879 | 873 | } |
@@ -903,7 +897,7 @@ discard block |
||
903 | 897 | $lowercase_name = strtolower($xml_path_info['basename']); |
904 | 898 | $uppercase_name = strtoupper($xml_path_info['basename']); |
905 | 899 | |
906 | - if(strlen($lowercase_name) != $filename_len |
|
900 | + if (strlen($lowercase_name) != $filename_len |
|
907 | 901 | || |
908 | 902 | strlen($uppercase_name) != $filename_len) |
909 | 903 | { |
@@ -916,9 +910,9 @@ discard block |
||
916 | 910 | |
917 | 911 | $varing_case_filename = ''; |
918 | 912 | |
919 | - for($i = 0; $i < $filename_len; $i++) |
|
913 | + for ($i = 0; $i < $filename_len; $i++) |
|
920 | 914 | { |
921 | - if($lowercase_name[$i] != $uppercase_name[$i]) |
|
915 | + if ($lowercase_name[$i] != $uppercase_name[$i]) |
|
922 | 916 | { |
923 | 917 | $varing_case_filename .= "[{$lowercase_name[$i]}{$uppercase_name[$i]}]"; |
924 | 918 | } |
@@ -932,13 +926,13 @@ discard block |
||
932 | 926 | |
933 | 927 | $restoreWorkDir = new RestoreWorkDir(); |
934 | 928 | |
935 | - if($glob_pattern) |
|
929 | + if ($glob_pattern) |
|
936 | 930 | { |
937 | 931 | // change current dir to the xml file directory to keep |
938 | 932 | // glob pattern shorter (maximum 260 chars). |
939 | 933 | $success = chdir($glob_pattern); |
940 | 934 | |
941 | - if(!$success) |
|
935 | + if (!$success) |
|
942 | 936 | { |
943 | 937 | throw new ErrorMessage("Failed to change work dir to {$glob_pattern}."); |
944 | 938 | } |
@@ -950,14 +944,14 @@ discard block |
||
950 | 944 | // realpath() would have the same effect, but it is not documented as such |
951 | 945 | $matched_files = glob($glob_pattern, GLOB_NOSORT | GLOB_NOESCAPE | GLOB_ERR); |
952 | 946 | |
953 | - unset($RestoreWorkDir); // restore work dir after call to glob() |
|
947 | + unset($RestoreWorkDir); // restore work dir after call to glob() |
|
954 | 948 | |
955 | - if($matched_files === FALSE || !is_array($matched_files)) |
|
949 | + if ($matched_files === FALSE || !is_array($matched_files)) |
|
956 | 950 | { |
957 | 951 | throw new ErrorMessage("Directory listing for $xml_file failed."); |
958 | 952 | } |
959 | 953 | |
960 | - switch(count($matched_files)) |
|
954 | + switch (count($matched_files)) |
|
961 | 955 | { |
962 | 956 | case 0: |
963 | 957 | throw new ErrorMessage("Directory listing for $xml_file failed."); |
@@ -968,9 +962,9 @@ discard block |
||
968 | 962 | default: |
969 | 963 | // more than one files with the same name and different case |
970 | 964 | // case-sensitive file system |
971 | - foreach($mached_files as $matched_file) |
|
965 | + foreach ($mached_files as $matched_file) |
|
972 | 966 | { |
973 | - if(pathinfo($matched_file, PATHINFO_BASENAME) == $xml_path_info['basename']) |
|
967 | + if (pathinfo($matched_file, PATHINFO_BASENAME) == $xml_path_info['basename']) |
|
974 | 968 | { |
975 | 969 | return ($xml_path_info['filename'] == $query_id); |
976 | 970 | } |
@@ -979,7 +973,7 @@ discard block |
||
979 | 973 | |
980 | 974 | } |
981 | 975 | |
982 | - throw new ErrorMessage("Internal application error."); // unreachable |
|
976 | + throw new ErrorMessage("Internal application error."); // unreachable |
|
983 | 977 | } |
984 | 978 | |
985 | 979 | /** |
@@ -1000,9 +994,9 @@ discard block |
||
1000 | 994 | */ |
1001 | 995 | function validate_schema_doc($xml_file, $table_element) |
1002 | 996 | { |
1003 | - foreach($table_element->childNodes as $col_node) |
|
997 | + foreach ($table_element->childNodes as $col_node) |
|
1004 | 998 | { |
1005 | - if($col_node->nodeType == XML_ELEMENT_NODE |
|
999 | + if ($col_node->nodeType == XML_ELEMENT_NODE |
|
1006 | 1000 | && |
1007 | 1001 | $col_node->tagName == 'column') |
1008 | 1002 | { |
@@ -1010,10 +1004,9 @@ discard block |
||
1010 | 1004 | $col_size = NULL; |
1011 | 1005 | |
1012 | 1006 | // check auto-increment column |
1013 | - if($col_node->hasAttribute('auto_increment')) |
|
1007 | + if ($col_node->hasAttribute('auto_increment')) |
|
1014 | 1008 | { |
1015 | - fwrite |
|
1016 | - ( |
|
1009 | + fwrite( |
|
1017 | 1010 | fopen('php://stdout', 'wt'), |
1018 | 1011 | $xml_file . '(' . $col_node->getLineNo() . ")\n\t" |
1019 | 1012 | . |
@@ -1023,7 +1016,7 @@ discard block |
||
1023 | 1016 | static |
1024 | 1017 | $autoinc_types = array('number', 'bignumber'); |
1025 | 1018 | |
1026 | - if(!in_array($col_type, $autoinc_types)) |
|
1019 | + if (!in_array($col_type, $autoinc_types)) |
|
1027 | 1020 | { |
1028 | 1021 | throw |
1029 | 1022 | new XmlSchemaError( |
@@ -1037,10 +1030,9 @@ discard block |
||
1037 | 1030 | } |
1038 | 1031 | |
1039 | 1032 | // check tinytext |
1040 | - if($col_type == 'tinytext') |
|
1033 | + if ($col_type == 'tinytext') |
|
1041 | 1034 | { |
1042 | - fwrite |
|
1043 | - ( |
|
1035 | + fwrite( |
|
1044 | 1036 | fopen('php://stdout', 'wt'), |
1045 | 1037 | $xml_file . '(' . $col_node->getLineNo() . ")\n\t" |
1046 | 1038 | . |
@@ -1049,12 +1041,12 @@ discard block |
||
1049 | 1041 | } |
1050 | 1042 | |
1051 | 1043 | // check size attribute |
1052 | - if($col_node->hasAttribute('size')) |
|
1044 | + if ($col_node->hasAttribute('size')) |
|
1053 | 1045 | { |
1054 | 1046 | $col_size = $col_node->getAttribute('size'); |
1055 | 1047 | } |
1056 | 1048 | |
1057 | - if($col_type == 'varchar' && $col_size === NULL) |
|
1049 | + if ($col_type == 'varchar' && $col_size === NULL) |
|
1058 | 1050 | { |
1059 | 1051 | throw |
1060 | 1052 | new XmlSchemaError( |
@@ -1068,7 +1060,7 @@ discard block |
||
1068 | 1060 | $varsize_types = array('char', 'varchar', 'float'); |
1069 | 1061 | |
1070 | 1062 | |
1071 | - if($col_size !== NULL && !in_array($col_type, $varsize_types)) |
|
1063 | + if ($col_size !== NULL && !in_array($col_type, $varsize_types)) |
|
1072 | 1064 | { |
1073 | 1065 | throw |
1074 | 1066 | new XmlSchemaError( |
@@ -1102,8 +1094,8 @@ discard block |
||
1102 | 1094 | const RETCODE_GENERIC_XML_SYNTAX = 50; |
1103 | 1095 | const RETCODE_QUERY_ELEMENT = 40; |
1104 | 1096 | const RETCODE_XSD_VALIDATION = 30; |
1105 | - const RETCODE_BUILTIN_CHECKS = 20; |
|
1106 | - const RETCODE_DB_SCHEMA_MATCH = 10; // no schema match is currently implemented. |
|
1097 | + const RETCODE_BUILTIN_CHECKS = 20; |
|
1098 | + const RETCODE_DB_SCHEMA_MATCH = 10; // no schema match is currently implemented. |
|
1107 | 1099 | const RETCODE_SUCCESS = 0; |
1108 | 1100 | |
1109 | 1101 | |
@@ -1116,13 +1108,13 @@ discard block |
||
1116 | 1108 | */ |
1117 | 1109 | public function code($val = -1) |
1118 | 1110 | { |
1119 | - if($val == -1) |
|
1111 | + if ($val == -1) |
|
1120 | 1112 | { |
1121 | 1113 | return $this->exit_code; |
1122 | 1114 | } |
1123 | 1115 | else |
1124 | 1116 | { |
1125 | - if($this->exit_code < $val) |
|
1117 | + if ($this->exit_code < $val) |
|
1126 | 1118 | { |
1127 | 1119 | $this->exit_code = $val; |
1128 | 1120 | } |
@@ -1184,7 +1176,7 @@ discard block |
||
1184 | 1176 | */ |
1185 | 1177 | public function __destruct() |
1186 | 1178 | { |
1187 | - if($this->file_name) |
|
1179 | + if ($this->file_name) |
|
1188 | 1180 | { |
1189 | 1181 | unlink($this->file_name); |
1190 | 1182 | $this->file_name = NULL; |
@@ -1214,12 +1206,12 @@ discard block |
||
1214 | 1206 | $cmdname = CMD_NAME; |
1215 | 1207 | |
1216 | 1208 | // php manual says resources should not normally be declared constant |
1217 | - if(!defined('STDERR')) |
|
1209 | + if (!defined('STDERR')) |
|
1218 | 1210 | { |
1219 | 1211 | define('STDERR', fopen('php://stderr', 'wt')); |
1220 | 1212 | } |
1221 | 1213 | |
1222 | - if(!defined('__DIR__')) |
|
1214 | + if (!defined('__DIR__')) |
|
1223 | 1215 | { |
1224 | 1216 | define('__DIR__', dirname(__FILE__)); |
1225 | 1217 | } |
@@ -1234,7 +1226,7 @@ discard block |
||
1234 | 1226 | $query_args = NULL; |
1235 | 1227 | $query_args_file = NULL; |
1236 | 1228 | |
1237 | - while($argc >= 2 && $argv[1][0] == '-') |
|
1229 | + while ($argc >= 2 && $argv[1][0] == '-') |
|
1238 | 1230 | { |
1239 | 1231 | $option = $argv[1]; |
1240 | 1232 | |
@@ -1242,17 +1234,17 @@ discard block |
||
1242 | 1234 | $argv = array_values($argv); |
1243 | 1235 | $argc = count($argv); |
1244 | 1236 | |
1245 | - switch($option) |
|
1237 | + switch ($option) |
|
1246 | 1238 | { |
1247 | 1239 | case '-s': |
1248 | 1240 | case '--schema': |
1249 | 1241 | case '--schema-language': |
1250 | - if($query_args !== NULL) |
|
1242 | + if ($query_args !== NULL) |
|
1251 | 1243 | { |
1252 | 1244 | throw new SyntaxError("Both --args-string and --schema-language options given."); |
1253 | 1245 | } |
1254 | 1246 | |
1255 | - if($query_args_file !== NULL) |
|
1247 | + if ($query_args_file !== NULL) |
|
1256 | 1248 | { |
1257 | 1249 | throw new SyntaxError("Both --args-file and --schema-language options given."); |
1258 | 1250 | } |
@@ -1272,7 +1264,7 @@ discard block |
||
1272 | 1264 | |
1273 | 1265 | case '--xe-path': |
1274 | 1266 | case '--xe': |
1275 | - if($argc < 2) |
|
1267 | + if ($argc < 2) |
|
1276 | 1268 | { |
1277 | 1269 | throw |
1278 | 1270 | new SyntaxError("Option '{$option}' requires an argument., see `{$cmdname} --help`"); |
@@ -1290,17 +1282,17 @@ discard block |
||
1290 | 1282 | case '--args-string': |
1291 | 1283 | case '--arguments': |
1292 | 1284 | case '--args': |
1293 | - if($schema_language !== NULL) |
|
1285 | + if ($schema_language !== NULL) |
|
1294 | 1286 | { |
1295 | 1287 | throw new SyntaxError("Both --schema-language and --args-string options given."); |
1296 | 1288 | } |
1297 | 1289 | |
1298 | - if($query_args_file !== NULL) |
|
1290 | + if ($query_args_file !== NULL) |
|
1299 | 1291 | { |
1300 | 1292 | throw new SyntaxError("Both --args-string and --args-file options given."); |
1301 | 1293 | } |
1302 | 1294 | |
1303 | - if($argc < 2) |
|
1295 | + if ($argc < 2) |
|
1304 | 1296 | { |
1305 | 1297 | throw |
1306 | 1298 | new SyntaxError("Option '{$option}' requires an argument., see `{$cmdname} --help`"); |
@@ -1316,17 +1308,17 @@ discard block |
||
1316 | 1308 | |
1317 | 1309 | case '--arguments-file': |
1318 | 1310 | case '--args-file': |
1319 | - if($schema_language !== NULL) |
|
1311 | + if ($schema_language !== NULL) |
|
1320 | 1312 | { |
1321 | 1313 | throw new SyntaxError("Both --schema-language and --args-file options given."); |
1322 | 1314 | } |
1323 | 1315 | |
1324 | - if($query_args !== NULL) |
|
1316 | + if ($query_args !== NULL) |
|
1325 | 1317 | { |
1326 | 1318 | throw new SyntaxError("Both --args-string and --args-file options given."); |
1327 | 1319 | } |
1328 | 1320 | |
1329 | - if($argc < 2) |
|
1321 | + if ($argc < 2) |
|
1330 | 1322 | { |
1331 | 1323 | throw |
1332 | 1324 | new SyntaxError("Option '{$option}' requires an argument., see `{$cmdname} --help`"); |
@@ -1357,7 +1349,7 @@ discard block |
||
1357 | 1349 | } |
1358 | 1350 | } |
1359 | 1351 | |
1360 | - if($argc < 2 || |
|
1352 | + if ($argc < 2 || |
|
1361 | 1353 | ( |
1362 | 1354 | $argc == 2 |
1363 | 1355 | && |
@@ -1415,21 +1407,21 @@ discard block |
||
1415 | 1407 | $query_user_args = array(); |
1416 | 1408 | |
1417 | 1409 | // check $xe_path, $query_args |
1418 | - if(!$validate_only) |
|
1410 | + if (!$validate_only) |
|
1419 | 1411 | { |
1420 | - if($xe_path == NULL) |
|
1412 | + if ($xe_path == NULL) |
|
1421 | 1413 | { |
1422 | 1414 | // assume validator.php is in directory .../xe/tools/dbxml_validator/ in an XE installation |
1423 | 1415 | $xe_path = dirname(dirname(realpath(__DIR__))); |
1424 | 1416 | } |
1425 | 1417 | |
1426 | - if(!file_exists($xe_path . '/index.php')) |
|
1418 | + if (!file_exists($xe_path . '/index.php')) |
|
1427 | 1419 | { |
1428 | 1420 | throw |
1429 | 1421 | new ErrorMessage("File index.php not found in {$xe_path}."); |
1430 | 1422 | } |
1431 | 1423 | |
1432 | - if(!defined('_XE_PATH_')) |
|
1424 | + if (!defined('_XE_PATH_')) |
|
1433 | 1425 | { |
1434 | 1426 | define('_XE_PATH_', $xe_path . '/'); |
1435 | 1427 | } |
@@ -1485,7 +1477,7 @@ discard block |
||
1485 | 1477 | */ |
1486 | 1478 | public static function getDBType() |
1487 | 1479 | { |
1488 | - if(self::$db_info) |
|
1480 | + if (self::$db_info) |
|
1489 | 1481 | { |
1490 | 1482 | return self::$db_info->master_db['db_type']; |
1491 | 1483 | } |
@@ -1538,10 +1530,9 @@ discard block |
||
1538 | 1530 | */ |
1539 | 1531 | public static function setNoDBInfo() |
1540 | 1532 | { |
1541 | - $db_info = (object)NULL; |
|
1533 | + $db_info = (object) NULL; |
|
1542 | 1534 | $db_info->master_db = |
1543 | - array |
|
1544 | - ( |
|
1535 | + array( |
|
1545 | 1536 | 'db_type' => NULL, |
1546 | 1537 | 'db_hostname' => NULL, |
1547 | 1538 | 'db_port' => NULL, |
@@ -1565,10 +1556,9 @@ discard block |
||
1565 | 1556 | */ |
1566 | 1557 | public static function setMysqlDBInfo() |
1567 | 1558 | { |
1568 | - $db_info = (object)NULL; |
|
1559 | + $db_info = (object) NULL; |
|
1569 | 1560 | $db_info->master_db = |
1570 | - array |
|
1571 | - ( |
|
1561 | + array( |
|
1572 | 1562 | 'db_type' => 'mysql', |
1573 | 1563 | 'db_hostname' => NULL, |
1574 | 1564 | 'db_port' => NULL, |
@@ -1584,7 +1574,7 @@ discard block |
||
1584 | 1574 | |
1585 | 1575 | self::setDBInfo($db_info); |
1586 | 1576 | |
1587 | - if(array_key_exists('__DB__', $GLOBALS) |
|
1577 | + if (array_key_exists('__DB__', $GLOBALS) |
|
1588 | 1578 | && |
1589 | 1579 | array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__'])) |
1590 | 1580 | { |
@@ -1607,10 +1597,9 @@ discard block |
||
1607 | 1597 | */ |
1608 | 1598 | public static function setMysqliDBInfo() |
1609 | 1599 | { |
1610 | - $db_info = (object)NULL; |
|
1600 | + $db_info = (object) NULL; |
|
1611 | 1601 | $db_info->master_db = |
1612 | - array |
|
1613 | - ( |
|
1602 | + array( |
|
1614 | 1603 | 'db_type' => 'mysqli', |
1615 | 1604 | 'db_hostname' => NULL, |
1616 | 1605 | 'db_port' => NULL, |
@@ -1626,7 +1615,7 @@ discard block |
||
1626 | 1615 | |
1627 | 1616 | self::setDBInfo($db_info); |
1628 | 1617 | |
1629 | - if(array_key_exists('__DB__', $GLOBALS) |
|
1618 | + if (array_key_exists('__DB__', $GLOBALS) |
|
1630 | 1619 | && |
1631 | 1620 | array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__'])) |
1632 | 1621 | { |
@@ -1649,10 +1638,9 @@ discard block |
||
1649 | 1638 | */ |
1650 | 1639 | public static function setCubridDBInfo() |
1651 | 1640 | { |
1652 | - $db_info = (object)NULL; |
|
1641 | + $db_info = (object) NULL; |
|
1653 | 1642 | $db_info->master_db = |
1654 | - array |
|
1655 | - ( |
|
1643 | + array( |
|
1656 | 1644 | 'db_type' => 'cubrid', |
1657 | 1645 | 'db_hostname' => NULL, |
1658 | 1646 | 'db_port' => NULL, |
@@ -1668,7 +1656,7 @@ discard block |
||
1668 | 1656 | |
1669 | 1657 | self::setDBInfo($db_info); |
1670 | 1658 | |
1671 | - if(array_key_exists('__DB__', $GLOBALS) |
|
1659 | + if (array_key_exists('__DB__', $GLOBALS) |
|
1672 | 1660 | && |
1673 | 1661 | array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__'])) |
1674 | 1662 | { |
@@ -1691,10 +1679,9 @@ discard block |
||
1691 | 1679 | */ |
1692 | 1680 | public static function setMssqlDBInfo() |
1693 | 1681 | { |
1694 | - $db_info = (object)NULL; |
|
1682 | + $db_info = (object) NULL; |
|
1695 | 1683 | $db_info->master_db = |
1696 | - array |
|
1697 | - ( |
|
1684 | + array( |
|
1698 | 1685 | 'db_type' => 'mssql', |
1699 | 1686 | 'db_hostname' => NULL, |
1700 | 1687 | 'db_port' => NULL, |
@@ -1710,7 +1697,7 @@ discard block |
||
1710 | 1697 | |
1711 | 1698 | self::setDBInfo($db_info); |
1712 | 1699 | |
1713 | - if(array_key_exists('__DB__', $GLOBALS) |
|
1700 | + if (array_key_exists('__DB__', $GLOBALS) |
|
1714 | 1701 | && |
1715 | 1702 | array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__'])) |
1716 | 1703 | { |
@@ -1765,25 +1752,25 @@ discard block |
||
1765 | 1752 | } |
1766 | 1753 | |
1767 | 1754 | global $lang; |
1768 | - $lang = new Any_prop_obj_base(); // to return NULL on non-existent properties |
|
1755 | + $lang = new Any_prop_obj_base(); // to return NULL on non-existent properties |
|
1769 | 1756 | $lang->filter = New LangArgFilterErrorMessage(); |
1770 | 1757 | |
1771 | - if(!defined('__XE__')) |
|
1758 | + if (!defined('__XE__')) |
|
1772 | 1759 | { |
1773 | 1760 | define('__XE__', TRUE); |
1774 | 1761 | } |
1775 | 1762 | |
1776 | - if(!defined('__ZBXE__')) |
|
1763 | + if (!defined('__ZBXE__')) |
|
1777 | 1764 | { |
1778 | 1765 | define('__ZBXE__', TRUE); |
1779 | 1766 | } |
1780 | 1767 | |
1781 | - if(!defined('__DEBUG__')) |
|
1768 | + if (!defined('__DEBUG__')) |
|
1782 | 1769 | { |
1783 | 1770 | define('__DEBUG__', 0); |
1784 | 1771 | } |
1785 | 1772 | |
1786 | - if(!defined('__DEBUG_QUERY__')) |
|
1773 | + if (!defined('__DEBUG_QUERY__')) |
|
1787 | 1774 | { |
1788 | 1775 | define('__DEBUG_QUERY__', 0); |
1789 | 1776 | } |
@@ -1807,7 +1794,7 @@ discard block |
||
1807 | 1794 | require_once(__DIR__ . '/connect_wrapper.php'); |
1808 | 1795 | |
1809 | 1796 | // check $query_args, $query_args_file |
1810 | - if($query_args_file) |
|
1797 | + if ($query_args_file) |
|
1811 | 1798 | { |
1812 | 1799 | try |
1813 | 1800 | { |
@@ -1821,7 +1808,7 @@ discard block |
||
1821 | 1808 | } |
1822 | 1809 | else |
1823 | 1810 | { |
1824 | - if($query_args) |
|
1811 | + if ($query_args) |
|
1825 | 1812 | { |
1826 | 1813 | try |
1827 | 1814 | { |
@@ -1841,8 +1828,7 @@ discard block |
||
1841 | 1828 | |
1842 | 1829 | $schema_file = NULL; |
1843 | 1830 | $schemas_set = |
1844 | - array |
|
1845 | - ( |
|
1831 | + array( |
|
1846 | 1832 | 'delete' => __DIR__ . '/xml_delete.xsd', |
1847 | 1833 | 'update' => __DIR__ . '/xml_update.xsd', |
1848 | 1834 | 'select' => __DIR__ . '/xml_select.xsd', |
@@ -1855,12 +1841,12 @@ discard block |
||
1855 | 1841 | |
1856 | 1842 | $i = 1; |
1857 | 1843 | |
1858 | - if(pathinfo($argv[1], PATHINFO_EXTENSION) == 'xsd') |
|
1844 | + if (pathinfo($argv[1], PATHINFO_EXTENSION) == 'xsd') |
|
1859 | 1845 | { |
1860 | 1846 | $schema_file = $argv[$i++]; |
1861 | 1847 | } |
1862 | 1848 | |
1863 | - for(; $i < count($argv); $i++) |
|
1849 | + for (; $i < count($argv); $i++) |
|
1864 | 1850 | { |
1865 | 1851 | try |
1866 | 1852 | { |
@@ -1869,7 +1855,7 @@ discard block |
||
1869 | 1855 | $use_schema_language = $schema_language; |
1870 | 1856 | |
1871 | 1857 | $retcode->push(ReturnCode::RETCODE_GENERIC_XML_SYNTAX); |
1872 | - if($domDocument->load($argv[$i])) |
|
1858 | + if ($domDocument->load($argv[$i])) |
|
1873 | 1859 | { |
1874 | 1860 | $retcode->pop(); |
1875 | 1861 | |
@@ -1883,7 +1869,7 @@ discard block |
||
1883 | 1869 | } |
1884 | 1870 | } |
1885 | 1871 | |
1886 | - if(!$schema_file && !$use_schema_language |
|
1872 | + if (!$schema_file && !$use_schema_language |
|
1887 | 1873 | && |
1888 | 1874 | ( |
1889 | 1875 | $queryElement->tagName != 'query' |
@@ -1903,7 +1889,7 @@ discard block |
||
1903 | 1889 | ); |
1904 | 1890 | } |
1905 | 1891 | |
1906 | - if(!$schema_file && !$use_schema_language && !$skip_query_id |
|
1892 | + if (!$schema_file && !$use_schema_language && !$skip_query_id |
|
1907 | 1893 | && |
1908 | 1894 | !validate_query_id($argv[$i], $queryElement->getAttribute('id'))) |
1909 | 1895 | { |
@@ -1916,24 +1902,24 @@ discard block |
||
1916 | 1902 | ); |
1917 | 1903 | } |
1918 | 1904 | |
1919 | - if($use_schema_language) |
|
1905 | + if ($use_schema_language) |
|
1920 | 1906 | { |
1921 | 1907 | $document_schema = $table_schema; |
1922 | 1908 | } |
1923 | 1909 | else |
1924 | 1910 | { |
1925 | - if(!$document_schema) |
|
1911 | + if (!$document_schema) |
|
1926 | 1912 | { |
1927 | 1913 | $document_schema = $schemas_set[$queryElement->getAttribute('action')]; |
1928 | 1914 | } |
1929 | 1915 | } |
1930 | 1916 | |
1931 | 1917 | $retcode->push(ReturnCode::RETCODE_XSD_VALIDATION); |
1932 | - if($domDocument->schemaValidate($document_schema)) |
|
1918 | + if ($domDocument->schemaValidate($document_schema)) |
|
1933 | 1919 | { |
1934 | 1920 | $retcode->pop(); |
1935 | 1921 | |
1936 | - if($use_schema_language) |
|
1922 | + if ($use_schema_language) |
|
1937 | 1923 | { |
1938 | 1924 | validate_schema_doc($argv[$i], $domDocument->documentElement); |
1939 | 1925 | } |
@@ -1944,22 +1930,22 @@ discard block |
||
1944 | 1930 | $success = TRUE; |
1945 | 1931 | } |
1946 | 1932 | |
1947 | - if(!$validate_only) |
|
1933 | + if (!$validate_only) |
|
1948 | 1934 | { |
1949 | 1935 | // Generate SQL with the db provider back-ends |
1950 | 1936 | |
1951 | - if(function_exists('sys_get_temp_dir')) |
|
1937 | + if (function_exists('sys_get_temp_dir')) |
|
1952 | 1938 | { |
1953 | 1939 | $tmpdir = sys_get_temp_dir(); |
1954 | 1940 | } |
1955 | 1941 | else |
1956 | 1942 | { |
1957 | 1943 | $tmpdir = getenv('TEMP'); |
1958 | - if(!$tmpdir) |
|
1944 | + if (!$tmpdir) |
|
1959 | 1945 | { |
1960 | 1946 | $tmpdir = getenv('TMP'); |
1961 | 1947 | } |
1962 | - if(!$tmpdir) |
|
1948 | + if (!$tmpdir) |
|
1963 | 1949 | { |
1964 | 1950 | $tmpdir = '/tmp'; |
1965 | 1951 | } |
@@ -1968,30 +1954,29 @@ discard block |
||
1968 | 1954 | |
1969 | 1955 | global $_SERVER; |
1970 | 1956 | |
1971 | - if(!is_array($_SERVER)) |
|
1957 | + if (!is_array($_SERVER)) |
|
1972 | 1958 | { |
1973 | 1959 | $_SERVER = array(); |
1974 | 1960 | } |
1975 | 1961 | |
1976 | - if(!array_key_exists('REMOTE_ADDR', $_SERVER)) |
|
1962 | + if (!array_key_exists('REMOTE_ADDR', $_SERVER)) |
|
1977 | 1963 | { |
1978 | 1964 | $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; |
1979 | 1965 | } |
1980 | 1966 | |
1981 | 1967 | $set_db_info_methods = |
1982 | - array |
|
1983 | - ( |
|
1968 | + array( |
|
1984 | 1969 | 'mysql' => 'setMysqlDBInfo', |
1985 | 1970 | 'mysqli' => 'setMysqliDBInfo', |
1986 | 1971 | 'cubrid' => 'setCubridDBInfo', |
1987 | 1972 | 'mssql' => 'setMssqlDBInfo' |
1988 | 1973 | ); |
1989 | 1974 | |
1990 | - foreach($set_db_info_methods as $db_type => $set_info_method) |
|
1975 | + foreach ($set_db_info_methods as $db_type => $set_info_method) |
|
1991 | 1976 | { |
1992 | 1977 | Context::$set_info_method(); // calls setMysqlDBInfo()/setCubridDBInfo()/... |
1993 | 1978 | |
1994 | - if($use_schema_language) |
|
1979 | + if ($use_schema_language) |
|
1995 | 1980 | { |
1996 | 1981 | $GLOBALS['__DB__'][$db_type]->queries = ''; |
1997 | 1982 | $GLOBALS['__DB__'][$db_type]->createTableByXmlFile($argv[$i]); |
@@ -2010,26 +1995,25 @@ discard block |
||
2010 | 1995 | // copied from classes/db/DB.class.php |
2011 | 1996 | $oParser = new XmlQueryParser(); |
2012 | 1997 | $args_array = |
2013 | - $oParser->parse_xml_query |
|
2014 | - ( |
|
1998 | + $oParser->parse_xml_query( |
|
2015 | 1999 | pathinfo($argv[$i], PATHINFO_FILENAME), // query id |
2016 | - $argv[$i], // xml file |
|
2000 | + $argv[$i], // xml file |
|
2017 | 2001 | $unlink_tmpfile->file_name // cache file |
2018 | 2002 | ); |
2019 | 2003 | $args_array = $args_array->queryTag->getArguments(); |
2020 | 2004 | |
2021 | 2005 | $GLOBALS['__DB__'][$db_type]->queries = ''; |
2022 | 2006 | $k = 1; |
2023 | - foreach($args_array as $arg) |
|
2007 | + foreach ($args_array as $arg) |
|
2024 | 2008 | { |
2025 | - if(// why would there be a query arg without a var name ? |
|
2009 | + if (// why would there be a query arg without a var name ? |
|
2026 | 2010 | isset($arg->variable_name) |
2027 | 2011 | && |
2028 | 2012 | !array_key_exists($arg->variable_name, $query_user_args)) |
2029 | 2013 | { |
2030 | - if(isset($arg->argument_validator)) |
|
2014 | + if (isset($arg->argument_validator)) |
|
2031 | 2015 | { |
2032 | - if(FALSE // some default values are to be parsed by php, some are not... |
|
2016 | + if (FALSE // some default values are to be parsed by php, some are not... |
|
2033 | 2017 | && |
2034 | 2018 | isset($arg->argument_validator->default_value) |
2035 | 2019 | && |
@@ -2040,9 +2024,9 @@ discard block |
||
2040 | 2024 | } |
2041 | 2025 | else |
2042 | 2026 | { |
2043 | - if($arg->argument_validator->filter) |
|
2027 | + if ($arg->argument_validator->filter) |
|
2044 | 2028 | { |
2045 | - switch($arg->argument_validator->filter) |
|
2029 | + switch ($arg->argument_validator->filter) |
|
2046 | 2030 | { |
2047 | 2031 | case 'email': |
2048 | 2032 | case 'email_address': |
@@ -2081,18 +2065,17 @@ discard block |
||
2081 | 2065 | } |
2082 | 2066 | } |
2083 | 2067 | |
2084 | - if(!array_key_exists($arg->variable_name, $query_user_args)) |
|
2068 | + if (!array_key_exists($arg->variable_name, $query_user_args)) |
|
2085 | 2069 | { |
2086 | 2070 | $query_user_args[$arg->variable_name] = sprintf('%06d', $k); |
2087 | 2071 | } |
2088 | 2072 | |
2089 | - if(isset($arg->argument_validator)) |
|
2073 | + if (isset($arg->argument_validator)) |
|
2090 | 2074 | { |
2091 | - if(isset($arg->argument_validator->min_length)) |
|
2075 | + if (isset($arg->argument_validator->min_length)) |
|
2092 | 2076 | { |
2093 | 2077 | $query_user_args[$arg->variable_name] = |
2094 | - str_pad |
|
2095 | - ( |
|
2078 | + str_pad( |
|
2096 | 2079 | $query_user_args[$arg->variable_name], |
2097 | 2080 | $arg->argument_validator->min_length, |
2098 | 2081 | isset($arg->argument_validator->filter) && |
@@ -2105,11 +2088,10 @@ discard block |
||
2105 | 2088 | ); |
2106 | 2089 | } |
2107 | 2090 | |
2108 | - if(isset($arg->argument_validator->max_length)) |
|
2091 | + if (isset($arg->argument_validator->max_length)) |
|
2109 | 2092 | { |
2110 | 2093 | $query_user_args[$arg->variable_name] = |
2111 | - substr |
|
2112 | - ( |
|
2094 | + substr( |
|
2113 | 2095 | $query_user_args[$arg->variable_name], |
2114 | 2096 | 0, |
2115 | 2097 | $arg->argument_validator->max_length |
@@ -2122,15 +2104,14 @@ discard block |
||
2122 | 2104 | } |
2123 | 2105 | |
2124 | 2106 | $resultset = |
2125 | - $GLOBALS['__DB__'][$db_type]->_executeQuery |
|
2126 | - ( |
|
2127 | - $unlink_tmpfile->file_name, // cache_file |
|
2128 | - (object)$query_user_args, // source_args |
|
2129 | - basename($argv[$i]), // query_id |
|
2107 | + $GLOBALS['__DB__'][$db_type]->_executeQuery( |
|
2108 | + $unlink_tmpfile->file_name, // cache_file |
|
2109 | + (object) $query_user_args, // source_args |
|
2110 | + basename($argv[$i]), // query_id |
|
2130 | 2111 | array() // arg_columns |
2131 | 2112 | ); |
2132 | 2113 | |
2133 | - if(is_a($resultset, 'Object') && !$resultset->toBool()) |
|
2114 | + if (is_a($resultset, 'Object') && !$resultset->toBool()) |
|
2134 | 2115 | { |
2135 | 2116 | throw new XmlSchemaError($argv[$i], -1, 'mysql SQL query generation failed'); |
2136 | 2117 | } |
@@ -2147,7 +2128,7 @@ discard block |
||
2147 | 2128 | } |
2148 | 2129 | } |
2149 | 2130 | |
2150 | - if(!$success) |
|
2131 | + if (!$success) |
|
2151 | 2132 | { |
2152 | 2133 | libXmlDisplayError($argv[$i], TRUE); |
2153 | 2134 | } |
@@ -2160,7 +2141,7 @@ discard block |
||
2160 | 2141 | } |
2161 | 2142 | catch (ErrorMessage $exc) |
2162 | 2143 | { |
2163 | - if($retcode->code() == ReturnCode::RETCODE_SUCCESS) |
|
2144 | + if ($retcode->code() == ReturnCode::RETCODE_SUCCESS) |
|
2164 | 2145 | { |
2165 | 2146 | $retcode->code(ReturnCode::RETCODE_VALIDATOR_INTERNAL); |
2166 | 2147 | } |
@@ -2170,7 +2151,7 @@ discard block |
||
2170 | 2151 | } |
2171 | 2152 | catch (ErrorException $exc) |
2172 | 2153 | { |
2173 | - if($retcode->code() == ReturnCode::RETCODE_SUCCESS) |
|
2154 | + if ($retcode->code() == ReturnCode::RETCODE_SUCCESS) |
|
2174 | 2155 | { |
2175 | 2156 | $retcode->code(ReturnCode::RETCODE_VALIDATOR_INTERNAL); |
2176 | 2157 | } |
@@ -2194,21 +2175,21 @@ discard block |
||
2194 | 2175 | catch (SyntaxError $syntax) |
2195 | 2176 | { |
2196 | 2177 | fwrite(STDERR, $syntax->getMessage() . "\n"); |
2197 | - exit(254); // wrong command line |
|
2178 | + exit(254); // wrong command line |
|
2198 | 2179 | // 255 is reserved by php (for parse errors, etc.) |
2199 | 2180 | } |
2200 | 2181 | catch (ErrorMessage $exc) |
2201 | 2182 | { |
2202 | 2183 | fwrite(STDERR, $exc->getMessage() . "\n"); |
2203 | 2184 | libXmlDisplayError(); |
2204 | - exit(ReturnCode::RETCODE_VALIDATOR_INTERNAL); // internal validator error |
|
2185 | + exit(ReturnCode::RETCODE_VALIDATOR_INTERNAL); // internal validator error |
|
2205 | 2186 | } |
2206 | 2187 | catch (Exception $exc) |
2207 | 2188 | { |
2208 | 2189 | fwrite(STDERR, $exc->getFile() . '(' . $exc->getLine() . ")\n\t" . $exc->getMessage() . "\n"); |
2209 | 2190 | fwrite(STDERR, $exc->getTraceAsString()); |
2210 | 2191 | libXmlDisplayError(); |
2211 | - exit(ReturnCode::RETCODE_VALIDATOR_INTERNAL); // internal validator error |
|
2192 | + exit(ReturnCode::RETCODE_VALIDATOR_INTERNAL); // internal validator error |
|
2212 | 2193 | } |
2213 | 2194 | |
2214 | 2195 | /* End of file validate.php */ |
@@ -150,13 +150,11 @@ discard block |
||
150 | 150 | if($throw_error) |
151 | 151 | { |
152 | 152 | throw new ErrorMessage($msg); |
153 | - } |
|
154 | - else |
|
153 | + } else |
|
155 | 154 | { |
156 | 155 | fwrite(STDERR, $msg . "\n"); |
157 | 156 | } |
158 | - } |
|
159 | - else |
|
157 | + } else |
|
160 | 158 | { |
161 | 159 | if($throw_error) |
162 | 160 | { |
@@ -346,8 +344,7 @@ discard block |
||
346 | 344 | "\nANSI SQL-99 declares the table specification as required." |
347 | 345 | ); |
348 | 346 | } |
349 | - } |
|
350 | - else |
|
347 | + } else |
|
351 | 348 | { |
352 | 349 | // base table or view |
353 | 350 | |
@@ -369,13 +366,11 @@ discard block |
||
369 | 366 | $child_node->getLineNo(), |
370 | 367 | 'Duplicate <conditions> elements.' |
371 | 368 | ); |
372 | - } |
|
373 | - else |
|
369 | + } else |
|
374 | 370 | { |
375 | 371 | $has_conditions_element = TRUE; |
376 | 372 | } |
377 | - } |
|
378 | - else |
|
373 | + } else |
|
379 | 374 | { |
380 | 375 | throw |
381 | 376 | new XmlSchemaError( |
@@ -396,8 +391,7 @@ discard block |
||
396 | 391 | 'Expected <conditions> element as content.' |
397 | 392 | ); |
398 | 393 | } |
399 | - } |
|
400 | - else |
|
394 | + } else |
|
401 | 395 | { |
402 | 396 | foreach($table_element->childNodes as $child_node) |
403 | 397 | { |
@@ -609,8 +603,7 @@ discard block |
||
609 | 603 | if($first_child) |
610 | 604 | { |
611 | 605 | $first_child = FALSE; |
612 | - } |
|
613 | - else |
|
606 | + } else |
|
614 | 607 | { |
615 | 608 | if(!$child_node->hasAttribute('pipe')) |
616 | 609 | { |
@@ -629,14 +622,12 @@ discard block |
||
629 | 622 | if($child_node->tagName == 'group') |
630 | 623 | { |
631 | 624 | checkConditionsGroup($xml_file, $child_node); |
632 | - } |
|
633 | - else |
|
625 | + } else |
|
634 | 626 | { |
635 | 627 | if($child_node->tagName == 'query') |
636 | 628 | { |
637 | 629 | validate_select_query($xml_file, $child_node); |
638 | - } |
|
639 | - else |
|
630 | + } else |
|
640 | 631 | { |
641 | 632 | if($child_node->tagName == 'condition') |
642 | 633 | { |
@@ -851,8 +842,7 @@ discard block |
||
851 | 842 | try |
852 | 843 | { |
853 | 844 | $success = chdir($this->dirname); |
854 | - } |
|
855 | - catch (Exception $e) |
|
845 | + } catch (Exception $e) |
|
856 | 846 | { |
857 | 847 | print "Failed to restore working dir {$this->dirname}."; |
858 | 848 | } |
@@ -921,8 +911,7 @@ discard block |
||
921 | 911 | if($lowercase_name[$i] != $uppercase_name[$i]) |
922 | 912 | { |
923 | 913 | $varing_case_filename .= "[{$lowercase_name[$i]}{$uppercase_name[$i]}]"; |
924 | - } |
|
925 | - else |
|
914 | + } else |
|
926 | 915 | { |
927 | 916 | $varing_case_filename .= $lowercase_name[$i]; |
928 | 917 | } |
@@ -1119,8 +1108,7 @@ discard block |
||
1119 | 1108 | if($val == -1) |
1120 | 1109 | { |
1121 | 1110 | return $this->exit_code; |
1122 | - } |
|
1123 | - else |
|
1111 | + } else |
|
1124 | 1112 | { |
1125 | 1113 | if($this->exit_code < $val) |
1126 | 1114 | { |
@@ -1488,8 +1476,7 @@ discard block |
||
1488 | 1476 | if(self::$db_info) |
1489 | 1477 | { |
1490 | 1478 | return self::$db_info->master_db['db_type']; |
1491 | - } |
|
1492 | - else |
|
1479 | + } else |
|
1493 | 1480 | { |
1494 | 1481 | return NULL; |
1495 | 1482 | } |
@@ -1588,8 +1575,7 @@ discard block |
||
1588 | 1575 | && |
1589 | 1576 | array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__'])) |
1590 | 1577 | { |
1591 | - } |
|
1592 | - else |
|
1578 | + } else |
|
1593 | 1579 | { |
1594 | 1580 | $GLOBALS['__DB__'][$db_info->master_db['db_type']] = |
1595 | 1581 | new DBMysqlConnectWrapper(); |
@@ -1630,8 +1616,7 @@ discard block |
||
1630 | 1616 | && |
1631 | 1617 | array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__'])) |
1632 | 1618 | { |
1633 | - } |
|
1634 | - else |
|
1619 | + } else |
|
1635 | 1620 | { |
1636 | 1621 | $GLOBALS['__DB__'][$db_info->master_db['db_type']] = |
1637 | 1622 | new DBMysqliConnectWrapper(); |
@@ -1672,8 +1657,7 @@ discard block |
||
1672 | 1657 | && |
1673 | 1658 | array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__'])) |
1674 | 1659 | { |
1675 | - } |
|
1676 | - else |
|
1660 | + } else |
|
1677 | 1661 | { |
1678 | 1662 | $GLOBALS['__DB__'][$db_info->master_db['db_type']] = |
1679 | 1663 | new DBCubridConnectWrapper(); |
@@ -1714,8 +1698,7 @@ discard block |
||
1714 | 1698 | && |
1715 | 1699 | array_key_exists($db_info->master_db['db_type'], $GLOBALS['__DB__'])) |
1716 | 1700 | { |
1717 | - } |
|
1718 | - else |
|
1701 | + } else |
|
1719 | 1702 | { |
1720 | 1703 | $GLOBALS['__DB__'][$db_info->master_db['db_type']] = |
1721 | 1704 | new DBMssqlConnectWrapper(); |
@@ -1812,22 +1795,19 @@ discard block |
||
1812 | 1795 | try |
1813 | 1796 | { |
1814 | 1797 | $query_user_args = require($query_args_file); |
1815 | - } |
|
1816 | - catch (Exception $exc) |
|
1798 | + } catch (Exception $exc) |
|
1817 | 1799 | { |
1818 | 1800 | fwrite(STDERR, "Error in arguments file.\n"); |
1819 | 1801 | throw $exc; |
1820 | 1802 | } |
1821 | - } |
|
1822 | - else |
|
1803 | + } else |
|
1823 | 1804 | { |
1824 | 1805 | if($query_args) |
1825 | 1806 | { |
1826 | 1807 | try |
1827 | 1808 | { |
1828 | 1809 | eval('$query_user_args = array(' . $query_args . ');'); |
1829 | - } |
|
1830 | - catch (Exception $exc) |
|
1810 | + } catch (Exception $exc) |
|
1831 | 1811 | { |
1832 | 1812 | fwrite(STDERR, "Error in arguments string.\n"); |
1833 | 1813 | throw $exc; |
@@ -1919,8 +1899,7 @@ discard block |
||
1919 | 1899 | if($use_schema_language) |
1920 | 1900 | { |
1921 | 1901 | $document_schema = $table_schema; |
1922 | - } |
|
1923 | - else |
|
1902 | + } else |
|
1924 | 1903 | { |
1925 | 1904 | if(!$document_schema) |
1926 | 1905 | { |
@@ -1936,8 +1915,7 @@ discard block |
||
1936 | 1915 | if($use_schema_language) |
1937 | 1916 | { |
1938 | 1917 | validate_schema_doc($argv[$i], $domDocument->documentElement); |
1939 | - } |
|
1940 | - else |
|
1918 | + } else |
|
1941 | 1919 | { |
1942 | 1920 | validate_xml_query($argv[$i], $domDocument->documentElement); |
1943 | 1921 | } |
@@ -1951,8 +1929,7 @@ discard block |
||
1951 | 1929 | if(function_exists('sys_get_temp_dir')) |
1952 | 1930 | { |
1953 | 1931 | $tmpdir = sys_get_temp_dir(); |
1954 | - } |
|
1955 | - else |
|
1932 | + } else |
|
1956 | 1933 | { |
1957 | 1934 | $tmpdir = getenv('TEMP'); |
1958 | 1935 | if(!$tmpdir) |
@@ -2001,8 +1978,7 @@ discard block |
||
2001 | 1978 | print " {$db_type} query:\n"; |
2002 | 1979 | print $GLOBALS['__DB__'][$db_type]->queries; |
2003 | 1980 | print "\n"; |
2004 | - } |
|
2005 | - else |
|
1981 | + } else |
|
2006 | 1982 | { |
2007 | 1983 | $unlink_tmpfile = |
2008 | 1984 | new UnlinkFile(tempnam($tmpdir, 'xe_')); |
@@ -2037,8 +2013,7 @@ discard block |
||
2037 | 2013 | { |
2038 | 2014 | $query_user_args[$arg->variable_name] = |
2039 | 2015 | eval('return ' . $arg->argument_validator->default_value->toString() . ';'); |
2040 | - } |
|
2041 | - else |
|
2016 | + } else |
|
2042 | 2017 | { |
2043 | 2018 | if($arg->argument_validator->filter) |
2044 | 2019 | { |
@@ -2133,8 +2108,7 @@ discard block |
||
2133 | 2108 | if(is_a($resultset, 'Object') && !$resultset->toBool()) |
2134 | 2109 | { |
2135 | 2110 | throw new XmlSchemaError($argv[$i], -1, 'mysql SQL query generation failed'); |
2136 | - } |
|
2137 | - else |
|
2111 | + } else |
|
2138 | 2112 | { |
2139 | 2113 | print "\n"; |
2140 | 2114 | print pathinfo($argv[$i], PATHINFO_FILENAME); |
@@ -2151,14 +2125,12 @@ discard block |
||
2151 | 2125 | { |
2152 | 2126 | libXmlDisplayError($argv[$i], TRUE); |
2153 | 2127 | } |
2154 | - } |
|
2155 | - catch (XmlSchemaError $exc) |
|
2128 | + } catch (XmlSchemaError $exc) |
|
2156 | 2129 | { |
2157 | 2130 | $retcode->code(ReturnCode::RETCODE_BUILTIN_CHECKS); |
2158 | 2131 | |
2159 | 2132 | fwrite(STDERR, $exc->getMessage() . "\n"); |
2160 | - } |
|
2161 | - catch (ErrorMessage $exc) |
|
2133 | + } catch (ErrorMessage $exc) |
|
2162 | 2134 | { |
2163 | 2135 | if($retcode->code() == ReturnCode::RETCODE_SUCCESS) |
2164 | 2136 | { |
@@ -2167,8 +2139,7 @@ discard block |
||
2167 | 2139 | |
2168 | 2140 | fwrite(STDERR, $exc->getMessage() . "\n"); |
2169 | 2141 | libXmlDisplayError($argv[$i]); |
2170 | - } |
|
2171 | - catch (ErrorException $exc) |
|
2142 | + } catch (ErrorException $exc) |
|
2172 | 2143 | { |
2173 | 2144 | if($retcode->code() == ReturnCode::RETCODE_SUCCESS) |
2174 | 2145 | { |
@@ -2178,8 +2149,7 @@ discard block |
||
2178 | 2149 | fwrite(STDERR, "{$exc->getFile()}({$exc->getLine()}):\n\t{$exc->getMessage()}.\n"); |
2179 | 2150 | fwrite(STDERR, $exc->getTraceAsString()); |
2180 | 2151 | libXmlDisplayError($argv[$i]); |
2181 | - } |
|
2182 | - catch (Exception $exc) |
|
2152 | + } catch (Exception $exc) |
|
2183 | 2153 | { |
2184 | 2154 | $retcode->code(ReturnCode::RETCODE_VALIDATOR_INTERNAL); |
2185 | 2155 | |
@@ -2190,20 +2160,17 @@ discard block |
||
2190 | 2160 | } |
2191 | 2161 | |
2192 | 2162 | exit($retcode->code()); |
2193 | -} |
|
2194 | -catch (SyntaxError $syntax) |
|
2163 | +} catch (SyntaxError $syntax) |
|
2195 | 2164 | { |
2196 | 2165 | fwrite(STDERR, $syntax->getMessage() . "\n"); |
2197 | 2166 | exit(254); // wrong command line |
2198 | 2167 | // 255 is reserved by php (for parse errors, etc.) |
2199 | -} |
|
2200 | -catch (ErrorMessage $exc) |
|
2168 | +} catch (ErrorMessage $exc) |
|
2201 | 2169 | { |
2202 | 2170 | fwrite(STDERR, $exc->getMessage() . "\n"); |
2203 | 2171 | libXmlDisplayError(); |
2204 | 2172 | exit(ReturnCode::RETCODE_VALIDATOR_INTERNAL); // internal validator error |
2205 | -} |
|
2206 | -catch (Exception $exc) |
|
2173 | +} catch (Exception $exc) |
|
2207 | 2174 | { |
2208 | 2175 | fwrite(STDERR, $exc->getFile() . '(' . $exc->getLine() . ")\n\t" . $exc->getMessage() . "\n"); |
2209 | 2176 | fwrite(STDERR, $exc->getTraceAsString()); |
@@ -606,6 +606,11 @@ discard block |
||
606 | 606 | * --------------------------------------------------------------------------------------------- |
607 | 607 | */ |
608 | 608 | |
609 | +/** |
|
610 | + * @param double $v1 |
|
611 | + * @param double $v2 |
|
612 | + * @param integer $vh |
|
613 | + */ |
|
609 | 614 | private function hue_to_rgb($v1, $v2, $vh) |
610 | 615 | { |
611 | 616 | $vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh); |
@@ -620,6 +625,10 @@ discard block |
||
620 | 625 | return intval(floor(floatval($n) + 0.5), 10); |
621 | 626 | } |
622 | 627 | |
628 | +/** |
|
629 | + * @param integer $min |
|
630 | + * @param integer $max |
|
631 | + */ |
|
623 | 632 | private function clamp_number($n, $min, $max) |
624 | 633 | { |
625 | 634 | return min(max($n, $min), $max); |
@@ -648,7 +657,7 @@ discard block |
||
648 | 657 | * |
649 | 658 | * @param string $str |
650 | 659 | * @param int $from index |
651 | - * @param int|bool $to index (optional) |
|
660 | + * @param integer $to index (optional) |
|
652 | 661 | * @return string |
653 | 662 | */ |
654 | 663 | private function substring($str, $from = 0, $to = FALSE) |
@@ -680,7 +689,7 @@ discard block |
||
680 | 689 | * |
681 | 690 | * @param string $str |
682 | 691 | * @param int $start index |
683 | - * @param int|bool $end index (optional) |
|
692 | + * @param integer $end index (optional) |
|
684 | 693 | * @return string |
685 | 694 | */ |
686 | 695 | private function str_slice($str, $start = 0, $end = FALSE) |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $this->memory_limit = 128 * 1048576; // 128MB in bytes |
48 | 48 | $this->max_execution_time = 60; // 1 min |
49 | 49 | $this->pcre_backtrack_limit = 1000 * 1000; |
50 | - $this->pcre_recursion_limit = 500 * 1000; |
|
50 | + $this->pcre_recursion_limit = 500 * 1000; |
|
51 | 51 | |
52 | 52 | $this->raise_php_limits = (bool) $raise_php_limits; |
53 | 53 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | } |
92 | 92 | |
93 | 93 | // preserve strings so their content doesn't get accidentally minified |
94 | - $css = preg_replace_callback('/(?:"(?:[^\\\\"]|\\\\.|\\\\)*")|'."(?:'(?:[^\\\\']|\\\\.|\\\\)*')/S", array($this, 'replace_string'), $css); |
|
94 | + $css = preg_replace_callback('/(?:"(?:[^\\\\"]|\\\\.|\\\\)*")|' . "(?:'(?:[^\\\\']|\\\\.|\\\\)*')/S", array($this, 'replace_string'), $css); |
|
95 | 95 | |
96 | 96 | // Let's divide css code in chunks of 25.000 chars aprox. |
97 | 97 | // Reason: PHP's PCRE functions like preg_replace have a "backtrack limit" |
@@ -229,8 +229,8 @@ discard block |
||
229 | 229 | $token_tring = self::TOKEN . (count($this->preserved_tokens) - 1) . '___'; |
230 | 230 | $css = preg_replace($placeholder, $token_tring, $css, 1); |
231 | 231 | // Preserve new lines for /*! important comments |
232 | - $css = preg_replace('/\s*[\n\r\f]+\s*(\/\*'. $token_tring .')/S', self::NL.'$1', $css); |
|
233 | - $css = preg_replace('/('. $token_tring .'\*\/)\s*[\n\r\f]+\s*/S', '$1'.self::NL, $css); |
|
232 | + $css = preg_replace('/\s*[\n\r\f]+\s*(\/\*' . $token_tring . ')/S', self::NL . '$1', $css); |
|
233 | + $css = preg_replace('/(' . $token_tring . '\*\/)\s*[\n\r\f]+\s*/S', '$1' . self::NL, $css); |
|
234 | 234 | continue; |
235 | 235 | } |
236 | 236 | |
@@ -238,10 +238,10 @@ discard block |
||
238 | 238 | // shorten that to /*\*/ and the next one to /**/ |
239 | 239 | if (substr($token, (strlen($token) - 1), 1) === '\\') { |
240 | 240 | $this->preserved_tokens[] = '\\'; |
241 | - $css = preg_replace($placeholder, self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1); |
|
241 | + $css = preg_replace($placeholder, self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1); |
|
242 | 242 | $i = $i + 1; // attn: advancing the loop |
243 | 243 | $this->preserved_tokens[] = ''; |
244 | - $css = preg_replace('/' . self::COMMENT . $i . '___/', self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1); |
|
244 | + $css = preg_replace('/' . self::COMMENT . $i . '___/', self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1); |
|
245 | 245 | continue; |
246 | 246 | } |
247 | 247 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | if ($start_index > 2) { |
253 | 253 | if (substr($css, $start_index - 3, 1) === '>') { |
254 | 254 | $this->preserved_tokens[] = ''; |
255 | - $css = preg_replace($placeholder, self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1); |
|
255 | + $css = preg_replace($placeholder, self::TOKEN . (count($this->preserved_tokens) - 1) . '___', $css, 1); |
|
256 | 256 | } |
257 | 257 | } |
258 | 258 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | $css = preg_replace('/;;+/', ';', $css); |
367 | 367 | |
368 | 368 | // Restore new lines for /*! important comments |
369 | - $css = preg_replace('/'. self::NL .'/', "\n", $css); |
|
369 | + $css = preg_replace('/' . self::NL . '/', "\n", $css); |
|
370 | 370 | |
371 | 371 | // restore preserved comments and strings |
372 | 372 | for ($i = 0, $max = count($this->preserved_tokens); $i < $max; $i++) { |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | $terminator = ')'; |
411 | 411 | } |
412 | 412 | |
413 | - while ($found_terminator === FALSE && $end_index+1 <= $max_index) { |
|
413 | + while ($found_terminator === FALSE && $end_index + 1 <= $max_index) { |
|
414 | 414 | $end_index = $this->index_of($css, $terminator, $end_index + 1); |
415 | 415 | |
416 | 416 | // endIndex == 0 doesn't really apply here |
@@ -554,7 +554,7 @@ discard block |
||
554 | 554 | private function rgb_to_hex($matches) |
555 | 555 | { |
556 | 556 | // Support for percentage values rgb(100%, 0%, 45%); |
557 | - if ($this->index_of($matches[1], '%') >= 0){ |
|
557 | + if ($this->index_of($matches[1], '%') >= 0) { |
|
558 | 558 | $rgbcolors = explode(',', str_replace('%', '', $matches[1])); |
559 | 559 | for ($i = 0; $i < count($rgbcolors); $i++) { |
560 | 560 | $rgbcolors[$i] = $this->round_number(floatval($rgbcolors[$i]) * 2.55); |
@@ -570,7 +570,7 @@ discard block |
||
570 | 570 | } |
571 | 571 | |
572 | 572 | // Fix for issue #2528093 |
573 | - if (!preg_match('/[\s\,\);\}]/', $matches[2])){ |
|
573 | + if (!preg_match('/[\s\,\);\}]/', $matches[2])) { |
|
574 | 574 | $matches[2] = ' ' . $matches[2]; |
575 | 575 | } |
576 | 576 | |
@@ -594,12 +594,12 @@ discard block |
||
594 | 594 | } else { |
595 | 595 | $v2 = $l < 0.5 ? $l * (1 + $s) : ($l + $s) - ($s * $l); |
596 | 596 | $v1 = (2 * $l) - $v2; |
597 | - $r = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h + (1/3))); |
|
597 | + $r = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h + (1 / 3))); |
|
598 | 598 | $g = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h)); |
599 | - $b = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h - (1/3))); |
|
599 | + $b = $this->round_number(255 * $this->hue_to_rgb($v1, $v2, $h - (1 / 3))); |
|
600 | 600 | } |
601 | 601 | |
602 | - return $this->rgb_to_hex(array('', $r.','.$g.','.$b, $matches[2])); |
|
602 | + return $this->rgb_to_hex(array('', $r . ',' . $g . ',' . $b, $matches[2])); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | /* HELPERS |
@@ -611,7 +611,7 @@ discard block |
||
611 | 611 | $vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh); |
612 | 612 | if ($vh * 6 < 1) return $v1 + ($v2 - $v1) * 6 * $vh; |
613 | 613 | if ($vh * 2 < 1) return $v2; |
614 | - if ($vh * 3 < 2) return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6; |
|
614 | + if ($vh * 3 < 2) return $v1 + ($v2 - $v1) * ((2 / 3) - $vh) * 6; |
|
615 | 615 | return $v1; |
616 | 616 | } |
617 | 617 |
@@ -609,9 +609,15 @@ |
||
609 | 609 | private function hue_to_rgb($v1, $v2, $vh) |
610 | 610 | { |
611 | 611 | $vh = $vh < 0 ? $vh + 1 : ($vh > 1 ? $vh - 1 : $vh); |
612 | - if ($vh * 6 < 1) return $v1 + ($v2 - $v1) * 6 * $vh; |
|
613 | - if ($vh * 2 < 1) return $v2; |
|
614 | - if ($vh * 3 < 2) return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6; |
|
612 | + if ($vh * 6 < 1) { |
|
613 | + return $v1 + ($v2 - $v1) * 6 * $vh; |
|
614 | + } |
|
615 | + if ($vh * 2 < 1) { |
|
616 | + return $v2; |
|
617 | + } |
|
618 | + if ($vh * 3 < 2) { |
|
619 | + return $v1 + ($v2 - $v1) * ((2/3) - $vh) * 6; |
|
620 | + } |
|
615 | 621 | return $v1; |
616 | 622 | } |
617 | 623 |