return $whereclause;
}
-// Return a simple object list w/o related information.
-function getNarrowObjectList ($type_id = 0)
+// Return a simple object list w/o related information, so that the returned value
+// can be directly used by printSelect().
+function getNarrowObjectList ($typeList = array())
{
$ret = array();
- if (!$type_id)
- {
- showError ('Invalid argument', __FUNCTION__);
- return $ret;
- }
- // object type id is known and constant, but it's Ok to have this standard overhead
- $query =
- "select RackObject.id as id, RackObject.name as name, dict_value as objtype_name, " .
- "objtype_id from " .
- "RackObject inner join Dictionary on objtype_id=dict_key join Chapter on Chapter.id = Dictionary.chapter_id " .
- "where RackObject.deleted = 'no' and Chapter.name = 'RackObjectType' " .
- "and objtype_id = ${type_id} " .
- "order by name";
- $result = useSelectBlade ($query, __FUNCTION__);
- while ($row = $result->fetch (PDO::FETCH_ASSOC))
+ global $dbxlink;
+ foreach ($typeList as $type_id)
{
- foreach (array (
- 'id',
- 'name',
- 'objtype_name',
- 'objtype_id'
- ) as $cname)
- $ret[$row['id']][$cname] = $row[$cname];
- $ret[$row['id']]['dname'] = displayedName ($ret[$row['id']]);
+ $type_id = $dbxlink->quote (trim ($type_id));
+ $query =
+ "select RackObject.id as id, RackObject.name as name, dict_value as objtype_name, " .
+ "objtype_id from " .
+ "RackObject inner join Dictionary on objtype_id=dict_key join Chapter on Chapter.id = Dictionary.chapter_id " .
+ "where RackObject.deleted = 'no' and Chapter.name = 'RackObjectType' " .
+ "and objtype_id = ${type_id} " .
+ "order by name";
+ $result = useSelectBlade ($query, __FUNCTION__);
+ while ($row = $result->fetch (PDO::FETCH_ASSOC))
+ $ret[$row['id']] = displayedName ($row);
}
return $ret;
}
'js' => 'javascript',
);
+$attrtypes = array
+(
+ 'uint' => '[U] unsigned integer',
+ 'float' => '[F] floating point',
+ 'string' => '[S] string',
+ 'dict' => '[D] dictionary record'
+);
+
// Main menu.
function renderIndex ()
{
printOpFormIntro ('addIPv4Allocation');
echo "<tr><td>";
printImageHREF ('add', 'allocate', TRUE);
- echo "</td><td><select name='object_id' tabindex=100>";
-
- foreach (explode (',', getConfigVar ('IPV4_PERFORMERS')) as $type)
- foreach (getNarrowObjectList ($type) as $object)
- echo "<option value='${object['id']}'>${object['dname']}</option>";
-
- echo "</select></td><td><input type=text tabindex=101 name=bond_name size=10></td><td>";
+ echo "</td><td>";
+ printSelect (getNarrowObjectList (explode (',', getConfigVar ('IPV4_PERFORMERS'))), 'object_id', NULL, 100);
+ echo "</td><td><input type=text tabindex=101 name=bond_name size=10></td><td>";
printSelect ($aat, 'bond_type', NULL, 102);
echo "</td><td>";
printImageHREF ('add', 'allocate', TRUE, 103);
function renderAttributes ()
{
- global $nextorder;
+ global $nextorder, $attrtypes;
$attrMap = getAttrMap();
startPortlet ('Optional attributes');
echo "<table class=cooltable border=0 cellpadding=5 cellspacing=0 align=center>\n";
{
echo "<tr class=row_${order}>";
echo "<td class=tdleft>${attr['name']}</td>";
- echo "<td class=tdleft>${attr['type']}</td>";
+ echo "<td class=tdleft>" . $attrtypes[$attr['type']] . "</td>";
echo '<td class=tdleft>';
if (count ($attr['application']) == 0)
echo ' ';
printOpFormIntro ('add');
echo '<tr><td>';
printImageHREF ('add', 'Create attribute', TRUE);
- echo "</td><td><input type=text tabindex=100 name=attr_name></td>";
- echo '<td><select name=attr_type tabindex=101>';
- echo '<option value=uint>uint</option>';
- echo '<option value=float>float</option>';
- echo '<option value=string>string</option>';
- echo '<option value=dict>dict</option>';
- echo '</select></td><td>';
+ echo "</td><td><input type=text tabindex=100 name=attr_name></td><td>";
+ global $attrtypes;
+ printSelect ($attrtypes, 'attr_type', NULL, 101);
+ echo '</td><td>';
printImageHREF ('add', 'Create attribute', TRUE, 102);
echo '</td></tr></form>';
}
startPortlet ('Add new');
echo "<table cellspacing=0 cellpadding=5 align=center class=widetable>\n";
printOpFormIntro ('addLB');
- echo "<tr valign=top><th>LB / VS</th><td class=tdleft><select name='object_id' tabindex=1>";
- foreach (explode (',', getConfigVar ('NATV4_PERFORMERS')) as $type)
- foreach (getNarrowObjectList ($type) as $object)
- echo "<option value='${object['id']}'>${object['dname']}</option>";
- echo "</select> ";
+ echo "<tr valign=top><th>LB / VS</th><td class=tdleft>";
+ printSelect (getNarrowObjectList (explode (',', getConfigVar ('NATV4_PERFORMERS'))), 'object_id', NULL, 1);
printSelect ($vs_list, 'vs_id', NULL, 2);
echo "</td><td>";
printImageHREF ('add', 'Configure LB', TRUE, 5);
startPortlet ('Add new');
echo "<table cellspacing=0 cellpadding=5 align=center class=widetable>\n";
printOpFormIntro ('addLB');
- echo "<tr valign=top><th>LB / RS pool</th><td class=tdleft><select name='object_id' tabindex=1>";
- foreach (explode (',', getConfigVar ('NATV4_PERFORMERS')) as $type)
- foreach (getNarrowObjectList ($type) as $object)
- echo "<option value='${object['id']}'>${object['dname']}</option>";
- echo "</select> ";
+ echo "<tr valign=top><th>LB / RS pool</th><td class=tdleft>";
+ printSelect (getNarrowObjectList (explode (',', getConfigVar ('NATV4_PERFORMERS'))), 'object_id', NULL, 1);
printSelect ($rsplist, 'pool_id', NULL, 2);
echo "</td><td>";
printImageHREF ('add', 'Configure LB', TRUE, 5);