[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 4 5 /** 6 * Generic class for handling custom statuses that are defined via global constants 7 * (as opposed as needing to be registered via some static method in this class) What this class 8 * does is can the list of globally defined constants and grab those that start with a certain prefix, 9 * such as "BLOG_STATUS_", since that will be an indicator that the given constant is a valid status. 10 * While this method is far from clean, it allows to create new statuses on the fly with very 11 * little effort. 12 * 13 * \ingroup DAO 14 */ 15 class GenericStatusList 16 { 17 18 /** 19 * returns a list with all the user statuses that have been defined 20 * so far in the code. 21 * 22 * @return Returns an array where every position is an array with two 23 * keys: "constant" and "value", where "constant" is the name of the constant 24 * that defines this status and "value" is the value assigned to it 25 */ 26 function getStatusList( $prefix, $statusAllId, $includeStatusAll = false ) 27 { 28 // get all the constants defined so far 29 $constants = get_defined_constants(); 30 $statusList = Array(); 31 32 if( $includeStatusAll ) { 33 $statusAllLowercase = strtolower( $statusAllId ); 34 $statusList["$statusAllLowercase"] = -1; 35 } 36 37 foreach( $constants as $constant => $value ) { 38 if( substr( $constant, 0, strlen($prefix)) == $prefix && $constant != $statusAllId ) { 39 $constant = strtolower($constant); 40 $statusList[ "$constant" ] = $value; 41 } 42 } 43 44 return $statusList; 45 } 46 47 /** 48 * @param status The status code we'd like to check 49 * 50 * @return Returns true if the status is valid or false otherwise. By default this 51 * class returns always true so please override it in your own implementations! 52 */ 53 function isValidStatus( $status ) 54 { 55 return( true ); 56 } 57 58 /** 59 * returns the default status code for this class. By default, it is just 'true' 60 * so it is advisable that classes inheriting from this one override this method 61 * with their own 62 * 63 * @return The default status 64 */ 65 function getDefaultStatus() 66 { 67 return( true ); 68 } 69 } 70 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |