Ejemplo n.º 1
0
 /**
  * Loads app/config/bootstrap.php.
  * If the alternative paths are set in this file
  * they will be added to the paths vars.
  *
  * @param boolean $boot Load application bootstrap (if true)
  * @return void
  * @access private
  */
 function __loadBootstrap($app)
 {
     S2Cache::config('_s2framework_core_', array('duration' => 86400, 'engine' => 'File', 'path' => S2Paths::get($app, 'S2_CACHE') . 'core'));
     if (!($fileArray = S2Cache::read($app . '_paths_' . md5(cmsFramework::getConfig('secret')), '_s2framework_core_'))) {
         $configPath = S2Paths::get($app, 'S2_APP_CONFIG');
         if (@(!(include $configPath . 'paths.php'))) {
             trigger_error(sprintf(__t("Can't find application paths file. Please create %spaths.php, and make sure it is readable by PHP.", true), $configPath), E_USER_ERROR);
         }
         $this->basePaths = $basePaths;
         $fileArray = $this->buildPaths($relativePaths);
         $Folder = new Folder();
         $items = array();
         // Build the Theme file array
         foreach ($basePaths as $basePath) {
             if (false === strstr($basePath, 's2framework')) {
                 // Front end theme folder
                 $tree = $Folder->tree($basePath . $themePath);
                 if (is_array($tree)) {
                     foreach ($tree[1] as $file) {
                         // Get the theme name and folder to build an array
                         $path = str_replace($basePath . $themePath . DS, '', $file);
                         $path = explode(DS, $path);
                         if (count($path) > 2) {
                             $theme_folder = array_shift($path);
                             # Begin theme info
                             $pathinfo = pathinfo($file);
                             $parts = explode(DS, str_replace(PATH_ROOT, '', $pathinfo['dirname']));
                             array_pop($parts);
                             $items['Theme'][$theme_folder]['.info']['path'] = str_replace(PATH_ROOT, '', implode(DS, $parts)) . DS;
                             if ($theme_css_pos = strpos($items['Theme'][$theme_folder]['.info']['path'], 'theme_css')) {
                                 $items['Theme'][$theme_folder]['.info']['path'] = substr($items['Theme'][$theme_folder]['.info']['path'], 0, $theme_css_pos);
                             }
                             if ($theme_images_pos = strpos($items['Theme'][$theme_folder]['.info']['path'], 'theme_images')) {
                                 $items['Theme'][$theme_folder]['.info']['path'] = substr($items['Theme'][$theme_folder]['.info']['path'], 0, $theme_images_pos);
                             }
                             $secondToLast = array_pop($parts);
                             $thirdToLast = array_pop($parts);
                             array_pop($parts);
                             if ($secondToLast == 'theme_css' || $thirdToLast == 'theme_css') {
                                 array_pop($parts);
                             }
                             if ($thirdToLast == 'theme_css') {
                                 array_pop($parts);
                             }
                             $items['Theme'][$theme_folder]['.info']['location'] = array_pop($parts);
                             if (strstr($file, 'com_jreviews_addon')) {
                                 $items['Theme'][$theme_folder]['.info']['addon'] = 1;
                             } else {
                                 $items['Theme'][$theme_folder]['.info']['addon'] = 0;
                             }
                             # End theme info
                             # Adds file to theme folder array
                             $theme_subdir = array_shift($path);
                             $theme_file = strtolower(implode(DS, $path));
                             $theme_file_path = str_replace(PATH_ROOT, '', $file);
                             // Exclude images from theme_css folder
                             if ($theme_subdir == 'theme_css' && !strstr($theme_file, '.css')) {
                                 continue;
                             }
                             $items['Theme'][$theme_folder][$theme_subdir][$theme_file] = $theme_file;
                             // $theme_file_path;
                             # Add any extra files to the default theme.
                             # This makes the system think files from different themes are in the default folder without forcing users to move files around
                             // In Component folder we use full relative path because we don't know which theme has been selected
                             if ($items['Theme'][$theme_folder]['.info']['location'] == "jreviews") {
                                 $items['Theme'][$theme_folder][$theme_subdir][$theme_file] = $theme_file_path;
                             }
                             // For any non-default folder, add missing files to default folder with full relative path
                             if ($items['Theme'][$theme_folder]['.info']['location'] != "jreviews" && !isset($items['Theme']['default'][$theme_subdir][$theme_file])) {
                                 $items['Theme']['default'][$theme_subdir][$theme_file] = $theme_file_path;
                             }
                         }
                     }
                 }
                 // Admin theme folder
                 $tree = $Folder->tree($basePath . $themePathAdmin);
                 if (is_array($tree)) {
                     foreach ($tree[1] as $file) {
                         // Get the theme name and folder to build an array
                         $path = str_replace($basePath . $themePathAdmin . DS, '', $file);
                         $path = explode(DS, $path);
                         if (count($path) > 2) {
                             $theme_folder = array_shift($path);
                             # Begin theme info
                             if (!isset($items['AdminTheme'][$theme_folder]['.info'])) {
                                 $pathinfo = pathinfo($file);
                                 $parts = explode(DS, $pathinfo['dirname']);
                                 array_pop($parts);
                                 $items['AdminTheme'][$theme_folder]['.info']['path'] = str_replace(PATH_ROOT, '', implode(DS, $parts)) . DS;
                             }
                             # End theme info
                             # Adds file to theme folder array
                             $theme_subdir = array_shift($path);
                             $theme_file = strtolower(implode(DS, $path));
                             $theme_file_path = str_replace(PATH_ROOT, '', $file);
                             if ($theme_subdir == 'theme_css' && !strstr($theme_file, '.css')) {
                                 continue;
                             }
                             $items['AdminTheme'][$theme_folder][$theme_subdir][$theme_file] = $theme_file;
                             //$theme_file_path;
                             if (!strstr($theme_file_path, 'components' . DS . 'com_jreviews' . DS)) {
                                 $items['AdminTheme']['default'][$theme_subdir][$theme_file] = $theme_file_path;
                             }
                         }
                     }
                 }
                 // Front end js folder
                 $tree = $Folder->tree($basePath . $jsPath);
                 if (is_array($tree)) {
                     foreach ($tree[1] as $file) {
                         if (strstr($file, '.js')) {
                             // Get the theme name and folder to build an array
                             $path = str_replace(array($basePath . $jsPath . DS, DS), array('', _DS), $file);
                             $items['Javascript'][$path] = str_replace(array(PATH_ROOT, DS), array('', _DS), $file);
                         }
                     }
                 }
                 // Admin js folder
                 $tree = $Folder->tree($basePath . $jsPathAdmin);
                 if (is_array($tree)) {
                     foreach ($tree[1] as $file) {
                         if (strstr($file, '.js')) {
                             // Get the theme name and folder to build an array
                             $path = str_replace(array($basePath . $jsPathAdmin . DS, DS), array('', _DS), $file);
                             $items['AdminJavascript'][$path] = str_replace(array(PATH_ROOT, DS), array('', _DS), $file);
                         }
                     }
                 }
             }
         }
         $fileArray = array_merge($fileArray, $items);
         //prx($items['Theme']);exit;
         S2Cache::write($app . '_paths_' . md5(cmsFramework::getConfig('secret')), $fileArray, '_s2framework_core_');
         unset($Folder, $tree);
     }
     $App =& App::getInstance();
     $App->{$app . 'Paths'} = $fileArray;
     unset($this->__items, $items);
 }
Ejemplo n.º 2
0
 /**
  * Loads app/config/bootstrap.php.
  * If the alternative paths are set in this file
  * they will be added to the paths vars.
  *
  * @param boolean $boot Load application bootstrap (if true)
  * @return void
  * @access private
  */
 function __loadBootstrap($app)
 {
     S2Cache::config('_s2framework_core_', array('duration' => 86400, 'engine' => 'File', 'path' => S2Paths::get($app, 'S2_CACHE') . 'core'));
     $fallback_theme = S2Paths::get($app, 'S2_FALLBACK_THEME', 'default');
     $path_root_replace = PATH_ROOT != DS ? PATH_ROOT : '';
     $cache_key = $app . '_paths_' . md5(WWW_ROOT . PATH_ROOT . cmsFramework::getConfig('secret'));
     if (!($fileArray = S2Cache::read($cache_key, '_s2framework_core_'))) {
         $configPath = S2Paths::get($app, 'S2_APP_CONFIG');
         if (@(!(include $configPath . 'paths.php'))) {
             trigger_error(sprintf(__t("Can't find application paths file. Please create %spaths.php, and make sure it is readable by PHP.", true), $configPath), E_USER_ERROR);
         }
         $this->basePaths = $basePaths;
         $fileArray = $this->buildPaths($relativePaths);
         $Folder = new Folder();
         $items = array();
         // Build the Theme file array
         foreach ($basePaths as $basePath) {
             if (false === strstr($basePath, 's2framework')) {
                 // Front end theme folder
                 $Folder->path = $basePath . $themePath;
                 $baseRelPath = ltrim(str_replace($path_root_replace, '', $basePath), DS);
                 list($dirs) = $Folder->read(true);
                 if (!empty($dirs)) {
                     foreach ($dirs as $theme) {
                         $tree = $Folder->tree($basePath . $themePath . DS . $theme);
                         if (is_array($tree) && !empty($tree)) {
                             if (strstr($basePath, 'com_jreviews_addons')) {
                                 $items['Theme'][$theme]['.info']['location'] = 'addon';
                             } elseif (strstr($basePath, 'com_jreviews')) {
                                 $items['Theme'][$theme]['.info']['location'] = 'jreviews';
                             } elseif (strstr($basePath, 'jreviews_overrides')) {
                                 $items['Theme'][$theme]['.info']['location'] = 'overrides';
                             }
                             $themeRelPath = $baseRelPath . $themePath . DS . $theme . DS;
                             $items['Theme'][$theme]['.info']['path'] = $themeRelPath;
                             // Read theme info xml file
                             $infoFile = $basePath . $themePath . DS . $theme . DS . 'themeInfo.xml';
                             if (file_exists($infoFile)) {
                                 $xml = simplexml_load_file($infoFile);
                                 $items['Theme'][$theme]['.info']['name'] = Sanitize::getString($xml->settings, 'name');
                                 $items['Theme'][$theme]['.info']['title'] = Sanitize::getString($xml->settings, 'title');
                                 $items['Theme'][$theme]['.info']['configuration'] = Sanitize::getString($xml->settings, 'configuration', 1);
                                 $items['Theme'][$theme]['.info']['fallback'] = Sanitize::getString($xml->settings, 'fallback', 0);
                                 $items['Theme'][$theme]['.info']['addon'] = Sanitize::getString($xml->settings, 'addon', 0);
                                 $items['Theme'][$theme]['.info']['mobile'] = Sanitize::getString($xml->settings, 'mobile', 0);
                                 $items['Theme'][$theme]['.info']['description'] = Sanitize::getString($xml, 'description');
                             } else {
                                 // Support for themes without xml file
                                 $items['Theme'][$theme]['.info']['name'] = $theme;
                                 $items['Theme'][$theme]['.info']['title'] = $theme;
                                 $items['Theme'][$theme]['.info']['configuration'] = '1';
                                 $items['Theme'][$theme]['.info']['fallback'] = '0';
                                 $items['Theme'][$theme]['.info']['addon'] = $items['Theme'][$theme]['.info']['location'] == (string) 'addon' ? 1 : 0;
                                 $items['Theme'][$theme]['.info']['mobile'] = '0';
                                 $items['Theme'][$theme]['.info']['description'] = 'themeInfo.xml file is missing for this theme.';
                             }
                             foreach ($tree[1] as $file) {
                                 // Get the theme name and folder to build an array
                                 $path = strtolower(str_replace($basePath . $themePath . DS, '', $file));
                                 if (count(explode(DS, $path)) > 2) {
                                     # Adds file to theme folder array
                                     extract(pathinfo($path));
                                     $theme_folder = str_replace($theme . DS, '', $dirname);
                                     $theme_file_path = ltrim(str_replace($path_root_replace, '', $file), DS);
                                     $theme_folder_parts = explode(DS, $theme_folder);
                                     $theme_folder = array_shift($theme_folder_parts);
                                     if ($theme_folder == 'theme_images' && !empty($theme_folder_parts)) {
                                         // Adds support for theme images in sub-folders
                                         $basename = implode(DS, $theme_folder_parts) . DS . $basename;
                                     } elseif (!empty($theme_folder_parts)) {
                                         $basename = array_shift($theme_folder_parts) . DS . $basename;
                                     }
                                     // Exclude images from theme_css folder
                                     if (strstr($theme_folder, 'theme_css') && $extension != 'css') {
                                         continue;
                                     }
                                     $items['Theme'][$theme][$theme_folder][$basename] = $basename;
                                     // $theme_file_path;
                                     # Add any extra files to the default theme.
                                     # This makes the system think files from different themes are in the default folder without forcing users to move files around
                                     // In Component folder we use full relative path because we don't know which theme has been selected
                                     if ($items['Theme'][$theme]['.info']['location'] == "jreviews") {
                                         $items['Theme'][$theme][$theme_folder][$basename] = $theme_file_path;
                                     }
                                     // For any non-default folder, add missing files to default folder with full relative path
                                     if ($items['Theme'][$theme]['.info']['location'] != "jreviews" && !isset($items['Theme'][$fallback_theme][$theme_folder][$basename])) {
                                         $items['Theme'][$fallback_theme][$theme_folder][$basename] = $theme_file_path;
                                     }
                                 }
                             }
                         }
                     }
                 }
                 // Admin theme folder
                 $Folder->path = $basePath . $themePathAdmin;
                 list($dirs) = $Folder->read(true);
                 if (!empty($dirs)) {
                     foreach ($dirs as $theme) {
                         # Begin theme info
                         if (!isset($items['AdminTheme'][$theme]['.info'])) {
                             $themeRelPath = $baseRelPath . $themePathAdmin . DS . $theme . DS;
                             $items['AdminTheme'][$theme]['.info']['path'] = $themeRelPath;
                             $items['AdminTheme'][$theme]['.info']['name'] = $theme;
                             $items['AdminTheme'][$theme]['.info']['title'] = $theme;
                         }
                         $tree = $Folder->tree($basePath . $themePathAdmin . DS . $theme);
                         if (is_array($tree) && !empty($tree)) {
                             foreach ($tree[1] as $file) {
                                 // Get the theme name and folder to build an array
                                 $path = strtolower(str_replace($basePath . $themePathAdmin . DS, '', $file));
                                 if (count(explode(DS, $path)) > 2) {
                                     # Adds file to theme folder array
                                     extract(pathinfo($path));
                                     $theme_folder = str_replace($theme . DS, '', $dirname);
                                     $theme_file_path = ltrim(str_replace($path_root_replace, '', $file), DS);
                                     $theme_folder_parts = explode(DS, $theme_folder);
                                     $theme_folder = array_shift($theme_folder_parts);
                                     !empty($theme_folder_parts) and $basename = array_shift($theme_folder_parts) . DS . $basename;
                                     // Exclude images from theme_css folder
                                     if (strstr($theme_folder, 'theme_css') && $extension != 'css') {
                                         continue;
                                     }
                                     $items['AdminTheme'][$theme][$theme_folder][$basename] = $basename;
                                     //$theme_file_path;
                                     if (!strstr($theme_file_path, 'components' . DS . 'com_jreviews' . DS)) {
                                         $items['AdminTheme']['default'][$theme_folder][$basename] = $theme_file_path;
                                     }
                                 }
                             }
                         }
                     }
                 }
                 // Front end js folder
                 $tree = $Folder->tree($basePath . $jsPath);
                 if (is_array($tree)) {
                     foreach ($tree[1] as $file) {
                         if (strstr($file, '.js')) {
                             // Get the theme name and folder to build an array
                             $path = str_replace(array($basePath . $jsPath . DS, DS), array('', _DS), $file);
                             $items['Javascript'][$path] = ltrim(str_replace(array($path_root_replace, DS), array('', _DS), $file), _DS);
                         }
                     }
                 }
                 // Admin js folder
                 $tree = $Folder->tree($basePath . $jsPathAdmin);
                 if (is_array($tree)) {
                     foreach ($tree[1] as $file) {
                         if (strstr($file, '.js')) {
                             // Get the theme name and folder to build an array
                             $path = str_replace(array($basePath . $jsPathAdmin . DS, DS), array('', _DS), $file);
                             $items['AdminJavascript'][$path] = ltrim(str_replace(array($path_root_replace, DS), array('', _DS), $file), _DS);
                         }
                     }
                 }
             }
         }
         $fileArray = array_merge($fileArray, $items);
         //prx($items['AdminTheme']);exit;
         //prx($items['Theme']);exit;
         //prx($fileArray);exit;
         S2Cache::write($cache_key, $fileArray, '_s2framework_core_');
         unset($Folder, $tree);
     }
     $App =& App::getInstance();
     $App->{$app . 'Paths'} = $fileArray;
     unset($this->__items, $items);
 }
Ejemplo n.º 3
0
 * 		'prefix' => Inflector::slug(APP_DIR) . '_', //[optional]  prefix every cache file with this string
 *	));
 *
 * Xcache (http://xcache.lighttpd.net/)
 *
 * 	 Cache::config('default', array(
 *		'engine' => 'Xcache', //[required]
 *		'duration'=> 3600, //[optional]
 *		'probability'=> 100, //[optional]
 * 		'prefix' => Inflector::slug(APP_DIR) . '_', //[optional] prefix every cache file with this string
 *		'user' => 'user', //user from xcache.admin.user settings
 *      'password' => 'password', //plaintext password (xcache.admin.pass)
 *	));
 *
 *
 * Memcache (http://www.danga.com/memcached/)
 *
 * 	 Cache::config('default', array(
 *		'engine' => 'Memcache', //[required]
 *		'duration'=> 3600, //[optional]
 *		'probability'=> 100, //[optional]
 * 		'prefix' => Inflector::slug(APP_DIR) . '_', //[optional]  prefix every cache file with this string
 * 		'servers' => array(
 * 			'127.0.0.1:11211' // localhost, default port 11211
 * 		), //[optional]
 * 		'compress' => false, // [optional] compress data in Memcache (slower, but uses less memory)
 *	));
 *
 */
S2Cache::config('default', array('engine' => 'File', 'path' => S2Paths::get('jreviews', 'S2_CACHE') . '__data'));