Bug fixes and changes to URL field.
This commit is contained in:
+1
-1
@@ -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){
|
||||
|
||||
+15
-3
@@ -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
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
+1
-1
@@ -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>';
|
||||
|
||||
Reference in New Issue
Block a user