XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
point_level_icon.lib.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 
7 function pointLevelIconTrans($matches)
8 {
9  $member_srl = $matches[3];
10  if($member_srl < 1)
11  {
12  return $matches[0];
13  }
14 
15  $orig_text = preg_replace('/' . preg_quote($matches[5], '/') . '<\/' . $matches[6] . '>$/', '', $matches[0]);
16 
17  // Check Group Image Mark
18  $oMemberModel = getModel('member');
19  if($oMemberModel->getGroupImageMark($member_srl))
20  {
21  return $orig_text . $matches[5] . '</' . $matches[6] . '>';
22  }
23 
24  if(!isset($GLOBALS['_pointLevelIcon'][$member_srl]))
25  {
26  // Get point configuration
27  if(!$GLOBALS['_pointConfig'])
28  {
29  $oModuleModel = getModel('module');
30  $GLOBALS['_pointConfig'] = $oModuleModel->getModuleConfig('point');
31  }
32  $config = $GLOBALS['_pointConfig'];
33 
34  // Get point model
35  if(!$GLOBALS['_pointModel'])
36  {
37  $GLOBALS['_pointModel'] = getModel('point');
38  }
39  $oPointModel = &$GLOBALS['_pointModel'];
40 
41  // Get points
42  if(!$oPointModel->isExistsPoint($member_srl))
43  {
44  return $matches[0];
45  }
46 
47  $point = $oPointModel->getPoint($member_srl);
48 
49  // Get level
50  $level = $oPointModel->getLevel($point, $config->level_step);
51  $text = $matches[5];
52 
53  // Get a path where level icon is
54  $level_icon = sprintf('%smodules/point/icons/%s/%d.gif', Context::getRequestUri(), $config->level_icon, $level);
55 
56  // Get per to go to the next level if not a top level
57  $per = NULL;
58  if($level < $config->max_level)
59  {
60  $next_point = $config->level_step[$level + 1];
61  $present_point = $config->level_step[$level];
62  if($next_point > 0)
63  {
64  $per = (int) (($point - $present_point) / ($next_point - $present_point) * 100);
65  $per = $per . '%';
66  }
67  }
68 
69  $title = sprintf('%s:%s%s%s, %s:%s/%s', Context::getLang('point'), $point, $config->point_name, $per ? ' (' . $per . ')' : '', Context::getLang('level'), $level, $config->max_level);
70  $alt = sprintf('[%s:%s]', Context::getLang('level'), $level);
71 
72  $GLOBALS['_pointLevelIcon'][$member_srl] = sprintf('<img src="%s" alt="%s" title="%s" class="xe_point_level_icon" style="vertical-align:middle;margin-right:3px;" />', $level_icon, $alt, $title);
73  }
74  $text = $GLOBALS['_pointLevelIcon'][$member_srl];
75 
76  return $orig_text . $text . $matches[5] . '</' . $matches[6] . '>';
77 }
78 
79 /* End of file point_level_icon.lib.php */
80 /* Location: ./addons/point_level_icon/point_level_icon.lib.php */
$oModuleModel
Definition: ko.install.php:236
pointLevelIconTrans($matches)
Function to change point icon.
if(file_exists(_XE_PATH_. 'config/config.user.inc.php')) if(!defined('__DEBUG__')) if(!defined('__DEBUG_OUTPUT__')) if(!defined('__DEBUG_PROTECT__')) if(!defined('__DEBUG_PROTECT_IP__')) if(!defined('__DEBUG_DB_OUTPUT__')) if(!defined('__LOG_SLOW_QUERY__')) if(!defined('__LOG_SLOW_TRIGGER__')) if(!defined('__LOG_SLOW_ADDON__')) if(!defined('__LOG_SLOW_WIDGET__')) if(!defined('__DEBUG_QUERY__')) if(!defined('__OB_GZHANDLER_ENABLE__')) if(!defined('__ENABLE_PHPUNIT_TEST__')) if(!defined('__PROXY_SERVER__')) if(!defined('__ERROR_LOG__')) if(!defined('__DISABLE_DEFAULT_CSS__')) if(!defined('__AUTO_OPCACHE_INVALIDATE__')) if((__DEBUG_OUTPUT__==2)&&version_compare(PHP_VERSION, '6.0.0')===-1) if(version_compare(PHP_VERSION, '5.3.0') >=0) $GLOBALS['__xe_autoload_file_map']
Definition: config.inc.php:324
getLang($code)
getRequestUri($ssl_mode=FOLLOW_REQUEST_SSL, $domain=null)
getModel($module_name)
Definition: func.inc.php:145