MDL-21437 data - latlong, radio menu and multimenu now working under sqlserver & oracle
This commit is contained in:
@@ -66,17 +66,22 @@ class data_field_latlong extends data_field_base {
|
||||
}
|
||||
|
||||
function display_search_field($value = '') {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
$lats = $DB->get_records_sql_menu('SELECT id, content FROM {data_content} WHERE fieldid=? GROUP BY content ORDER BY content', array($this->field->id));
|
||||
$longs = $DB->get_records_sql_menu('SELECT id, content1 FROM {data_content} WHERE fieldid=? GROUP BY content ORDER BY content', array($this->field->id));
|
||||
global $CFG, $DB;
|
||||
|
||||
$varcharlat = $DB->sql_compare_text('content');
|
||||
$varcharlong= $DB->sql_compare_text('content1');
|
||||
$latlongsrs = $DB->get_recordset_sql(
|
||||
"SELECT DISTINCT $varcharlat AS la, $varcharlong AS lo
|
||||
FROM {data_content}
|
||||
WHERE fieldid = ?
|
||||
ORDER BY $varcharlat, $varcharlong", array($this->field->id));
|
||||
|
||||
$options = array();
|
||||
if(!empty($lats) && !empty($longs)) {
|
||||
$options[''] = '';
|
||||
// Make first index blank.
|
||||
foreach($lats as $key => $temp) {
|
||||
$options[$temp.','.$longs[$key]] = $temp.','.$longs[$key];
|
||||
}
|
||||
foreach ($latlongsrs as $latlong) {
|
||||
$options[$latlong->la . ',' . $latlong->lo] = $latlong->la . ',' . $latlong->lo;
|
||||
}
|
||||
$latlongsrs->close();
|
||||
|
||||
return html_writer::select($options, 'f_'.$this->field->id, $value);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,12 +55,14 @@ class data_field_menu extends data_field_base {
|
||||
}
|
||||
|
||||
function display_search_field($content = '') {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
global $CFG, $DB;
|
||||
|
||||
$usedoptions = array();
|
||||
$sql = "SELECT DISTINCT content
|
||||
$varcharcontent = $DB->sql_compare_text('content', 255);
|
||||
$sql = "SELECT DISTINCT $varcharcontent AS content
|
||||
FROM {data_content}
|
||||
WHERE fieldid=? AND content IS NOT NULL";
|
||||
|
||||
$usedoptions = array();
|
||||
if ($used = $DB->get_records_sql($sql, array($this->field->id))) {
|
||||
foreach ($used as $data) {
|
||||
$value = $data->content;
|
||||
@@ -84,7 +86,7 @@ class data_field_menu extends data_field_base {
|
||||
return '';
|
||||
}
|
||||
|
||||
return html_writer::select($options, 'f_'.$this->field->id, $content, array(''=>' '));
|
||||
return html_writer::select($options, 'f_'.$this->field->id, $content);
|
||||
}
|
||||
|
||||
function parse_search_field() {
|
||||
|
||||
@@ -74,10 +74,12 @@ class data_field_multimenu extends data_field_base {
|
||||
$str = '<select name="f_'.$this->field->id.'[]" multiple="multiple">';
|
||||
|
||||
// display only used options
|
||||
$usedoptions = array();
|
||||
$sql = "SELECT DISTINCT content
|
||||
$varcharcontent = $DB->sql_compare_text('content', 255);
|
||||
$sql = "SELECT DISTINCT $varcharcontent AS content
|
||||
FROM {data_content}
|
||||
WHERE fieldid=? AND content IS NOT NULL";
|
||||
|
||||
$usedoptions = array();
|
||||
if ($used = $DB->get_records_sql($sql, array($this->field->id))) {
|
||||
foreach ($used as $data) {
|
||||
$valuestr = $data->content;
|
||||
|
||||
@@ -63,13 +63,19 @@ class data_field_radiobutton extends data_field_base {
|
||||
}
|
||||
|
||||
function display_search_field($value = '') {
|
||||
global $CFG, $DB, $OUTPUT;
|
||||
$temp = $DB->get_records_sql_menu('SELECT id, content FROM {data_content} WHERE fieldid=? GROUP BY content ORDER BY content', array($this->field->id));
|
||||
global $CFG, $DB;
|
||||
|
||||
$varcharcontent = $DB->sql_compare_text('content', 255);
|
||||
$used = $DB->get_records_sql(
|
||||
"SELECT DISTINCT $varcharcontent AS content
|
||||
FROM {data_content}
|
||||
WHERE fieldid=?
|
||||
ORDER BY $varcharcontent", array($this->field->id));
|
||||
|
||||
$options = array();
|
||||
if(!empty($temp)) {
|
||||
$options[''] = ''; //Make first index blank.
|
||||
foreach ($temp as $key) {
|
||||
$options[$key] = $key; //Build following indicies from the sql.
|
||||
if(!empty($used)) {
|
||||
foreach ($used as $rec) {
|
||||
$options[$rec->content] = $rec->content; //Build following indicies from the sql.
|
||||
}
|
||||
}
|
||||
return html_writer::select($options, 'f_'.$this->field->id, $value);
|
||||
|
||||
Reference in New Issue
Block a user