Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
14 | class Context |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * Allow rewrite |
||
19 | * @var bool TRUE: using rewrite mod, FALSE: otherwise |
||
20 | */ |
||
21 | public $allow_rewrite = FALSE; |
||
22 | |||
23 | /** |
||
24 | * Request method |
||
25 | * @var string GET|POST|XMLRPC |
||
26 | */ |
||
27 | public $request_method = 'GET'; |
||
28 | |||
29 | /** |
||
30 | * js callback function name. |
||
31 | * @var string |
||
32 | */ |
||
33 | public $js_callback_func = ''; |
||
34 | |||
35 | /** |
||
36 | * Response method.If it's not set, it follows request method. |
||
37 | * @var string HTML|XMLRPC |
||
38 | */ |
||
39 | public $response_method = ''; |
||
40 | |||
41 | /** |
||
42 | * Conatins request parameters and environment variables |
||
43 | * @var object |
||
44 | */ |
||
45 | public $context = NULL; |
||
46 | |||
47 | /** |
||
48 | * DB info |
||
49 | * @var object |
||
50 | */ |
||
51 | public $db_info = NULL; |
||
52 | |||
53 | /** |
||
54 | * FTP info |
||
55 | * @var object |
||
56 | */ |
||
57 | public $ftp_info = NULL; |
||
58 | |||
59 | /** |
||
60 | * ssl action cache file |
||
61 | * @var array |
||
62 | */ |
||
63 | public $sslActionCacheFile = './files/cache/sslCacheFile.php'; |
||
64 | |||
65 | /** |
||
66 | * List of actions to be sent via ssl (it is used by javascript xml handler for ajax) |
||
67 | * @var array |
||
68 | */ |
||
69 | public $ssl_actions = array(); |
||
70 | |||
71 | /** |
||
72 | * obejct oFrontEndFileHandler() |
||
73 | * @var object |
||
74 | */ |
||
75 | public $oFrontEndFileHandler; |
||
76 | |||
77 | /** |
||
78 | * script codes in <head>..</head> |
||
79 | * @var string |
||
80 | */ |
||
81 | public $html_header = NULL; |
||
82 | |||
83 | /** |
||
84 | * class names of <body> |
||
85 | * @var array |
||
86 | */ |
||
87 | public $body_class = array(); |
||
88 | |||
89 | /** |
||
90 | * codes after <body> |
||
91 | * @var string |
||
92 | */ |
||
93 | public $body_header = NULL; |
||
94 | |||
95 | /** |
||
96 | * class names before </body> |
||
97 | * @var string |
||
98 | */ |
||
99 | public $html_footer = NULL; |
||
100 | |||
101 | /** |
||
102 | * path of Xpress Engine |
||
103 | * @var string |
||
104 | */ |
||
105 | public $path = ''; |
||
106 | // language information - it is changed by HTTP_USER_AGENT or user's cookie |
||
107 | /** |
||
108 | * language type |
||
109 | * @var string |
||
110 | */ |
||
111 | public $lang_type = ''; |
||
112 | |||
113 | /** |
||
114 | * contains language-specific data |
||
115 | * @var object |
||
116 | */ |
||
117 | public $lang = NULL; |
||
118 | |||
119 | /** |
||
120 | * list of loaded languages (to avoid re-loading them) |
||
121 | * @var array |
||
122 | */ |
||
123 | public $loaded_lang_files = array(); |
||
124 | |||
125 | /** |
||
126 | * site's browser title |
||
127 | * @var string |
||
128 | */ |
||
129 | public $site_title = ''; |
||
130 | |||
131 | /** |
||
132 | * variables from GET or form submit |
||
133 | * @var mixed |
||
134 | */ |
||
135 | public $get_vars = NULL; |
||
136 | |||
137 | /** |
||
138 | * Checks uploaded |
||
139 | * @var bool TRUE if attached file exists |
||
140 | */ |
||
141 | public $is_uploaded = FALSE; |
||
142 | /** |
||
143 | * Pattern for request vars check |
||
144 | * @var array |
||
145 | */ |
||
146 | public $patterns = array( |
||
147 | '/<\?/iUsm', |
||
148 | '/<\%/iUsm', |
||
149 | '/<script\s*?language\s*?=\s*?("|\')?\s*?php\s*("|\')?/iUsm' |
||
150 | ); |
||
151 | /** |
||
152 | * Check init |
||
153 | * @var bool FALSE if init fail |
||
154 | */ |
||
155 | public $isSuccessInit = TRUE; |
||
156 | |||
157 | /** |
||
158 | * returns static context object (Singleton). It's to use Context without declaration of an object |
||
159 | * |
||
160 | * @return object Instance |
||
161 | */ |
||
162 | function &getInstance() |
||
172 | |||
173 | /** |
||
174 | * Cunstructor |
||
175 | * |
||
176 | * @return void |
||
177 | */ |
||
178 | function Context() |
||
194 | |||
195 | /** |
||
196 | * Initialization, it sets DB information, request arguments and so on. |
||
197 | * |
||
198 | * @see This function should be called only once |
||
199 | * @return void |
||
200 | */ |
||
201 | function init() |
||
202 | { |
||
203 | // fix missing HTTP_RAW_POST_DATA in PHP 5.6 and above |
||
204 | if(!isset($GLOBALS['HTTP_RAW_POST_DATA']) && version_compare(PHP_VERSION, '5.6.0', '>=') === TRUE) |
||
205 | { |
||
206 | $GLOBALS['HTTP_RAW_POST_DATA'] = file_get_contents("php://input"); |
||
207 | |||
208 | // If content is not XML JSON, unset |
||
209 | if(!preg_match('/^[\<\{\[]/', $GLOBALS['HTTP_RAW_POST_DATA']) && strpos($_SERVER['CONTENT_TYPE'], 'json') === FALSE && strpos($_SERVER['HTTP_CONTENT_TYPE'], 'json') === FALSE) |
||
210 | { |
||
211 | unset($GLOBALS['HTTP_RAW_POST_DATA']); |
||
212 | } |
||
213 | } |
||
214 | |||
215 | // set context variables in $GLOBALS (to use in display handler) |
||
216 | $this->context = &$GLOBALS['__Context__']; |
||
217 | $this->context->lang = &$GLOBALS['lang']; |
||
218 | $this->context->_COOKIE = $_COOKIE; |
||
219 | |||
220 | // 20140429 editor/image_link |
||
221 | $this->_checkGlobalVars(); |
||
222 | |||
223 | $this->setRequestMethod(''); |
||
224 | |||
225 | $this->_setXmlRpcArgument(); |
||
226 | $this->_setJSONRequestArgument(); |
||
227 | $this->_setRequestArgument(); |
||
228 | $this->_setUploadedArgument(); |
||
229 | |||
230 | $this->loadDBInfo(); |
||
231 | if($this->db_info->use_sitelock == 'Y') |
||
232 | { |
||
233 | if(is_array($this->db_info->sitelock_whitelist)) $whitelist = $this->db_info->sitelock_whitelist; |
||
234 | |||
235 | if(!IpFilter::filter($whitelist)) |
||
236 | { |
||
237 | $title = ($this->db_info->sitelock_title) ? $this->db_info->sitelock_title : 'Maintenance in progress...'; |
||
238 | $message = $this->db_info->sitelock_message; |
||
239 | |||
240 | define('_XE_SITELOCK_', TRUE); |
||
241 | define('_XE_SITELOCK_TITLE_', $title); |
||
242 | define('_XE_SITELOCK_MESSAGE_', $message); |
||
243 | |||
244 | header("HTTP/1.1 403 Forbidden"); |
||
245 | if(FileHandler::exists(_XE_PATH_ . 'common/tpl/sitelock.user.html')) |
||
246 | { |
||
247 | include _XE_PATH_ . 'common/tpl/sitelock.user.html'; |
||
248 | } |
||
249 | else |
||
250 | { |
||
251 | include _XE_PATH_ . 'common/tpl/sitelock.html'; |
||
252 | } |
||
253 | exit; |
||
254 | } |
||
255 | } |
||
256 | |||
257 | // If XE is installed, get virtual site information |
||
258 | if(self::isInstalled()) |
||
259 | { |
||
260 | $oModuleModel = getModel('module'); |
||
261 | $site_module_info = $oModuleModel->getDefaultMid(); |
||
262 | |||
263 | if(!isset($site_module_info)) |
||
264 | { |
||
265 | $site_module_info = new stdClass(); |
||
266 | } |
||
267 | |||
268 | // if site_srl of site_module_info is 0 (default site), compare the domain to default_url of db_config |
||
269 | if($site_module_info->site_srl == 0 && $site_module_info->domain != $this->db_info->default_url) |
||
270 | { |
||
271 | $site_module_info->domain = $this->db_info->default_url; |
||
272 | } |
||
273 | |||
274 | $this->set('site_module_info', $site_module_info); |
||
275 | if($site_module_info->site_srl && isSiteID($site_module_info->domain)) |
||
276 | { |
||
277 | $this->set('vid', $site_module_info->domain, TRUE); |
||
278 | } |
||
279 | |||
280 | if(!isset($this->db_info)) |
||
281 | { |
||
282 | $this->db_info = new stdClass(); |
||
283 | } |
||
284 | |||
285 | $this->db_info->lang_type = $site_module_info->default_language; |
||
286 | if(!$this->db_info->lang_type) |
||
287 | { |
||
288 | $this->db_info->lang_type = 'en'; |
||
289 | } |
||
290 | if(!$this->db_info->use_db_session) |
||
291 | { |
||
292 | $this->db_info->use_db_session = 'N'; |
||
293 | } |
||
294 | } |
||
295 | |||
296 | // Load Language File |
||
297 | $lang_supported = $this->loadLangSelected(); |
||
298 | |||
299 | // Retrieve language type set in user's cookie |
||
300 | if($this->lang_type = $this->get('l')) |
||
301 | { |
||
302 | if($_COOKIE['lang_type'] != $this->lang_type) |
||
303 | { |
||
304 | setcookie('lang_type', $this->lang_type, $_SERVER['REQUEST_TIME'] + 3600 * 24 * 1000); |
||
305 | } |
||
306 | } |
||
307 | elseif($_COOKIE['lang_type']) |
||
308 | { |
||
309 | $this->lang_type = $_COOKIE['lang_type']; |
||
310 | } |
||
311 | |||
312 | // If it's not exists, follow default language type set in db_info |
||
313 | if(!$this->lang_type) |
||
314 | { |
||
315 | $this->lang_type = $this->db_info->lang_type; |
||
316 | } |
||
317 | |||
318 | // if still lang_type has not been set or has not-supported type , set as English. |
||
319 | if(!$this->lang_type) |
||
320 | { |
||
321 | $this->lang_type = 'en'; |
||
322 | } |
||
323 | if(is_array($lang_supported) && !isset($lang_supported[$this->lang_type])) |
||
324 | { |
||
325 | $this->lang_type = 'en'; |
||
326 | } |
||
327 | |||
328 | $this->set('lang_supported', $lang_supported); |
||
329 | $this->setLangType($this->lang_type); |
||
330 | |||
331 | // load module module's language file according to language setting |
||
332 | $this->loadLang(_XE_PATH_ . 'modules/module/lang'); |
||
333 | |||
334 | // set session handler |
||
335 | if(self::isInstalled() && $this->db_info->use_db_session == 'Y') |
||
336 | { |
||
337 | $oSessionModel = getModel('session'); |
||
338 | $oSessionController = getController('session'); |
||
339 | session_set_save_handler( |
||
340 | array(&$oSessionController, 'open'), array(&$oSessionController, 'close'), array(&$oSessionModel, 'read'), array(&$oSessionController, 'write'), array(&$oSessionController, 'destroy'), array(&$oSessionController, 'gc') |
||
341 | ); |
||
342 | } |
||
343 | |||
344 | if($sess = $_POST[session_name()]) session_id($sess); |
||
345 | session_start(); |
||
346 | |||
347 | // set authentication information in Context and session |
||
348 | if(self::isInstalled()) |
||
349 | { |
||
350 | $oModuleModel = getModel('module'); |
||
351 | $oModuleModel->loadModuleExtends(); |
||
352 | |||
353 | $oMemberModel = getModel('member'); |
||
354 | $oMemberController = getController('member'); |
||
355 | |||
356 | if($oMemberController && $oMemberModel) |
||
357 | { |
||
358 | // if signed in, validate it. |
||
359 | if($oMemberModel->isLogged()) |
||
360 | { |
||
361 | $oMemberController->setSessionInfo(); |
||
362 | } |
||
363 | // check auto sign-in |
||
364 | elseif($_COOKIE['xeak']) |
||
365 | { |
||
366 | $oMemberController->doAutologin(); |
||
367 | } |
||
368 | |||
369 | $this->set('is_logged', $oMemberModel->isLogged()); |
||
370 | $this->set('logged_info', $oMemberModel->getLoggedInfo()); |
||
371 | } |
||
372 | } |
||
373 | |||
374 | // load common language file |
||
375 | $this->lang = &$GLOBALS['lang']; |
||
376 | $this->loadLang(_XE_PATH_ . 'common/lang/'); |
||
377 | |||
378 | // check if using rewrite module |
||
379 | $this->allow_rewrite = ($this->db_info->use_rewrite == 'Y' ? TRUE : FALSE); |
||
380 | |||
381 | // set locations for javascript use |
||
382 | $url = array(); |
||
383 | $current_url = self::getRequestUri(); |
||
384 | if($_SERVER['REQUEST_METHOD'] == 'GET') |
||
385 | { |
||
386 | if($this->get_vars) |
||
387 | { |
||
388 | $url = array(); |
||
389 | View Code Duplication | foreach($this->get_vars as $key => $val) |
|
390 | { |
||
391 | if(is_array($val) && count($val) > 0) |
||
392 | { |
||
393 | foreach($val as $k => $v) |
||
394 | { |
||
395 | $url[] = $key . '[' . $k . ']=' . urlencode($v); |
||
396 | } |
||
397 | } |
||
398 | elseif($val) |
||
399 | { |
||
400 | $url[] = $key . '=' . urlencode($val); |
||
401 | } |
||
402 | } |
||
403 | |||
404 | $current_url = self::getRequestUri(); |
||
405 | if($url) $current_url .= '?' . join('&', $url); |
||
406 | } |
||
407 | else |
||
408 | { |
||
409 | $current_url = $this->getUrl(); |
||
410 | } |
||
411 | } |
||
412 | else |
||
413 | { |
||
414 | $current_url = self::getRequestUri(); |
||
415 | } |
||
416 | |||
417 | $this->set('current_url', $current_url); |
||
418 | $this->set('request_uri', self::getRequestUri()); |
||
419 | |||
420 | if(strpos($current_url, 'xn--') !== FALSE) |
||
421 | { |
||
422 | $this->set('current_url', self::decodeIdna($current_url)); |
||
423 | } |
||
424 | |||
425 | if(strpos(self::getRequestUri(), 'xn--') !== FALSE) |
||
426 | { |
||
427 | $this->set('request_uri', self::decodeIdna(self::getRequestUri())); |
||
428 | } |
||
429 | } |
||
430 | |||
431 | /** |
||
432 | * Finalize using resources, such as DB connection |
||
433 | * |
||
434 | * @return void |
||
435 | */ |
||
436 | function close() |
||
440 | |||
441 | /** |
||
442 | * Load the database information |
||
443 | * |
||
444 | * @return void |
||
445 | */ |
||
446 | function loadDBInfo() |
||
520 | |||
521 | /** |
||
522 | * Get DB's db_type |
||
523 | * |
||
524 | * @return string DB's db_type |
||
525 | */ |
||
526 | function getDBType() |
||
531 | |||
532 | /** |
||
533 | * Set DB information |
||
534 | * |
||
535 | * @param object $db_info DB information |
||
536 | * @return void |
||
537 | */ |
||
538 | function setDBInfo($db_info) |
||
543 | |||
544 | /** |
||
545 | * Get DB information |
||
546 | * |
||
547 | * @return object DB information |
||
548 | */ |
||
549 | function getDBInfo() |
||
554 | |||
555 | /** |
||
556 | * Return ssl status |
||
557 | * |
||
558 | * @return object SSL status (Optional - none|always|optional) |
||
559 | */ |
||
560 | function getSslStatus() |
||
565 | |||
566 | /** |
||
567 | * Return default URL |
||
568 | * |
||
569 | * @return string Default URL |
||
570 | */ |
||
571 | function getDefaultUrl() |
||
576 | |||
577 | /** |
||
578 | * Find supported languages |
||
579 | * |
||
580 | * @return array Supported languages |
||
581 | */ |
||
582 | function loadLangSupported() |
||
597 | |||
598 | /** |
||
599 | * Find selected languages to serve in the site |
||
600 | * |
||
601 | * @return array Selected languages |
||
602 | */ |
||
603 | function loadLangSelected() |
||
635 | |||
636 | /** |
||
637 | * Single Sign On (SSO) |
||
638 | * |
||
639 | * @return bool True : Module handling is necessary in the control path of current request , False : Otherwise |
||
640 | */ |
||
641 | function checkSSO() |
||
730 | |||
731 | /** |
||
732 | * Check if FTP info is registered |
||
733 | * |
||
734 | * @return bool True: FTP information is registered, False: otherwise |
||
735 | */ |
||
736 | function isFTPRegisted() |
||
740 | |||
741 | /** |
||
742 | * Get FTP information |
||
743 | * |
||
744 | * @return object FTP information |
||
745 | */ |
||
746 | function getFTPInfo() |
||
759 | |||
760 | /** |
||
761 | * Add string to browser title |
||
762 | * |
||
763 | * @param string $site_title Browser title to be added |
||
764 | * @return void |
||
765 | */ |
||
766 | function addBrowserTitle($site_title) |
||
783 | |||
784 | /** |
||
785 | * Set string to browser title |
||
786 | * |
||
787 | * @param string $site_title Browser title to be set |
||
788 | * @return void |
||
789 | */ |
||
790 | function setBrowserTitle($site_title) |
||
799 | |||
800 | /** |
||
801 | * Get browser title |
||
802 | * |
||
803 | * @return string Browser title(htmlspecialchars applied) |
||
804 | */ |
||
805 | function getBrowserTitle() |
||
814 | |||
815 | /** |
||
816 | * Return layout's title |
||
817 | * @return string layout's title |
||
818 | */ |
||
819 | public function getSiteTitle() |
||
830 | |||
831 | /** |
||
832 | * Get browser title |
||
833 | * @deprecated |
||
834 | */ |
||
835 | function _getBrowserTitle() |
||
839 | |||
840 | /** |
||
841 | * Load language file according to language type |
||
842 | * |
||
843 | * @param string $path Path of the language file |
||
844 | * @return void |
||
845 | */ |
||
846 | function loadLang($path) |
||
884 | |||
885 | /** |
||
886 | * Evaluation of xml language file |
||
887 | * |
||
888 | * @param string Path of the language file |
||
889 | * @return void |
||
890 | */ |
||
891 | function _evalxmlLang($path) |
||
918 | |||
919 | /** |
||
920 | * Load language file of xml type |
||
921 | * |
||
922 | * @param string $path Path of the language file |
||
923 | * @return string file name |
||
924 | */ |
||
925 | function _loadXmlLang($path) |
||
932 | |||
933 | /** |
||
934 | * Load language file of php type |
||
935 | * |
||
936 | * @param string $path Path of the language file |
||
937 | * @return string file name |
||
938 | */ |
||
939 | function _loadPhpLang($path) |
||
962 | |||
963 | /** |
||
964 | * Set lang_type |
||
965 | * |
||
966 | * @param string $lang_type Language type. |
||
967 | * @return void |
||
968 | */ |
||
969 | function setLangType($lang_type = 'ko') |
||
978 | |||
979 | /** |
||
980 | * Get lang_type |
||
981 | * |
||
982 | * @return string Language type |
||
983 | */ |
||
984 | function getLangType() |
||
989 | |||
990 | /** |
||
991 | * Return string accoring to the inputed code |
||
992 | * |
||
993 | * @param string $code Language variable name |
||
994 | * @return string If string for the code exists returns it, otherwise returns original code |
||
995 | */ |
||
996 | function getLang($code) |
||
1008 | |||
1009 | /** |
||
1010 | * Set data to lang variable |
||
1011 | * |
||
1012 | * @param string $code Language variable name |
||
1013 | * @param string $val `$code`s value |
||
1014 | * @return void |
||
1015 | */ |
||
1016 | function setLang($code, $val) |
||
1024 | |||
1025 | /** |
||
1026 | * Convert strings of variables in $source_object into UTF-8 |
||
1027 | * |
||
1028 | * @param object $source_obj Conatins strings to convert |
||
1029 | * @return object converted object |
||
1030 | */ |
||
1031 | function convertEncoding($source_obj) |
||
1062 | |||
1063 | /** |
||
1064 | * Check flag |
||
1065 | * |
||
1066 | * @param mixed $val |
||
1067 | * @param string $key |
||
1068 | * @param mixed $charset charset |
||
1069 | * @see arrayConvWalkCallback will replaced array_walk_recursive in >=PHP5 |
||
1070 | * @return void |
||
1071 | */ |
||
1072 | function checkConvertFlag(&$val, $key = null, $charset = null) |
||
1089 | |||
1090 | /** |
||
1091 | * Convert array type variables into UTF-8 |
||
1092 | * |
||
1093 | * @param mixed $val |
||
1094 | * @param string $key |
||
1095 | * @param string $charset character set |
||
1096 | * @see arrayConvWalkCallback will replaced array_walk_recursive in >=PHP5 |
||
1097 | * @return object converted object |
||
1098 | */ |
||
1099 | function doConvertEncoding(&$val, $key = null, $charset) |
||
1107 | |||
1108 | /** |
||
1109 | * Convert strings into UTF-8 |
||
1110 | * |
||
1111 | * @param string $str String to convert |
||
1112 | * @return string converted string |
||
1113 | */ |
||
1114 | function convertEncodingStr($str) |
||
1122 | |||
1123 | function decodeIdna($domain) |
||
1134 | |||
1135 | /** |
||
1136 | * Force to set response method |
||
1137 | * |
||
1138 | * @param string $method Response method. [HTML|XMLRPC|JSON] |
||
1139 | * @return void |
||
1140 | */ |
||
1141 | function setResponseMethod($method = 'HTML') |
||
1148 | |||
1149 | /** |
||
1150 | * Get reponse method |
||
1151 | * |
||
1152 | * @return string Response method. If it's not set, returns request method. |
||
1153 | */ |
||
1154 | function getResponseMethod() |
||
1168 | |||
1169 | /** |
||
1170 | * Determine request method |
||
1171 | * |
||
1172 | * @param string $type Request method. (Optional - GET|POST|XMLRPC|JSON) |
||
1173 | * @return void |
||
1174 | */ |
||
1175 | function setRequestMethod($type = '') |
||
1187 | |||
1188 | /** |
||
1189 | * handle global arguments |
||
1190 | * |
||
1191 | * @return void |
||
1192 | */ |
||
1193 | function _checkGlobalVars() |
||
1203 | |||
1204 | /** |
||
1205 | * handle request arguments for GET/POST |
||
1206 | * |
||
1207 | * @return void |
||
1208 | */ |
||
1209 | function _setRequestArgument() |
||
1251 | |||
1252 | function _recursiveCheckVar($val) |
||
1273 | |||
1274 | /** |
||
1275 | * Handle request arguments for JSON |
||
1276 | * |
||
1277 | * @return void |
||
1278 | */ |
||
1279 | function _setJSONRequestArgument() |
||
1294 | |||
1295 | /** |
||
1296 | * Handle request arguments for XML RPC |
||
1297 | * |
||
1298 | * @return void |
||
1299 | */ |
||
1300 | function _setXmlRpcArgument() |
||
1330 | |||
1331 | /** |
||
1332 | * Filter xml variables |
||
1333 | * |
||
1334 | * @param string $key Variable key |
||
1335 | * @param object $val Variable value |
||
1336 | * @return mixed filtered value |
||
1337 | */ |
||
1338 | function _filterXmlVars($key, $val) |
||
1381 | |||
1382 | /** |
||
1383 | * Filter request variable |
||
1384 | * |
||
1385 | * @see Cast variables, such as _srl, page, and cpage, into interger |
||
1386 | * @param string $key Variable key |
||
1387 | * @param string $val Variable value |
||
1388 | * @param string $do_stripslashes Whether to strip slashes |
||
1389 | * @return mixed filtered value. Type are string or array |
||
1390 | */ |
||
1391 | function _filterRequestVar($key, $val, $do_stripslashes = 1) |
||
1451 | |||
1452 | /** |
||
1453 | * Check if there exists uploaded file |
||
1454 | * |
||
1455 | * @return bool True: exists, False: otherwise |
||
1456 | */ |
||
1457 | function isUploaded() |
||
1462 | |||
1463 | /** |
||
1464 | * Handle uploaded file |
||
1465 | * |
||
1466 | * @return void |
||
1467 | */ |
||
1468 | function _setUploadedArgument() |
||
1506 | |||
1507 | /** |
||
1508 | * Return request method |
||
1509 | * @return string Request method type. (Optional - GET|POST|XMLRPC|JSON) |
||
1510 | */ |
||
1511 | function getRequestMethod() |
||
1516 | |||
1517 | /** |
||
1518 | * Return request URL |
||
1519 | * @return string request URL |
||
1520 | */ |
||
1521 | function getRequestUrl() |
||
1538 | |||
1539 | /** |
||
1540 | * Return js callback func. |
||
1541 | * @return string callback func. |
||
1542 | */ |
||
1543 | function getJSCallbackFunc() |
||
1557 | |||
1558 | /** |
||
1559 | * Make URL with args_list upon request URL |
||
1560 | * |
||
1561 | * @param int $num_args Arguments nums |
||
1562 | * @param array $args_list Argument list for set url |
||
1563 | * @param string $domain Domain |
||
1564 | * @param bool $encode If TRUE, use url encode. |
||
1565 | * @param bool $autoEncode If TRUE, url encode automatically, detailed. Use this option, $encode value should be TRUE |
||
1566 | * @return string URL |
||
1567 | */ |
||
1568 | function getUrl($num_args = 0, $args_list = array(), $domain = null, $encode = TRUE, $autoEncode = FALSE) |
||
1802 | |||
1803 | /** |
||
1804 | * Return after removing an argument on the requested URL |
||
1805 | * |
||
1806 | * @param string $ssl_mode SSL mode |
||
1807 | * @param string $domain Domain |
||
1808 | * @retrun string converted URL |
||
1809 | */ |
||
1810 | function getRequestUri($ssl_mode = FOLLOW_REQUEST_SSL, $domain = null) |
||
1900 | |||
1901 | /** |
||
1902 | * Set a context value with a key |
||
1903 | * |
||
1904 | * @param string $key Key |
||
1905 | * @param string $val Value |
||
1906 | * @param mixed $set_to_get_vars If not FALSE, Set to get vars. |
||
1907 | * @return void |
||
1908 | */ |
||
1909 | function set($key, $val, $set_to_get_vars = 0) |
||
1927 | |||
1928 | /** |
||
1929 | * Return key's value |
||
1930 | * |
||
1931 | * @param string $key Key |
||
1932 | * @return string Key |
||
1933 | */ |
||
1934 | function get($key) |
||
1944 | |||
1945 | /** |
||
1946 | * Get one more vars in object vars with given arguments(key1, key2, key3,...) |
||
1947 | * |
||
1948 | * @return object |
||
1949 | */ |
||
1950 | function gets() |
||
1967 | |||
1968 | /** |
||
1969 | * Return all data |
||
1970 | * |
||
1971 | * @return object All data |
||
1972 | */ |
||
1973 | function getAll() |
||
1978 | |||
1979 | /** |
||
1980 | * Return values from the GET/POST/XMLRPC |
||
1981 | * |
||
1982 | * @return Object Request variables. |
||
1983 | */ |
||
1984 | function getRequestVars() |
||
1993 | |||
1994 | /** |
||
1995 | * Register if an action is to be encrypted by SSL. Those actions are sent to https in common/js/xml_handler.js |
||
1996 | * |
||
1997 | * @param string $action act name |
||
1998 | * @return void |
||
1999 | */ |
||
2000 | function addSSLAction($action) |
||
2017 | |||
2018 | /** |
||
2019 | * Register if actions are to be encrypted by SSL. Those actions are sent to https in common/js/xml_handler.js |
||
2020 | * |
||
2021 | * @param string $action act name |
||
2022 | * @return void |
||
2023 | */ |
||
2024 | function addSSLActions($action_array) |
||
2045 | |||
2046 | /** |
||
2047 | * Delete if action is registerd to be encrypted by SSL. |
||
2048 | * |
||
2049 | * @param string $action act name |
||
2050 | * @return void |
||
2051 | */ |
||
2052 | function subtractSSLAction($action) |
||
2064 | |||
2065 | /** |
||
2066 | * Get SSL Action |
||
2067 | * |
||
2068 | * @return string acts in array |
||
2069 | */ |
||
2070 | function getSSLActions() |
||
2078 | |||
2079 | /** |
||
2080 | * Check SSL action are existed |
||
2081 | * |
||
2082 | * @param string $action act name |
||
2083 | * @return bool If SSL exists, return TRUE. |
||
2084 | */ |
||
2085 | function isExistsSSLAction($action) |
||
2090 | |||
2091 | /** |
||
2092 | * Normalize file path |
||
2093 | * |
||
2094 | * @deprecated |
||
2095 | * @param string $file file path |
||
2096 | * @return string normalized file path |
||
2097 | */ |
||
2098 | function normalizeFilePath($file) |
||
2112 | |||
2113 | /** |
||
2114 | * Get abstract file url |
||
2115 | * |
||
2116 | * @deprecated |
||
2117 | * @param string $file file path |
||
2118 | * @return string Converted file path |
||
2119 | */ |
||
2120 | function getAbsFileUrl($file) |
||
2135 | |||
2136 | /** |
||
2137 | * Load front end file |
||
2138 | * |
||
2139 | * @param array $args array |
||
2140 | * case js : |
||
2141 | * $args[0]: file name, |
||
2142 | * $args[1]: type (head | body), |
||
2143 | * $args[2]: target IE, |
||
2144 | * $args[3]: index |
||
2145 | * case css : |
||
2146 | * $args[0]: file name, |
||
2147 | * $args[1]: media, |
||
2148 | * $args[2]: target IE, |
||
2149 | * $args[3]: index |
||
2150 | * |
||
2151 | */ |
||
2152 | function loadFile($args) |
||
2158 | |||
2159 | /** |
||
2160 | * Unload front end file |
||
2161 | * |
||
2162 | * @param string $file File name with path |
||
2163 | * @param string $targetIe Target IE |
||
2164 | * @param string $media Media query |
||
2165 | * @return void |
||
2166 | */ |
||
2167 | function unloadFile($file, $targetIe = '', $media = 'all') |
||
2172 | |||
2173 | /** |
||
2174 | * Unload front end file all |
||
2175 | * |
||
2176 | * @param string $type Unload target (optional - all|css|js) |
||
2177 | * @return void |
||
2178 | */ |
||
2179 | function unloadAllFiles($type = 'all') |
||
2184 | |||
2185 | /** |
||
2186 | * Add the js file |
||
2187 | * |
||
2188 | * @deprecated |
||
2189 | * @param string $file File name with path |
||
2190 | * @param string $optimized optimized (That seems to not use) |
||
2191 | * @param string $targetie target IE |
||
2192 | * @param string $index index |
||
2193 | * @param string $type Added position. (head:<head>..</head>, body:<body>..</body>) |
||
2194 | * @param bool $isRuleset Use ruleset |
||
2195 | * @param string $autoPath If path not readed, set the path automatically. |
||
2196 | * @return void |
||
2197 | */ |
||
2198 | function addJsFile($file, $optimized = FALSE, $targetie = '', $index = 0, $type = 'head', $isRuleset = FALSE, $autoPath = null) |
||
2218 | |||
2219 | /** |
||
2220 | * Remove the js file |
||
2221 | * |
||
2222 | * @deprecated |
||
2223 | * @param string $file File name with path |
||
2224 | * @param string $optimized optimized (That seems to not use) |
||
2225 | * @param string $targetie target IE |
||
2226 | * @return void |
||
2227 | */ |
||
2228 | function unloadJsFile($file, $optimized = FALSE, $targetie = '') |
||
2233 | |||
2234 | /** |
||
2235 | * Unload all javascript files |
||
2236 | * |
||
2237 | * @return void |
||
2238 | */ |
||
2239 | function unloadAllJsFiles() |
||
2244 | |||
2245 | /** |
||
2246 | * Add javascript filter |
||
2247 | * |
||
2248 | * @param string $path File path |
||
2249 | * @param string $filename File name |
||
2250 | * @return void |
||
2251 | */ |
||
2252 | function addJsFilter($path, $filename) |
||
2257 | |||
2258 | /** |
||
2259 | * Same as array_unique but works only for file subscript |
||
2260 | * |
||
2261 | * @deprecated |
||
2262 | * @param array $files File list |
||
2263 | * @return array File list |
||
2264 | */ |
||
2265 | function _getUniqueFileList($files) |
||
2281 | |||
2282 | /** |
||
2283 | * Returns the list of javascripts that matches the given type. |
||
2284 | * |
||
2285 | * @param string $type Added position. (head:<head>..</head>, body:<body>..</body>) |
||
2286 | * @return array Returns javascript file list. Array contains file, targetie. |
||
2287 | */ |
||
2288 | function getJsFile($type = 'head') |
||
2293 | |||
2294 | /** |
||
2295 | * Add CSS file |
||
2296 | * |
||
2297 | * @deprecated |
||
2298 | * @param string $file File name with path |
||
2299 | * @param string $optimized optimized (That seems to not use) |
||
2300 | * @param string $media Media query |
||
2301 | * @param string $targetie target IE |
||
2302 | * @param string $index index |
||
2303 | * @return void |
||
2304 | * |
||
2305 | */ |
||
2306 | function addCSSFile($file, $optimized = FALSE, $media = 'all', $targetie = '', $index = 0) |
||
2311 | |||
2312 | /** |
||
2313 | * Remove css file |
||
2314 | * |
||
2315 | * @deprecated |
||
2316 | * @param string $file File name with path |
||
2317 | * @param string $optimized optimized (That seems to not use) |
||
2318 | * @param string $media Media query |
||
2319 | * @param string $targetie target IE |
||
2320 | * @return void |
||
2321 | */ |
||
2322 | function unloadCSSFile($file, $optimized = FALSE, $media = 'all', $targetie = '') |
||
2327 | |||
2328 | /** |
||
2329 | * Unload all css files |
||
2330 | * |
||
2331 | * @return void |
||
2332 | */ |
||
2333 | function unloadAllCSSFiles() |
||
2338 | |||
2339 | /** |
||
2340 | * Return a list of css files |
||
2341 | * |
||
2342 | * @return array Returns css file list. Array contains file, media, targetie. |
||
2343 | */ |
||
2344 | function getCSSFile() |
||
2349 | |||
2350 | /** |
||
2351 | * Returns javascript plugin file info |
||
2352 | * @param string $pluginName |
||
2353 | * @return stdClass |
||
2354 | */ |
||
2355 | function getJavascriptPluginInfo($pluginName) |
||
2404 | /** |
||
2405 | * Load javascript plugin |
||
2406 | * |
||
2407 | * @param string $plugin_name plugin name |
||
2408 | * @return void |
||
2409 | */ |
||
2410 | function loadJavascriptPlugin($plugin_name) |
||
2461 | |||
2462 | /** |
||
2463 | * Add html code before </head> |
||
2464 | * |
||
2465 | * @param string $header add html code before </head>. |
||
2466 | * @return void |
||
2467 | */ |
||
2468 | function addHtmlHeader($header) |
||
2473 | |||
2474 | function clearHtmlHeader() |
||
2479 | |||
2480 | /** |
||
2481 | * Returns added html code by addHtmlHeader() |
||
2482 | * |
||
2483 | * @return string Added html code before </head> |
||
2484 | */ |
||
2485 | function getHtmlHeader() |
||
2490 | |||
2491 | /** |
||
2492 | * Add css class to Html Body |
||
2493 | * |
||
2494 | * @param string $class_name class name |
||
2495 | */ |
||
2496 | function addBodyClass($class_name) |
||
2501 | |||
2502 | /** |
||
2503 | * Return css class to Html Body |
||
2504 | * |
||
2505 | * @return string Return class to html body |
||
2506 | */ |
||
2507 | function getBodyClass() |
||
2514 | |||
2515 | /** |
||
2516 | * Add html code after <body> |
||
2517 | * |
||
2518 | * @param string $header Add html code after <body> |
||
2519 | */ |
||
2520 | function addBodyHeader($header) |
||
2525 | |||
2526 | /** |
||
2527 | * Returns added html code by addBodyHeader() |
||
2528 | * |
||
2529 | * @return string Added html code after <body> |
||
2530 | */ |
||
2531 | function getBodyHeader() |
||
2536 | |||
2537 | /** |
||
2538 | * Add html code before </body> |
||
2539 | * |
||
2540 | * @param string $footer Add html code before </body> |
||
2541 | */ |
||
2542 | function addHtmlFooter($footer) |
||
2547 | |||
2548 | /** |
||
2549 | * Returns added html code by addHtmlHeader() |
||
2550 | * |
||
2551 | * @return string Added html code before </body> |
||
2552 | */ |
||
2553 | function getHtmlFooter() |
||
2558 | |||
2559 | /** |
||
2560 | * Get config file |
||
2561 | * |
||
2562 | * @retrun string The path of the config file that contains database settings |
||
2563 | */ |
||
2564 | function getConfigFile() |
||
2568 | |||
2569 | /** |
||
2570 | * Get FTP config file |
||
2571 | * |
||
2572 | * @return string The path of the config file that contains FTP settings |
||
2573 | */ |
||
2574 | function getFTPConfigFile() |
||
2578 | |||
2579 | /** |
||
2580 | * Checks whether XE is installed |
||
2581 | * |
||
2582 | * @return bool True if the config file exists, otherwise FALSE. |
||
2583 | */ |
||
2584 | function isInstalled() |
||
2588 | |||
2589 | /** |
||
2590 | * Transforms codes about widget or other features into the actual code, deprecatred |
||
2591 | * |
||
2592 | * @param string Transforms codes |
||
2593 | * @return string Transforms codes |
||
2594 | */ |
||
2595 | function transContent($content) |
||
2599 | |||
2600 | /** |
||
2601 | * Check whether it is allowed to use rewrite mod |
||
2602 | * |
||
2603 | * @return bool True if it is allowed to use rewrite mod, otherwise FALSE |
||
2604 | */ |
||
2605 | function isAllowRewrite() |
||
2610 | |||
2611 | /** |
||
2612 | * Converts a local path into an URL |
||
2613 | * |
||
2614 | * @param string $path URL path |
||
2615 | * @return string Converted path |
||
2616 | */ |
||
2617 | function pathToUrl($path) |
||
2667 | |||
2668 | /** |
||
2669 | * Get meta tag |
||
2670 | * @return array The list of meta tags |
||
2671 | */ |
||
2672 | function getMetaTag() |
||
2690 | |||
2691 | /** |
||
2692 | * Add the meta tag |
||
2693 | * |
||
2694 | * @param string $name name of meta tag |
||
2695 | * @param string $content content of meta tag |
||
2696 | * @param mixed $is_http_equiv value of http_equiv |
||
2697 | * @return void |
||
2698 | */ |
||
2699 | function addMetaTag($name, $content, $is_http_equiv = FALSE) |
||
2704 | |||
2705 | } |
||
2706 | /* End of file Context.class.php */ |
||
2708 |