mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Single plugin shortcode now detected in shortcode/single/*.php;
Plugin legacy *.sc moved to shortcode_legacy_list (system update requried); Single plugin shortcodes override now possible (core/override/shortcodes/single/); Testing phase
This commit is contained in:
@@ -936,6 +936,10 @@ class system_tools
|
|||||||
{
|
{
|
||||||
$ret_code = $ep->checkAddon($row['plugin_path'], $this_addon); // See whether spaces before opening tag or after closing tag
|
$ret_code = $ep->checkAddon($row['plugin_path'], $this_addon); // See whether spaces before opening tag or after closing tag
|
||||||
}
|
}
|
||||||
|
elseif(strpos($this_addon, 'sc_') === 0)
|
||||||
|
{
|
||||||
|
$this_addon = substr($this_addon, 3). ' (sc)';
|
||||||
|
}
|
||||||
$text .= "<div class='clear'>";
|
$text .= "<div class='clear'>";
|
||||||
$text .= "<img class='icon action S16' src='".e_IMAGE_ABS."fileinspector/".$error_image[$ret_code]."' alt='".$error_messages[$ret_code]."' title='".$error_messages[$ret_code]."' />";
|
$text .= "<img class='icon action S16' src='".e_IMAGE_ABS."fileinspector/".$error_image[$ret_code]."' alt='".$error_messages[$ret_code]."' title='".$error_messages[$ret_code]."' />";
|
||||||
$text .= trim($this_addon); // $ret_code - 0=OK, 1=content error, 2=access error
|
$text .= trim($this_addon); // $ret_code - 0=OK, 1=content error, 2=access error
|
||||||
|
@@ -1429,6 +1429,15 @@ function update_70x_to_706($type='')
|
|||||||
$sql->db_Select_gen("ALTER TABLE `".MPREFIX."generic` ADD INDEX `gen_type` (`gen_type`);");
|
$sql->db_Select_gen("ALTER TABLE `".MPREFIX."generic` ADD INDEX `gen_type` (`gen_type`);");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isset($pref['shortcode_legacy_list']))
|
||||||
|
{
|
||||||
|
if ($just_check) return update_needed();
|
||||||
|
// Reset, legacy and new shortcode list will be generated in plugin update routine
|
||||||
|
$pref['shortcode_legacy_list'] = array();
|
||||||
|
$pref['shortcode_list'] = array();
|
||||||
|
save_prefs();
|
||||||
|
}
|
||||||
|
|
||||||
if (!$just_check)
|
if (!$just_check)
|
||||||
{
|
{
|
||||||
@@ -1446,6 +1455,7 @@ function update_70x_to_706($type='')
|
|||||||
save_prefs();
|
save_prefs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// If we get to here, in checking mode no updates are required. In update mode, all done.
|
// If we get to here, in checking mode no updates are required. In update mode, all done.
|
||||||
if ($just_check) return TRUE;
|
if ($just_check) return TRUE;
|
||||||
$admin_log->log_event('UPDATE_02',LAN_UPDATE_14.$e107info['e107_version'],E_LOG_INFORMATIVE,''); // Log result of actual update
|
$admin_log->log_event('UPDATE_02',LAN_UPDATE_14.$e107info['e107_version'],E_LOG_INFORMATIVE,''); // Log result of actual update
|
||||||
|
@@ -75,6 +75,7 @@
|
|||||||
<core name="e_shortcode_list"><![CDATA[array (
|
<core name="e_shortcode_list"><![CDATA[array (
|
||||||
'siteinfo' => 'siteinfo',
|
'siteinfo' => 'siteinfo',
|
||||||
)]]></core>
|
)]]></core>
|
||||||
|
<core name="shortcode_list"><![CDATA[array ()]]></core>
|
||||||
<core name="e_sitelink_list"><![CDATA[array (
|
<core name="e_sitelink_list"><![CDATA[array (
|
||||||
'news' => 'news',
|
'news' => 'news',
|
||||||
'page' => 'page',
|
'page' => 'page',
|
||||||
|
@@ -290,7 +290,7 @@ class e107plugin
|
|||||||
|
|
||||||
$plug_info = $this->plug_vars;
|
$plug_info = $this->plug_vars;
|
||||||
$eplug_addons = $this->getAddons($plugin_path);
|
$eplug_addons = $this->getAddons($plugin_path);
|
||||||
|
|
||||||
//Ensure the plugin path lives in the same folder as is configured in the plugin.php/plugin.xml - no longer relevant.
|
//Ensure the plugin path lives in the same folder as is configured in the plugin.php/plugin.xml - no longer relevant.
|
||||||
if ($plugin_path == $plug_info['folder'])
|
if ($plugin_path == $plug_info['folder'])
|
||||||
{
|
{
|
||||||
@@ -1630,7 +1630,7 @@ class e107plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
$currentPref = $core->getPref($prefName.'/'.$plugin);
|
$currentPref = $core->getPref($prefName.'/'.$plugin);
|
||||||
echo 'Path: '.$plugin.' Pref: '.$prefName.' Current: '.$currentPref.' New: '.$pathEntry.'<br />';
|
//echo 'Path: '.$plugin.' Pref: '.$prefName.' Current: '.$currentPref.' New: '.$pathEntry.'<br />';
|
||||||
switch ($when)
|
switch ($when)
|
||||||
{
|
{
|
||||||
case 'install':
|
case 'install':
|
||||||
@@ -2378,7 +2378,12 @@ class e107plugin
|
|||||||
{
|
{
|
||||||
$core->update($var.'_list', "");
|
$core->update($var.'_list', "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reset
|
||||||
|
$core->set('bbcode_list', array())
|
||||||
|
->set('shortcode_legacy_list', array())
|
||||||
|
->set('shortcode_list', array());
|
||||||
|
|
||||||
$query = "SELECT * FROM #plugin WHERE plugin_addons !='' ORDER BY plugin_path ASC";
|
$query = "SELECT * FROM #plugin WHERE plugin_addons !='' ORDER BY plugin_path ASC";
|
||||||
|
|
||||||
if ($sql->db_Select_gen($query))
|
if ($sql->db_Select_gen($query))
|
||||||
@@ -2388,7 +2393,7 @@ class e107plugin
|
|||||||
$is_installed = ($row['plugin_installflag'] == 1);
|
$is_installed = ($row['plugin_installflag'] == 1);
|
||||||
$tmp = explode(",", $row['plugin_addons']);
|
$tmp = explode(",", $row['plugin_addons']);
|
||||||
$path = $row['plugin_path'];
|
$path = $row['plugin_path'];
|
||||||
|
|
||||||
if ($is_installed)
|
if ($is_installed)
|
||||||
{
|
{
|
||||||
foreach ($tmp as $val)
|
foreach ($tmp as $val)
|
||||||
@@ -2402,19 +2407,35 @@ class e107plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// search for .bb and .sc files.
|
// search for .bb and .sc files.
|
||||||
|
$scl_array = array();
|
||||||
$sc_array = array();
|
$sc_array = array();
|
||||||
$bb_array = array();
|
$bb_array = array();
|
||||||
$sql_array = array();
|
$sql_array = array();
|
||||||
|
|
||||||
foreach ($tmp as $adds)
|
foreach ($tmp as $adds)
|
||||||
{
|
{
|
||||||
if (substr($adds, -3) == ".sc")
|
// legacy shortcodes - plugin root *.sc files
|
||||||
|
if (substr($adds, -3) === ".sc")
|
||||||
{
|
{
|
||||||
$sc_name = substr($adds, 0, -3); // remove the .sc
|
$sc_name = substr($adds, 0, -3); // remove the .sc
|
||||||
|
if ($is_installed)
|
||||||
|
{
|
||||||
|
$scl_array[$sc_name] = "0"; // default userclass = e_UC_PUBLIC
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$scl_array[$sc_name] = e_UC_NOBODY; // register shortcode, but disable it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// new shortcodes location - shortcodes/single/*.php
|
||||||
|
elseif (substr($adds, 0, 3) === "sc_")
|
||||||
|
{
|
||||||
|
$sc_name = substr(substr($adds, 3), 0, -4); // remove the sc_ and .php
|
||||||
|
|
||||||
if ($is_installed)
|
if ($is_installed)
|
||||||
{
|
{
|
||||||
$sc_array[$sc_name] = "0"; // default userclass = e_UC_PUBLIC
|
$sc_array[$sc_name] = "0"; // default userclass = e_UC_PUBLIC
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$sc_array[$sc_name] = e_UC_NOBODY; // register shortcode, but disable it
|
$sc_array[$sc_name] = e_UC_NOBODY; // register shortcode, but disable it
|
||||||
@@ -2443,7 +2464,7 @@ class e107plugin
|
|||||||
$core->setPref('e_sql_list/'.$path, $adds);
|
$core->setPref('e_sql_list/'.$path, $adds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build Bbcode list (will be empty if plugin not installed)
|
// Build Bbcode list (will be empty if plugin not installed)
|
||||||
if (count($bb_array) > 0)
|
if (count($bb_array) > 0)
|
||||||
{
|
{
|
||||||
@@ -2452,6 +2473,12 @@ class e107plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build shortcode list - do if uninstalled as well
|
// Build shortcode list - do if uninstalled as well
|
||||||
|
if (count($scl_array) > 0)
|
||||||
|
{
|
||||||
|
ksort($scl_array);
|
||||||
|
$core->setPref('shortcode_legacy_list/'.$path, $scl_array);
|
||||||
|
}
|
||||||
|
|
||||||
if (count($sc_array) > 0)
|
if (count($sc_array) > 0)
|
||||||
{
|
{
|
||||||
ksort($sc_array);
|
ksort($sc_array);
|
||||||
@@ -2512,7 +2539,8 @@ class e107plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Grab List of Shortcodes & BBcodes
|
// Grab List of Shortcodes & BBcodes
|
||||||
$shortcodeList = $fl->get_files(e_PLUGIN.$plugin_path, '\.sc$', "standard", 1);
|
$shortcodeLegacyList = $fl->get_files(e_PLUGIN.$plugin_path, '\.sc$', "standard", 1);
|
||||||
|
$shortcodeList = $fl->get_files(e_PLUGIN.$plugin_path.'/shortcodes/single', '\.php$', "standard", 1);
|
||||||
|
|
||||||
$bbcodeList = $fl->get_files(e_PLUGIN.$plugin_path, '\.bb$', "standard", 1);
|
$bbcodeList = $fl->get_files(e_PLUGIN.$plugin_path, '\.bb$', "standard", 1);
|
||||||
$bbcodeClassList= $fl->get_files(e_PLUGIN.$plugin_path, '^bb_(.*)\.php$', "standard", 1);
|
$bbcodeClassList= $fl->get_files(e_PLUGIN.$plugin_path, '^bb_(.*)\.php$', "standard", 1);
|
||||||
@@ -2520,17 +2548,21 @@ class e107plugin
|
|||||||
|
|
||||||
$sqlList = $fl->get_files(e_PLUGIN.$plugin_path, '_sql\.php$', "standard", 1);
|
$sqlList = $fl->get_files(e_PLUGIN.$plugin_path, '_sql\.php$', "standard", 1);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Search Shortcodes
|
// Search Shortcodes
|
||||||
foreach ($shortcodeList as $sc)
|
foreach ($shortcodeLegacyList as $sc)
|
||||||
{
|
{
|
||||||
if (is_readable(e_PLUGIN.$plugin_path."/".$sc['fname']))
|
if (is_readable(e_PLUGIN.$plugin_path."/".$sc['fname']))
|
||||||
{
|
{
|
||||||
$p_addons[] = $sc['fname'];
|
$p_addons[] = $sc['fname'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
foreach ($shortcodeList as $sc)
|
||||||
|
{
|
||||||
|
if (is_readable(e_PLUGIN.$plugin_path."/shortcodes/single/".$sc['fname']))
|
||||||
|
{
|
||||||
|
$p_addons[] = 'sc_'.$sc['fname'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Search Bbcodes.
|
// Search Bbcodes.
|
||||||
foreach ($bbcodeList as $bb)
|
foreach ($bbcodeList as $bb)
|
||||||
|
@@ -446,30 +446,61 @@ class e_parse_shortcode
|
|||||||
protected function loadPluginSCFiles()
|
protected function loadPluginSCFiles()
|
||||||
{
|
{
|
||||||
$pref = e107::getPref('shortcode_list');
|
$pref = e107::getPref('shortcode_list');
|
||||||
|
$prefl = e107::getPref('shortcode_legacy_list');
|
||||||
|
|
||||||
|
// new shortcodes - functions, shortcode/single/*.php
|
||||||
if ($pref)
|
if ($pref)
|
||||||
{
|
{
|
||||||
foreach ($pref as $path => $namearray)
|
foreach ($pref as $path => $namearray)
|
||||||
{
|
{
|
||||||
foreach ($namearray as $code => $uclass)
|
foreach ($namearray as $code => $uclass)
|
||||||
{
|
{
|
||||||
|
$code = strtoupper($code);
|
||||||
|
if (!$this->isRegistered($code))
|
||||||
|
{
|
||||||
|
if($this->isOverride($code))
|
||||||
|
{
|
||||||
|
$this->registered_codes[$code]['type'] = 'override';
|
||||||
|
$this->registered_codes[$code]['function'] = 'override_'.strtolower($code).'_shortcode';
|
||||||
|
$this->registered_codes[$code]['path'] = e_CORE.'override/shortcodes/single/';
|
||||||
|
$this->registered_codes[$code]['perms'] = $uclass;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$this->registered_codes[$code]['type'] = 'plugin';
|
||||||
|
$this->registered_codes[$code]['function'] = strtolower($code).'_shortcode';
|
||||||
|
$this->registered_codes[$code]['path'] = e_PLUGIN.$path.'/shortcodes/single/';
|
||||||
|
$this->registered_codes[$code]['perms'] = $uclass;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// legacy .sc - plugin root
|
||||||
|
if ($prefl)
|
||||||
|
{
|
||||||
|
foreach ($prefl as $path => $namearray)
|
||||||
|
{
|
||||||
|
foreach ($namearray as $code => $uclass)
|
||||||
|
{
|
||||||
|
// XXX old? investigate
|
||||||
if ($code == 'shortcode_config')
|
if ($code == 'shortcode_config')
|
||||||
{
|
{
|
||||||
include_once(e_PLUGIN.$path.'/shortcode_config.php');
|
include_once(e_PLUGIN.$path.'/shortcode_config.php');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$code = strtoupper($code);
|
$code = strtoupper($code);
|
||||||
if (!$this->isRegistered($code))
|
if (!$this->isRegistered($code))
|
||||||
{
|
{
|
||||||
$this->registered_codes[$code]['type'] = 'plugin';
|
$this->registered_codes[$code]['type'] = 'plugin_legacy';
|
||||||
$this->registered_codes[$code]['path'] = $path;
|
$this->registered_codes[$code]['path'] = $path;
|
||||||
$this->registered_codes[$code]['perms'] = $uclass; // XXX how we get this?
|
$this->registered_codes[$code]['perms'] = $uclass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -578,7 +609,7 @@ class e_parse_shortcode
|
|||||||
|
|
||||||
function isRegistered($code)
|
function isRegistered($code)
|
||||||
{
|
{
|
||||||
return in_array($code, $this->registered_codes);
|
return array_key_exists($code, $this->registered_codes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function resetScClass($className, $object)
|
public function resetScClass($className, $object)
|
||||||
@@ -804,6 +835,7 @@ class e_parse_shortcode
|
|||||||
|
|
||||||
case 'override':
|
case 'override':
|
||||||
case 'func':
|
case 'func':
|
||||||
|
case 'plugin':
|
||||||
//It is a function, so include the file and call the function
|
//It is a function, so include the file and call the function
|
||||||
$_function = $this->registered_codes[$code]['function'];
|
$_function = $this->registered_codes[$code]['function'];
|
||||||
if (!function_exists($_function) && $this->registered_codes[$code]['path'])
|
if (!function_exists($_function) && $this->registered_codes[$code]['path'])
|
||||||
@@ -811,13 +843,14 @@ class e_parse_shortcode
|
|||||||
include_once($this->registered_codes[$code]['path'].strtolower($code).'.php');
|
include_once($this->registered_codes[$code]['path'].strtolower($code).'.php');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (function_exists($_function))
|
if (function_exists($_function))
|
||||||
{
|
{
|
||||||
$ret = call_user_func($_function, $parm, $sc_mode);
|
$ret = call_user_func($_function, $parm, $sc_mode);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'plugin':
|
case 'plugin_legacy':
|
||||||
$scFile = e_PLUGIN.strtolower($this->registered_codes[$code]['path']).'/'.strtolower($code).'.sc';
|
$scFile = e_PLUGIN.strtolower($this->registered_codes[$code]['path']).'/'.strtolower($code).'.sc';
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user