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>


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>



CategoryDevelopmentHandlers
Comments [Hide comments]
Comment by NilsLindenberg
2005-02-16 11:56:28
I deleted a spam comment from -- 221.15.143.44 (2005-02-16 07:46:14)
Comment by JeroenJansen
2005-02-18 15:17:58
When moving a page, you don't move the ACLs of the page, in this code. I guess this is necessary for a complete move.
Comment by adsl-68-126-198-197.dsl.pltn13.pacbell.net
2005-02-20 07:47:14
I just tried this on 1.1.6.0. no luck. Error:
"Fatal error: Call to undefined method Wakka::SetMessage() in /home/brendon/public_html/wikka/handlers/page/move.php on line 16"
Comment by JavaWoman
2005-02-20 10:26:18
@adsl-68-126-198-197.dsl.pltn13.pacbell.net
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...)
Comment by JavaWoman
2005-02-20 10:28:57
@JeroenJansen,
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).
Comment by DevNet
2008-02-04 02:03:03
Hey guys...I really need help with moving a page or redirecting a page. See, I've switched from mediawiki and of course that means that the front page is index.php?=Main_Page.

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.
Comment by BrianKoontz
2008-02-04 14:53:02
DevNet, something like this should work (seems to work fine on my system):

RewriteRule ^index.php.*$ HomePage/

Place it immediately prior to the rewrite rule for "wikka.php?wakka="
Comment by BrianKoontz
2008-02-04 17:25:24
From DarTar re previous comment:

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
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki