From 02f8e7f63307a5bdc8cd2ea6ccf89867a4dfb6f8 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 5 Feb 2005 22:29:40 +0000 Subject: [PATCH] r46: Added new selection engine that can do it all one one page! --- global.php | 3 +- includes/functions.php | 102 +++++++++++++++++++++++++++ templates/default/pcv_select_row.tpl | 1 + 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100755 templates/default/pcv_select_row.tpl diff --git a/global.php b/global.php index 126eb42..fcacfe2 100755 --- a/global.php +++ b/global.php @@ -32,7 +32,8 @@ $globaltemplates = array( 'headinclude', 'footer', 'selectoption', - 'selectoptgroup' + 'selectoptgroup', + 'pcv_select_row' ); $tpl->cache(array_merge($globaltemplates, (array)$fetchtemplates)); diff --git a/includes/functions.php b/includes/functions.php index e215732..30f48c6 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -273,6 +273,108 @@ function can_perform($bitmask, $userinfo = null) return ($userinfo['permissions'] & $_PERMISSION["bitmask"]); } +// #################### Start construct_pcv_select ################### +// constructs a product/component/version select with one go :-) +function construct_pcv_select($type = 'radio', $prefix = '     ') +{ + global $bugsys, $DB_sql, $tpl; + static $HTML; + + if ($HTML) + { + return $HTML; + } + + $row['typeselect'] = $type; + + $products_fetch = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "product ORDER BY displayorder ASC"); + while ($product = $DB_sql->fetch_array($products_fetch)) + { + if ($product['componentmother']) + { + $components["$product[componentmother]"]["$product[productid]"] = $product; + } + else + { + $products["$product[productid]"] = $product; + } + } + + $versions_fetch = $DB_sql->query("SELECT * FROM " . TABLE_PREFIX . "version ORDER BY displayorder"); + while ($version = $DB_sql->fetch_array($versions_fetch)) + { + $versions["$version[productid]"]["$version[versionid]"] = $version; + } + + foreach ($products AS $product) + { + $row['prefix'] = ''; + $valuepfx = "p$product[productid]"; + $row['value'] = "{$valuepfx}c0v0"; + $row['title'] = "$product[title]"; + $row['description'] = ''; + eval('$HTML .= "' . $tpl->fetch('pcv_select_row') . '";'); + $HTML .= construct_pcv_select_global_version($product['productid'], 0, $versions, $prefix, $type); + if (is_array($versions["$product[productid]"])) + { + foreach ($versions["$product[productid]"] AS $version) + { + $row['prefix'] = $prefix . $prefix; + $row['typeselect'] = $type; + $row['value'] = "{$valuepfx}c0v$version[versionid]"; + $row['title'] = $version['version']; + eval('$HTML .= "' . $tpl->fetch('pcv_select_row') . '";'); + } + } + + if (is_array($components["$product[productid]"])) + { + foreach ($components["$product[productid]"] AS $component) + { + $row['prefix'] = $prefix; + $valuepfx .= "c$component[productid]"; + $row['value'] = "{$valuepfx}v0"; + $row['title'] = $component['title']; + $row['description'] = ''; + eval('$HTML .= "' . $tpl->fetch('pcv_select_row') . '";'); + $HTML .= construct_pcv_select_global_version($component['componentmother'], $component['productid'], $versions, $prefix, $type);; + if (is_array($versions["$component[productid]"])) + { + foreach ($versions["$component[productid]"] AS $version) + { + $row['prefix'] = $prefix . $prefix; + $row['value'] = "$valuepfx$version[versionid]"; + $row['title'] = $version['version']; + $row['description'] = ''; + eval('$HTML .= "' . $tpl->fetch('pcv_select_row') . '";'); + } + } + } + } + } + + return $HTML; +} + +// ############ Start construct_pcv_select_global_version ############ +function construct_pcv_select_global_version($product = 0, $component = 0, $versions = array(), $prefix = '', $type) +{ + global $tpl; + if (is_array($versions['0'])) + { + foreach ($versions['0'] AS $version) + { + $row['prefix'] = $prefix . $prefix; + $row['typeselect'] = $type; + $row['value'] = "p{$product}c{$component}v$version[versionid]"; + $row['title'] = $version['version']; + $row['description'] = ''; + eval('$global_versions_html .= "' . $tpl->fetch('pcv_select_row') . '";'); + } + } + return $global_versions_html; +} + /*=====================================================================*\ || ################################################################### || # $HeadURL$ diff --git a/templates/default/pcv_select_row.tpl b/templates/default/pcv_select_row.tpl new file mode 100755 index 0000000..b9644fc --- /dev/null +++ b/templates/default/pcv_select_row.tpl @@ -0,0 +1 @@ +$row[prefix] $row[title]: $row[description]
-- 2.22.5