Summary:
admin/listtags.php : directories bad config.php key for assets and Cannot redeclare smarty_function
Detailed Description:
admin/listtags.php : directories bad config.php key for assets and Cannot
redeclare smarty_function
L47 $dirs[] = $config['root_path'].'/assets/plugins';
### assets plugin directory do not match if $config['assets_path'] is customised
in config.php
L48 $dirs[] = $config['root_path'].'/plugins';
### directory deprecated
admin/listtags.php :
from L 46 to 51
$dirs = [];
$dirs[] = $config['root_path'].'/assets/plugins';
$dirs[] = $config['root_path'].'/plugins';
$dirs[] = $config['root_path'].'/lib/plugins';
$dirs[] = $config['admin_path'].'/plugins';
$config = cmsms()->GetConfig();
corrected :
$dirs = [];
$dirs[] = $config['assets_path'].'/plugins'; // good assets plugins directory
$dirs[] = $config['root_path'].'/plugins'; // deprecated
$dirs[] = $config['root_path'].'/lib/plugins';
$dirs[] = $config['admin_path'].'/plugins';
$config = cmsms()->GetConfig();
now, if I want to modify an existing plugin, this way for exemple :
copy lib/plugins/function.cms_stylesheet.php
to assets/plugins/function.cms_stylesheet.php (and do some modifications)
result:
Fatal error: Cannot redeclare smarty_function_cms_stylesheet() (previously
declared in....
admin/listtags.php L110 to 119
$files = array();
foreach( $dirs as $one ) {
$files = array_merge($files,glob($one.'/*.php'));
}
if( is_array($files) && count($files) ) {
$file_array = array();
foreach($files as $onefile) {
$file = basename($onefile);
$parts = explode('.',$file);
#### problem : plugins are merged even if already exist
### corrected
$files = array();
foreach( $dirs as $one ) {
foreach (glob($one.'/*.php') as $pluginfilepath){
//get plugin name as key
$files[basename($pluginfilepath)] = $pluginfilepath;
}
unset($pluginfilepath);
}
if( is_array($files) && count($files) ) {
$file_array = array();
foreach($files as $file => $onefile) {
//add $file as already formated key
$parts = explode('.',$file);
then works as expected
also assets plugin directory do not match if $config['assets_path'] is
customised in config.php
in lib/classes/internal/class.Smarty_CMS.php L 237
// plugins with the smarty_cms_function
$cachable = TRUE;
$dirs = [];
$dirs[] =
cms_join_path(CMS_ROOT_PATH,'assets','plugins',$type.'.'.$name.'.php');
$dirs[] = cms_join_path(CMS_ROOT_PATH,'plugins',$type.'.'.$name.'.php');
--------corrected------------------
// plugins with the smarty_cms_function
$cachable = TRUE;
$dirs = [];
$config = cms_config::get_instance(); // get config
$dirs[] =
cms_join_path(CMS_ROOT_PATH,$config['assets_dir'],'plugins',$type.'.'.$name.'.php');
// good assets plugins directory
$dirs[] = cms_join_path(CMS_ROOT_PATH,'plugins',$type.'.'.$name.'.php'); //
deprecated
------------------------
Note in
https://docs.cmsmadesimple.org/configuration/config-file/config-reference#config_assets_url
assets_url
seem to be use nowhere and not set
so there is no default value