add settings page for optional Link on Hub button
This commit is contained in:
parent
34f18e9663
commit
6bc3200bd9
|
@ -9,4 +9,6 @@ hub.domain/link/item
|
||||||
|
|
||||||
where an item is the numeric value of an object from the database.
|
where an item is the numeric value of an object from the database.
|
||||||
|
|
||||||
|
It is possible to use /admin/addons/link settings page for enabling or disabling of showing "Link on Hub" button (currently used javascript hack for the integrating with wall-item-menu, it will be fixed later)
|
||||||
|
|
||||||
Based on Zotlabs/Module/Display.php
|
Based on Zotlabs/Module/Display.php
|
|
@ -12,16 +12,37 @@ use Zotlabs\Extend\Hook;
|
||||||
use Zotlabs\Extend\Route;
|
use Zotlabs\Extend\Route;
|
||||||
|
|
||||||
function link_load() {
|
function link_load() {
|
||||||
register_hook('page_end', 'addon/link/link.php', 'link_active');
|
|
||||||
Route::register('addon/link/Mod_Link.php','link');
|
Route::register('addon/link/Mod_Link.php','link');
|
||||||
|
if (get_config('link','linkonhub'))
|
||||||
|
register_hook('page_end', 'addon/link/link.php', 'link_active');
|
||||||
}
|
}
|
||||||
|
|
||||||
function link_unload() {
|
function link_unload() {
|
||||||
unregister_hook('page_end', 'addon/link/link.php', 'link_active');
|
|
||||||
Route::unregister('addon/link/Mod_Link.php','link');
|
Route::unregister('addon/link/Mod_Link.php','link');
|
||||||
|
unregister_hook('page_end', 'addon/link/link.php', 'link_active');
|
||||||
|
}
|
||||||
|
|
||||||
|
function link_plugin_admin(&$a,&$o) {
|
||||||
|
$linkonhub = get_config('link','linkonhub');
|
||||||
|
|
||||||
|
$t = get_markup_template( "admin.tpl", "addon/link/" );
|
||||||
|
$o = replace_macros($t, array(
|
||||||
|
'$submit' => t('Submit'),
|
||||||
|
'$linkonhub' => array('linkonhub', t('Show "Link on Hub" button'), get_config('link', 'linkonhub'), t('Currently used javascript hack for the integrating with wall-item-menu (will be fixed later)')),
|
||||||
|
));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function link_plugin_admin_post(&$a) {
|
||||||
|
set_config('link','linkonhub',trim($_POST['linkonhub']));
|
||||||
|
info( t('Settings updated.') . EOL);
|
||||||
|
if (get_config('link','linkonhub'))
|
||||||
|
register_hook('page_end', 'addon/link/link.php', 'link_active');
|
||||||
|
else
|
||||||
|
unregister_hook('page_end', 'addon/link/link.php', 'link_active');
|
||||||
}
|
}
|
||||||
|
|
||||||
function link_active(&$a,&$b) {
|
function link_active(&$a,&$b) {
|
||||||
// Javascript code for "Link on Hub" button insert - it is not good, it is temporarily, just for testing purposes
|
// Javascript code for "Link on Hub" button insert - it is not good, it is temporarily, works not good
|
||||||
$b .= "\n<script>window.buttonsnotedited = true; setInterval(addButtons, 1000); function addButtons() { if (window.buttonsnotedited == true) { if (loadingPage == false) { let visibleitems = document.querySelectorAll('.btn-group [aria-labelledby]'); for (currentitem of visibleitems) { if (currentitem.getAttribute('aria-labelledby').substr(0,15) == 'wall-item-menu-') currentitem.querySelector('[title=\"Link to Source\"]').outerHTML += '<a class=\"dropdown-item\" href=\"/link/' + currentitem.getAttribute('aria-labelledby').substr(15) + '\" title=\"Link on Hub\"><i class=\"generic-icons-nav fa fa-fw fa-external-link\"></i>Link on Hub</a>';} window.buttonsnotedited = false; } } }</script>\n";
|
$b .= "\n<script>window.buttonsnotedited = true; setInterval(addButtons, 1000); function addButtons() { if (window.buttonsnotedited == true) { if (loadingPage == false) { let visibleitems = document.querySelectorAll('.btn-group [aria-labelledby]'); for (currentitem of visibleitems) { if (currentitem.getAttribute('aria-labelledby').substr(0,15) == 'wall-item-menu-') currentitem.querySelector('[title=\"Link to Source\"]').outerHTML += '<a class=\"dropdown-item\" href=\"/link/' + currentitem.getAttribute('aria-labelledby').substr(15) + '\" title=\"Link on Hub\"><i class=\"generic-icons-nav fa fa-fw fa-external-link\"></i>Link on Hub</a>';} window.buttonsnotedited = false; } } }</script>\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
{{include file="field_checkbox.tpl" field=$linkonhub}}
|
||||||
|
<div class="submit"><input type="submit" name="page_site" value="{{$submit}}" /></div>
|
Loading…
Reference in New Issue