• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wfIsInfinity函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wfIsInfinity函数的典型用法代码示例。如果您正苦于以下问题:PHP wfIsInfinity函数的具体用法?PHP wfIsInfinity怎么用?PHP wfIsInfinity使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: getExpiry

 /**
  * Get the expiry time for a given action, by combining the relevant inputs.
  *
  * @param string $action
  *
  * @return string 14-char timestamp or "infinity", or false if the input was invalid
  */
 function getExpiry($action)
 {
     if ($this->mExpirySelection[$action] == 'existing') {
         return $this->mExistingExpiry[$action];
     } elseif ($this->mExpirySelection[$action] == 'othertime') {
         $value = $this->mExpiry[$action];
     } else {
         $value = $this->mExpirySelection[$action];
     }
     if (wfIsInfinity($value)) {
         $time = 'infinity';
     } else {
         $unix = strtotime($value);
         if (!$unix || $unix === -1) {
             return false;
         }
         // @todo FIXME: Non-qualified absolute times are not in users specified timezone
         // and there isn't notice about it in the ui
         $time = wfTimestamp(TS_MW, $unix);
     }
     return $time;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:29,代码来源:ProtectionForm.php


示例2: translateBlockExpiry

 /**
  * @todo Maybe translate block durations.  Note that this function is somewhat misnamed: it
  * deals with translating the *duration* ("1 week", "4 days", etc), not the expiry time
  * (which is an absolute timestamp). Please note: do NOT add this blindly, as it is used
  * on old expiry lengths recorded in log entries. You'd need to provide the start date to
  * match up with it.
  *
  * @param string $str The validated block duration in English
  * @return string Somehow translated block duration
  * @see LanguageFi.php for example implementation
  */
 function translateBlockExpiry($str)
 {
     $duration = SpecialBlock::getSuggestedDurations($this);
     foreach ($duration as $show => $value) {
         if (strcmp($str, $value) == 0) {
             return htmlspecialchars(trim($show));
         }
     }
     if (wfIsInfinity($str)) {
         foreach ($duration as $show => $value) {
             if (wfIsInfinity($value)) {
                 return htmlspecialchars(trim($show));
             }
         }
     }
     // If all else fails, return a standard duration or timestamp description.
     $time = strtotime($str, 0);
     if ($time === false) {
         // Unknown format. Return it as-is in case.
         return $str;
     } elseif ($time !== strtotime($str, 1)) {
         // It's a relative timestamp.
         // $time is relative to 0 so it's a duration length.
         return $this->formatDuration($time);
     } else {
         // It's an absolute timestamp.
         if ($time === 0) {
             // wfTimestamp() handles 0 as current time instead of epoch.
             return $this->timeanddate('19700101000000');
         } else {
             return $this->timeanddate($time);
         }
     }
 }
开发者ID:nanasess,项目名称:mediawiki,代码行数:45,代码来源:Language.php


示例3: parseExpiryInput

 /**
  * Convert a submitted expiry time, which may be relative ("2 weeks", etc) or absolute
  * ("24 May 2034", etc), into an absolute timestamp we can put into the database.
  * @param string $expiry Whatever was typed into the form
  * @return string Timestamp or 'infinity'
  */
 public static function parseExpiryInput($expiry)
 {
     if (wfIsInfinity($expiry)) {
         $expiry = 'infinity';
     } else {
         $expiry = strtotime($expiry);
         if ($expiry < 0 || $expiry === false) {
             return false;
         }
         $expiry = wfTimestamp(TS_MW, $expiry);
     }
     return $expiry;
 }
开发者ID:kolzchut,项目名称:mediawiki-molsa-new,代码行数:19,代码来源:SpecialBlock.php


示例4: getParametersForApi

 protected function getParametersForApi()
 {
     $entry = $this->entry;
     $params = $entry->getParameters();
     static $map = array('5::duration', '6:array:flags', '6::flags' => '6:array:flags');
     foreach ($map as $index => $key) {
         if (isset($params[$index])) {
             $params[$key] = $params[$index];
             unset($params[$index]);
         }
     }
     $subtype = $entry->getSubtype();
     if ($subtype === 'block' || $subtype === 'reblock') {
         // Defaults for old log entries missing some fields
         $params += array('5::duration' => 'infinite', '6:array:flags' => array());
         if (!is_array($params['6:array:flags'])) {
             $params['6:array:flags'] = $params['6:array:flags'] === '' ? array() : explode(',', $params['6:array:flags']);
         }
         if (!wfIsInfinity($params['5::duration'])) {
             $ts = wfTimestamp(TS_UNIX, $entry->getTimestamp());
             $expiry = strtotime($params['5::duration'], $ts);
             if ($expiry !== false && $expiry > 0) {
                 $params[':timestamp:expiry'] = $expiry;
             }
         }
     }
     return $params;
 }
开发者ID:Acidburn0zzz,项目名称:mediawiki,代码行数:28,代码来源:BlockLogFormatter.php


示例5: execute

 public function execute()
 {
     global $wgContLang;
     $params = $this->extractRequestParams();
     $pageObj = $this->getTitleOrPageId($params, 'fromdbmaster');
     $titleObj = $pageObj->getTitle();
     $errors = $titleObj->getUserPermissionsErrors('protect', $this->getUser());
     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'])));
         }
     }
     $restrictionTypes = $titleObj->getRestrictionTypes();
     $db = $this->getDB();
     $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('create-titleexists');
         }
         if (!$titleObj->exists() && $p[0] != 'create') {
             $this->dieUsageMsg('missingtitle-createonly');
         }
         if (!in_array($p[0], $restrictionTypes) && $p[0] != 'create') {
             $this->dieUsageMsg(array('protect-invalidaction', $p[0]));
         }
         if (!in_array($p[1], $this->getConfig()->get('RestrictionLevels')) && $p[1] != 'all') {
             $this->dieUsageMsg(array('protect-invalidlevel', $p[1]));
         }
         if (wfIsInfinity($expiry[$i])) {
             $expiryarray[$p[0]] = 'infinity';
         } else {
             $exp = strtotime($expiry[$i]);
             if ($exp < 0 || !$exp) {
                 $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' => $wgContLang->formatExpiry($expiryarray[$p[0]], TS_ISO_8601, 'infinite'));
     }
     $cascade = $params['cascade'];
     if ($params['watch']) {
         $this->logFeatureUsage('action=protect&watch');
     }
     $watch = $params['watch'] ? 'watch' : $params['watchlist'];
     $this->setWatch($watch, $titleObj, 'watchdefault');
     $status = $pageObj->doUpdateRestrictions($protections, $expiryarray, $cascade, $params['reason'], $this->getUser());
     if (!$status->isOK()) {
         $this->dieStatus($status);
     }
     $res = array('title' => $titleObj->getPrefixedText(), 'reason' => $params['reason']);
     if ($cascade) {
         $res['cascade'] = true;
     }
     $res['protections'] = $resultProtections;
     $result = $this->getResult();
     ApiResult::setIndexedTagName($res['protections'], 'protection');
     $result->addValue(null, $this->getModuleName(), $res);
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:73,代码来源:ApiProtect.php


示例6: formatExpiry

 private function formatExpiry($expiry)
 {
     if (wfIsInfinity($expiry)) {
         return $this->context->msg('protect-expiry-indefinite')->text();
     }
     $lang = $this->context->getLanguage();
     $user = $this->context->getUser();
     return $this->context->msg('protect-expiring-local', $lang->userTimeAndDate($expiry, $user), $lang->userDate($expiry, $user), $lang->userTime($expiry, $user))->text();
 }
开发者ID:mb720,项目名称:mediawiki,代码行数:9,代码来源:ProtectLogFormatter.php


示例7: parseExpiryInput

 /**
  * Convert a submitted expiry time, which may be relative ("2 weeks", etc) or absolute
  * ("24 May 2034", etc), into an absolute timestamp we can put into the database.
  * @param string $expiry Whatever was typed into the form
  * @return string Timestamp or "infinity" string for the DB implementation
  */
 public static function parseExpiryInput($expiry)
 {
     static $infinity;
     if ($infinity == null) {
         $infinity = wfGetDB(DB_SLAVE)->getInfinity();
     }
     if (wfIsInfinity($expiry)) {
         $expiry = $infinity;
     } else {
         $expiry = strtotime($expiry);
         if ($expiry < 0 || $expiry === false) {
             return false;
         }
         $expiry = wfTimestamp(TS_MW, $expiry);
     }
     return $expiry;
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:23,代码来源:SpecialBlock.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wfIsWindows函数代码示例发布时间:2022-05-23
下一篇:
PHP wfIsHHVM函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap