Source for file ExtensionRequirement.class.php

Documentation is available at ExtensionRequirement.class.php

  1. <?php
  2. /**
  3. * @package polyphony.startupcheck
  4. *
  5. * @copyright Copyright &copy; 2005, Middlebury College
  6. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  7. *
  8. * @version $Id: ExtensionRequirement.class.php,v 1.6 2007/09/19 14:04:50 adamfranco Exp $
  9. */
  10.  
  11. /**
  12. * This {@link StartupRequirement} checks to make sure PHP has a given extension loaded (or can load it).
  13. *
  14. * @package polyphony.startupcheck
  15. *
  16. * @copyright Copyright &copy; 2005, Middlebury College
  17. * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
  18. *
  19. * @version $Id: ExtensionRequirement.class.php,v 1.6 2007/09/19 14:04:50 adamfranco Exp $
  20. */
  21. class ExtensionRequirement extends StartupRequirement {
  22.  
  23. var $_extension;
  24. /**
  25. * Constructor
  26. * @param string $extension The name of the extension that must be loaded (case-sensitive)
  27. */
  28. function ExtensionRequirement($extension) {
  29. $this->_extension = $extension;
  30. }
  31. /**
  32. * Checks the environment and returns a status value. Return value is one of STARTUP_STATUS_* defines.
  33. * @access public
  34. * @return integer
  35. */
  36. function getStatus()
  37. {
  38. debug::output(
  39. "ExtensionRequirement - checking to make sure PHP loaded $this->_extension.", 7, "StartupCheck");
  40. if (!extension_loaded($this->_extension)) {
  41. $prefix = (PHP_SHLIB_SUFFIX == 'dll') ? 'php_' : '';
  42. if (!@dl($prefix . $this->_extension . "." . PHP_SHLIB_SUFFIX)) {
  43. StartupCheck::error(dgettext("polyphony",
  44. sprintf(
  45. "ExtensionRequirement - PHP extension <b>%s</b> is neither loaded nor could we load it dynamically.",
  46. $this->_extension
  47. )));
  48. return STARTUP_STATUS_ERROR;
  49. }
  50. }
  51. return STARTUP_STATUS_OK;
  52. }
  53. /**
  54. * Returns this requirement's display name.
  55. * @access public
  56. * @return string
  57. */
  58. function getDisplayName()
  59. {
  60. return dgettext("polyphony","PHP Extension Check")." : ".$this->_extension;
  61. }
  62. /**
  63. * Returns a {@link Wizard} object containing fields for user input to complete installation process.
  64. * @access public
  65. * @return ref object
  66. */
  67. function createWizard()
  68. {
  69. $null = null;
  70. return $null;
  71. }
  72. /**
  73. * Tells the requirement class to perform its update/install operation. If user input is required, it is passed in the form of a {@link WizardStep} containing field values.
  74. * @param optional array $properties An array of {@link WizardProperty} objects corresponding to the {@link Wizard} as created by {@link createWizard()}.
  75. * @access public
  76. * @return int Returns the new status of this requirement after attempting update.
  77. */
  78. function doUpdate( $properties = null )
  79. {
  80. return STARTUP_STATUS_NOT_CHECKED;
  81. }
  82. }

Documentation generated on Wed, 19 Sep 2007 10:23:07 -0400 by phpDocumentor 1.3.0RC3