Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

...
  • 3 commits
  • 1 file changed
  • 0 commit comments
  • 1 contributor
Commits on Aug 29, 2012
alan blount zeroasterisk added shell methods for delete and delete_uri
added a couple of shell methods and improved help to match
b648514
alan blount zeroasterisk Merge branch 'new_branch_name' 73bc5e4
alan blount zeroasterisk Merge pull request #6 from zeroasterisk/master
a few updates to the shell
e13fcfe
Showing with 48 additions and 11 deletions.
  1. +48 −11 vendors/shells/seo_redirects.php
59 vendors/shells/seo_redirects.php
View
@@ -15,16 +15,21 @@ function main(){
function help(){
$this->out("{$this->shell} Shell");
$this->hr();
- $this->out(" cake {$this->shell} search <url or redirect> Quickly search for an existing redirect");
- $this->out(" cake {$this->shell} add <url> <redirect> (priority:100) (callback:null)");
- $this->out(" Add a new simple redirect");
+ $this->out("Add a new simple redirect");
+ $this->out(" cake {$this->shell} add <url> <redirect> (priority:100) (callback:null)");
+ $this->out(" cake {$this->shell} add '/mybad/path*' '/my-cleaned-up-path' 50");
+ $this->out(" cake {$this->shell} add '/myother-bad/path*' '/my-cleaned-up-path' 60");
+ $this->out(" cake {$this->shell} add '/my*' '/my-failover-path' 10");
+ $this->out(" cake {$this->shell} add '#/some-old-route-(.*)#i' '/new-route-$1' 10");
+ $this->out(" cake {$this->shell} add '#/(admin|moderator)/(.*)#i' '/$2?old-prefix=$1' 10");
$this->out();
- $this->out("examples:");
- $this->out(" cake {$this->shell} add '/mybad/path*' '/my-cleaned-up-path' 50");
- $this->out(" cake {$this->shell} add '/myother-bad/path*' '/my-cleaned-up-path' 60");
- $this->out(" cake {$this->shell} add '/my*' '/my-failover-path' 10");
- $this->out(" cake {$this->shell} add '#/some-old-route-(.*)#i' '/new-route-$1' 10");
- $this->out(" cake {$this->shell} add '#/(admin|moderator)/(.*)#i' '/$2?old-prefix=$1' 10");
+ $this->out("Quickly search for an existing redirect:");
+ $this->out(" cake {$this->shell} search <url or redirect>");
+ $this->out(" cake {$this->shell} search 'partial-string'");
+ $this->out();
+ $this->out("Easily delete redirect or URI records (by id only)");
+ $this->out(" cake {$this->shell} delete \$id [\$seo_redirect_id] [\$seo_redirect_id]");
+ $this->out(" cake {$this->shell} delete_uri \$id [\$seo_uri_id] [\$seo_uri_id]");
$this->out();
$this->out("more about SEO Redirects");
$this->out(" https://github.com/webtechnick/CakePHP-Seo-Plugin/wiki/Seo-Redirects");
@@ -72,7 +77,6 @@ function search() {
$this->out(" (active={$redirect['SeoRedirect']['is_active']}) (priority={$redirect['SeoRedirect']['priority']}) (callback={$redirect['SeoRedirect']['callback']})");
}
}
-
/**
* A means for simply adding redirects
*/
@@ -128,11 +132,44 @@ function add(){
}
else {
$this->out("Errors");
+ print_r($this->SeoUrl->errors);
print_r($this->SeoUrl->validationErrors);
$this->out();
}
}
/**
+ * A simple way to delete SEO Redirects
+ */
+ function delete() {
+ while (!empty($this->args)) {
+ $seo_redirect_id = array_shift($this->args);
+ if (empty($seo_redirect_id)) {
+ return $this->errorAndExit("Missing or empty SEO Redirect ID -- can not delete it: $seo_redirect_id");
+ }
+ if ($this->SeoRedirect->delete($seo_redirect_id)) {
+ $this->out("deleted SEO redirect id: $seo_redirect_id");
+ } else {
+ $this->errorAndExit("Unable to delete SEO redirect id: $seo_redirect_id");
+ }
+ }
+ }
+ /**
+ * A simple way to delete SEO URIs
+ */
+ function delete_uri() {
+ while (!empty($this->args)) {
+ $id = array_shift($this->args);
+ if (empty($id)) {
+ return $this->errorAndExit("Missing or empty SEO URI ID -- can not delete it: $id");
+ }
+ if ($this->SeoUri->delete($id)) {
+ $this->out("deleted SEO URI id: $id");
+ } else {
+ $this->errorAndExit("Unable to delete SEO URI id: $id");
+ }
+ }
+ }
+ /**
* Private method to output the error and exit(1)
* @param string message to output
* @return void
@@ -142,4 +179,4 @@ protected function errorAndExit($message) {
$this->out("Error: $message");
exit(1);
}
-}
+}

No commit comments for this range

Something went wrong with that request. Please try again.