1 | <?php |
---|
2 | /* |
---|
3 | Plugin Name: Media Icon |
---|
4 | Version: auto |
---|
5 | Description: add an icon to non-picture files |
---|
6 | Plugin URI: http://fr.piwigo.org/ext/extension_view.php?eid=654 |
---|
7 | Author: Julien1311 |
---|
8 | */ |
---|
9 | |
---|
10 | //Check whether we are indeed included by Piwigo. |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
12 | |
---|
13 | define('MEDIA_ICON_DIR' , basename(dirname(__FILE__))); |
---|
14 | define('MEDIA_ICON_PATH' , PHPWG_PLUGINS_PATH.MEDIA_ICON_DIR.'/'); |
---|
15 | define('MEDIA_ICON_ABSOLUTE_PATH' , dirname(__FILE__).'/'); |
---|
16 | define('MEDIA_ICON_ADMIN', get_root_url() . 'admin.php?page=plugin-'.MEDIA_ICON_DIR); |
---|
17 | |
---|
18 | /* +-----------------------------------------------------------------------+ |
---|
19 | * | Plugin admin | |
---|
20 | * +-----------------------------------------------------------------------+ */ |
---|
21 | |
---|
22 | // Add an entry to the plugins menu |
---|
23 | add_event_handler('get_admin_plugin_menu_links', 'media_icon_admin_menu'); |
---|
24 | |
---|
25 | function media_icon_admin_menu($menu) { |
---|
26 | array_push( |
---|
27 | $menu, array( |
---|
28 | 'NAME' => 'Media Icon', |
---|
29 | 'URL' => MEDIA_ICON_ADMIN, |
---|
30 | ) |
---|
31 | ); |
---|
32 | return $menu; |
---|
33 | } |
---|
34 | |
---|
35 | /* +-----------------------------------------------------------------------+ |
---|
36 | * | Plugin code | |
---|
37 | * +-----------------------------------------------------------------------+ */ |
---|
38 | |
---|
39 | include_once(MEDIA_ICON_PATH.'include/thumbnails.inc.php'); |
---|
40 | |
---|
41 | /* +-----------------------------------------------------------------------+ |
---|
42 | * | CSS Style | |
---|
43 | * +-----------------------------------------------------------------------+ */ |
---|
44 | |
---|
45 | add_event_handler('loc_end_page_header', 'media_icon_css'); |
---|
46 | |
---|
47 | function media_icon_css() { |
---|
48 | global $template, $conf; |
---|
49 | |
---|
50 | $conf_media_icon_general = unserialize($conf['media_icon_general']); |
---|
51 | |
---|
52 | //add a stylesheet |
---|
53 | $template->append('head_elements', '<link rel="stylesheet" type="text/css" href="'.MEDIA_ICON_PATH.'template/media_icon.css">'); |
---|
54 | if (defined('IN_ADMIN') and IN_ADMIN) |
---|
55 | $template->append('head_elements', '<link rel="stylesheet" type="text/css" href="'.MEDIA_ICON_PATH.'admin/admin.css">'); |
---|
56 | } |
---|
57 | ?> |
---|