gwynne Wed Aug 8 23:26:05 2007 UTC
Added files:
/phd/setup PhD_Interface.class.php PhD_Options.class.php
PhD_Output.class.php
Removed files:
/phd/setup CLI.class.php
Modified files:
/phd/setup Configurator.class.php Option_Metadata.inc.php
setup.messages.php setup.php
Log:
- Removed unnecessary functiosn from the Configurator
- Updated the header comments of several formats to make more grammatical
sense.
- Moved the PhD_Options and PhD_Output classes into their own include files
for modularity and cleanliness.
- Added a compatibility_mode option to allow PhD to skip the slow translation
steps for already-converted trees.
- Reworded a few status messages.
- Changed CLI.class.php to PhD_Interface.class.php for cleanliness and
consistency.
- Factored all CLI-specific code out of setup.php into
PhD_Interface.class.php, facilitating future implementation of other interfaces
if needed.
http://cvs.php.net/viewvc.cgi/phd/setup/Configurator.class.php?r1=1.5&r2=1.6&diff_format=u
Index: phd/setup/Configurator.class.php
diff -u phd/setup/Configurator.class.php:1.5
phd/setup/Configurator.class.php:1.6
--- phd/setup/Configurator.class.php:1.5 Tue Aug 7 08:09:07 2007
+++ phd/setup/Configurator.class.php Wed Aug 8 23:26:05 2007
@@ -1,6 +1,6 @@
<?php
-/* $Id: Configurator.class.php,v 1.5 2007/08/07 08:09:07 gwynne Exp $
+/* $Id: Configurator.class.php,v 1.6 2007/08/08 23:26:05 gwynne Exp $
+-------------------------------------------------------------------------+
| Copyright(c) 2007 |
| Authors: |
@@ -52,11 +52,6 @@
}
}
- public function isValidOptionValue( $name, $value ) {
- $vf = $GLOBALS[ 'OPTIONS_DATA' ][ $name ][ 'validity_check_function' ];
- return is_callable( $vf ) ? $vf( $value ) : FALSE;
- }
-
public function writeConfig() {
try {
$file = new Template_File( dirname( __FILE__ ) . '/config.in.php',
$this->config_php_path, TRUE );
http://cvs.php.net/viewvc.cgi/phd/setup/Option_Metadata.inc.php?r1=1.6&r2=1.7&diff_format=u
Index: phd/setup/Option_Metadata.inc.php
diff -u phd/setup/Option_Metadata.inc.php:1.6
phd/setup/Option_Metadata.inc.php:1.7
--- phd/setup/Option_Metadata.inc.php:1.6 Tue Aug 7 08:09:07 2007
+++ phd/setup/Option_Metadata.inc.php Wed Aug 8 23:26:05 2007
@@ -1,6 +1,6 @@
<?php
-/* $Id: Option_Metadata.inc.php,v 1.6 2007/08/07 08:09:07 gwynne Exp $
+/* $Id: Option_Metadata.inc.php,v 1.7 2007/08/08 23:26:05 gwynne Exp $
+-------------------------------------------------------------------------+
| Copyright(c) 2007 |
| Authors: |
@@ -10,94 +10,11 @@
| world-wide-web at the following url: |
| http://phd.php.net/LICENSE |
+-------------------------------------------------------------------------+
- | Provides the common code for managing the config.php file in setup.php. |
+ | The metadata for PhD configuration options. |
+-------------------------------------------------------------------------+
*/
-class Phd_Options {
-
- const TYPE_ARBITRARY = 0; // Any user-entered value
- const TYPE_LIST = 1; // One of a list of enumerated values
- const TYPE_NUMERIC = 2; // Any integer
- const TYPE_FILESIZE = 3; // A positive integer including the
[KMGTP[B]] suffix
- const TYPE_FLAG = 4; // Boolean flag
-
- public static function getType( $optName ) {
- global $OPTIONS_DATA;
-
- if ( empty( $OPTIONS_DATA[ $optName ] ) ) {
- return NULL;
- }
- return $OPTIONS_DATA[ $optName ][ 'type' ];
- }
-
- public static function getValueList( $optName ) { // TYPE_LIST options
only
- global $OPTIONS_DATA;
-
- if ( PhD_Options::getType( $optName ) != PhD_Options::TYPE_LIST ) {
- return NULL;
- }
- return call_user_func( $OPTIONS_DATA[ $optName ][ 'value_list_func' ]
);
- }
-
- public static function checkValidity( $optName, $value ) {
- global $OPTIONS_DATA;
-
- if ( ( $type = PhD_Options::getType( $optName ) ) === NULL ) {
- return NULL;
- }
- switch ( $type ) {
- case PhD_Options::TYPE_ARBITRARY:
- return call_user_func( $OPTIONS_DATA[ $optName ][
'validity_func' ], $value );
- case PhD_Options::TYPE_LIST:
- return in_array( $value, PhD_Options::getValueList( $optName )
);
- case PhD_Options::TYPE_NUMERIC:
- if ( ctype_digit( $value ) ) {
- return ( $value >= $OPTIONS_DATA[ $optName ][ 'min_value'
] &&
- $value <= $OPTIONS_DATA[ $optName ][ 'max_value'
] );
- }
- return FALSE;
- case PhD_Options::TYPE_FILESIZE:
- return preg_match( '/^(\d+)(?:([KMGTP])B?)?$/iu', $value ) ?
TRUE : FALSE;
- case PhD_Options::TYPE_FLAG:
- return in_array( substr( strtolower( $value ), 0, 1 ), array(
1, 0, 'y', 'n' ) ) || $value === TRUE || $value === FALSE;
- default:
- return NULL;
- }
- }
-
- public static function getFinalValue( $optName, $value ) {
- global $OPTIONS_DATA;
-
- if ( ( $type = PhD_Options::getType( $optName ) ) === NULL ) {
- return NULL;
- }
- switch ( $type ) {
- case PhD_Options::TYPE_ARBITRARY:
- return isset( $OPTIONS_DATA[ $optName ][ 'final_value_func' ]
) ?
- call_user_func( $OPTIONS_DATA[ $optName ][
'final_value_func' ], $value ) : $value;
- case PhD_Options::TYPE_LIST:
- case PhD_Options::TYPE_NUMERIC:
- return $value;
- case PhD_Options::TYPE_FILESIZE:
- preg_match( '/^(\d+)(?:([KMGTP])B?)?$/iu', $value, $matches );
- $multipliers = array(
- '' => 1,
- 'K' => 1024,
- 'M' => 1048576,
- 'G' => 1073741824,
- 'T' => 1099511627776,
- 'P' => 1125899906842620
- );
- return ( intval( $matches[ 1 ] ) * $multipliers[ strval(
$matches[ 2 ] ) ] );
- case PhD_Options::TYPE_FLAG:
- return is_bool( $value ) ? $value : ( substr( strtolower(
$value ), 0, 1 ) == 'y' ? TRUE : FALSE );
- default:
- return NULL;
- }
- }
-
-}
+require_once 'PhD_Options.class.php';
function OPTIONS_META_scan_script_dir( $name ) {
static $lists = NULL;
@@ -305,11 +222,10 @@
'type' => PhD_Options::TYPE_FLAG,
'default_value' => FALSE,
'description' => <<<~MESSAGE
-PhD is capable of using either traditional <!-- Revision: --> and
-<!-- EN-Revision: --> tags or the <phd:revision/> tag to specify version
-control information for files and their translated counterparts. If the
-revision control flag is set, PhD will enforce revision matching between
-translated files and English files.
+PhD is capable of using the <phd:revision/> tag to specify version control
+information for files and their translated counterparts. If the revision
+control flag is set, PhD will enforce revision matching between translated
+files and English files.
MESSAGE
,
'details' => <<<~MESSAGE
@@ -324,6 +240,37 @@
'invalid_message' => 'Please enter "(Y)es" or "(N)o".'
),
+ 'compatibility_mode' => array(
+ 'display_name' => 'Compatibility mode',
+ 'type' => PhD_Options::TYPE_FLAG,
+ 'default_value' => TRUE,
+ 'description' => <<<~MESSAGE
+Turning on this flag causes PhD to modify its processing in several ways to
+make it compatible with documentation that was written for a legacy form of
+DocBook publishing, specifically XSL or DSSSL.
+MESSAGE
+ ,
+ 'details' => <<<~MESSAGE
+The specific differences are:
+ - XML files without IDs are not rejected; an ID is autogenerated based on
+ its path relative to the XML root.
+ - XML files containing more than one root element are not rejected; the
+ extra elements are treated as separate sections.
+ - When revision control is on, <!-- Revision: --> and <!-- EN-Revision: -->
+ tags are automatically replaced with an equivelant <phd:revision/> tag.
+ - <!-- [name]: [value] --> tags are automatically replaced with equivelant
+ <phd:meta/> tags.
+ - Entity references and entity delcarations are replaced with equivelant
+ <phd:define/>, <phd:constant/> and <phd:include/> tags.
+WARNING: This extra processing entails an extra phase during the build, which
+will slow it down considerably. Please consider converting old documents to use
+PhD elements using convert.php.
+MESSAGE
+ ,
+ 'prompt' => 'Type "(Y)es" to enable compatibility mode, or "(N)o" to
disable it',
+ 'invalid_message' => 'Please enter "(Y)es" or "(N)o".'
+ ),
+
'build_log_file' => array(
'display_name' => 'Build Log',
'type' => PhD_Options::TYPE_ARBITRARY,
http://cvs.php.net/viewvc.cgi/phd/setup/setup.messages.php?r1=1.6&r2=1.7&diff_format=u
Index: phd/setup/setup.messages.php
diff -u phd/setup/setup.messages.php:1.6 phd/setup/setup.messages.php:1.7
--- phd/setup/setup.messages.php:1.6 Tue Aug 7 08:09:07 2007
+++ phd/setup/setup.messages.php Wed Aug 8 23:26:05 2007
@@ -1,6 +1,6 @@
<?php
-/* $Id: setup.messages.php,v 1.6 2007/08/07 08:09:07 gwynne Exp $
+/* $Id: setup.messages.php,v 1.7 2007/08/08 23:26:05 gwynne Exp $
+-------------------------------------------------------------------------+
| Copyright(c) 2007 |
| Authors: |
@@ -10,27 +10,12 @@
| world-wide-web at the following url: |
| http://phd.php.net/LICENSE |
+-------------------------------------------------------------------------+
- | Provides the text for error, warning, and status messages in setup.php. |
+ | The text for error, warning, and status messages in setup.php. |
+-------------------------------------------------------------------------+
*/
-class PhD_Output {
-
- protected static $argList = NULL;
- protected static function paramStringCallback( $v ) {
- $v = next( self::$argList );
- return ( is_bool( $v ) ? ( $v ? "Yes" : "No" ) : $v );
- }
- public static function paramString( $whichClass, $constName /*, ... */ ) {
- self::$argList = func_get_args(); next( self::$argList );
- $str = constant( "PhD_{$whichClass}s::{$constName}" );
- return count( self::$argList ) > 2 ?
- preg_replace_callback( '/%%%/', array( __CLASS__,
'paramStringCallback' ), $str ) :
- $str;
- }
+require_once 'PhD_Output.class.php';
-}
-
class PhD_Messages {
const USAGE = <<<~MESSAGE
@@ -63,8 +48,7 @@
const NUMBYTES_VALUES = <<<~MESSAGE
This is a value given in number of bytes. For convenience you may use any of
-the following suffixes to multiply the number by the shown factor. By the way,
-if you actually use the P suffix, I pity you.
+the following suffixes to multiply the number by the shown factor.
K = 1024, M = K*1024, G = M*1024, T = G*1024, P = T*1024
MESSAGE;
@@ -78,8 +62,7 @@
MESSAGE;
const CONFIG_SAVED = <<<~MESSAGE
-The settings were successfully saved to config.php. You may now start using
-PhD.
+Your settings were successfully saved to config.php. PhD is now ready for use.
MESSAGE;
}
http://cvs.php.net/viewvc.cgi/phd/setup/setup.php?r1=1.5&r2=1.6&diff_format=u
Index: phd/setup/setup.php
diff -u phd/setup/setup.php:1.5 phd/setup/setup.php:1.6
--- phd/setup/setup.php:1.5 Tue Aug 7 08:09:07 2007
+++ phd/setup/setup.php Wed Aug 8 23:26:05 2007
@@ -1,6 +1,6 @@
<?php
-/* $Id: setup.php,v 1.5 2007/08/07 08:09:07 gwynne Exp $
+/* $Id: setup.php,v 1.6 2007/08/08 23:26:05 gwynne Exp $
+-------------------------------------------------------------------------+
| Copyright(c) 2007 |
| Authors: |
@@ -10,42 +10,29 @@
| world-wide-web at the following url: |
| http://phd.php.net/LICENSE |
+-------------------------------------------------------------------------+
- | Provides a simple CLI interface for configuration of the per-site PhD |
- | system options. Chosen options are saved in config.php, an |
- | automagically generated file. An existing config.php is presumed to |
- | offer defaults for setup. No user authentication is done by this |
- | script; do not make it accessible to non-administrators. |
+ | A simple interface to configuration of the per-site PhD system options. |
+ | Chosen options are saved in config.php, an automatically generated |
+ | file. An existing config.php is presumed to offer defaults for setup. |
+ | No user authentication is done by this script; do not make it |
+ | accessible to non-administrators. |
+-------------------------------------------------------------------------+
*/
-$SETUP_REVISION = '$Id: setup.php,v 1.5 2007/08/07 08:09:07 gwynne Exp $';
+$SETUP_REVISION = '$Id: setup.php,v 1.6 2007/08/08 23:26:05 gwynne Exp $';
/*---------------------------------------------------------------------------*/
require_once 'setup.messages.php';
require_once 'Option_Metadata.inc.php';
require_once 'Configurator.class.php';
-require_once 'CLI.class.php';
+require_once 'PhD_Interface.class.php';
/*---------------------------------------------------------------------------*/
-function PhD_Error( $message ) {
- print "ERROR: " . PhD_Output::paramString( 'Error', $message ) . "\n";
- exit( 1 );
-}
-
-function PhD_Warning( $message ) {
- print "WARNING: " . PhD_Output::paramString( 'Warning', $message ) ."\n";
-}
-
-/*---------------------------------------------------------------------------*/
-$userInterface = NULL;
+$interface = NULL;
$configurator = NULL;
/*---------------------------------------------------------------------------*/
-if ( php_sapi_name() != 'cli' ) {
- PhD_Error( 'ONLY_CLI_SUPPORTED' );
-}
$configurator = new PhD_Configurator;
-$userInterface = new PhD_CLI_Interface;
+$interface = new PhD_Interface;
/*---------------------------------------------------------------------------*/
// Fill in defaults.
@@ -60,10 +47,10 @@
/*---------------------------------------------------------------------------*/
// Run the interface. TRUE if user chose values, FALSE if user wanted to break
out
-if ( $userInterface->run() === TRUE ) {
+if ( $interface->run() === TRUE ) {
// We have a set of values. We trust the interface to have checked the
validity.
$configurator->writeConfig();
- $userInterface->reportSuccess();
+ $interface->reportSuccess();
} else {
PhD_Warning( 'UNSAVED_CHANGES' );
}
http://cvs.php.net/viewvc.cgi/phd/setup/PhD_Interface.class.php?view=markup&rev=1.1
Index: phd/setup/PhD_Interface.class.php
+++ phd/setup/PhD_Interface.class.php
<?php
/* $Id: PhD_Interface.class.php,v 1.1 2007/08/08 23:26:05 gwynne Exp $
+-------------------------------------------------------------------------+
| Copyright(c) 2007 |
| Authors: |
| Gwynne Raskind <[EMAIL PROTECTED]>
|
| This source file is subject to the license that is bundled with this |
| package in the file LICENSE, and is available through the |
| world-wide-web at the following url: |
| http://phd.php.net/LICENSE |
+-------------------------------------------------------------------------+
| The interface for setup.php to talk to the user. Another version of |
| this code could potentially implement a Web-based configuration. |
+-------------------------------------------------------------------------+
*/
function PhD_Error( $message ) {
print "ERROR: " . PhD_Output::paramString( 'Error', $message ) . "\n";
exit( 1 );
}
function PhD_Warning( $message ) {
print "WARNING: " . PhD_Output::paramString( 'Warning', $message ) ."\n";
}
class PhD_Interface {
protected $quietMode = 0;
public function __construct() {
if ( php_sapi_name() != 'cli' ) {
PhD_Error( 'ONLY_CLI_SUPPORTED' );
}
// If we someday have a version of PHP with the nice long getopt() on
all systems patch...
if ( in_array( '-h', $_SERVER[ 'argv' ] ) || in_array( '--help',
$_SERVER[ 'argv' ] ) ) {
print PhD_Output::paramString( 'Message', 'USAGE', $_SERVER[ 'argv'
][ 0 ] );
exit( 1 );
}
if ( in_array( '-q', $_SERVER[ 'argv' ] ) || in_array( '--quiet',
$_SERVER[ 'argv' ] ) ) {
$this->quietMode = 1;
} else if ( in_array( '-s', $_SERVER[ 'argv' ] ) || in_array(
'--silent', $_SERVER[ 'argv' ] ) ) {
$this->quietMode = 2;
} else if ( in_array( '-v', $_SERVER[ 'argv' ] ) || in_array(
'--verbose', $_SERVER[ 'argv' ] ) ) {
$this->quietMode = 0;
}
}
public function __destruct() {
}
public function run() {
global $configurator, $OPTIONS, $OPTIONS_DATA;
$now = date( DATE_RFC2822 );
print PhD_Output::paramString( 'Message', 'CONFIG_BEGIN', $now ) .
"\n\n";
do {
$this->displaySettings( 'CURRENT_SETTINGS' );
print PhD_Output::paramString( 'Prompt', 'INSTRUCTIONS' ) . "\n\n";
foreach ( $OPTIONS_DATA as $optionName => $optionData ) {
printf( "%-40s\n", "{$optionData[ 'display_name' ]}:" );
if ( $this->quietMode < 2 ) {
print "{$optionData[ 'description' ]}\n";
}
if ( $this->quietMode < 1 ) {
print "{$optionData[ 'details' ]}\n";
}
switch ( PhD_Options::getType( $optionName ) ) {
case PhD_Options::TYPE_ARBITRARY:
print PhD_Output::paramString( 'Message', 'NO_VALUES' );
break;
case PhD_Options::TYPE_LIST:
print PhD_Output::paramString( 'Message',
'AVAILABLE_VALUES',
wordwrap( "\t" . implode( ' ',
PhD_Options::getValueList( $optionName ) ), 71, "\n\t", FALSE ) );
break;
case PhD_Options::TYPE_NUMERIC:
print PhD_Output::paramString( 'Message',
'NUMERIC_VALUE',
$optionData[ 'min_value' ], $optionData[
'max_value' ] );
break;
case PhD_Options::TYPE_FILESIZE:
print PhD_Output::paramString( 'Message',
'NUMBYTES_VALUES' );
break;
case PhD_Options::TYPE_FLAG:
print PhD_Output::paramString( 'Message',
'BOOLEAN_VALUES' );
break;
default:
PhD_Error( 'INTERNAL_ERROR' );
}
print "\n\n";
do {
$response = $this->getLine( PhD_Output::paramString(
'Prompt', 'OPTION_PROMPT', $optionData[ 'prompt' ],
$configurator->$optionName ) );
if ( $response === '' ) {
$response = $configurator->$optionName;
}
if ( PhD_Options::checkValidity( $optionName, $response )
=== TRUE ) {
break;
}
print "{$optionData[ 'invalid_message' ]}\n";
} while ( TRUE );
$configurator->$optionName = PhD_Options::getFinalValue(
$optionName, $response );
print "\n";
}
$this->displaySettings( 'CHOSEN_SETTINGS' );
do {
$response = $this->getLine( PhD_Output::paramString( 'Prompt',
'CONFIG_COMPLETE' ) );
switch ( strval( $response ) ) {
case 'yes':
return TRUE;
case 'restart':
continue 3;
case 'quit':
return FALSE;
default:
print PhD_Output::paramString( 'Prompt',
'INVALID_CONFIG_COMPLETE' );
continue 2;
}
} while ( TRUE );
} while ( TRUE );
}
public function reportSuccess() {
print "\n" . PhD_Output::paramString( 'Message', 'CONFIG_SAVED' ) .
"\n\n";
}
protected function getLine( $prompt = NULL ) {
if ( !is_null( $prompt ) ) {
print $prompt;
}
if ( ( $result = fgets( STDIN ) ) === FALSE ) {
PhD_Error( 'INPUT_EOF' );
}
return trim( $result );
}
protected function displaySettings( $headerConst ) {
global $configurator, $OPTIONS_DATA;
print PhD_Output::paramString( 'Message', $headerConst ) . "\n";
foreach ( $OPTIONS_DATA as $name => $data ) {
printf( "\t%-25s: %s\n", $name,
is_bool( $configurator->$name ) ? ( $configurator->$name ? "On"
: "Off" ) : $configurator->$name );
}
print "\n";
}
}
/*
* vim600: sw=4 ts=4 fdm=syntax syntax=php et
* vim<600: sw=4 ts=4
*/
?>
http://cvs.php.net/viewvc.cgi/phd/setup/PhD_Options.class.php?view=markup&rev=1.1
Index: phd/setup/PhD_Options.class.php
+++ phd/setup/PhD_Options.class.php
<?php
/* $Id: PhD_Options.class.php,v 1.1 2007/08/08 23:26:05 gwynne Exp $
+-------------------------------------------------------------------------+
| Copyright(c) 2007 |
| Authors: |
| Gwynne Raskind <[EMAIL PROTECTED]>
|
| This source file is subject to the license that is bundled with this |
| package in the file LICENSE, and is available through the |
| world-wide-web at the following url: |
| http://phd.php.net/LICENSE |
+-------------------------------------------------------------------------+
| A facility for easily managing option metadata. |
+-------------------------------------------------------------------------+
*/
class Phd_Options {
const TYPE_ARBITRARY = 0; // Any user-entered value
const TYPE_LIST = 1; // One of a list of enumerated values
const TYPE_NUMERIC = 2; // Any integer
const TYPE_FILESIZE = 3; // A positive integer including the
[KMGTP[B]] suffix
const TYPE_FLAG = 4; // Boolean flag
public static function getType( $optName ) {
global $OPTIONS_DATA;
if ( empty( $OPTIONS_DATA[ $optName ] ) ) {
return NULL;
}
return $OPTIONS_DATA[ $optName ][ 'type' ];
}
public static function getValueList( $optName ) { // TYPE_LIST options
only
global $OPTIONS_DATA;
if ( PhD_Options::getType( $optName ) != PhD_Options::TYPE_LIST ) {
return NULL;
}
return call_user_func( $OPTIONS_DATA[ $optName ][ 'value_list_func' ] );
}
public static function checkValidity( $optName, $value ) {
global $OPTIONS_DATA;
if ( ( $type = PhD_Options::getType( $optName ) ) === NULL ) {
return NULL;
}
switch ( $type ) {
case PhD_Options::TYPE_ARBITRARY:
return call_user_func( $OPTIONS_DATA[ $optName ][
'validity_func' ], $value );
case PhD_Options::TYPE_LIST:
return in_array( $value, PhD_Options::getValueList( $optName )
);
case PhD_Options::TYPE_NUMERIC:
if ( ctype_digit( $value ) ) {
return ( $value >= $OPTIONS_DATA[ $optName ][ 'min_value' ]
&&
$value <= $OPTIONS_DATA[ $optName ][ 'max_value' ]
);
}
return FALSE;
case PhD_Options::TYPE_FILESIZE:
return preg_match( '/^(\d+)(?:([KMGTP])B?)?$/iu', $value ) ?
TRUE : FALSE;
case PhD_Options::TYPE_FLAG:
return in_array( substr( strtolower( $value ), 0, 1 ), array(
1, 0, 'y', 'n' ) ) ||
$value === TRUE || $value === FALSE;
default:
return NULL;
}
}
public static function getFinalValue( $optName, $value ) {
global $OPTIONS_DATA;
if ( ( $type = PhD_Options::getType( $optName ) ) === NULL ) {
return NULL;
}
switch ( $type ) {
case PhD_Options::TYPE_ARBITRARY:
return isset( $OPTIONS_DATA[ $optName ][ 'final_value_func' ] )
?
call_user_func( $OPTIONS_DATA[ $optName ][
'final_value_func' ], $value ) : $value;
case PhD_Options::TYPE_LIST:
case PhD_Options::TYPE_NUMERIC:
return $value;
case PhD_Options::TYPE_FILESIZE:
preg_match( '/^(\d+)(?:([KMGTP])B?)?$/iu', $value, $matches );
$multipliers = array(
'' => 1,
'K' => 1024,
'M' => 1048576,
'G' => 1073741824,
'T' => 1099511627776,
'P' => 1125899906842620
);
return ( intval( $matches[ 1 ] ) * $multipliers[ strval(
$matches[ 2 ] ) ] );
case PhD_Options::TYPE_FLAG:
return is_bool( $value ) ? $value : ( substr( strtolower(
$value ), 0, 1 ) == 'y' ? TRUE : FALSE );
default:
return NULL;
}
}
}
/*
* vim600: sw=4 ts=4 fdm=syntax syntax=php et
* vim<600: sw=4 ts=4
*/
?>
http://cvs.php.net/viewvc.cgi/phd/setup/PhD_Output.class.php?view=markup&rev=1.1
Index: phd/setup/PhD_Output.class.php
+++ phd/setup/PhD_Output.class.php
<?php
/* $Id: PhD_Output.class.php,v 1.1 2007/08/08 23:26:05 gwynne Exp $
+-------------------------------------------------------------------------+
| Copyright(c) 2007 |
| Authors: |
| Gwynne Raskind <[EMAIL PROTECTED]>
|
| This source file is subject to the license that is bundled with this |
| package in the file LICENSE, and is available through the |
| world-wide-web at the following url: |
| http://phd.php.net/LICENSE |
+-------------------------------------------------------------------------+
| The class for formatting PhD setup messages (use this more globally?). |
+-------------------------------------------------------------------------+
*/
class PhD_Output {
protected static $argList = NULL;
protected static function paramStringCallback( $v ) {
$v = next( self::$argList );
return ( is_bool( $v ) ? ( $v ? "Yes" : "No" ) : $v );
}
public static function paramString( $whichClass, $constName /*, ... */ ) {
self::$argList = func_get_args(); next( self::$argList );
$str = constant( "PhD_{$whichClass}s::{$constName}" );
return count( self::$argList ) > 2 ?
preg_replace_callback( '/%%%/', array( __CLASS__,
'paramStringCallback' ), $str ) :
$str;
}
}
/*
* vim600: sw=4 ts=4 fdm=syntax syntax=php et
* vim<600: sw=4 ts=4
*/
?>