public function execute() { $groupsString = $this->getOption('limit-to-groups'); if ($groupsString) { $limitToGroups = explode(',', $groupsString); foreach ($limitToGroups as $i => $g) { $limitToGroups[$i] = trim($g); } } else { $limitToGroups = false; } $pageImporter = new PageImporter(); // export pages if ($this->getOption('export')) { $pageImporter->exportPagesToFiles($this, $limitToGroups); $this->output("\n## Finished exporting pages.\n"); } else { $pageImporter->import($this, $limitToGroups); $this->output("\n## Finished importing pages.\n"); } }
<?php /** * Pages standardly used by the FOD Wikis * * Documentation: https://github.com/enterprisemediawiki/FODStandardPages * Support: https://github.com/enterprisemediawiki/FODStandardPages * Source code: https://github.com/enterprisemediawiki/FODStandardPages * * @file FODStandardPages.php * @addtogroup Extensions * @author James Montalvo * @copyright © 2014 by James Montalvo * @licence GNU GPL v3+ */ # Not a valid entry point, skip unless MEDIAWIKI is defined if (!defined('MEDIAWIKI')) { die('FODStandardPages extension'); } define('FOD_STANDARD_SETTINGS_VERSION', '0.1.0'); $GLOBALS['wgExtensionCredits']['other'][] = array('path' => __FILE__, 'name' => 'FOD Standard Pages', 'url' => 'http://github.com/enterprisemediawiki/FODStandardPages', 'author' => 'James Montalvo', 'descriptionmsg' => 'fodstandardpages-desc', 'version' => FOD_STANDARD_SETTINGS_VERSION); $GLOBALS['wgMessagesDirs']['FODStandardPages'] = __DIR__ . '/i18n'; PageImporter::registerPageList("FODStandardPages", __DIR__ . "/pages.php", __DIR__ . "/pages", "Updated with content from Extension:FODStandardPages version " . FOD_STANDARD_SETTINGS_VERSION);
function handlePost($params) { session_write_close(); header('Connection: close'); $app = Dataface_Application::getInstance(); try { require_once 'inc/PageImporter.php'; require_once 'inc/SweteSite.class.php'; if (!@$_POST['website_id']) { throw new Exception("No Site Specified"); } $site = SweteSite::loadSiteById($_POST['website_id']); if (!$site) { throw new Exception("No site found by that ID."); } $importer = new PageImporter(); $importer->site = $site; $importer->translate = true; $importer->logTranslationMisses = true; if (@$_POST['--depth'] and intval($_POST['--depth'])) { $importer->depth = intval($_POST['--depth']); } if (@$_POST['--startingPoint']) { $importer->startingPoint = trim($_POST['--startingPoint']); } $importer->loadContent = true; $importer->doImport(); $addedIds = array(); $updatedIds = array(); foreach ($importer->pagesAdded as $p) { $addedIds[] = $p->val('webpage_id'); } foreach ($importer->pagesUpdated as $p) { $updatedIds[] = $p->val("webpage_id"); } $out = array('code' => 200, 'message' => 'Successfully imported ' . count($importer->pagesAdded) . ' pages updated ' . count($importer->pagesUpdated) . ' pages.', 'pagesUpdated' => count($importer->pagesUpdated), 'pagesAdded' => count($importer->pagesAdded), 'addedIds' => $addedIds, 'updatedIds' => $updatedIds); } catch (Exception $ex) { $out = array('code' => $ex->getCode(), 'message' => $ex->getMessage()); } header('Content-type: text/json; charset="' . $app->_conf['oe'] . '"'); echo json_encode($out); return; }