Conditions | 32 |
Paths | 5491 |
Total Lines | 197 |
Code Lines | 175 |
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 |
||
69 | function drawDirs_Files($list, &$manager) |
||
70 | { |
||
71 | global $relative, $afruViewType, $IMConfig, $insertMode, $backend_url_enc; |
||
72 | |||
73 | switch ($afruViewType) { |
||
74 | case 'listview': |
||
75 | $maxNameLength = 30; |
||
76 | ?> |
||
77 | <table class="listview" id="listview"> |
||
78 | <thead> |
||
79 | <tr> |
||
80 | <th>Name</th> |
||
81 | <th>Size</th> |
||
82 | <th>Image Size</th> |
||
83 | <th>Date Modified</th> |
||
84 | <th> </th> |
||
85 | </tr> |
||
86 | </thead> |
||
87 | <tbody> |
||
88 | <?php |
||
89 | // start of foreach for draw listview folders . |
||
90 | foreach ($list[0] as $path => $dir) { ?> |
||
91 | <tr> |
||
92 | <td><span style="width:20px;"><img src="<?php print $IMConfig['base_url']; ?>icons/folder_small.gif" alt=""/></span> |
||
93 | <a href="<?php print $backend_url_enc; ?>__function=images&mode=<?php echo $insertMode; ?>&dir=<?php echo rawurlencode($path); ?>&viewtype=<?php echo $afruViewType; ?>" onclick="updateDir('<?php echo $path; ?>')" title="<?php echo $dir['entry']; ?>"> |
||
94 | <?php |
||
95 | if (strlen($dir['entry']) > $maxNameLength) { |
||
96 | echo substr($dir['entry'], 0, $maxNameLength) . '...'; |
||
97 | } else { |
||
98 | echo $dir['entry']; |
||
99 | } |
||
100 | ?> |
||
101 | </a></td> |
||
102 | <td colspan="2">Folder</td> |
||
103 | |||
104 | <td><?php echo date($IMConfig['date_format'], $dir['stat']['mtime']); ?></td> |
||
105 | |||
106 | <td class="actions"> |
||
107 | <?php |
||
108 | if ($IMConfig['allow_delete']) { |
||
109 | ?> |
||
110 | <a href="<?php print $backend_url_enc; ?>__function=images&mode=<?php echo $insertMode; ?>&dir=<?php echo $relative; ?>&deld=<?php echo rawurlencode($path); ?>&viewtype=<?php echo $afruViewType; ?>" title="Trash" |
||
111 | onclick="return confirmDeleteDir('<?php echo $dir['entry']; ?>', <?php echo $dir['count']; ?>);" style="border:0px;"><img src="<?php print $IMConfig['base_url']; ?>img/edit_trash.gif" height="15" width="15" alt="Trash" border="0"/></a> |
||
112 | <?php |
||
113 | } |
||
114 | ?> |
||
115 | <?php if ($IMConfig['allow_rename']) { ?> |
||
116 | <a href="#" title="Rename" onclick="renameDir('<?php echo rawurlencode($dir['entry']); ?>'); return false;"><img src="<?php print $IMConfig['base_url']; ?>img/edit_rename.gif" height="15" width="15" alt="Rename" border="0"/></a> |
||
117 | <?php } ?> |
||
118 | <?php if ($IMConfig['allow_cut_copy_paste']) { ?> |
||
119 | <a href="#" title="Cut" onclick="copyDir('<?php echo rawurlencode($dir['entry']); ?>','move'); return false;"><img src="<?php print $IMConfig['base_url']; ?>img/edit_cut.gif" height="15" width="15" alt="Cut"/></a> |
||
120 | <a href="#" title="Copy" onclick="copyDir('<?php echo rawurlencode($dir['entry']); ?>','copy'); return false;"><img src="<?php print $IMConfig['base_url']; ?>img/edit_copy.gif" height="15" width="15" alt="Copy"/></a> |
||
121 | <?php } ?> |
||
122 | </td> |
||
123 | </tr> |
||
124 | <?php |
||
125 | } // end of foreach for draw listview folders . |
||
126 | |||
127 | clearstatcache(); |
||
128 | |||
129 | // start of foreach for draw listview files . |
||
130 | foreach ($list[1] as $entry => $file) { |
||
131 | ?> |
||
132 | <tr> |
||
133 | <td> |
||
134 | <a href="#" class="thumb" style="cursor: pointer;vertical-align:middle;" ondblclick="this.onclick();window.top.onOK();" |
||
135 | onclick="selectImage('<?php echo $file['relative']; ?>', '<?php echo preg_replace('#\..{3,4}$#', '', $entry); ?>', <?php echo $file['image'][0]; ?>, <?php echo $file['image'][1]; ?>);return false;" |
||
136 | title="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>" <?php if ('image' |
||
137 | == $insertMode) { ?> onmouseover="showPreview('<?php echo $file['relative']; ?>')" onmouseout="showPreview(window.parent.document.getElementById('f_url').value)" <?php } ?> > |
||
138 | <span style="width:20px;vertical-align:middle;"><img src="<?php print $IMConfig['base_url']; |
||
139 | if (is_file('icons/' . $file['ext'] . '_small.gif')) { |
||
140 | echo 'icons/' . $file['ext'] . '_small.gif'; |
||
141 | } else { |
||
142 | echo $IMConfig['default_listicon']; |
||
143 | } ?>" alt="" style="border:none;"/></span><span style="vertical-align:middle;"> |
||
144 | <?php |
||
145 | if (strlen($entry) > $maxNameLength) { |
||
146 | echo substr($entry, 0, $maxNameLength) . '...'; |
||
147 | } else { |
||
148 | echo $entry; |
||
149 | } |
||
150 | ?></span> |
||
151 | </a></td> |
||
152 | <td><?php echo Files::formatSize($file['stat']['size']); ?></td> |
||
153 | <td><?php if ($file['image'][0] > 0) { |
||
154 | echo $file['image'][0] . 'x' . $file['image'][1]; |
||
155 | } ?></td> |
||
156 | <td><?php echo date($IMConfig['date_format'], $file['stat']['mtime']); ?></td> |
||
157 | <td class="actions"> |
||
158 | <?php if ($IMConfig['img_library'] && $IMConfig['allow_edit_image'] && $file['image'][0] > 0) { ?> |
||
159 | <a href="javascript:;" title="Edit" onclick="editImage('<?php echo rawurlencode($file['relative']); ?>');"><img src="<?php print $IMConfig['base_url']; ?>img/edit_pencil.gif" height="15" width="15" alt="Edit" border="0"/></a> |
||
160 | <?php } ?> |
||
161 | <?php |
||
162 | if ($IMConfig['allow_delete']) { |
||
163 | ?> |
||
164 | <a href="<?php print $backend_url_enc; ?>__function=images&dir=<?php echo $relative; ?>&delf=<?php echo rawurlencode($file['relative']); ?>&mode=<?php echo $insertMode; ?>&viewtype=<?php echo $afruViewType; ?>" title="Trash" |
||
165 | onclick="return confirmDeleteFile('<?php echo $entry; ?>');"><img src="<?php print $IMConfig['base_url']; ?>img/edit_trash.gif" height="15" width="15" alt="Trash" border="0"/></a> |
||
166 | <?php |
||
167 | } |
||
168 | ?> |
||
169 | <?php if ($IMConfig['allow_rename']) { ?> |
||
170 | <a href="#" title="Rename" onclick="renameFile('<?php echo rawurlencode($file['relative']); ?>'); return false;"><img src="<?php print $IMConfig['base_url']; ?>img/edit_rename.gif" height="15" width="15" alt="Rename" border="0"/></a> |
||
171 | <?php } ?> |
||
172 | <?php if ($IMConfig['allow_cut_copy_paste']) { ?> |
||
173 | <a href="#" title="Cut" onclick="copyFile('<?php echo rawurlencode($entry); ?>','move'); return false;"><img src="<?php print $IMConfig['base_url']; ?>img/edit_cut.gif" height="15" width="15" alt="Cut"/></a> |
||
174 | <a href="#" title="Copy" onclick="copyFile('<?php echo rawurlencode($entry); ?>','copy'); return false;"><img src="<?php print $IMConfig['base_url']; ?>img/edit_copy.gif" height="15" width="15" alt="Copy"/></a> |
||
175 | <?php } ?> |
||
176 | </td> |
||
177 | </tr> |
||
178 | <?php |
||
179 | }//end of foreach of draw listview files |
||
180 | ?> |
||
181 | </tbody> |
||
182 | </table> |
||
183 | <?php |
||
184 | break; |
||
185 | case 'thumbview': // thumbview is default |
||
186 | default: |
||
187 | $maxFileNameLength = 16; |
||
188 | $maxFolderNameLength = 16; |
||
189 | // start of foreach for draw thumbview folders. |
||
190 | foreach ($list[0] as $path => $dir) { ?> |
||
191 | <div class="dir_holder"> |
||
192 | <a class="dir" href="<?php print $backend_url_enc; ?>__function=images&mode=<?php echo $insertMode; ?>&dir=<?php echo rawurlencode($path); ?>&viewtype=<?php echo $afruViewType; ?>" onclick="updateDir('<?php echo $path; ?>')" title="<?php echo $dir['entry']; ?>"><img |
||
193 | src="<?php print $IMConfig['base_url']; ?>img/folder.gif" height="80" width="80" alt="<?php echo $dir['entry']; ?>"/></a> |
||
194 | |||
195 | <div class="fileName"> |
||
196 | <?php if (strlen($dir['entry']) > $maxFolderNameLength) { |
||
197 | echo substr($dir['entry'], 0, $maxFolderNameLength) . '...'; |
||
198 | } else { |
||
199 | echo $dir['entry']; |
||
200 | } ?> |
||
201 | </div> |
||
202 | <div class="edit"> |
||
203 | <?php |
||
204 | if ($IMConfig['allow_delete']) { |
||
205 | ?> |
||
206 | <a href="<?php print $backend_url_enc; ?>__function=images&mode=<?php echo $insertMode; ?>&dir=<?php echo $relative; ?>&deld=<?php echo rawurlencode($path); ?>&viewtype=<?php echo $afruViewType; ?>" title="Trash" |
||
207 | onclick="return confirmDeleteDir('<?php echo $dir['entry']; ?>', <?php echo $dir['count']; ?>);"><img src="<?php print $IMConfig['base_url']; ?>img/edit_trash.gif" height="15" width="15" alt="Trash"/></a> |
||
208 | <?php |
||
209 | } |
||
210 | ?> |
||
211 | <?php if ($IMConfig['allow_rename']) { ?> |
||
212 | <a href="#" title="Rename" onclick="renameDir('<?php echo rawurlencode($dir['entry']); ?>'); return false;"><img src="<?php print $IMConfig['base_url']; ?>img/edit_rename.gif" height="15" width="15" alt="Rename" border="0"/></a> |
||
213 | <?php } ?> |
||
214 | <?php if ($IMConfig['allow_cut_copy_paste']) { ?> |
||
215 | <a href="#" title="Cut" onclick="copyDir('<?php echo rawurlencode($dir['entry']); ?>','move'); return false;"><img src="<?php print $IMConfig['base_url']; ?>img/edit_cut.gif" height="15" width="15" alt="Cut"/></a> |
||
216 | <a href="#" title="Copy" onclick="copyDir('<?php echo rawurlencode($dir['entry']); ?>','copy'); return false;"><img src="<?php print $IMConfig['base_url']; ?>img/edit_copy.gif" height="15" width="15" alt="Copy"/></a> |
||
217 | <?php } ?> |
||
218 | </div> |
||
219 | </div> |
||
220 | <?php |
||
221 | } // end of foreach for draw thumbview folders. |
||
222 | |||
223 | // start of foreach for draw thumbview files. |
||
224 | foreach ($list[1] as $entry => $file) { |
||
225 | $afruimgdimensions = $manager->checkImageSize($file['relative']); |
||
226 | $thisFileNameLength = $maxFileNameLength; |
||
227 | ?> |
||
228 | <div class="thumb_holder" id="holder_<?php echo asc2hex($entry) ?>"> |
||
229 | <a href="#" class="thumb" style="cursor: pointer;" ondblclick="this.onclick();window.top.onOK();" |
||
230 | onclick="selectImage('<?php echo $file['relative']; ?>', '<?php echo preg_replace('#\..{3,4}$#', '', $entry); ?>', <?php echo $file['image'][0]; ?>, <?php echo $file['image'][1]; ?>);return false;" |
||
231 | title="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>"> |
||
232 | <img src="<?php print $manager->getThumbnail($file['relative']); ?>" alt="<?php echo $entry; ?> - <?php echo Files::formatSize($file['stat']['size']); ?>"/> |
||
233 | </a> |
||
234 | <div class="fileName"> |
||
235 | <?php |
||
236 | if (strlen($entry) > $thisFileNameLength + 3) { |
||
237 | echo strtolower(substr($entry, 0, $thisFileNameLength)) . '...'; |
||
238 | } else { |
||
239 | echo $entry; |
||
240 | } |
||
241 | ?> |
||
242 | </div> |
||
243 | <div class="edit"> |
||
244 | <?php if ($IMConfig['img_library'] && $IMConfig['allow_edit_image'] && $file['image'][0] > 0) { ?> |
||
245 | <a href="javascript:;" title="Edit" onclick="editImage('<?php echo rawurlencode($file['relative']); ?>');"><img src="<?php print $IMConfig['base_url']; ?>img/edit_pencil.gif" height="15" width="15" alt="Edit"/></a> |
||
246 | <?php $thisFileNameLength -= 3; |
||
247 | } ?> |
||
248 | <?php |
||
249 | if ($IMConfig['allow_delete']) { |
||
250 | ?> |
||
251 | <a href="<?php print $backend_url_enc; ?>__function=images&mode=<?php echo $insertMode; ?>&dir=<?php echo $relative; ?>&delf=<?php echo rawurlencode($file['relative']); ?>&viewtype=<?php echo $afruViewType; ?>" title="Trash" |
||
252 | onclick="return confirmDeleteFile('<?php echo $entry; ?>');"><img src="<?php print $IMConfig['base_url']; ?>img/edit_trash.gif" height="15" width="15" alt="Trash"/></a> |
||
253 | <?php |
||
254 | } |
||
255 | ?> |
||
256 | <?php if ($IMConfig['allow_rename']) { ?> |
||
257 | <a href="#" title="Rename" onclick="renameFile('<?php echo rawurlencode($file['relative']); ?>'); return false;"><img src="<?php print $IMConfig['base_url']; ?>img/edit_rename.gif" height="15" width="15" alt="Rename"/></a> |
||
258 | <?php $thisFileNameLength -= 3; |
||
259 | } ?> |
||
260 | <?php if ($IMConfig['allow_cut_copy_paste']) { ?> |
||
261 | <a href="#" title="Cut" onclick="copyFile('<?php echo rawurlencode($entry); ?>','move'); return false;"><img src="<?php print $IMConfig['base_url']; ?>img/edit_cut.gif" height="15" width="15" alt="Cut"/></a> |
||
262 | <a href="#" title="Copy" onclick="copyFile('<?php echo rawurlencode($entry); ?>','copy'); return false;"><img src="<?php print $IMConfig['base_url']; ?>img/edit_copy.gif" height="15" width="15" alt="Copy"/></a> |
||
263 | <?php $thisFileNameLength -= 6; |
||
264 | } ?> |
||
265 | |||
266 | </div> |
||
451 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.