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

Revision 31175, 5.0 KB checked in by SergeD, 5 years ago (diff)

version 1.2.25 - see changelog for details

Line 
1<?php
2/*
3Theme Name: GreyDragon
4Version: 1.2.25
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
30// Load Theme's Parameters
31function 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  $template->smarty->registerPlugin("modifier", "get_x_half", "greydragon_array_getXhalf");
51  $template->smarty->registerPlugin("modifier", "get_y_half", "greydragon_array_getYhalf");
52
53  // Allow dynamic addition of metadata tabs content
54  add_event_handler('loc_begin_picture', 'greydragon_picture_handler');
55}
56
57function greydragon_array_getXhalf($array) {
58  if (isset($array) && (count($array) > 0)):
59    return (int)($array[0] / 2);
60  else:
61    return "";
62  endif;
63}
64
65function greydragon_array_getYhalf($array) {
66  if (isset($array) && (count($array) > 1)):
67    return (int)($array[1] / 2);
68  else:
69    return 1000;
70  endif;
71}
72
73
74function greydragon_picture_handler() {
75  global $template;
76
77  $template->set_prefilter('picture', 'greydragon_prepare_meta');
78}
79
80function greydragon_prepare_meta($tpl_source, &$smarty) {
81
82  $metadata = greyDragonCore::Instance()->getPageTabs();
83
84  $content  = $tpl_source;
85  if ($metadata["icon"]):
86    $pattern  = '#{\*GD_META_ICO\*}#';
87    $replace  = $metadata["icon"] . "{*GD_META_ICO*}";
88    $content  = preg_replace($pattern, $replace, $content, 1);
89  endif;
90  if ($metadata["text"]):
91    $pattern  = '#{\*GD_META_TXT\*}#';
92    $replace  = $metadata["text"] . "{*GD_META_TXT*}";
93    $content  = preg_replace($pattern, $replace, $content, 1);
94  endif;
95  if ($metadata["content"]):
96    $pattern  = '#{\*GD_META_CONTENT\*}#';
97    $replace  = $metadata["content"] . "{*GD_META_CONTENT*}";
98    $content  = preg_replace($pattern, $replace, $content, 1);
99  endif;
100
101  $pattern  = '#<div.*"theImageAndInfos".*>#';
102  $replace  = '$0
103    {if isset($previous.U_IMG)}<a class="gd-nav nav-prev" title="{\'Previous\'|translate}" href="{$previous.U_IMG}">&nbsp;</a>{/if}
104    {if isset($next.U_IMG)    }<a class="gd-nav nav-next" title="{\'Next\'|translate}" href="{$next.U_IMG}">&nbsp;</a>{/if}
105    {if isset($U_UP)          }<a class="gd-nav nav-up"   title="{\'Up\'|translate}" href="{$U_UP}">&nbsp;</a>{/if}
106{*    <a class="gd-nav nav-zoom" title="{\'Full HD\'|translate}" href="{$U_UP}">&nbsp;</a> *}
107  {html_head}
108    <style type="text/css">{strip}
109      {if $current.selected_derivative}
110      #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}
111      #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}
112      {if $DISPLAY_NAV_THUMB}#theImageAndInfos .gd-nav.nav-up {ldelim} margin-left: -182px; {rdelim}{/if}
113      {else}
114      #theImageAndInfos .gd-nav.nav-prev {ldelim} margin-left: -32% !important; top: 40%; {rdelim}
115      #theImageAndInfos .gd-nav.nav-next {ldelim} margin-right: -32% !important; top: 40%; {rdelim}
116      {/if}
117{*      #theImageAndInfos .gd-nav.nav-zoom {ldelim} top: {$current.selected_derivative->get_size()|get_y_half}px; {rdelim} *}
118    {/strip}</style>
119  {/html_head}';
120
121  $content  = preg_replace($pattern, $replace, $content, 1);
122
123  return $content;
124}
125
126// Render custom header content
127function greydragon_render_header() {
128  return greyDragonCore::Instance()->getHeader();
129}
130
131function greydragon_nobreadcrumb_counter() {
132  global $template;
133
134  $titre = $template->get_template_vars('TITLE');
135  $pos = strrpos($titre,"[");
136  if ($pos !== false):
137    $template->assign('TITLE', substr($titre, 0, $pos));
138  endif;
139}
140
141?>
Note: See TracBrowser for help on using the repository browser.