From a2d5d8091f68263812624f8ed1092cbf5338e744 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 6 Nov 2009 07:34:56 -0800 Subject: The ajaxify_tag_form was not being called when the block was created. Moved the code to ajaxify the add form into the block html and deleted tag.js. Fixes Ticket #872 --- modules/tag/helpers/tag_theme.php | 1 - modules/tag/js/tag.js | 13 ------------- modules/tag/views/tag_block.html.php | 17 ++++++++++++++--- 3 files changed, 14 insertions(+), 17 deletions(-) delete mode 100644 modules/tag/js/tag.js (limited to 'modules') diff --git a/modules/tag/helpers/tag_theme.php b/modules/tag/helpers/tag_theme.php index 76c0ea6b..e966821a 100644 --- a/modules/tag/helpers/tag_theme.php +++ b/modules/tag/helpers/tag_theme.php @@ -21,7 +21,6 @@ class tag_theme_Core { static function head($theme) { $theme->css("jquery.autocomplete.css"); $theme->script("jquery.autocomplete.js"); - $theme->script("tag.js"); $theme->css("tag.css"); } diff --git a/modules/tag/js/tag.js b/modules/tag/js/tag.js deleted file mode 100644 index 4760084d..00000000 --- a/modules/tag/js/tag.js +++ /dev/null @@ -1,13 +0,0 @@ -function ajaxify_tag_form() { - $("#g-tag form").ajaxForm({ - dataType: "json", - success: function(data) { - if (data.result == "success") { - $.get($("#g-tag-cloud").attr("title"), function(data, textStatus) { - $("#g-tag-cloud").html(data); - }); - } - $("#g-tag form").resetForm(); - } - }); -} diff --git a/modules/tag/views/tag_block.html.php b/modules/tag/views/tag_block.html.php index ad36b297..00b57360 100644 --- a/modules/tag/views/tag_block.html.php +++ b/modules/tag/views/tag_block.html.php @@ -1,7 +1,7 @@ - -
"> +
">
\ No newline at end of file -- cgit v1.2.3 From b01056da917e7da2921a5cd4c65b129489cbc19f Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 6 Nov 2009 13:03:48 -0800 Subject: Modify the Menu_Element class to allow for the specification of a custom view. Also allow the root element to specify a css id. --- modules/gallery/libraries/Menu.php | 17 +++++++++++++---- modules/gallery/views/menu.html.php | 3 +-- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'modules') diff --git a/modules/gallery/libraries/Menu.php b/modules/gallery/libraries/Menu.php index 20405317..e2b68d1a 100644 --- a/modules/gallery/libraries/Menu.php +++ b/modules/gallery/libraries/Menu.php @@ -79,6 +79,15 @@ class Menu_Element { return $this; } + /** + * Specifiy a view for this menu item + * @chainable + */ + public function view($view) { + $this->view = $view; + return $this; + } + } /** @@ -86,7 +95,7 @@ class Menu_Element { */ class Menu_Element_Link extends Menu_Element { public function render() { - $view = new View("menu_link.html"); + $view = new View(isset($this->view) ? $this->view : "menu_link.html"); $view->menu = $this; return $view; } @@ -108,7 +117,7 @@ class Menu_Element_Ajax_Link extends Menu_Element { } public function render() { - $view = new View("menu_ajax_link.html"); + $view = new View(isset($this->view) ? $this->view : "menu_ajax_link.html"); $view->menu = $this; return $view; } @@ -119,7 +128,7 @@ class Menu_Element_Ajax_Link extends Menu_Element { */ class Menu_Element_Dialog extends Menu_Element { public function render() { - $view = new View("menu_dialog.html"); + $view = new View(isset($this->view) ? $this->view : "menu_dialog.html"); $view->menu = $this; return $view; } @@ -208,7 +217,7 @@ class Menu_Core extends Menu_Element { } public function render() { - $view = new View("menu.html"); + $view = new View(isset($this->view) ? $this->view : "menu.html"); $view->menu = $this; return $view; } diff --git a/modules/gallery/views/menu.html.php b/modules/gallery/views/menu.html.php index b4b38c93..cb49bcdf 100644 --- a/modules/gallery/views/menu.html.php +++ b/modules/gallery/views/menu.html.php @@ -1,8 +1,7 @@ elements): // Don't show the menu if it has no choices ?> is_root): ?> - -
    +
      css_id) ? "id='$menu->css_id'" : "" ?> class="css_class ?>"> elements as $element): ?> render() ?> -- cgit v1.2.3 From b5f2dbc2c4fa974f486bc92c75054940424ed323 Mon Sep 17 00:00:00 2001 From: Tim Almdal Date: Fri, 6 Nov 2009 14:08:46 -0800 Subject: Create a user_menu for the top of the page. Change the login, edit profile and logout portions of the banner to be rendered by the Theme_View::user_menu callback. This fires the user_menu event. Fixes Ticket #871. --- modules/gallery/helpers/gallery_event.php | 28 +++++++++++++++++++++++ modules/gallery/helpers/gallery_theme.php | 8 ------- modules/gallery/libraries/Theme_View.php | 8 +++++++ modules/gallery/views/login.html.php | 26 --------------------- modules/gallery/views/login_current_user.html.php | 11 +++++++++ themes/night_wind/views/page.html.php | 11 +++++---- themes/wind/views/page.html.php | 1 + 7 files changed, 55 insertions(+), 38 deletions(-) delete mode 100644 modules/gallery/views/login.html.php create mode 100644 modules/gallery/views/login_current_user.html.php (limited to 'modules') diff --git a/modules/gallery/helpers/gallery_event.php b/modules/gallery/helpers/gallery_event.php index e3cb6a9b..43920815 100644 --- a/modules/gallery/helpers/gallery_event.php +++ b/modules/gallery/helpers/gallery_event.php @@ -97,6 +97,34 @@ class gallery_event_Core { $data[] = $item->title; } + static function user_menu($menu, $theme) { + if ($theme->page_type != "login") { + Kohana::log("alert", "in gallery::user_menu"); + $user = identity::active_user(); + if ($user->guest) { + $menu->append(Menu::factory("dialog") + ->id("user_menu_login") + ->css_id("g-login-link") + ->url(url::site("login/ajax")) + ->label(t("Login"))); + } else { + $csrf = access::csrf_token(); + $menu->append(Menu::factory("dialog") + ->id("user_menu_edit_profile") + ->css_id("g-user-profile-link") + ->view("login_current_user.html") + ->url(url::site("form/edit/users/{$user->id}")) + ->label($user->display_name())); + $menu->append(Menu::factory("link") + ->id("user_menu_logout") + ->css_id("g-logout-link") + ->url(url::site("logout?csrf=$csrf&continue=" . + urlencode(url::current(true)))) + ->label(t("Logout"))); + } + } + } + static function site_menu($menu, $theme) { if ($theme->page_type != "login") { $menu->append(Menu::factory("link") diff --git a/modules/gallery/helpers/gallery_theme.php b/modules/gallery/helpers/gallery_theme.php index 0682d4ae..ab3e7eb5 100644 --- a/modules/gallery/helpers/gallery_theme.php +++ b/modules/gallery/helpers/gallery_theme.php @@ -52,14 +52,6 @@ class gallery_theme_Core { return $buf; } - static function header_top($theme) { - if ($theme->page_type != "login") { - $view = new View("login.html"); - $view->user = identity::active_user(); - return $view->render(); - } - } - static function admin_head($theme) { $theme->css("gallery.css"); $theme->script("gallery.panel.js"); diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php index 9670313d..f8fae0f7 100644 --- a/modules/gallery/libraries/Theme_View.php +++ b/modules/gallery/libraries/Theme_View.php @@ -78,6 +78,14 @@ class Theme_View_Core extends Gallery_View { return $this->page_type; } + public function user_menu() { + $menu = Menu::factory("root") + ->css_id("g-login-menu") + ->css_class("g-inline ui-helper-clear-fix"); + module::event("user_menu", $menu, $this); + return $menu->render(); + } + public function site_menu() { $menu = Menu::factory("root"); module::event("site_menu", $menu, $this); diff --git a/modules/gallery/views/login.html.php b/modules/gallery/views/login.html.php deleted file mode 100644 index 4c13ef4b..00000000 --- a/modules/gallery/views/login.html.php +++ /dev/null @@ -1,26 +0,0 @@ - - diff --git a/modules/gallery/views/login_current_user.html.php b/modules/gallery/views/login_current_user.html.php new file mode 100644 index 00000000..e3b3688f --- /dev/null +++ b/modules/gallery/views/login_current_user.html.php @@ -0,0 +1,11 @@ + +
    • + label->for_html() ?> + + html::mark_clean( + "{$name}"))) ?> + + $name)) ?> + +
    • diff --git a/themes/night_wind/views/page.html.php b/themes/night_wind/views/page.html.php index a14a3278..f41dcd27 100644 --- a/themes/night_wind/views/page.html.php +++ b/themes/night_wind/views/page.html.php @@ -77,14 +77,15 @@ site_status() ?>
      - header_top() ?> - + user_menu() ?> + header_top() ?>
      site_menu() ?>
      @@ -93,8 +94,9 @@
        + -
      • + >