Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert "Create a gallery::plugin_path which returns the appropriate p…

…ath to the module or theme. This checks for the existence of an application/modules or application/themes first."

This reverts commit e1e1461a77caf5bff457927f098366497de6ffff.
  • Loading branch information...
commit 2634a683b30982963264faf9867d32d1aa71a182 1 parent aa0529d
@talmdal talmdal authored
View
31 modules/gallery/controllers/admin_themes.php
@@ -29,20 +29,17 @@ public function index() {
private function _get_themes() {
$themes = array();
- foreach (array(APPPATH . "themes/", THEMEPATH) as $themepath) {
- foreach (scandir($themepath) as $theme_name) {
- if ($theme_name[0] == ".") {
- continue;
- }
- $file = $themepath . "$theme_name/theme.info";
- if (file_exists($file)) {
- $theme_info = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS);
- $theme_info->description = t($theme_info->description);
- $theme_info->name = t($theme_info->name);
-
- $themes[$theme_name] = $theme_info;
- }
+ foreach (scandir(THEMEPATH) as $theme_name) {
+ if ($theme_name[0] == ".") {
+ continue;
}
+
+ $file = THEMEPATH . "$theme_name/theme.info";
+ $theme_info = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS);
+ $theme_info->description = t($theme_info->description);
+ $theme_info->name = t($theme_info->name);
+
+ $themes[$theme_name] = $theme_info;
}
return $themes;
}
@@ -50,8 +47,8 @@ private function _get_themes() {
public function preview($type, $theme_name) {
$view = new View("admin_themes_preview.html");
$theme_name = preg_replace("/[^\w]/", "", $theme_name);
- $view->info = new ArrayObject(parse_ini_file(
- gallery::plugin_path("$theme_name/theme.info", "theme")), ArrayObject::ARRAY_AS_PROPS);
+ $view->info = new ArrayObject(
+ parse_ini_file(THEMEPATH . "$theme_name/theme.info"), ArrayObject::ARRAY_AS_PROPS);
$view->theme_name = $theme_name;
$view->type = $type;
if ($type == "admin") {
@@ -66,8 +63,8 @@ public function choose($type, $theme_name) {
access::verify_csrf();
$theme_name = preg_replace("/[^\w]/", "", $theme_name);
- $info = new ArrayObject(parse_ini_file(
- gallery::plugin_path("$theme_name/theme.info", "theme")), ArrayObject::ARRAY_AS_PROPS);
+ $info = new ArrayObject(
+ parse_ini_file(THEMEPATH . "$theme_name/theme.info"), ArrayObject::ARRAY_AS_PROPS);
if ($type == "admin" && $info->admin) {
module::set_var("gallery", "active_admin_theme", $theme_name);
View
13 modules/gallery/helpers/gallery.php
@@ -110,17 +110,4 @@ static function find_file($directory, $file, $required=false) {
return $file_name;
}
- /**
- * Return a full path to the theme or module file. It checks the APPPATH/(themes|modules) first
- * then the THEMEPATH | MODPATH
- * @param $file the file or directory
- * @param $type ("module" | "theme" optional: defaults to "module")
- * @return string
- */
- static function plugin_path($file, $type="module") {
- if (!file_exists($ofile = APPPATH . "{$type}s/$file")) {
- $ofile = $type == "module" ? MODPATH . $file : THEMEPATH . $file;
- }
- return $ofile;
- }
}
View
4 modules/gallery/helpers/gallery_installer.php
@@ -245,8 +245,8 @@ static function install() {
// Instantiate default themes (site and admin)
foreach (array("wind", "admin_wind") as $theme_name) {
- $file = gallery::plugin_path("$theme_name/theme.info", "theme");
- $theme_info = new ArrayObject(parse_ini_file($file, ArrayObject::ARRAY_AS_PROPS);
+ $theme_info = new ArrayObject(parse_ini_file(THEMEPATH . $theme_name . "/theme.info"),
+ ArrayObject::ARRAY_AS_PROPS);
$theme = ORM::factory("theme");
$theme->name = $theme_name;
$theme->version = $theme_info->version;
View
34 modules/gallery/helpers/module.php
@@ -77,23 +77,15 @@ static function is_active($module_name) {
static function available() {
if (empty(self::$available)) {
$modules = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS);
- foreach (array(APPPATH . "modules/", MODPATH) as $modpath) {
- foreach (scandir($modpath) as $module_name) {
- if ($module_name[0] == ".") {
- continue;
- }
- $file = "{$modpath}$module_name/module.info";
- if (file_exists($file)) {
- $modules->$module_name =
- new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS);
- $m =& $modules->$module_name;
- $m->installed = self::is_installed($module_name);
- $m->active = self::is_active($module_name);
- $m->code_version = $m->version;
- $m->version = self::get_version($module_name);
- $m->locked = false;
- }
- }
+ foreach (glob(MODPATH . "*/module.info") as $file) {
+ $module_name = basename(dirname($file));
+ $modules->$module_name = new ArrayObject(parse_ini_file($file), ArrayObject::ARRAY_AS_PROPS);
+ $m =& $modules->$module_name;
+ $m->installed = self::is_installed($module_name);
+ $m->active = self::is_active($module_name);
+ $m->code_version = $m->version;
+ $m->version = self::get_version($module_name);
+ $m->locked = false;
}
// Lock certain modules
@@ -121,7 +113,7 @@ static function active() {
*/
static function install($module_name) {
$kohana_modules = Kohana::config("core.modules");
- array_unshift($kohana_modules, gallery::plugin_path($module_name));
+ array_unshift($kohana_modules, MODPATH . $module_name);
Kohana::config_set("core.modules", $kohana_modules);
$installer_class = "{$module_name}_installer";
@@ -148,7 +140,7 @@ static function install($module_name) {
*/
static function upgrade($module_name) {
$kohana_modules = Kohana::config("core.modules");
- array_unshift($kohana_modules, gallery::plugin_path($module_name));
+ array_unshift($kohana_modules, MODPATH . $module_name);
Kohana::config_set("core.modules", $kohana_modules);
$version_before = module::get_version($module_name);
@@ -187,7 +179,7 @@ static function upgrade($module_name) {
*/
static function activate($module_name) {
$kohana_modules = Kohana::config("core.modules");
- array_unshift($kohana_modules, gallery::plugin_path($module_name));
+ array_unshift($kohana_modules, MODPATH . $module_name);
Kohana::config_set("core.modules", $kohana_modules);
$installer_class = "{$module_name}_installer";
@@ -279,7 +271,7 @@ static function load_modules() {
$gallery = $module;
} else {
self::$active[] = $module;
- $kohana_modules[] = gallery::plugin_path($module->name);
+ $kohana_modules[] = MODPATH . $module->name;
}
}
self::$active[] = $gallery; // put gallery last in the module list to match core.modules
View
7 modules/gallery/helpers/theme.php
@@ -30,8 +30,11 @@ class theme_Core {
*/
static function load_themes() {
$modules = Kohana::config("core.modules");
- array_unshift($modules, gallery::plugin_path(module::get_var("gallery",
- (Router::$controller == "admin") ? "active_admin_theme" : "active_site_theme"), "theme"));
+ if (Router::$controller == "admin") {
+ array_unshift($modules, THEMEPATH . module::get_var("gallery", "active_admin_theme"));
+ } else {
+ array_unshift($modules, THEMEPATH . module::get_var("gallery", "active_site_theme"));
+ }
Kohana::config_set("core.modules", $modules);
}
Please sign in to comment.
Something went wrong with that request. Please try again.