/** * Parse the input field into an array of URLs and Title objects */ private static function parseURLlist($pageList) { $pageList = preg_split('@[\\r\\n]+@', $pageList); $urls = array(); foreach ($pageList as $url) { $url = trim($url); if (!empty($url)) { $title = WikiPhoto::getArticleTitleNoCheck(urldecode($url)); $urls[] = array('url' => $url, 'title' => $title); } } return $urls; }
function execute($par) { global $wgOut, $wgUser, $wgRequest; global $wgUseAjax, $wgAjaxUploadDestCheck, $wgAjaxLicensePreview; if ($wgUser->isBlocked()) { $wgOut->blockedPage(); return; } if ($wgUser->getID() == 0) { $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext'); return; } if (!in_array('staff', $wgUser->getGroups())) { $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->showErrorPage('nosuchspecialpage', 'nospecialpagetext'); return; } $this->errorFile = ""; $this->errorTitle = ""; if ($wgRequest->getVal('delete')) { $wgOut->setArticleBodyOnly(true); $hpid = str_replace('delete_', '', $wgRequest->getVal('delete')); $html = self::deleteHPImage($hpid); $wgOut->addHTML($html); return; } $this->postSuccessful = true; if ($wgRequest->wasPosted()) { if ($wgRequest->getVal("updateActive")) { $dbw = wfGetDB(DB_MASTER); //first clear them all $dbw->update(WikihowHomepageAdmin::HP_TABLE, array('hp_active' => 0, 'hp_order' => 0), '*', __METHOD__); $images = $wgRequest->getArray("hp_images"); $count = 1; foreach ($images as $image) { if (!$image) { continue; } $dbw->update(WikihowHomepageAdmin::HP_TABLE, array('hp_active' => 1, 'hp_order' => $count), array('hp_id' => $image)); $count++; } } else { $title = WikiPhoto::getArticleTitleNoCheck($wgRequest->getVal('articleName')); if (!$title->exists()) { $this->postSuccessful = false; $this->errorTitle = "* That article does not exist."; } if ($this->postSuccessful) { //keep going $imageTitle = Title::newFromText($wgRequest->getVal('wpDestFile'), NS_IMAGE); $file = new LocalFile($imageTitle, RepoGroup::singleton()->getLocalRepo()); $file->upload($wgRequest->getFileTempName('wpUploadFile'), '', ''); $filesize = $file->getSize(); if ($filesize > 0) { $dbw = wfGetDB(DB_MASTER); $dbw->insert(WikihowHomepageAdmin::HP_TABLE, array('hp_page' => $title->getArticleID(), 'hp_image' => $imageTitle->getArticleID())); $article = new Article($imageTitle); $limit = array(); $limit['move'] = "sysop"; $limit['edit'] = "sysop"; $protectResult = $article->updateRestrictions($limit, "Used on homepage"); } else { $this->postSuccessful = false; $this->errorFile = "* We encountered an error uploading that file."; } } } } $useAjaxDestCheck = $wgUseAjax && $wgAjaxUploadDestCheck; $useAjaxLicensePreview = $wgUseAjax && $wgAjaxLicensePreview; $adc = wfBoolToStr($useAjaxDestCheck); $alp = wfBoolToStr($useAjaxLicensePreview); $wgOut->setPageTitle('WikiHow Homepage Admin'); $wgOut->addScript("<script type=\"text/javascript\">\nwgAjaxUploadDestCheck = {$adc};\nwgAjaxLicensePreview = {$alp};\n</script>"); $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('jquery-ui-1.8.custom.min.js'), 'extensions/wikihow/common/ui/js', false)); $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('wikihowhomepageadmin.js'), 'extensions/wikihow/homepage', false)); $wgOut->addScript(HtmlSnips::makeUrlTags('css', array('wikihowhomepageadmin.css'), 'extensions/wikihow/homepage', false)); $wgOut->addScript(HtmlSnips::makeUrlTags('js', array('upload.js'), 'skins/common', false)); $this->displayHomepageData(); $this->displayForm(); }