1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Personal Favicon |
---|
4 | Version: auto |
---|
5 | Description: Replace Piwigo fivicon by the favicon in local directory |
---|
6 | Plugin URI: http://piwigo.org/ext/extension_view.php?eid=462 |
---|
7 | Author: ddtddt |
---|
8 | Author URI: http://temmii.com/piwigo/ |
---|
9 | */ |
---|
10 | |
---|
11 | // +-----------------------------------------------------------------------+ |
---|
12 | // | Personal Favicon by plugin for Piwigo | |
---|
13 | // +-----------------------------------------------------------------------+ |
---|
14 | // | Copyright(C) 2010-2016 ddtddt http://temmii.com/piwigo/ | |
---|
15 | // +-----------------------------------------------------------------------+ |
---|
16 | // | This program is free software; you can redistribute it and/or modify | |
---|
17 | // | it under the terms of the GNU General Public License as published by | |
---|
18 | // | the Free Software Foundation | |
---|
19 | // | | |
---|
20 | // | This program is distributed in the hope that it will be useful, but | |
---|
21 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
22 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
23 | // | General Public License for more details. | |
---|
24 | // | | |
---|
25 | // | You should have received a copy of the GNU General Public License | |
---|
26 | // | along with this program; if not, write to the Free Software | |
---|
27 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
28 | // | USA. | |
---|
29 | // +-----------------------------------------------------------------------+ |
---|
30 | define('PFI_DIR' , basename(dirname(__FILE__))); |
---|
31 | define('PFI_PATH' , PHPWG_PLUGINS_PATH . PFI_DIR . '/'); |
---|
32 | define('PFI_ADMIN',get_root_url().'admin.php?page=plugin-'.PFI_DIR); |
---|
33 | |
---|
34 | add_event_handler('loading_lang', 'PersoFavicon_loading_lang'); |
---|
35 | function PersoFavicon_loading_lang(){ |
---|
36 | load_language('plugin.lang', PFI_PATH); |
---|
37 | } |
---|
38 | |
---|
39 | //Ajout du menu admin |
---|
40 | add_event_handler('get_admin_plugin_menu_links', 'PersoFavicon_admin_menu'); |
---|
41 | function PersoFavicon_admin_menu($menu){ |
---|
42 | $menu[] = array( |
---|
43 | 'NAME' => l10n('PersoFavicon'), |
---|
44 | 'URL' => PFI_ADMIN, |
---|
45 | ); |
---|
46 | return $menu; |
---|
47 | } |
---|
48 | |
---|
49 | |
---|
50 | // Remplace le code dans le header |
---|
51 | add_event_handler('loc_begin_page_header', 'Change_Favicon', 55 ); |
---|
52 | function Change_Favicon(){ |
---|
53 | global $template; |
---|
54 | $template->set_prefilter('header', 'Favicon'); |
---|
55 | } |
---|
56 | |
---|
57 | function Favicon($content, &$smarty){ |
---|
58 | $search = '#<link rel="shortcut icon".*?favicon.ico">#'; |
---|
59 | global $conf; |
---|
60 | $favicon_name = & $conf['PersoFavicon']; |
---|
61 | |
---|
62 | if (!empty($favicon_name)){ |
---|
63 | $replacement = '<link rel="shortcut icon" type="image/x-icon" href="'.PHPWG_ROOT_PATH.PWG_LOCAL_DIR.$favicon_name.'.ico">'; |
---|
64 | }else{ |
---|
65 | $replacement = '<link rel="shortcut icon" type="image/x-icon" href="'.PHPWG_ROOT_PATH.PWG_LOCAL_DIR.'favicon.ico">'; |
---|
66 | } |
---|
67 | return preg_replace($search, $replacement, $content); |
---|
68 | } |
---|
69 | |
---|
70 | ?> |
---|