2020-03-21 18:30:30 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Name: Link
|
|
|
|
* Description: Using short links on whole hub
|
2020-03-31 21:08:20 +00:00
|
|
|
* Version: 0.04
|
2020-03-21 18:30:30 +00:00
|
|
|
* Author: ivan zlax <@zlax@ussr.win>
|
|
|
|
* Maintainer: ivan zlax <@zlax@ussr.win>
|
|
|
|
*/
|
|
|
|
|
2020-03-31 20:21:35 +00:00
|
|
|
use Zotlabs\Lib\Apps;
|
|
|
|
use Zotlabs\Extend\Hook;
|
|
|
|
use Zotlabs\Extend\Route;
|
2020-03-21 18:30:30 +00:00
|
|
|
|
2020-03-31 20:21:35 +00:00
|
|
|
function link_load() {
|
|
|
|
register_hook('page_end', 'addon/link/link.php', 'link_active');
|
|
|
|
Route::register('addon/link/Mod_Link.php','link');
|
|
|
|
}
|
2020-03-21 18:30:30 +00:00
|
|
|
|
2020-03-31 20:21:35 +00:00
|
|
|
function link_unload() {
|
|
|
|
unregister_hook('page_end', 'addon/link/link.php', 'link_active');
|
|
|
|
Route::unregister('addon/link/Mod_Link.php','link');
|
2020-03-31 17:45:31 +00:00
|
|
|
}
|
|
|
|
|
2020-03-31 20:21:35 +00:00
|
|
|
function link_active(&$a,&$b) {
|
2020-03-31 21:08:20 +00:00
|
|
|
// Javascript code for "Link on Hub" button insert - it is not good, it is temporarily, just for testing purposes
|
|
|
|
$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";
|
2020-03-31 20:21:35 +00:00
|
|
|
}
|