Move Handler
The handler move.php assumes that wikka is able to deal with RedirectingPages, and doesn't adjust links pointing to the old page. It can be considered a rename handler.
<div class="page">
<?php
if ($this->page) {
if ($this->UserIsOwner() || $this->IsAdmin()) {
if ($newtag = $_POST["newtag"]) {
if ($this->LoadPage($newtag)) $error = "Tag <b>".$newtag."</b> already exists";
if (!$error) {
$this->Query("update ".$this->config["table_prefix"]."links set from_tag = '".$newtag."' where from_tag = '".$this->tag."'");
$this->Query("update ".$this->config["table_prefix"]."pages set comment_on = '".$newtag."' where comment_on = '".$this->tag."'");
$this->Query("update ".$this->config["table_prefix"]."pages set tag = '".$newtag."' where tag = '".$this->tag."'");
if ($_POST["forwarder"]) $this->SavePage($this->tag, "=>[[".$newtag."]]", $this->page["comment_on"], "moved to ".$newtag, $this->page["private"]);
$this->SetMessage("Page has been moved!");
if ($_POST["forwarder"]) $this->Redirect($this->href());
else $this->Redirect($this->href("", $newtag));
}
}
if ($error) print "<div class='error'>".$error."</div>";
print $this->FormOpen("move");
print "Move page to <input name='newtag' value='".$newtag."' size='40' maxlength='50'> - Keep old page as forwarder <input type='checkbox' name='forwarder' value='1' checked><input type='submit' value='move'>";
print $this->FormClose();
} else print "<em>You're not the owner of this page.</em>";
} else print "Page ".$this->tag." doesn't exist.";
?>
</div>
<?php
if ($this->page) {
if ($this->UserIsOwner() || $this->IsAdmin()) {
if ($newtag = $_POST["newtag"]) {
if ($this->LoadPage($newtag)) $error = "Tag <b>".$newtag."</b> already exists";
if (!$error) {
$this->Query("update ".$this->config["table_prefix"]."links set from_tag = '".$newtag."' where from_tag = '".$this->tag."'");
$this->Query("update ".$this->config["table_prefix"]."pages set comment_on = '".$newtag."' where comment_on = '".$this->tag."'");
$this->Query("update ".$this->config["table_prefix"]."pages set tag = '".$newtag."' where tag = '".$this->tag."'");
if ($_POST["forwarder"]) $this->SavePage($this->tag, "=>[[".$newtag."]]", $this->page["comment_on"], "moved to ".$newtag, $this->page["private"]);
$this->SetMessage("Page has been moved!");
if ($_POST["forwarder"]) $this->Redirect($this->href());
else $this->Redirect($this->href("", $newtag));
}
}
if ($error) print "<div class='error'>".$error."</div>";
print $this->FormOpen("move");
print "Move page to <input name='newtag' value='".$newtag."' size='40' maxlength='50'> - Keep old page as forwarder <input type='checkbox' name='forwarder' value='1' checked><input type='submit' value='move'>";
print $this->FormClose();
} else print "<em>You're not the owner of this page.</em>";
} else print "Page ".$this->tag." doesn't exist.";
?>
</div>
The above code didn't work for me as it uses comment_on (not sure where that comes from...). The following code works in v1.1.5.3. I now have this integrated this with PageAdmin.
<div class="page">
<?php
if ($this->page) {
if ($this->UserIsOwner() || $this->IsAdmin()) {
if ($newtag = $_POST["newtag"]) {
if ($this->LoadPage($newtag)) $error = "Tag <b>".$newtag."</b> already exists";
if (!$error) {
$this->Query("update ".$this->config["table_prefix"]."links set from_tag = '".$newtag."' where from_tag = '".$this->tag."'");
//$this->Query("update ".$this->config["table_prefix"]."pages set comment_on = '".$newtag."' where comment_on = '".$this->tag."'");
$this->Query("update ".$this->config["table_prefix"]."comments set page_tag = '".$newtag."' where page_tag = '".$this->tag."'");
$this->Query("update ".$this->config["table_prefix"]."pages set tag = '".$newtag."' where tag = '".$this->tag."'");
if ($_POST["forwarder"]) $this->SavePage($this->tag, "=>[[".$newtag."]]", $this->page["comment_on"], "moved to ".$newtag, $this->page["private"]);
$this->SetMessage("Page has been moved!");
if ($_POST["forwarder"]) $this->Redirect($this->href());
else $this->Redirect($this->href("", $newtag));
}
}
if ($error) print "<div class='error'>".$error."</div>";
print $this->FormOpen("move");
print "Move page to <input name='newtag' value='".$newtag."' size='40' maxlength='50'> - Keep old page as forwarder <input type='checkbox' name='forwarder' value='1' checked><input type='submit' value='move'>";
print $this->FormClose();
} else print "<em>You're not the owner of this page.</em>";
} else print "Page ".$this->tag." doesn't exist.";
?>
</div>
<?php
if ($this->page) {
if ($this->UserIsOwner() || $this->IsAdmin()) {
if ($newtag = $_POST["newtag"]) {
if ($this->LoadPage($newtag)) $error = "Tag <b>".$newtag."</b> already exists";
if (!$error) {
$this->Query("update ".$this->config["table_prefix"]."links set from_tag = '".$newtag."' where from_tag = '".$this->tag."'");
//$this->Query("update ".$this->config["table_prefix"]."pages set comment_on = '".$newtag."' where comment_on = '".$this->tag."'");
$this->Query("update ".$this->config["table_prefix"]."comments set page_tag = '".$newtag."' where page_tag = '".$this->tag."'");
$this->Query("update ".$this->config["table_prefix"]."pages set tag = '".$newtag."' where tag = '".$this->tag."'");
if ($_POST["forwarder"]) $this->SavePage($this->tag, "=>[[".$newtag."]]", $this->page["comment_on"], "moved to ".$newtag, $this->page["private"]);
$this->SetMessage("Page has been moved!");
if ($_POST["forwarder"]) $this->Redirect($this->href());
else $this->Redirect($this->href("", $newtag));
}
}
if ($error) print "<div class='error'>".$error."</div>";
print $this->FormOpen("move");
print "Move page to <input name='newtag' value='".$newtag."' size='40' maxlength='50'> - Keep old page as forwarder <input type='checkbox' name='forwarder' value='1' checked><input type='submit' value='move'>";
print $this->FormClose();
} else print "<em>You're not the owner of this page.</em>";
} else print "Page ".$this->tag." doesn't exist.";
?>
</div>
CategoryDevelopmentHandlers
"Fatal error: Call to undefined method Wakka::SetMessage() in /home/brendon/public_html/wikka/handlers/page/move.php on line 16"
Seems SetMessage() has been removed in version 1.1.6.0; its functionality is now integrated with the Redirect() method, so you need only a single call.
(Note to self: that's not what the WikkaReleaseNotes state - will have to investigate that...)
Agreed, ACLs - *if* they exist for the page - will have to be "moved" as well. Note that a page will only have a corresponding ACLs record if the ACLs are set to something different than the site default (as defined in the configuration file).
Now when users land there it asks if they want to create the page in wikka. I can't have them landing on that page and .htaccess redirects don't seem to help. If someone could help me I'd greatly appreciate it. devnet at gmail dot com.
RewriteRule ^index.php.*$ HomePage/
Place it immediately prior to the rewrite rule for "wikka.php?wakka="
You may want to consider transparent redirections giving a permanently
moved (301) reponse using Apache's mod_alias:
RedirectPermanent /foo http://foobar.com/foo
If you prefer RewriteRules you can create permanent redirections via a
[R=permanent,L] flag
301 redirections are considered as the best solution in terms from a
SEO point of view