50 lines
1.6 KiB
PHP
50 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* Name: Link
|
|
* Description: Using short links on whole hub
|
|
* Version: 0.67
|
|
* Author: ivan zlax <@zlax@ussr.win>
|
|
* Maintainer: ivan zlax <@zlax@ussr.win>
|
|
*/
|
|
|
|
use Zotlabs\Lib\Apps;
|
|
use Zotlabs\Extend\Hook;
|
|
use Zotlabs\Extend\Route;
|
|
|
|
function link_load() {
|
|
Route::register('addon/link/Mod_Link.php','link');
|
|
if (get_config('link','linkonhub'))
|
|
register_hook('dropdown_extras', 'addon/link/link.php', 'dropdown_link');
|
|
set_config('link','linkenabled',1);
|
|
}
|
|
|
|
function link_unload() {
|
|
Route::unregister('addon/link/Mod_Link.php','link');
|
|
unregister_hook('dropdown_extras', 'addon/link/link.php', 'dropdown_link');
|
|
del_config('link','linkenabled');
|
|
}
|
|
|
|
function link_plugin_admin(&$a,&$o) {
|
|
$t = get_markup_template( "admin.tpl", "addon/link/" );
|
|
$o = replace_macros($t, array(
|
|
'$submit' => t('Submit'),
|
|
'$linkonhub' => array('linkonhub', t('Show "Link on Hub" in the dropdown menu'), get_config('link', 'linkonhub')),
|
|
));
|
|
}
|
|
|
|
function link_plugin_admin_post(&$a) {
|
|
set_config('link','linkonhub',trim($_POST['linkonhub']));
|
|
if (get_config('link','linkonhub'))
|
|
register_hook('dropdown_extras', 'addon/link/link.php', 'dropdown_link');
|
|
else
|
|
unregister_hook('dropdown_extras', 'addon/link/link.php', 'dropdown_link');
|
|
info( t('Settings updated.') . EOL );
|
|
}
|
|
|
|
function dropdown_link(&$extras) {
|
|
$arr = $extras;
|
|
$item_id = $extras['item']['item_id'];
|
|
$arr['dropdown_extras'] .= '<a class="dropdown-item" href="'.z_root().'/link/'.$item_id.'" title="'.t('Link on Hub').'" class="u-url"><i class="generic-icons-nav fa fa-fw fa-link"></i>'.t('Link on Hub').'</a>';
|
|
$extras = $arr;
|
|
}
|