/
ui.php
59 lines (50 loc) · 1.9 KB
/
ui.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
// Copyright (C) 2010-2011 Aron Racho <aron@mi-squred.com>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
require_once( $GLOBALS['fileroot'] . "/library/options.inc.php" );
function getLabel( $value, $list_id ) {
// get from list_options
$result = generate_display_field(array('data_type'=>'1','list_id'=>$list_id), $value);
if ( $result != '') {
return $result;
}
// if not found, default to the passed-in value
return $value;
}
function getLayoutLabel( $value, $form_id ) {
// get from layout_options
$sql = sqlStatement(
"SELECT title from layout_options WHERE form_id = ? and field_id = ?", array($form_id, $value)
);
if (sqlNumRows($sql) > 0) {
$result = sqlFetchArray( $sql );
return xl( $result['title'] );
}
// if not found, default to the passed-in value
return $value;
}
function getListOptions( $list_id ) {
$options = array();
$sql = sqlStatement(
"SELECT option_id, title from list_options WHERE list_id = ?", array($list_id)
);
for($iter=0; $row=sqlFetchArray( $sql ); $iter++) {
$options[] = new Option(
out( $row['option_id'] ), // id
out( xl_list_label($row['title']) ) // label
);
}
return $options;
}
function getListOptionsArray( $list_id ) {
$optionsArray = array();
foreach ( getListOptions($list_id) as $option ) {
$optionsArray[] = array( "id" => $option->id, "label" => $option->label );
}
return $optionsArray;
}
?>