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


PHP wAvatar::getAvatarHtml方法代码示例

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


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

示例1: execute

 public function execute()
 {
     $user = $this->getUser();
     // Blocked users cannot submit new comments, and neither can those users
     // without the necessary privileges. Also prevent obvious cross-site request
     // forgeries (CSRF)
     $id = $this->getMain()->getVal('userid');
     $name = $this->getMain()->getVal('username');
     $size = $this->getMain()->getVal('size');
     if ($id == '') {
         if ($name != '') {
             $id = User::idFromName($name);
         } else {
             $id = 0;
         }
     }
     if ($size = '') {
         $size = 'l';
     }
     $avatar = new wAvatar($id, $size);
     $responseBody = array('state' => 200, 'message' => '', 'html' => $avatar->getAvatarHtml(), 'url' => $avatar->getAvatarUrlPath());
     $result = $this->getResult();
     $result->addValue($this->getModuleName(), 'res', $responseBody);
     return true;
 }
开发者ID:Reasno,项目名称:SocialProfile,代码行数:25,代码来源:AvatarShow.api.php

示例2: renderSiteAvatarParserFunction

 /**
  * Function to render the {{#siteavatar:Prefix}} function
  *
  * @param Parser $parser: MW parser object
  * @param string $username: Username of user to show avatar for
  * @param string $size: Size of avatar to return (s/m/ml/l), or px value (100px, 10px, etc)
  * @return array: output of function, and options for the parser
  */
 static function renderSiteAvatarParserFunction($parser, $prefix = '', $givenSize = 'm')
 {
     global $wgUploadPath;
     $sizes = array('s', 'm', 'ml', 'l');
     if (in_array($givenSize, $sizes)) {
         // if given size is a code,
         $size = $givenSize;
         // use code,
         $px = '';
         // and leave px value empty
     } elseif (substr($givenSize, -2) == 'px') {
         //given size is a value in px
         $givenPx = intval(substr($givenSize, 0, strlen($givenSize) - 2));
         //get int value of given px size
         if (!is_int($givenPx)) {
             // if px value is not int
             $size = 'm';
             // give default avatar
             $px = '';
             // with no px value
         }
         if ($givenPx <= 16) {
             // if given px value is smaller than small,
             $size = 's';
             // use the small avatar,
             $px = $givenSize;
             // and the given px value
         } elseif ($givenPx <= 30) {
             // if given px value is smaller than medium,
             $size = 'm';
             // use the medium avatar,
             $px = $givenSize;
             // and the given px value
         } elseif ($givenPx <= 50) {
             // if given px value is smaller than medium-large,
             $size = 'ml';
             // use the medium-large avatar,
             $px = $givenSize;
             // and the given px value
         } else {
             // if given px value is bigger then medium large,
             $size = 'l';
             // use the large avatar,
             $px = $givenSize;
             // and the given px value
         }
     } else {
         // size value is not code or px
         $size = 'm';
         // give default avatar
         $px = '';
         // with no px value
     }
     if (HuijiPrefix::hasPrefix($prefix)) {
         $id = $prefix;
         $avatar = new wSiteAvatar($id, $size);
     } else {
         // Fallback for the case where an invalid (nonexistent) user name
         // was supplied...
         $avatar = new wAvatar(-1, 'm');
         // not very nice, but -1 will get the default avatar
     }
     if ($px) {
         // if px value needed, set height to it
         $output = $avatar->getAvatarHtml(array('height' => $px));
     } else {
         // but if not needed, don't
         $output = $avatar->getAvatarHtml();
     }
     return array($output, 'noparse' => true, 'isHTML' => true);
 }
开发者ID:volvor,项目名称:SocialProfile,代码行数:79,代码来源:AvatarParserFunction.php

示例3: simplifyPageActivity

 /**
  * @param $type String: activity type, such as 'friend' or 'foe' or 'edit'
  * @param $has_page Boolean: true by default
  */
 function simplifyPageActivity($type, $has_page = true)
 {
     global $wgLang, $wgMemc;
     if (!isset($this->items_grouped[$type]) || !is_array($this->items_grouped[$type])) {
         return '';
     }
     foreach ($this->items_grouped[$type] as $page_name => $page_data) {
         $timeago = HuijiFunctions::getTimeAgo($page_data['timestamp']) . '前';
         $key = wfForeignMemcKey('huiji', '', 'simplifyPageActivity', $type, $page_name, $page_data['timestamp'], count($page_data['users']), $this->show_following_sites);
         if (isset($this->displayed[$type][$page_name])) {
             continue;
         }
         $users = '';
         $pages = '';
         if ($type == 'friend' || $type == 'foe' || $type == 'user_message' || $type == 'user_user_follow') {
             $page_title = Title::newFromText($page_name, NS_USER);
         } elseif ($type == 'user_site_follow') {
             $page_title = Title::newFromText($page_name . ':');
         } elseif ($type == 'image_upload') {
             $page_title = Title::newFromText($page_name, NS_FILE);
         } else {
             $page_title = Title::newFromText($page_name);
         }
         $count_users = count($page_data['users']);
         $user_index = 0;
         $pages_count = 0;
         // Init empty variable to be used later on for GENDER processing
         // if the event is only for one user.
         $userNameForGender = '';
         foreach ($page_data['users'] as $user_name => $action) {
             /* get rid of same actions more than 1/2 day ago */
             // if ( $page_data['timestamp'] < $this->half_day_ago ) {
             // 	continue;
             // }
             $count_actions = count($action);
             if ($has_page && !isset($this->displayed[$type][$page_name])) {
                 $this->displayed[$type][$page_name] = 1;
                 $pages .= $this->fixPageTitle($page_title, $page_data);
                 /* get User Avatar for display */
                 if ($this->show_following_sites) {
                     $avatar = new wSiteAvatar($page_data['prefix'][0], 'ml');
                 } else {
                     $avatar = new wAvatar(User::idFromName($user_name), 'ml');
                 }
                 $avatarUrl = $avatar->getAvatarHtml();
                 if ($count_users == 1 && $count_actions > 1) {
                     $pages .= wfMessage('word-separator')->text();
                     $pages .= wfMessage('parentheses', wfMessage("useractivity-group-{$type}", $count_actions, $user_name)->text())->text();
                 }
                 $pages_count++;
             }
             // Single user on this action,
             // see if we can stack any other singles
             if ($count_users == 1) {
                 $userNameForGender = $user_name;
                 foreach ($this->items_grouped[$type] as $page_name2 => $page_data2) {
                     // if we find singles for this type, not displayed and not co-worked.
                     if (!isset($this->displayed[$type][$page_name2]) && count($page_data2['users']) == 1) {
                         //change since sept.7: only group pages with same prefix.
                         if (isset($page_data['prefix']) && $page_data['prefix'][0] != $page_data2['prefix'][0]) {
                             continue;
                         }
                         // don't stack the old ones.
                         /* get rid of same actions more than 1/2 day ago */
                         if ($page_data2['timestamp'] < $page_data['timestamp'] - $this->half_a_day || $page_data2['timestamp'] > $page_data['timestamp']) {
                             continue;
                         }
                         foreach ($page_data2['users'] as $user_name2 => $action2) {
                             if ($user_name2 == $user_name && $pages_count < $this->item_max) {
                                 $count_actions2 = count($action2);
                                 if ($type == 'friend' || $type == 'foe' || $type == 'user_message' || $type == 'user_user_follow') {
                                     $page_title2 = Title::newFromText($page_name2, NS_USER);
                                 } elseif ($type == 'user_site_follow') {
                                     $page_title2 = Title::newFromText($page_name2 . ':');
                                 } elseif ($type == 'image_upload') {
                                     $page_title2 = Title::newFromText($page_name2, NS_FILE);
                                 } else {
                                     $page_title2 = Title::newFromText($page_name2);
                                 }
                                 if ($pages) {
                                     $pages .= $page_title2->inNamespace(NS_FILE) ? '' : ',';
                                 }
                                 $pages .= $this->fixPageTitle($page_title2, $page_data2);
                                 if ($count_actions2 > 1) {
                                     $pages .= ' (' . wfMessage("useractivity-group-{$type}", $count_actions2)->text() . ')';
                                 }
                                 $pages_count++;
                                 // if (isset($page_data['prefix'])){
                                 // 	$page_data['prefix'] = array_merge($page_data['prefix'], $page_data2['prefix']);
                                 // }
                                 $this->displayed[$type][$page_name2] = 1;
                             }
                         }
                     }
                 }
             }
//.........这里部分代码省略.........
开发者ID:volvor,项目名称:SocialProfile,代码行数:101,代码来源:UserActivityClass.php


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