aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions.inc.php
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/functions.inc.php37
1 files changed, 32 insertions, 5 deletions
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 76c95e326..85db1eb76 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -20,6 +20,33 @@ include( 'functions_category.inc.php' );
//----------------------------------------------------------- generic functions
+// get_enums returns an array containing the possible values of a enum field
+// in a table of the database.
+function get_enums( $table, $field )
+{
+ // retrieving the properties of the table. Each line represents a field :
+ // columns are 'Field', 'Type'
+ $result=mysql_query("desc $table");
+ while ( $row = mysql_fetch_array( $result ) )
+ {
+ // we are only interested in the the field given in parameter for the
+ // function
+ if ( $row['Field']==$field )
+ {
+ // retrieving possible values of the enum field
+ // enum('blue','green','black')
+ $option = explode( ',', substr($row['Type'], 5, -1 ) );
+ for ( $i = 0; $i < sizeof( $option ); $i++ )
+ {
+ // deletion of quotation marks
+ $option[$i] = str_replace( "'", '',$option[$i] );
+ }
+ }
+ }
+ mysql_free_result( $result );
+ return $option;
+}
+
// get_boolean transforms a string to a boolean value. If the string is
// "false" (case insensitive), then the boolean value false is returned. In
// any other case, true is returned.
@@ -54,9 +81,9 @@ function array_remove( $array, $value )
// are precised : e.g. 1052343429.89276600
function get_moment()
{
- $t1 = explode( " ", microtime() );
- $t2 = explode( ".", $t1[0] );
- $t2 = $t1[1].".".$t2[1];
+ $t1 = explode( ' ', microtime() );
+ $t2 = explode( '.', $t1[0] );
+ $t2 = $t1[1].'.'.$t2[1];
return $t2;
}
@@ -273,9 +300,9 @@ function pwg_log( $file, $category, $picture = '' )
}
}
-function templatize_array( $array, $global_array_name )
+function templatize_array( $array, $global_array_name, $handle )
{
- global $vtp, $handle, $lang, $page, $user, $conf;
+ global $vtp, $lang, $page, $user, $conf;
for( $i = 0; $i < sizeof( $array ); $i++ )
{