1 | <?php |
---|
2 | /* |
---|
3 | Theme Name: GreyDragon |
---|
4 | Version: 1.2.22 |
---|
5 | Description: GreyDragon Theme |
---|
6 | Theme URI: http://piwigo.org/ext/extension_view.php?eid=775 |
---|
7 | Author: Serge Dosyukov |
---|
8 | Author URI: http://blog.dragonsoft.us |
---|
9 | */ |
---|
10 | |
---|
11 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
12 | |
---|
13 | define('GDTHEME_ID', basename(dirname(__FILE__))); |
---|
14 | if (!defined('GDTHEME_PATH')): |
---|
15 | define('GDTHEME_PATH', PHPWG_THEMES_PATH . GDTHEME_ID . '/'); |
---|
16 | endif; |
---|
17 | require_once( GDTHEME_PATH . 'include/greydragon.class.php'); |
---|
18 | require_once( GDTHEME_PATH . 'admin/upgrade.inc.php'); |
---|
19 | |
---|
20 | $themeCore = greyDragonCore::Instance(GDTHEME_VERSION); |
---|
21 | |
---|
22 | $themeconf = array( |
---|
23 | 'name' => 'greydragon', |
---|
24 | 'parent' => 'default', |
---|
25 | 'colorscheme' => 'whitehawk' == $themeCore->getOption('p_colorpack') ? 'clear' : 'dark' |
---|
26 | ); |
---|
27 | |
---|
28 | add_event_handler('init', 'greydragon_init'); |
---|
29 | |
---|
30 | // Load Theme's Parameters |
---|
31 | function greydragon_init() { |
---|
32 | global $template; |
---|
33 | |
---|
34 | $themeCore = greyDragonCore::Instance(); |
---|
35 | |
---|
36 | if ($themeCore->hasCustomFavicon() || $themeCore->hasOption("p_header") || $themeCore->hasOption('page_banner', TRUE)): |
---|
37 | add_event_handler('render_page_banner', 'greydragon_render_header'); |
---|
38 | endif; |
---|
39 | if ($themeCore->getOption("p_nocounter") == "on"): |
---|
40 | add_event_handler('loc_end_index', 'greydragon_nobreadcrumb_counter'); |
---|
41 | endif; |
---|
42 | if ($themeCore->getOption("p_pict_tab_exif") == "off"): |
---|
43 | pwg_set_session_var('show_metadata', 0); |
---|
44 | else: |
---|
45 | pwg_set_session_var('show_metadata', 1); |
---|
46 | endif; |
---|
47 | |
---|
48 | $template->assign('greydragon', $themeCore->getConfig()); |
---|
49 | |
---|
50 | // Allow dynamic addition of metadata tabs content |
---|
51 | add_event_handler('loc_begin_picture', 'greydragon_picture_handler'); |
---|
52 | |
---|
53 | } |
---|
54 | |
---|
55 | function greydragon_picture_handler() { |
---|
56 | global $template; |
---|
57 | |
---|
58 | $template->set_prefilter('picture', 'greydragon_prepare_meta'); |
---|
59 | } |
---|
60 | |
---|
61 | function greydragon_prepare_meta($tpl_source, &$smarty) { |
---|
62 | // metadata array |
---|
63 | // each tab represented by respected sub array |
---|
64 | // sub array need to include |
---|
65 | // "id" = unique id of the tab |
---|
66 | // "icon_class" = class to be used to render icon tabs |
---|
67 | // "title" = tab or menu block title |
---|
68 | // "content" = block content |
---|
69 | // "target" = optional, rendering target - "left", "top", "right", "bottom", not supported, reserved for future use |
---|
70 | // "combine" = combine_css or combine_js reference block |
---|
71 | // |
---|
72 | // prior to rendering, each element would be processed and converted into tab content in picture.tpl |
---|
73 | |
---|
74 | $metadata = array(); |
---|
75 | $metadata = trigger_change('gd_get_metadata', $metadata); |
---|
76 | |
---|
77 | $meta_icon = ""; |
---|
78 | $meta_text = ""; |
---|
79 | $meta_content = ""; |
---|
80 | |
---|
81 | foreach ($metadata as $item): |
---|
82 | |
---|
83 | $id = $item["id"]; |
---|
84 | $icon_class = $item["icon_class"]; |
---|
85 | $title = $item["title"]; |
---|
86 | $block_content = $item["content"]; |
---|
87 | $combine = $item["combine"]; |
---|
88 | $no_overlay = $item["no_overlay"]; |
---|
89 | |
---|
90 | if ($no_overlay): |
---|
91 | $meta_icon .= '<li class="ico-btn btn-' . $id . '">' . $block_content . '</li>'; |
---|
92 | else: |
---|
93 | $meta_icon .= '<li class="meta-' . $id . '{if $ico_mode=="on"} ' . $icon_class . '{/if}{if $def_tab == "' . $id . '"} active{/if}" >{if $ico_mode=="off"}' . $title . '{/if}</li>'; |
---|
94 | endif; |
---|
95 | |
---|
96 | $meta_text .= '<li class="{if $ico_mode=="on"}' . $icon_class . '{/if}{if $def_tab == "' . $id . '"} active{/if}" rel="tab-' . $id . '">{if $ico_mode=="off"}' . $title . '{/if}</li>'; |
---|
97 | if (isset($combine)): |
---|
98 | $meta_content .= '{strip}' . $combine . '{strip}'; |
---|
99 | endif; |
---|
100 | $meta_content .= '<div id="tab-' . $id . '" class="image-metadata-tab">' . $block_content . '</div>'; |
---|
101 | endforeach; |
---|
102 | |
---|
103 | $content = $tpl_source; |
---|
104 | if ($meta_icon): |
---|
105 | $pattern = '#{\*GD_META_ICO\*}#'; |
---|
106 | $replace = $meta_icon . "{*GD_META_ICO*}"; |
---|
107 | $content = preg_replace($pattern, $replace, $content, 1); |
---|
108 | endif; |
---|
109 | if ($meta_text): |
---|
110 | $pattern = '#{\*GD_META_TXT\*}#'; |
---|
111 | $replace = $meta_text . "{*GD_META_TXT*}"; |
---|
112 | $content = preg_replace($pattern, $replace, $content, 1); |
---|
113 | endif; |
---|
114 | if ($meta_content): |
---|
115 | $pattern = '#{\*GD_META_CONTENT\*}#'; |
---|
116 | $replace = $meta_content . "{*GD_META_CONTENT*}"; |
---|
117 | $content = preg_replace($pattern, $replace, $content, 1); |
---|
118 | endif; |
---|
119 | return $content; |
---|
120 | } |
---|
121 | |
---|
122 | // Render custom header content |
---|
123 | function greydragon_render_header() { |
---|
124 | return greyDragonCore::Instance()->getHeader(); |
---|
125 | } |
---|
126 | |
---|
127 | function greydragon_nobreadcrumb_counter() { |
---|
128 | global $template; |
---|
129 | |
---|
130 | $titre = $template->get_template_vars('TITLE'); |
---|
131 | $pos = strrpos($titre,"["); |
---|
132 | if ($pos !== false): |
---|
133 | $template->assign('TITLE', substr($titre, 0, $pos)); |
---|
134 | endif; |
---|
135 | } |
---|
136 | |
---|
137 | ?> |
---|