Conditions | 19 |
Paths | > 20000 |
Total Lines | 75 |
Code Lines | 35 |
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 |
||
61 | public function draw() |
||
62 | { |
||
63 | header('Cache-Control: Public, must-revalidate'); |
||
64 | header("Content-type: text/html; charset=" . Globals::$conf->file->character_set_client); |
||
65 | |||
66 | // Need global variable $title to be defined by caller (like dol_loginfunction) |
||
67 | // Caller can also set $morelogincontent = array(['options']=>array('js'=>..., 'table'=>...); |
||
68 | // Protection to avoid direct call of template |
||
69 | if (empty(Globals::$conf) || !is_object(Globals::$conf)) { |
||
70 | print "Error, template page can't be called as URL"; |
||
71 | exit; |
||
72 | } |
||
73 | |||
74 | |||
75 | if (DolUtils::GETPOST('dol_hide_topmenu')) { |
||
76 | Globals::$conf->dol_hide_topmenu = 1; |
||
77 | } |
||
78 | if (DolUtils::GETPOST('dol_hide_leftmenu')) { |
||
79 | Globals::$conf->dol_hide_leftmenu = 1; |
||
80 | } |
||
81 | if (DolUtils::GETPOST('dol_optimize_smallscreen')) { |
||
82 | Globals::$conf->dol_optimize_smallscreen = 1; |
||
83 | } |
||
84 | if (DolUtils::GETPOST('dol_no_mouse_hover')) { |
||
85 | Globals::$conf->dol_no_mouse_hover = 1; |
||
86 | } |
||
87 | if (DolUtils::GETPOST('dol_use_jmobile')) { |
||
88 | Globals::$conf->dol_use_jmobile = 1; |
||
89 | } |
||
90 | |||
91 | // If we force to use jmobile, then we reenable javascript |
||
92 | if (!empty(Globals::$conf->dol_use_jmobile)) { |
||
93 | Globals::$conf->use_javascript_ajax = 1; |
||
94 | } |
||
95 | |||
96 | $php_self = DolUtils::dol_escape_htmltag($_SERVER['PHP_SELF']); |
||
97 | $php_self .= DolUtils::dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?' . DolUtils::dol_escape_htmltag($_SERVER["QUERY_STRING"]) : ''; |
||
98 | if (!preg_match('/mainmenu=/', $php_self)) { |
||
99 | $php_self .= (preg_match('/\?/', $php_self) ? '&' : '?') . 'mainmenu=home'; |
||
100 | } |
||
101 | |||
102 | $this->url = $php_self; |
||
103 | |||
104 | |||
105 | // Javascript code on logon page only to detect user tz, dst_observed, dst_first, dst_second |
||
106 | /* |
||
107 | $arrayofjs=array( |
||
108 | '/includes/jstz/jstz.min.js'.(empty(Globals::$conf->dol_use_jmobile)?'':'?version='.urlencode(DOL_VERSION)), |
||
109 | '/core/js/dst.js'.(empty(Globals::$conf->dol_use_jmobile)?'':'?version='.urlencode(DOL_VERSION)) |
||
110 | ); |
||
111 | */ |
||
112 | $arrayofjs = array( |
||
113 | DOL_BASE_URI . '/includes/jstz/jstz.min.js' . (empty(Globals::$conf->dol_use_jmobile) ? '' : '?version=' . urlencode(DOL_VERSION)), |
||
114 | DOL_BASE_URI . '/core/js/dst.js' . (empty(Globals::$conf->dol_use_jmobile) ? '' : '?version=' . urlencode(DOL_VERSION)) |
||
115 | ); |
||
116 | |||
117 | // $titletruedolibarrversion is defined by dol_loginfunction in security2.lib.php. |
||
118 | // We must keep the @, some tools use it to know it is login page and find true dolibarr version. |
||
119 | // $titleofloginpage = Globals::$langs->trans('Login') . ' @ ' . $titletruedolibarrversion; |
||
120 | $titleofloginpage = Globals::$langs->trans('Login') . ' @ ' . DOL_VERSION; |
||
121 | |||
122 | $disablenofollow = 1; |
||
123 | if (!preg_match('/' . constant('DOL_APPLICATION_TITLE') . '/', $this->title)) { |
||
124 | $disablenofollow = 0; |
||
125 | } |
||
126 | |||
127 | print $this->top_htmlhead('', $titleofloginpage, 0, 0, $arrayofjs, array(), 0, $disablenofollow); |
||
128 | |||
129 | |||
130 | $colorbackhmenu1 = '60,70,100'; // topmenu |
||
131 | if (!isset(Globals::$conf->global->THEME_ELDY_TOPMENU_BACK1)) { |
||
132 | Globals::$conf->global->THEME_ELDY_TOPMENU_BACK1 = $colorbackhmenu1; |
||
133 | } |
||
134 | $colorbackhmenu1 = empty($user->conf->THEME_ELDY_ENABLE_PERSONALIZED) ? (empty(Globals::$conf->global->THEME_ELDY_TOPMENU_BACK1) ? $colorbackhmenu1 : Globals::$conf->global->THEME_ELDY_TOPMENU_BACK1) : (empty($user->conf->THEME_ELDY_TOPMENU_BACK1) ? $colorbackhmenu1 : $user->conf->THEME_ELDY_TOPMENU_BACK1); |
||
135 | $colorbackhmenu1 = join(',', DolUtils2::colorStringToArray($colorbackhmenu1)); // Normalize value to 'x,y,z' |
||
136 | } |
||
138 |