From 80821e0b4a4248a7890843ffe9c6d545ba8b81b6 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 4 Aug 2009 02:45:48 -0600 Subject: [PATCH] Use API for Prefs UI menu generation. Additionally, at least for DIMP, make Growler notification work again. However, this will only work for IMP options - once a user moves to another app's options, the regular notifications will be used. Pretty much means we will have to build a prefs-only Growler notification handler that doesn't rely on any specific AJAX app to be loaded. --- ansel/browse_edit.php | 2 +- ansel/lib/Ansel.php | 8 +-- ansel/lib/Api.php | 15 ++++ ansel/templates/menu.inc | 2 +- babel/edit.php | 2 +- babel/lib/Babel.php | 76 ++++++++++---------- babel/lib/base.php | 2 +- babel/view.php | 118 +++++++++++++++---------------- chora/lib/Api.php | 27 +++++++ chora/lib/Chora.php | 2 +- chora/templates/menu.inc | 2 +- crumb/lib/Api.php | 18 +++++ crumb/lib/Crumb.php | 8 +-- crumb/templates/menu.inc | 2 +- fima/lib/Api.php | 15 ++++ fima/lib/Fima.php | 8 +-- fima/templates/menu.inc | 2 +- folks/lib/Api.php | 15 ++++ folks/lib/Folks.php | 8 +-- folks/templates/menu.inc | 2 +- gollem/lib/Api.php | 15 ++++ gollem/lib/Gollem.php | 12 ++-- imp/lib/Api.php | 40 ++++++++++- imp/lib/DIMP.php | 6 +- imp/lib/IMP.php | 10 ++- imp/lib/Notification/Listener/Status.php | 5 +- ingo/lib/Api.php | 15 ++++ ingo/lib/Ingo.php | 4 +- ingo/templates/menu.inc | 2 +- jeta/lib/Api.php | 18 +++++ jeta/lib/Jeta.php | 4 +- jeta/main.php | 2 +- kastalia/lib/Api.php | 18 +++++ kastalia/lib/Kastalia.php | 13 +--- kastalia/templates/menu.inc | 2 +- kronolith/lib/Api.php | 15 ++++ kronolith/lib/Kronolith.php | 4 +- kronolith/templates/menu.inc | 2 +- nag/lib/Api.php | 15 ++++ nag/lib/Nag.php | 4 +- nag/templates/menu.inc | 2 +- news/lib/Api.php | 19 ++++- news/lib/News.php | 8 +-- news/templates/menu.inc | 2 +- skeleton/lib/Api.php | 18 +++++ skeleton/lib/Skeleton.php | 4 +- skeleton/templates/menu.inc | 2 +- skoli/lib/Api.php | 18 +++++ skoli/lib/Skoli.php | 8 +-- skoli/templates/menu.inc | 2 +- turba/lib/Api.php | 15 ++++ turba/lib/Turba.php | 10 +-- turba/templates/menu.inc | 2 +- 53 files changed, 446 insertions(+), 204 deletions(-) diff --git a/ansel/browse_edit.php b/ansel/browse_edit.php index 76a2a410b..52a7e9538 100644 --- a/ansel/browse_edit.php +++ b/ansel/browse_edit.php @@ -23,7 +23,7 @@ if ($layout->updated()) { $title = _("My Photos :: Add Content"); require ANSEL_TEMPLATES . '/common-header.inc'; -echo ''; +echo ''; $notification->notify(array('listeners' => 'status')); require $registry->get('templates', 'horde') . '/portal/edit.inc'; require $registry->get('templates', 'horde') . '/common-footer.inc'; diff --git a/ansel/lib/Ansel.php b/ansel/lib/Ansel.php index 90513a0a4..0a027d5ff 100644 --- a/ansel/lib/Ansel.php +++ b/ansel/lib/Ansel.php @@ -598,7 +598,7 @@ class Ansel { /** * Build Ansel's list of menu items. */ - function getMenu($returnType = 'object') + function getMenu() { global $conf, $registry; @@ -655,11 +655,7 @@ class Ansel { Horde::popupJs($pl, array('urlencode' => true)) . 'return false;'); } - if ($returnType == 'object') { - return $menu; - } else { - return $menu->render(); - } + return $menu; } /** diff --git a/ansel/lib/Api.php b/ansel/lib/Api.php index 5c33f44ed..86c14bb83 100644 --- a/ansel/lib/Api.php +++ b/ansel/lib/Api.php @@ -30,6 +30,11 @@ class Ansel_Api extends Horde_Registry_Api 'type' => 'boolean' ), + 'prefsMenu' => array( + 'args' => array(), + 'type' => 'object' + ), + 'browse' => array( 'args' => array('path' => 'string'), 'type' => '{urn:horde}hashHash', @@ -255,6 +260,16 @@ class Ansel_Api extends Horde_Registry_Api } /** + * Generate the menu to use on the prefs page. + * + * @return Horde_Menu A Horde_Menu object. + */ + public function prefsMenu() + { + return Ansel::getMenu(); + } + + /** * Browse through Ansel's gallery tree. * * @param string $path The level of the tree to browse. diff --git a/ansel/templates/menu.inc b/ansel/templates/menu.inc index e04ca0eb1..5e211513d 100644 --- a/ansel/templates/menu.inc +++ b/ansel/templates/menu.inc @@ -1,5 +1,5 @@ set('menu', Babel::getMenu('string')); +$template->set('menu', Babel::getMenu()->render()); $template->set('notify', Horde_Util::bufferOutput(array($notification, 'notify'), array('listeners' => 'status'))); /* Create upload form */ diff --git a/babel/lib/Babel.php b/babel/lib/Babel.php index b0183480e..6eb4b0a4a 100644 --- a/babel/lib/Babel.php +++ b/babel/lib/Babel.php @@ -186,53 +186,49 @@ class Babel { /** * Get the module main Menu. **/ - function getMenu($returnType = 'object') + function getMenu() { global $registry; - $menu = new Horde_Menu(); + $menu = new Horde_Menu(); $menu->addArray(array('url' => Horde::applicationUrl('index.php'), - 'text' => _("_General"), - 'icon' => 'list.png')); - - if (Babel::hasPermission('view')) { - $menu->addArray(array('url' => Horde::applicationUrl('view.php'), - 'text' => _("_View"), - 'icon' => 'view.png')); - } - - if (Babel::hasPermission('stats')) { - $menu->addArray(array('url' => Horde::applicationUrl('stats.php'), - 'text' => _("_Stats"), - 'icon' => 'extract.png')); - } - - if (Babel::hasPermission('extract')) { - $menu->addArray(array('url' => Horde::applicationUrl('extract.php'), - 'text' => _("_Extract"), - 'icon' => 'extract.png')); - } - - if (Babel::hasPermission('make')) { - $menu->addArray(array('url' => Horde::applicationUrl('make.php'), - 'text' => _("_Make"), - 'icon' => 'make.png')); - } - - if (Babel::hasPermission('upload')) { - $menu->addArray(array('url' => Horde::applicationUrl('upload.php'), - 'text' => _("_Upload"), - 'icon' => 'upload.png')); - } - if ($returnType == 'object') { - return $menu; - } else { - return $menu->render(); - } + 'text' => _("_General"), + 'icon' => 'list.png')); + + if (Babel::hasPermission('view')) { + $menu->addArray(array('url' => Horde::applicationUrl('view.php'), + 'text' => _("_View"), + 'icon' => 'view.png')); + } + + if (Babel::hasPermission('stats')) { + $menu->addArray(array('url' => Horde::applicationUrl('stats.php'), + 'text' => _("_Stats"), + 'icon' => 'extract.png')); + } + + if (Babel::hasPermission('extract')) { + $menu->addArray(array('url' => Horde::applicationUrl('extract.php'), + 'text' => _("_Extract"), + 'icon' => 'extract.png')); + } + + if (Babel::hasPermission('make')) { + $menu->addArray(array('url' => Horde::applicationUrl('make.php'), + 'text' => _("_Make"), + 'icon' => 'make.png')); + } + + if (Babel::hasPermission('upload')) { + $menu->addArray(array('url' => Horde::applicationUrl('upload.php'), + 'text' => _("_Upload"), + 'icon' => 'upload.png')); + } + + return $menu; } - /** * Send an Email. **/ diff --git a/babel/lib/base.php b/babel/lib/base.php index b47384f7c..8eccc3012 100644 --- a/babel/lib/base.php +++ b/babel/lib/base.php @@ -87,7 +87,7 @@ if (($lang = Horde_Util::getFormData('display_language')) !== null) { } /* Set up the template fields. */ -$template->set('menu', Babel::getMenu('string')); +$template->set('menu', Babel::getMenu()->render()); $template->set('notify', Horde_Util::bufferOutput(array($notification, 'notify'), array('listeners' => 'status'))); $template->set('lang', Babel::displayLanguage()); $fmenu = Babel::LanguageSelection(); diff --git a/babel/view.php b/babel/view.php index ae87ca007..5302aeb99 100644 --- a/babel/view.php +++ b/babel/view.php @@ -55,7 +55,7 @@ $show = 'edit'; $vars = &Horde_Variables::getDefaultVariables(); if ($app) { - + $napp = ($app == 'horde') ? '' : $app; $pofile = HORDE_BASE . '/' . $napp . '/po/' . $lang . '.po'; $po = new File_Gettext_PO(); @@ -63,10 +63,10 @@ if ($app) { // Set Scope $lockscope = sprintf("babel-%s-%s", $app, $lang); - + // Initialize Horde_Lock class $locks = &Horde_Lock::singleton('sql'); - + // $curlocks = $locks->getLocks($lockscope); // var_dump($curlocks); } @@ -87,62 +87,62 @@ if (($f_save || $f_cancel) && $cstring) { } if ($f_save && $cstring) { - + $decstr = $po->encstr[$cstring]; $msgstr = Horde_Util::getFormData('msgstr'); $comments = trim($po->comments[$decstr]); $phpformat = Horde_Util::getFormData('phpformat'); $fuzzy = Horde_Util::getFormData('fuzzy'); - + $status = $po->status[$decstr]; foreach($status as $k => $v) { if ($v == 'untranslated' && !empty($msgstr)) { unset($status[$k]); } - + if ($v == 'php-format' && !$phpformat) { unset($status[$k]); } - + if ($v == 'fuzzy' && !$fuzzy) { unset($status[$k]); } } - + if (!in_array('php-format', $status) && $phpformat) { $status[] = 'php-format'; } - + if (!in_array('fuzzy', $status) && $fuzzy) { $status[] = 'fuzzy'; } - + $status = array_unique($status); $po->status[$decstr] = $status; - + $status = ''; if (preg_match('/(#,.*)$/', $comments, $m)) { $status = $m[1]; } - + if (count($po->status[$decstr])) { $newstatus = "#, " . implode(', ', $po->status[$decstr]); } else { $newstatus = ""; } - + $newcomments = str_replace($status, $newstatus, $comments); - + $po->comments[$decstr] = $newcomments; $po->strings[$decstr] = Translate_Display::convert_string($msgstr); $po->save($pofile); } -// +// /* Set up the template fields. */ -$template->set('menu', Babel::getMenu('string')); +$template->set('menu', Babel::getMenu()->render()); $template->set('notify', Horde_Util::bufferOutput(array($notification, 'notify'), array('listeners' => 'status'))); /* Create upload form */ @@ -152,26 +152,26 @@ if (!$app) { $form->setButtons(_("View")); $form->addVariable(_("Module"), 'module', 'enum', true, false, null, array(Babel::listApps(), true)); $form->addVariable('', '', 'spacer', true); - + $renderer_params = array(); $renderer = new Horde_Form_Renderer($renderer_params); $renderer->setAttrColumnWidth('20%'); - + $form->renderActive($renderer, $vars, Horde::selfURL(), 'post'); } else { - + if (Babel::hasPermission('view', 'tabs', PERMS_EDIT)) { $hmenu_desc = _("Edit Header"); $url = Horde::applicationUrl('edit.php'); $url = Horde_Util::addParameter($url, array('module' => $app, 'url' => 'view')); - + $hmenu = Horde::link($url, $hmenu_desc, 'menuitem', null); $hmenu .= Horde::img('edit.png', null, $hmenu_desc) . ' ' . $hmenu_desc . ' '; } else { $hmenu = ''; } - + Translate_Display::header(_("Meta Informations"), $hmenu); echo ''; $i = 0; @@ -184,11 +184,11 @@ if (!$app) { } echo '
'; Translate_Display::info(); - + Translate_Display::header(_("Statistic")); - + $report = Translate::stats($app, $lang); - + echo ''; echo ''; echo ''; @@ -209,7 +209,7 @@ if (!$app) { echo "\n\t"; echo "\n\t"; echo "\t"; - + echo '
' . _("Language") . '" . @$report[$lang][4] . "" . @$report[$lang][5] . "
'; Translate_Display::info(); @@ -219,7 +219,7 @@ if (!$app) { $filter_html .= Horde::img('edit.png') . ' '; $filter_html .= '' . _("Filter: ") . ''; $filter_html .= '[ '; - if (!$filter) { + if (!$filter) { $hmenu_desc = '' . _("All") . ''; } else { $hmenu_desc = _("All"); @@ -239,7 +239,7 @@ if (!$app) { $filter_html .= Horde::link($url, $hmenu_desc, 'menuitem', null). ' ' . $hmenu_desc . ' '; $filter_html .= '| '; - + if ($filter == 'fuzzy') { $hmenu_desc = '' . _("Fuzzy") . ''; } else { @@ -269,7 +269,7 @@ if (!$app) { $filter_html .= ''; $perpage = 100; - + foreach($po->strings as $msgid => $msgstr) { if ($filter && !in_array($filter, $po->status[$msgid])) { unset($po->strings[$msgid]); @@ -282,7 +282,7 @@ if (!$app) { unset($po->ref[$msgid]); } } - + $numitem = count($po->strings); // Set list min/max values $min = $page * $perpage; @@ -291,43 +291,43 @@ if (!$app) { $min = $page * $perpage; } $max = $min + $perpage; - + // Start start/end items (according to current page) $start = ($page * $perpage) + 1; $end = min($numitem, $start + $perpage - 1); - + $cntstr = 0; - + $pageinf = ' [' . sprintf(_("%s to %s of %s"), $start, $end, $numitem) . ']'; Translate_Display::header(_("Translations") . $pageinf, $filter_html); - + foreach($po->strings as $msgid => $msgstr) { $cntstr++; - + if ($start && $cntstr < $start) { continue; } - + if ($end && $cntstr > $end) { break; } - + if ($filter && !in_array($filter, $po->status[$msgid])) { continue; } - + $encstr = base64_encode($msgid); $bgcolor = '1px #000000'; if (in_array('fuzzy', $po->status[$msgid])) { $bgcolor = '3px #FFFF00'; } - + if (in_array('untranslated', $po->status[$msgid])) { $bgcolor = '3px #FF0000'; } - + $locked = false; if ($curlock = $locks->getLocks(md5($encstr), $lockscope)) { foreach($curlock as $lid => $linfo) { @@ -337,12 +337,12 @@ if (!$app) { } } } - + if ($editmode && $cstring == $encstr) { - + // Lock the current item for 5 minutes $locks->setLock(Horde_Auth::getAuth(), md5($encstr), $lockscope, 300); - + echo '
'; echo ''; echo ''; @@ -350,8 +350,8 @@ if (!$app) { echo ''; echo ''; } - - + + ?> @@ -365,7 +365,7 @@ if (!$app) {
- + ref[$msgid] as $k => $v) { @@ -378,26 +378,26 @@ if (!$app) { $surl = Horde_Util::addParameter($surl, array('module' => $app, 'file' => $sfile, 'line' => $sline)); - + $onclick = "viewwindow=window.open('". $surl . "', 'viewsource', 'toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=650,height=350,left=100,top=100'); if(window.focus) { viewwindow.focus()} ; return false;"; - + $surl = Horde::link('#', $sline, null, null, $onclick); $surl .= $sline . ''; $surl = str_replace('&', '&', $surl); } else { $surl = $sline; } - + $ref[$sfile][] = $surl; } } - + $i = 0; foreach($ref as $k => $v) { echo sprintf("", ($i++ %2), $k, implode(' | ', $v)); } ?> -
%s[ %s ]
+
', $po->status[$msgid]); } - ?> - - - + ?> + + + @@ -434,7 +434,7 @@ if (!$app) { $surl = Horde::applicationUrl('view.php'); $surl = Horde_Util::addParameter($surl, array('module' => $app, 'cstring' => $encstr, 'editmode' => 1, 'page' => $page, 'filter' => $filter, 'search' => $search)); $surl .= "#" . md5($encstr); - + echo Horde::link($surl, _("Edit Translation")) . Horde::img('babel.png') . ' ' ._("Edit Translation") . ""; } elseif ($editmode && $cstring == $encstr) { echo ''; @@ -445,7 +445,7 @@ if (!$app) { } ?> -
+ -

+

'; } @@ -485,7 +485,7 @@ if (!$app) { $editmode, - 'module' => $app, + 'module' => $app, 'filter' => $filter, 'search' => $search)); $pager = new Horde_UI_Pager('page', $vars, array('num' => $numitem, 'url' => $viewurl, 'page_count' => 10, 'perpage' => $perpage)); diff --git a/chora/lib/Api.php b/chora/lib/Api.php index bd458bc91..0cf7af28e 100644 --- a/chora/lib/Api.php +++ b/chora/lib/Api.php @@ -16,6 +16,23 @@ class Chora_Api extends Horde_Registry_Api */ public $version = 'H4 (3.0-git)'; + /** + * The services provided by this application. + * + * @var array + */ + public $services = array( + 'perms' => array( + 'args' => array(), + 'type' => '{urn:horde}hashHash' + ), + + 'prefsMenu' => array( + 'args' => array(), + 'type' => 'object' + ) + ); + public function perms() { static $perms = array(); @@ -38,4 +55,14 @@ class Chora_Api extends Horde_Registry_Api return $perms; } + /** + * Generate the menu to use on the prefs page. + * + * @return Horde_Menu A Horde_Menu object. + */ + public function prefsMenu() + { + return Chora::getMenu(); + } + } diff --git a/chora/lib/Chora.php b/chora/lib/Chora.php index 8bc192299..39f1ea9ea 100644 --- a/chora/lib/Chora.php +++ b/chora/lib/Chora.php @@ -421,7 +421,7 @@ class Chora { $menu = new Horde_Menu(); $menu->add(self::url('browsedir'), _("_Browse"), 'chora.png'); - return $menu->render(); + return $menu; } /** diff --git a/chora/templates/menu.inc b/chora/templates/menu.inc index 11c17bc02..4b6e3a3d0 100644 --- a/chora/templates/menu.inc +++ b/chora/templates/menu.inc @@ -2,6 +2,6 @@

- + render() ?> notify(array('listeners' => 'status')) ?> diff --git a/crumb/lib/Api.php b/crumb/lib/Api.php index 54fa30010..7d72e6824 100644 --- a/crumb/lib/Api.php +++ b/crumb/lib/Api.php @@ -2,4 +2,22 @@ class Crumb_Api extends Horde_Registry_Api { public $version = 'H4 (0.1-git)'; + + public $services = array( + 'prefsMenu' => array( + 'args' => array(), + 'type' => 'object' + ) + ); + + /** + * Generate the menu to use on the prefs page. + * + * @return Horde_Menu A Horde_Menu object. + */ + public function prefsMenu() + { + return Crumb::getMenu(); + } + } diff --git a/crumb/lib/Crumb.php b/crumb/lib/Crumb.php index 2c342532b..3ffe1fa38 100644 --- a/crumb/lib/Crumb.php +++ b/crumb/lib/Crumb.php @@ -17,7 +17,7 @@ class Crumb { /** * Build Crumb's list of menu items. */ - function getMenu($returnType = 'object') + function getMenu() { global $conf, $registry, $browser, $print_link; @@ -25,11 +25,7 @@ class Crumb { $menu->add(Horde::applicationUrl('listclients.php'), _("List Clients"), 'user.png', $registry->getImageDir('horde')); $menu->add(Horde::applicationUrl('addclient.php'), _("Add Client"), 'user.png', $registry->getImageDir('horde')); - if ($returnType == 'object') { - return $menu; - } else { - return $menu->render(); - } + return $menu; } } diff --git a/crumb/templates/menu.inc b/crumb/templates/menu.inc index 97ab6d970..583eeba4d 100644 --- a/crumb/templates/menu.inc +++ b/crumb/templates/menu.inc @@ -1,4 +1,4 @@ notify(array('listeners' => 'status')) ?> diff --git a/fima/lib/Api.php b/fima/lib/Api.php index 59cadd0f7..814d17841 100644 --- a/fima/lib/Api.php +++ b/fima/lib/Api.php @@ -10,6 +10,11 @@ class Fima_Api extends Horde_Regsitry_Api 'updated' => 'boolean' ), 'type' => 'boolean' + ), + + 'prefsMenu' => array( + 'args' => array(), + 'type' => 'object' ) ); @@ -45,4 +50,14 @@ class Fima_Api extends Horde_Regsitry_Api return $updated; } + /** + * Generate the menu to use on the prefs page. + * + * @return Horde_Menu A Horde_Menu object. + */ + public function prefsMenu() + { + return Fima::getMenu(); + } + } diff --git a/fima/lib/Fima.php b/fima/lib/Fima.php index 421389d7e..e9ae5c184 100644 --- a/fima/lib/Fima.php +++ b/fima/lib/Fima.php @@ -747,7 +747,7 @@ class Fima { /** * Build Fima's list of menu items. */ - function getMenu($returnType = 'object') + function getMenu() { global $conf, $registry, $browser, $print_link; @@ -774,11 +774,7 @@ class Fima { $menu->add($print_link, _("_Print"), 'print.png', $registry->getImageDir('horde'), '_blank', Horde::popupJs($print_link, array('urlencode' => true)) . 'return false;', '__noselection'); } - if ($returnType == 'object') { - return $menu; - } else { - return $menu->render(); - } + return $menu; } } diff --git a/fima/templates/menu.inc b/fima/templates/menu.inc index 2eda29fae..0eb6b2e40 100644 --- a/fima/templates/menu.inc +++ b/fima/templates/menu.inc @@ -19,7 +19,7 @@ foreach ($ledgers as $ledgerId => $ledger) {
- + render() ?>
diff --git a/folks/lib/Api.php b/folks/lib/Api.php index f853dbbcb..dd1762796 100644 --- a/folks/lib/Api.php +++ b/folks/lib/Api.php @@ -17,6 +17,11 @@ class Folks_Api extends Horde_Registry_Api public $version = 'H4 (0.1-git)'; public $services = array( + 'prefsMenu' => array( + 'args' => array(), + 'type' => 'object' + ), + 'commentCallback' => array( 'args' => array('id' => 'string'), 'type' => 'string' @@ -151,6 +156,16 @@ class Folks_Api extends Horde_Registry_Api } /** + * Generate the menu to use on the prefs page. + * + * @return Horde_Menu A Horde_Menu object. + */ + public function prefsMenu() + { + return Folks::getMenu(); + } + + /** * Returns profile image URL. * * @param string $user User uid diff --git a/folks/lib/Folks.php b/folks/lib/Folks.php index d7d2d7bb9..3389575fa 100644 --- a/folks/lib/Folks.php +++ b/folks/lib/Folks.php @@ -290,7 +290,7 @@ class Folks { /** * Build Folks's list of menu items. */ - static function getMenu($returnType = 'object') + static function getMenu() { $img = $GLOBALS['registry']->getImageDir('horde'); $menu = new Horde_Menu(Horde_Menu::MASK_ALL); @@ -301,10 +301,6 @@ class Folks { $menu->add(Horde::applicationUrl('search.php'), _("Search"), 'search.png', $img); $menu->add(self::getUrlFor('list', 'online'), _("List"), 'group.png', $img); - if ($returnType == 'object') { - return $menu; - } else { - return $menu->render(); - } + return $menu; } } diff --git a/folks/templates/menu.inc b/folks/templates/menu.inc index 9d3c6acdb..ab8185ff3 100644 --- a/folks/templates/menu.inc +++ b/folks/templates/menu.inc @@ -1,4 +1,4 @@ notify(array('listeners' => 'status')) ?> diff --git a/gollem/lib/Api.php b/gollem/lib/Api.php index b1a6e78e1..69acc5edd 100644 --- a/gollem/lib/Api.php +++ b/gollem/lib/Api.php @@ -38,6 +38,11 @@ class Gollem_Api extends Horde_Registry_Api 'type' => 'boolean' ), + 'prefsMenu' => array( + 'args' => array(), + 'type' => 'object' + ), + 'browse' => array( 'args' => array('path' => 'string'), 'type' => '{urn:horde}hashHash', @@ -156,6 +161,16 @@ class Gollem_Api extends Horde_Registry_Api } /** + * Generate the menu to use on the prefs page. + * + * @return Horde_Menu A Horde_Menu object. + */ + public function prefsMenu() + { + return Gollem::getMenu(); + } + + /** * Browses through the VFS tree. * * Each VFS backend is listed as a directory at the top level. No modify diff --git a/gollem/lib/Gollem.php b/gollem/lib/Gollem.php index 0a136c03a..c7d663aec 100644 --- a/gollem/lib/Gollem.php +++ b/gollem/lib/Gollem.php @@ -754,11 +754,9 @@ class Gollem /** * Build Gollem's list of menu items. * - * @param string $returnType Either 'object' or 'string'. - * - * @return mixed Either a Horde_Menu object or the rendered menu text. + * @return Horde_Menu A Horde_Menu object. */ - static public function getMenu($returnType = 'object') + static public function getMenu() { $menu = new Horde_Menu(); $menu->add(Horde_Util::addParameter(Horde::applicationUrl('manager.php'), 'dir', Gollem::getHome()), _("_My Home"), 'folder_home.png'); @@ -779,9 +777,7 @@ class Gollem } } - return ($returnType == 'object') - ? $menu - : $menu->render(); + return $menu; } /** @@ -799,7 +795,7 @@ class Gollem $link = Horde::link('#', _("Change Server"), '', '', 'serverSubmit(true);return false;'); $t->set('slink', sprintf('', $link, ($menu_view != 'text') ? Horde::img('gollem.png') : '', ($menu_view != 'icon') ? Horde::highlightAccessKey(_("_Change Server"), $t->get('accesskey')) : '')); } - $t->set('menu_string', Gollem::getMenu('string')); + $t->set('menu_string', Gollem::getMenu()->render()); echo $t->fetch(GOLLEM_TEMPLATES . '/menu.html'); } diff --git a/imp/lib/Api.php b/imp/lib/Api.php index cfe6b3b2a..43068459c 100644 --- a/imp/lib/Api.php +++ b/imp/lib/Api.php @@ -211,6 +211,15 @@ class IMP_Api extends Horde_Registry_Api 'prefsCallback' => array( 'args' => array() + ), + + 'prefsMenu' => array( + 'args' => array(), + 'type' => 'object' + ), + + 'prefsStatus' => array( + 'args' => array() ) ); @@ -462,6 +471,33 @@ class IMP_Api extends Horde_Registry_Api } /** + * Generate the menu to use on the prefs page. + * + * @return Horde_Menu A Horde_Menu object. + */ + public function prefsMenu() + { + return IMP::getMenu(); + } + + /** + * Output notifications on the preferences page. + */ + public function prefsStatus() + { + try { + $GLOBALS['imp_authentication'] = 'throw'; + require_once dirname(__FILE__) . '/base.php'; + if (IMP::getViewMode() == 'dimp') { + Horde::addInlineScript(array(DIMP::notify(true)), 'dom'); + return; + } + } catch (Horde_Exception $e) {} + + IMP::status(); + } + + /** * TODO */ protected function _prefsSentmailSelect($updated) @@ -749,7 +785,9 @@ class IMP_Api extends Horde_Registry_Api )); if ($new_session) { - $_SESSION['imp']['cache']['select_view'] = empty($credentials['imp_select_view']) ? '' : $credentials['imp_select_view']; + $_SESSION['imp']['cache']['select_view'] = empty($credentials['imp_select_view']) + ? '' + : $credentials['imp_select_view']; /* Set the Horde ID, since it may have been altered by the 'realm' * setting. */ diff --git a/imp/lib/DIMP.php b/imp/lib/DIMP.php index 231dea247..1edd2c94f 100644 --- a/imp/lib/DIMP.php +++ b/imp/lib/DIMP.php @@ -97,15 +97,17 @@ class DIMP /** * Return the javascript code necessary to display notification popups. * + * @param boolean $parent Send notifications to parent window? + * * @return string The notification JS code. */ - static public function notify() + static public function notify($parent = false) { $GLOBALS['notification']->notify(array('listeners' => 'status')); $msgs = $GLOBALS['imp_notify']->getStack(); return count($msgs) - ? 'DimpCore.showNotifications(' . Horde_Serialize::serialize($msgs, Horde_Serialize::JSON) . ')' + ? ($parent ? 'parent.' : '') . 'DimpCore.showNotifications(' . Horde_Serialize::serialize($msgs, Horde_Serialize::JSON) . ')' : ''; } diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 3a75cf891..73e273aa7 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -538,11 +538,9 @@ class IMP /** * Build IMP's list of menu items. * - * @param string $type Return type: either 'object' or 'string'. - * - * @return mixed Either a Horde_Menu object or the rendered menu text. + * @return Horde_Menu A Horde_Menu object. */ - static public function getMenu($type = 'object') + static public function getMenu() { global $conf, $prefs, $registry; @@ -609,7 +607,7 @@ class IMP $menu->add(Horde::applicationUrl('filterprefs.php'), _("Fi_lters"), 'filters.png'); } - return ($type == 'object') ? $menu : $menu->render(); + return $menu; } /** @@ -635,7 +633,7 @@ class IMP $t->set('flist', self::flistSelect(array('selected' => $GLOBALS['imp_mbox']['mailbox'], 'inc_vfolder' => true))); $t->set('flink', sprintf('%s%s
%s', Horde::link('#'), ($menu_view != 'text') ? Horde::img('folders/open.png', _("Open Folder"), ($menu_view == 'icon') ? array('title' => _("Open Folder")) : array()) : '', ($menu_view != 'icon') ? Horde::highlightAccessKey(_("Open Fo_lder"), $ak) : '')); } - $t->set('menu_string', self::getMenu('string')); + $t->set('menu_string', self::getMenu()->render()); self::$_menuTemplate = $t; } diff --git a/imp/lib/Notification/Listener/Status.php b/imp/lib/Notification/Listener/Status.php index 6355ba67f..9c3da48ec 100644 --- a/imp/lib/Notification/Listener/Status.php +++ b/imp/lib/Notification/Listener/Status.php @@ -61,9 +61,8 @@ class IMP_Notification_Listener_Status extends Horde_Notification_Listener_Statu public function notify(&$messageStack, $options = array()) { /* For dimp, don't capture notification messages if we are logging - * out or accessing the options pages. */ - if (($this->_viewmode == 'dimp') && - Horde_Auth::getAuth() && !strstr($_SERVER['PHP_SELF'], '/prefs.php')) { + * out. */ + if (($this->_viewmode == 'dimp') && Horde_Auth::getAuth()) { $options['store'] = true; } parent::notify($messageStack, $options); diff --git a/ingo/lib/Api.php b/ingo/lib/Api.php index b78a329fa..ab7cab855 100644 --- a/ingo/lib/Api.php +++ b/ingo/lib/Api.php @@ -29,6 +29,11 @@ class Ingo_Api extends Horde_Registry_Api 'type' => '{urn:horde}stringArray' ), + 'prefsMenu' => array( + 'args' => array(), + 'type' => 'object' + ), + 'removeUserData' => array( 'args' => array('user' => 'string'), 'type' => 'boolean' @@ -107,6 +112,16 @@ class Ingo_Api extends Horde_Registry_Api } /** + * Generate the menu to use on the prefs page. + * + * @return Horde_Menu A Horde_Menu object. + */ + public function prefsMenu() + { + return Ingo::getMenu(); + } + + /** * Removes user data. * * @param string $user Name of user to remove data for. diff --git a/ingo/lib/Ingo.php b/ingo/lib/Ingo.php index 0bfc8d12a..364bc48a4 100644 --- a/ingo/lib/Ingo.php +++ b/ingo/lib/Ingo.php @@ -382,7 +382,7 @@ class Ingo /** * Build Ingo's list of menu items. */ - static public function getMenu($returnType = 'object') + static public function getMenu() { $menu = new Horde_Menu(); $menu->add(Horde::applicationUrl('filters.php'), _("Filter _Rules"), 'ingo.png', null, null, null, basename($_SERVER['PHP_SELF']) == 'index.php' ? 'current' : null); @@ -410,7 +410,7 @@ class Ingo $menu->add('#', _("_Permissions"), 'perms.png', $GLOBALS['registry']->getImageDir('horde'), '', Horde::popupJs(Horde::url($GLOBALS['registry']->get('webroot', 'horde') . '/services/shares/edit.php', true), array('params' => array('app' => 'ingo', 'share' => $_SESSION['ingo']['backend']['id'] . ':' . Horde_Auth::getAuth()), 'urlencode' => true)) . 'return false;'); } - return ($returnType == 'object') ? $menu : $menu->render(); + return $menu; } } diff --git a/ingo/templates/menu.inc b/ingo/templates/menu.inc index 693191c77..1c1e9cf18 100644 --- a/ingo/templates/menu.inc +++ b/ingo/templates/menu.inc @@ -13,7 +13,7 @@ - + render() ?>
diff --git a/jeta/lib/Api.php b/jeta/lib/Api.php index 77cc1896a..5ffa6901b 100644 --- a/jeta/lib/Api.php +++ b/jeta/lib/Api.php @@ -2,4 +2,22 @@ class Jeta_Api extends Horde_Registry_Api { public $version = 'H4 (2.0-git)'; + + public $services = array( + 'prefsMenu' => array( + 'args' => array(), + 'type' => 'object' + ) + ); + + /** + * Generate the menu to use on the prefs page. + * + * @return Horde_Menu A Horde_Menu object. + */ + public function prefsMenu() + { + return Jeta::getMenu(); + } + } diff --git a/jeta/lib/Jeta.php b/jeta/lib/Jeta.php index 964afe627..250fb41fb 100644 --- a/jeta/lib/Jeta.php +++ b/jeta/lib/Jeta.php @@ -13,7 +13,7 @@ class Jeta { /** * Build Jeta's list of menu items. */ - function getMenu($returnType = 'object') + function getMenu() { global $registry, $conf; @@ -22,7 +22,7 @@ class Jeta { /* Jeta Home. */ $menu->addArray(array('url' => Horde::applicationUrl('main.php'), 'text' => _("_Shell"), 'icon' => 'jeta.png', 'class' => (basename($_SERVER['PHP_SELF']) == 'main.php' || basename($_SERVER['PHP_SELF']) == 'index.php') ? 'current' : '')); - return ($returnType == 'object') ? $menu : $menu->render(); + return $menu; } } diff --git a/jeta/main.php b/jeta/main.php index 34013ba2d..fb59c4972 100644 --- a/jeta/main.php +++ b/jeta/main.php @@ -13,7 +13,7 @@ require_once dirname(__FILE__) . '/lib/base.php'; $applet = Jeta_Applet::factory($prefs->getValue('sshdriver')); $template = new Horde_Template(); -$template->set('menu', Jeta::getMenu('string')); +$template->set('menu', Jeta::getMenu()->render()); $template->set('notification', $notification->notify(array('listeners' => 'status'))); $template->set('applet', $applet->generateAppletCode()); diff --git a/kastalia/lib/Api.php b/kastalia/lib/Api.php index 8a0d665f3..b99a6d53e 100644 --- a/kastalia/lib/Api.php +++ b/kastalia/lib/Api.php @@ -2,4 +2,22 @@ class Kastalia_Api extends Horde_Registry_Api { public $version = '1.0.1'; + + public $services = array( + 'prefsMenu' => array( + 'args' => array(), + 'type' => 'object' + ) + ); + + /** + * Generate the menu to use on the prefs page. + * + * @return Horde_Menu A Horde_Menu object. + */ + public function prefsMenu() + { + return Kastalia::getMenu(); + } + } diff --git a/kastalia/lib/Kastalia.php b/kastalia/lib/Kastalia.php index c7915d5dc..6b5aeacf1 100755 --- a/kastalia/lib/Kastalia.php +++ b/kastalia/lib/Kastalia.php @@ -16,22 +16,15 @@ class Kastalia { /** * Build Kastalia's list of menu items. */ - function getMenu($returnType = 'object') + function getMenu() { global $conf, $registry, $browser, $print_link; - require_once 'Horde/Menu.php'; - - $menu = new Menu(HORDE_MENU_MASK_ALL); + $menu = new Horde_Menu(HORDE_MENU_MASK_ALL); $menu->add(Horde::applicationUrl('upload_menu.php'), _("Upload"), 'menu/upload.png', $registry->getImageDir('kastalia')); - - if ($returnType == 'object') { - return $menu; - } else { - return $menu->render(); - } + return $menu; } //diese Funktion entfernt aus einem String alle hier angegebenen Sonderzeichen diff --git a/kastalia/templates/menu.inc b/kastalia/templates/menu.inc index dc4aabd6c..8ae1df709 100755 --- a/kastalia/templates/menu.inc +++ b/kastalia/templates/menu.inc @@ -1,4 +1,4 @@ notify(array('listeners' => 'status')) ?> diff --git a/kronolith/lib/Api.php b/kronolith/lib/Api.php index d02dab50e..3ff3e9738 100644 --- a/kronolith/lib/Api.php +++ b/kronolith/lib/Api.php @@ -34,6 +34,11 @@ class Kronolith_Api extends Horde_Registry_Api 'args' => array() ), + 'prefsMenu' => array( + 'args' => array(), + 'type' => 'object' + ), + 'show' => array( 'link' => '%application%/event.php?calendar=|calendar|&eventID=|event|&uid=|uid|' ), @@ -271,6 +276,16 @@ class Kronolith_Api extends Horde_Registry_Api } /** + * Generate the menu to use on the prefs page. + * + * @return Horde_Menu A Horde_Menu object. + */ + public function prefsMenu() + { + return Kronolith::getMenu(); + } + + /** * TODO */ protected function _prefsRemoteCalManagement($updated) diff --git a/kronolith/lib/Kronolith.php b/kronolith/lib/Kronolith.php index 54a00a8ac..94a419263 100644 --- a/kronolith/lib/Kronolith.php +++ b/kronolith/lib/Kronolith.php @@ -1861,7 +1861,7 @@ class Kronolith /** * Builds Kronolith's list of menu items. */ - public static function getMenu($returnType = 'object') + public static function getMenu() { global $conf, $registry, $browser, $prefs; @@ -1897,7 +1897,7 @@ class Kronolith $menu->add(Horde_Util::addParameter($view->link(), 'print', 1), _("_Print"), 'print.png', $registry->getImageDir('horde'), '_blank', 'Horde.popup({ url: kronolithPrintLink ? kronolithPrintLink : this.href });return false;', '__noselection'); } - return ($returnType == 'object') ? $menu : $menu->render(); + return $menu; } /** diff --git a/kronolith/templates/menu.inc b/kronolith/templates/menu.inc index 522c7189d..9114c335b 100644 --- a/kronolith/templates/menu.inc +++ b/kronolith/templates/menu.inc @@ -1,4 +1,4 @@ notify(array('listeners' => 'status')) ?> diff --git a/nag/lib/Api.php b/nag/lib/Api.php index 9b5057a3d..aaa5f1a2a 100644 --- a/nag/lib/Api.php +++ b/nag/lib/Api.php @@ -35,6 +35,11 @@ class Nag_Api extends Horde_Registry_Api 'type' => 'boolean' ), + 'prefsMenu' => array( + 'args' => array(), + 'type' => 'object' + ), + 'removeUserData' => array( 'args' => array('user' => 'string'), 'type' => 'boolean' @@ -240,6 +245,16 @@ class Nag_Api extends Horde_Registry_Api } /** + * Generate the menu to use on the prefs page. + * + * @return Horde_Menu A Horde_Menu object. + */ + public function prefsMenu() + { + return Nag::getMenu(); + } + + /** * Removes user data. * * @param string $user Name of user to remove data for. diff --git a/nag/lib/Nag.php b/nag/lib/Nag.php index 4764a988c..fb3c76c70 100644 --- a/nag/lib/Nag.php +++ b/nag/lib/Nag.php @@ -661,7 +661,7 @@ class Nag /** * Build Nag's list of menu items. */ - function getMenu($returnType = 'object') + function getMenu() { global $conf, $registry, $print_link; @@ -690,7 +690,7 @@ class Nag $menu->add($print_link, _("_Print"), 'print.png', $registry->getImageDir('horde'), '_blank', Horde::popupJs($print_link, array('urlencode' => true)) . 'return false;', '__noselection'); } - return ($returnType == 'object') ? $menu : $menu->render(); + return $menu; } function status() diff --git a/nag/templates/menu.inc b/nag/templates/menu.inc index da24cd28e..344791a21 100644 --- a/nag/templates/menu.inc +++ b/nag/templates/menu.inc @@ -1,4 +1,4 @@ '{urn:horde}hashHash' ), + 'prefsMenu' => array( + 'args' => array(), + 'type' => 'object' + ), + 'commentCallback' => array( 'args' => array('id' => 'string'), 'type' => 'string' @@ -72,6 +75,16 @@ class News_Api extends Horde_Registry_Api } /** + * Generate the menu to use on the prefs page. + * + * @return Horde_Menu A Horde_Menu object. + */ + public function prefsMenu() + { + return News::getMenu(); + } + + /** * Callback for comment API * * @param int $id Internal data identifier diff --git a/news/lib/News.php b/news/lib/News.php index b1092f284..ea01602ae 100644 --- a/news/lib/News.php +++ b/news/lib/News.php @@ -490,7 +490,7 @@ class News { /** * Build News's list of menu articles */ - static public function getMenu($returnType = 'object') + static public function getMenu() { $menu = new Horde_Menu(); $img_dir = $GLOBALS['registry']->getImageDir('horde'); @@ -511,11 +511,7 @@ class News { $menu->add(Horde::applicationUrl('admin/categories/index.php'), _("Administration"), 'administration.png', $img_dir); } - if ($returnType == 'object') { - return $menu; - } else { - return $menu->render(); - } + return $menu; } } diff --git a/news/templates/menu.inc b/news/templates/menu.inc index 9fecbd66d..e765e12ea 100644 --- a/news/templates/menu.inc +++ b/news/templates/menu.inc @@ -8,6 +8,6 @@ - +render() ?> notify(array('listeners' => 'status')) ?> diff --git a/skeleton/lib/Api.php b/skeleton/lib/Api.php index 8477a2f25..78ec45d46 100644 --- a/skeleton/lib/Api.php +++ b/skeleton/lib/Api.php @@ -2,4 +2,22 @@ class Skeleton_Api extends Horde_Registry_Api { public $version = 'H4 (0.1-git)'; + + public $services = array( + 'prefsMenu' => array( + 'args' => array(), + 'type' => 'object' + ) + ); + + /** + * Generate the menu to use on the prefs page. + * + * @return Horde_Menu A Horde_Menu object. + */ + public function prefsMenu() + { + return Skeleton::getMenu(); + } + } diff --git a/skeleton/lib/Skeleton.php b/skeleton/lib/Skeleton.php index dc76980bf..2c2b3fff6 100644 --- a/skeleton/lib/Skeleton.php +++ b/skeleton/lib/Skeleton.php @@ -15,12 +15,12 @@ class Skeleton /** * Build Skeleton's list of menu items. */ - static public function getMenu($returnType = 'object') + static public function getMenu() { $menu = new Horde_Menu(Horde_Menu::MASK_ALL); $menu->add(Horde::applicationUrl('list.php'), _("List"), 'user.png', $GLOBALS['registry']->getImageDir('horde')); - return ($returnType == 'object') ? $menu : $menu->render(); + return $menu; } } diff --git a/skeleton/templates/menu.inc b/skeleton/templates/menu.inc index 72a144dd2..31a5993ab 100644 --- a/skeleton/templates/menu.inc +++ b/skeleton/templates/menu.inc @@ -1,4 +1,4 @@ notify(array('listeners' => 'status')) ?> diff --git a/skoli/lib/Api.php b/skoli/lib/Api.php index e43684d2a..3b4ebf95a 100644 --- a/skoli/lib/Api.php +++ b/skoli/lib/Api.php @@ -2,4 +2,22 @@ class Skoli_Api extends Horde_Registry_Api { public $version = 'H4 (0.1-git)'; + + public $services = array( + 'prefsMenu' => array( + 'args' => array(), + 'type' => 'object' + ) + ); + + /** + * Generate the menu to use on the prefs page. + * + * @return Horde_Menu A Horde_Menu object. + */ + public function prefsMenu() + { + return Skoli::getMenu(); + } + } diff --git a/skoli/lib/Skoli.php b/skoli/lib/Skoli.php index e972bffcc..7c5832d85 100644 --- a/skoli/lib/Skoli.php +++ b/skoli/lib/Skoli.php @@ -486,7 +486,7 @@ class Skoli { /** * Build Skoli's list of menu items. */ - function getMenu($returnType = 'object') + function getMenu() { global $conf, $registry, $browser, $print_link; @@ -513,11 +513,7 @@ class Skoli { } */ - if ($returnType == 'object') { - return $menu; - } else { - return $menu->render(); - } + return $menu; } /** diff --git a/skoli/templates/menu.inc b/skoli/templates/menu.inc index 72cecc822..2996974ad 100644 --- a/skoli/templates/menu.inc +++ b/skoli/templates/menu.inc @@ -1,4 +1,4 @@ notify(array('listeners' => 'status')) ?> diff --git a/turba/lib/Api.php b/turba/lib/Api.php index 06705e8a5..839077d9d 100644 --- a/turba/lib/Api.php +++ b/turba/lib/Api.php @@ -41,6 +41,11 @@ class Turba_Api extends Horde_Registry_Api 'type' => 'boolean' ), + 'prefsMenu' => array( + 'args' => array(), + 'type' => 'object' + ), + 'removeUserData' => array( 'args' => array('user' => 'string'), 'type' => 'boolean' @@ -370,6 +375,16 @@ class Turba_Api extends Horde_Registry_Api } /** + * Generate the menu to use on the prefs page. + * + * @return Horde_Menu A Horde_Menu object. + */ + public function prefsMenu() + { + return Turba::getMenu(); + } + + /** * Removes user data. * * @param string $user Name of user to remove data for. diff --git a/turba/lib/Turba.php b/turba/lib/Turba.php index 5d36e0649..990229c65 100644 --- a/turba/lib/Turba.php +++ b/turba/lib/Turba.php @@ -264,8 +264,6 @@ class Turba { /** * Returns the real name, if available, of a user. - * - * @since Turba 2.2 */ function getUserName($uid) { @@ -287,8 +285,6 @@ class Turba { /** * Gets extended permissions on an address book. * - * @since Turba 2.1 - * * @param Turba_Driver $addressBook The address book to get extended permissions for. * @param string $permission What extended permission to get. * @@ -468,8 +464,6 @@ class Turba { * Retrieve a new source config entry based on a Turba share. * * @param Horde_Share object The share to base config on. - * - * @since Turba 2.2 */ function getSourceFromShare(&$share) { @@ -586,7 +580,7 @@ class Turba { /** * Build Turba's list of menu items. */ - function getMenu($returnType = 'object') + function getMenu() { $menu = new Horde_Menu(); @@ -611,7 +605,7 @@ class Turba { $menu->add($GLOBALS['print_link'], _("_Print"), 'print.png', $GLOBALS['registry']->getImageDir('horde'), '_blank', Horde::popupJs($GLOBALS['print_link'], array('urlencode' => true)) . 'return false);', '__noselection'); } - return ($returnType == 'object') ? $menu : $menu->render(); + return $menu; } } diff --git a/turba/templates/menu.inc b/turba/templates/menu.inc index d064486ec..afc2cad17 100644 --- a/turba/templates/menu.inc +++ b/turba/templates/menu.inc @@ -9,7 +9,7 @@
- + render() ?>
-- 2.11.0