<?php
/**
* Display list
* @access Public
*/
function Displist ()
{
How to display without indentation
$this->misdisplistindex = true;
Echo (' <p align= "right" ><a href= "Action=new&part=role" > Add new Role </a> </p>); _fcksavedurl= "" Action=new&part=role "> Add new Role </a> </p>");
//
$this->mlisttitle = ' user role list ';
$this->setdataoption (' list ');
//
$this->setquerytable (Array ($this->mtableuserrole));
//
Query order
$this->setqueryorder (' ASC ', $this->mtableuserrole, ' sequence ');
//
$this->query (' list ');
Parent::D isplist ();
Another way to display, using an array as the stack, a: the stack when the role, press the end of the delete source
$this->checkproperty (' Mrdb ');
$this->checkproperty (' Mrsql ');
$this->mrsql->select (' role, title, parent ');
$this->mrsql->from ($this->mtableuserrole);
$this->mrsql->orderby (' Parent, sequence ');
$this->mrs = $this->mrdb->execute ($this->mrsql->sql ());
if (0 < count ($this->mrs))
// {
$source = & $this->mrs->getarray (); Digital Index
$stack = Array ('); Stack
$stacki = Array (-1); and stack corresponds to the level of data in the tree in the record stack
$target = Array ();
while (0 < count ($stack))
// {
$item = Array_shift ($stack);
$lev = Array_shift ($stacki);
if (!empty ($item))
// {
Where the processed data is placed in the target array.
Array_push ($target, Str_repeat (", $lev). $item);
$s 1 = str_repeat (", $lev). $item;
// }
$del = Array (); The node to remove from the $source
$ar = Array (); Nodes that need to be added to the stack
foreach ($source as $key => $val)
// {
Find a matching child node
if (empty ($item))
// {
$find = Empty ($source [$key] [' parent ']);
// }
Else
// {
$find = ($item = = $source [$key] [' parent ']);
// }
if ($find)
// {
Array_unshift ($ar, $source [$key] [' role ']);
$del [] = $key;
// }
// }
foreach ($ar as $val)
// {
Array_unshift ($stack, $val);
Array_unshift ($stacki, $lev + 1);
// }
foreach ($del as $val)
// {
Unset ($source [$val]);
// }
Echo (Implode (', ', $stack). ' <br/> '. Implode (', ', $stacki). ' <br/> '. Implode (', ', $target). ' <br/><br/> ');
// }
Debug_array ();
// }
Else
// {
Echo (' <center> not retrieving Data </center> ');
// }
Another way to display, using an array as the stack, B: Stack time to save the index of the array, out of the stack and then delete the source after use
$this->checkproperty (' Mrdb ');
$this->checkproperty (' Mrsql ');
$this->mrsql->select (' role, title, parent ');
$this->mrsql->from ($this->mtableuserrole);
$this->mrsql->orderby (' Parent, sequence ');
$this->mrs = $this->mrdb->execute ($this->mrsql->sql ());
if (!empty ($this->mrs) &&! $this->mrs->eof)
{
$source = & $this->mrs->getarray (); Digital Index
$stack = Array (-1); Stack
$stacki = Array (-1); and stack corresponds to the level of data in the tree in the record stack
$target = Array ();
while (0 < count ($stack))
{
$item = Array_shift ($stack);
$lev = Array_shift ($stacki);
if ( -1!= $item)
{
Where the processed data is placed in the target array.
$s 1 = str_repeat (", $lev). ' <a href= '? action=disp&part=role&role= '. $source [$item] [' role ']. ' > '. $source [$item] [' title ']. ' </a> ';
$s 2 = ' <a href= ' action=edit&part=role&role= '. $source [$item] [' role ']. ' > Editor </a> <a href= '? action=delete&part=role&role= '. $source [$item] [' role ']. ' > Delete </a> ';
Array_push ($target, Array ($s 1, $s 2));
}
$del = Array (); The node to remove from the $source
$ar = Array (); Nodes that need to be added to the stack
foreach ($source as $key => $val)
{
Find a matching child node
if ( -1 = $item)
{
$find = Empty ($source [$key] [' parent ']);
}
Else
{
$find = ($source [$item] [' role '] = = $source [$key] [' parent ']);
}
if ($find)
{
Array_unshift ($ar, $key);
}
}
foreach ($ar as $val)
{
Array_unshift ($stack, $val);
Array_unshift ($stacki, $lev + 1);
}
Remove from source
Unset ($source [$item]);
Echo (Implode (', ', $stack). ' <br/> '. Implode (', ', $stacki). ' <br/> '. Implode (', ', $target). ' <br/><br/> ');
}
Output
Echo (' <p align= "right" ><a href= "Action=new&part=role" > Add new Role </a> </p>);
Array_unshift ($target, Array (' role ', ' operation '));
$this->checkproperty (' mrlt ');
$this->mrlt->setdata ($target);
$this->mrlt->mlisttitle = ' user role list ';
$this->mrlt->misdispindex = false;
$this->mrlt->disp ();
}
Else
{
Echo (' <center> not retrieving Data </center> ');
}
}//End of function displist
?>