Use Boolean in tree_base data
Simplify config['subdirs'] substitution Signed-off-by: Diederik de Groot <ddegroot@talon.nl>
This commit is contained in:
@@ -17,14 +17,14 @@ $base_config = Array(
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
$tree_base = Array(
|
$tree_base = Array(
|
||||||
'settings' => array('path' => 'tftproot', "strip" => 1),
|
'settings' => array('path' => 'tftproot', "strip" => TRUE),
|
||||||
'wallpapers' => array('path' => 'tftproot', "strip" => 0),
|
'wallpapers' => array('path' => 'tftproot', "strip" => FALSE),
|
||||||
'ringtones' => array('path' => 'tftproot', "strip" => 1),
|
'ringtones' => array('path' => 'tftproot', "strip" => TRUE),
|
||||||
'locales' => array('path' => 'tftproot', "strip" => 1),
|
'locales' => array('path' => 'tftproot', "strip" => TRUE),
|
||||||
'firmware' => array('path' => 'tftproot', "strip" => 1),
|
'firmware' => array('path' => 'tftproot', "strip" => TRUE),
|
||||||
'languages' => array('path' => 'locales', "strip" => 0),
|
'languages' => array('path' => 'locales', "strip" => FALSE),
|
||||||
'countries' => array('path' => 'locales', "strip" => 0),
|
'countries' => array('path' => 'locales', "strip" => FALSE),
|
||||||
'default_language' => array('path' => 'locales', "strip" => 1),
|
'default_language' => array('path' => 'locales', "strip" => TRUE),
|
||||||
);
|
);
|
||||||
|
|
||||||
# Merge config
|
# Merge config
|
||||||
@@ -33,19 +33,18 @@ if (!empty($ini_array)) {
|
|||||||
$config = array_merge($base_config, $ini_array);
|
$config = array_merge($base_config, $ini_array);
|
||||||
}
|
}
|
||||||
|
|
||||||
# rewrite config['subdirs'] paths using tree_base data
|
# build new config['subdirs'] paths substituting bases from tree_base
|
||||||
# Not sure if this is a good way
|
|
||||||
foreach ($tree_base as $key => $value) {
|
foreach ($tree_base as $key => $value) {
|
||||||
if (!empty($config['subdirs'][$key])) {
|
$tmp = $config;
|
||||||
if (substr($config['subdirs'][$key], 0, 1) !== "/") {
|
if (!empty($tmp['subdirs'][$key])) {
|
||||||
$path = $config['subdirs'][$value['path']].'/'.$config['subdirs'][$key];
|
if (substr($tmp['subdirs'][$key], 0, 1) !== "/") {
|
||||||
$config['subdirs'][$key] = $path;
|
if (is_array($tmp['subdirs'][$value['path']])) {
|
||||||
|
$path = $tmp['subdirs'][$value['path']]['path'].'/'.$tmp['subdirs'][$key];
|
||||||
|
} else {
|
||||||
|
$path = $tmp['subdirs'][$value['path']].'/'.$tmp['subdirs'][$key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
$config['subdirs'][$key] = array('path' => $path, 'strip' => $value['strip']);
|
||||||
foreach ($tree_base as $key => $value) {
|
|
||||||
if (!empty($config['subdirs'][$key])) {
|
|
||||||
$config['subdirs'][$key] = array('path' => $config['subdirs'][$key], 'strip' => $value['strip']);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -56,7 +56,7 @@ class Resolver {
|
|||||||
$iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
|
$iterator = new RecursiveIteratorIterator($dir_iterator, RecursiveIteratorIterator::SELF_FIRST);
|
||||||
foreach ($iterator as $file) {
|
foreach ($iterator as $file) {
|
||||||
if ($file->isFile()) {
|
if ($file->isFile()) {
|
||||||
if ($value['strip'] === 1) {
|
if ($value['strip']) {
|
||||||
$this->addFile($file->getFileName(), $file->getPathname());
|
$this->addFile($file->getFileName(), $file->getPathname());
|
||||||
} else {
|
} else {
|
||||||
$subdir = basename(dirname($file->getPathname()));
|
$subdir = basename(dirname($file->getPathname()));
|
||||||
|
Reference in New Issue
Block a user