PageRenderTime 27ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/sgl/includes/configuration/prepend.inc.php

http://logisticsouth.googlecode.com/
PHP | 139 lines | 39 code | 22 blank | 78 comment | 10 complexity | a855337f322129e0442f4832618d34df MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0
  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 QCubed Framework
  17. //////////////////////////////
  18. require(__QCUBED_CORE__ . '/framework/DisableMagicQuotes.inc.php');
  19. require(__QCUBED_CORE__ . '/qcubed.inc.php');
  20. ///////////////////////////////
  21. // Define the Application Class
  22. ///////////////////////////////
  23. /**
  24. * The Application class is an abstract class that statically provides
  25. * information and global utilities for the entire web application.
  26. *
  27. * Custom constants for this webapp, as well as global variables and global
  28. * methods should be declared in this abstract class (declared statically).
  29. *
  30. * This Application class should extend from the ApplicationBase class in
  31. * the framework.
  32. */
  33. abstract class QApplication extends QApplicationBase {
  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. // First use the QCubed Autoloader
  42. if (!parent::Autoload($strClassName)) {
  43. // TODO: Run any custom autoloading functionality (if any) here...
  44. }
  45. }
  46. ////////////////////////////
  47. // QApplication Customizations (e.g. EncodingType, etc.)
  48. ////////////////////////////
  49. // public static $EncodingType = 'ISO-8859-1';
  50. ////////////////////////////
  51. // Additional Static Methods
  52. ////////////////////////////
  53. // TODO: Define any other custom global WebApplication functions (if any) here...
  54. }
  55. // Register the autoloader
  56. spl_autoload_register(array('QApplication', 'Autoload'));
  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. * QCubed 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', error_reporting());
  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. session_start();
  89. //////////////////////////////////////////////
  90. // Setup Internationalization and Localization (if applicable)
  91. // Note, this is where you would implement code to do Language Setting discovery, as well, for example:
  92. // * Checking against $_GET['language_code']
  93. // * checking against session (example provided below)
  94. // * Checking the URL
  95. // * etc.
  96. // TODO: options to do this are left to the developer
  97. //////////////////////////////////////////////
  98. if (isset($_SESSION)) {
  99. if (array_key_exists('country_code', $_SESSION))
  100. QApplication::$CountryCode = $_SESSION['country_code'];
  101. if (array_key_exists('language_code', $_SESSION))
  102. QApplication::$LanguageCode = $_SESSION['language_code'];
  103. }
  104. // Initialize I18n if QApplication::$LanguageCode is set
  105. if (QApplication::$LanguageCode)
  106. QI18n::Initialize();
  107. else {
  108. QApplication::$CountryCode = 'es';
  109. QApplication::$LanguageCode = 'es';
  110. QDateTime::$DefaultFormat = 'DD MMMM YYYY';
  111. QI18n::Initialize();
  112. }
  113. if (QApplication::$EncodingType == 'UTF-8') {
  114. QApplication::$Database[1]->NonQuery("SET NAMES 'utf8'");
  115. }
  116. }
  117. ?>