Wiki source for MovePages


Show raw source

==== Move Handler====
>>See also:
~-RefactorWiki
~-PageAdminAction
>>
The [[Docs:HandlerInfo | 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.

%%(php)<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>%%
----
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 [[PageAdminAction | PageAdmin]].
%%(php)
<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>
%%

----
CategoryDevelopmentHandlers
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki