diff options
-rw-r--r-- | modules/gallery/helpers/gallery_event.php | 28 | ||||
-rw-r--r-- | modules/gallery/helpers/gallery_theme.php | 8 | ||||
-rw-r--r-- | modules/gallery/libraries/Theme_View.php | 8 | ||||
-rw-r--r-- | modules/gallery/views/login.html.php | 26 | ||||
-rw-r--r-- | modules/gallery/views/login_current_user.html.php | 11 | ||||
-rw-r--r-- | themes/night_wind/views/page.html.php | 11 | ||||
-rw-r--r-- | themes/wind/views/page.html.php | 1 |
7 files changed, 55 insertions, 38 deletions
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 @@ -<?php defined("SYSPATH") or die("No direct script access.") ?> -<ul id="g-login-menu" class="g-inline ui-helper-clearfix"> - <? if ($user->guest): ?> - <li class="g-first"> - <a href="<?= url::site("login/ajax") ?>" - title="<?= t("Login to Gallery")->for_html_attr() ?>" - id="g-login-link" class="g-dialog-link"><?= t("Login") ?></a> - </li> - <? else: ?> - <li class="g-first"> - <? if (identity::is_writable()): ?> - <?= t('Logged in as %name', array('name' => html::mark_clean( - '<a href="' . url::site("form/edit/users/{$user->id}") . - '" title="' . t("Edit your profile")->for_html_attr() . - '" id="g-user-profile-link" class="g-dialog-link">' . - html::clean($user->display_name()) . '</a>'))) ?> - <? else: ?> - <?= t('Logged in as %name', array('name' => html::clean($user->display_name()))) ?> - <? endif ?> - </li> - <li> - <a href="<?= url::site("logout?csrf=$csrf&continue=" . urlencode(url::current(true))) ?>" - id="g-logout-link"><?= t("Logout") ?></a> - </li> - <? endif ?> -</ul> 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 @@ +<?php defined("SYSPATH") or die("No direct script access.") ?> +<li> + <? $name = $menu->label->for_html() ?> + <? if (identity::is_writable()): ?> + <?= t("Logged in as %name", array("name" => html::mark_clean( + "<a href='$menu->url' title='" . t("Edit your profile")->for_html_attr() . + "' id='$menu->id' class='g-dialog-link'>{$name}</a>"))) ?> + <? else: ?> + <?= t("Logged in as %name", array("name" => $name)) ?> + <? endif ?> +</li> 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 @@ <?= $theme->site_status() ?> <div id="g-header" class="ui-helper-clearfix"> <div id="g-banner"> - <?= $theme->header_top() ?> <? if ($header_text = module::get_var("gallery", "header_text")): ?> <?= $header_text ?> <? else: ?> - <a id="g-logo" href="<?= item::root()->url() ?>" title="<?= t("go back to the Gallery home")->for_html_attr() ?>"> + <a id="g-logo" class="g-left" href="<?= item::root()->url() ?>" title="<?= t("go back to the Gallery home")->for_html_attr() ?>"> <img width="107" height="48" alt="<?= t("Gallery logo: Your photos on your web site")->for_html_attr() ?>" src="<?= url::file("lib/images/logo.png") ?>" /> </a> <? endif ?> + <?= $theme->user_menu() ?> + <?= $theme->header_top() ?> <div id="g-site-menu"> <?= $theme->site_menu() ?> </div> @@ -93,8 +94,9 @@ <? if (!empty($parents)): ?> <ul class="g-breadcrumbs"> + <? $i = 0 ?> <? foreach ($parents as $parent): ?> - <li> + <li<? if ($i == 0) print " class=\"g-first\"" ?>> <!-- Adding ?show=<id> causes Gallery3 to display the page containing that photo. For now, we just do it for the immediate parent so that when you go back up a @@ -104,8 +106,9 @@ <?= html::purify($parent->title) ?> </a> </li> + <? $i++ ?> <? endforeach ?> - <li class="active"><?= html::purify($theme->item()->title) ?></li> + <li class="g-active"><?= html::purify($theme->item()->title) ?></li> </ul> <? endif ?> </div> diff --git a/themes/wind/views/page.html.php b/themes/wind/views/page.html.php index a2b2fdd7..f41dcd27 100644 --- a/themes/wind/views/page.html.php +++ b/themes/wind/views/page.html.php @@ -84,6 +84,7 @@ <img width="107" height="48" alt="<?= t("Gallery logo: Your photos on your web site")->for_html_attr() ?>" src="<?= url::file("lib/images/logo.png") ?>" /> </a> <? endif ?> + <?= $theme->user_menu() ?> <?= $theme->header_top() ?> <div id="g-site-menu"> <?= $theme->site_menu() ?> |