]> git.mjollnir.org Git - moodle.git/commitdiff
Bug fixes and changes to URL field.
authorvyshane <vyshane>
Fri, 24 Mar 2006 14:34:00 +0000 (14:34 +0000)
committervyshane <vyshane>
Fri, 24 Mar 2006 14:34:00 +0000 (14:34 +0000)
mod/data/add.php
mod/data/field.php
mod/data/field/textarea/mod.html
mod/data/field/url/field.class.php
mod/data/field/url/mod.html
mod/data/lib.php

index e71eeae7f4cabf59a36014d5a1007ad4b53aae84..e0eb5f8d07ae585c50496c407a5677d2db2e8999 100755 (executable)
      * 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){
index 60b9046b56164bd100a587980a2451c528b70ed9..fa65352cd5b156944f39cd2e98a200892950d8c8 100755 (executable)
                 /// 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);
             $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);
 
 
         if ($showtabs) {
             $currenttab = 'fields';
-            include_once('tabs.php'); 
+            include_once('tabs.php');
         }
 
         /// Print any notices
index 262c120b3c646ea285292285f85021e41b2c3d63..5073c097f1769a58a6dead3899d0e075e5f36d19 100755 (executable)
@@ -5,14 +5,39 @@
     </tr>
     <tr>
         <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>
+        <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('fieldwidth', 'data'); ?>:</td>
-        <td class="c1"><input style="width:50px;" type="text" name="param2" id="width" value="<?php echo($this->field->param2); ?>" /> columns</td>
+        <td class="c0">
+            <?php echo get_string('fieldwidth', 'data'); ?>:
+        </td>
+        <td class="c1">
+            <input style="width:50px;" type="text" name="param2" id="width" value=
+            <?php
+                if (empty($this->field->param2)) {
+                    echo '"60"';
+                } else {
+                    echo('"' . $this->field->param2 . '"');
+                }
+            ?> /> columns
+        </td>
     </tr>
     <tr>
-        <td class="c0"><?php echo get_string('fieldheight', 'data'); ?>:</td>
-        <td class="c1"><input style="width:50px;" type="text" name="param3" id="height" value="<?php echo($this->field->param3); ?>" /> rows</td>
+        <td class="c0">
+            <?php echo get_string('fieldheight', 'data'); ?>:
+        </td>
+        <td class="c1">
+            <input style="width:50px;" type="text" name="param3" id="height" value=
+            <?php
+                if (empty($this->field->param3)) {
+                    echo '"35"';
+                } else {
+                    echo('"' . $this->field->param3 . '"');
+                }
+            ?> /> rows
+        </td>
     </tr>
 </table>
index 8a6165ec267ab36607771d7eefb6ceab5dd7e803..943c5223cd758e1421eebb9bc46bb95192bcacd3 100755 (executable)
@@ -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 = '<div title="'.$this->field->description.'">';
         $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.'" /></td></tr>';
-        if (!empty($this->field->param1)) {
+        if (!empty($this->field->param1) && $this->field->param1) {
             $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.'" /></td></tr>';
         }
         $str .= '</table>';
@@ -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 = '<a href="'.$url.'">'.$text.'</a>';
+                } else {
+                    $str = '<a href="'.$url.'">'.$url.'</a>';
+                }
+            } else {
+                $str = $url;
             }
-            return '<a href = "'.$url.'">'.$text.'</a>';
+            return $str;
         }
         return false;
     }
index b105c27331f0b57a27ef209d21997fde9d85780e..7d0c9f7675ed7e481b621ca853d1b94d9da2c5dd 100755 (executable)
@@ -7,4 +7,8 @@
         <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>
-</table>
+    <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>
\ No newline at end of file
index 34023594e7493d92757dc826066dce5d6cfab976..f3be3f7ebd79238b6b85ce6ff4cf1907e6e577e2 100755 (executable)
@@ -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 = '<div align="center">';
         $str .= '<table>';