1 | <?php |
---|
2 | add_event_handler('loc_end_page_header', 'media_icon_picture_css'); |
---|
3 | add_event_handler('render_element_content','media_icon_add_tag_picture',EVENT_HANDLER_PRIORITY_NEUTRAL+10,2); |
---|
4 | |
---|
5 | function media_icon_add_tag_picture($content, $element_info) { |
---|
6 | $media_icon_type = ""; |
---|
7 | |
---|
8 | switch (strrchr($element_info['file'], ".")) { |
---|
9 | case ".pdf": |
---|
10 | $media_icon_type = "pdf"; |
---|
11 | break; |
---|
12 | case ".docx": |
---|
13 | $media_icon_type = "document"; |
---|
14 | break; |
---|
15 | case ".doc": |
---|
16 | $media_icon_type = "document"; |
---|
17 | break; |
---|
18 | case ".odt": |
---|
19 | $media_icon_type = "document"; |
---|
20 | break; |
---|
21 | case ".xlsx": |
---|
22 | $media_icon_type = "spreadsheet"; |
---|
23 | break; |
---|
24 | case ".xls": |
---|
25 | $media_icon_type = "spreadsheet"; |
---|
26 | break; |
---|
27 | case ".ods": |
---|
28 | $media_icon_type = "spreadsheet"; |
---|
29 | break; |
---|
30 | case ".pptx": |
---|
31 | $media_icon_type = "presentation"; |
---|
32 | break; |
---|
33 | case ".ppt": |
---|
34 | $media_icon_type = "presentation"; |
---|
35 | break; |
---|
36 | case ".odp": |
---|
37 | $media_icon_type = "presentation"; |
---|
38 | break; |
---|
39 | } |
---|
40 | |
---|
41 | if ($media_icon_type != "") { |
---|
42 | preg_match('/<\s*img\s+[^>]*?src\s*=\s*(\'|\")(.*?)\\1[^>]*?\/?\s*>/i',$content,$match); |
---|
43 | |
---|
44 | $content = str_replace($match[0],'<span class="media_icon_'.$media_icon_type.'"></span>'.$match[0].'</a>',$content); |
---|
45 | } |
---|
46 | |
---|
47 | return $content; |
---|
48 | } |
---|
49 | |
---|
50 | function media_icon_picture_css() { |
---|
51 | global $template, $conf; |
---|
52 | |
---|
53 | $conf_media_icon_general = unserialize($conf['media_icon_general']); |
---|
54 | $conf_media_icon_advanced = unserialize($conf['media_icon_advanced']); |
---|
55 | |
---|
56 | $template->set_filename('media_icon_template', dirname(__FILE__).'/template/media_icon_picture.tpl'); |
---|
57 | |
---|
58 | $template->assign( |
---|
59 | 'media_icon_advanced', |
---|
60 | array( |
---|
61 | 'xposition' => $conf_media_icon_advanced['xposition'], |
---|
62 | 'yposition' => $conf_media_icon_advanced['yposition'], |
---|
63 | 'opacity' => $conf_media_icon_advanced['opacity'], |
---|
64 | ) |
---|
65 | ); |
---|
66 | |
---|
67 | $template->concat('PLUGIN_INDEX_CONTENT_END', $template->parse('media_icon_template', true)); |
---|
68 | |
---|
69 | //add a stylesheet |
---|
70 | $template->append('head_elements', '<link rel="stylesheet" type="text/css" href="'.MEDIA_ICON_PATH.'template/media_icon.css">'); |
---|
71 | $template->append('head_elements', '<link rel="stylesheet" type="text/css" href="'.MEDIA_ICON_PATH.'template/'.$conf_media_icon_general['style'].'_media_icon.css">'); |
---|
72 | } |
---|
73 | ?> |
---|