source: extensions/greydragon/themeconf.inc.php @ 31987

Revision 31987, 5.5 KB checked in by SergeD, 8 months ago (diff)

version 1.3.2 - see changelog for details

Line 
1<?php
2/*
3Theme Name: GreyDragon
4Version: 1.3.2
5Description: GreyDragon Theme
6Theme URI: http://piwigo.org/ext/extension_view.php?eid=775
7Author: Serge Dosyukov
8Author URI: http://blog.dragonsoft.us
9*/
10
11if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
12
13define('GDTHEME_ID',   basename(dirname(__FILE__)));
14if (!defined('GDTHEME_PATH')):
15  define('GDTHEME_PATH', PHPWG_THEMES_PATH . GDTHEME_ID . '/');
16endif;
17require_once( GDTHEME_PATH . 'include/greydragon.class.php');
18require_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
28add_event_handler('init', 'greydragon_init');
29
30if (defined('IN_ADMIN')) {
31  add_event_handler('loc_after_page_header', 'greydragon_add_admin_controller');
32}
33
34// Load Theme's Parameters
35function greydragon_init() {
36  global $template;
37
38  $themeCore = greyDragonCore::Instance();
39
40  if ($themeCore->hasCustomFavicon() || $themeCore->hasOption("p_header") || $themeCore->hasOption('page_banner', TRUE)):
41    add_event_handler('render_page_banner', 'greydragon_render_header');
42  endif;
43  if ($themeCore->getOption("p_nocounter") == "on"):
44    add_event_handler('loc_end_index', 'greydragon_nobreadcrumb_counter');
45  endif;
46  if ($themeCore->getOption("p_pict_tab_exif") == "off"):
47    pwg_set_session_var('show_metadata', 0);
48  else:
49    pwg_set_session_var('show_metadata', 1);
50  endif;
51
52  $template->assign('greydragon', $themeCore->getConfig());
53
54  $template->smarty->registerPlugin("modifier", "get_x_half", "greydragon_array_getXhalf");
55  $template->smarty->registerPlugin("modifier", "get_y_half", "greydragon_array_getYhalf");
56
57  // Allow dynamic addition of metadata tabs content
58  add_event_handler('loc_begin_picture', 'greydragon_picture_handler');
59}
60
61function greydragon_add_admin_controller() {
62  global $template, $page, $user;
63
64  $template->assign(array(                                               
65    'GDTHEME_PATH' => GDTHEME_PATH
66  ));
67
68  $template->set_filename('gdtheme_admin_controller', realpath(GDTHEME_PATH . 'admin/admin_controller.tpl'));
69  $template->parse('gdtheme_admin_controller');
70}
71
72function greydragon_array_getXhalf($array) {
73  if (isset($array) && (count($array) > 0)):
74    return (int)($array[0] / 2);
75  else:
76    return "";
77  endif;
78}
79
80function greydragon_array_getYhalf($array) {
81  if (isset($array) && (count($array) > 1)):
82    return (int)($array[1] / 2);
83  else:
84    return 1000;
85  endif;
86}
87
88function greydragon_picture_handler() {
89  global $template;
90
91  $template->set_prefilter('picture', 'greydragon_prepare_meta');
92}
93
94function greydragon_prepare_meta($tpl_source, &$smarty) {
95
96  $metadata = greyDragonCore::Instance()->getPageTabs();
97
98  $content  = $tpl_source;
99  if ($metadata["icon"]):
100    $pattern  = '#{\*GD_META_ICO\*}#';
101    $replace  = $metadata["icon"] . "{*GD_META_ICO*}";
102    $content  = preg_replace($pattern, $replace, $content, 1);
103  endif;
104  if ($metadata["text"]):
105    $pattern  = '#{\*GD_META_TXT\*}#';
106    $replace  = $metadata["text"] . "{*GD_META_TXT*}";
107    $content  = preg_replace($pattern, $replace, $content, 1);
108  endif;
109  if ($metadata["content"]):
110    $pattern  = '#{\*GD_META_CONTENT\*}#';
111    $replace  = $metadata["content"] . "{*GD_META_CONTENT*}";
112    $content  = preg_replace($pattern, $replace, $content, 1);
113  endif;
114
115  $pattern  = '#<div.*"theImageAndInfos".*>#';
116  $replace  = '$0
117    {if isset($previous.U_IMG)}<a class="gd-nav nav-prev" title="{\'Previous\'|@translate}" href="{$previous.U_IMG}"><i class="fas fa-angle-left"></i></a>{/if}
118    {if isset($next.U_IMG)    }<a class="gd-nav nav-next" title="{\'Next\'|@translate}" href="{$next.U_IMG}"><i class="fas fa-angle-right"></i></a>{/if}
119    {if isset($U_UP)          }<a class="gd-nav nav-up"   title="{\'Up\'|@translate}" href="{$U_UP}"><i class="fas fa-angle-up"></i></a>{/if}
120{*    <a class="gd-nav nav-zoom" title="{\'Full HD\'|@translate}" href="{$U_UP}">&nbsp;</a> *}
121  {html_head}
122    <style type="text/css">{strip}
123      {if $current.selected_derivative}
124      #theImageAndInfos .gd-nav.nav-prev {ldelim} margin-left: {if $DISPLAY_NAV_THUMB}calc(-142px - {else}-{/if}{$current.selected_derivative->get_size()|get_x_half}px{if $DISPLAY_NAV_THUMB}){/if} !important; top: {$current.selected_derivative->get_size()|get_y_half}px; {rdelim}
125      #theImageAndInfos .gd-nav.nav-next {ldelim} margin-right: {if $DISPLAY_NAV_THUMB}calc(146px - {else}-{/if}{$current.selected_derivative->get_size()|get_x_half}px{if $DISPLAY_NAV_THUMB}){/if} !important; top: {$current.selected_derivative->get_size()|get_y_half}px; {rdelim}
126      {if $DISPLAY_NAV_THUMB}#theImageAndInfos .gd-nav.nav-up {ldelim} margin-left: -182px; {rdelim}{/if}
127      {else}
128      #theImageAndInfos .gd-nav.nav-prev {ldelim} margin-left: -32% !important; top: 40%; {rdelim}
129      #theImageAndInfos .gd-nav.nav-next {ldelim} margin-right: -32% !important; top: 40%; {rdelim}
130      {/if}
131{*      #theImageAndInfos .gd-nav.nav-zoom {ldelim} top: {$current.selected_derivative->get_size()|get_y_half}px; {rdelim} *}
132    {/strip}</style>
133  {/html_head}';
134
135  $content  = preg_replace($pattern, $replace, $content, 1);
136
137  return $content;
138}
139
140// Render custom header content
141function greydragon_render_header() {
142  return greyDragonCore::Instance()->getHeader();
143}
144
145function greydragon_nobreadcrumb_counter() {
146  global $template;
147
148  $titre = $template->get_template_vars('TITLE');
149  $pos = strrpos($titre,"[");
150  if ($pos !== false):
151    $template->assign('TITLE', substr($titre, 0, $pos));
152  endif;
153}
Note: See TracBrowser for help on using the repository browser.