Preliminary work to cut over to Kohana 2.4

- Kohana::log() -> Kohana_Log::add()
- Kohana::config_XXX -> Kohana_Config::instance()->XXX
- Implement View::set_global in MY_View
- Updated Cache_Database_Driver to latest APIs
- ORM::$loaded -> ORM::loaded()
- Updated item::viewable() to use K2.4 parenthesization
This commit is contained in:
Bharat Mediratta
2009-11-25 13:22:24 -08:00
parent e201536d82
commit 2e420522ec
63 changed files with 257 additions and 225 deletions

View File

@@ -36,13 +36,13 @@ class module_Core {
*/
static function set_version($module_name, $version) {
$module = self::get($module_name);
if (!$module->loaded) {
if (!$module->loaded()) {
$module->name = $module_name;
$module->active = $module_name == "gallery"; // only gallery is active by default
}
$module->version = $version;
$module->save();
Kohana::log("debug", "$module_name: version is now $version");
Kohana_Log::add("debug", "$module_name: version is now $version");
}
/**
@@ -126,9 +126,10 @@ class module_Core {
* @param string $module_name
*/
static function install($module_name) {
$kohana_modules = Kohana::config("core.modules");
$config = Kohana_Config::instance();
$kohana_modules = $config->get("core.modules");
array_unshift($kohana_modules, MODPATH . $module_name);
Kohana::config_set("core.modules", $kohana_modules);
$config->set("core.modules", $kohana_modules);
// Rebuild the include path so the module installer can benefit from auto loading
Kohana::include_paths(true);
@@ -142,7 +143,7 @@ class module_Core {
// Now the module is installed but inactive, so don't leave it in the active path
array_shift($kohana_modules);
Kohana::config_set("core.modules", $kohana_modules);
$config->set("core.modules", $kohana_modules);
log::success(
"module", t("Installed module %module_name", array("module_name" => $module_name)));
@@ -193,9 +194,10 @@ class module_Core {
* @param string $module_name
*/
static function activate($module_name) {
$kohana_modules = Kohana::config("core.modules");
$config = Kohana_Config::instance();
$kohana_modules = $config->get("core.modules");
array_unshift($kohana_modules, MODPATH . $module_name);
Kohana::config_set("core.modules", $kohana_modules);
$config->set("core.modules", $kohana_modules);
$installer_class = "{$module_name}_installer";
if (method_exists($installer_class, "activate")) {
@@ -203,7 +205,7 @@ class module_Core {
}
$module = self::get($module_name);
if ($module->loaded) {
if ($module->loaded()) {
$module->active = true;
$module->save();
}
@@ -230,7 +232,7 @@ class module_Core {
}
$module = self::get($module_name);
if ($module->loaded) {
if ($module->loaded()) {
$module->active = false;
$module->save();
}
@@ -257,7 +259,7 @@ class module_Core {
graphics::remove_rules($module_name);
$module = self::get($module_name);
if ($module->loaded) {
if ($module->loaded()) {
$module->delete();
}
module::load_modules();
@@ -290,8 +292,9 @@ class module_Core {
}
}
self::$active[] = $gallery; // put gallery last in the module list to match core.modules
Kohana::config_set(
"core.modules", array_merge($kohana_modules, Kohana::config("core.modules")));
$config = Kohana_Config::instance();
$config->set(
"core.modules", array_merge($kohana_modules, $config->get("core.modules")));
}
/**
@@ -348,11 +351,11 @@ class module_Core {
// We cache all vars in gallery._cache so that we can load all vars at once for
// performance.
if (empty(self::$var_cache)) {
$row = Database::instance()
$row = db::build()
->select("value")
->from("vars")
->where(array("module_name" => "gallery", "name" => "_cache"))
->get()
->execute()
->current();
if ($row) {
self::$var_cache = unserialize($row->value);
@@ -395,7 +398,7 @@ class module_Core {
->where("module_name", $module_name)
->where("name", $name)
->find();
if (!$var->loaded) {
if (!$var->loaded()) {
$var->module_name = $module_name;
$var->name = $name;
}
@@ -432,7 +435,7 @@ class module_Core {
->where("module_name", $module_name)
->where("name", $name)
->find();
if ($var->loaded) {
if ($var->loaded()) {
$var->delete();
}