A Qcodo based CMS/ecommerce framework
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

134 lines
4.1 KiB

12 years ago
  1. <?php
  2. if (!defined('__PREPEND_INCLUDED__')) {
  3. // Ensure prepend.inc is only executed once
  4. define('__PREPEND_INCLUDED__', 1);
  5. ///////////////////////////////////
  6. // Define Server-specific constants
  7. ///////////////////////////////////
  8. /*
  9. * This assumes that the configuration include file is in the same directory
  10. * as this prepend include file. For security reasons, you can feel free
  11. * to move the configuration file anywhere you want. But be sure to provide
  12. * a relative or absolute path to the file.
  13. */
  14. require(dirname(__FILE__) . '/configuration.inc.php');
  15. //////////////////////////////
  16. // Include the Qcodo Framework
  17. //////////////////////////////
  18. require(__QCODO_CORE__ . '/qcodo.inc.php');
  19. ///////////////////////////////
  20. // Define the Application Class
  21. ///////////////////////////////
  22. /**
  23. * The Application class is an abstract class that statically provides
  24. * information and global utilities for the entire web application.
  25. *
  26. * Custom constants for this webapp, as well as global variables and global
  27. * methods should be declared in this abstract class (declared statically).
  28. *
  29. * This Application class should extend from the ApplicationBase class in
  30. * the framework.
  31. */
  32. abstract class QApplication extends QApplicationBase
  33. {
  34. /**
  35. * This is called by the PHP5 Autoloader. This method overrides the
  36. * one in ApplicationBase.
  37. *
  38. * @return void
  39. */
  40. public static function Autoload($strClassName)
  41. {
  42. // First use the Qcodo Autoloader
  43. if (!parent::Autoload($strClassName))
  44. {
  45. // TODO: Run any custom autoloading functionality (if any) here...
  46. }
  47. }
  48. ////////////////////////////
  49. // QApplication Customizations (e.g. EncodingType, etc.)
  50. ////////////////////////////
  51. // public static $EncodingType = 'ISO-8859-1';
  52. ////////////////////////////
  53. // Additional Static Methods
  54. ////////////////////////////
  55. //Define any other custom global WebApplication functions (if any) here...
  56. }
  57. //////////////////////////
  58. // Custom Global Functions
  59. //////////////////////////
  60. // TODO: Define any custom global functions (if any) here...
  61. ////////////////
  62. // Include Files
  63. ////////////////
  64. // TODO: Include any other include files (if any) here...
  65. ///////////////////////
  66. // Setup Error Handling
  67. ///////////////////////
  68. /*
  69. * Set Error/Exception Handling to the default
  70. * Qcodo HandleError and HandlException functions
  71. * (Only in non CLI mode)
  72. *
  73. * Feel free to change, if needed, to your own
  74. * custom error handling script(s).
  75. */
  76. if (array_key_exists('SERVER_PROTOCOL', $_SERVER)) {
  77. set_error_handler('QcodoHandleError');
  78. set_exception_handler('QcodoHandleException');
  79. }
  80. ////////////////////////////////////////////////
  81. // Initialize the Application and DB Connections
  82. ////////////////////////////////////////////////
  83. QApplication::Initialize();
  84. QApplication::InitializeDatabaseConnections();
  85. /////////////////////////////
  86. // Start Session Handler (if required)
  87. /////////////////////////////
  88. if( ! isset($_SESSION))
  89. session_start();
  90. //////////////////////////////////////////////
  91. // Setup Internationalization and Localization (if applicable)
  92. // Note, this is where you would implement code to do Language Setting discovery, as well, for example:
  93. // * Checking against $_GET['language_code']
  94. // * checking against session (example provided below)
  95. // * Checking the URL
  96. // * etc.
  97. // TODO: options to do this are left to the developer
  98. //////////////////////////////////////////////
  99. if (isset($_SESSION)) {
  100. if (array_key_exists('country_code', $_SESSION))
  101. QApplication::$CountryCode = $_SESSION['country_code'];
  102. if (array_key_exists('language_code', $_SESSION))
  103. QApplication::$LanguageCode = $_SESSION['language_code'];
  104. }
  105. // Initialize I18n if QApplication::$LanguageCode is set
  106. if (QApplication::$LanguageCode)
  107. QI18n::Initialize();
  108. else {
  109. // QApplication::$CountryCode = 'us';
  110. // QApplication::$LanguageCode = 'en';
  111. // QI18n::Initialize();
  112. }
  113. }
  114. ?>