mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
Added setScVar() function to shortcode handler, modified forum and news to use new function. More work on new level handler, implemented it in forum shortcodes.
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/level_handler.php,v $
|
||||
| $Revision: 1.8 $
|
||||
| $Date: 2009-01-18 16:47:41 $
|
||||
| $Revision: 1.9 $
|
||||
| $Date: 2009-01-25 17:44:13 $
|
||||
| $Author: mcfly_e107 $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -118,6 +118,7 @@ class e107UserRank
|
||||
{
|
||||
|
||||
var $ranks = array();
|
||||
var $userRanks = array();
|
||||
|
||||
function e107UserRank()
|
||||
{
|
||||
@@ -166,22 +167,26 @@ class e107UserRank
|
||||
}
|
||||
}
|
||||
|
||||
function _getImage($info)
|
||||
function _getImage(&$info)
|
||||
{
|
||||
if($info['lan_pfx'])
|
||||
$img = $info['image'];
|
||||
if($info['lan_pfx'] && strpos('_', $info['image']))
|
||||
{
|
||||
$_tmp = explode('_', $info['image'], 2);
|
||||
return e_LANGUAGE.'_'.$tmp[1];
|
||||
$img = e_LANGUAGE.'_'.$_tmp[1];
|
||||
}
|
||||
return $info['image'];
|
||||
return e_IMAGE_ABS.'ranks/'.$img;
|
||||
}
|
||||
|
||||
function getRanks($userId)
|
||||
{
|
||||
$e107 = e107::getInstance();
|
||||
if(!$userId && USER) { $userId = USERID; }
|
||||
if($ret = getcachedvars('userRankInfo_'.$userId)) { return $ret; }
|
||||
|
||||
if(isset($this->userRanks[$userId]))
|
||||
{
|
||||
return $this->userRanks[$userId];
|
||||
}
|
||||
|
||||
$ret = array();
|
||||
$userData = get_user_data($userId);
|
||||
if($userData['user_admin'])
|
||||
@@ -189,16 +194,16 @@ class e107UserRank
|
||||
if($userData['user_perms'] == '0')
|
||||
{
|
||||
//Main Site Admin
|
||||
$ret['special'] = "<img src='".$this->_getImage($this->ranks['special'][1]['image'])."' /><br />";
|
||||
$data['special'] = "<img src='".$this->_getImage($this->ranks['special'][1])."' /><br />";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Site Admin
|
||||
$ret['special'] = "<img src='".$this->_getImage($this->ranks['special'][2]['image'])."' /><br />";
|
||||
$data['special'] = "<img src='".$this->_getImage($this->ranks['special'][2])."' /><br />";
|
||||
}
|
||||
}
|
||||
|
||||
$userData['daysregged'] = max(1, round((time() - $userData['user_join']) / 86400));
|
||||
$userData['user_daysregged'] = max(1, round((time() - $userData['user_join']) / 86400));
|
||||
$level = $this->_calcLevel($userData);
|
||||
|
||||
$lastRank = count($this->ranks['data']) - 1;
|
||||
@@ -209,7 +214,7 @@ class e107UserRank
|
||||
}
|
||||
elseif($level >= $this->ranks['data'][$lastRank]['thresh'])
|
||||
{
|
||||
$rank = 9;
|
||||
$rank = $lastRank;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -226,28 +231,27 @@ class e107UserRank
|
||||
{
|
||||
$data['name'] = '[ '.$e107->tp->toHTML($this->ranks['data'][$rank]['name'], FALSE, 'defs').' ]';
|
||||
$img_title = ($this->ranks['data'][$rank]['name'] ? "title='".$this->ranks['data'][$rank]['name']."'" : '');
|
||||
$data['pic'] = "<img {$img_title} src='".$this->_getImage($this->ranks['data'][$rank]['image'])."' /><br />";
|
||||
|
||||
cachevars('userRankInfo_'.$userId, $data);
|
||||
return $data;
|
||||
$data['pic'] = "<img {$img_title} src='".$this->_getImage($this->ranks['data'][$rank])."' /><br />";
|
||||
}
|
||||
$this->userRanks[$userId] = $data;
|
||||
return $data;
|
||||
}
|
||||
|
||||
function _calcLevel(&$userData)
|
||||
{
|
||||
var_dump($this->ranks['config']);
|
||||
global $pref;
|
||||
$value = 0;
|
||||
$calc = $this->ranks['config']['calc'];
|
||||
$calc = $pref['ranks_calc'];
|
||||
$search = array();
|
||||
$replace = array();
|
||||
foreach($this->ranks['config']['fields'] as $f)
|
||||
foreach(explode(',', $pref['ranks_flist']) as $f)
|
||||
{
|
||||
$search[] = $f['name'];
|
||||
$replace[] = $userData[$f['name']];
|
||||
$search[] = '{'.$f.'}';
|
||||
$replace[] = $userData['user_'.$f];
|
||||
}
|
||||
$calc = str_replace($search, $replace, $calc);
|
||||
$calc = '$userLevelValue = '.str_replace($search, $replace, $calc).';';
|
||||
$value = eval($calc);
|
||||
return $value;
|
||||
return $userLevelValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -9,9 +9,9 @@
|
||||
* News handler
|
||||
*
|
||||
* $Source: /cvs_backup/e107_0.8/e107_handlers/news_class.php,v $
|
||||
* $Revision: 1.12 $
|
||||
* $Date: 2009-01-18 00:27:10 $
|
||||
* $Author: secretr $
|
||||
* $Revision: 1.13 $
|
||||
* $Date: 2009-01-25 17:44:13 $
|
||||
* $Author: mcfly_e107 $
|
||||
*/
|
||||
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
@@ -236,8 +236,8 @@ class news {
|
||||
$loop_uid = $news['news_author'];
|
||||
|
||||
require_once(e_FILE.'shortcode/batch/news_shortcodes.php');
|
||||
$e107->tp->e_sc->scClasses['news_shortcodes']->news_item = $news;
|
||||
$e107->tp->e_sc->scClasses['news_shortcodes']->param = $param;
|
||||
setScVar('news_shortcodes', 'news_item', $news);
|
||||
setScVar('news_shortcodes', 'param', $param);
|
||||
$text = $e107->tp->parseTemplate($NEWS_PARSE, true);
|
||||
|
||||
if ($mode == 'return')
|
||||
|
@@ -12,8 +12,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/shortcode_handler.php,v $
|
||||
| $Revision: 1.23 $
|
||||
| $Date: 2009-01-16 01:02:41 $
|
||||
| $Revision: 1.24 $
|
||||
| $Date: 2009-01-25 17:44:13 $
|
||||
| $Author: mcfly_e107 $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@@ -25,6 +25,21 @@ function register_shortcode($classFunc, $codes, $path='', $force=false)
|
||||
$e107 = e107::getInstance();
|
||||
$sc = &$e107->tp->e_sc;
|
||||
|
||||
//If codes is set to true, let's go get a list of shortcode methods
|
||||
if(is_bool($codes) && $codes === true)
|
||||
{
|
||||
$codes = array();
|
||||
$tmp = get_class_methods($classFunc);
|
||||
foreach($tmp as $c)
|
||||
{
|
||||
if(strpos($c, 'get_') === 0)
|
||||
{
|
||||
$codes[] = substr($c, 4);
|
||||
}
|
||||
}
|
||||
unset($tmp);
|
||||
}
|
||||
|
||||
//We only register these shortcodes if they have not already been registered in some manner
|
||||
//ie theme or other plugin .sc files
|
||||
if(is_array($codes))
|
||||
@@ -48,6 +63,12 @@ function register_shortcode($classFunc, $codes, $path='', $force=false)
|
||||
}
|
||||
}
|
||||
|
||||
function setScVar($scName, $scVar, &$value)
|
||||
{
|
||||
$e107 = e107::getInstance();
|
||||
$e107->tp->e_sc->scClasses[$scName]->$scVar = $value;
|
||||
}
|
||||
|
||||
function initShortcodeClass($class)
|
||||
{
|
||||
$e107 = e107::getInstance();
|
||||
@@ -235,10 +256,16 @@ class e_shortcode
|
||||
}
|
||||
$this->scClasses[$_class] = new $_class;
|
||||
}
|
||||
if(is_callable(array($_class, $_method)))
|
||||
if(method_exists($this->scClasses[$_class], $_method))
|
||||
{
|
||||
|
||||
$ret = $this->scClasses[$_class]->$_method($parm, $sc_mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
echo $_class.'::'.$_method.' NOT FOUND!<br />';
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'func':
|
||||
|
Reference in New Issue
Block a user