Skip to content

Commit

Permalink
Added selection which content (pages, media files or both) should be …
Browse files Browse the repository at this point in the history
…moved
  • Loading branch information
michitux committed Oct 29, 2013
1 parent 229822d commit 4f5f2d3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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'];
Expand Down
6 changes: 4 additions & 2 deletions helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand All @@ -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);
}

Expand Down
4 changes: 4 additions & 0 deletions lang/en/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit 4f5f2d3

Please sign in to comment.