setData($data);
if (!$displayData) {
$displayData= array();
foreach ($data as $value) {
$displayData[]= array($value);
}
} else {
$this->setDisplayData($displayData);
}
// Generate instance wide unique ID
$tmp= gettimeofday();
$this->id= 'l'.md5($tmp['sec']);
// Set reorderable flag
$this->reorderable= $reorderable;
if (!$reorderable) {
$this->sortData();
}
}
private function setData($data)
{
$this->data= $data;
}
private function setDisplayData($data)
{
if (!is_array($data)) {
die ("sortableList needs an array as data!");
}
// Transfer information
$this->displayData= $data;
// Create initial mapping
$this->mapping= array_keys($data);
$this->current_mapping= $this->mapping;
// Find the number of coluns
reset($this->displayData);
$first= current($this->displayData);
if (is_array($first)) {
$this->columns= count($first);
} else {
$this->columns= 1;
}
// Preset sort orders to 'down'
for ($column= 0; $column<$this->columns; $column++) {
$this->sortDirection[]= true;
}
}
public function setWidth($width)
{
$this->width= $width;
}
public function setInstantDelete($flag)
{
$this->instantDelete= $flag;
}
public function setEditable($flag)
{
$this->editable= $flag;
}
public function setDeleteable($flag)
{
$this->deleteable= $flag;
}
public function setHeight($height)
{
$this->height= $height;
}
public function setCssClass($css)
{
$this->cssclass= $css;
}
public function setHeader($header)
{
$this->header= $header;
}
public function setColspecs($specs)
{
$this->colspecs= $specs;
}
public function render()
{
$result= "
\n";
$result.= "
cssclass)?" class='".$this->cssclass."'":"").">\n";
$action_width= 0;
if (strpos($this->acl, 'w') === false) {
$edit_image= $this->editable?"":"";
} else {
$edit_image= $this->editable?"":"";
}
if (strpos($this->acl, 'd') === false) {
$delete_image= $this->deleteable?"":"";
} else {
$delete_image= $this->deleteable?"":"";
}
// Do we need colspecs?
$action_width= ($this->editable?20:0) + ($this->deleteable?20:0);
if ($this->colspecs) {
$result.= "
\n";
for ($i= 0; $i<$this->columns; $i++) {
$result.= "
\n";
}
// Extend by another column if we've actions specified
if ($action_width) {
$result.= "
\n";
}
$result.= "
\n";
}
// Do we need a header?
if ($this->header) {
$result.= " \n
\n";
for ($i= 0; $i<$this->columns; $i++) {
$link= "href='?plug=".$_GET['plug']."&PID=".$this->id."&act=SORT_$i'";
$sorter= "";
if ($i == $this->sortColumn){
$sorter= " ";
}
if ($this->reorderable) {
$result.= "