Merge pull request #86 from kleeja-official/MitanOmar-patch-1

update plugins from kleeja admin control panel
This commit is contained in:
Mitan Omar
2019-05-03 08:34:25 +02:00
committed by GitHub
7 changed files with 408 additions and 98 deletions

View File

@@ -3,7 +3,7 @@
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="./">{lang.R_CPINDEX}</a></li>
<li class="breadcrumb-item active">{lang.R_CALLS}</li>
<IF NAME="current_smt == show_h24"><li class="breadcrumb-item active"> {lang.SHOW_FROM_24H}</li></IF>
<IF NAME="current_smt == 'show_h24'"><li class="breadcrumb-item active"> {lang.SHOW_FROM_24H}</li></IF>
</ol>

View File

@@ -6,25 +6,36 @@
</ol>
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link (case == installed?active:)" href="{action}">{lang.INSTALLED_PLUGINS}</a>
</li>
<li class="nav-item">
<a class="nav-link (case == local?active:)" href="{action}&amp;case=local">{lang.LOCAL_PLUGINS}</a>
</li>
<li class="nav-item">
<a class="nav-link (case == store?active:)" href="{action}&amp;case=store">{lang.KLEEJA_STORE}</a>
</li>
<li class="nav-item">
<a class="nav-link (case == check?active:)" href="{action}&amp;case=check">{lang.R_CHECK_UPDATE}</a>
</li>
</ul>
<IF NAME="no_plugins">
<div class="alert alert-info">
{lang.NO_PLUGINS}
<br>
<br>
<a class="btn btn-primary btn-lg text-center" href="#" data-toggle="modal" data-target="#plugin_add_new">
<i class="fa fa-upload"></i> {lang.UPLOAD_LOCAL_PC}
</a>
</div>
<!-- installed plugins -->
<IF NAME="case == installed">
<ELSE>
<IF NAME="no_plugins">
<div class="alert alert-info my-1">
{lang.NO_PLUGINS}
</div>
</IF>
<IF NAME="installed_plugins">
<div class="row">
<LOOP NAME="installed_plugins">
<div class="col-sm-12 col-md-3 mt-2">
<div class="card">
<img class="card-img-top" src="{{icon}}" alt="{{plg_name}}">
@@ -60,24 +71,23 @@
</div>
</div>
</LOOP>
</div>
<br>
<hr>
</IF>
<!-- available plugins -->
<nav class="breadcrumb">
<!-- ..... -->
<!-- local plugins -->
<!-- ..... -->
<ELSEIF NAME="case == local">
<nav class="breadcrumb my-2">
<div class="breadcrumb-item align-middle">{lang.ADD_NEW_PLUGIN}</div>
<a class="btn btn-primary btn-sm float-right" href="#" data-toggle="modal" data-target="#plugin_add_new">
<a class="btn btn-primary btn-sm float-right mx-1" href="#" data-toggle="modal" data-target="#plugin_add_new">
<i class="fa fa-upload"></i> {lang.UPLOAD_LOCAL_PC}
</a>
<a class="btn btn-primary btn-sm float-right mx-1" href="{action}&amp;case=store">
<i class="fa fa-puzzle-piece"></i> {lang.KLEEJA_STORE}
</a>
</nav>
<br>
<ul class="list-unstyled list-group">
@@ -93,11 +103,6 @@
</LOOP>
</ul>
</IF>
<!-- new plugin modal -->
<div id="plugin_add_new" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="addNewPlugin" aria-hidden="true">
@@ -127,3 +132,68 @@
</form>
</div>
<!-- end new plugin modal -->
<!-- ...... -->
<!-- store/check -->
<!-- ..... -->
<ELSEIF NAME="case == store" OR="case == check">
<IF NAME="no_store_plugins">
<div class="alert alert-info my-3">
<IF NAME="case == check">{lang.ALL_PLUGINS_UPDATED}<ELSE>{lang.NO_PLUGINS}</IF>
</div>
</IF>
<ul class="list-unstyled list-group mt-2">
<LOOP NAME="store_plugins">
<li class="media d-flex justify-content-between list-group-item">
<img class="mr-3 rounded-circle" src="{{icon}}" alt="{{title}}" style="width: 75px">
<div class="media-body">
<h5 class="mt-0 mb-2">{{title}}</h5>
<!-- Button trigger modal -->
<div class="d-flex justify-content-between">
<div style="direction: ltr;"><IF NAME="case == check">{{current_version}} → </IF>{{version}}</div>
<button type="button" class="btn btn-primary pull-(lang.DIR==ltr?right:left)" data-toggle="modal" data-target="#Modal_{{name}}">
<IF NAME="case == check">{lang.UPDATE}<ELSE>{lang.VIEW}</IF>
</button>
</div>
<!-- Modal -->
<div class="modal fade" id="Modal_{{name}}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="exampleModalLabel">{{title}}</h4>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<ul class="list-group list-group-flush">
<li class="list-group-item">
{lang.DEVELOPER}: {{developer}}
<IF LOOP="website"> <i class="fa fa-download" title="{lang.ENABLE}"></i><a href="{{website}}" target="_tab"><i class="fa fa-external-link" title="{lang.ENABLE}"></i></a></IF>
</li>
<li class="list-group-item">{lang.VERSION}: {{version}}</li>
<li class="list-group-item">{{kj_version_cmtp}}</li>
<IF LOOP="NotCompatible">
<li class="list-group-item list-group-item-danger">
{lang.PLUGIN_N_CMPT_KLJ}
</li>
</IF>
</ul>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{lang.CLOSE}</button>
<a class="btn btn-primary" href="{plugin_download_link}{{name}}" title="Install">{lang.INSTALL} <i class="fa fa-download" title="Download"></i></a>
</div>
</div>
</div>
</div>
<!-- end modal -->
</div>
</li>
</LOOP>
</ul>
</IF>

View File

@@ -20,7 +20,7 @@ if (!defined('IN_ADMIN'))
#get current case
$case = g('case', 'str');
$case = g('case', 'str', 'installed');
#set _get form key
$GET_FORM_KEY = kleeja_add_form_key_get('PLUGINS_FORM_KEY');
@@ -32,14 +32,17 @@ $plugin_install_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&amp;
$plugin_uninstall_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&amp;case=uninstall&amp;' . $GET_FORM_KEY . '&amp;plg=';
$plugin_enable_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&amp;case=enable&amp;' . $GET_FORM_KEY . '&amp;plg=';
$plugin_disable_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&amp;case=disable&amp;' . $GET_FORM_KEY . '&amp;plg=';
$plugin_download_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&amp;case=download&amp;' . $GET_FORM_KEY . '&amp;plg=';
$plugin_update_link = ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '&amp;case=update&amp;' . $GET_FORM_KEY . '&amp;plg=';
//check _GET Csrf token
if ($case && in_array($case, array('install', 'uninstall', 'enable', 'disable')))
if (!empty($case) && in_array($case, array('install', 'uninstall', 'enable', 'disable' , 'download' , 'update')))
{
if (!kleeja_check_form_key_get('PLUGINS_FORM_KEY'))
{
kleeja_admin_err($lang['INVALID_GET_KEY'], $action);
exit;
}
}
@@ -49,6 +52,7 @@ if(ip('newplugin'))
if(!kleeja_check_form_key('adm_plugins'))
{
kleeja_admin_err($lang['INVALID_FORM_KEY'], true, $lang['ERROR'], true, $action);
exit;
}
$case = 'upload';
@@ -57,6 +61,9 @@ if(ip('newplugin'))
switch ($case):
default:
case 'local':
case 'store':
case 'check':
# Get installed plugins
$query = array(
@@ -115,7 +122,8 @@ switch ($case):
$available_plugins = array();
while (false !== ($folder_name = readdir($dh)))
{
if (is_dir(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $folder_name) && preg_match('/[a-z0-9_.]{3,}/', $folder_name)) {
if (is_dir(PATH . KLEEJA_PLUGINS_FOLDER . '/' . $folder_name) && preg_match('/[a-z0-9_.]{3,}/', $folder_name))
{
if (empty($installed_plugins[$folder_name]))
{
array_push($available_plugins,
@@ -136,32 +144,87 @@ switch ($case):
$stylee = "admin_plugins";
break;
//do not proceed if not store case
if(! in_array($case, ['store', 'check']))
{
break;
}
// plugins avilable in kleeja remote catalog
if (!($catalog_plugins = $cache->get('catalog_plugins')))
{
$store_link = 'https://raw.githubusercontent.com/kleeja-official/plugin-catalog/master/plugins.json';
$catalog_plugins = fetch_remote_file($store_link);
$catalog_plugins = json_decode($catalog_plugins , true);
if(json_last_error() == JSON_ERROR_NONE)
{
$cache->save('catalog_plugins', $catalog_plugins);
}
}
// make an array for all plugins in kleeja remote catalog
// that are not exsisted locally.
$store_plugins = array();
$available_plugins_names = array_column($available_plugins, 'name');
foreach ($catalog_plugins as $plugin_info)
{
if ($case == 'store' && (in_array($plugin_info['name'] , $available_plugins_names) ||
! empty($installed_plugins[$plugin_info['name']]) )
)
{
continue;
}
// is there a new version of this in the store
elseif ($case == 'check' && (! empty($installed_plugins[$plugin_info['name']]) &&
version_compare(
strtolower($installed_plugins[$plugin_info['name']]['extra_info']['plugin_version']),
strtolower($plugin_info['file']['version']),
'>=') || empty($installed_plugins[$plugin_info['name']]))
) {
continue;
}
$store_plugins[$plugin_info['name']] = array(
'name' => $plugin_info['name'],
'developer' => $plugin_info['developer'],
'version' => $plugin_info['file']['version'],
'title' => ! empty($plugin_info['title'][$config['language']]) ? $plugin_info['title'][$config['language']] : $plugin_info['title']['en'],
'website' => $plugin_info['website'],
'current_version' => ! empty($installed_plugins[$plugin_info['name']]) ? strtolower($installed_plugins[$plugin_info['name']]['extra_info']['plugin_version']) : '',
'kj_min_version' => $plugin_info['kleeja_version']['min'],
'kj_max_version' => $plugin_info['kleeja_version']['max'],
'kj_version_cmtp' => sprintf($lang[ 'KLJ_VER_NO_PLUGIN'], $plugin_info['kleeja_version']['min'], $plugin_info['kleeja_version']['max']),
'icon' => $plugin_info['icon'] ,
'NotCompatible' => version_compare(strtolower($plugin_info['kleeja_version']['min']), KLEEJA_VERSION , '<=')
&& version_compare(strtolower($plugin_info['kleeja_version']['max']), KLEEJA_VERSION , '>=')
? false : true,
);
}
$no_store_plugins = sizeof($store_plugins) == 0;
break;
//
//upload a plugin
//
case 'upload':
$ERRORS = array();
if(intval($userinfo['founder']) !== 1)
{
$ERRORS[] = $lang['HV_NOT_PRVLG_ACCESS'];
}
#is uploaded?
if(empty($_FILES['plugin_file']['tmp_name']))
{
$ERRORS[] = $lang['CHOSE_F'];
}
#extract it to plugins folder
if(!sizeof($ERRORS))
{
@@ -192,14 +255,13 @@ switch ($case):
@unlink($_FILES['plugin_file']['tmp_name']);
}
if(!sizeof($ERRORS))
{
kleeja_admin_info($lang['NO_PROBLEM_AFTER_ZIP'], true, '', true, $action);
}
else
{
kleeja_admin_err('- ' . implode('<br>- ', $ERRORS), ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
kleeja_admin_err('- ' . implode('<br>- ', $ERRORS), true, '', true, ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
}
break;
@@ -210,17 +272,14 @@ switch ($case):
//
case 'install':
if(intval($userinfo['founder']) !== 1)
{
kleeja_admin_err($lang['HV_NOT_PRVLG_ACCESS'], ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
exit;
}
$plg_name = g('plg', 'str');
if (empty($plg_name))
{
if (defined('DEBUG'))
@@ -246,7 +305,7 @@ switch ($case):
#if already installed, show a message
if (!empty(Plugins::getInstance()->installed_plugin_info($plg_name)))
{
kleeja_admin_info($lang['PLUGIN_EXISTS_BEFORE'], ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
kleeja_admin_info($lang['PLUGIN_EXISTS_BEFORE'], true, '', true, ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
exit;
}
@@ -267,7 +326,6 @@ switch ($case):
$plugin_first_run = $kleeja_plugin[$plg_name]['first_run']['en'];
}
#check if compatible with kleeja
#'plugin_kleeja_version_min' => '1.8',
# Max version of Kleeja that's required to run this plugin
@@ -275,7 +333,10 @@ switch ($case):
if (version_compare(KLEEJA_VERSION, $plugin_info['plugin_kleeja_version_min'], '<'))
{
kleeja_admin_info($lang['PLUGIN_N_CMPT_KLJ'] . '<br>k:' . KLEEJA_VERSION . '|<|p.min:' . $plugin_info['plugin_kleeja_version_min'], ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
kleeja_admin_info(
$lang['PLUGIN_N_CMPT_KLJ'] . '<br>k:' . KLEEJA_VERSION . '|<|p.min:' . $plugin_info['plugin_kleeja_version_min'],
true, '', true, ADMIN_PATH . '?cp=' . basename(__file__, '.php')
);
exit;
}
@@ -283,20 +344,21 @@ switch ($case):
{
if (version_compare(KLEEJA_VERSION, $plugin_info['plugin_kleeja_version_max'], '>'))
{
kleeja_admin_info($lang['PLUGIN_N_CMPT_KLJ'] . '<br>k:' . KLEEJA_VERSION . '|>|p.max:' . $plugin_info['plugin_kleeja_version_max'], ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
kleeja_admin_info(
$lang['PLUGIN_N_CMPT_KLJ'] . '<br>k:' . KLEEJA_VERSION . '|>|p.max:' . $plugin_info['plugin_kleeja_version_max'],
true, '', true, ADMIN_PATH . '?cp=' . basename(__file__, '.php')
);
exit;
}
}
delete_cache('', true);
if (is_array($plugin_info['plugin_description']))
{
$plugin_info['plugin_description'] = !empty($plugin_info['plugin_description']['en']) ? $plugin_info['plugin_description']['en'] : $plugin_info['plugin_description'][0];
}
#add to database
$insert_query = array(
'INSERT' => '`plg_name` ,`plg_ver`, `plg_author`, `plg_dsc`, `plg_icon`, `plg_uninstall`, `plg_instructions`, `plg_store`, `plg_files`',
@@ -306,14 +368,12 @@ switch ($case):
$SQL->build($insert_query);
#may God protect you brother.
if(is_callable($install_callback))
{
$install_callback($SQL->insert_id());
}
#show done, msg
$text = '<h3>' . $lang['NEW_PLUGIN_ADDED'] . '</h3>';
if ($plugin_first_run)
@@ -332,8 +392,6 @@ switch ($case):
break;
//
//uninstall a plugin
//
@@ -345,16 +403,15 @@ switch ($case):
exit;
}
$plg_name = g('plg', 'str');
if (empty($plg_name))
{
if (defined('DEV_STAGE'))
{
exit('empty($plg_name)');
}
//no plugin selected? back
redirect(ADMIN_PATH . "?cp=" . basename(__file__, '.php'));
}
@@ -390,16 +447,13 @@ switch ($case):
'WHERE' => "plg_name='" . $SQL->escape($plg_name) . "'"
);
$result = $SQL->build($query);
$pluginDatabaseInfo = $SQL->fetch($result);
#sad to see you go, brother
$uninstall_callback(!empty($pluginDatabaseInfo) ? $pluginDatabaseInfo['plg_id'] : 0);
delete_cache('', true);
#remove from database
@@ -414,7 +468,6 @@ switch ($case):
$text = '<h3>' . $lang['PLUGIN_DELETED'] . '</h3>';
$text .= '<script type="text/javascript"> setTimeout("get_kleeja_link(\'' . ADMIN_PATH . '?cp=' . basename(__file__, '.php') . '\');", 2000);</script>' . "\n";
$stylee = 'admin_info';
}
@@ -422,7 +475,7 @@ switch ($case):
//
//disable a plugin
// disable a plugin
//
case 'disable':
case 'enable':
@@ -433,10 +486,8 @@ switch ($case):
exit;
}
$plg_name = g('plg', 'str');
if (empty($plg_name))
{
if (defined('DEV_STAGE'))
@@ -458,7 +509,6 @@ switch ($case):
$SQL->build($update_query);
delete_cache('', true);
#show done, msg
@@ -471,5 +521,131 @@ switch ($case):
break;
case 'download':
if(intval($userinfo['founder']) !== 1)
{
kleeja_admin_err($lang['HV_NOT_PRVLG_ACCESS'], ADMIN_PATH . '?cp=' . basename(__file__, '.php'));
exit;
}
$download_plugin = g('plg');
// update it , rename function doesn't move the folder , if the folder is exists on the new dir
if( file_exists( PATH . KLEEJA_PLUGINS_FOLDER. '/' . $download_plugin . '/init.php' ) )
{
redirect( $plugin_update_link . $download_plugin );
exit;
}
// plugins avilable in kleeja store
$store_link = 'https://raw.githubusercontent.com/kleeja-official/plugin-catalog/master/plugins.json';
$catalog_plugins = fetch_remote_file($store_link);
if ($catalog_plugins)
{
$catalog_plugins = json_decode($catalog_plugins , true);
$store_plugins = array();
// make an arry for all plugins in kleeja store that not included in our server
foreach ($catalog_plugins as $plugin_info)
{
$store_plugins[$plugin_info['name']] = array(
'name' => $plugin_info['name'] ,
'plg_version' => $plugin_info['file']['version'] ,
'url' => $plugin_info['file']['url'] ,
'kj_min_version' => $plugin_info['kleeja_version']['min'] ,
'kj_max_version' => $plugin_info['kleeja_version']['max'] ,
);
}
// // => this plugin is hosted in our store
if (isset($store_plugins[$download_plugin]))
{
// check if the version of the plugin is compatible with our kleeja version or not
if (
version_compare(strtolower($store_plugins[$download_plugin]['kj_min_version']), KLEEJA_VERSION , '<=')
&& version_compare(strtolower($store_plugins[$download_plugin]['kj_max_version']), KLEEJA_VERSION , '>=')
)
{
$download_plugin_link = $store_plugins[$download_plugin]['url'];
$downloaded_plugin_zip = fetch_remote_file($download_plugin_link, PATH . 'cache/' . $download_plugin . '.zip', 60, false, 10, true);
if ($downloaded_plugin_zip)
{
if (file_exists(PATH . 'cache/' . $download_plugin . '.zip' ) )
{
$zip = new ZipArchive();
if ($zip->open(PATH . 'cache/' . $download_plugin . '.zip' ) === true)
{
if( $zip->extractTo(PATH . KLEEJA_PLUGINS_FOLDER))
{
$zip->close();
// we dont need the zip file anymore
unlink(PATH . 'cache/' . $download_plugin . '.zip');
// for example :: When we extract zip file , the name will be ( advanced-extras-1.0 )
// so we need to remove the version from folder name and replace ( - ) with ( _ )
// and done
$plugin_folder_name = PATH . KLEEJA_PLUGINS_FOLDER. '/' . str_replace('_' , '-' , $download_plugin) . '-' . $store_plugins[$download_plugin]['plg_version'];
rename($plugin_folder_name , PATH . KLEEJA_PLUGINS_FOLDER. '/' . $download_plugin);
// download or update msg
kleeja_admin_info(
sprintf($lang[ig('update') ? 'PLUGIN_UPDATED' : 'PLUGIN_DOWNLOADED'], $download_plugin),
ADMIN_PATH . '?cp=' . basename(__file__, '.php')
);
exit;
}
else
{
kleeja_admin_err($lang['EXTRACT_ZIP_FAILED']);
}
}
}
else
{
kleeja_admin_err($lang['PLUGIN_FILE_NOT_FOUND']);
}
}
else
{
kleeja_admin_err($lang['PLUGINS_SERVER_ERROR']);
}
}
else
{
kleeja_admin_err($lang['PLUGIN_N_CMPT_KLJ']);
}
}
else
{
kleeja_admin_err(sprintf($lang['PLUGIN_REMOTE_FILE_MISSING'], $download_plugin));
}
}
else
{
kleeja_admin_err($lang['PLUGINS_SERVER_ERROR']);
}
break;
case 'update':
$update_plugin = g('plg');
$plugin_folder_name = PATH . KLEEJA_PLUGINS_FOLDER . '/' . $update_plugin;
if (is_dir($plugin_folder_name))
{
delete_plugin_folder($plugin_folder_name);
}
redirect($plugin_download_link . $update_plugin . '&amp;update' );
break;
endswitch;

View File

@@ -380,4 +380,31 @@ function adm_is_start_box_hidden($name)
is_array($plugin_run_result = Plugins::getInstance()->run('adm_start_boxes_func', get_defined_vars())) ? extract($plugin_run_result) : null; //run hook
return in_array($name, $boxes);
}
/**
* delete plugin folder
* @param string $dir plugin folder path
* @return void
*/
function delete_plugin_folder($dir)
{
$it = new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS);
$files = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($files as $file)
{
if ($file->isLink())
{
unlink($file->getPathname());
}
else if ($file->isDir())
{
rmdir($file->getPathname());
}
else
{
unlink($file->getPathname());
}
}
rmdir($dir);
}

View File

@@ -174,38 +174,19 @@ class kleeja_style
*/
protected function _if_callback($matches)
{
$char = array(' eq ', ' lt ', ' gt ', ' lte ', ' gte ', ' neq ', '==', '!=', '>=', '<=', '<', '>');
$reps = array('==', '<', '>', '<=', '>=', '!=', '==', '!=', '>=', '<=', '<', '>');
$atts = call_user_func(array('kleeja_style', '_get_attributes'), $matches[0]);
$con = trim(!empty($atts['NAME']) ? $atts['NAME'] : (empty($atts['LOOP']) ? '' : $atts['LOOP']));
$con = str_replace('$this->vars', '[----this-vars----]', $con);
if (preg_match('/(.*)(' . implode('|', $char) . ')(.*)/i', $con, $arr))
$condition = '';
foreach(['NAME' => '', 'LOOP' => '', 'AND' => ' && ', 'OR' => ' || '] as $attribute=>$separator)
{
$arr[1] = trim($arr[1]);
$var1 = $arr[1][0] != '$' ? call_user_func(array('kleeja_style', '_var_callback'), (!empty($atts['NAME']) ? '{' . $arr[1] . '}' : '{{' . $arr[1] . '}}')) : $arr[1];
$opr = str_replace($char, $reps, $arr[2]);
$var2 = trim($arr[3]);
#check for type
if ($var2[0] != '$' && !preg_match('/[0-9]/', $var2))
if(! empty($atts[$attribute]))
{
$var2 = '"' . str_replace('"', '\"', $var2) . '"';
$condition .= $separator . $this->parse_condition($atts[$attribute], !empty($atts['LOOP']));
}
$con = "$var1$opr$var2";
}
elseif ($con[0] !== '$' && strpos($con, '(') === false)
{
$con = call_user_func(array('kleeja_style', '_var_callback'), (!empty($atts['NAME']) ? '{' . $con . '}' : '{{' . $con . '}}'));
}
$con = str_replace( '[----this-vars----]', '$this->vars', $con);
return strtoupper($matches[1]) == 'IF'
? '<?php if(' . $con . '){ ?>'
: (strtoupper($matches[1]) == 'UNLESS' ? '<?php if(!(' . $con . ')){ ?>' : '<?php }elseif(' . $con . '){ ?>');
? '<?php if(' . $condition . '){ ?>'
: (strtoupper($matches[1]) == 'UNLESS' ? '<?php if(!(' . $condition . ')){ ?>' : '<?php }elseif(' . $condition . '){ ?>');
}
@@ -219,6 +200,32 @@ class kleeja_style
return '<IF NAME="' . $matches[1] . '">' . $matches[2] . '<ELSE>' . $matches[3] . '</IF>';
}
protected function parse_condition($condition, $is_loop)
{
$char = array(' eq ', ' lt ', ' gt ', ' lte ', ' gte ', ' neq ', '==', '!=', '>=', '<=', '<', '>');
$reps = array('==', '<', '>', '<=', '>=', '!=', '==', '!=', '>=', '<=', '<', '>');
$con = str_replace('$this->vars', '[----this-vars----]', $condition);
if (preg_match('/(.*)(' . implode('|', $char) . ')(.*)/i', $con, $arr)) {
$arr[1] = trim($arr[1]);
$var1 = $arr[1][0] != '$' ? call_user_func(array('kleeja_style', '_var_callback'), (! $is_loop ? '{' . $arr[1] . '}' : '{{' . $arr[1] . '}}')) : $arr[1];
$opr = str_replace($char, $reps, $arr[2]);
$var2 = trim($arr[3]);
#check for type
if ($var2[0] != '$' && !preg_match('/[0-9]/', $var2)) {
$var2 = '"' . str_replace('"', '\"', $var2) . '"';
}
$con = "$var1 $opr $var2";
} elseif ($con[0] !== '$' && strpos($con, '(') === false) {
$con = call_user_func(array('kleeja_style', '_var_callback'), (!$is_loop ? '{' . $con . '}' : '{{' . $con . '}}'));
}
return str_replace('[----this-vars----]', '$this->vars', $con);
}
/**
* make variable printable

View File

@@ -262,10 +262,25 @@ return array(
'NO_ZIP_ARCHIVE' => 'يبدو أن ZipArchive ليس متوفراً علي خادمك، قم بتثبيته فهو من المتطلبات.',
'EXTRACT_ZIP_FAILED' => 'صادفتنا مشكلة أثناء فك الأرشيف! تأكد من أنه ملف zip صالح، وأن مجلد "%s" قابل للكتابة.',
'NO_PROBLEM_AFTER_ZIP' => 'لقد تم فك الملف بنجاح وهو جاهز للتفعيل.',
'SESSION_ENDED' => 'انتهت الجلسة، هل تريد تسجل الدخول من جديد؟',
'SESSION_ENDED' => 'انتهت الجلسة، هل تريد تسجل الدخول من جديد؟',
//3.0.3
'CUSTOMIZATION' => 'تخصيص',
'SHOW' => 'عرض',
'HIDE' => 'إخفاء',
'STATS_BOXES' => 'صناديق الإحصائيات',
'CUSTOMIZATION' => 'تخصيص',
'SHOW' => 'عرض',
'HIDE' => 'إخفاء',
'VIEW' => 'إستعراض',
'INSTALL' => 'تثبيت',
'CLOSE' => 'إغلاق',
'STATS_BOXES' => 'صناديق الإحصائيات',
'PLUGIN_UPDATED' => 'الإضافة "%s" تم تحديثها بنجاح ..',
'PLUGIN_DOWNLOADED' => 'الإضافة "%s" تم تحميلها بنجاح ..',
'PLUGIN_FILE_NOT_FOUND' => 'ملف الإضافة مفقود لايمكن إيجاده!',
'PLUGIN_REMOTE_FILE_MISSING' => 'الإضافة "%s" ليست على موجوة على متجر كليجا الخارجي!',
'PLUGINS_SERVER_ERROR' => 'واجهنا خطأ أثناء الإتصال بخادم متجر كليجا الخارجي...',
'INSTALLED_PLUGINS' => 'الإضافات المثبتة',
'LOCAL_PLUGINS' => 'الإضافات المحلية',
'KLEEJA_STORE' => 'متجر كليجا',
'KLJ_VER_NO_PLUGIN' => 'هذه الإضافة يمكنها العمل على إصدار كليجا %1$s حتى إصدار %2$s.',
'VERSION' => 'الإصدار',
'DEVELOPER' => 'المطور',
'ALL_PLUGINS_UPDATED' => 'لا يوجد إضافات تحتاج تحديث حالياً ... ',
);

View File

@@ -120,7 +120,7 @@ return array(
'PLUGIN_DELETED' => 'Plugin deleted...',
'PLGUIN_DISABLED_ENABLED' => 'Plugin Enabled / Disabled',
'NO_PLUGINS' => 'No plugins found',
'NO_PLUGINS' => 'No plugins found! You could start browsing plugins and installing them by clicking the tab "Kleeja Store" or upload a plugin file from the tab "Local Plugins".',
'NEW_PLUGIN_ADDED' => 'Plugin added ... ',
'PLUGIN_EXISTS_BEFORE' => 'This plugin exists before with same version or above, so no need to update it!.',
'R_CHECK_UPDATE' => 'Check for updates',
@@ -262,8 +262,23 @@ return array(
'NO_PROBLEM_AFTER_ZIP' => 'The file has been extracted successfully and it\'s ready to be enabled',
'SESSION_ENDED' => 'Session has ended, do you want to login again?',
//3.0.3
'CUSTOMIZATION' => 'Customization',
'SHOW' => 'Show',
'HIDE' => 'Hide',
'STATS_BOXES' => 'Stats Boxes',
'CUSTOMIZATION' => 'Customization',
'SHOW' => 'Show',
'HIDE' => 'Hide',
'VIEW' => 'View',
'INSTALL' => 'Install',
'CLOSE' => 'Close',
'STATS_BOXES' => 'Stats Boxes',
'PLUGIN_UPDATED' => 'Plugin "%s" has been updated successfully ..',
'PLUGIN_DOWNLOADED' => 'Plugin "%s" has been downloaded successfully ..',
'PLUGIN_FILE_NOT_FOUND' => 'The plugin file is missing!',
'PLUGIN_REMOTE_FILE_MISSING'=> 'The plugin "%s" is not on Kleeja remote server!',
'PLUGINS_SERVER_ERROR' => 'We encountered an error while connecting to the plugins remote server ...',
'INSTALLED_PLUGINS' => 'Installed Plugins',
'LOCAL_PLUGINS' => 'Local Plugins',
'KLEEJA_STORE' => 'Kleeja Store',
'KLJ_VER_NO_PLUGIN' => 'This plugin can works on Kleeja version %1$s up to version %2$s.',
'VERSION' => 'Version',
'DEVELOPER' => 'Developer',
'ALL_PLUGINS_UPDATED' => 'There are no plugins that require an update currently...',
);