From: dongsheng Date: Wed, 16 Apr 2008 02:46:03 +0000 (+0000) Subject: MDL-14320, improve coding style, thanks Petr, merged from MOODLE_19_STABLE X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=1dfbf846f8db71ab8ce9a38b31ea6c64f7b9f48e;p=moodle.git MDL-14320, improve coding style, thanks Petr, merged from MOODLE_19_STABLE --- diff --git a/mod/data/field/file/field.class.php b/mod/data/field/file/field.class.php index 25bbd14f34..8cbb4cb5ef 100755 --- a/mod/data/field/file/field.class.php +++ b/mod/data/field/file/field.class.php @@ -97,35 +97,29 @@ class data_field_file extends data_field_base { global $CFG; - if ($content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)){ - $contents[0] = $content->content; - $contents[1] = $content->content1; + if (!$content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)) { + return false; + } - $src = empty($contents[0])? '':$contents[0]; - $name = empty($contents[1])? $src:$contents[1]; + $width = $this->field->param1 ? ' width = "'.s($this->field->param1).'" ':' '; + $height = $this->field->param2 ? ' height = "'.s($this->field->param2).'" ':' '; - $path = $this->data->course.'/'.$CFG->moddata.'/data/'.$this->data->id.'/'.$this->field->id.'/'.$recordid; + if (empty($content->content)) { + return ''; + } - if ($CFG->slasharguments) { - $source = $CFG->wwwroot.'/file.php/'.$path; - } else { - $source = $CFG->wwwroot.'/file.php?file=/'.$path; - } + require_once($CFG->libdir.'/filelib.php'); - $width = $this->field->param1 ? ' width = "'.s($this->field->param1).'" ':' '; - $height = $this->field->param2 ? ' height = "'.s($this->field->param2).'" ':' '; + $src = $content->content; + $name = empty($content->content1) ? $src : $content->content1; - if (isset($contents[0])) { - require_once($CFG->libdir.'/filelib.php'); - $icon = mimeinfo('icon', $src); - $str = ''.$icon.' '. - ''.$name.''; - } else { - $str = ''; - } - return $str; - } - return false; + $source = get_file_url($this->data->course.'/'.$CFG->moddata.'/data/'.$this->data->id.'/'.$this->field->id.'/'.$recordid); + + $icon = mimeinfo('icon', $src); + $str = ''.$icon.' '. + ''.$name.''; + + return $str; }