]> git.mjollnir.org Git - moodle.git/commitdiff
[MDL-8407] Add new function text_export_supported() or export_text_value() to those...
authorrobertall <robertall>
Fri, 30 May 2008 02:03:39 +0000 (02:03 +0000)
committerrobertall <robertall>
Fri, 30 May 2008 02:03:39 +0000 (02:03 +0000)
mod/data/field/file/field.class.php
mod/data/field/latlong/field.class.php
mod/data/field/picture/field.class.php
mod/data/field/url/field.class.php

index 4837e4e27f29847607a4659f2dea2d5b0d000017..b0e2aa809d00d3e0e6a96c654bd0e74ffaf456b9 100755 (executable)
@@ -23,7 +23,6 @@
 ///////////////////////////////////////////////////////////////////////////
 
 class data_field_file extends data_field_base {
-
     var $type = 'file';
 
     function data_field_file($field=0, $data=0) {
@@ -32,7 +31,6 @@ class data_field_file extends data_field_base {
 
     function display_add_field($recordid=0) {
         global $CFG;
-
         if ($recordid){
             if ($content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)) {
                 $contents[0] = $content->content;
@@ -41,13 +39,10 @@ class data_field_file extends data_field_base {
                 $contents[0] = '';
                 $contents[1] = '';
             }
-
             $src         = empty($contents[0]) ? '' : $contents[0];
             $name        = empty($contents[1]) ? $src : $contents[1];
             $displayname = empty($contents[1]) ? '' : $contents[1];
-
             $path = $this->data->course.'/'.$CFG->moddata.'/data/'.$this->data->id.'/'.$this->field->id.'/'.$recordid;
-
             if ($CFG->slasharguments) {
                 $source = $CFG->wwwroot.'/file.php/'.$path;
             } else {
@@ -59,7 +54,6 @@ class data_field_file extends data_field_base {
             $displayname = '';
             $source = '';
         }
-
         $str = '<div title="' . s($this->field->description) . '">';
         $str .= '<fieldset><legend><span class="accesshide">'.$this->field->name.'</span></legend>';
         $str .= '<input type="hidden" name ="field_'.$this->field->id.'_file" value="fakevalue" />';
@@ -70,8 +64,8 @@ class data_field_file extends data_field_base {
         $str .= '<input type="hidden" name="MAX_FILE_SIZE" value="'.s($this->field->param3).'" />';
         $str .= '</fieldset>';
         $str .= '</div>';
-
-        if ($recordid and isset($content) and !empty($content->content)){                     // Print icon
+        if ($recordid and isset($content) and !empty($content->content)) {
+            // Print icon
             require_once($CFG->libdir.'/filelib.php');
             $icon = mimeinfo('icon', $src);
             $str .= '<img src="'.$CFG->pixpath.'/f/'.$icon.'" class="icon" alt="'.$icon.'" />'.
@@ -81,54 +75,43 @@ class data_field_file extends data_field_base {
     }
 
     function display_search_field($value = '') {
-        return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';   
+        return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';
     }
-    
+
     function generate_sql($tablealias, $value) {
-        return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content LIKE '%{$value}%') "; 
+        return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content LIKE '%{$value}%') ";
     }
-    
 
     function parse_search_field() {
         return optional_param('f_'.$this->field->id, '', PARAM_NOTAGS);
     }
 
     function display_browse_field($recordid, $template) {
-
         global $CFG;
-
         if (!$content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)) {
             return false;
         }
-
         $width = $this->field->param1 ? ' width = "'.s($this->field->param1).'" ':' ';
         $height = $this->field->param2 ? ' height = "'.s($this->field->param2).'" ':' ';
-
         if (empty($content->content)) {
             return '';
         }
-
         require_once($CFG->libdir.'/filelib.php');
-
         $src  = $content->content;
         $name = empty($content->content1) ? $src : $content->content1;
-
         $source = get_file_url($this->data->course.'/'.$CFG->moddata.'/data/'.$this->data->id.'/'.$this->field->id.'/'.$recordid);
-
         $icon = mimeinfo('icon', $src);
         $str = '<img src="'.$CFG->pixpath.'/f/'.$icon.'" height="16" width="16" alt="'.$icon.'" />&nbsp;'.
                         '<a href="'.$source.'/'.$src.'" >'.$name.'</a>';
-
         return $str;
     }
 
 
-/// content = a ## b where a is the filename, b is the display file name
+    // content: "a##b" where a is the file name, b is the display name
     function update_content($recordid, $value, $name) {
         global $CFG;
-
         if (!$oldcontent = get_record('data_content','fieldid', $this->field->id, 'recordid', $recordid)) {
-        /// Quickly make one now!
+        // Quickly make one now!
             $oldcontent = new object;
             $oldcontent->fieldid = $this->field->id;
             $oldcontent->recordid = $recordid;
@@ -136,23 +119,20 @@ class data_field_file extends data_field_base {
                 print_error('cannotinsertempty', 'data');
             }
         }
-
         $content = new object;
         $content->id = $oldcontent->id;
-
         $names = explode('_',$name);
         switch ($names[2]) {
-            case 'file':    //file just uploaded
-                //$course = get_course('course', 'id', $this->data->course);
-
+            case 'file':
+                // file just uploaded
+#                $course = get_course('course', 'id', $this->data->course);
                 $filename = $_FILES[$names[0].'_'.$names[1]];
                 $filename = $filename['name'];
                 $dir = $this->data->course.'/'.$CFG->moddata.'/data/'.$this->data->id.'/'.$this->field->id.'/'.$recordid;
-
-                //only use the manager if file is present, to avoid "are you sure you selected a file to upload" msg
+                // only use the manager if file is present, to avoid "are you sure you selected a file to upload" msg
                 if ($filename){
                     require_once($CFG->libdir.'/uploadlib.php');
-                    //FIX ME: $course not defined heer!!
+                    // FIX ME: $course not defined here
                     $um = new upload_manager($names[0].'_'.$names[1],true,false,$this->data->course,false,$this->field->param3);
                     if ($um->process_file_uploads($dir)) {
                         $newfile_name = $um->get_new_filename();
@@ -162,7 +142,8 @@ class data_field_file extends data_field_base {
                 }
                 break;
 
-            case 'filename':    //only changing alt tag
+            case 'filename':
+                // only changing alt tag
                 $content->content1 = clean_param($value, PARAM_NOTAGS);
                 update_record('data_content', $content);
                 break;
@@ -172,15 +153,20 @@ class data_field_file extends data_field_base {
         }
     }
 
-    function notemptyfield($value, $name){
+    function notemptyfield($value, $name) {
         $names = explode('_',$name);
-        if ($names[2] == 'file'){
+        if ($names[2] == 'file') {
             $filename = $_FILES[$names[0].'_'.$names[1]];
-            return !empty($filename['name']);    //if there's a file in $_FILES, not empty
+            return !empty($filename['name']);
+            // if there's a file in $_FILES, not empty
         }
         return false;
     }
 
+    function text_export_supported() {
+        return false;
+    }
+
 }
 
 ?>
index b9e4e9d988e6323d101a631fd012ad52dbe0b408..9d7b734f4e67c9288d9f5d5a02242cbcafce3c49 100755 (executable)
@@ -1,4 +1,4 @@
-<?php
+<?php  // $Id$
 ///////////////////////////////////////////////////////////////////////////
 //                                                                       //
 // NOTICE OF COPYRIGHT                                                   //
 ///////////////////////////////////////////////////////////////////////////
 
 class data_field_latlong extends data_field_base {
-
     var $type = 'latlong';
 
     // This is an array of URL schemes for linking out to services, using the float values of lat and long.
     // In each scheme, the special markers @lat@ and @long@ will be replaced by the float values.
     // The config options for the field store each service name that should be displayed, in a comma-separated
     // field. Therefore please DO NOT include commas in the service names if you are adding extra services.
+
+    // Parameter data used:
+    // "param1" is a comma-separated list of the linkout service names that are enabled for this instance
+    // "param2" indicates the label that will be used in generating Google Earth KML files: -1 for item #, -2 for lat/long, positive number for the (text) field to use.
+
     var $linkoutservices = array(
           "Google Maps" => "http://maps.google.com/maps?q=@lat@,+@long@&iwloc=A&hl=en",
           "Google Earth" => "@wwwroot@/mod/data/field/latlong/kml.php?d=@dataid@&fieldid=@fieldid@&rid=@recordid@",
           "Geabios" => "http://www.geabios.com/html/services/maps/PublicMap.htm?lat=@lat@&lon=@long@&fov=0.3&title=Moodle%20data%20item",
           "OpenStreetMap" => "http://www.openstreetmap.org/index.html?lat=@lat@&lon=@long@&zoom=11",
           "Multimap" => "http://www.multimap.com/map/browse.cgi?scale=200000&lon=@long@&lat=@lat@&icon=x"
-          );
+    );
     // Other map sources listed at http://kvaleberg.com/extensions/mapsources/index.php?params=51_30.4167_N_0_7.65_W_region:earth
 
-
-
-    // Parameter data used:
-    // "param1" is a comma-separated list of the linkout service names that are enabled for this instance
-    // "param2" indicates the label that will be used in generating Google Earth KML files: -1 for item #, -2 for lat/long, positive number for the (text) field to use.
-
-
-
     function data_field_latlong($field=0, $data=0) {
         parent::data_field_base($field, $data);
     }
 
-    function display_add_field($recordid=0){
+    function display_add_field($recordid=0) {
         global $CFG;
-
         $lat = '';
         $long = '';
-
-        if ($recordid){
+        if ($recordid) {
             if ($content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)) {
                 $lat  = $content->content;
                 $long = $content->content1;
             }
         }
-        
         $str = '<div title="'.s($this->field->description).'">';
         $str .= '<fieldset><legend><span class="accesshide">'.$this->field->name.'</span></legend>';
         $str .= '<table><tr><td align="right">';
@@ -72,60 +65,56 @@ class data_field_latlong extends data_field_base {
         $str .= '</table>';
         $str .= '</fieldset>';
         $str .= '</div>';
-
         return $str;
     }
-    
+
     function display_search_field($value = '') {
         global $CFG;
         $lats = get_records_sql_menu('SELECT id, content from '.$CFG->prefix.'data_content WHERE fieldid='.$this->field->id.' GROUP BY content ORDER BY content');
         $longs = get_records_sql_menu('SELECT id, content1 from '.$CFG->prefix.'data_content WHERE fieldid='.$this->field->id.' GROUP BY content ORDER BY content');
         $options = array();
         if(!empty($lats) && !empty($longs)) {
-            $options[''] = '';              //Make first index blank.
+            $options[''] = '';
+            // Make first index blank.
             foreach($lats as $key => $temp) {
                 $options[$temp.','.$longs[$key]] = $temp.','.$longs[$key];
             }
         }
        return choose_from_menu($options, 'f_'.$this->field->id, $value, 'choose', '', 0, true);
     }
-    
+
     function parse_search_field() {
         return optional_param('f_'.$this->field->id, '', PARAM_NOTAGS);
     }
-    
+
     function generate_sql($tablealias, $value) {
         $latlong[0] = '';
         $latlong[1] = '';
         $latlong = explode (',', $value, 2);
-        return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content = '$latlong[0]' AND {$tablealias}.content1 = '$latlong[1]') "; 
+        return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content = '$latlong[0]' AND {$tablealias}.content1 = '$latlong[1]') ";
     }
 
     function display_browse_field($recordid, $template) {
         global $CFG;
-        if ($content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)){
+        if ($content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)) {
             $lat = empty($content->content)? '':$content->content;
             $long = empty($content->content1)? '':$content->content1;
-
             if (empty($lat) or empty($long)) {
                 return '';
             }
-
-          if($lat < 0) {
-              $compasslat = "" . sprintf('%01.4f', 0 - $lat) . '°S';
-           } else {
-              $compasslat = "" . sprintf('%01.4f', $lat) . "°N";
-          }
-          if($long < 0) {
-              $compasslong = "" . sprintf('%01.4f', 0 - $long) . '°W';
-           } else {
-              $compasslong = "" . sprintf('%01.4f', $long) . "°E";
-          }
-
+            if($lat < 0) {
+                $compasslat = "" . sprintf('%01.4f', 0 - $lat) . '°S';
+            } else {
+                $compasslat = "" . sprintf('%01.4f', $lat) . "°N";
+            }
+            if($long < 0) {
+                $compasslong = "" . sprintf('%01.4f', 0 - $long) . '°W';
+            } else {
+                $compasslong = "" . sprintf('%01.4f', $long) . "°E";
+            }
             $str = '<form style="display:inline;">';
             $str.= "$compasslat, $compasslong";
 
-
             // Now let's create the jump-to-services link
             $servicesshown = explode(',', $this->field->param1);
 
@@ -139,7 +128,7 @@ class data_field_latlong extends data_field_base {
                 '@courseid@'=> $this->data->course,
                 '@fieldid@'=> $content->fieldid,
                 '@recordid@'=> $content->recordid,
-                );
+            );
 
             if(sizeof($servicesshown)==1 && $servicesshown[0]) {
                 $str .= " <a href='"
@@ -147,7 +136,6 @@ class data_field_latlong extends data_field_base {
                           ."'>$servicesshown[0]</a> ";
             } elseif (sizeof($servicesshown)>1) {
                 $str .= "\n<select name='jumpto'>";
-
                 foreach($servicesshown as $servicename){
                     // Add a link to a service
                     $str .= "\n  <option value='"
@@ -158,9 +146,7 @@ class data_field_latlong extends data_field_base {
                 //   which allows the "Go" button to refer to the drop-down selector.
                 $str .= "\n</select><input type='button' value='" . get_string('go') . "' onclick='if(previousSibling.value){self.location=previousSibling.value}'/>";
             }
-
             $str.= '</form>';
-
             return $str;
         }
         return false;
@@ -170,19 +156,19 @@ class data_field_latlong extends data_field_base {
         $content = new object;
         $content->fieldid = $this->field->id;
         $content->recordid = $recordid;
-
         $names = explode('_', $name);
-        switch ($names[2]){
-            case 0:    // update lat
+        switch ($names[2]) {
+            case 0:
+                // update lat
                 $content->content = (float)$value;
                 break;
-            case 1:    // update long
+            case 1:
+                // update long
                 $content->content1 = (float)$value;
                 break;
             default:
                 break;
         }
-
         if ($oldcontent = get_record('data_content','fieldid', $this->field->id, 'recordid', $recordid)) {
             $content->id = $oldcontent->id;
             return update_record('data_content', $content);
@@ -193,16 +179,23 @@ class data_field_latlong extends data_field_base {
 
     function get_sort_sql($fieldname) {
         global $CFG;
-
         switch ($CFG->dbfamily) {
-            case 'mysql':   // string in an arithmetic operation is converted to a floating-point number
+            case 'mysql':
+                // string in an arithmetic operation is converted to a floating-point number
                 return '('.$fieldname.'+0.0)';
-            case 'postgres': //cast is for PG
+            case 'postgres':
+                //cast is for PG
                 return 'CAST('.$fieldname.' AS REAL)';
-            default:    //Return just the fieldname. TODO: Look behaviour under MSSQL and Oracle
+            default:
+                //Return just the fieldname. TODO: Look behaviour under MSSQL and Oracle
                 return $fieldname;
         }
     }
+
+    function export_text_value($record) {
+        return sprintf('%01.4f', $record->content) . " " . sprintf('%01.4f', $record->content1);
+    }
+
 }
 
 ?>
index 8ece8a8ec9aaf5231c861d3e38567f1ba7d97692..a9f6e9a51ebd8c48436beb40e63f97a86ae8a7a5 100755 (executable)
@@ -1,4 +1,4 @@
-<?php // $Id$
+<?php  // $Id$
 ///////////////////////////////////////////////////////////////////////////
 //                                                                       //
 // NOTICE OF COPYRIGHT                                                   //
 //                                                                       //
 ///////////////////////////////////////////////////////////////////////////
 
-require_once($CFG->dirroot.'/mod/data/field/file/field.class.php'); // Base class is 'file'
+require_once($CFG->dirroot.'/mod/data/field/file/field.class.php');
+// Base class is 'file'
 
 class data_field_picture extends data_field_file {
-
     var $type = 'picture';
-
     var $previewwidth  = 50;
     var $previewheight = 50;
 
@@ -35,28 +34,23 @@ class data_field_picture extends data_field_file {
         parent::data_field_base($field, $data);
     }
 
-    function display_add_field($recordid=0){
+    function display_add_field($recordid=0) {
         global $CFG;
-
         $filepath = '';
         $filename = '';
         $description = '';
-
-        if ($recordid){
+        if ($recordid) {
             if ($content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)) {
                 $filename = $content->content;
                 $description = $content->content1;
             }
-
             $path = $this->data->course.'/'.$CFG->moddata.'/data/'.$this->data->id.'/'.$this->field->id.'/'.$recordid;
-
             if ($CFG->slasharguments) {
                 $filepath = $CFG->wwwroot.'/file.php/'.$path.'/'.$filename;
             } else {
                 $filepath = $CFG->wwwroot.'/file.php?file=/'.$path.'/'.$filename;
             }
         }
-
         $str = '<div title="'.s($this->field->description).'">';
         $str .= '<fieldset><legend><span class="accesshide">'.$this->field->name.'</span></legend>';
         $str .= '<input type="hidden" name ="field_'.$this->field->id.'_file" id="field_'.$this->field->id.'_file"  value="fakevalue" />';
@@ -64,7 +58,7 @@ class data_field_picture extends data_field_file {
         $str .= '<label for="field_'.$this->field->id.'_filename">'.get_string('alttext','data') .'</label>&nbsp;<input type="text" name="field_'
                 .$this->field->id.'_filename" id="field_'.$this->field->id.'_filename" value="'.s($description).'" /><br />';
         $str .= '<input type="hidden" name="MAX_FILE_SIZE" value="'.s($this->field->param3).'" />';
-        if ($filepath){
+        if ($filepath) {
             $str .= '<img width="'.s($this->previewwidth).'" height="'.s($this->previewheight).'" src="'.$filepath.'" alt="" />';
         }
         $str .= '</fieldset>';
@@ -73,37 +67,33 @@ class data_field_picture extends data_field_file {
     }
 
     function display_search_field($value = '') {
-        return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';   
+        return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';
     }
 
     function parse_search_field() {
         return optional_param('f_'.$this->field->id, '', PARAM_NOTAGS);
     }
-    
+
     function generate_sql($tablealias, $value) {
-        return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content LIKE '%{$value}%') "; 
+        return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content LIKE '%{$value}%') ";
     }
 
     function display_browse_field($recordid, $template) {
         global $CFG;
-
         if ($content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)){
-            if (isset($content->content)){
+            if (isset($content->content)) {
                 $contents[0] = $content->content;
                 $contents[1] = $content->content1;
             }
-
-            if (empty($contents[0])) {   // Nothing to show
+            if (empty($contents[0])) {
+                // Nothing to show
                 return '';
             }
-
             $alt = empty($contents[1])? '':$contents[1];
             $title = empty($contents[1])? '':$contents[1];
             $src = $contents[0];
-
             $path = $this->data->course.'/'.$CFG->moddata.'/data/'.$this->data->id.'/'.$this->field->id.'/'.$recordid;
             $thumbnaillocation = $CFG->dataroot .'/'.$this->data->course.'/'.$CFG->moddata.'/data/'.$this->data->id.'/'.$this->field->id.'/'.$recordid.'/thumb/'.$src;
-
             if ($CFG->slasharguments) {
                 $source = $CFG->wwwroot.'/file.php/'.$path.'/'.$src;
                 $thumbnailsource = file_exists($thumbnaillocation) ? $CFG->wwwroot.'/file.php/'.$path.'/thumb/'.$src : $source;
@@ -128,10 +118,8 @@ class data_field_picture extends data_field_file {
     }
 
     function update_field() {
-
         // Get the old field data so that we can check whether the thumbnail dimensions have changed
         $oldfield = get_record('data_fields', 'id', $this->field->id);
-
         if (!update_record('data_fields', $this->field)) {
             notify('updating of new field failed!');
             return false;
@@ -139,16 +127,17 @@ class data_field_picture extends data_field_file {
 
         // Have the thumbnail dimensions changed?
         if ($oldfield && ($oldfield->param4 != $this->field->param4 || $oldfield->param5 != $this->field->param5)) {
-
             // Check through all existing records and update the thumbnail
             if ($contents = get_records('data_content', 'fieldid', $this->field->id)) {
                 if (count($contents) > 20) {
                     notify(get_string('resizingimages', 'data'), 'notifysuccess');
-                    echo "\n\n";   // To make sure that ob_flush() has the desired effect
+                    echo "\n\n";
+                    // To make sure that ob_flush() has the desired effect
                     ob_flush();
                 }
                 foreach ($contents as $content) {
-                    @set_time_limit(300);     // Might be slow!
+                    @set_time_limit(300);
+                    // Might be slow!
                     $this->update_thumbnail($content);
                 }
             }
@@ -158,22 +147,17 @@ class data_field_picture extends data_field_file {
 
     function update_content($recordid, $value, $name) {
         parent::update_content($recordid, $value, $name);
-
         $content = get_record('data_content','fieldid', $this->field->id, 'recordid', $recordid);
-
-        $this->update_thumbnail($content); // Regenerate the thumbnail
+        $this->update_thumbnail($content);
+        // Regenerate the thumbnail
     }
 
-    /**
-    * (Re)generate thumbnail image according to the dimensions specified in the field settings.
-    * If thumbnail width and height are BOTH not specified then no thumbnail is generated, and
-    * additionally an attempted delete of the existing thumbnail takes place.
-    */
     function update_thumbnail($content) {
+        // (Re)generate thumbnail image according to the dimensions specified in the field settings.
+        // If thumbnail width and height are BOTH not specified then no thumbnail is generated, and
+        // additionally an attempted delete of the existing thumbnail takes place.
         global $CFG;
-
         require_once($CFG->libdir . '/gdlib.php');
-
         $datalocation = $CFG->dataroot .'/'.$this->data->course.'/'.$CFG->moddata.'/data/'.
                         $this->data->id.'/'.$this->field->id.'/'.$content->recordid;
         $originalfile = $datalocation.'/'.$content->content;
@@ -181,18 +165,18 @@ class data_field_picture extends data_field_file {
             return;
         }
         if (!file_exists($datalocation.'/thumb')) {
-             mkdir($datalocation.'/thumb', 0777);
+            mkdir($datalocation.'/thumb', 0777);
+            // robertall: Why hardcode 0777??
         }
         $thumbnaillocation = $datalocation.'/thumb/'.$content->content;
         $imageinfo = GetImageSize($originalfile);
         $image->width  = $imageinfo[0];
         $image->height = $imageinfo[1];
         $image->type   = $imageinfo[2];
-
-        if (!$image->width || !$image->height) {  // Should not happen
+        if (!$image->width || !$image->height) {
+            // Should not happen
             return;
         }
-
         switch ($image->type) {
             case 1:
                 if (function_exists('ImageCreateFromGIF')) {
@@ -216,42 +200,40 @@ class data_field_picture extends data_field_file {
                 }
                 break;
         }
-
-        // fix for MDL-7270
         $thumbwidth  = isset($this->field->param4)?$this->field->param4:'';
         $thumbheight = isset($this->field->param5)?$this->field->param5:'';
-
-        if ($thumbwidth || $thumbheight) { // Only if either width OR height specified do we want a thumbnail
-
+        if ($thumbwidth || $thumbheight) {
+            // Only if either width OR height specified do we want a thumbnail
             $wcrop = $image->width;
             $hcrop = $image->height;
-
             if ($thumbwidth && !$thumbheight) {
                 $thumbheight = $image->height * $thumbwidth / $image->width;
             } else if($thumbheight && !$thumbwidth) {
                 $thumbwidth = $image->width * $thumbheight / $image->height;
-            } else { // BOTH are set - may need to crop if aspect ratio differs
+            } else {
+                // BOTH are set - may need to crop if aspect ratio differs
                 $hratio = $image->height / $thumbheight;
                 $wratio = $image->width  / $thumbwidth;
-                if ($wratio > $hratio) { // Crop the width
+                if ($wratio > $hratio) {
+                    // Crop the width
                     $wcrop = intval($thumbwidth * $hratio);
-                } elseif($hratio > $wratio) { // Crop the height
+                } elseif($hratio > $wratio) {
+                    //Crop the height
                     $hcrop = intval($thumbheight * $wratio);
                 }
             }
 
             // At this point both $thumbwidth and $thumbheight are set, and $wcrop and $hcrop
+
             if (function_exists('ImageCreateTrueColor') and $CFG->gdversion >= 2) {
                 $im1 = ImageCreateTrueColor($thumbwidth,$thumbheight);
             } else {
                 $im1 = ImageCreate($thumbwidth,$thumbheight);
             }
-            
-            // Prevent alpha blending for PNG images
             if ($image->type == 3) {
+                // Prevent alpha blending for PNG images
                 imagealphablending($im1, false);
             }
-            
             $cx = $image->width  / 2;
             $cy = $image->height / 2;
 
@@ -261,28 +243,36 @@ class data_field_picture extends data_field_file {
 
             ImageCopyBicubic($im1, $im, 0, 0, $cx-$halfwidth, $cy-$halfheight,
                              $thumbwidth, $thumbheight, $halfwidth*2, $halfheight*2);
-            
-            // Save alpha transparency for PNG images
+
             if ($image->type == 3) {
+                // Save alpha transparency for PNG images
                 imagesavealpha($im1, true);
             }
-            
             if (function_exists('ImageJpeg') && $image->type != 3) {
-                @touch($thumbnaillocation);  // Helps in Safe mode
+                @touch($thumbnaillocation);
+                // Helps in Safe mode
                 if (ImageJpeg($im1, $thumbnaillocation, 90)) {
                     @chmod($thumbnaillocation, 0666);
+                    // robertall: Why hardcode 0666??
                 }
             } elseif (function_exists('ImagePng') && $image->type == 3) {
-                @touch($thumbnaillocation);  // Helps in Safe mode
+                @touch($thumbnaillocation);
+                // Helps in Safe mode
                 if (ImagePng($im1, $thumbnaillocation, 9)) {
                     @chmod($thumbnaillocation, 0666);
-                } 
+                    // robertall: Why hardcode 0666??
+                }
             }
-
-        } else { // Try and remove the thumbnail - we don't want thumbnailing active
+        } else {
+            // Try to remove the thumbnail - we don't want thumbnailing active
             @unlink($thumbnaillocation);
         }
     }
+
+    function text_export_supported() {
+        return false;
+    }
+
 }
 
 ?>
index 23c9138b4d62ed7261e91c4ef821634776d745af..6754af116f151e90f2efdfc39fd3b84100a7578b 100755 (executable)
 ///////////////////////////////////////////////////////////////////////////
 
 class data_field_url extends data_field_base {
-
     var $type = 'url';
 
     function data_field_text($field=0, $data=0) {
         parent::data_field_base($field, $data);
     }
 
-    function display_add_field($recordid=0){
+    function display_add_field($recordid=0) {
         global $CFG;
-
         $url = '';
         $text = '';
-
-        if ($recordid){
+        if ($recordid) {
             if ($content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)) {
                 $url  = $content->content;
                 $text = $content->content1;
             }
         }
-        $url  = empty($url) ?  'http://' : $url;
-
+        $url = empty($url) ? 'http://' : $url;
         $str = '<div title="'.s($this->field->description).'">';
         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="'.s($text).'" size="60" /></td></tr>';
             $str .= '</table>';
-        } else {   // Just the URL field
+        } else {
+            // Just the URL field
             $str .= '<input type="text" name="field_'.$this->field->id.'_0" id="field_'.$this->field->id.'_0" value="'.s($url).'" size="60" />';
         }
         $str .= '</div>';
-
         return $str;
     }
 
     function display_search_field($value = '') {
-        return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';   
+        return '<input type="text" size="16" name="f_'.$this->field->id.'" value="'.$value.'" />';
     }
-    
+
     function parse_search_field() {
         return optional_param('f_'.$this->field->id, '', PARAM_NOTAGS);
     }
-    
+
     function generate_sql($tablealias, $value) {
-        return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content LIKE '%{$value}%') "; 
+        return " ({$tablealias}.fieldid = {$this->field->id} AND {$tablealias}.content LIKE '%{$value}%') ";
     }
 
     function display_browse_field($recordid, $template) {
-        if ($content = get_record('data_content', 'fieldid', $this->field->id, 'recordid', $recordid)){
+        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
+            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 ($this->field->param1) {
+                // param1 defines whether we want to autolink the url.
                 if (!empty($text)) {
                     $str = '<a href="'.$url.'">'.$text.'</a>';
                 } else {
@@ -101,13 +96,14 @@ class data_field_url extends data_field_base {
         $content = new object;
         $content->fieldid = $this->field->id;
         $content->recordid = $recordid;
-
         $names = explode('_', $name);
-        switch ($names[2]){
-            case 0:    // update link
+        switch ($names[2]) {
+            case 0:
+                // update link
                 $content->content = clean_param($value, PARAM_URL);
                 break;
-            case 1:    // add text
+            case 1:
+                // add text
                 $content->content1 = clean_param($value, PARAM_NOTAGS);
                 break;
             default:
@@ -122,15 +118,20 @@ class data_field_url extends data_field_base {
         }
     }
 
-    function notemptyfield($value, $name){
+    function notemptyfield($value, $name) {
         $names = explode('_',$name);
-        $value = clean_param($value, PARAM_URL);    //clean first
-        if ($names[2] == '0'){
+        $value = clean_param($value, PARAM_URL);
+        //clean first
+        if ($names[2] == '0') {
             return ($value!='http://' && !empty($value));
         }
         return false;
     }
 
+    function export_text_value($record) {
+        return $record->content . " " . $record->content1;
+    }
+
 }
 
 ?>