Various little fixes.

This commit is contained in:
moodler 2006-03-26 05:03:10 +00:00
parent 3620b8dccf
commit 473dd2888b
7 changed files with 58 additions and 85 deletions

View file

@ -80,27 +80,31 @@ class data_field_picture extends data_field_file {
$contents[1] = $content->content1;
}
if (empty($contents[0])) { // Nothing to show
return '';
}
$alt = empty($contents[1])? '':$contents[1];
$title = empty($contents[1])? '':$contents[1];
$src = empty($contents[0])? '':$contents[0];
$src = $contents[0];
$path = $this->data->course.'/'.$CFG->moddata.'/data/'.$this->data->id.'/'.$this->field->id.'/'.$recordid;
if ($CFG->slasharguments) {
$source = $CFG->wwwroot.'/file.php/'.$path;
$source = $CFG->wwwroot.'/file.php/'.$path.'/'.$src;
} else {
$source = $CFG->wwwroot.'/file.php?file=/'.$path;
$source = $CFG->wwwroot.'/file.php?file=/'.$path.'/'.$src;
}
if ($template == 'listtemplate') {
$width = $this->field->param4 ? ' width="'.$this->field->param4.'" ' : ' ';
$height = $this->field->param5 ? ' height="'.$this->field->param5.'" ' : ' ';
$str = '<a href="view.php?d='.$this->field->dataid.'&amp;rid='.$recordid.'"><img '.
$width.$height.' src="'.$source.'/'.$src.'" alt="'.$alt.'" title="'.$title.'" border="0" /></a>';
$width.$height.' src="'.$source.'" alt="'.$alt.'" title="'.$title.'" border="0" /></a>';
} else {
$width = $this->field->param1 ? ' width="'.$this->field->param1.'" ':' ';
$height = $this->field->param2 ? ' height="'.$this->field->param2.'" ':' ';
$str = '<img '.$width.$height.' src="'.$source.'/'.$src.'" alt="'.$alt.'" title="'.$title.'" />';
$str = '<a href="'.$source.'"><img '.$width.$height.' src="'.$source.'" alt="'.$alt.'" title="'.$title.'" border="0"/></a>';
}
return $str;
}

View file

@ -45,7 +45,7 @@ class data_field_url extends data_field_base {
$url = empty($url) ? 'http://' : $url;
$str = '<div title="'.$this->field->description.'">';
if (!empty($this->field->param1)) {
if (!empty($this->field->param1) and empty($this->field->param2)) {
$str .= '<table><tr><td align="right">';
$str .= get_string('url','data').':</td><td><input type="text" name="field_'.$this->field->id.'_0" id="field_'.$this->field->id.'_0" value="'.$url.'" size="60" /></td></tr>';
$str .= '<tr><td align="right">'.get_string('text','data').':</td><td><input type="text" name="field_'.$this->field->id.'_1" id="field_'.$this->field->id.'_1" value="'.$text.'" size="60" /></td></tr>';
@ -62,6 +62,14 @@ class data_field_url extends data_field_base {
if ($content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)){
$url = empty($content->content)? '':$content->content;
$text = empty($content->content1)? '':$content->content1;
if (empty($url) or ($url == 'http://')) {
return '';
}
if (!empty($this->field->param2)) { // param2 forces the text to something
$text = $this->field->param2;
}
if ($this->field->param1) { // param1 defines whether we want to autolink the url.
if (!empty($text)) {

View file

@ -7,8 +7,12 @@
<td class="c0"> <?php echo get_string('fielddescription', 'data'); ?>: </td>
<td class="c1"> <input class="fielddescription" type="text" name="description" id="description" value = "<?php echo ($this->field->description);?>" /> </td>
</tr>
<tr>
<td class="c0"> <?php echo get_string('forcelinkname', 'data'); ?>: </td>
<td class="c1"> <input class="forcelinkname" type="text" name="param2" id="forcelinkname" value = "<?php echo ($this->field->param2);?>" /> </td>
</tr>
<tr>
<td class="c0"><?php echo get_string('autolinkurl', 'data') ?></td>
<td class="c1"><input type="checkbox" name="param1" id="param1" <?php if($this->field->param1) {echo 'checked="checked"';} ?> value="1" /></td>
</tr>
</table>
</table>