From 4949a2ce0b5daca7afe86a261be447440fce7eff Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Sun, 18 Oct 2009 09:23:59 -0700 Subject: Optimize the get method to retrieve the module information from the loaded modules. In addition add a method "info" to return the module information contained in the module.info file --- modules/gallery/helpers/module.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/gallery/helpers/module.php b/modules/gallery/helpers/module.php index fe37f4f9..77ec6f63 100644 --- a/modules/gallery/helpers/module.php +++ b/modules/gallery/helpers/module.php @@ -50,8 +50,20 @@ class module_Core { * @param string $module_name */ static function get($module_name) { - // @todo can't easily use model_cache here because it throw an exception on missing models. - return ORM::factory("module", array("name" => $module_name)); + if (empty(self::$modules[$module_name])) { + return ORM::factory("module", array("name" => $module_name)); + } + return self::$modules[$module_name]; + } + + /** + * Get the information about a module + * @returns ArrayObject containing the module information from the module.info file or false if + * not found + */ + static function info($module_name) { + $module_list = self::available(); + return isset($module_list->$module_name) ? $module_list->$module_name : false; } /** @@ -79,7 +91,8 @@ class module_Core { $modules = new ArrayObject(array(), ArrayObject::ARRAY_AS_PROPS); 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); + $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); -- cgit v1.2.3 From b976f9b3665771444c30e914fe21cbce5848bd21 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sun, 18 Oct 2009 10:30:36 -0700 Subject: Move away from embedding the tag id in to the CSS id. This is brittle and causes us to do silly things to extract the id. Use rel instead so: becomes: --- modules/tag/js/tag.js | 4 ++-- modules/tag/views/admin_tags.html.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/tag/js/tag.js b/modules/tag/js/tag.js index 17845272..532ada95 100644 --- a/modules/tag/js/tag.js +++ b/modules/tag/js/tag.js @@ -37,7 +37,7 @@ function editInPlace(element) { closeEditInPlaceForms(); // create edit form - var tag_id = $(this).attr('id').substr(5); + var tag_id = $(this).attr('rel'); var tag_name = $(this).html(); var tag_width = $(this).width(); $(this).parent().data("revert", $(this).parent().html()); @@ -64,7 +64,7 @@ function editInPlace(element) { success: function(data) { if (data.result == "success") { closeEditInPlaceForms(); // close form - $("#g-tag-" + data.tag_id).text(data.new_tagname); // update tagname + $(".g-tag[rel=" + data.tag_id + "]").text(data.new_tagname); // update tagname console.log(data); window.location.reload(); } else if (data.result == "error") { diff --git a/modules/tag/views/admin_tags.html.php b/modules/tag/views/admin_tags.html.php index edc466bb..2d41ee5f 100644 --- a/modules/tag/views/admin_tags.html.php +++ b/modules/tag/views/admin_tags.html.php @@ -47,7 +47,7 @@
  • - name) ?> + name) ?> (count ?>) id") ?>" class="g-dialog-link g-delete-link g-button"> -- cgit v1.2.3