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


PHP Block::infinity方法代码示例

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


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

示例1: isStruck

 /**
  * @return bool Whether this sign-off has been struck
  */
 public function isStruck()
 {
     return $this->timestampStruck !== Block::infinity();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:7,代码来源:CodeSignoff.php

示例2: convertExpiry

 public function convertExpiry($str)
 {
     if (strlen($str) == 0) {
         return;
     }
     if ($str == 'infinite' || $str == 'indefinite') {
         return Block::infinity();
     } else {
         # Convert GNU-style date, on error returns -1 for PHP <5.1 and false for PHP >=5.1
         $expiry = strtotime($str);
         if ($expiry < 0 || $expiry === false) {
             return;
         }
         return wfTimestamp(TS_MW, $expiry);
     }
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:16,代码来源:CrosswikiBlock.page.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: updateRestrictions

 /**
  * Update the article's restriction field, and leave a log entry.
  *
  * @param $limit Array: set of restriction keys
  * @param $reason String
  * @param &$cascade Integer. Set to false if cascading protection isn't allowed.
  * @param $expiry Array: per restriction type expiration
  * @return bool true on success
  */
 public function updateRestrictions($limit = array(), $reason = '', &$cascade = 0, $expiry = array())
 {
     global $wgUser, $wgContLang;
     $restrictionTypes = $this->mTitle->getRestrictionTypes();
     $id = $this->mTitle->getArticleID();
     if ($id <= 0) {
         wfDebug("updateRestrictions failed: article id {$id} <= 0\n");
         return false;
     }
     if (wfReadOnly()) {
         wfDebug("updateRestrictions failed: read-only\n");
         return false;
     }
     if (!$this->mTitle->userCan('protect')) {
         wfDebug("updateRestrictions failed: insufficient permissions\n");
         return false;
     }
     if (!$cascade) {
         $cascade = false;
     }
     // Take this opportunity to purge out expired restrictions
     Title::purgeExpiredRestrictions();
     # FIXME: Same limitations as described in ProtectionForm.php (line 37);
     # we expect a single selection, but the schema allows otherwise.
     $current = array();
     $updated = Article::flattenRestrictions($limit);
     $changed = false;
     foreach ($restrictionTypes as $action) {
         if (isset($expiry[$action])) {
             # Get current restrictions on $action
             $aLimits = $this->mTitle->getRestrictions($action);
             $current[$action] = implode('', $aLimits);
             # Are any actual restrictions being dealt with here?
             $aRChanged = count($aLimits) || !empty($limit[$action]);
             # If something changed, we need to log it. Checking $aRChanged
             # assures that "unprotecting" a page that is not protected does
             # not log just because the expiry was "changed".
             if ($aRChanged && $this->mTitle->mRestrictionsExpiry[$action] != $expiry[$action]) {
                 $changed = true;
             }
         }
     }
     $current = Article::flattenRestrictions($current);
     $changed = $changed || $current != $updated;
     $changed = $changed || $updated && $this->mTitle->areRestrictionsCascading() != $cascade;
     $protect = $updated != '';
     # If nothing's changed, do nothing
     if ($changed) {
         if (wfRunHooks('ArticleProtect', array(&$this, &$wgUser, $limit, $reason))) {
             $dbw = wfGetDB(DB_MASTER);
             # Prepare a null revision to be added to the history
             $modified = $current != '' && $protect;
             if ($protect) {
                 $comment_type = $modified ? 'modifiedarticleprotection' : 'protectedarticle';
             } else {
                 $comment_type = 'unprotectedarticle';
             }
             $comment = $wgContLang->ucfirst(wfMsgForContent($comment_type, $this->mTitle->getPrefixedText()));
             # Only restrictions with the 'protect' right can cascade...
             # Otherwise, people who cannot normally protect can "protect" pages via transclusion
             $editrestriction = isset($limit['edit']) ? array($limit['edit']) : $this->mTitle->getRestrictions('edit');
             # The schema allows multiple restrictions
             if (!in_array('protect', $editrestriction) && !in_array('sysop', $editrestriction)) {
                 $cascade = false;
             }
             $cascade_description = '';
             if ($cascade) {
                 $cascade_description = ' [' . wfMsgForContent('protect-summary-cascade') . ']';
             }
             if ($reason) {
                 $comment .= ": {$reason}";
             }
             $editComment = $comment;
             $encodedExpiry = array();
             $protect_description = '';
             foreach ($limit as $action => $restrictions) {
                 if (!isset($expiry[$action])) {
                     $expiry[$action] = Block::infinity();
                 }
                 $encodedExpiry[$action] = Block::encodeExpiry($expiry[$action], $dbw);
                 if ($restrictions != '') {
                     $protect_description .= "[{$action}={$restrictions}] (";
                     if ($encodedExpiry[$action] != 'infinity') {
                         $protect_description .= wfMsgForContent('protect-expiring', $wgContLang->timeanddate($expiry[$action], false, false), $wgContLang->date($expiry[$action], false, false), $wgContLang->time($expiry[$action], false, false));
                     } else {
                         $protect_description .= wfMsgForContent('protect-expiry-indefinite');
                     }
                     $protect_description .= ') ';
                 }
             }
             $protect_description = trim($protect_description);
//.........这里部分代码省略.........
开发者ID:GodelDesign,项目名称:Godel,代码行数:101,代码来源:Article.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: exit

$wgUser = User::newFromName($userName);
if (!$wgUser) {
    print "Invalid username\n";
    exit(1);
}
if ($wgUser->isAnon()) {
    $wgUser->addToDatabase();
}
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";
开发者ID:yusufchang,项目名称:app,代码行数:31,代码来源:protectKeyPages.php

示例7: formatRow

 /**
  * Callback function to output a block
  */
 function formatRow($block)
 {
     global $wgUser, $wgLang;
     wfProfileIn(__METHOD__);
     static $sk = null, $msg = null;
     if (is_null($sk)) {
         $sk = $wgUser->getSkin();
     }
     if (is_null($msg)) {
         $msg = array();
         $keys = array('infiniteblock', 'expiringblock', 'unblocklink', 'anononlyblock', 'createaccountblock', 'noautoblockblock', 'emailblock');
         foreach ($keys as $key) {
             $msg[$key] = wfMsgHtml($key);
         }
         $msg['blocklistline'] = wfMsg('blocklistline');
     }
     # Prepare links to the blocker's user and talk pages
     $blocker_id = $block->getBy();
     $blocker_name = $block->getByName();
     $blocker = $sk->userLink($blocker_id, $blocker_name);
     $blocker .= $sk->userToolLinks($blocker_id, $blocker_name);
     # Prepare links to the block target's user and contribs. pages (as applicable, don't do it for autoblocks)
     if ($block->mAuto) {
         $target = $block->getRedactedName();
         # Hide the IP addresses of auto-blocks; privacy
     } else {
         $target = $sk->userLink($block->mUser, $block->mAddress) . $sk->userToolLinks($block->mUser, $block->mAddress, false, Linker::TOOL_LINKS_NOBLOCK);
     }
     $formattedTime = $wgLang->timeanddate($block->mTimestamp, true);
     $properties = array();
     if ($block->mExpiry === "" || $block->mExpiry === Block::infinity()) {
         $properties[] = $msg['infiniteblock'];
     } else {
         $properties[] = wfMsgReplaceArgs($msg['expiringblock'], array($wgLang->timeanddate($block->mExpiry, true)));
     }
     if ($block->mAnonOnly) {
         $properties[] = $msg['anononlyblock'];
     }
     if ($block->mCreateAccount) {
         $properties[] = $msg['createaccountblock'];
     }
     if (!$block->mEnableAutoblock && $block->mUser) {
         $properties[] = $msg['noautoblockblock'];
     }
     if ($block->mBlockEmail && $block->mUser) {
         $properties[] = $msg['emailblock'];
     }
     $properties = implode(', ', $properties);
     $line = wfMsgReplaceArgs($msg['blocklistline'], array($formattedTime, $blocker, $target, $properties));
     $unblocklink = '';
     if ($wgUser->isAllowed('block')) {
         $titleObj = SpecialPage::getTitleFor("Ipblocklist");
         $unblocklink = ' (' . $sk->makeKnownLinkObj($titleObj, $msg['unblocklink'], 'action=unblock&id=' . urlencode($block->mId)) . ')';
     }
     $comment = $sk->commentBlock($block->mReason);
     $s = "{$line} {$comment}";
     if ($block->mHideName) {
         $s = '<span class="history-deleted">' . $s . '</span>';
     }
     wfProfileOut(__METHOD__);
     return "<li>{$s} {$unblocklink}</li>\n";
 }
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:65,代码来源:SpecialIpblocklist.php

示例8: doBlock

 /**
  * Backend block code.
  * $userID and $expiry will be filled accordingly
  * @return array(message key, arguments) on failure, empty array on success
  */
 function doBlock(&$userId = null, &$expiry = null)
 {
     global $wgUser, $wgSysopUserBans, $wgSysopRangeBans;
     $userId = 0;
     # Expand valid IPv6 addresses, usernames are left as is
     $this->BlockAddress = IP::sanitizeIP($this->BlockAddress);
     # isIPv4() and IPv6() are used for final validation
     $rxIP4 = '\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}';
     $rxIP6 = '\\w{1,4}:\\w{1,4}:\\w{1,4}:\\w{1,4}:\\w{1,4}:\\w{1,4}:\\w{1,4}:\\w{1,4}';
     $rxIP = "({$rxIP4}|{$rxIP6})";
     # Check for invalid specifications
     if (!preg_match("/^{$rxIP}\$/", $this->BlockAddress)) {
         $matches = array();
         if (preg_match("/^({$rxIP4})\\/(\\d{1,2})\$/", $this->BlockAddress, $matches)) {
             # IPv4
             if ($wgSysopRangeBans) {
                 if (!IP::isIPv4($this->BlockAddress) || $matches[2] < 16 || $matches[2] > 32) {
                     return array('ip_range_invalid');
                 }
                 $this->BlockAddress = Block::normaliseRange($this->BlockAddress);
             } else {
                 # Range block illegal
                 return array('range_block_disabled');
             }
         } else {
             if (preg_match("/^({$rxIP6})\\/(\\d{1,3})\$/", $this->BlockAddress, $matches)) {
                 # IPv6
                 if ($wgSysopRangeBans) {
                     if (!IP::isIPv6($this->BlockAddress) || $matches[2] < 64 || $matches[2] > 128) {
                         return array('ip_range_invalid');
                     }
                     $this->BlockAddress = Block::normaliseRange($this->BlockAddress);
                 } else {
                     # Range block illegal
                     return array('range_block_disabled');
                 }
             } else {
                 # Username block
                 if ($wgSysopUserBans) {
                     $user = User::newFromName($this->BlockAddress);
                     if (!is_null($user) && $user->getID()) {
                         # Use canonical name
                         $userId = $user->getID();
                         $this->BlockAddress = $user->getName();
                     } else {
                         return array('nosuchusershort', htmlspecialchars($user ? $user->getName() : $this->BlockAddress));
                     }
                 } else {
                     return array('badipaddress');
                 }
             }
         }
     }
     $reasonstr = $this->BlockReasonList;
     if ($reasonstr != 'other' && $this->BlockReason != '') {
         // Entry from drop down menu + additional comment
         $reasonstr .= ': ' . $this->BlockReason;
     } elseif ($reasonstr == 'other') {
         $reasonstr = $this->BlockReason;
     }
     $expirestr = $this->BlockExpiry;
     if ($expirestr == 'other') {
         $expirestr = $this->BlockOther;
     }
     if (strlen($expirestr) == 0) {
         return array('ipb_expiry_invalid');
     }
     if ($expirestr == 'infinite' || $expirestr == 'indefinite') {
         $expiry = Block::infinity();
     } else {
         # Convert GNU-style date, on error returns -1 for PHP <5.1 and false for PHP >=5.1
         $expiry = strtotime($expirestr);
         if ($expiry < 0 || $expiry === false) {
             return array('ipb_expiry_invalid');
         }
         $expiry = wfTimestamp(TS_MW, $expiry);
     }
     # Create block
     # Note: for a user block, ipb_address is only for display purposes
     $block = new Block($this->BlockAddress, $userId, $wgUser->getID(), $reasonstr, wfTimestampNow(), 0, $expiry, $this->BlockAnonOnly, $this->BlockCreateAccount, $this->BlockEnableAutoblock, $this->BlockHideName, $this->BlockEmail);
     if (wfRunHooks('BlockIp', array(&$block, &$wgUser))) {
         if (!$block->insert()) {
             return array('ipb_already_blocked', htmlspecialchars($this->BlockAddress));
         }
         wfRunHooks('BlockIpComplete', array($block, $wgUser));
         # Prepare log parameters
         $logParams = array();
         $logParams[] = $expirestr;
         $logParams[] = $this->blockLogFlags();
         # Make log entry, if the name is hidden, put it in the oversight log
         $log_type = $this->BlockHideName ? 'oversight' : 'block';
         $log = new LogPage($log_type);
         $log->addEntry('block', Title::makeTitle(NS_USER, $this->BlockAddress), $reasonstr, $logParams);
         # Report to the user
         return array();
//.........这里部分代码省略.........
开发者ID:ErdemA,项目名称:wikihow,代码行数:101,代码来源:SpecialBlockip.php

示例9: doNamespaceRestriction

 public static function doNamespaceRestriction($uid, $user)
 {
     global $wgUser, $wgRequest;
     $r = new UserRestriction();
     $r->setType(UserRestriction::NAMESPACE);
     $r->setNamespace($wgRequest->getVal('namespace'));
     $r->setSubjectId($uid);
     $r->setSubjectText($user);
     $r->setBlockerId($wgUser->getId());
     $r->setBlockerText($wgUser->getName());
     $r->setReason($wgRequest->getVal('reason'));
     $r->setExpiry(UserRestriction::convertExpiry($wgRequest->getVal('expiry')));
     $r->setTimestamp(wfTimestampNow(TS_MW));
     $r->commit();
     $logExpiry = $wgRequest->getVal('expiry') ? $wgRequest->getVal('expiry') : Block::infinity();
     $l = new LogPage('restrict');
     $l->addEntry('restrict', Title::makeTitle(NS_USER, $user), $r->getReason(), array($r->getType(), $r->getNamespace(), $logExpiry));
 }
开发者ID:ruizrube,项目名称:spdef,代码行数:18,代码来源:SpecialRestrictUser.php

示例10: addLogParams

 /**
  * @static
  * @param $result ApiResult
  * @param $vals
  * @param $params
  * @param $type
  * @param $ts
  * @return array
  */
 public static function addLogParams($result, &$vals, $params, $type, $ts)
 {
     $params = explode("\n", $params);
     switch ($type) {
         case 'move':
             if (isset($params[0])) {
                 $title = Title::newFromText($params[0]);
                 if ($title) {
                     $vals2 = array();
                     ApiQueryBase::addTitleInfo($vals2, $title, 'new_');
                     $vals[$type] = $vals2;
                 }
             }
             if (isset($params[1]) && $params[1]) {
                 $vals[$type]['suppressedredirect'] = '';
             }
             $params = null;
             break;
         case 'patrol':
             $vals2 = array();
             list($vals2['cur'], $vals2['prev'], $vals2['auto']) = $params;
             $vals[$type] = $vals2;
             $params = null;
             break;
         case 'rights':
             $vals2 = array();
             list($vals2['old'], $vals2['new']) = $params;
             $vals[$type] = $vals2;
             $params = null;
             break;
         case 'block':
             $vals2 = array();
             list($vals2['duration'], $vals2['flags']) = $params;
             // Indefinite blocks have no expiry time
             if (Block::parseExpiryInput($params[0]) !== Block::infinity()) {
                 $vals2['expiry'] = wfTimestamp(TS_ISO_8601, strtotime($params[0], wfTimestamp(TS_UNIX, $ts)));
             }
             $vals[$type] = $vals2;
             $params = null;
             break;
     }
     if (!is_null($params)) {
         $result->setIndexedTagName($params, 'param');
         $vals = array_merge($vals, $params);
     }
     return $vals;
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:56,代码来源:ApiQueryLogEvents.php

示例11: doSubmit

 /**
  * Submit the form parameters for the page config to the DB.
  * 
  * @return mixed (true on success, error string on failure)
  */
 public function doSubmit()
 {
     # Double-check permissions
     if (!$this->isAllowed()) {
         return 'stablize_denied';
     }
     # Parse and cleanup the expiry time given...
     $expiry = $this->getExpiry();
     if ($expiry === false) {
         return 'stabilize_expiry_invalid';
     } elseif ($expiry !== Block::infinity() && $expiry < wfTimestampNow()) {
         return 'stabilize_expiry_old';
     }
     # Update the DB row with the new config...
     $changed = FRPageConfig::setStabilitySettings($this->page, $this->getNewConfig());
     # Log if this actually changed anything...
     if ($changed) {
         $article = new FlaggableWikiPage($this->page);
         if (FlaggedRevs::useOnlyIfProtected()) {
             # Config may have changed to allow stable versions, so refresh
             # the tracking table to account for any hidden reviewed versions...
             $frev = FlaggedRevision::determineStable($this->page, FR_MASTER);
             if ($frev) {
                 $article->updateStableVersion($frev);
             } else {
                 $article->clearStableVersion();
             }
         }
         # Update logs and make a null edit
         $nullRev = $this->updateLogsAndHistory($article);
         # Null edit may have been auto-reviewed already
         $frev = FlaggedRevision::newFromTitle($this->page, $nullRev->getId(), FR_MASTER);
         $updatesDone = (bool) $frev;
         // stableVersionUpdates() already called?
         # Check if this null edit is to be reviewed...
         if ($this->reviewThis && !$frev) {
             $flags = null;
             # Review this revision of the page...
             $ok = FlaggedRevs::autoReviewEdit($article, $this->user, $nullRev, $flags, true);
             if ($ok) {
                 FlaggedRevs::markRevisionPatrolled($nullRev);
                 // reviewed -> patrolled
                 $updatesDone = true;
                 // stableVersionUpdates() already called
             }
         }
         # Update page and tracking tables and clear cache.
         if (!$updatesDone) {
             FlaggedRevs::stableVersionUpdates($this->page);
         }
     }
     # Apply watchlist checkbox value (may be NULL)
     $this->updateWatchlist();
     # Take this opportunity to purge out expired configurations
     FRPageConfig::purgeExpiredConfigurations();
     return true;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:62,代码来源:PageStabilityForm.php

示例12: showForm

    public function showForm($err = null)
    {
        $out = $this->getOutput();
        $form = $this->form;
        // convenience
        $title = $this->form->getPage();
        $oldConfig = $form->getOldConfig();
        $s = '';
        // form HTML string
        # Add any error messages
        if ("" != $err) {
            $out->setSubtitle(wfMsgHtml('formerror'));
            $out->addHTML("<p class='error'>{$err}</p>\n");
        }
        # Add header text
        if (!$form->isAllowed()) {
            $s .= wfMsgExt('stabilization-perm', 'parse', $title->getPrefixedText());
        } else {
            $s .= wfMsgExt('stabilization-text', 'parse', $title->getPrefixedText());
        }
        # Borrow some protection messages for dropdowns
        $reasonDropDown = Xml::listDropDown('wpReasonSelection', wfMsgForContent('protect-dropdown'), wfMsgForContent('protect-otherreason-op'), $form->getReasonSelection(), 'mwStabilize-reason', 4);
        $scExpiryOptions = wfMsgForContent('protect-expiry-options');
        $showProtectOptions = $scExpiryOptions !== '-' && $form->isAllowed();
        $dropdownOptions = array();
        // array of <label,value>
        # Add the current expiry as a dropdown option
        if ($oldConfig['expiry'] && $oldConfig['expiry'] != Block::infinity()) {
            $timestamp = $this->getLang()->timeanddate($oldConfig['expiry']);
            $d = $this->getLang()->date($oldConfig['expiry']);
            $t = $this->getLang()->time($oldConfig['expiry']);
            $dropdownOptions[] = array(wfMsg('protect-existing-expiry', $timestamp, $d, $t), 'existing');
        }
        # Add "other time" expiry dropdown option
        $dropdownOptions[] = array(wfMsg('protect-othertime-op'), 'othertime');
        # Add custom expiry dropdown options (from MediaWiki message)
        foreach (explode(',', $scExpiryOptions) as $option) {
            if (strpos($option, ":") === false) {
                $show = $value = $option;
            } else {
                list($show, $value) = explode(":", $option);
            }
            $dropdownOptions[] = array($show, $value);
        }
        # Actually build the options HTML...
        $expiryFormOptions = '';
        foreach ($dropdownOptions as $option) {
            $show = htmlspecialchars($option[0]);
            $value = htmlspecialchars($option[1]);
            $expiryFormOptions .= Xml::option($show, $value, $form->getExpirySelection() === $value) . "\n";
        }
        # Build up the form...
        $s .= Xml::openElement('form', array('name' => 'stabilization', 'action' => $this->getTitle()->getLocalUrl(), 'method' => 'post'));
        # Add stable version override and selection options
        $s .= Xml::fieldset(wfMsg('stabilization-def'), false) . "\n" . Xml::radioLabel(wfMsg('stabilization-def1'), 'wpStableconfig-override', 1, 'default-stable', 1 == $form->getOverride(), $this->disabledAttr()) . '<br />' . "\n" . Xml::radioLabel(wfMsg('stabilization-def2'), 'wpStableconfig-override', 0, 'default-current', 0 == $form->getOverride(), $this->disabledAttr()) . "\n" . Xml::closeElement('fieldset');
        # Add autoreview restriction select
        $s .= Xml::fieldset(wfMsg('stabilization-restrict'), false) . $this->buildSelector($form->getAutoreview()) . Xml::closeElement('fieldset') . Xml::fieldset(wfMsg('stabilization-leg'), false) . Xml::openElement('table');
        # Add expiry dropdown to form...
        if ($showProtectOptions && $form->isAllowed()) {
            $s .= "\n\t\t\t\t<tr>\n\t\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('stabilization-expiry'), 'mwStabilizeExpirySelection') . "</td>\n\t\t\t\t\t<td class='mw-input'>" . Xml::tags('select', array('id' => 'mwStabilizeExpirySelection', 'name' => 'wpExpirySelection', 'onchange' => 'onFRChangeExpiryDropdown()') + $this->disabledAttr(), $expiryFormOptions) . "</td>\n\t\t\t\t</tr>";
        }
        # Add custom expiry field to form...
        $attribs = array('id' => "mwStabilizeExpiryOther", 'onkeyup' => 'onFRChangeExpiryField()') + $this->disabledAttr();
        $s .= "\n\t\t\t<tr>\n\t\t\t\t<td class='mw-label'>" . Xml::label(wfMsg('stabilization-othertime'), 'mwStabilizeExpiryOther') . '</td>
				<td class="mw-input">' . Xml::input("mwStabilize-expiry", 50, $form->getExpiryCustom(), $attribs) . '</td>
			</tr>';
        # Add comment input and submit button
        if ($form->isAllowed()) {
            $watchLabel = wfMsgExt('watchthis', 'parseinline');
            $watchAttribs = array('accesskey' => wfMsg('accesskey-watch'), 'id' => 'wpWatchthis');
            $watchChecked = $this->getUser()->getOption('watchdefault') || $title->userIsWatching();
            $reviewLabel = wfMsgExt('stabilization-review', 'parseinline');
            $s .= ' <tr>
					<td class="mw-label">' . xml::label(wfMsg('stabilization-comment'), 'wpReasonSelection') . '</td>
					<td class="mw-input">' . $reasonDropDown . '</td>
				</tr>
				<tr>
					<td class="mw-label">' . Xml::label(wfMsg('stabilization-otherreason'), 'wpReason') . '</td>
					<td class="mw-input">' . Xml::input('wpReason', 70, $form->getReasonExtra(), array('id' => 'wpReason', 'maxlength' => 255)) . '</td>
				</tr>
				<tr>
					<td></td>
					<td class="mw-input">' . Xml::check('wpReviewthis', $form->getReviewThis(), array('id' => 'wpReviewthis')) . "<label for='wpReviewthis'>{$reviewLabel}</label>" . '&#160;&#160;&#160;&#160;&#160;' . Xml::check('wpWatchthis', $watchChecked, $watchAttribs) . "&#160;<label for='wpWatchthis' " . Xml::expandAttributes(array('title' => Linker::titleAttrib('watch', 'withaccess'))) . ">{$watchLabel}</label>" . '</td>
				</tr>
				<tr>
					<td></td>
					<td class="mw-submit">' . Xml::submitButton(wfMsg('stabilization-submit')) . '</td>
				</tr>' . Xml::closeElement('table') . Html::hidden('title', $this->getTitle()->getPrefixedDBKey()) . Html::hidden('page', $title->getPrefixedText()) . Html::hidden('wpEditToken', $this->getUser()->editToken());
        } else {
            $s .= Xml::closeElement('table');
        }
        $s .= Xml::closeElement('fieldset') . Xml::closeElement('form');
        $out->addHTML($s);
        $out->addHTML(Xml::element('h2', null, htmlspecialchars(LogPage::logName('stable'))));
        LogEventsList::showLogExtract($out, 'stable', $title->getPrefixedText(), '', array('lim' => 25));
        # Add some javascript for expiry dropdowns
        $out->addScript("<script type=\"text/javascript\">\n\t\t\t\tfunction onFRChangeExpiryDropdown() {\n\t\t\t\t\tdocument.getElementById('mwStabilizeExpiryOther').value = '';\n\t\t\t\t}\n\t\t\t\tfunction onFRChangeExpiryField() {\n\t\t\t\t\tdocument.getElementById('mwStabilizeExpirySelection').value = 'othertime';\n\t\t\t\t}\n\t\t\t</script>");
    }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:98,代码来源:Stabilization_body.php

示例13: poUpdateRestrictions

function poUpdateRestrictions($article, $restrictions, $cascade = false, $expiration = null)
{
    global $wgProtectOwnDoProtect, $wgUser, $wgProtectOwnCacheUserCan, $wgProtectOwnCacheIsOwner;
    if ($expiration === null) {
        $expiration = array();
        $infinity = Block::infinity();
        foreach ($restrictions as $action => $level) {
            $expiration[$action] = $infinity;
        }
    }
    # temporary assign protect right, in order to update the restricitons
    $wgProtectOwnDoProtect = true;
    // tells spSetRestrictionsAssignDynamicRights to add the "protect" right
    //	wfDebugLog( 'ProtectOwn', 'Form: purge user\'s rights then force reload');
    $wgUser->mRights = null;
    // clear current user rights
    $wgUser->getRights();
    // force rights reloading
    $wgProtectOwnDoProtect = false;
    wfDebugLog('ProtectOwn', "UpdateRestrictions: restrictions =\n " . var_export($restrictions, true) . "\nexpiration=\n" . var_export($expiration, true));
    // update restrictions
    $success = $article->updateRestrictions($restrictions, 'ProtectOwn', $cascade, $expiration);
    // note that this article function check that the user has sufficient rights
    # clear userCan and isOwner caches
    # because of protect right granted few instants
    # IsOwner cache clearing should not be necessary, but IsOwner hook may be affected by restrictions update
    //	wfDebugLog( 'ProtectOwn', 'Form: purge userCan and isOwner caches');
    $wgProtectOwnCacheUserCan = array();
    $wgProtectOwnCacheIsOwner = array();
    # remove temporary assigned protect right by reloading rights with $wgSetRestrictionsDoProtect = false
    //	wfDebugLog( 'ProtectOwn', 'Form: purge user\'s rights then force reload');
    $wgUser->mRights = null;
    // clear current user rights (and clear the "protect" right
    $wgUser->getRights();
    // force rights reloading
    return $success;
}
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:37,代码来源:ProtectOwn.php

示例14: 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

示例15: 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


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