2015-12-08 13:57:50 +01:00
< ? php
/**
* Name : bookmarker
2016-03-20 08:06:33 +01:00
* Description : Replace #^ with a bookmark icon. Font awesome is used for Redbasic and derived themes. A neutral dark grey PNG file is used for other themes.
* Version : 1.1
2015-12-08 13:57:50 +01:00
* Author : Mike Macgirvin < mike @ zothub . com >
2016-02-28 12:11:12 +01:00
* Maintainer : Mike Macgirvin < mike @ macgirvin . com >
2015-12-08 13:57:50 +01:00
*
*/
function bookmarker_install () {
register_hook ( 'prepare_body' , 'addon/bookmarker/bookmarker.php' , 'bookmarker_prepare_body' , 10 );
}
function bookmarker_uninstall () {
unregister_hook ( 'prepare_body' , 'addon/bookmarker/bookmarker.php' , 'bookmarker_prepare_body' );
}
function bookmarker_prepare_body ( & $a , & $b ) {
if ( get_pconfig ( local_channel (), 'bookmarker' , 'disable' ))
return ;
if ( ! strpos ( $b [ 'html' ], 'bookmark-identifier' ))
return ;
2016-04-17 16:29:18 +02:00
if ( function_exists ( 'redbasic_init' ) || App :: $theme_info [ 'extends' ] == 'redbasic' )
2016-03-20 08:06:33 +01:00
$bookmarkicon = '<i class="icon-bookmark"></i>' ;
else
$bookmarkicon = '<img src="addon/bookmarker/bookmarker.png" width="19px" height="20px" alt="#^" />' ;
2015-12-08 13:57:50 +01:00
$id = $b [ 'item' ][ 'id' ];
if ( local_channel ())
2016-03-20 08:06:33 +01:00
$link = '<a class="fakelink" onclick="itemBookmark(' . $id . '); return false;" title="' . t ( 'Save Bookmarks' ) . '" href="#">' . $bookmarkicon . '</a> ' ;
2015-12-08 13:57:50 +01:00
else
2016-03-20 08:06:33 +01:00
$link = $bookmarkicon . '</a> ' ;
2015-12-08 13:57:50 +01:00
$b [ 'html' ] = str_replace ( '<span class="bookmark-identifier">#^</span>' , $link , $b [ 'html' ]);
}