$color[16] = '#ff9933'; /* (orange) Highlight color */
require(SM_PATH . 'functions/global.php');
+require(SM_PATH . 'functions/arrays.php');
/* load default configuration */
require(SM_PATH . 'config/config_default.php');
}
}
+/**
+ * Before 1.5.2 version hook was part of functions/constants.php.
+ * After init layout changes, hook had to be moved because include/constants.php is
+ * loaded before plugins are initialized.
+ * @since 1.2.0
+ */
+do_hook('loading_constants');
switch ($sInitLocation) {
- case 'style': session_write_close(); sqsetcookieflush(); break;
+ case 'style':
+
+ // need to get the right template set up
+ sqGetGlobalVar('templatedir', $templatedir, SQ_GET);
+
+ // sanitize just in case...
+ $templatedir = preg_replace('/(\.\.\/){1,}/', '', $templatedir);
+
+ // could also conceivably make sure given templatedir is in $aTemplateSet
+
+ // set template directory only if what was given is valid
+ if (is_dir(SM_PATH . 'templates/' . $templatedir . '/')) {
+ $sTplDir = SM_PATH . 'templates/' . $templatedir . '/';
+ }
+
+ session_write_close();
+ sqsetcookieflush();
+ break;
+
case 'redirect':
/**
* directory hashing functions are needed for all setups in case
$prefs_cache = false; //array();
}
- /* see 'redirect' switch */
+ /* see 'redirect' case */
require(SM_PATH . 'functions/prefs.php');
$prefs_backend = do_hook_function('prefs_backend');
*/
require(SM_PATH . 'include/load_prefs.php');
-
// i do not understand the frames language cookie story
/**
* We'll need this to later have a noframes version
* Initialize the template object
*/
require(SM_PATH . 'class/template/template.class.php');
+
/*
* $sTplDir is not initialized when a user is not logged in, so we will use
- * the config file defaults here. If the neccesary variables are net set,
+ * the config file defaults here. If the neccesary variables are not set,
* force a default value.
+ *
+ * If the user is logged in, $sTplDir will be set in load_prefs.php, so we
+ * shouldn't change it here.
*/
-$aTemplateSet = ( !isset($aTemplateSet) ? array() : $aTemplateSet );
-$templateset_default = ( !isset($templateset_default) ? 0 : $templateset_default );
-
-$sTplDir = ( !isset($aTemplateSet[$templateset_default]['PATH']) ?
- SM_PATH . 'templates/default/' :
- $aTemplateSet[$templateset_default]['PATH'] );
+if (!isset($sTplDir)) {
+ $aTemplateSet = ( !isset($aTemplateSet) ? array() : $aTemplateSet );
+ $templateset_default = ( !isset($templateset_default) ? 0 : $templateset_default );
+
+ $sTplDir = !isset($aTemplateSet[$templateset_default]['PATH']) ? SM_PATH . 'templates/default/' : $aTemplateSet[$templateset_default]['PATH'];
+ $icon_theme_path = !$use_icons ? NULL : $sTplDir . 'images/';
+}
$oTemplate = new Template($sTplDir);
+// We want some variables to always be available to the template
+$always_include = array('sTplDir', 'icon_theme_path');
+foreach ($always_include as $var) {
+ $oTemplate->assign($var, (isset($$var) ? $$var : NULL));
+}
+
/**
* Initialize our custom error handler object
*/