Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: page move function #58

Open
Andrwe opened this issue Feb 28, 2011 · 3 comments
Open

feature: page move function #58

Andrwe opened this issue Feb 28, 2011 · 3 comments

Comments

@Andrwe
Copy link

Andrwe commented Feb 28, 2011

Hi,

I really like blogtng.
There is just one thing I'm missing.
It would be nice if blogtng would provide a function for other plugins which allows moving of pages.
So e.g. dw-editx could also move pages stored in blogtng database without losing the comments and tags of it.

@Andrwe
Copy link
Author

Andrwe commented Apr 6, 2011

Because there is no responds until now I'd like to know whether this request is accepted or not.

This function is one of the few reasons I can't use blogtng for the wiki of my company.

@Klap-in
Copy link
Member

Klap-in commented Sep 17, 2013

On short term i don't expect improvements on this area.
There have been some developments with respect to the page move pluign https://github.com/michitux/DokuWiki-Pagemove-Plugin/ by @michitux
When these developments (somewhere in future) are released it can be nice to come back to this issue and see what is possible to perform updates of BlogTNG metadata with triggers from moves with this plugin.

@michitux
Copy link
Member

I had a look at this when I implemented the pagemove plugin. The new pagemove plugin provides an event that other plugins can use in order to move their data. I wrote some code for a new action component in action/pagemove.php which doesn't work as such but should provide a general idea of how that could/should work. The main problem is that the md5sum of the page id is used as primary id which means that also all comments for that page need to be updated.

<?php
/**
 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
 * @author     Michael Hamann <[email protected]>
 */

// must be run within Dokuwiki
if (!defined('DOKU_INC')) die();

class action_plugin_blogtng_pagemove extends DokuWiki_Action_Plugin{
    private $entry = null;
    private $tags = array();

    function register(&$controller) {
        $controller->register_hook('PAGEMOVE_PAGE_RENAME', 'BEFORE', $this, 'get_data', array());
        $controller->register_hook('PAGEMOVE_PAGE_RENAME', 'AFTER', $this, 'update_data', array());
    }

    function get_data($event, $params) {
        global $ID;
        $old_pid = md5($ID);

        /** @var helper_plugin_blogtng_entry $entryhelper */
        $entryhelper =& plugin_load('helper', 'blogtng_entry');

        if ($entryhelper->load_by_pid($old_pid) === helper_plugin_blogtng_entry::RET_OK) {
            $this->entry = $entryhelper->entry;
            $taghelper = $entryhelper->getTagHelper();
            $this->tags = $taghelper->tags;
            $entryhelper->delete();
        }
    }

    function update_data(&$event, $params) {
        if (!is_null($this->entry)) {
            $new_id = $event->data['opts']['new_id'];

            $new_pid = md5($new_id);

            /** @var helper_plugin_blogtng_entry $entryhelper */
            $entryhelper =& plugin_load('helper', 'blogtng_entry');

            $entryhelper->load_by_pid($new_pid);
            $entryhelper->entry['page'] = $new_id;
            $entryhelper->set($this->entry);
            $entryhelper->save();

            $taghelper = $entryhelper->getTagHelper();
            $taghelper->set($this->tags);
            $taghelper->save();
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants