* 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');
if (get_config('link','hideasides'))
register_hook('page_header', 'addon/link/link.php', 'hideasides_header');
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');
unregister_hook('page_header', 'addon/link/link.php', 'hideasides_header');
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'),
'$hideasides' => array('hideasides', t('Hide side panels on the link page'), get_config('link', 'hideasides')),
'$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']));
set_config('link','hideasides',trim($_POST['hideasides']));
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');
if (get_config('link','hideasides'))
register_hook('page_header', 'addon/link/link.php', 'hideasides_header');
else
unregister_hook('page_header', 'addon/link/link.php', 'hideasides_header');
info( t('Settings updated.') . EOL );
}
function dropdown_link($a, &$extras) {
$arr = $extras;
$item_id = $extras['item']['item_id'];
$arr['dropdown_extras'] .= ''.t('Link on Hub').'';
$extras = $arr;
}
function hideasides_header($a, &$b) {
$querystr = stristr(App::$query_string, '/', true);
if ($querystr == "link") {
$addScriptTag = "\r\n";
App::$page['htmlhead'] .= $addScriptTag;
}
}