Conditions | 18 |
Paths | 1152 |
Total Lines | 134 |
Code Lines | 80 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
58 | public function index($executeActions = true): bool |
||
59 | { |
||
60 | global $conf; |
||
61 | global $db; |
||
62 | global $user; |
||
63 | global $hookmanager; |
||
64 | global $user; |
||
65 | global $menumanager; |
||
66 | global $langs; |
||
67 | global $mysoc; |
||
68 | |||
69 | // Load translation files required by the page |
||
70 | $langs->loadLangs(array('admin', 'companies')); |
||
71 | |||
72 | $action = ''; |
||
73 | |||
74 | if (!$user->admin) { |
||
75 | accessforbidden(); |
||
76 | } |
||
77 | |||
78 | // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context |
||
79 | $hookmanager->initHooks(array('homesetup')); |
||
80 | |||
81 | |||
82 | /* |
||
83 | * View |
||
84 | */ |
||
85 | |||
86 | $form = new Form($db); |
||
87 | |||
88 | $wikihelp = 'EN:First_setup|FR:Premiers_paramétrages|ES:Primeras_configuraciones'; |
||
89 | llxHeader('', $langs->trans("Setup"), $wikihelp); |
||
90 | |||
91 | |||
92 | print load_fiche_titre($langs->trans("SetupArea"), '', 'tools'); |
||
93 | |||
94 | |||
95 | if (getDolGlobalString('MAIN_MOTD_SETUPPAGE')) { |
||
96 | $conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i', '<br>', $conf->global->MAIN_MOTD_SETUPPAGE); |
||
97 | if (getDolGlobalString('MAIN_MOTD_SETUPPAGE')) { |
||
98 | $i = 0; |
||
99 | $reg = array(); |
||
100 | while (preg_match('/__\(([a-zA-Z|@]+)\)__/i', $conf->global->MAIN_MOTD_SETUPPAGE, $reg) && $i < 100) { |
||
101 | $tmp = explode('|', $reg[1]); |
||
102 | if (!empty($tmp[1])) { |
||
103 | $langs->load($tmp[1]); |
||
104 | } |
||
105 | $conf->global->MAIN_MOTD_SETUPPAGE = preg_replace('/__\(' . preg_quote($reg[1]) . '\)__/i', $langs->trans($tmp[0]), $conf->global->MAIN_MOTD_SETUPPAGE); |
||
106 | $i++; |
||
107 | } |
||
108 | |||
109 | print "\n<!-- Start of welcome text for setup page -->\n"; |
||
110 | print '<table width="100%" class="notopnoleftnoright"><tr><td>'; |
||
111 | print dol_htmlentitiesbr($conf->global->MAIN_MOTD_SETUPPAGE); |
||
112 | print '</td></tr></table><br>'; |
||
113 | print "\n<!-- End of welcome text for setup page -->\n"; |
||
114 | } |
||
115 | } |
||
116 | |||
117 | print '<span class="opacitymedium hideonsmartphone">'; |
||
118 | print $langs->trans("SetupDescription1") . ' '; |
||
119 | print $langs->trans("AreaForAdminOnly") . ' '; |
||
120 | print $langs->trans("SetupDescription2", $langs->transnoentities("MenuCompanySetup"), $langs->transnoentities("Modules")); |
||
121 | print "<br><br>"; |
||
122 | print '</span>'; |
||
123 | |||
124 | print '<br>'; |
||
125 | |||
126 | // Show info setup company |
||
127 | if (!getDolGlobalString('MAIN_INFO_SOCIETE_NOM') || !getDolGlobalString('MAIN_INFO_SOCIETE_COUNTRY') || getDolGlobalString('MAIN_INFO_SOCIETE_SETUP_TODO_WARNING')) { |
||
128 | $setupcompanynotcomplete = 1; |
||
129 | } |
||
130 | |||
131 | print '<section class="setupsection">'; |
||
132 | |||
133 | print img_picto('', 'company', 'class="paddingright valignmiddle double"') . ' ' . $langs->trans("SetupDescriptionLink", DOL_URL_ROOT . '/admin/company.php?mainmenu=home' . (empty($setupcompanynotcomplete) ? '' : '&action=edit&token=' . newToken()), $langs->transnoentities("Setup"), $langs->transnoentities("MenuCompanySetup")); |
||
134 | print '<br><br>'; |
||
135 | print $langs->trans("SetupDescription3b"); |
||
136 | if (!empty($setupcompanynotcomplete)) { |
||
137 | $langs->load("errors"); |
||
138 | $warnpicto = img_warning($langs->trans("WarningMandatorySetupNotComplete"), 'style="padding-right: 6px;"'); |
||
139 | print '<br><div class="warning"><a href="' . DOL_URL_ROOT . '/admin/company.php?mainmenu=home' . (empty($setupcompanynotcomplete) ? '' : '&action=edit') . '">' . $warnpicto . $langs->trans("WarningMandatorySetupNotComplete") . '</a></div>'; |
||
140 | } |
||
141 | |||
142 | print '</section>'; |
||
143 | |||
144 | print '<br>'; |
||
145 | print '<br>'; |
||
146 | |||
147 | print '<section class="setupsection">'; |
||
148 | |||
149 | $nbmodulesnotautoenabled = count($conf->modules); |
||
150 | if (in_array('fckeditor', $conf->modules)) { |
||
151 | $nbmodulesnotautoenabled--; |
||
152 | } |
||
153 | if (in_array('export', $conf->modules)) { |
||
154 | $nbmodulesnotautoenabled--; |
||
155 | } |
||
156 | if (in_array('import', $conf->modules)) { |
||
157 | $nbmodulesnotautoenabled--; |
||
158 | } |
||
159 | |||
160 | // Show info setup module |
||
161 | print img_picto('', 'cog', 'class="paddingright valignmiddle double"') . ' ' . $langs->trans("SetupDescriptionLink", DOL_URL_ROOT . '/admin/modules.php?mainmenu=home', $langs->transnoentities("Setup"), $langs->transnoentities("Modules")); |
||
162 | print '<br><br>' . $langs->trans("SetupDescription4b"); |
||
163 | if ($nbmodulesnotautoenabled <= getDolGlobalInt('MAIN_MIN_NB_ENABLED_MODULE_FOR_WARNING', 1)) { // If only minimal initial modules enabled |
||
164 | $langs->load("errors"); |
||
165 | $warnpicto = img_warning($langs->trans("WarningEnableYourModulesApplications"), 'style="padding-right: 6px;"'); |
||
166 | print '<br><div class="warning"><a href="' . DOL_URL_ROOT . '/admin/modules.php?mainmenu=home">' . $warnpicto . $langs->trans("WarningEnableYourModulesApplications") . '</a></div>'; |
||
167 | } |
||
168 | |||
169 | print '</section>'; |
||
170 | |||
171 | print '<br>'; |
||
172 | print '<br>'; |
||
173 | print '<br>'; |
||
174 | |||
175 | // Add hook to add information |
||
176 | $parameters = array(); |
||
177 | $object = new stdClass(); |
||
|
|||
178 | $reshook = $hookmanager->executeHooks('addHomeSetup', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
||
179 | print $hookmanager->resPrint; |
||
180 | if (empty($reshook)) { |
||
181 | // Show into other |
||
182 | //print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("SetupDescription5")."</span><br>"; |
||
183 | print '<br class="hideonsmartphone">'; |
||
184 | |||
185 | // Show logo |
||
186 | print '<div class="center"><div class="logo_setup"></div></div>'; |
||
187 | } |
||
188 | |||
189 | // End of page |
||
190 | llxFooter(); |
||
191 | $db->close(); |
||
192 | } |
||
194 |