Skip to content

Commit

Permalink
Issue #5120 - Reworked as object for increased flexibility. Some twea…
Browse files Browse the repository at this point in the history
…king still to be done.
  • Loading branch information
CaMer0n committed Nov 30, 2023
1 parent 9313239 commit dbcc265
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 33 deletions.
14 changes: 7 additions & 7 deletions class2.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
//
// E: Setup other essential PHP parameters
//
define('e107_INIT', true);
const e107_INIT = true;


// DEPRECATED, use e107::getConfig() and e107::getPlugConfig()
Expand Down Expand Up @@ -208,7 +208,7 @@
e107_require_once($tmp.'/e107_class.php');
unset($tmp);

if(empty($config['directories'])) // old e107_config.php format.
if(!class_exists('e107_config')) // old e107_config.php format.
{
$e107_paths = compact('ADMIN_DIRECTORY', 'FILES_DIRECTORY', 'IMAGES_DIRECTORY', 'THEMES_DIRECTORY', 'PLUGINS_DIRECTORY', 'HANDLERS_DIRECTORY', 'LANGUAGES_DIRECTORY', 'HELP_DIRECTORY', 'DOWNLOADS_DIRECTORY','UPLOADS_DIRECTORY','SYSTEM_DIRECTORY', 'MEDIA_DIRECTORY','CACHE_DIRECTORY','LOGS_DIRECTORY', 'CORE_DIRECTORY', 'WEB_DIRECTORY');
$legacy_sql_info = compact('mySQLserver', 'mySQLuser', 'mySQLpassword', 'mySQLdefaultdb', 'mySQLprefix');
Expand All @@ -225,10 +225,10 @@
}
else // New e107_config.php format. v2.4+
{
$e107_paths = $config['directories'];
$sql_info = $config['mySQL'];
$E107_CONFIG = $config['other'] ?? [];
unset($config);
$e107_paths = $config->paths();
$sql_info = $config->database();
$E107_CONFIG = $config->other() ?? [];
//unset($config);
}


Expand Down Expand Up @@ -1369,7 +1369,7 @@ function getperms($arg, $ap = null, $path = null)
return true;
}

if ($arg === 'P' && preg_match('#(.*?)/' .e107::getInstance()->getFolder('plugins'). '(.*?)/(.*?)#', $path, $matches))
if ($arg === 'P' && preg_match('#(.*?)/' .e107::getFolder('plugins'). '(.*?)/(.*?)#', $path, $matches))
{
$sql = e107::getDb('psql');

Expand Down
66 changes: 40 additions & 26 deletions e107_tests/tests/_data/e107_config.php.sample
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,44 @@ $SYSTEM_DIRECTORY = 'e107_system/';

$E107_CONFIG = array('site_path' => '000000test');
*/
define('e_MOD_REWRITE',true);
const e_MOD_REWRITE = true;

return [
'mySQL' => [
'server' => '{{ mySQLserver }}',
'user' => '{{ mySQLuser }}',
'password' => '{{ mySQLpassword }}',
'defaultdb'=> '{{ mySQLdefaultdb }}',
'prefix' => '{{ mySQLprefix }}',
'charset' => 'utf8',
],
'directories' => [ // leave empty to use default
'admin' => 'e107_admin/',
'files' => 'e107_files/',
'images' => 'e107_images/',
'themes' => 'e107_themes/',
'plugins' => 'e107_plugins/',
'handlers' => 'e107_handlers/',
'languages' => 'e107_languages/',
'help' => 'e107_docs/help/',
'system' => 'e107_system/',
'media' => 'e107_media/',
],
'other' => [
'site_path' => '000000test'
]
];
class e107_config
{
public function database()
{
return [
'server' => '{{ mySQLserver }}',
'user' => '{{ mySQLuser }}',
'password' => '{{ mySQLpassword }}',
'defaultdb'=> '{{ mySQLdefaultdb }}',
'prefix' => '{{ mySQLprefix }}',
'charset' => 'utf8',
];
}

public function paths()
{
return [
'admin' => 'e107_admin/',
'files' => 'e107_files/',
'images' => 'e107_images/',
'themes' => 'e107_themes/',
'plugins' => 'e107_plugins/',
'handlers' => 'e107_handlers/',
'languages' => 'e107_languages/',
'help' => 'e107_docs/help/',
'system' => 'e107_system/',
'media' => 'e107_media/',
];
}

public function other()
{
return [
'site_path' => '000000test'
];
}
}

return new e107_config;

0 comments on commit dbcc265

Please sign in to comment.