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 |
||
6 | class boardMobile extends boardView |
||
7 | { |
||
8 | function init() |
||
9 | { |
||
10 | $oSecurity = new Security(); |
||
11 | $oSecurity->encodeHTML('document_srl', 'comment_srl', 'vid', 'mid', 'page', 'category', 'search_target', 'search_keyword', 'sort_index', 'order_type', 'trackback_srl'); |
||
12 | |||
13 | if($this->module_info->list_count) $this->list_count = $this->module_info->list_count; |
||
14 | if($this->module_info->mobile_list_count) $this->list_count = $this->module_info->mobile_list_count; |
||
15 | if($this->module_info->search_list_count) $this->search_list_count = $this->module_info->search_list_count; |
||
|
|||
16 | if($this->module_info->mobile_search_list_count) $this->search_list_count = $this->module_info->mobile_search_list_count; |
||
17 | if($this->module_info->page_count) $this->page_count = $this->module_info->page_count; |
||
18 | if($this->module_info->mobile_page_count) $this->page_count = $this->module_info->mobile_page_count; |
||
19 | $this->except_notice = $this->module_info->except_notice == 'N' ? false : true; |
||
20 | |||
21 | // $this->_getStatusNameListecret option backward compatibility |
||
22 | $oDocumentModel = getModel('document'); |
||
23 | |||
24 | $statusList = $this->_getStatusNameList($oDocumentModel); |
||
25 | if(isset($statusList['SECRET'])) |
||
26 | { |
||
27 | $this->module_info->secret = 'Y'; |
||
28 | } |
||
29 | |||
30 | // use_category <=1.5.x, hide_category >=1.7.x |
||
31 | $count_category = count($oDocumentModel->getCategoryList($this->module_info->module_srl)); |
||
32 | View Code Duplication | if($count_category) |
|
33 | { |
||
34 | if($this->module_info->hide_category) |
||
35 | { |
||
36 | $this->module_info->use_category = ($this->module_info->hide_category == 'Y') ? 'N' : 'Y'; |
||
37 | } |
||
38 | else if($this->module_info->use_category) |
||
39 | { |
||
40 | $this->module_info->hide_category = ($this->module_info->use_category == 'Y') ? 'N' : 'Y'; |
||
41 | } |
||
42 | else |
||
43 | { |
||
44 | $this->module_info->hide_category = 'N'; |
||
45 | $this->module_info->use_category = 'Y'; |
||
46 | } |
||
47 | } |
||
48 | else |
||
49 | { |
||
50 | $this->module_info->hide_category = 'Y'; |
||
51 | $this->module_info->use_category = 'N'; |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * check the consultation function, if the user is admin then swich off consultation function |
||
56 | * if the user is not logged, then disppear write document/write comment./ view document |
||
57 | **/ |
||
58 | if($this->module_info->consultation == 'Y' && !$this->grant->manager && !$this->grant->consultation_read) |
||
59 | { |
||
60 | $this->consultation = true; |
||
61 | if(!Context::get('is_logged')) $this->grant->list = $this->grant->write_document = $this->grant->write_comment = $this->grant->view = false; |
||
62 | } else { |
||
63 | $this->consultation = false; |
||
64 | } |
||
65 | |||
66 | $oDocumentModel = getModel('document'); |
||
67 | $extra_keys = $oDocumentModel->getExtraKeys($this->module_info->module_srl); |
||
68 | Context::set('extra_keys', $extra_keys); |
||
69 | |||
70 | $template_path = sprintf("%sm.skins/%s/",$this->module_path, $this->module_info->mskin); |
||
71 | View Code Duplication | if(!is_dir($template_path)||!$this->module_info->mskin) |
|
72 | { |
||
73 | $this->module_info->mskin = 'default'; |
||
74 | $template_path = sprintf("%sm.skins/%s/",$this->module_path, $this->module_info->mskin); |
||
75 | } |
||
76 | $this->setTemplatePath($template_path); |
||
77 | Context::addJsFilter($this->module_path.'tpl/filter', 'input_password.xml'); |
||
78 | } |
||
79 | |||
80 | function dispBoardCategory() |
||
86 | |||
87 | function getBoardCommentPage() |
||
111 | |||
112 | function dispBoardMessage($msg_code) |
||
123 | } |
||
124 |
An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.
If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.