[tons of changes and fixes mark@wwworldmedia.com**20050614163720 image upload without scaling add_dt bug user edit cookie crumb added edit button graphic and up and down icons ] { hunk ./admin/user_edit.phtml 7 + $cookie_link_1 = "Users"; + hunk ./incl_scaffold.phtml 16 + $this->singular_ws = preg_replace("/\s+/", "_", $singular); + $this->plural_ws = preg_replace("/\s+/", "_", $plural); + hunk ./incl_scaffold.phtml 163 - $this->cols[$name] = array( + $this->cols["$name"] = array( hunk ./incl_scaffold.phtml 182 - usort($a, $f); + uasort($a, $f); hunk ./incl_scaffold.phtml 185 - + hunk ./incl_scaffold.phtml 199 - function addVirtualColumn($name, $type, $data) { + function addVirtualColumn($name, $type, $data = array()) { hunk ./incl_scaffold.phtml 394 + $this->singular_ws = preg_replace("/\s+/", "_", $singular); + $this->plural_ws = preg_replace("/\s+/", "_", $plural); + hunk ./incl_scaffold.phtml 400 - $this->sort_var = "sort_" . str_replace(" ", "_", $plural); + $this->sort_var = "sort_{$this->plural_ws}"; hunk ./incl_scaffold.phtml 402 - $this->start_var = "start_$plural"; + $this->start_var = "start_{$this->plural_ws}"; hunk ./incl_scaffold.phtml 405 - $this->add_link_url = "${singular}_new.phtml"; + $this->add_link_url = "{$this->singular_ws}_new.phtml"; hunk ./incl_scaffold.phtml 512 - $url = add_url_arg(get_my_url(), $this->sort_var, $col["name"]); - if ($this->use_ajax) { - $onclick = "onclick=\"return " . ws($this->plural) . "_switch('$url');\""; + if ($this->show_move_link === false) { + // allow column sorting + $url = add_url_arg(get_my_url(), $this->sort_var, $col["name"]); + if ($this->use_ajax) { + $onclick = "onclick=\"return {$this->plural_ws}_switch('$url');\""; + } else { + $onclick = ""; + } + + $html .= "$col[label]\n"; hunk ./incl_scaffold.phtml 523 - $onclick = ""; + // disable column sorting; sort key move up/down enabled + $html .= "$col[label]\n"; hunk ./incl_scaffold.phtml 526 - - $html .= "$col[label]\n"; hunk ./incl_scaffold.phtml 614 - $onclick = "onclick=\"return " . ws($this->plural) . "_switch('$url');\""; + $onclick = "onclick=\"return {$this->plural_ws}_switch('$url');\""; hunk ./incl_scaffold.phtml 705 - $ed_pg = $this->singular . "_edit.phtml"; + $ed_pg = "{$this->singular_ws}_edit.phtml"; hunk ./incl_scaffold.phtml 761 - $onclick = "onclick=\"return " . ws($this->plural) . "_switch('$link');\""; + $onclick = "onclick=\"return {$this->plural_ws}_switch('$link');\""; hunk ./incl_scaffold.phtml 763 - $html .= "$this->move_link_label_up"; + //$html .= "$this->move_link_label_up"; + $html .= ""; hunk ./incl_scaffold.phtml 772 - $onclick = "onclick=\"return " . ws($this->plural) . "_switch('$link');\""; + $onclick = "onclick=\"return {$this->plural_ws}_switch('$link');\""; hunk ./incl_scaffold.phtml 774 - $html .= "$this->move_link_label_down"; + //$html .= "$this->move_link_label_down"; + $html .= ""; hunk ./incl_scaffold.phtml 785 - $html .= "$this->edit_link_label"; + //$html .= "$this->edit_link_label"; + $html .= ""; hunk ./incl_scaffold.phtml 806 - $pl = ws($this->plural); hunk ./incl_scaffold.phtml 811 - function " . str_replace(" ", "_", $this->plural) . "_switch(url) { + function {$this->plural_ws}_switch(url) { hunk ./incl_scaffold.phtml 833 - A.setRequestHeader(\"X-Fetcher-$pl\", \"Ajax\"); + A.setRequestHeader(\"X-Fetcher-{$this->plural_ws}\", \"Ajax\"); hunk ./incl_scaffold.phtml 904 - $key = "HTTP_X_FETCHER_" . strtoupper(ws($this->plural)); + $key = "HTTP_X_FETCHER_" . strtoupper($this->plural_ws); hunk ./incl_scaffold.phtml 926 + $this->singular_ws = preg_replace("/\s+/", "_", $singular); + $this->plural_ws = preg_replace("/\s+/", "_", $plural); + hunk ./incl_scaffold.phtml 933 - $this->delete_button_post_url = "${plural}.phtml"; + $this->delete_button_post_url = "{$this->plural_ws}.phtml"; hunk ./incl_scaffold.phtml 936 - $this->scaled_photo_prefix = ""; + $this->photo_prefix = ""; + $this->photo_preview = false; hunk ./incl_scaffold.phtml 939 + $this->virtual_column_types[] = "Photo"; hunk ./incl_scaffold.phtml 974 - $button_name = str_replace(" ", "_", "{$this->singular}_delete"); + $button_name = "{$this->singular_ws}_delete"; hunk ./incl_scaffold.phtml 979 - $button_name = str_replace(" ", "_", "{$this->singular}_save"); + $button_name = "{$this->singular_ws}_save"; hunk ./incl_scaffold.phtml 987 - "; + "; hunk ./incl_scaffold.phtml 992 - onclick=\"return confirm('Are you sure you want to delete this $this->singular?');\">"; + onclick=\"return confirm('Are you sure you want to delete this $this->singular?');\" />"; hunk ./incl_scaffold.phtml 1006 - value=\"$val\">"; + value=\"$val\" />"; hunk ./incl_scaffold.phtml 1019 - value=\"$val\">"; + value=\"$val\" />"; hunk ./incl_scaffold.phtml 1068 - value=\"$val\"> + value=\"$val\" /> hunk ./incl_scaffold.phtml 1088 - "; + "; hunk ./incl_scaffold.phtml 1093 + function renderVirtualPhoto($row, $col) { + global $uploaded_img_url; + + $name = $col["name"]; + + $html = " + + "; + + if (empty($row[$name])) { + $html .= "No pic has been uploaded yet.
"; + } else { + if ($this->photo_preview === true) { + $html .= "\"$name
"; + } else { + $html .= "View image
"; + } + } + + $html .= " + + "; + + return $html; + } + hunk ./incl_scaffold.phtml 1145 - + hunk ./incl_scaffold.phtml 1231 - function " . str_replace(" ", "_", $this->plural) . "_switch(url) { + function {$this->plural_ws}_switch(url) { hunk ./incl_scaffold.phtml 1249 - A.setRequestHeader(\"X-Fetcher-{$this->plural}\", \"Ajax\"); + A.setRequestHeader(\"X-Fetcher-{$this->plural_ws}\", \"Ajax\"); hunk ./incl_scaffold.phtml 1270 - return function() { return " . str_replace(" ", "_", $this->plural) . "_switch(the_url); } + return function() { return {$this->plural_ws}_switch(the_url); } hunk ./incl_scaffold.phtml 1285 - $key = "HTTP_X_FETCHER_" . strtoupper($this->plural); + $key = "HTTP_X_FETCHER_" . strtoupper($this->plural_ws); hunk ./incl_scaffold.phtml 1293 + // save photo w/o scaling + function saveVirtualPhoto($row, $col) { + global $uploaded_img_path; + global $uploaded_img_url; + + if (empty($uploaded_img_path)) $this->error("saveVirtualPhoto(): No uploaded image path"); + if (empty($uploaded_img_url)) $this->error("saveVirutalPhoto(): No uploaded image URL"); + + $pk = $this->primary_key; + + $field = $col["name"]; + if (empty($_FILES[$field]) || empty($_FILES[$field]["name"])) + return; + $tmp = $_FILES[$field]["tmp_name"]; + if (! is_uploaded_file($tmp)) $this->error("saveVirtualPhoto(): Bad upload!"); + + $sql = ""; + + // build the output filename. + $fn = ""; + if (! empty($this->photo_prefix)) + $fn .= "$this->photo_prefix-"; + + if (! empty($row[$pk])) + $fn .= "$row[$pk]-"; + if (! empty($_FILES[$field]["name"])) + $fn .= basename($_FILES[$field]["name"]); + $out_fn = escapeshellcmd($uploaded_img_path . $fn); + //$out_url = $uploaded_img_url . $fn; + $out_url = $fn; + + // build command string + if (! move_uploaded_file($tmp, $out_fn)) { + $this->error("saveVirtualPhoto(): Command failed: 'move_uploaded_file($tmp, $out_fn)'"); + } + + $sql .= "$field = '$out_url', "; + + if (file_exists($tmp)) + unlink($tmp); + return $sql; + } + hunk ./incl_scaffold.phtml 1358 - if (! empty($this->scaled_photo_prefix)) - $fn .= "$this->scaled_photo_prefix-"; + if (! empty($this->photo_prefix)) + $fn .= "$this->photo_prefix-"; hunk ./incl_scaffold.phtml 1367 - $out_url = $uploaded_img_url . $fn; + //$out_url = $uploaded_img_url . $fn; + $out_url = $fn; hunk ./incl_scaffold.phtml 1453 + + xgoto("{$this->plural_ws}.phtml"); hunk ./incl_scaffold.phtml 1472 + $this->singular_ws = preg_replace("/\s+/", "_", $singular); + $this->plural_ws = preg_replace("/\s+/", "_", $plural); + hunk ./incl_scaffold.phtml 1501 - + hunk ./incl_scaffold.phtml 1503 - $this->edit_link_url = "{$this->singular}_edit.phtml?$this->primary_key={KEY}"; + $this->edit_link_url = "{$this->singular_ws}_edit.phtml?$this->primary_key={KEY}"; hunk ./incl_scaffold.phtml 1550 - } - } - - if (! function_exists("ws")) { - function ws($txt) { - return preg_replace("/\s+/", "_", $txt); }