";
}
$first= "";
}
@@ -250,7 +279,7 @@ class sortableListing {
$reorderable= $this->reorderable?"":" style='cursor:default'";
if (strpos($this->acl, 'r') !== false) {
foreach ($this->mapping as $nr => $row) {
- $editable= $this->editable?" onclick='$(\"edit_".$this->id."_$nr\").click()'":"";
+ $editable= $this->editable?" onClick='$(\"edit_".$this->id."_$nr\").click()'":"";
$id= "";
if (isset($this->modes[$row])) {
@@ -269,8 +298,14 @@ class sortableListing {
$first= " style='border:0'";
foreach ($this->displayData[$row] as $column) {
- $result.= "
".$column."
\n";
- $first= "";
+
+ // Do NOT use the onClick statement for columns that contain links or buttons.
+ if(preg_match("<.*type=.submit..*>", $column) || preg_match("", $column)){
+ $result.= "
".$column."
\n";
+ }else{
+ $result.= "
".$column."
\n";
+ }
+ $first= "";
}
if ($action_width) {
@@ -291,7 +326,7 @@ class sortableListing {
$result.= "\n";
$result.= " \n\n\n";
- $result.= " \n";
+# $result.= " \n";
$result.= " \n";
$result.= " \n";
@@ -317,26 +352,27 @@ class sortableListing {
public function update()
{
- // Do not do anything if this is not our PID, or there's even no PID available...
- if(!isset($_REQUEST['PID']) || $_REQUEST['PID'] != $this->id) {
- return;
- }
// Filter GET with "act" attributes
- if (!$this->reorderable && isset($_GET['act'])) {
- $key= validate($_GET['act']);
- if (preg_match('/^SORT_([0-9]+)$/', $key, $match)) {
- // Switch to new column or invert search order?
- $column= $match[1];
- if ($this->sortColumn != $column) {
- $this->sortColumn= $column;
- } else {
- $this->sortDirection[$column]= !$this->sortDirection[$column];
- }
+ if (!$this->reorderable){
+ if(isset($_GET['act']) && isset($_GET['PID']) && $this->id == $_GET['PID']) {
+
+ $key= validate($_GET['act']);
+ if (preg_match('/^SORT_([0-9]+)$/', $key, $match)) {
+
+ // Switch to new column or invert search order?
+ $column= $match[1];
+ if ($this->sortColumn != $column) {
+ $this->sortColumn= $column;
+ } else {
+ $this->sortDirection[$column]= !$this->sortDirection[$column];
+ }
- // Update mapping according to sort parameters
- $this->sortData();
+ }
}
+
+ // Update mapping according to sort parameters
+ $this->sortData();
}
}
@@ -344,7 +380,7 @@ class sortableListing {
public function save_object()
{
// Do not do anything if this is not our PID, or there's even no PID available...
- if(!isset($_REQUEST['PID']) || $_REQUEST['PID'] != $this->id) {
+ if(isset($_REQUEST['PID']) && $_REQUEST['PID'] != $this->id) {
return;
}
@@ -448,11 +484,10 @@ class sortableListing {
public function getMaintainedData()
{
$tmp= array();
-
foreach ($this->mapping as $src => $dst) {
- $tmp[$this->keys[$dst]]= $this->data[$dst];
+ $realKey = $this->keys[$dst];
+ $tmp[$realKey] = $this->data[$realKey];
}
-
return $tmp;
}
@@ -471,6 +506,8 @@ class sortableListing {
public function sortData()
{
+ if(!count($this->data)) return;
+
// Extract data
$tmp= array();
foreach($this->displayData as $item) {
@@ -526,6 +563,23 @@ class sortableListing {
$this->mapping[]= count($this->mapping);
$this->modified= true;
+ // 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++) {
+ if(!isset($this->sortDirection[$column])){
+ $this->sortDirection[$column]= true;
+ }
+ }
+
+
// Sort data after we've added stuff
$this->sortData();
}
@@ -535,4 +589,8 @@ class sortableListing {
return isset($this->keys[$index])?$this->keys[$index]:null;
}
+ public function getData($index) {
+ $realkey = $this->keys[$index];
+ return($this->data[$realkey]);
+ }
}