aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Clemens Neubauer <cn-tools@gmx.at> 2021-01-07 21:45:48 +0100
committerGravatar GitHub <noreply@github.com> 2021-01-07 21:45:48 +0100
commitef458992c12438f88780c52076cf105e3de8a60e (patch)
treeaa4679fc50d789b3479a0b15c1d968a64c1ca97c
parentbfd872e885c72ac7ca9a6bcf9b6928c1d3e501cb (diff)
two new hooks (#3342)
* add two new hooks I develop a new extension and i need 2 new hooks for it * update EN documentation * Correct typing errors * Update app/views/helpers/javascript_vars.phtml Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
-rw-r--r--app/layout/nav_menu.phtml4
-rw-r--r--app/views/helpers/javascript_vars.phtml2
-rw-r--r--docs/en/developers/03_Backend/05_Extensions.md2
-rw-r--r--lib/Minz/ExtensionManager.php8
-rw-r--r--p/scripts/main.js1
5 files changed, 17 insertions, 0 deletions
diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml
index d76eb776d..124189c68 100644
--- a/app/layout/nav_menu.phtml
+++ b/app/layout/nav_menu.phtml
@@ -175,6 +175,10 @@
</a>
</div>
+ <div class="stick" id="nav_menu_hooks">
+ <?= Minz_ExtensionManager::callHook('nav_menu') ?>
+ </div>
+
<div class="item search">
<form action="<?= _url('index', 'index') ?>" method="get">
<input type="search" name="search" class="extend" value="<?php
diff --git a/app/views/helpers/javascript_vars.phtml b/app/views/helpers/javascript_vars.phtml
index 11373b76f..089175f7d 100644
--- a/app/views/helpers/javascript_vars.phtml
+++ b/app/views/helpers/javascript_vars.phtml
@@ -1,6 +1,7 @@
<?php
$mark = FreshRSS_Context::$user_conf->mark_when;
$s = validateShortcutList(FreshRSS_Context::$user_conf->shortcuts);
+$extData = Minz_ExtensionManager::callHook('js_vars', []);
echo htmlspecialchars(json_encode(array(
'context' => array(
'anonymous' => !FreshRSS_Auth::hasAccess(),
@@ -62,4 +63,5 @@ echo htmlspecialchars(json_encode(array(
'read' => rawurlencode(_i('read')),
'unread' => rawurlencode(_i('unread')),
),
+ 'extensions' => $extData,
), JSON_UNESCAPED_UNICODE), ENT_NOQUOTES, 'UTF-8');
diff --git a/docs/en/developers/03_Backend/05_Extensions.md b/docs/en/developers/03_Backend/05_Extensions.md
index 5ba90bc8c..1ddfdb208 100644
--- a/docs/en/developers/03_Backend/05_Extensions.md
+++ b/docs/en/developers/03_Backend/05_Extensions.md
@@ -327,9 +327,11 @@ The following events are available:
* `feed_before_actualize` (`function($feed) -> Feed | null`): will be executed when a feed is updated. The feed (instance of FreshRSS\_Feed) will be passed as parameter.
* `feed_before_insert` (`function($feed) -> Feed | null`): will be executed when a new feed is imported into the database. The new feed (instance of FreshRSS\_Feed) will be passed as parameter.
* `freshrss_init` (`function() -> none`): will be executed at the end of the initialization of FreshRSS, useful to initialize components or to do additional access checks
+* `js_vars` (`function($vars = array) -> array | null`): will be executed if the `jsonVars` in the header will be generated
* `menu_admin_entry` (`function() -> string`): add an entry at the end of the "Administration" menu, the returned string must be valid HTML (e.g. `<li class="item active"><a href="url">New entry</a></li>`)
* `menu_configuration_entry` (`function() -> string`): add an entry at the end of the "Configuration" menu, the returned string must be valid HTML (e.g. `<li class="item active"><a href="url">New entry</a></li>`)
* `menu_other_entry` (`function() -> string`): add an entry at the end of the header dropdown menu (i.e. after the "About" entry), the returned string must be valid HTML (e.g. `<li class="item active"><a href="url">New entry</a></li>`)
+* `nav_menu` (`function() -> string`): will be executed if the navigation was built.
* `nav_reading_modes` (`function($reading_modes) -> array | null`): **TODO** add documentation
* `post_update` (`function(none) -> none`): **TODO** add documentation
* `simplepie_before_init` (`function($simplePie, $feed) -> none`): **TODO** add documentation
diff --git a/lib/Minz/ExtensionManager.php b/lib/Minz/ExtensionManager.php
index b2814e4a3..e802aad16 100644
--- a/lib/Minz/ExtensionManager.php
+++ b/lib/Minz/ExtensionManager.php
@@ -39,6 +39,10 @@ class Minz_ExtensionManager {
'list' => array(),
'signature' => 'NoneToNone',
),
+ 'js_vars' => array( // function($vars = array) -> array | null
+ 'list' => array(),
+ 'signature' => 'OneToOne',
+ ),
'menu_admin_entry' => array( // function() -> string
'list' => array(),
'signature' => 'NoneToString',
@@ -51,6 +55,10 @@ class Minz_ExtensionManager {
'list' => array(),
'signature' => 'NoneToString',
),
+ 'nav_menu' => array( // function() -> string
+ 'list' => array(),
+ 'signature' => 'NoneToString',
+ ),
'nav_reading_modes' => array( // function($readingModes = array) -> array | null
'list' => array(),
'signature' => 'OneToOne',
diff --git a/p/scripts/main.js b/p/scripts/main.js
index f8d20a622..0dbae3913 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -43,6 +43,7 @@ var context;
context.icons = json.icons;
context.icons.read = decodeURIComponent(context.icons.read);
context.icons.unread = decodeURIComponent(context.icons.unread);
+ context.extensions = json.extensions;
}());
//</Global context>