diff options
| author | 2017-12-10 11:31:19 +0100 | |
|---|---|---|
| committer | 2017-12-10 11:31:19 +0100 | |
| commit | 84c78098d27de624319df37ffb1a522318ec6778 (patch) | |
| tree | fcf8af3fac381b56df4ff798729ecc92bab5955d | |
| parent | c3d2496bb3ce665faf4a0f24a4aa2ab300ab56d3 (diff) | |
added new extension hook
using hook for reading modes in navigation
| -rw-r--r-- | app/layout/nav_menu.phtml | 42 | ||||
| -rw-r--r-- | lib/Minz/ExtensionManager.php | 4 |
2 files changed, 34 insertions, 12 deletions
diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml index f6d824d55..c0141e8a4 100644 --- a/app/layout/nav_menu.phtml +++ b/app/layout/nav_menu.phtml @@ -131,20 +131,38 @@ <?php $url_output = Minz_Request::currentRequest(); ?> <div class="stick" id="nav_menu_views"> - <?php $url_output['a'] = 'normal'; ?> - <a class="view_normal btn <?php echo $actual_view == 'normal'? 'active' : ''; ?>" title="<?php echo _t('index.menu.normal_view'); ?>" href="<?php echo Minz_Url::display($url_output); ?>"> - <?php echo _i("view-normal"); ?> - </a> + <?php + $readingModes = array( + 'normal' => array( + 'name' => _i("view-normal"), + 'title' => _t('index.menu.normal_view'), + 'url' => array_merge($url_output, array('c' => Minz_Request::defaultControllerName(), 'a' => 'normal')), + 'active' => (Minz_Request::controllerName() == Minz_Request::defaultControllerName() && $actual_view == 'normal'), + ), + 'global' => array( + 'name' => _i("view-global"), + 'title' => _t('index.menu.global_view'), + 'url' => array_merge($url_output, array('c' => Minz_Request::defaultControllerName(), 'a' => 'global')), + 'active' => (Minz_Request::controllerName() == Minz_Request::defaultControllerName() && $actual_view == 'global'), + ), + 'reader' => array( + 'name' => _i("view-reader"), + 'title' => _t('index.menu.reader_view'), + 'url' => array_merge($url_output, array('c' => Minz_Request::defaultControllerName(), 'a' => 'reader')), + 'active' => (Minz_Request::controllerName() == Minz_Request::defaultControllerName() && $actual_view == 'reader'), + ), + ); - <?php $url_output['a'] = 'global'; ?> - <a class="view_global btn <?php echo $actual_view == 'global'? 'active' : ''; ?>" title="<?php echo _t('index.menu.global_view'); ?>" href="<?php echo Minz_Url::display($url_output); ?>"> - <?php echo _i("view-global"); ?> - </a> + $readingModes = Minz_ExtensionManager::callHook('nav_reading_modes', $readingModes); - <?php $url_output['a'] = 'reader'; ?> - <a class="view_reader btn <?php echo $actual_view == 'reader'? 'active' : ''; ?>" title="<?php echo _t('index.menu.reader_view'); ?>" href="<?php echo Minz_Url::display($url_output); ?>"> - <?php echo _i("view-reader"); ?> - </a> + foreach($readingModes as $key => $mode) { + ?> + <a class="view_normal btn <?php if ($mode['active']) { echo 'active'; } ?>" title="<?php echo $mode['title']; ?>" href="<?php echo Minz_Url::display($mode['url']); ?>"> + <?php echo $mode['name']; ?> + </a> + <?php + } + ?> <?php $url_output['a'] = 'rss'; diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php index c5c68a8d4..68bdc463c 100644 --- a/lib/Minz/ExtensionManager.php +++ b/lib/Minz/ExtensionManager.php @@ -31,6 +31,10 @@ class Minz_ExtensionManager { 'list' => array(), 'signature' => 'NoneToNone', ), + 'nav_reading_modes' => array( // function($readingModes = array) -> array | null + 'list' => array(), + 'signature' => 'OneToOne', + ), ); private static $ext_to_hooks = array(); |
