Conditions | 1 |
Paths | 1 |
Total Lines | 111 |
Code Lines | 75 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
42 | public function __construct($db) |
||
43 | { |
||
44 | $this->db = $db; |
||
45 | $this->numero = 10000; |
||
46 | |||
47 | // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' |
||
48 | // It is used to group modules in module setup page |
||
49 | $this->family = "portal"; |
||
50 | $this->module_position = '50'; |
||
51 | // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) |
||
52 | $this->name = preg_replace('/^mod/i', '', get_only_class($this)); |
||
53 | $this->description = "Enable to build and serve public web sites with CMS features"; |
||
54 | // Possible values for version are: 'development', 'experimental', 'dolibarr' or version |
||
55 | $this->version = 'dolibarr'; |
||
56 | // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) |
||
57 | $this->const_name = 'MAIN_MODULE_' . static::getNameOf($this->name); // strtoupper($this->name); |
||
58 | // Name of image file used for this module. |
||
59 | $this->picto = 'website'; |
||
60 | |||
61 | // Data directories to create when module is enabled |
||
62 | $this->dirs = array("/website/temp"); |
||
63 | |||
64 | // Config pages |
||
65 | $this->config_page_url = array('website.php'); |
||
66 | |||
67 | // Dependencies |
||
68 | $this->hidden = getDolGlobalInt('MODULE_WEBSITE_DISABLED'); // A condition to disable module |
||
69 | $this->depends = array('modFckeditor'); // List of modules id that must be enabled if this module is enabled |
||
70 | $this->requiredby = array(); // List of modules id to disable if this one is disabled |
||
71 | $this->conflictwith = array(); // List of modules id this module is in conflict with |
||
72 | $this->phpmin = array(7, 0); // Minimum version of PHP required by module |
||
73 | $this->langfiles = array("website"); |
||
74 | |||
75 | // Constants |
||
76 | $this->const = array(); |
||
77 | |||
78 | // New pages on tabs |
||
79 | //$this->tabs[] = array(); // To add a new tab identified by code tabname1 |
||
80 | |||
81 | // Boxes |
||
82 | $this->boxes = array(); |
||
83 | |||
84 | // Permissions |
||
85 | $this->rights = array(); // Permission array used by this module |
||
86 | $this->rights_class = 'website'; |
||
87 | $r = 0; |
||
88 | |||
89 | $this->rights[$r][0] = 10001; |
||
90 | $this->rights[$r][1] = 'Read website content'; |
||
91 | $this->rights[$r][3] = 0; |
||
92 | $this->rights[$r][4] = 'read'; |
||
93 | $r++; |
||
94 | |||
95 | $this->rights[$r][0] = 10002; |
||
96 | $this->rights[$r][1] = 'Create/modify website content (html and javascript content)'; |
||
97 | $this->rights[$r][3] = 0; |
||
98 | $this->rights[$r][4] = 'write'; |
||
99 | $r++; |
||
100 | |||
101 | $this->rights[$r][0] = 10003; |
||
102 | $this->rights[$r][1] = 'Create/modify website content (dynamic php code). Dangerous, must be reserved to restricted developers.'; |
||
103 | $this->rights[$r][3] = 0; |
||
104 | $this->rights[$r][4] = 'writephp'; |
||
105 | $r++; |
||
106 | |||
107 | $this->rights[$r][0] = 10005; |
||
108 | $this->rights[$r][1] = 'Delete website content'; |
||
109 | $this->rights[$r][3] = 0; |
||
110 | $this->rights[$r][4] = 'delete'; |
||
111 | $r++; |
||
112 | |||
113 | $this->rights[$r][0] = 10008; |
||
114 | $this->rights[$r][1] = 'Export website content'; |
||
115 | $this->rights[$r][3] = 0; |
||
116 | $this->rights[$r][4] = 'export'; |
||
117 | $r++; |
||
118 | |||
119 | // Main menu entries |
||
120 | $r = 0; |
||
121 | $this->menu[$r] = array('fk_menu' => '0', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode |
||
122 | 'type' => 'top', // This is a Left menu entry |
||
123 | 'titre' => 'WebSites', |
||
124 | 'prefix' => img_picto('', $this->picto, 'class="pictofixedwidth em092"'), |
||
125 | 'mainmenu' => 'website', |
||
126 | 'url' => '/website/index.php', |
||
127 | 'langs' => 'website', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. |
||
128 | 'position' => 100, |
||
129 | 'enabled' => '$conf->website->enabled', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. |
||
130 | 'perms' => '$user->rights->website->read', // Use 'perms'=>'$user->hasRight("mymodule","level1","level2")' if you want your menu with a permission rules |
||
131 | 'target' => '', |
||
132 | 'user' => 2); // 0=Menu for internal users, 1=external users, 2=both |
||
133 | $r++; |
||
134 | |||
135 | // Exports |
||
136 | $r = 1; |
||
137 | |||
138 | $this->export_code[$r] = $this->rights_class . '_' . $r; |
||
139 | $this->export_label[$r] = 'MyWebsitePages'; // Translation key (used only if key ExportDataset_xxx_z not found) |
||
140 | $this->export_permission[$r] = array(array("website", "export")); |
||
141 | $this->export_icon[$r] = 'globe'; |
||
142 | $keyforclass = 'WebsitePage'; |
||
143 | $keyforclassfile = '/website/class/websitepage.class.php'; |
||
144 | $keyforelement = 'Website'; |
||
145 | include DOL_DOCUMENT_ROOT . '/core/commonfieldsinexport.inc.php'; |
||
146 | //$keyforselect='myobject'; $keyforelement='myobject'; $keyforaliasextra='extra'; |
||
147 | //include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php'; |
||
148 | $this->export_sql_start[$r] = 'SELECT DISTINCT '; |
||
149 | $this->export_sql_end[$r] = ' FROM ' . MAIN_DB_PREFIX . 'website_page as t, ' . MAIN_DB_PREFIX . 'website as p'; |
||
150 | $this->export_sql_end[$r] .= ' WHERE t.fk_website = p.rowid'; |
||
151 | $this->export_sql_end[$r] .= ' AND p.entity IN (' . getEntity('website') . ')'; |
||
152 | $r++; |
||
153 | } |
||
248 |