Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revises load order to allow for theme previewing

  • Loading branch information...
commit 240fd6b0254f8c36c2d02b40af208c1880fb3502 1 parent f0e275e
@dleffler dleffler authored
View
41 exponent.php
@@ -32,6 +32,37 @@
// Initialize the MVC framework - for objects we need loaded now
require_once(BASE.'framework/core/expFramework.php');
+
+// Initialize the Sessions Subsystem
+expSession::initialize();
+
+// Initialize the theme subsystem 1.0 compatibility layer
+require_once(BASE.'framework/core/subsystems-1/theme.php');
+if (!defined('DISPLAY_THEME')) {
+ /* exdoc
+ * The directory and class name of the current active theme. This may be different
+ * than the configure theme (DISPLAY_THEME_REAL) due to previewing.
+ */
+ define('DISPLAY_THEME',DISPLAY_THEME_REAL);
+}
+
+if (!defined('THEME_ABSOLUTE')) {
+ /* exdoc
+ * The absolute path to the current active theme's files. This is similar to the BASE constant
+ */
+ define('THEME_ABSOLUTE',BASE.'themes/'.DISPLAY_THEME.'/'); // This is the recommended way
+}
+
+if (!defined('THEME_RELATIVE')) {
+ /* exdoc
+ * The relative web path to the current active theme. This is similar to the PATH_RELATIVE constant.
+ */
+ define('THEME_RELATIVE',PATH_RELATIVE.'themes/'.DISPLAY_THEME.'/');
+}
+// add our theme folder to autoload and place it first
+$auto_dirs2[] = BASE.'themes/'.DISPLAY_THEME_REAL.'/modules';
+$auto_dirs2 = array_reverse($auto_dirs2);
+
/**
* the list of available/active controllers
* @global array $available_controllers
@@ -40,17 +71,7 @@
$available_controllers = initializeControllers(); //original position
//$available_controllers = array();
-// Initialize the Sessions Subsystem
-expSession::initialize();
-
-// Initialize the theme subsystem 1.0 compatibility layer
-require_once(BASE.'framework/core/subsystems-1/theme.php');
-//$validateTheme = array("headerinfo"=>false,"footerinfo"=>false);
-
// Initialize the language subsystem
-//$cur_lang = array();
-//$default_lang = array();
-//$target_lang_file = '';
expLang::loadLang();
// Initialize the Core Subsystem
View
24 exponent_bootstrap.php
@@ -75,29 +75,7 @@ function __realpath($path) {
require_once(BASE . 'framework/core/subsystems/expSettings.php'); // we don't have our autoloader loaded yet
expSettings::initialize();
-if (!defined('DISPLAY_THEME')) {
- /* exdoc
- * The directory and class name of the current active theme. This may be different
- * than the configure theme (DISPLAY_THEME_REAL) due to previewing.
- */
- define('DISPLAY_THEME',DISPLAY_THEME_REAL);
-}
-
-if (!defined('THEME_ABSOLUTE')) {
- /* exdoc
- * The absolute path to the current active theme's files. This is similar to the BASE constant
- */
- define('THEME_ABSOLUTE',BASE.'themes/'.DISPLAY_THEME.'/'); // This is the recommended way
-}
-
-if (!defined('THEME_RELATIVE')) {
- /* exdoc
- * The relative web path to the current active theme. This is similar to the PATH_RELATIVE constant.
- */
- define('THEME_RELATIVE',PATH_RELATIVE.'themes/'.DISPLAY_THEME.'/');
-}
-
-// Process PHP-wrapper settings (ini_sets and setting and eventually the autoloader)
+// Process PHP-wrapper settings (ini_sets and settings)
require_once(BASE . 'exponent_php_setup.php');
$info = gd_info();
View
117 exponent_php_setup.php
@@ -40,31 +40,22 @@
@date_default_timezone_set(DISPLAY_DEFAULT_TIMEZONE);
// Initialize the AutoLoader subsystem - for objects we want loaded on the fly
-/** exdoc
- * In PHP5, the autoloader function will check these
- * directories when it tries to load a class definition
- * file. Other parts of the system should append to this
- * directory as needed, in order to take full advantage
- * of autoloading
- * @node Subsystems:Autoloader
- */
-//$auto_dirs = array(BASE.'datatypes', BASE.'framework/core/subsystems-1/forms', BASE.'framework/core/subsystems-1/forms/controls');
$auto_dirs = array(
- BASE.'framework/core/models-1', // old 1.0 /datatypes
- BASE.'framework/core/subsystems-1/forms',
- BASE.'framework/core/subsystems-1/forms/controls',
- BASE.'framework/core/controllers',
- BASE.'framework/core/models', // used to be framework/core/datatypes & framework/datatypes
- BASE.'framework/core/subsystems',
- BASE.'framework/modules/ecommerce/billingcalculators',
- BASE.'framework/modules/ecommerce/shippingcalculators',
- BASE.'framework/modules/ecommerce/products/controllers', //FIXME does NOT exist
- BASE.'framework/modules/ecommerce/products/datatypes', // models
+ BASE.'framework/core/models-1', // old 1.0 /datatypes
+ BASE.'framework/core/subsystems-1/forms',
+ BASE.'framework/core/subsystems-1/forms/controls',
+ BASE.'framework/core/controllers',
+ BASE.'framework/core/models', // used to be framework/core/datatypes & framework/datatypes
+ BASE.'framework/core/subsystems',
+ BASE.'framework/modules/ecommerce/billingcalculators',
+ BASE.'framework/modules/ecommerce/shippingcalculators',
+ BASE.'framework/modules/ecommerce/products/controllers', //FIXME does NOT exist
+ BASE.'framework/modules/ecommerce/products/datatypes', // models
);
$auto_dirs2 = array(
- BASE.'themes/'.DISPLAY_THEME_REAL.'/modules',
- BASE.'framework/modules'
+// BASE.'themes/'.DISPLAY_THEME_REAL.'/modules', //FIXME add this dynamically
+ BASE.'framework/modules'
);
/** exdoc
@@ -86,48 +77,48 @@ function expLoadClasses($class) {
}
// recursive function used for (auto?)loading 2.0 modules controllers & models instead of using initializeControllers()
-// foreach ($auto_dirs2 as $dir) {
-// if (is_readable($dir)) {
-// $dh = opendir($dir);
-// while (($file = readdir($dh)) !== false) {
-// if (is_dir($dir.'/'.$file) && ($file != '..' && $file != '.')) {
-// // load controllers
-// $dirpath = $dir.'/'.$file.'/controllers';
-// if (file_exists($dirpath)) {
-// $controller_dir = opendir($dirpath);
-// while (($ctl_file = readdir($controller_dir)) !== false) {
-// if (substr($ctl_file,0,-4) == $class && substr($ctl_file,-4,4) == ".php") {
-// include_once($dirpath.'/'.$ctl_file);
-// return;
-// }
-// }
-// }
-// // load models
-// $dirpath = $dir.'/'.$file.'/models';
-// if (file_exists($dirpath)) {
-// $controller_dir = opendir($dirpath);
-// while (($ctl_file = readdir($controller_dir)) !== false) {
-// if (substr($ctl_file,0,-4) == $class && substr($ctl_file,-4,4) == ".php") {
-// include_once($dirpath.'/'.$ctl_file);
-// return;
-// }
-// }
-// }
-// }
-// }
-// }
-// }
-//
- // autoload the old school modules instead of using exponent_modules_initialize()
-// if (is_readable(BASE.'framework/modules-1')) {
-// $dh = opendir(BASE.'framework/modules-1');
-// while (($file = readdir($dh)) !== false) {
-// if ($file == $class && is_dir(BASE.'framework/modules-1/'.$file) && is_readable(BASE.'framework/modules-1/'.$file.'/class.php')) {
-// include_once(BASE.'framework/modules-1/'.$file.'/class.php');
-// return;
-// }
-// }
-// }
+ foreach ($auto_dirs2 as $dir) {
+ if (is_readable($dir)) {
+ $dh = opendir($dir);
+ while (($file = readdir($dh)) !== false) {
+ if (is_dir($dir.'/'.$file) && ($file != '..' && $file != '.')) {
+ // load controllers
+ $dirpath = $dir.'/'.$file.'/controllers';
+ if (file_exists($dirpath)) {
+ $controller_dir = opendir($dirpath);
+ while (($ctl_file = readdir($controller_dir)) !== false) {
+ if (substr($ctl_file,0,-4) == $class && substr($ctl_file,-4,4) == ".php") {
+ include_once($dirpath.'/'.$ctl_file);
+ return;
+ }
+ }
+ }
+ // load models
+ $dirpath = $dir.'/'.$file.'/models';
+ if (file_exists($dirpath)) {
+ $controller_dir = opendir($dirpath);
+ while (($ctl_file = readdir($controller_dir)) !== false) {
+ if (substr($ctl_file,0,-4) == $class && substr($ctl_file,-4,4) == ".php") {
+ include_once($dirpath.'/'.$ctl_file);
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // autoload the old school modules instead of using exponent_modules_initialize()
+ if (is_readable(BASE.'framework/modules-1')) {
+ $dh = opendir(BASE.'framework/modules-1');
+ while (($file = readdir($dh)) !== false) {
+ if ($file == $class && is_dir(BASE.'framework/modules-1/'.$file) && is_readable(BASE.'framework/modules-1/'.$file.'/class.php')) {
+ include_once(BASE.'framework/modules-1/'.$file.'/class.php');
+ return;
+ }
+ }
+ }
}
View
40 framework/core/subsystems/expSession.php
@@ -87,7 +87,7 @@ public static function clearUserCache() {
self::clearCurrentUserSessionCache();
}
- /* exdoc
+ /** exdoc
* Runs necessary code to initialize sessions for use.
* This sends the session cookie header (via the session_start
* PHP function) and sets up session variables needed by the
@@ -98,7 +98,7 @@ public static function initialize() {
// session key may be overridden
if (!defined('SYS_SESSION_KEY')) {
- /* exdoc
+ /** exdoc
* @state <b>UNDOCUMENTED</b>
* @node Undocumented
*/
@@ -110,10 +110,10 @@ public static function initialize() {
define('SYS_SESSION_COOKIE','PHPSESSID');
}
- $sessid = '';
+// $sessid = '';
if (isset($_GET['expid']))
{
- $sessid = $_GET['expid'];
+ $sessid = $_GET['expid'];
}
else if (isset($_POST['expid']))
{
@@ -147,7 +147,7 @@ public static function initialize() {
}
}
- /* exdoc
+ /** exdoc
* Validates the stored session ticket against the database. This is used
* to force refreshes and force logouts. It also updates activity time.
* @node Subsystems:Sessions
@@ -195,10 +195,12 @@ public static function validate() {
define('SITE_403_HTML', SITE_403_REAL_HTML);
}
- /* exdoc
+ /** exdoc
* Creates user ticket in sessionticket table and session
*
+ * @param $ticket
* @param User $user The user object of the newly logged-in user. Uses id of 0 if not supplied.
+ * @return
* @node Subsystems:Sessions
*/
public static function updateTicket($ticket, $user){
@@ -211,12 +213,14 @@ public static function updateTicket($ticket, $user){
return $ticket;
}
- /* exdoc
+ /** exdoc
* Checks to see if the session holds a set variable of the given name.
*
* Note that some session variables (like the user object and the ticket)
* cannot be changed using this call (for security / sanity reason)
* @node Subsystems:Sessions
+ * @param $var
+ * @return bool
*/
public static function is_set($var) {
return isset($_SESSION[SYS_SESSION_KEY]['vars'][$var]);
@@ -241,7 +245,7 @@ public static function getTicketString() {
}
}
- /* exdoc
+ /** exdoc
* Removes a variable from the session.
*
* Note that some session variables (like the user object and the ticket)
@@ -270,7 +274,7 @@ public static function login($user) {
exponent_permissions_load($user);
}
- /* exdoc
+ /** exdoc
* Clears the session of all user data, used when a user logs out.
* This gets rid of stale session tickets, and resets the session
* to a blank state.
@@ -286,11 +290,12 @@ public static function logout() {
//redirect_to(array('section'=>SITE_DEFAULT_SECTION));
}
- /* exdoc
+ /** exdoc
* Looks at the session data to see if the current session is
* that of a logged in user. Returns true if the viewer is logged
* in, and false if it is not
* @node Subsystems:Sessions
+ * @return bool
*/
public static function loggedIn() {
//if ($anon){
@@ -301,7 +306,7 @@ public static function loggedIn() {
//}
}
- /* exdoc
+ /** exdoc
* Clears global users session cache
*
* @param Modules $modules If not set, applies to all modules. If set, will only clear cache for that module
@@ -342,11 +347,12 @@ public static function clearAllUsersSessionCache($modules = null, $user = null)
*/
}
- /* exdoc
+ /** exdoc
* Clears current users session cache
*
* @param Modules $modules Array or string. If not set, applies to all modules. If set, will only clear cache for that module
- * @param User $user if not set,applies to all users. If set, will only clear for that user
+ *
+ * @internal param \User $user if not set,applies to all users. If set, will only clear for that user
* @node Subsystems:Sessions
*/
public static function clearCurrentUserSessionCache($modules = null) {
@@ -364,17 +370,21 @@ public static function clearCurrentUserSessionCache($modules = null) {
}
}
- //Clears entire user session data and truncates the sessionticket table
+ /**
+ * Clears entire user session data and truncates the sessionticket table
+ *
+ */
public static function clearAllSessionData(){
global $db;
$db->delete('sessionticket',"1");
unset($_SESSION[SYS_SESSION_KEY]);
}
- /* exdoc
+ /** exdoc
* Creates user ticket in sessionticket table and session
*
* @param User $user The user object of the newly logged-in user. Uses id of 0 if not supplied.
+ * @return null
* @node Subsystems:Sessions
*/
static function createTicket($user = null){
View
33 framework/core/subsystems/expSettings.php
@@ -21,7 +21,11 @@
class expSettings {
public static function initialize() {
- //overides function html entity decode
+ /**
+ * overides function html entity decode
+ * @param $str
+ * @return string
+ */
function exponent_unhtmlentities( $str ) {
$trans = get_html_translation_table(HTML_ENTITIES);
$trans['&apos;'] = '\'';
@@ -51,7 +55,7 @@ function exponent_unhtmlentities( $str ) {
}
}
- /* exdoc
+ /** exdoc
* Uses magical regular expressions voodoo to pull the
* actuall define() calls out of a configuration PHP file,
* and return them in an associative array, for use in
@@ -59,6 +63,8 @@ function exponent_unhtmlentities( $str ) {
* array of constant names => values
*
* @param string $configname Configuration Profile name
+ * @param null $site_root
+ * @return array
* @node Subsystems:Config
*/
public static function parse($configname,$site_root = null) {
@@ -94,13 +100,14 @@ public static function parse($configname,$site_root = null) {
return $options;
}
- /* exdoc
+ /** exdoc
* Looks through the source of a given configuration PHP file,
* and pulls out (by mysterious regular expressions) the define()
* calls and returns those values. Returns an associative array
* of constant names => values
*
* @param string $file The full path to the file to parse.
+ * @return array
* @node Subsystems:Config
*/
public static function parseFile($file) {
@@ -130,7 +137,7 @@ public static function parseFile($file) {
return $options;
}
- /* exdoc
+ /** exdoc
* This function looks through all of the available configuration
* extensions, and generates a form object consisting of each
* extension's form part. This can then be used to edit the full
@@ -138,6 +145,8 @@ public static function parseFile($file) {
*
* @param string $configname The name of the configuration profile,
* for filling in default values.
+ * @param bool $database
+ * @return \form
* @node Subsystems:Config
*/
public static function configurationForm($configname,$database=false) {
@@ -253,12 +262,13 @@ public static function writeFile($str, $configname="") {
//}
}
- /* exdoc
+ /** exdoc
* Processes the POSTed data from the configuration form
* object generated by self::configurationForm, and writes
* a bunch of define() statements to the profiles config file.
*
* @param array $values The _POST array to pull configuration data from.
+ * @param null $site_root
* @node Subsystems:Config
*/
public static function saveConfiguration($values,$site_root=null) {
@@ -351,13 +361,14 @@ public static function saveConfiguration($values,$site_root=null) {
}
}
- /* exdoc
+ /** exdoc
* Takes care of setting the appropriate template variables
* to be used when viewing a profile or set of profiles.
* Returns the initializes template.
*
* @param template $template The template object to assign to.
* @param string $configname The name of the configuration profile.
+ * @return \template
* @node Subsystems:Config
*/
public static function outputConfigurationTemplate($template,$configname) {
@@ -389,13 +400,14 @@ public static function outputConfigurationTemplate($template,$configname) {
return $template;
}
- /* exdoc
+ /** exdoc
* Looks through the conf/profiles directory, and finds all of
* the configuration profiles in existence. This function also
* performs some minor name-mangling, to make the Profile Names
* more user friendly. Returns an array of Profile names.
*
* @node Subsystems:Config
+ * @return array
*/
public static function profiles() {
$profiles = array();
@@ -411,7 +423,7 @@ public static function profiles() {
return $profiles;
}
- /* exdoc
+ /** exdoc
* Deletes a configuration profile from the conf/profiles
* directory.
*
@@ -425,7 +437,7 @@ public static function deleteProfile($profile) {
}
}
- /* exdoc
+ /** exdoc
* Activates a Configuration Profile.
*
* @param string $profile The name of the Profile to activate.
@@ -440,10 +452,11 @@ public static function activateProfile($profile) {
}
}
- /* exdoc
+ /** exdoc
* Parse Drop Down options from a file.
* @param string $dropdown_name The name of the dropdown type. The name of the
* file will be retrieved by adding .dropdown as a suffix, and searching the conf/data directory.
+ * @return array
* @node Subsystems:Config
*/
public static function dropdownData($dropdown_name) {
Please sign in to comment.
Something went wrong with that request. Please try again.