当前位置: 首页>>代码示例>>PHP>>正文


PHP Article::updateRestrictions方法代码示例

本文整理汇总了PHP中Article::updateRestrictions方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::updateRestrictions方法的具体用法?PHP Article::updateRestrictions怎么用?PHP Article::updateRestrictions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Article的用法示例。


在下文中一共展示了Article::updateRestrictions方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 public function execute()
 {
     global $wgUser, $wgTitle, $wgArticle;
     $userName = $this->getOption('u', 'Maintenance script');
     $reason = $this->getOption('r', '');
     $protection = "sysop";
     if ($this->hasOption('semiprotect')) {
         $protection = "autoconfirmed";
     } elseif ($this->hasOption('unprotect')) {
         $protection = "";
     }
     $wgUser = User::newFromName($userName);
     $restrictions = array('edit' => $protection, 'move' => $protection);
     $wgTitle = Title::newFromText($this->getArg());
     if (!$wgTitle) {
         $this->error("Invalid title", true);
     }
     $wgArticle = new Article($wgTitle);
     # un/protect the article
     $this->output("Updating protection status... ");
     $success = $wgArticle->updateRestrictions($restrictions, $reason);
     if ($success) {
         $this->output("done\n");
     } else {
         $this->output("failed\n");
     }
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:27,代码来源:protect.php

示例2: toggle

 public static function toggle($pagename)
 {
     global $wgUser;
     $title = Title::newFromDBkey($pagename);
     if (!$title) {
         return self::returnMsg(self::TITLE_INVALID, $protectState);
     }
     $aid = $title->getArticleID();
     // title must exist!
     if ($aid == 0) {
         return self::returnMsg(self::TITLE_INVALID, $protectState);
     }
     // user must have the required clearance
     if (!$wgUser->isAllowed('protect')) {
         return self::returnMsg(self::USER_INSUFFICIENT_RIGHT, $protectState);
     }
     $protectState = $title->isProtected('edit');
     // format the restriction
     //  whilst inverting the state...
     $group = $protectState ? '' : 'sysop';
     $restriction = array('edit' => $group);
     // update!
     $article = new Article($title);
     $code = $article->updateRestrictions($restriction);
     $msg = $code ? self::SUCCESS : self::FAILURE;
     // update protection status
     $protectState = $code ? !$protectState : $protectState;
     return self::returnMsg($msg, $protectState);
 }
开发者ID:clrh,项目名称:mediawiki,代码行数:29,代码来源:QuickEditProtect.php

示例3: execute

 public function execute()
 {
     global $wgUser, $wgRestrictionTypes, $wgRestrictionLevels;
     $params = $this->extractRequestParams();
     $titleObj = NULL;
     if (!isset($params['title'])) {
         $this->dieUsageMsg(array('missingparam', 'title'));
     }
     if (!isset($params['token'])) {
         $this->dieUsageMsg(array('missingparam', 'token'));
     }
     if (empty($params['protections'])) {
         $this->dieUsageMsg(array('missingparam', 'protections'));
     }
     if (!$wgUser->matchEditToken($params['token'])) {
         $this->dieUsageMsg(array('sessionfailure'));
     }
     $titleObj = Title::newFromText($params['title']);
     if (!$titleObj) {
         $this->dieUsageMsg(array('invalidtitle', $params['title']));
     }
     $errors = $titleObj->getUserPermissionsErrors('protect', $wgUser);
     if ($errors) {
         // We don't care about multiple errors, just report one of them
         $this->dieUsageMsg(reset($errors));
     }
     $expiry = (array) $params['expiry'];
     if (count($expiry) != count($params['protections'])) {
         if (count($expiry) == 1) {
             $expiry = array_fill(0, count($params['protections']), $expiry[0]);
         } else {
             $this->dieUsageMsg(array('toofewexpiries', count($expiry), count($params['protections'])));
         }
     }
     $protections = array();
     $expiryarray = array();
     $resultProtections = array();
     foreach ($params['protections'] as $i => $prot) {
         $p = explode('=', $prot);
         $protections[$p[0]] = $p[1] == 'all' ? '' : $p[1];
         if ($titleObj->exists() && $p[0] == 'create') {
             $this->dieUsageMsg(array('create-titleexists'));
         }
         if (!$titleObj->exists() && $p[0] != 'create') {
             $this->dieUsageMsg(array('missingtitles-createonly'));
         }
         if (!in_array($p[0], $wgRestrictionTypes) && $p[0] != 'create') {
             $this->dieUsageMsg(array('protect-invalidaction', $p[0]));
         }
         if (!in_array($p[1], $wgRestrictionLevels) && $p[1] != 'all') {
             $this->dieUsageMsg(array('protect-invalidlevel', $p[1]));
         }
         if (in_array($expiry[$i], array('infinite', 'indefinite', 'never'))) {
             $expiryarray[$p[0]] = Block::infinity();
         } else {
             $exp = strtotime($expiry[$i]);
             if ($exp < 0 || $exp == false) {
                 $this->dieUsageMsg(array('invalidexpiry', $expiry[$i]));
             }
             $exp = wfTimestamp(TS_MW, $exp);
             if ($exp < wfTimestampNow()) {
                 $this->dieUsageMsg(array('pastexpiry', $expiry[$i]));
             }
             $expiryarray[$p[0]] = $exp;
         }
         $resultProtections[] = array($p[0] => $protections[$p[0]], 'expiry' => $expiryarray[$p[0]] == Block::infinity() ? 'infinite' : wfTimestamp(TS_ISO_8601, $expiryarray[$p[0]]));
     }
     $cascade = $params['cascade'];
     $articleObj = new Article($titleObj);
     if ($params['watch']) {
         $articleObj->doWatch();
     }
     if ($titleObj->exists()) {
         $ok = $articleObj->updateRestrictions($protections, $params['reason'], $cascade, $expiryarray);
     } else {
         $ok = $titleObj->updateTitleProtection($protections['create'], $params['reason'], $expiryarray['create']);
     }
     if (!$ok) {
         // This is very weird. Maybe the article was deleted or the user was blocked/desysopped in the meantime?
         // Just throw an unknown error in this case, as it's very likely to be a race condition
         $this->dieUsageMsg(array());
     }
     $res = array('title' => $titleObj->getPrefixedText(), 'reason' => $params['reason']);
     if ($cascade) {
         $res['cascade'] = '';
     }
     $res['protections'] = $resultProtections;
     $this->getResult()->setIndexedTagName($res['protections'], 'protection');
     $this->getResult()->addValue(null, $this->getModuleName(), $res);
 }
开发者ID:ui-libraries,项目名称:TIRW,代码行数:90,代码来源:ApiProtect.php

示例4: execute

 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();
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:82,代码来源:WikihowHomepageAdmin.body.php

示例5: execute

 public function execute()
 {
     global $wgUser;
     $this->getMain()->requestWriteMode();
     $params = $this->extractRequestParams();
     $titleObj = NULL;
     if (!isset($params['title'])) {
         $this->dieUsageMsg(array('missingparam', 'title'));
     }
     if (!isset($params['token'])) {
         $this->dieUsageMsg(array('missingparam', 'token'));
     }
     if (!isset($params['protections']) || empty($params['protections'])) {
         $this->dieUsageMsg(array('missingparam', 'protections'));
     }
     if (!$wgUser->matchEditToken($params['token'])) {
         $this->dieUsageMsg(array('sessionfailure'));
     }
     $titleObj = Title::newFromText($params['title']);
     if (!$titleObj) {
         $this->dieUsageMsg(array('invalidtitle', $params['title']));
     }
     $errors = $titleObj->getUserPermissionsErrors('protect', $wgUser);
     if (!empty($errors)) {
         // We don't care about multiple errors, just report one of them
         $this->dieUsageMsg(current($errors));
     }
     if (in_array($params['expiry'], array('infinite', 'indefinite', 'never'))) {
         $expiry = Block::infinity();
     } else {
         $expiry = strtotime($params['expiry']);
         if ($expiry < 0 || $expiry == false) {
             $this->dieUsageMsg(array('invalidexpiry'));
         }
         $expiry = wfTimestamp(TS_MW, $expiry);
         if ($expiry < wfTimestampNow()) {
             $this->dieUsageMsg(array('pastexpiry'));
         }
     }
     $protections = array();
     foreach ($params['protections'] as $prot) {
         $p = explode('=', $prot);
         $protections[$p[0]] = $p[1] == 'all' ? '' : $p[1];
         if ($titleObj->exists() && $p[0] == 'create') {
             $this->dieUsageMsg(array('create-titleexists'));
         }
         if (!$titleObj->exists() && $p[0] != 'create') {
             $this->dieUsageMsg(array('missingtitles-createonly'));
         }
     }
     $dbw = wfGetDb(DB_MASTER);
     $dbw->begin();
     if ($titleObj->exists()) {
         $articleObj = new Article($titleObj);
         $ok = $articleObj->updateRestrictions($protections, $params['reason'], $params['cascade'], $expiry);
     } else {
         $ok = $titleObj->updateTitleProtection($protections['create'], $params['reason'], $expiry);
     }
     if (!$ok) {
         // This is very weird. Maybe the article was deleted or the user was blocked/desysopped in the meantime?
         // Just throw an unknown error in this case, as it's very likely to be a race condition
         $this->dieUsageMsg(array());
     }
     $dbw->commit();
     $res = array('title' => $titleObj->getPrefixedText(), 'reason' => $params['reason']);
     if ($expiry == Block::infinity()) {
         $res['expiry'] = 'infinity';
     } else {
         $res['expiry'] = wfTimestamp(TS_ISO_8601, $expiry);
     }
     if ($params['cascade']) {
         $res['cascade'] = '';
     }
     $res['protections'] = $protections;
     $this->getResult()->addValue(null, $this->getModuleName(), $res);
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:76,代码来源:ApiProtect.php

示例6: array

}
if (empty($wgWikiaKeyPages)) {
    $wgWikiaKeyPages = array('Image:Wiki.png', 'Image:Favicon.ico');
}
#--- define restriction level and duration
$restrictions['edit'] = 'sysop';
$restrictions['move'] = 'sysop';
$titleRestrictions = 'sysop';
$expiry = Block::infinity();
#--- define reason msg and fetch it
$wgMessageCache->addMessages(array('createwiki-protect-reason' => 'Part of the official interface'));
$reason = wfMsgForContent('createwiki-protect-reason');
$wgUser->addGroup('staff');
$wgUser->addGroup('bot');
foreach ($wgWikiaKeyPages as $pageName) {
    $title = Title::newFromText($pageName);
    $article = new Article($title);
    if ($article->exists()) {
        $ok = $article->updateRestrictions($restrictions, $reason, 0, $expiry);
    } else {
        $ok = $title->updateTitleProtection($titleRestrictions, $reason, $expiry);
    }
    if ($ok) {
        print "Protected key page: {$pageName}\n";
    } else {
        print "Failed while trying to protect {$pageName}\n";
    }
}
$wgUser->removeGroup('staff');
$wgUser->removeGroup('bot');
print "Done protecting pages.\n";
开发者ID:yusufchang,项目名称:app,代码行数:31,代码来源:protectKeyPages.php

示例7: protectKeyPages

 /**
  * protect key pages
  *
  * @author Lucas 'TOR' Garczewski <tor@wikia-inc.com>
  */
 private function protectKeyPages()
 {
     global $wgUser, $wgWikiaKeyPages;
     $saveUser = $wgUser;
     $wgUser = \User::newFromName(self::WIKIA_USER);
     if (empty($wgWikiaKeyPages)) {
         $wgWikiaKeyPages = array('File:Wiki.png', 'File:Favicon.ico');
     }
     /**
      * define restriction level and duration
      */
     $restrictions["edit"] = 'sysop';
     $restrictions["move"] = 'sysop';
     $restrictions["create"] = 'sysop';
     $titleRestrictions = 'sysop';
     $expiry_string = \Block::infinity();
     $expiry_array = array('edit' => $expiry_string, 'move' => $expiry_string);
     /**
      *  define reason msg and fetch it
      */
     $reason = wfMsgForContent('autocreatewiki-protect-reason');
     foreach ($wgWikiaKeyPages as $pageName) {
         $title = \Title::newFromText($pageName);
         $article = new \Article($title);
         if ($article->exists()) {
             $cascade = 0;
             $ok = $article->updateRestrictions($restrictions, $reason, $cascade, $expiry_array);
         } else {
             $wikiPage = \WikiPage::factory($title);
             $ignored_reference = false;
             // doing this because MW1.19 doUpdateRestrictions() is weird, and has this passed by reference
             $status = $wikiPage->doUpdateRestrictions(array('create' => $titleRestrictions), array('create' => $expiry_string), $ignored_reference, $reason, $wgUser);
             $ok = $status->isOK();
         }
         if ($ok) {
             $this->info('Protected key page', ['page_name' => $pageName]);
         } else {
             $this->warning('failed to protect key page', ['page_name' => $pageName]);
         }
     }
     $wgUser = $saveUser;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:47,代码来源:CreateNewWikiTask.class.php

示例8: execute

 function execute($par)
 {
     global $wgRequest, $wgOut, $wgTitle;
     $param = $wgRequest->getText('param');
     $parcheck = $wgRequest->getText('parcheck');
     $action = $wgTitle->getFullURL();
     $description = wfMsgExt('checksite-description', array('parse'));
     $label = wfMsgExt('checksite-label', array('parseinline'));
     $submit = wfMsg('checksite-submit');
     $post = "\n\t\t\t<form action=\"{$action}\" method=\"get\">\n\t\t\t{$description}\n\t\t\t{$label}\n\t\t\t<input type=\"text\" name=\"parcheck\" value=\"{$param}\" size=\"40\" maxlength=\"80\" />\n\t\t\t<input type=\"submit\" value=\"{$submit}\" />\n\t\t\t</form>";
     $this->setHeaders();
     if (!isset($parcheck) || strlen($parcheck) < 5) {
         $wgOut->addHTML($post);
         return;
     }
     $newdom = check_validate_domain($parcheck);
     if (!$newdom) {
         $parcheck = htmlspecialchars($parcheck);
         $wgOut->addWikiMsg('checksite-cant-check', $parcheck);
         return;
     }
     $newpage = $newdom;
     $newpage[0] = strtoupper($newpage[0]);
     $title = Title::newFromUrl($newpage);
     if (!is_object($title)) {
         $wgOut->addWikiMsg('checksite-not-found', $newpage);
         return;
     }
     if (!$title->exists()) {
         $wgOut->addWikiMsg('checksite-not-exist', $newpage);
         return;
     }
     $newhost = check_get_host($newdom);
     if (!$newhost) {
         $wgOut->addWikiMsg('checksite-url-not-found', $newdom);
         return;
     }
     if ($rob = @fopen("http://{$newhost}/robots.txt", 'r')) {
         $txt = fread($rob, 4096);
         while (!feof($rob)) {
             $txt .= fread($rob, 4096);
             if (strlen($txt) > 20000) {
                 break;
             }
         }
         fclose($rob);
         if (eregi("User-agent:[ \t\n]*WebsiteWiki[ \t\r\n]*Disallow:[ \t\r\n]*/", $txt)) {
             global $wgUser;
             $output = wfMsg('checksite-robots', $newhost, $newpage);
             $orgUser = $wgUser;
             //TODO: should this hardcoded user be here?
             $wgUser = User::newFromName('Sysop');
             $article = new Article($title);
             $restrict = array('edit' => 'sysop', 'move' => 'sysop');
             $article->updateRestrictions($restrict, $output);
             $redirectUrl = wfMsg('checksite-redirect-url');
             $redirectComment = wfMsg('checksite-redirect-comment');
             $article->updateArticle("#REDIRECT [[{$redirectUrl}]]", $redirectComment, false, false);
             $wgUser = $orgUser;
             return;
         }
     }
     //TODO: check if this hardcoded URL should remain here
     if (stristr($newhost, 'duckshop.de')) {
         $wgOut->addWikiMsg('checksite-screenshot-error');
         return;
     }
     $output = wfMsg('checksite-screenshot-updating', $newpage);
     /**
      * @todo -- lines below do nothing, so why they are there?
      * 
      * $url = fopen("http://thumbs.websitewiki.de/newthumb.php?name=$newdom", 'r');
      * fclose($url);
      */
     # Output
     $wgOut->addHTML($output);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:77,代码来源:Checksite.body.php

示例9: Article

     ${$svar}++;
     if (isset($options['dry'])) {
         echo "done.\n";
     } else {
         if ($image->recordUpload($archive->value, $commentText, $license)) {
             # We're done!
             echo "done.\n";
             if ($doProtect) {
                 # Protect the file
                 $article = new Article($title);
                 echo "\nWaiting for slaves...\n";
                 // Wait for slaves.
                 sleep(2.0);
                 wfWaitForSlaves(1.0);
                 echo "\nSetting image restrictions ... ";
                 if ($article->updateRestrictions($restrictions)) {
                     echo "done.\n";
                 } else {
                     echo "failed.\n";
                 }
             }
         } else {
             echo "failed.\n";
         }
     }
 }
 # Print out some statistics
 echo "\n";
 foreach (array('count' => 'Found', 'added' => 'Added', 'skipped' => 'Skipped', 'overwritten' => 'Overwritten') as $var => $desc) {
     if (${$var} > 0) {
         echo "{$desc}: {${$var}}\n";
开发者ID:ruizrube,项目名称:spdef,代码行数:31,代码来源:importImages.php

示例10: protectKeyPages

 /**
  * protect key pages
  *
  * @author Lucas 'TOR' Garczewski <tor@wikia-inc.com>
  */
 private function protectKeyPages()
 {
     global $wgUser, $wgWikiaKeyPages;
     $wgUser = User::newFromName("CreateWiki script");
     if ($wgUser->isAnon()) {
         $wgUser->addToDatabase();
     }
     if (empty($wgWikiaKeyPages)) {
         $wgWikiaKeyPages = array('File:Wiki.png', 'File:Favicon.ico');
     }
     /**
      * define restriction level and duration
      */
     $restrictions["edit"] = 'sysop';
     $restrictions["move"] = 'sysop';
     $restrictions["create"] = 'sysop';
     $titleRestrictions = 'sysop';
     $expiry_string = Block::infinity();
     $expiry_array = array('edit' => $expiry_string, 'move' => $expiry_string);
     /**
      *  define reason msg and fetch it
      */
     $reason = wfMsgForContent('autocreatewiki-protect-reason');
     $wgUser->addGroup('staff');
     foreach ($wgWikiaKeyPages as $pageName) {
         $title = Title::newFromText($pageName);
         $article = new Article($title);
         if ($article->exists()) {
             $cascade = 0;
             $ok = $article->updateRestrictions($restrictions, $reason, $cascade, $expiry_array);
         } else {
             $wikiPage = WikiPage::factory($title);
             $ignored_reference = false;
             // doing this because MW1.19 doUpdateRestrictions() is weird, and has this passed by reference
             $status = $wikiPage->doUpdateRestrictions(array('create' => $titleRestrictions), array('create' => $expiry_string), $ignored_reference, $reason, $wgUser);
             $ok = $status->isOK();
         }
         if ($ok) {
             Wikia::log(__METHOD__, "ok", "Protected key page: {$pageName}");
         } else {
             Wikia::log(__METHOD__, "err", "Failed while trying to protect {$pageName}");
         }
     }
     $wgUser->removeGroup("staff");
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:50,代码来源:CreateWikiLocalJob.php

示例11: doScrapeInsert


//.........这里部分代码省略.........
                                    $bill_name = $bill_type_ary[1];
                                } else {
                                    continue;
                                }
                                // if the first letter is lower case not likely a bill
                                if (trim($bill_name) == '') {
                                    continue;
                                }
                                if (islower(substr($bill_name, 0, 1))) {
                                    continue;
                                }
                                // conform white space and case:
                                $bill_name = str_replace(array('S. ', 'Con. ', 'Res. '), array('S.', 'CON.', 'RES. '), $bill_name);
                                // make sure its not a false possitave and load bill data from govTrack:
                                if ($this->get_and_process_billid($bill_name, $stream->date_start_time)) {
                                    $bill_categories[$bill_name] = $bill_name;
                                }
                            }
                        }
                    }
                    // add speech by attribute to annotation body:
                    $annotate_body .= 'Speech By: [[Speech by:=' . str_replace('_', ' ', $pData['Spoken_by']) . ']] ';
                    // add speech by attribute to body as well?
                    $body .= "\n\n" . 'Speech By: [[Speech by:=' . str_replace('_', ' ', $pData['Spoken_by']) . ']] ';
                    // add any mentions of bills with linkback to full bill title:
                    $body = preg_replace_callback($bill_pattern_ary, array('self', 'bill_pattern_cp'), $body);
                    // source the doument:
                    $body .= "\n\n" . 'Source: [[Data Source Name:=C-SPAN Congressional Chronicle]] [[Data Source URL:=' . $this->base_url . $pData['href'] . ']]';
                    $body .= "\n";
                    // add the title to the top of the page:
                    $body = "==={$title}===\n" . $body;
                    $cspan_title_str = $this->get_aligned_time_title($pData, 'Thomas_en', $stream);
                    if (!$cspan_title_str) {
                        $cspan_title_str = 'Thomas_en:' . $stream->name . '/' . seconds2npt($pData['wiki_start_time']) . '/' . seconds2npt($pData['wiki_end_time']);
                    }
                    $cspanTitle = Title::makeTitle(MV_NS_MVD, ucfirst($cspan_title_str));
                    // print "do edit ".$cspanTitle->getText()."\n";
                    do_update_wiki_page($cspanTitle, $body);
                    // protect editing of the offical record (but allow moving for sync)
                    $cspanTitle->loadRestrictions();
                    global $wgRestrictionTypes;
                    foreach ($wgRestrictionTypes as $action) {
                        // Fixme: this form currently requires individual selections,
                        // but the db allows multiples separated by commas.
                        $mRestrictions[$action] = implode('', $cspanTitle->getRestrictions($action));
                    }
                    $article = new Article($cspanTitle);
                    $mRestrictions['edit']['sysop'] = true;
                    $expiry = Block::infinity();
                    $dbw = wfGetDB(DB_MASTER);
                    $dbw->begin();
                    $ok = $article->updateRestrictions($mRestrictions, wfMsg('mv_source_material'), false, $expiry);
                    if ($ok) {
                        print "updated permisions for " . $cspanTitle->getText() . "\n";
                        $dbw->commit();
                    } else {
                        print "failed to update restrictions :(\n";
                    }
                    // process each bill to the annotation body;
                    $bcat = '';
                    $bill_lead_in = "\n\nBill ";
                    // print_r($bill_categories);
                    foreach ($bill_categories as $bill) {
                        if (trim($bill) != '') {
                            // use short title for category and long title for semantic link... (highly arbitrary)
                            $annotate_body .= $bill_lead_in . '[[Bill:=' . $this->cur_bill_short_title . ']] ';
                            $bill_lead_in = ' , ';
                            $annotate_body .= "[[Category:{$bill}]] ";
                        }
                    }
                    if (trim($title) != '') {
                        $annotate_body .= "[[Category:{$title}]]\n";
                    }
                    // see if we can align with an existing speech page:
                    $anno_title_str = $this->get_aligned_time_title($pData, 'Anno_en', $stream);
                    if (!$anno_title_str) {
                        $anno_title_str = 'Anno_en:' . $stream->name . '/' . seconds2npt($pData['wiki_start_time']) . '/' . seconds2npt($pData['wiki_end_time']);
                    }
                    $annoTitle = Title::makeTitle(MV_NS_MVD, ucfirst($anno_title_str));
                    do_update_wiki_page($annoTitle, $annotate_body);
                    // [Page: S14580] replaced with:  [[Category:BillName]]
                    // would be good to link into the official record for "pages"
                    // [[Speech by:=name]]
                    // [[category:=title]]
                    // for documentation:
                    // semantic qualities would be Aruging For:billX or Arguging Agaist billY
                    // these pages are non-editable
                    // maybe put the category info into annotations layer? (since it applies to both?)
                    // do new page mvd:or_
                }
            }
            // $inx_cspan_person_ary = array_keys($g_row_matches);
            // $inx_row_person_ary = array_keys($g_person_time_ary);
            // for($i=0;$i<5;$i++){
            // }
            // find match person1->person2
            // average switch time to get offset of stream
            // use offset to insert all $person_time_array data
        }
    }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:101,代码来源:scrape_and_insert.inc.php


注:本文中的Article::updateRestrictions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。