* 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){
/// 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
</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>
function display_add_field($recordid=0){
global $CFG;
-
$url = '';
$text = '';
$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>';
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;
}
<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
}
//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>';