MDL-14320, remove icon when no file in entry, Thanks Robert
authordongsheng <dongsheng>
Tue, 15 Apr 2008 02:41:27 +0000 (02:41 +0000)
committerdongsheng <dongsheng>
Tue, 15 Apr 2008 02:41:27 +0000 (02:41 +0000)
mod/data/field/file/field.class.php

index e806ff7fa0d5990d4859a50f378bd8ca842b0a82..25bbd14f34c975a36ea77f98c2ae06b4109a541d 100755 (executable)
@@ -115,10 +115,14 @@ class data_field_file extends data_field_base {
             $width = $this->field->param1 ? ' width = "'.s($this->field->param1).'" ':' ';
             $height = $this->field->param2 ? ' height = "'.s($this->field->param2).'" ':' ';
 
-            require_once($CFG->libdir.'/filelib.php');
-            $icon = mimeinfo('icon', $src);
-            $str = '<img src="'.$CFG->pixpath.'/f/'.$icon.'" height="16" width="16" alt="'.$icon.'" />&nbsp;'.
-                            '<a href="'.$source.'/'.$src.'" >'.$name.'</a>';
+            if (isset($contents[0])) {
+                require_once($CFG->libdir.'/filelib.php');
+                $icon = mimeinfo('icon', $src);
+                $str = '<img src="'.$CFG->pixpath.'/f/'.$icon.'" height="16" width="16" alt="'.$icon.'" />&nbsp;'.
+                                '<a href="'.$source.'/'.$src.'" >'.$name.'</a>';
+            } else {
+                $str = '';
+            }
             return $str;
         }
         return false;