[Support for deletion checkboxes becomes general "group controls", "delete" being a default.. tom@wwworldmedia.com**20050921153436] { hunk ./GangplankList.php 39 - $this->show_delete_checkbox = true; - $this->delete_checked_label = "Delete checked items"; hunk ./GangplankList.php 46 + /* functionality relating to group controls - delete checked, etc.. */ + $this->show_group_controls = true; + $this->group_controls = array(); + $this->group_controls["delete"] = + array("title" => "Delete checked items", + "callback" => array($this, "handleDelete")); + hunk ./GangplankList.php 77 - if ($this->show_delete_checkbox) + if ($this->show_group_controls) hunk ./GangplankList.php 97 - $this->break_row_values[$column] = (rand() % 99999) . (rand() % 99999); + $this->break_row_values[$column] = md5(time()); hunk ./GangplankList.php 174 - if ($this->show_delete_checkbox) { + if ($this->show_group_controls) { + // if we are going to be using group controls (checkboxes), we'll set a hidden var. hunk ./GangplankList.php 177 - $html .= "singular_ws}_delete\" value=\"1\">"; + $field_name = "{$this->singular_ws}_do_group"; + $html .= ""; hunk ./GangplankList.php 190 - if ($this->show_delete_checkbox) { - $html .= "Del"; + if ($this->show_group_controls) { + $html .= " "; hunk ./GangplankList.php 547 - if ($this->show_delete_checkbox) { - $html .= ""; - $html .= "singular_ws}_delete_$primary_key_val\" value=\"1\">"; + if ($this->show_group_controls) { + $html .= ""; + $html .= "singular_ws}_checked_$primary_key_val\" value=\"1\">"; hunk ./GangplankList.php 671 - ($this->show_delete_checkbox && !empty($this->delete_checked_label)) ) { + ($this->show_group_controls) ) { hunk ./GangplankList.php 679 - if ($this->show_delete_checkbox && !empty($this->delete_checked_label)) { - $delete_checked_url = add_url_arg(get_my_url(), "{$this->singular_ws}_delete", 1); - $onclick = "if (confirm('Delete these $this->plural?')) { document.forms.{$this->singular_ws}.submit(); } return false;"; - $html .= "

$this->delete_checked_label

"; + if ($this->show_group_controls) { + $html .= "

"; + $items = array(); + foreach ($this->group_controls as $short_name => $control) { + $onclick = "if (confirm('$control[title]?')) { document.forms.{$this->singular_ws}.{$this->singular_ws}_do_group.value = '$short_name'; document.forms.{$this->singular_ws}.submit(); } return false;"; + $items[] = "$control[title]"; + } + $html .= join(" - ", $items); + $html .= "

"; hunk ./GangplankList.php 708 - if ($this->show_delete_checkbox) + if ($this->show_group_controls) hunk ./GangplankList.php 778 - if (! preg_match("/{$this->singular_ws}_delete_(.*)/", $k, $aa)) + if (! preg_match("/{$this->singular_ws}_checked_(.*)/", $k, $aa)) hunk ./GangplankList.php 791 + // echo "

$qs

"; hunk ./GangplankList.php 797 + // print_r($_REQUEST); hunk ./GangplankList.php 799 - if (! empty($_REQUEST["{$this->singular_ws}_delete"])) { - $this->handleDelete(); + if (! empty($_REQUEST["{$this->singular_ws}_do_group"])) { + $clicked_group = $_REQUEST["{$this->singular_ws}_do_group"]; + foreach ($this->group_controls as $short_name => $control) { + //echo "TESTING $short_name vs $clicked_group

"; + if ($clicked_group == $short_name) { + // echo "DOING $short_name $control[callback]..."; + call_user_func($control["callback"]); + } + } }