SF.net SVN: postfixadmin:[1471] trunk/model/Config.php
Brought to you by:
christian_boltz,
gingerdog
|
From: <chr...@us...> - 2013-06-05 23:09:13
|
Revision: 1471
http://sourceforge.net/p/postfixadmin/code/1471
Author: christian_boltz
Date: 2013-06-05 23:09:10 +0000 (Wed, 05 Jun 2013)
Log Message:
-----------
Config.php:
- add read_f() - similar to read(), but accepts a second parameter which
is then included in the text using sprintf
- bool(): change parameter name
Modified Paths:
--------------
trunk/model/Config.php
Modified: trunk/model/Config.php
===================================================================
--- trunk/model/Config.php 2013-06-05 23:03:03 UTC (rev 1470)
+++ trunk/model/Config.php 2013-06-05 23:09:10 UTC (rev 1471)
@@ -115,8 +115,28 @@
return null;
}
+ /**
+ * read Config::$var and apply sprintf on it
+ * also checks if $var is changed by sprintf - if not, it writes a warning to error_log
+ *
+ * @param string $var Variable to obtain
+ * @param string $value Value to use as sprintf parameter
+ * @return string value of Config::$var, parsed by sprintf
+ * @access public
+ */
+ public static function read_f($var, $value) {
+ $text = self::read($var);
+
+ $newtext = sprintf($text, $value);
+
+ # check if sprintf changed something - if not, there are chances that $text didn't contain a %s
+ if ($text == $newtext) error_log("$var used via read_f, but nothing replaced (value $value)");
+
+ return $newtext;
+ }
+
/**
- * Used to read Configure::$var, converted to boolean
+ * Used to read Config::$var, converted to boolean
* (obviously only useful for settings that can be YES or NO)
*
* Usage
@@ -127,8 +147,8 @@
* @access public
*/
- public static function bool($setting) {
- $value = Config::read($setting);
+ public static function bool($var) {
+ $value = self::read($var);
if (strtoupper($value) == 'YES') { # YES
return true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|