From faf5ec4fa54882b1ef18b30bc1a913c2e23ce52a Mon Sep 17 00:00:00 2001 From: vyshane Date: Fri, 24 Mar 2006 14:34:00 +0000 Subject: [PATCH] Bug fixes and changes to URL field. --- mod/data/add.php | 2 +- mod/data/field.php | 18 ++++++++++++--- mod/data/field/textarea/mod.html | 35 +++++++++++++++++++++++++----- mod/data/field/url/field.class.php | 16 +++++++++----- mod/data/field/url/mod.html | 6 ++++- mod/data/lib.php | 2 +- 6 files changed, 63 insertions(+), 16 deletions(-) diff --git a/mod/data/add.php b/mod/data/add.php index e71eeae7f4..e0eb5f8d07 100755 --- a/mod/data/add.php +++ b/mod/data/add.php @@ -231,7 +231,7 @@ * Regular expression replacement section * ******************************************/ if ($data->addtemplate){ - $possiblefields = get_records('data_fields','dataid',$data->id); + $possiblefields = get_records('data_fields','dataid',$data->id,'id'); ///then we generate strings to replace foreach ($possiblefields as $eachfield){ diff --git a/mod/data/field.php b/mod/data/field.php index 60b9046b56..fa65352cd5 100755 --- a/mod/data/field.php +++ b/mod/data/field.php @@ -114,7 +114,19 @@ /// Create a field object to collect and store the data safely $field = data_get_field_from_id($fid, $data); $oldfieldname = $field->field->name; - $field->update_field($fieldinput); + + $field->field->name = $fieldinput->name; + $field->field->description = $fieldinput->description; + + for ($i=1; $i<=10; $i++) { + if (isset($fieldinput->{'param'.$i})) { + $field->field->{'param'.$i} = $fieldinput->{'param'.$i}; + } else { + $field->field->{'param'.$i} = ''; + } + } + + $field->update_field(); /// Update the templates. data_replace_field_in_templates($data, $oldfieldname, $field->field->name); @@ -210,7 +222,7 @@ $table->head = array(get_string('action','data'), get_string('fieldname','data'), get_string('type','data')); $table->align = array('center','left','right'); - if ($fff = get_records('data_fields','dataid',$data->id)){ + if ($fff = get_records('data_fields','dataid',$data->id,'id')){ foreach ($fff as $ff) { $field = data_get_field($ff, $data); @@ -267,7 +279,7 @@ if ($showtabs) { $currenttab = 'fields'; - include_once('tabs.php'); + include_once('tabs.php'); } /// Print any notices diff --git a/mod/data/field/textarea/mod.html b/mod/data/field/textarea/mod.html index 262c120b3c..5073c097f1 100755 --- a/mod/data/field/textarea/mod.html +++ b/mod/data/field/textarea/mod.html @@ -5,14 +5,39 @@ : - + + + - : - columns + + : + + + field->param2)) { + echo '"60"'; + } else { + echo('"' . $this->field->param2 . '"'); + } + ?> /> columns + - : - rows + + : + + + field->param3)) { + echo '"35"'; + } else { + echo('"' . $this->field->param3 . '"'); + } + ?> /> rows + diff --git a/mod/data/field/url/field.class.php b/mod/data/field/url/field.class.php index 8a6165ec26..943c5223cd 100755 --- a/mod/data/field/url/field.class.php +++ b/mod/data/field/url/field.class.php @@ -33,7 +33,6 @@ class data_field_url extends data_field_base { function display_add_field($recordid=0){ global $CFG; - $url = ''; $text = ''; @@ -48,7 +47,7 @@ class data_field_url extends data_field_base { $str = '
'; $str .= ''; - if (!empty($this->field->param1)) { + if (!empty($this->field->param1) && $this->field->param1) { $str .= ''; } $str .= '
'; $str .= get_string('url','data').':
'.get_string('text','data').':
'; @@ -61,10 +60,17 @@ 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($text)){ - $text = $url; + + if ($this->field->param1) { // param1 defines whether we want to autolink the url. + if (!empty($text)) { + $str = ''.$text.''; + } else { + $str = ''.$url.''; + } + } else { + $str = $url; } - return ''.$text.''; + return $str; } return false; } diff --git a/mod/data/field/url/mod.html b/mod/data/field/url/mod.html index b105c27331..7d0c9f7675 100755 --- a/mod/data/field/url/mod.html +++ b/mod/data/field/url/mod.html @@ -7,4 +7,8 @@ : - + + + field->param1) {echo 'checked="checked"';} ?> value="1" /> + + \ No newline at end of file diff --git a/mod/data/lib.php b/mod/data/lib.php index 34023594e7..f3be3f7ebd 100755 --- a/mod/data/lib.php +++ b/mod/data/lib.php @@ -318,7 +318,7 @@ function data_generate_default_template($data, $template, $recordid=0, $form=fal } //get all the fields for that database - if ($fields = get_records('data_fields', 'dataid', $data->id)) { + if ($fields = get_records('data_fields', 'dataid', $data->id, 'id')) { $str = '
'; $str .= ''; -- 2.39.5