From 4f5f2d39faa40a00a1979022b99c354796ba29b7 Mon Sep 17 00:00:00 2001 From: Michael Hamann Date: Tue, 29 Oct 2013 20:13:19 +0100 Subject: [PATCH] Added selection which content (pages, media files or both) should be moved --- admin.php | 4 +++- helper.php | 6 ++++-- lang/en/lang.php | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/admin.php b/admin.php index c065b7d..582570d 100644 --- a/admin.php +++ b/admin.php @@ -147,6 +147,7 @@ function printForm() { $form->startFieldset($this->getLang('pm_movens')); $form->addElement(form_makeMenuField('targetns', $ns_select_data, $this->opts['targetns'], $this->getLang('pm_targetns'), '', 'block')); $form->addElement(form_makeTextField('newnsname', $this->opts['newnsname'], $this->getLang('pm_newnsname'), '', 'block')); + $form->addElement(form_makeMenuField('contenttomove', array('pages' => $this->getLang('pm_move_pages'), 'media' => $this->getLang('pm_move_media'), 'both' => $this->getLang('pm_move_media_and_pages')), $this->opts['contenttomove'], $this->getLang('pm_content_to_move'), '', 'block')); $form->addElement(form_makeButton('submit', 'admin', $this->getLang('pm_submit'))); $form->endFieldset(); $form->printForm(); @@ -200,6 +201,7 @@ function handle() { $this->opts['targetns'] = getNS($ID); $this->opts['newnsname'] = ''; $this->opts['move_type'] = 'page'; + $this->opts['contenttomove'] = 'pages'; $this->helper = $this->loadHelper('pagemove', true); if (!$this->helper) return; @@ -237,10 +239,10 @@ function handle() { if (isset($_POST['targetns'])) $this->opts['targetns'] = cleanID((string)$_POST['targetns']); if (isset($_POST['newnsname'])) $this->opts['newnsname'] = cleanID((string)$_POST['newnsname']); if (isset($_POST['move_type'])) $this->opts['move_type'] = (string)$_POST['move_type']; + if (isset($_POST['contenttomove']) && in_array($_POST['contenttomove'], array('pages', 'media', 'both'), true)) $this->opts['contenttomove'] = $_POST['contenttomove']; // check the input for completeness if( $this->opts['move_type'] == 'namespace' ) { - $this->opts['media'] = true; // FIXME: add checkbox later! if ($this->opts['targetns'] == '') { $this->opts['newns'] = $this->opts['newnsname']; diff --git a/helper.php b/helper.php index 65f71a2..083fe98 100644 --- a/helper.php +++ b/helper.php @@ -57,7 +57,9 @@ public function start_namespace_move(&$opts) { $pagelist = array(); $pathToSearch = utf8_encodeFN(str_replace(':', '/', $opts['ns'])); $searchOpts = array('depth' => 0, 'skipacl' => true); - search($pagelist, $conf['datadir'], 'search_allpages', $searchOpts, $pathToSearch); + if (in_array($opts['contenttomove'], array('pages', 'both'))) { + search($pagelist, $conf['datadir'], 'search_allpages', $searchOpts, $pathToSearch); + } $pages = array(); foreach ($pagelist as $page) { $pages[] = $page['id']; @@ -72,7 +74,7 @@ public function start_namespace_move(&$opts) { // generate and save a list of all media files $medialist = array(); - if (isset($opts['media']) && $opts['media']) { + if (in_array($opts['contenttomove'], array('media,', 'both'))) { search($medialist, $conf['mediadir'], 'search_media', $searchOpts, $pathToSearch); } diff --git a/lang/en/lang.php b/lang/en/lang.php index 9e359cf..10280f9 100644 --- a/lang/en/lang.php +++ b/lang/en/lang.php @@ -53,6 +53,10 @@ $lang['pm_movepage'] = 'Move page'; $lang['pm_movens'] = 'Move namespace'; $lang['pm_submit'] = 'Submit'; +$lang['pm_content_to_move'] = 'Content to move'; +$lang['pm_move_pages'] = 'Pages'; +$lang['pm_move_media'] = 'Media files'; +$lang['pm_move_media_and_pages'] = 'Pages and media files'; // JavaScript preview $lang['js']['pm_previewpage'] = 'OLDPAGE will be moved to NEWPAGE'; $lang['js']['pm_previewns'] = 'All pages and namespaces in the namespace OLDNS will be moved in the namespace NEWNS';