2020-03-21 18:30:30 +00:00
< ? php
/**
* Name : Link
* Description : Using short links on whole hub
2020-04-07 08:48:05 +00:00
* Version : 0.66
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 () {
2020-04-04 20:18:26 +00:00
Route :: register ( 'addon/link/Mod_Link.php' , 'link' );
if ( get_config ( 'link' , 'linkonhub' ))
Hook :: register ( 'dropdown_extras' , 'addon/link/link.php' , 'dropdown_link' , 1 , 5000 );
set_config ( 'link' , 'linkenabled' , 1 );
2020-03-31 20:21:35 +00:00
}
2020-03-21 18:30:30 +00:00
2020-03-31 20:21:35 +00:00
function link_unload () {
2020-04-04 20:18:26 +00:00
Route :: unregister ( 'addon/link/Mod_Link.php' , 'link' );
Hook :: unregister ( 'dropdown_extras' , 'addon/link/link.php' , 'dropdown_link' );
del_config ( 'link' , 'linkenabled' );
2020-04-02 11:38:07 +00:00
}
function link_plugin_admin ( & $a , & $o ) {
2020-04-04 20:18:26 +00:00
$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' )),
));
2020-04-02 11:38:07 +00:00
}
function link_plugin_admin_post ( & $a ) {
2020-04-04 20:18:26 +00:00
set_config ( 'link' , 'linkonhub' , trim ( $_POST [ 'linkonhub' ]));
if ( get_config ( 'link' , 'linkonhub' ))
Hook :: register ( 'dropdown_extras' , 'addon/link/link.php' , 'dropdown_link' , 1 , 5000 );
else
Hook :: unregister ( 'dropdown_extras' , 'addon/link/link.php' , 'dropdown_link' );
info ( t ( 'Settings updated.' ) . EOL );
2020-03-31 17:45:31 +00:00
}
2020-04-04 20:18:26 +00:00
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 ;
2020-03-31 20:21:35 +00:00
}