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


PHP IP::prettifyIP方法代码示例

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


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

示例1: __construct

 /**
  * Construct an IP address representation.
  * @param string $address The textual representation of an IP address or CIDR range.
  */
 public function __construct($address)
 {
     // analyze address format
     $this->is_valid = IP::isIPAddress($address);
     if (!$this->is_valid) {
         return;
     }
     $this->is_ipv4 = IP::isIPv4($address);
     $this->is_ipv6 = !$this->is_ipv4 && IP::isIPv6($address);
     // analyze address range
     $this->is_range = IP::isValidBlock($address);
     $this->encoded_range = IP::parseRange($address);
     $this->range = array(IP::prettifyIP(IP::formatHex($this->encoded_range[self::START])), IP::prettifyIP(IP::formatHex($this->encoded_range[self::END])));
 }
开发者ID:bacoda,项目名称:Wikimedia-contrib,代码行数:18,代码来源:IP.php

示例2: showContributionsRow

 /**
  * Render the contribution of the pagerevision (time, bytes added/deleted, pagename comment)
  * @param Revision $rev
  */
 protected function showContributionsRow(Revision $rev)
 {
     $user = $this->getUser();
     $userId = $rev->getUser(Revision::FOR_THIS_USER, $user);
     if ($userId === 0) {
         $username = IP::prettifyIP($rev->getUserText(Revision::RAW));
         $isAnon = true;
     } else {
         $username = $rev->getUserText(Revision::FOR_THIS_USER, $user);
         $isAnon = false;
     }
     // FIXME: Style differently user comment when this is the case
     if ($rev->userCan(Revision::DELETED_COMMENT, $user)) {
         $comment = $rev->getComment(Revision::FOR_THIS_USER, $user);
         $comment = $this->formatComment($comment, $this->title);
     } else {
         $comment = $this->msg('rev-deleted-comment')->plain();
     }
     $ts = $rev->getTimestamp();
     $this->renderListHeaderWhereNeeded($this->getLanguage()->userDate($ts, $this->getUser()));
     $ts = new MWTimestamp($ts);
     if ($rev->userCan(Revision::DELETED_TEXT, $user)) {
         $diffLink = SpecialPage::getTitleFor('MobileDiff', $rev->getId())->getLocalUrl();
     } else {
         $diffLink = false;
     }
     // FIXME: Style differently user comment when this is the case
     if (!$rev->userCan(Revision::DELETED_USER, $user)) {
         $username = $this->msg('rev-deleted-user')->plain();
     }
     $bytes = null;
     if (isset($this->prevLengths[$rev->getParentId()])) {
         $bytes = $rev->getSize() - $this->prevLengths[$rev->getParentId()];
     }
     $isMinor = $rev->isMinor();
     $this->renderFeedItemHtml($ts, $diffLink, $username, $comment, $rev->getTitle(), $isAnon, $bytes, $isMinor);
 }
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:41,代码来源:SpecialMobileContributions.php

示例3: showRow

 /**
  * Show a row in history, including:
  * time of edit
  * changed bytes
  * name of editor
  * comment of edit
  * @param Revision $rev Revision id of the row wants to show
  * @param Revision|null $prev Revision id of previous Revision to display the difference
  */
 protected function showRow(Revision $rev, $prev)
 {
     $user = $this->getUser();
     $userId = $rev->getUser(Revision::FOR_THIS_USER, $user);
     if ($userId === 0) {
         $username = IP::prettifyIP($rev->getUserText(Revision::RAW));
         $isAnon = true;
     } else {
         $username = $rev->getUserText(Revision::FOR_THIS_USER, $user);
         $isAnon = false;
     }
     // FIXME: Style differently user comment when this is the case
     if ($rev->userCan(Revision::DELETED_COMMENT, $user)) {
         $comment = $rev->getComment(Revision::FOR_THIS_USER, $user);
         $comment = $this->formatComment($comment, $this->title);
     } else {
         $comment = $this->msg('rev-deleted-comment')->plain();
     }
     $ts = $rev->getTimestamp();
     $this->renderListHeaderWhereNeeded($this->getLanguage()->userDate($ts, $this->getUser()));
     $ts = new MWTimestamp($ts);
     $canSeeText = $rev->userCan(Revision::DELETED_TEXT, $user);
     if ($canSeeText && $prev && $prev->userCan(Revision::DELETED_TEXT, $user)) {
         $diffLink = SpecialPage::getTitleFor('MobileDiff', $rev->getId())->getLocalUrl();
     } elseif ($canSeeText && $rev->getTitle() !== null) {
         $diffLink = $rev->getTitle()->getLocalUrl(array('oldid' => $rev->getId()));
     } else {
         $diffLink = false;
     }
     // FIXME: Style differently user comment when this is the case
     if (!$rev->userCan(Revision::DELETED_USER, $user)) {
         $username = $this->msg('rev-deleted-user')->plain();
     }
     // When the page is named there is no need to print it in output
     if ($this->title) {
         $title = null;
     } else {
         $title = $rev->getTitle();
     }
     $bytes = $rev->getSize();
     if ($prev) {
         $bytes -= $prev->getSize();
     }
     $isMinor = $rev->isMinor();
     $this->renderFeedItemHtml($ts, $diffLink, $username, $comment, $title, $isAnon, $bytes, $isMinor);
 }
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:55,代码来源:SpecialMobileHistory.php

示例4: showFeedResultRow

 /**
  * Render a result row in feed view
  * @param object $row a row of db result
  */
 protected function showFeedResultRow($row)
 {
     if ($row->rc_deleted) {
         return;
     }
     $user = $this->getUser();
     $lang = $this->getLanguage();
     $date = $lang->userDate($row->rc_timestamp, $user);
     $this->renderListHeaderWhereNeeded($date);
     $title = Title::makeTitle($row->rc_namespace, $row->rc_title);
     $comment = $this->formatComment($row->rc_comment, $title);
     $ts = new MWTimestamp($row->rc_timestamp);
     $username = $row->rc_user != 0 ? htmlspecialchars($row->rc_user_text) : IP::prettifyIP($row->rc_user_text);
     $revId = $row->rc_this_oldid;
     $bytes = $row->rc_new_len - $row->rc_old_len;
     $isAnon = $row->rc_user == 0;
     $isMinor = $row->rc_minor != 0;
     if ($revId) {
         $diffTitle = SpecialPage::getTitleFor('MobileDiff', $revId);
         $diffLink = $diffTitle->getLocalUrl();
     } else {
         // hack -- use full log entry display
         $diffLink = Title::makeTitle($row->rc_namespace, $row->rc_title)->getLocalUrl();
     }
     $this->renderFeedItemHtml($ts, $diffLink, $username, $comment, $title, $isAnon, $bytes, $isMinor);
 }
开发者ID:GoProjectOwner,项目名称:mediawiki-extensions-MobileFrontend,代码行数:30,代码来源:SpecialMobileWatchlist.php

示例5: userLink

 /**
  * Make user link (or user contributions for unregistered users)
  * @param int $userId User id in database.
  * @param string $userName User name in database.
  * @param string $altUserName Text to display instead of the user name (optional)
  * @return string HTML fragment
  * @since 1.19 Method exists for a long time. $altUserName was added in 1.19.
  */
 public static function userLink($userId, $userName, $altUserName = false)
 {
     $classes = 'mw-userlink';
     if ($userId == 0) {
         $page = SpecialPage::getTitleFor('Contributions', $userName);
         if ($altUserName === false) {
             $altUserName = IP::prettifyIP($userName);
         }
         $classes .= ' mw-anonuserlink';
         // Separate link class for anons (bug 43179)
     } else {
         $page = Title::makeTitle(NS_USER, $userName);
     }
     return self::link($page, htmlspecialchars($altUserName !== false ? $altUserName : $userName), array('class' => $classes));
 }
开发者ID:paladox,项目名称:2,代码行数:23,代码来源:Linker.php

示例6: testPrettifyIP

 /**
  * Test for IP::prettifyIP()
  * @dataProvider provideIPsToPrettify
  */
 public function testPrettifyIP($ip, $prettified)
 {
     $this->assertEquals($prettified, IP::prettifyIP($ip), "Prettify of {$ip}");
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:8,代码来源:IPTest.php

示例7: userLink

 /**
  * Make user link (or user contributions for unregistered users)
  * @param $userId   Integer: user id in database.
  * @param string $userName user name in database.
  * @param string $altUserName text to display instead of the user name (optional)
  * @return String: HTML fragment
  * @since 1.19 Method exists for a long time. $altUserName was added in 1.19.
  */
 public static function userLink($userId, $userName, $altUserName = false)
 {
     if ($userId == 0) {
         $page = SpecialPage::getTitleFor('Contributions', $userName);
         if ($altUserName === false) {
             $altUserName = IP::prettifyIP($userName);
         }
     } else {
         $page = Title::makeTitle(NS_USER, $userName);
     }
     return self::link($page, htmlspecialchars($altUserName !== false ? $altUserName : $userName), array('class' => 'mw-userlink'));
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:20,代码来源:Linker.php

示例8: userLink

 /**
  * Make user link (or user contributions for unregistered users)
  * @param int $userId User id in database.
  * @param string $userName User name in database.
  * @param string $altUserName Text to display instead of the user name (optional)
  * @return string HTML fragment
  * @since 1.16.3. $altUserName was added in 1.19.
  */
 public static function userLink($userId, $userName, $altUserName = false)
 {
     $classes = 'mw-userlink';
     if ($userId == 0) {
         $page = SpecialPage::getTitleFor('Contributions', $userName);
         if ($altUserName === false) {
             $altUserName = IP::prettifyIP($userName);
         }
         $classes .= ' mw-anonuserlink';
         // Separate link class for anons (bug 43179)
     } else {
         $page = Title::makeTitle(NS_USER, $userName);
     }
     // Wrap the output with <bdi> tags for directionality isolation
     return self::link($page, '<bdi>' . htmlspecialchars($altUserName !== false ? $altUserName : $userName) . '</bdi>', ['class' => $classes]);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:24,代码来源:Linker.php


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