[7701] | 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 |
---|
[31466] | 8 | Author URI: http://temmii.com/piwigo/ |
---|
[7701] | 9 | */ |
---|
| 10 | |
---|
[31466] | 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 | // +-----------------------------------------------------------------------+ |
---|
[7767] | 30 | define('PFI_DIR' , basename(dirname(__FILE__))); |
---|
| 31 | define('PFI_PATH' , PHPWG_PLUGINS_PATH . PFI_DIR . '/'); |
---|
[31466] | 32 | define('PFI_ADMIN',get_root_url().'admin.php?page=plugin-'.PFI_DIR); |
---|
[7767] | 33 | |
---|
[31466] | 34 | add_event_handler('loading_lang', 'PersoFavicon_loading_lang'); |
---|
| 35 | function PersoFavicon_loading_lang(){ |
---|
| 36 | load_language('plugin.lang', PFI_PATH); |
---|
| 37 | } |
---|
| 38 | |
---|
[7767] | 39 | //Ajout du menu admin |
---|
| 40 | add_event_handler('get_admin_plugin_menu_links', 'PersoFavicon_admin_menu'); |
---|
[31466] | 41 | function PersoFavicon_admin_menu($menu){ |
---|
| 42 | $menu[] = array( |
---|
| 43 | 'NAME' => l10n('PersoFavicon'), |
---|
| 44 | 'URL' => PFI_ADMIN, |
---|
| 45 | ); |
---|
[7767] | 46 | return $menu; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | // Remplace le code dans le header |
---|
[7701] | 51 | add_event_handler('loc_begin_page_header', 'Change_Favicon', 55 ); |
---|
[31466] | 52 | function Change_Favicon(){ |
---|
[7701] | 53 | global $template; |
---|
| 54 | $template->set_prefilter('header', 'Favicon'); |
---|
[31466] | 55 | } |
---|
[7701] | 56 | |
---|
[31466] | 57 | function Favicon($content, &$smarty){ |
---|
[7701] | 58 | $search = '#<link rel="shortcut icon".*?favicon.ico">#'; |
---|
[31466] | 59 | global $conf; |
---|
| 60 | $favicon_name = & $conf['PersoFavicon']; |
---|
[7767] | 61 | |
---|
[31466] | 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 | } |
---|
[7701] | 67 | return preg_replace($search, $replacement, $content); |
---|
[31466] | 68 | } |
---|
[10632] | 69 | |
---|
[7701] | 70 | ?> |
---|