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


PHP Block::decodeExpiry方法代码示例

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


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

示例1: getVisibilitySettingsFromRow

 /**
  * Get page configuration settings from a DB row
  */
 public static function getVisibilitySettingsFromRow($row)
 {
     if ($row) {
         # This code should be refactored, now that it's being used more generally.
         $expiry = Block::decodeExpiry($row->fpc_expiry);
         # Only apply the settings if they haven't expired
         if (!$expiry || $expiry < wfTimestampNow()) {
             $row = null;
             // expired
             self::purgeExpiredConfigurations();
         }
     }
     // Is there a non-expired row?
     if ($row) {
         $level = $row->fpc_level;
         if (!self::isValidRestriction($row->fpc_level)) {
             $level = '';
             // site default; ignore fpc_level
         }
         $config = array('override' => $row->fpc_override ? 1 : 0, 'autoreview' => $level, 'expiry' => Block::decodeExpiry($row->fpc_expiry));
         # If there are protection levels defined check if this is valid...
         if (FlaggedRevs::useProtectionLevels()) {
             $level = self::getProtectionLevel($config);
             if ($level == 'invalid' || $level == 'none') {
                 // If 'none', make sure expiry is 'infinity'
                 $config = self::getDefaultVisibilitySettings();
                 // revert to default (none)
             }
         }
     } else {
         # Return the default config if this page doesn't have its own
         $config = self::getDefaultVisibilitySettings();
     }
     return $config;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:38,代码来源:FRPageConfig.php

示例2: getUserBlockErrors

 /**
  * @return Array: empty or a message key with parameters
  */
 static function getUserBlockErrors($user, $ip)
 {
     static $result = null;
     // Instance cache
     if (!is_null($result)) {
         return $result;
     }
     $block = self::getGlobalBlockingBlock($ip, $user->isAnon());
     if ($block) {
         global $wgLang;
         // Check for local whitelisting
         if (GlobalBlocking::getWhitelistInfo($block->gb_id)) {
             // Block has been whitelisted.
             return $result = array();
         }
         if ($user->isAllowed('ipblock-exempt') || $user->isAllowed('globalblock-exempt')) {
             // User is exempt from IP blocks.
             return $result = array();
         }
         # Messy B/C until $wgLang->formatExpiry() is well embedded
         if (Block::decodeExpiry($block->gb_expiry) == 'infinity') {
             $expiry = wfMsgExt('infiniteblock', 'parseinline');
         } else {
             $expiry = Block::decodeExpiry($block->gb_expiry);
             $expiry = wfMsgExt('expiringblock', 'parseinline', $wgLang->date($expiry), $wgLang->time($expiry));
         }
         $display_wiki = self::getWikiName($block->gb_by_wiki);
         $user_display = self::maybeLinkUserpage($block->gb_by_wiki, $block->gb_by);
         return $result = array('globalblocking-blocked', $user_display, $display_wiki, $block->gb_reason, $expiry, $ip);
     }
     return $result = array();
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:35,代码来源:GlobalBlocking.class.php

示例3: formatRow

 /**
  * Callback function to output a restriction
  */
 function formatRow($row)
 {
     global $wgUser, $wgLang, $wgContLang;
     wfProfileIn(__METHOD__);
     static $skin = null;
     if (is_null($skin)) {
         $skin = $wgUser->getSkin();
     }
     $title = Title::makeTitleSafe($row->page_namespace, $row->page_title);
     $link = $skin->makeLinkObj($title);
     $description_items = array();
     $protType = wfMsgHtml('restriction-level-' . $row->pr_level);
     $description_items[] = $protType;
     if ($row->pr_cascade) {
         $description_items[] = wfMsg('protect-summary-cascade');
     }
     $expiry_description = '';
     $stxt = '';
     if ($row->pr_expiry != 'infinity' && strlen($row->pr_expiry)) {
         $expiry = Block::decodeExpiry($row->pr_expiry);
         $expiry_description = wfMsgForContent('protect-expiring', $wgLang->timeanddate($expiry));
         $description_items[] = $expiry_description;
     }
     if (!is_null($size = $row->page_len)) {
         if ($size == 0) {
             $stxt = ' <small>' . wfMsgHtml('historyempty') . '</small>';
         } else {
             $stxt = ' <small>' . wfMsgHtml('historysize', $wgLang->formatNum($size)) . '</small>';
         }
         $stxt = $wgContLang->getDirMark() . $stxt;
     }
     wfProfileOut(__METHOD__);
     return '<li>' . wfSpecialList($link . $stxt, implode($description_items, ', ')) . "</li>\n";
 }
开发者ID:BackupTheBerlios,项目名称:shoutwiki-svn,代码行数:37,代码来源:SpecialProtectedpages.php

示例4: __construct

 public function __construct($db = '', $target = '', $proxy = null, $by = null, $expiry = '', $reason = '', $timestamp = '', $autoblock = 0, $options = array(), $id = 0)
 {
     $this->mDb = $db;
     $this->mTarget = $target;
     $this->mProxy = $proxy;
     $this->mBy = $by;
     $this->mExpiry = Block::decodeExpiry($expiry);
     $this->mTimestamp = wfTimestamp(TS_MW, $timestamp);
     $this->mReason = $reason;
     $this->mAutoblock = $autoblock;
     $this->mOptions = $options;
     $this->mId = $id;
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:13,代码来源:CrosswikiBlock.class.php

示例5: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     $fld_protection = false;
     if (!is_null($params['prop'])) {
         $prop = array_flip($params['prop']);
         $fld_protection = isset($prop['protection']);
     }
     $pageSet = $this->getPageSet();
     $titles = $pageSet->getGoodTitles();
     $result = $this->getResult();
     $pageIsRedir = $pageSet->getCustomField('page_is_redirect');
     $pageIsNew = $pageSet->getCustomField('page_is_new');
     $pageCounter = $pageSet->getCustomField('page_counter');
     $pageTouched = $pageSet->getCustomField('page_touched');
     $pageLatest = $pageSet->getCustomField('page_latest');
     $pageLength = $pageSet->getCustomField('page_len');
     if ($fld_protection && count($titles) > 0) {
         $this->addTables('page_restrictions');
         $this->addFields(array('pr_page', 'pr_type', 'pr_level', 'pr_expiry'));
         $this->addWhereFld('pr_page', array_keys($titles));
         $db = $this->getDB();
         $res = $this->select(__METHOD__);
         while ($row = $db->fetchObject($res)) {
             $protections[$row->pr_page][] = array('type' => $row->pr_type, 'level' => $row->pr_level, 'expiry' => Block::decodeExpiry($row->pr_expiry, TS_ISO_8601));
         }
         $db->freeResult($res);
     }
     foreach ($titles as $pageid => $unused) {
         $pageInfo = array('touched' => wfTimestamp(TS_ISO_8601, $pageTouched[$pageid]), 'lastrevid' => intval($pageLatest[$pageid]), 'counter' => intval($pageCounter[$pageid]), 'length' => intval($pageLength[$pageid]));
         if ($pageIsRedir[$pageid]) {
             $pageInfo['redirect'] = '';
         }
         if ($pageIsNew[$pageid]) {
             $pageInfo['new'] = '';
         }
         if ($fld_protection) {
             if (isset($protections[$pageid])) {
                 $pageInfo['protection'] = $protections[$pageid];
                 $result->setIndexedTagName($pageInfo['protection'], 'pr');
             } else {
                 $pageInfo['protection'] = array();
             }
         }
         $result->addValue(array('query', 'pages'), $pageid, $pageInfo);
     }
 }
开发者ID:mediawiki-extensions,项目名称:bizzwiki,代码行数:47,代码来源:ApiQueryInfo.php

示例6: formatRow

 /**
  * Callback function to output a restriction
  */
 function formatRow($row)
 {
     global $wgUser, $wgLang;
     wfProfileIn(__METHOD__);
     static $skin = null;
     if (is_null($skin)) {
         $skin = $wgUser->getSkin();
     }
     $title = Title::makeTitleSafe($row->pt_namespace, $row->pt_title);
     $link = $skin->link($title);
     $description_items = array();
     $protType = wfMsgHtml('restriction-level-' . $row->pt_create_perm);
     $description_items[] = $protType;
     $stxt = '';
     if ($row->pt_expiry != 'infinity' && strlen($row->pt_expiry)) {
         $expiry = Block::decodeExpiry($row->pt_expiry);
         $expiry_description = wfMsg('protect-expiring', $wgLang->timeanddate($expiry), $wgLang->date($expiry), $wgLang->time($expiry));
         $description_items[] = $expiry_description;
     }
     wfProfileOut(__METHOD__);
     return '<li>' . wfSpecialList($link . $stxt, implode($description_items, ', ')) . "</li>\n";
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:25,代码来源:SpecialProtectedtitles.php

示例7: formatRow

 /**
  * Callback function to output a restriction
  * @param $row object Protected title
  * @return string Formatted <li> element
  */
 public function formatRow($row)
 {
     global $wgUser, $wgLang, $wgContLang;
     wfProfileIn(__METHOD__);
     static $skin = null;
     if (is_null($skin)) {
         $skin = $wgUser->getSkin();
     }
     $title = Title::makeTitleSafe($row->page_namespace, $row->page_title);
     $link = $skin->makeLinkObj($title);
     $description_items = array();
     $protType = wfMsgHtml('restriction-level-' . $row->pr_level);
     $description_items[] = $protType;
     if ($row->pr_cascade) {
         $description_items[] = wfMsg('protect-summary-cascade');
     }
     $expiry_description = '';
     $stxt = '';
     if ($row->pr_expiry != 'infinity' && strlen($row->pr_expiry)) {
         $expiry = Block::decodeExpiry($row->pr_expiry);
         $expiry_description = wfMsg('protect-expiring', $wgLang->timeanddate($expiry), $wgLang->date($expiry), $wgLang->time($expiry));
         $description_items[] = $expiry_description;
     }
     if (!is_null($size = $row->page_len)) {
         $stxt = $wgContLang->getDirMark() . ' ' . $skin->formatRevisionSize($size);
     }
     # Show a link to the change protection form for allowed users otherwise a link to the protection log
     if ($wgUser->isAllowed('protect')) {
         $changeProtection = ' (' . $skin->makeKnownLinkObj($title, wfMsgHtml('protect_change'), 'action=unprotect') . ')';
     } else {
         $ltitle = SpecialPage::getTitleFor('Log');
         $changeProtection = ' (' . $skin->makeKnownLinkObj($ltitle, wfMsgHtml('protectlogpage'), 'type=protect&page=' . $title->getPrefixedUrl()) . ')';
     }
     wfProfileOut(__METHOD__);
     return '<li>' . wfSpecialList($link . $stxt, implode($description_items, ', ')) . $changeProtection . "</li>\n";
 }
开发者ID:ruizrube,项目名称:spdef,代码行数:41,代码来源:SpecialProtectedpages.php

示例8: getProtectionInfo

 /**
  * Get information about protections and put it in $protections
  */
 private function getProtectionInfo()
 {
     $this->protections = array();
     $db = $this->getDB();
     // Get normal protections for existing titles
     if (count($this->titles)) {
         $this->resetQueryParams();
         $this->addTables(array('page_restrictions', 'page'));
         $this->addWhere('page_id=pr_page');
         $this->addFields(array('pr_page', 'pr_type', 'pr_level', 'pr_expiry', 'pr_cascade', 'page_namespace', 'page_title'));
         $this->addWhereFld('pr_page', array_keys($this->titles));
         $res = $this->select(__METHOD__);
         while ($row = $db->fetchObject($res)) {
             $a = array('type' => $row->pr_type, 'level' => $row->pr_level, 'expiry' => Block::decodeExpiry($row->pr_expiry, TS_ISO_8601));
             if ($row->pr_cascade) {
                 $a['cascade'] = '';
             }
             $this->protections[$row->page_namespace][$row->page_title][] = $a;
             // Also check old restrictions
             if ($this->pageRestrictions[$row->pr_page]) {
                 $restrictions = explode(':', trim($this->pageRestrictions[$row->pr_page]));
                 foreach ($restrictions as $restrict) {
                     $temp = explode('=', trim($restrict));
                     if (count($temp) == 1) {
                         // old old format should be treated as edit/move restriction
                         $restriction = trim($temp[0]);
                         if ($restriction == '') {
                             continue;
                         }
                         $this->protections[$row->page_namespace][$row->page_title][] = array('type' => 'edit', 'level' => $restriction, 'expiry' => 'infinity');
                         $this->protections[$row->page_namespace][$row->page_title][] = array('type' => 'move', 'level' => $restriction, 'expiry' => 'infinity');
                     } else {
                         $restriction = trim($temp[1]);
                         if ($restriction == '') {
                             continue;
                         }
                         $this->protections[$row->page_namespace][$row->page_title][] = array('type' => $temp[0], 'level' => $restriction, 'expiry' => 'infinity');
                     }
                 }
             }
         }
         $db->freeResult($res);
     }
     // Get protections for missing titles
     if (count($this->missing)) {
         $this->resetQueryParams();
         $lb = new LinkBatch($this->missing);
         $this->addTables('protected_titles');
         $this->addFields(array('pt_title', 'pt_namespace', 'pt_create_perm', 'pt_expiry'));
         $this->addWhere($lb->constructSet('pt', $db));
         $res = $this->select(__METHOD__);
         while ($row = $db->fetchObject($res)) {
             $this->protections[$row->pt_namespace][$row->pt_title][] = array('type' => 'create', 'level' => $row->pt_create_perm, 'expiry' => Block::decodeExpiry($row->pt_expiry, TS_ISO_8601));
         }
         $db->freeResult($res);
     }
     // Cascading protections
     $images = $others = array();
     foreach ($this->everything as $title) {
         if ($title->getNamespace() == NS_FILE) {
             $images[] = $title->getDBkey();
         } else {
             $others[] = $title;
         }
     }
     if (count($others)) {
         // Non-images: check templatelinks
         $lb = new LinkBatch($others);
         $this->resetQueryParams();
         $this->addTables(array('page_restrictions', 'page', 'templatelinks'));
         $this->addFields(array('pr_type', 'pr_level', 'pr_expiry', 'page_title', 'page_namespace', 'tl_title', 'tl_namespace'));
         $this->addWhere($lb->constructSet('tl', $db));
         $this->addWhere('pr_page = page_id');
         $this->addWhere('pr_page = tl_from');
         $this->addWhereFld('pr_cascade', 1);
         $res = $this->select(__METHOD__);
         while ($row = $db->fetchObject($res)) {
             $source = Title::makeTitle($row->page_namespace, $row->page_title);
             $this->protections[$row->tl_namespace][$row->tl_title][] = array('type' => $row->pr_type, 'level' => $row->pr_level, 'expiry' => Block::decodeExpiry($row->pr_expiry, TS_ISO_8601), 'source' => $source->getPrefixedText());
         }
         $db->freeResult($res);
     }
     if (count($images)) {
         // Images: check imagelinks
         $this->resetQueryParams();
         $this->addTables(array('page_restrictions', 'page', 'imagelinks'));
         $this->addFields(array('pr_type', 'pr_level', 'pr_expiry', 'page_title', 'page_namespace', 'il_to'));
         $this->addWhere('pr_page = page_id');
         $this->addWhere('pr_page = il_from');
         $this->addWhereFld('pr_cascade', 1);
         $this->addWhereFld('il_to', $images);
         $res = $this->select(__METHOD__);
         while ($row = $db->fetchObject($res)) {
             $source = Title::makeTitle($row->page_namespace, $row->page_title);
             $this->protections[NS_FILE][$row->il_to][] = array('type' => $row->pr_type, 'level' => $row->pr_level, 'expiry' => Block::decodeExpiry($row->pr_expiry, TS_ISO_8601), 'source' => $source->getPrefixedText());
         }
         $db->freeResult($res);
//.........这里部分代码省略.........
开发者ID:rocLv,项目名称:conference,代码行数:101,代码来源:ApiQueryInfo.php

示例9: loadRestrictionsFromRow

 /**
  * Loads a string into mRestrictions array
  * @param resource $res restrictions as an SQL result.
  */
 private function loadRestrictionsFromRow($res, $oldFashionedRestrictions = NULL)
 {
     $dbr = wfGetDb(DB_SLAVE);
     $this->mRestrictions['edit'] = array();
     $this->mRestrictions['move'] = array();
     # Backwards-compatibility: also load the restrictions from the page record (old format).
     if ($oldFashionedRestrictions == NULL) {
         $oldFashionedRestrictions = $dbr->selectField('page', 'page_restrictions', array('page_id' => $this->getArticleId()), __METHOD__);
     }
     if ($oldFashionedRestrictions != '') {
         foreach (explode(':', trim($oldFashionedRestrictions)) as $restrict) {
             $temp = explode('=', trim($restrict));
             if (count($temp) == 1) {
                 // old old format should be treated as edit/move restriction
                 $this->mRestrictions["edit"] = explode(',', trim($temp[0]));
                 $this->mRestrictions["move"] = explode(',', trim($temp[0]));
             } else {
                 $this->mRestrictions[$temp[0]] = explode(',', trim($temp[1]));
             }
         }
         $this->mOldRestrictions = true;
         $this->mCascadeRestriction = false;
         $this->mRestrictionsExpiry = Block::decodeExpiry('');
     }
     if ($dbr->numRows($res)) {
         # Current system - load second to make them override.
         $now = wfTimestampNow();
         $purgeExpired = false;
         while ($row = $dbr->fetchObject($res)) {
             # Cycle through all the restrictions.
             // This code should be refactored, now that it's being used more generally,
             // But I don't really see any harm in leaving it in Block for now -werdna
             $expiry = Block::decodeExpiry($row->pr_expiry);
             // Only apply the restrictions if they haven't expired!
             if (!$expiry || $expiry > $now) {
                 $this->mRestrictionsExpiry = $expiry;
                 $this->mRestrictions[$row->pr_type] = explode(',', trim($row->pr_level));
                 $this->mCascadeRestriction |= $row->pr_cascade;
             } else {
                 // Trigger a lazy purge of expired restrictions
                 $purgeExpired = true;
             }
         }
         if ($purgeExpired) {
             Title::purgeExpiredRestrictions();
         }
     }
     $this->mRestrictionsLoaded = true;
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:53,代码来源:Title.php

示例10: loadRestrictions

 public function loadRestrictions($oldFashionedRestrictions = NULL)
 {
     if (!$this->mRestrictionsLoaded) {
         if ($this->exists()) {
             $dbr = wfGetDB(DB_SLAVE);
             $res = $dbr->select('page_restrictions', '*', array('pr_page' => $this->getArticleId()), __METHOD__);
             $this->loadRestrictionsFromRow($res, $oldFashionedRestrictions);
         } else {
             $title_protection = $this->getTitleProtection();
             if (is_array($title_protection)) {
                 extract($title_protection);
                 $now = wfTimestampNow();
                 $expiry = Block::decodeExpiry($pt_expiry);
                 if (!$expiry || $expiry > $now) {
                     // Apply the restrictions
                     $this->mRestrictionsExpiry = $expiry;
                     $this->mRestrictions['create'] = explode(',', trim($pt_create_perm));
                 } else {
                     // Get rid of the old restrictions
                     Title::purgeExpiredRestrictions();
                 }
             }
             $this->mRestrictionsLoaded = true;
         }
     }
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:26,代码来源:Title.php

示例11: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     $prop = array_flip($params['prop']);
     $fld_id = isset($prop['id']);
     $fld_address = isset($prop['address']);
     $fld_by = isset($prop['by']);
     $fld_timestamp = isset($prop['timestamp']);
     $fld_expiry = isset($prop['expiry']);
     $fld_reason = isset($prop['reason']);
     $fld_range = isset($prop['range']);
     $result = $this->getResult();
     $data = array();
     $this->addTables('globalblocks');
     if ($fld_id) {
         $this->addFields('gb_id');
     }
     if ($fld_address) {
         $this->addFields(array('gb_address', 'gb_anon_only'));
     }
     if ($fld_by) {
         $this->addFields(array('gb_by', 'gb_by_wiki'));
     }
     if ($fld_timestamp) {
         $this->addFields('gb_timestamp');
     }
     if ($fld_expiry) {
         $this->addFields('gb_expiry');
     }
     if ($fld_reason) {
         $this->addFields('gb_reason');
     }
     if ($fld_range) {
         $this->addFields(array('gb_range_start', 'gb_range_end'));
     }
     $this->addOption('LIMIT', $params['limit'] + 1);
     $this->addWhereRange('gb_timestamp', $params['dir'], $params['start'], $params['end']);
     if (isset($params['ids'])) {
         $this->addWhereFld('gb_id', $params['ids']);
     }
     if (isset($params['addresses'])) {
         $this->addWhereFld('gb_address', $params['addresses']);
     }
     if (isset($params['ip'])) {
         list($ip, $range) = IP::parseCIDR($params['ip']);
         if ($ip && $range) {
             # We got a CIDR range
             if ($range < 16) {
                 $this->dieUsage('CIDR ranges broader than /16 are not accepted', 'cidrtoobroad');
             }
             $lower = wfBaseConvert($ip, 10, 16, 8, false);
             $upper = wfBaseConvert($ip + pow(2, 32 - $range) - 1, 10, 16, 8, false);
         } else {
             $lower = $upper = IP::toHex($params['ip']);
         }
         $prefix = substr($lower, 0, 4);
         $this->addWhere(array("gb_range_start LIKE '{$prefix}%'", "gb_range_start <= '{$lower}'", "gb_range_end >= '{$upper}'"));
     }
     $res = $this->select(__METHOD__);
     $count = 0;
     foreach ($res as $row) {
         if (++$count > $params['limit']) {
             // We've had enough
             $this->setContinueEnumParameter('start', wfTimestamp(TS_ISO_8601, $row->gb_timestamp));
             break;
         }
         $block = array();
         if ($fld_id) {
             $block['id'] = $row->gb_id;
         }
         if ($fld_address) {
             $block['address'] = $row->gb_address;
             if ($row->gb_anon_only) {
                 $block['anononly'] = '';
             }
         }
         if ($fld_by) {
             $block['by'] = $row->gb_by;
             $block['bywiki'] = $row->gb_by_wiki;
         }
         if ($fld_timestamp) {
             $block['timestamp'] = wfTimestamp(TS_ISO_8601, $row->gb_timestamp);
         }
         if ($fld_expiry) {
             $block['expiry'] = Block::decodeExpiry($row->gb_expiry, TS_ISO_8601);
         }
         if ($fld_reason) {
             $block['reason'] = $row->gb_reason;
         }
         if ($fld_range) {
             $block['rangestart'] = IP::hexToQuad($row->gb_range_start);
             $block['rangeend'] = IP::hexToQuad($row->gb_range_end);
         }
         $data[] = $block;
     }
     $result->setIndexedTagName($data, 'block');
     $result->addValue('query', $this->getModuleName(), $data);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:98,代码来源:ApiQueryGlobalBlocks.php

示例12: run

 private function run($resultPageSet = null)
 {
     $db = $this->getDB();
     $params = $this->extractRequestParams();
     $this->addTables('protected_titles');
     $this->addFields(array('pt_namespace', 'pt_title', 'pt_timestamp'));
     $prop = array_flip($params['prop']);
     $this->addFieldsIf('pt_user', isset($prop['user']));
     $this->addFieldsIf('pt_reason', isset($prop['comment']));
     $this->addFieldsIf('pt_expiry', isset($prop['expiry']));
     $this->addFieldsIf('pt_create_perm', isset($prop['level']));
     $this->addWhereRange('pt_timestamp', $params['dir'], $params['start'], $params['end']);
     $this->addWhereFld('pt_namespace', $params['namespace']);
     $this->addWhereFld('pt_create_perm', $params['level']);
     if (isset($prop['user'])) {
         $this->addTables('user');
         $this->addFields('user_name');
         $this->addJoinConds(array('user' => array('LEFT JOIN', 'user_id=pt_user')));
     }
     $this->addOption('LIMIT', $params['limit'] + 1);
     $res = $this->select(__METHOD__);
     $count = 0;
     $result = $this->getResult();
     while ($row = $db->fetchObject($res)) {
         if (++$count > $params['limit']) {
             // We've reached the one extra which shows that there are additional pages to be had. Stop here...
             $this->setContinueEnumParameter('start', wfTimestamp(TS_ISO_8601, $row->pt_timestamp));
             break;
         }
         $title = Title::makeTitle($row->pt_namespace, $row->pt_title);
         if (is_null($resultPageSet)) {
             $vals = array();
             ApiQueryBase::addTitleInfo($vals, $title);
             if (isset($prop['timestamp'])) {
                 $vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->pt_timestamp);
             }
             if (isset($prop['user']) && !is_null($row->user_name)) {
                 $vals['user'] = $row->user_name;
             }
             if (isset($prop['comment'])) {
                 $vals['comment'] = $row->pt_reason;
             }
             if (isset($prop['expiry'])) {
                 $vals['expiry'] = Block::decodeExpiry($row->pt_expiry, TS_ISO_8601);
             }
             if (isset($prop['level'])) {
                 $vals['level'] = $row->pt_create_perm;
             }
             $fit = $result->addValue(array('query', $this->getModuleName()), null, $vals);
             if (!$fit) {
                 $this->setContinueEnumParameter('start', wfTimestamp(TS_ISO_8601, $row->pt_timestamp));
                 break;
             }
         } else {
             $titles[] = $title;
         }
     }
     $db->freeResult($res);
     if (is_null($resultPageSet)) {
         $result->setIndexedTagName_internal(array('query', $this->getModuleName()), $this->getModulePrefix());
     } else {
         $resultPageSet->populateFromTitles($titles);
     }
 }
开发者ID:ruizrube,项目名称:spdef,代码行数:64,代码来源:ApiQueryProtectedTitles.php

示例13: execute


//.........这里部分代码省略.........
     }
     if ($fld_range) {
         $this->addFields(array('ipb_range_start', 'ipb_range_end'));
     }
     if ($fld_flags) {
         $this->addFields(array('ipb_auto', 'ipb_anon_only', 'ipb_create_account', 'ipb_enable_autoblock', 'ipb_block_email', 'ipb_deleted', 'ipb_allow_usertalk'));
     }
     $this->addOption('LIMIT', $params['limit'] + 1);
     $this->addWhereRange('ipb_timestamp', $params['dir'], $params['start'], $params['end']);
     if (isset($params['ids'])) {
         $this->addWhereFld('ipb_id', $params['ids']);
     }
     if (isset($params['users'])) {
         foreach ((array) $params['users'] as $u) {
             $this->prepareUsername($u);
         }
         $this->addWhereFld('ipb_address', $this->usernames);
     }
     if (isset($params['ip'])) {
         list($ip, $range) = IP::parseCIDR($params['ip']);
         if ($ip && $range) {
             # We got a CIDR range
             if ($range < 16) {
                 $this->dieUsage('CIDR ranges broader than /16 are not accepted', 'cidrtoobroad');
             }
             $lower = wfBaseConvert($ip, 10, 16, 8, false);
             $upper = wfBaseConvert($ip + pow(2, 32 - $range) - 1, 10, 16, 8, false);
         } else {
             $lower = $upper = IP::toHex($params['ip']);
         }
         $prefix = substr($lower, 0, 4);
         $this->addWhere(array("ipb_range_start LIKE '{$prefix}%'", "ipb_range_start <= '{$lower}'", "ipb_range_end >= '{$upper}'"));
     }
     if (!$wgUser->isAllowed('suppress')) {
         $this->addWhereFld('ipb_deleted', 0);
     }
     // Purge expired entries on one in every 10 queries
     if (!mt_rand(0, 10)) {
         Block::purgeExpired();
     }
     $res = $this->select(__METHOD__);
     $count = 0;
     while ($row = $res->fetchObject()) {
         if (++$count > $params['limit']) {
             // We've had enough
             $this->setContinueEnumParameter('start', wfTimestamp(TS_ISO_8601, $row->ipb_timestamp));
             break;
         }
         $block = array();
         if ($fld_id) {
             $block['id'] = $row->ipb_id;
         }
         if ($fld_user && !$row->ipb_auto) {
             $block['user'] = $row->ipb_address;
         }
         if ($fld_by) {
             $block['by'] = $row->user_name;
         }
         if ($fld_timestamp) {
             $block['timestamp'] = wfTimestamp(TS_ISO_8601, $row->ipb_timestamp);
         }
         if ($fld_expiry) {
             $block['expiry'] = Block::decodeExpiry($row->ipb_expiry, TS_ISO_8601);
         }
         if ($fld_reason) {
             $block['reason'] = $row->ipb_reason;
         }
         if ($fld_range) {
             $block['rangestart'] = IP::hexToQuad($row->ipb_range_start);
             $block['rangeend'] = IP::hexToQuad($row->ipb_range_end);
         }
         if ($fld_flags) {
             // For clarity, these flags use the same names as their action=block counterparts
             if ($row->ipb_auto) {
                 $block['automatic'] = '';
             }
             if ($row->ipb_anon_only) {
                 $block['anononly'] = '';
             }
             if ($row->ipb_create_account) {
                 $block['nocreate'] = '';
             }
             if ($row->ipb_enable_autoblock) {
                 $block['autoblock'] = '';
             }
             if ($row->ipb_block_email) {
                 $block['noemail'] = '';
             }
             if ($row->ipb_deleted) {
                 $block['hidden'] = '';
             }
             if ($row->ipb_allow_usertalk) {
                 $block['allowusertalk'] = '';
             }
         }
         $data[] = $block;
     }
     $result->setIndexedTagName($data, 'block');
     $result->addValue('query', $this->getModuleName(), $data);
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:101,代码来源:ApiQueryBlocks.php

示例14: formatRow

 function formatRow($row)
 {
     global $wgLang, $wgUser;
     ## One-time setup
     static $sk = null;
     if (is_null($sk)) {
         $sk = $wgUser->getSkin();
     }
     ## Setup
     $timestamp = $row->gb_timestamp;
     $expiry = $row->gb_expiry;
     $options = array();
     # Messy B/C until $wgLang->formatExpiry() is well embedded
     if (Block::decodeExpiry($expiry) == 'infinity') {
         $options[] = wfMsgExt('infiniteblock', 'parseinline');
     } else {
         $expiry = Block::decodeExpiry($expiry);
         $options[] = wfMsgExt('expiringblock', 'parseinline', $wgLang->date($expiry), $wgLang->time($expiry));
     }
     # Check for whitelisting.
     $wlinfo = GlobalBlocking::getWhitelistInfo($row->gb_id);
     if ($wlinfo) {
         $options[] = wfMsg('globalblocking-list-whitelisted', User::whois($wlinfo['user']), $wlinfo['reason']);
     }
     $timestamp = $wgLang->timeanddate(wfTimestamp(TS_MW, $timestamp), true);
     if ($row->gb_anon_only) {
         $options[] = wfMsg('globalblocking-list-anononly');
     }
     ## Do afterthoughts (comment, links for admins)
     $info = array();
     if ($wgUser->isAllowed('globalunblock')) {
         $unblockTitle = SpecialPage::getTitleFor("RemoveGlobalBlock");
         $info[] = $sk->link($unblockTitle, wfMsgExt('globalblocking-list-unblock', 'parseinline'), array(), array('address' => $row->gb_address));
     }
     global $wgApplyGlobalBlocks;
     if ($wgUser->isAllowed('globalblock-whitelist') && $wgApplyGlobalBlocks) {
         $whitelistTitle = SpecialPage::getTitleFor("GlobalBlockStatus");
         $info[] = $sk->link($whitelistTitle, wfMsgExt('globalblocking-list-whitelist', 'parseinline'), array(), array('address' => $row->gb_address));
     }
     if ($wgUser->isAllowed('globalblock')) {
         $reblockTitle = SpecialPage::getTitleFor('GlobalBlock');
         $msg = wfMsgExt('globalblocking-list-modify', 'parseinline');
         $info[] = $sk->link($reblockTitle, $msg, array(), array('wpAddress' => $row->gb_address, 'modify' => 1));
     }
     ## Userpage link / Info on originating wiki
     $display_wiki = GlobalBlocking::getWikiName($row->gb_by_wiki);
     $user_display = GlobalBlocking::maybeLinkUserpage($row->gb_by_wiki, $row->gb_by);
     $infoItems = count($info) ? wfMsg('parentheses', $wgLang->pipeList($info)) : '';
     ## Put it all together.
     return Html::rawElement('li', array(), wfMsgExt('globalblocking-list-blockitem', array('parseinline'), $timestamp, $user_display, $display_wiki, $row->gb_address, $wgLang->commaList($options)) . ' ' . $sk->commentBlock($row->gb_reason) . ' ' . $infoItems);
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:51,代码来源:SpecialGlobalBlockList.php

示例15: formatRow

 /**
  * Callback function to output a restriction
  * @param $row object Protected title
  * @return string Formatted <li> element
  */
 public function formatRow($row)
 {
     global $wgUser, $wgLang, $wgContLang;
     wfProfileIn(__METHOD__);
     static $skin = null;
     if (is_null($skin)) {
         $skin = $wgUser->getSkin();
     }
     $title = Title::makeTitleSafe($row->page_namespace, $row->page_title);
     $link = $skin->link($title);
     $description_items = array();
     $protType = wfMsgHtml('restriction-level-' . $row->pr_level);
     $description_items[] = $protType;
     if ($row->pr_cascade) {
         $description_items[] = wfMsg('protect-summary-cascade');
     }
     $stxt = '';
     if ($row->pr_expiry != 'infinity' && strlen($row->pr_expiry)) {
         $expiry = Block::decodeExpiry($row->pr_expiry);
         $expiry_description = wfMsg('protect-expiring', $wgLang->timeanddate($expiry), $wgLang->date($expiry), $wgLang->time($expiry));
         $description_items[] = htmlspecialchars($expiry_description);
     }
     if (!is_null($size = $row->page_len)) {
         $stxt = $wgContLang->getDirMark() . ' ' . $skin->formatRevisionSize($size);
     }
     # Show a link to the change protection form for allowed users otherwise a link to the protection log
     if ($wgUser->isAllowed('protect')) {
         $changeProtection = ' (' . $skin->linkKnown($title, wfMsgHtml('protect_change'), array(), array('action' => 'unprotect')) . ')';
     } else {
         $ltitle = SpecialPage::getTitleFor('Log');
         $changeProtection = ' (' . $skin->linkKnown($ltitle, wfMsgHtml('protectlogpage'), array(), array('type' => 'protect', 'page' => $title->getPrefixedText())) . ')';
     }
     wfProfileOut(__METHOD__);
     return Html::rawElement('li', array(), wfSpecialList($link . $stxt, $wgLang->commaList($description_items)) . $changeProtection) . "\n";
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:40,代码来源:SpecialProtectedpages.php


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