Conditions | 20 |
Paths | > 20000 |
Total Lines | 60 |
Code Lines | 47 |
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 |
||
101 | function b_scrolling_term_edit($options) |
||
102 | { |
||
103 | global $xoopsDB; |
||
104 | $myts = MyTextSanitizer:: getInstance(); |
||
105 | $form = "<table style='width:100%' class='bg2'>"; |
||
106 | $form .= "<tr><th style='width:50%'>" . _OPTIONS . "</th><th style='width:50%'>" . _MB_LEXIKON_SETTINGS . '</th></tr>'; |
||
107 | $form .= "<tr><td class='even'>" . _MB_LEXIKON_BLIMIT . "</td><td class='odd'><input type='text' name='options[0]' size='16' maxlength=3 value='" . $options[0] . "' ></td></tr>"; |
||
108 | $form .= "<tr><td class='even'>" . _MB_LEXIKON_BSPEED . "</td><td class='odd'><input type='text' name='options[1]' size='16' maxlength=2 value='" . $options[1] . "' ></td></tr>"; |
||
109 | $form .= "<tr><td class='even'>" . _MB_LEXIKON_BACKGROUNDCOLOR . "</td><td class='odd'><input type='text' name='options[2]' size='16' value='" . $options[2] . "' ></td></tr>"; |
||
110 | //--- |
||
111 | $form .= "<tr><td class='even'>" . _MB_LEXIKON_DIRECTION . "</td><td class='odd'><select name='options[3]'>"; |
||
112 | $form .= "<option value='up' " . (('up' === $options[3]) ? ' selected' : '') . '>' . _MB_LEXIKON_UP . "</option>\n"; |
||
113 | $form .= "<option value='down' " . (('down' === $options[3]) ? ' selected' : '') . '>' . _MB_LEXIKON_DOWN . "</option>\n"; |
||
114 | $form .= '</select></td></tr>'; |
||
115 | //--- |
||
116 | $form .= "<tr><td class='even'>" . _MB_LEXIKON_ALTERNATE . "</td><td class='odd'>"; |
||
117 | $form .= "<input type='radio' name='options[4]' value='1'" . ((1 == $options[4]) ? ' checked' : '') . ' >' . _YES . ' '; |
||
118 | $form .= "<input type='radio' name='options[4]' value='0'" . ((0 == $options[4]) ? ' checked' : '') . ' >' . _NO . '<br></td></tr>'; |
||
119 | //--- |
||
120 | $form .= "<tr><td class='even'>" . _MB_LEXIKON_CHARS . " </td><td class='odd'><input type='text' name='options[5]' value='" . $options[5] . "' ></td></tr>"; |
||
121 | //--- |
||
122 | $form .= "<tr><td class='even'>" . _MB_LEXIKON_TERMSTOSHOW . ' ' . _MB_LEXIKON_SHOWDATE . "</td><td class='odd'>"; |
||
123 | $form .= "<input type='radio' name='options[6]' value='1'" . ((1 == $options[6]) ? ' checked' : '') . ' >' . _YES . ' '; |
||
124 | $form .= "<input type='radio' name='options[6]' value='0'" . ((0 == $options[6]) ? ' checked' : '') . ' >' . _NO . '<br></td></tr>'; |
||
125 | //--- |
||
126 | $form .= "<tr><td class='even'>" . _MB_LEXIKON_DISP . "</td><td class='odd'><select name='options[7]'>"; |
||
127 | $form .= "<option value='0' " . (('0' == $options[7]) ? ' selected' : '') . '>' . _MB_LEXIKON_MARQUEE . "</option>\n"; |
||
128 | $form .= "<option value='1' " . (('1' == $options[7]) ? ' selected' : '') . '>' . _MB_LEXIKON_PAUSESCROLLER . "</option>\n"; |
||
129 | $form .= "<option value='2' " . (('2' == $options[7]) ? ' selected' : '') . '>' . _MB_LEXIKON_DOMTICKER . "</option>\n"; |
||
130 | $form .= '</select></td></tr>'; |
||
131 | //--- |
||
132 | $form .= "<tr><td class='even'>" . _MB_LEXIKON_SORT . "</td><td class='odd'><select name='options[8]'>"; |
||
133 | $form .= "<option value='RAND()' " . (('RAND()' === $options[8]) ? ' selected' : '') . '>' . _MB_LEXIKON_RANDOM . "</option>\n"; |
||
134 | $form .= "<option value='datesub' " . (('datesub' === $options[8]) ? ' selected' : '') . '>' . _MB_LEXIKON_DATE . "</option>\n"; |
||
135 | $form .= "<option value='counter' " . (('counter' === $options[8]) ? ' selected' : '') . '>' . _MB_LEXIKON_HITS . "</option>\n"; |
||
136 | $form .= "<option value='term' " . (('term' === $options[8]) ? ' selected' : '') . '>' . _MB_LEXIKON_NAME . "</option>\n"; |
||
137 | $form .= '</select></td></tr>'; |
||
138 | //--- |
||
139 | $form .= "<tr><td class='even'>" . _MB_LEXIKON_ORDER . "</td><td class='odd'><select name='options[9]'>"; |
||
140 | $form .= "<option value='ASC' " . (('ASC' === $options[9]) ? ' selected' : '') . '>' . _ASCENDING . "</option>\n"; |
||
141 | $form .= "<option value='DESC' " . (('DESC' === $options[9]) ? ' selected' : '') . '>' . _DESCENDING . "</option>\n"; |
||
142 | $form .= '</select></td></tr>'; |
||
143 | //--- get allowed categories |
||
144 | $isAll = empty($options[10]); |
||
145 | $options_cat = array_slice($options, 10); |
||
146 | $form .= "<tr><td class='even'>" . _MB_LEXIKON_CATEGORY . "</td><td class='odd'><select name=\"options[]\" multiple=\"multiple\">"; |
||
147 | $form .= '<option value="0" '; |
||
148 | if ($isAll) { |
||
149 | $form .= ' selected="selected"'; |
||
150 | } |
||
151 | $form .= '>' . _ALL . '</option>'; |
||
152 | $resultcat = $xoopsDB->query('SELECT categoryID, name FROM ' . $xoopsDB->prefix('lxcategories') . ' ORDER BY categoryID ASC'); |
||
153 | while (list($categoryID, $name) = $xoopsDB->fetchRow($resultcat)) { |
||
154 | $sel = ($isAll || in_array($categoryID, $options_cat)) ? ' selected' : ''; |
||
155 | $form .= '<option value=' . $categoryID . " $sel>$categoryID : $name</option>\n"; |
||
156 | } |
||
157 | $form .= '</select></td></tr>'; |
||
158 | $form .= '</table>'; |
||
159 | //-------- |
||
160 | return $form; |
||
161 | } |
||
162 |