diff options
author | Paul Arthur <paul.arthur@flowerysong.com> | 2013-02-03 04:54:37 -0500 |
---|---|---|
committer | Paul Arthur <paul.arthur@flowerysong.com> | 2013-02-03 04:55:51 -0500 |
commit | c8cd1da88fbf0df1a99463032d97ac42d221a774 (patch) | |
tree | 9ee74797bf0f7b90f96ccbfd2f8b8829cbc49fd0 | |
parent | 10d54c9f7fd0b15b64a0474c6f33b63caabc4d03 (diff) | |
download | ampache-c8cd1da88fbf0df1a99463032d97ac42d221a774.tar.gz ampache-c8cd1da88fbf0df1a99463032d97ac42d221a774.tar.bz2 ampache-c8cd1da88fbf0df1a99463032d97ac42d221a774.zip |
Fix the debug_result convenience function
The point of a convenience function is to be convenient, not to have an
unused first parameter and always be surrounded by the same boilerplate.
-rw-r--r-- | lib/debug.lib.php | 17 | ||||
-rw-r--r-- | templates/show_install_check.inc.php | 54 | ||||
-rw-r--r-- | templates/show_install_config.inc.php | 22 | ||||
-rw-r--r-- | templates/show_test_table.inc.php | 112 |
4 files changed, 57 insertions, 148 deletions
diff --git a/lib/debug.lib.php b/lib/debug.lib.php index d3fa035b..0c8f9ab9 100644 --- a/lib/debug.lib.php +++ b/lib/debug.lib.php @@ -279,19 +279,18 @@ function escape_ini($str) { /** - * debug_ok - * Return an "OK" with the specified string + * debug_result + * + * Convenience function to format the output. */ -function debug_result($comment,$status=false,$value=false) { - +function debug_result($status = false, $value = null, $comment = '') { $class = $status ? 'ok' : 'notok'; + if (!$value) { $value = $status ? 'OK' : 'ERROR'; } - $final = '<span class="' . $class . '">' . scrub_out($value) . '</span> <em>' . $comment . '</em>'; - - return $final; - -} // debug_ok + return '[ <span class="' . $class . '">' . scrub_out($value) . + '</span> <em>' . $comment . '</em> ]'; +} ?> diff --git a/templates/show_install_check.inc.php b/templates/show_install_check.inc.php index 5b6fd83d..4085642f 100644 --- a/templates/show_install_check.inc.php +++ b/templates/show_install_check.inc.php @@ -32,48 +32,24 @@ </tr> <?php require $prefix . '/templates/show_test_table.inc.php'; ?> <tr> -<td><?php echo sprintf(T_('%s is readable'), 'ampache.cfg.php.dist'); ?></td> -<td>[ -<?php - if (!is_readable($prefix . '/config/ampache.cfg.php.dist')) { - echo debug_result('', false); - } - else { - echo debug_result('', true); - } -?> -] -</td> -<td><?php echo T_('This tests whether the configuration template can be read.'); ?></td> + <td><?php echo sprintf(T_('%s is readable'), 'ampache.cfg.php.dist'); ?></td> + <td> + <?php echo debug_result(is_readable($prefix . '/config/ampache.cfg.php.dist')); ?> + </td> + <td><?php echo T_('This tests whether the configuration template can be read.'); ?></td> </tr> <tr> -<td><?php echo sprintf(T_('%s is readable'), 'ampache.sql'); ?></td> -<td>[ -<?php - if (!is_readable($prefix . '/sql/ampache.sql')) { - echo debug_result('', false); - } - else { - echo debug_result('', true); - } -?> -] -</td> -<td><?php echo T_('This tests whether the file needed to initialise the database structure is available.'); ?></td> + <td><?php echo sprintf(T_('%s is readable'), 'ampache.sql'); ?></td> + <td> + <?php echo debug_result(is_readable($prefix . '/sql/ampache.sql')); ?> + </td> + <td><?php echo T_('This tests whether the file needed to initialise the database structure is available.'); ?></td> </tr> <tr> -<td><?php echo T_('ampache.cfg.php is writable'); ?></td> -<td>[ -<?php - if (!check_config_writable()) { - echo debug_result('', false); - } - else { - echo debug_result('', true); - } -?> -] -</td> -<td><?php echo T_('This tests whether PHP can write to config/. This is not strictly necessary, but will help streamline the installation process.'); ?></td> + <td><?php echo T_('ampache.cfg.php is writable'); ?></td> + <td> + <?php echo debug_result(check_config_writable()); ?> + </td> + <td><?php echo T_('This tests whether PHP can write to config/. This is not strictly necessary, but will help streamline the installation process.'); ?></td> </tr> </table> diff --git a/templates/show_install_config.inc.php b/templates/show_install_config.inc.php index bae4d3ba..9ec17b1f 100644 --- a/templates/show_install_config.inc.php +++ b/templates/show_install_config.inc.php @@ -72,33 +72,19 @@ require $prefix . '/templates/install_header.inc.php'; <table> <tr> <td class="align"><?php echo T_('ampache.cfg.php exists?'); ?></td> - <td>[ - <?php - if (!is_readable($configfile)) { - echo debug_result('',false); - } - else { - echo debug_result('',true); - } - ?> - ] + <td> + <?php echo debug_result(is_readable($configfile)); ?> </td> </tr> <tr> <td class="align"> <?php echo T_('ampache.cfg.php configured?'); ?> </td> - <td>[ + <td> <?php $results = @parse_ini_file($configfile); - if (!check_config_values($results)) { - echo debug_result('',false); - } - else { - echo debug_result('',true); - } + echo debug_result(check_config_values($results)); ?> - ] </td> </tr> <tr> diff --git a/templates/show_test_table.inc.php b/templates/show_test_table.inc.php index ba22e717..eaef19d1 100644 --- a/templates/show_test_table.inc.php +++ b/templates/show_test_table.inc.php @@ -22,9 +22,8 @@ ?> <tr> <td valign="top"><?php echo T_('PHP version'); ?></td> - <td valign="top">[ - <?php echo debug_result('', check_php_ver()); ?> - ] + <td valign="top"> + <?php echo debug_result(check_php_ver()); ?> </td> <td> <?php echo T_('This tests whether you are running at least the minimum version of PHP required by Ampache.'); ?> @@ -32,9 +31,8 @@ </tr> <tr> <td valign="top"><?php echo T_('Hash extension'); ?></td> - <td valign="top">[ - <?php echo debug_result('', function_exists('hash_algos')); ?> - ] + <td valign="top"> + <?php echo debug_result(function_exists('hash_algos')); ?> </td> <td> <?php echo T_('This tests whether you have the hash extension enabled. This extension is required by Ampache.'); ?> @@ -42,9 +40,8 @@ </tr> <tr> <td valign="top"><?php echo T_('SHA256 Hash'); ?></td> - <td valign="top">[ - <?php echo debug_result('', function_exists('hash_algos') ? in_array('sha256', hash_algos()) : false); ?> - ] + <td valign="top"> + <?php echo debug_result(function_exists('hash_algos') ? in_array('sha256', hash_algos()) : false); ?> </td> <td> <?php echo T_('This tests whether the hash extension supports SHA256. This algorithm is required by Ampache.'); ?> @@ -52,9 +49,8 @@ </tr> <tr> <td valign="top"><?php echo T_('PHP PDO'); ?></td> - <td valign="top">[ - <?php echo debug_result('', check_pdo()); ?> - ] + <td valign="top"> + <?php echo debug_result(check_pdo()); ?> </td> <td> <?php echo T_('This tests whether the PDO extension and the MySQL driver for PDO are installed. These are required by Ampache.'); ?> @@ -62,9 +58,8 @@ </tr> <tr> <td valign="top"><?php echo T_('PHP session extension'); ?></td> - <td valign="top">[ - <?php echo debug_result('', check_php_session()); ?> - ] + <td valign="top"> + <?php echo debug_result(check_php_session()); ?> </td> <td> <?php echo T_('This tests whether you have the session extension enabled. This extension is required by Ampache.'); ?> @@ -72,15 +67,8 @@ </tr> <tr> <td valign="top"><?php echo T_('PHP iconv extension'); ?></td> - <td valign="top">[ - <?php - if (!UI::check_iconv()) { - echo debug_result('',false); - } - else { - echo debug_result('',true); - } - ?>] + <td valign="top"> + <?php echo debug_result(UI::check_iconv()); ?> </td> <td> <?php echo T_('This tests whether you have the iconv extension enabled. This extension is required by Ampache.'); ?> @@ -88,9 +76,8 @@ </tr> <tr> <td valign="top"><?php echo T_('JSON extension'); ?></td> - <td valign="top">[ - <?php echo debug_result('', function_exists('json_encode')); ?> - ] + <td valign="top"> + <?php echo debug_result(function_exists('json_encode')); ?> </td> <td> <?php echo T_('This tests whether you have the JSON extension enabled. This extension is required by Ampache.'); ?> @@ -98,15 +85,8 @@ </tr> <tr> <td valign="top"><?php echo T_('PHP safe mode disabled'); ?></td> - <td valign="top">[ - <?php - if (!check_safemode()) { - echo debug_result('',false); - } - else { - echo debug_result('',true); - } - ?>] + <td valign="top"> + <?php echo debug_result(check_safemode()); ?> </td> <td> <?php echo T_('This test makes sure that PHP is not running in safe mode. Some features of Ampache will not work correctly in safe mode.'); ?> @@ -114,8 +94,8 @@ </tr> <tr> <td valign="top"><?php echo T_('PHP memory limit override'); ?></td> - <td valign="top">[ - <?php echo debug_result('', check_override_memory()); ?>] + <td valign="top"> + <?php echo debug_result(check_override_memory()); ?> </td> <td> <?php echo T_('This tests whether Ampache can override the memory limit. This is not strictly necessary, but may result in a better experience.'); ?> @@ -123,8 +103,8 @@ </tr> <tr> <td valign="top"><?php echo T_('PHP execution time override'); ?></td> - <td valign="top">[ - <?php echo debug_result('', check_override_exec_time()); ?>] + <td valign="top"> + <?php echo debug_result(check_override_exec_time()); ?> </td> <td> <?php echo T_('This tests whether Ampache can override the limit on maximum execution time. This is not strictly necessary, but may result in a better experience.'); ?> @@ -135,16 +115,8 @@ if (!defined('INSTALL')) { ?> <tr> <td valign="top"><?php echo T_('Configuration file readability'); ?></td> - <td valign="top">[ - <?php - if (!is_readable($configfile)) { - echo debug_result('',false); - } - else { - echo debug_result('',true); - } - ?> - ] + <td valign="top"> + <?php echo debug_result(is_readable($configfile)); ?> </td> <td width="350px"> <?php echo T_('This test attempts to read config/ampache.cfg.php. If this fails the file either is not in the correct location or is not currently readable.'); ?> @@ -154,18 +126,12 @@ if (!defined('INSTALL')) { <td valign="top"> <?php echo T_('Configuration file validity'); ?> </td> - <td valign="top">[ + <td valign="top"> <?php $results = @parse_ini_file($configfile); Config::set_by_array($results); - if (!check_config_values($results)) { - echo debug_result('',false); - } - else { - echo debug_result('',true); - } + echo debug_result(check_config_values($results)); ?> - ] </td> <td> <?php echo T_("This test makes sure that you have set all of the required configuration variables and that we are able to completely parse your config file."); ?> @@ -173,16 +139,8 @@ if (!defined('INSTALL')) { </tr> <tr> <td valign="top"><?php echo T_("Database connection"); ?></td> - <td valign="top">[ - <?php - if (!check_pdo() || !Dba::check_database()) { - echo debug_result('',false); - } - else { - echo debug_result('',true); - } - ?> - ] + <td valign="top"> + <?php echo debug_result(check_pdo() && Dba::check_database()); ?> </td> <td> <?php echo T_('This attempts to connect to your database using the values read from your configuration file.'); ?> @@ -190,17 +148,8 @@ if (!defined('INSTALL')) { </tr> <tr> <td valign="top"><?php echo T_('Database tables'); ?></td> - <td valign="top">[ - <?php - $db_inserted = check_pdo() ? Dba::check_database_inserted() : false; - if (!$db_inserted) { - echo debug_result('',false); - } - else { - echo debug_result('',true); - } - ?> - ] + <td valign="top"> + <?php echo debug_result(check_pdo() && Dba::check_database_inserted()); ?> </td> <td> <?php echo T_('This checks a few key tables to make sure that you have successfully inserted the Ampache database and that the user has access to the database'); ?> @@ -209,7 +158,7 @@ if (!defined('INSTALL')) { <tr> <td valign="top"><?php echo T_('Web path'); ?></td> - <td valign="top">[ + <td valign="top"> <?php if ($results['force_ssl']) { $http_type = 'https://'; @@ -220,11 +169,10 @@ if (!defined('INSTALL')) { echo " <img src=\"" . $results['web_path'] ."/images/icon_enable.png\" /> "; } else { - echo debug_result('',false); + echo debug_result(false); } ?> - ] </td> <td> <?php echo T_('This test makes sure that your web_path variable is set correctly and that we are able to get to the index page. If you do not see a check mark here then your web_path is not set correctly.'); ?> |