source: extensions/PersoFavicon/main.inc.php @ 31965

Revision 31466, 2.9 KB checked in by ddtddt, 4 years ago (diff)

[extensions] - PersoFavicon - 2.8

Line 
1<?php
2/*
3Plugin Name: Personal Favicon
4Version: auto
5Description: Replace Piwigo fivicon by the favicon in local directory
6Plugin URI: http://piwigo.org/ext/extension_view.php?eid=462
7Author: ddtddt
8Author 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// +-----------------------------------------------------------------------+
30define('PFI_DIR' , basename(dirname(__FILE__)));
31define('PFI_PATH' , PHPWG_PLUGINS_PATH . PFI_DIR . '/');
32define('PFI_ADMIN',get_root_url().'admin.php?page=plugin-'.PFI_DIR);
33
34add_event_handler('loading_lang', 'PersoFavicon_loading_lang');   
35function PersoFavicon_loading_lang(){
36  load_language('plugin.lang', PFI_PATH);
37}
38
39//Ajout du menu admin
40add_event_handler('get_admin_plugin_menu_links', 'PersoFavicon_admin_menu');
41function 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
51add_event_handler('loc_begin_page_header', 'Change_Favicon', 55 );
52function Change_Favicon(){
53        global $template;
54        $template->set_prefilter('header', 'Favicon');
55}
56
57function 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?>
Note: See TracBrowser for help on using the repository browser.