public function checkConfigFiles() { if (!isset($GLOBALS['phorkie']['cfgfiles']) || count($GLOBALS['phorkie']['cfgfiles']) == 0) { $this->info('No config files registered'); return; } foreach ($GLOBALS['phorkie']['cfgfiles'] as $file => $loaded) { if ($loaded) { $this->ok('Loaded config file: ' . Tools::foldPath($file)); } else { $this->info('Possible config file: ' . Tools::foldPath($file) . ' (not loaded)'); } } }
HTM; $stateMap = array('ok' => 'success', 'info' => 'info', 'error' => 'danger'); foreach ($messages as $arMessage) { list($type, $message) = $arMessage; $out .= '<li class="list-group-item list-group-item-' . $stateMap[$type] . '">'; $out .= htmlspecialchars($message); $out .= '</li>' . "\n"; } $out .= <<<HTM </ul> HTM; if (array_sum($GLOBALS['phorkie']['cfgfiles']) == 0) { //no config file loaded reset($GLOBALS['phorkie']['cfgfiles']); list($cfgFilePath, ) = each($GLOBALS['phorkie']['cfgfiles']); $cfgFilePath = Tools::foldPath($cfgFilePath); $cfgFileTemplate = htmlspecialchars(file_get_contents(__DIR__ . '/../data/config.php.dist')); $cfgFileLines = count(explode("\n", $cfgFileTemplate)); $out .= <<<HTM <h3 id="configfile">Configuration file</h3> <p> Phorkie did not find a configuration file. Please create one at </p> <pre>{$cfgFilePath}</pre> <p> from the following template: </p> <textarea style="width:99%; background-color: #F5F5F5" rows="{$cfgFileLines}">{$cfgFileTemplate}</textarea> <p> Remove the leading <tt>//</tt> from a line if you want to adjust it.
public function testFoldPathCurrentThrice() { $this->assertEquals('/path/to/foo/', Tools::foldPath('/path/././to/foo/./')); }