source: extensions/hr_glass_xl/themeconf.inc.php @ 31975

Revision 30085, 4.2 KB checked in by flop25, 5 years ago (diff)

2.7 compat: colorscheme and 2.7 only OS_default

Line 
1<?php
2/*
3Theme Name: hr_glass_xl
4Version: auto
5Description: A theme with an horizontal menu and a simple modern design
6Theme URI: http://fr.piwigo.org/ext/extension_view.php?eid=502
7Author: flop25
8Author URI: http://www.planete-flop.fr
9*/
10$themeconf = array(
11  'name'          => 'hr_glass_xl',
12  'parent'        => 'default',
13  'icon_dir'      => 'themes/hr_glass_xl/icon',
14  'mime_icon_dir' => 'themes/hr_glass_xl/icon/mimetypes/',
15  'local_head'    => 'local_head.tpl',
16  'activable'     => true,
17  'colorscheme' => 'clear',
18);
19//// [update check]
20if (!isset($conf['hr_glass_xl']))
21{
22  $config = array(
23    'home'       => true,
24    'categories' => true,
25    'picture'    => false,
26    'other'      => true,
27    );
28   
29  $query = '
30INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
31VALUES ("hr_glass_xl" , "'.pwg_db_real_escape_string(serialize($config)).'" , "hr_glass_xl parameters");';
32
33  pwg_query($query);
34  load_conf_from_db();
35}
36if (isset($conf['derivatives']))  {   
37  $new = @unserialize($conf['derivatives']);
38  if(!isset($new['d']['Optimal']))
39  {
40    $new['d']['Optimal']=ImageStdParams::get_custom(900,9999); 
41    $query = '
42        UPDATE '.CONFIG_TABLE.'
43        SET value="'.addslashes(serialize($new)).'"
44        WHERE param = "derivatives"
45        LIMIT 1';
46    pwg_query($query);
47    load_conf_from_db();
48  }
49}//// [/update check]
50
51
52
53// thx to P@t
54add_event_handler('loc_begin_page_header', 'set_hr_glass_xl_header');
55
56function set_hr_glass_xl_header()
57{
58  global $page, $conf, $template;
59
60  $config = unserialize($conf['hr_glass_xl']);
61
62  if (isset($page['body_id']) and $page['body_id'] == 'theCategoryPage')
63  {
64    $header = isset($page['category']) ? $config['categories'] : $config['home'];
65  }
66  elseif (isset($page['body_id']) and $page['body_id'] == 'thePicturePage')
67  {
68    $header = $config['picture'];
69  }
70  else
71  {
72    $header = $config['other'];
73  }
74
75  $template->assign('display_hr_glass_xl_banner', $header);
76}
77
78// function load_pattern
79// include the right ***.pattern.php
80// not compatible 2.2and<2.2
81
82function load_pattern()
83{
84  global $pattern;
85  $pwgversion=str_replace('.','',PHPWG_VERSION);
86  $pwgversion_array=explode('.', PHPWG_VERSION);
87  if (file_exists($pwgversion.'pattern.php'))
88  {
89    include($pwgversion.'.pattern.php');
90    return true;
91  }
92  elseif (file_exists(PHPWG_ROOT_PATH.'themes/hr_glass_xl/'.$pwgversion_array[0].$pwgversion_array[1].'x.pattern.php'))
93  {
94    include(PHPWG_ROOT_PATH.'themes/hr_glass_xl/'.$pwgversion_array[0].$pwgversion_array[1].'x.pattern.php');
95    return true;
96  }
97  else
98  {
99    $list_pattern_path=array();
100    $dir=PHPWG_ROOT_PATH.'themes/hr_glass_xl';
101    $dh = opendir($dir);
102    while (($file = readdir ($dh)) !== false ) {
103      if ($file !== '.' && $file !== '..') {
104        $path =$dir.'/'.$file;
105        if (!is_dir ($path)) { 
106          if(strpos($file,'pattern.php')!==false) { //On ne prend que les .pattern.php
107            $list_pattern_path[]=$file;
108          }
109        }
110      }
111    }
112    closedir($dh);
113    $f=0;
114    for($i = 10; $i >=0; $i--)
115    {
116      if (in_array($pwgversion_array[0].$i.'.pattern.php',$list_pattern_path))
117      {
118        include($pwgversion_array[0].$i.'.pattern.php');
119        return true;
120        $f=1;
121        break;
122      }
123    }
124    if ($f=0)
125    {
126      return false;
127    }
128  }
129 
130}
131if(!load_pattern())
132{
133  global $page;
134  $page['errors'][]='Theme not compatible';
135}
136
137/************************************ picture.tpl ************************************/
138//add_event_handler('render_element_content', 'hr_glass_xl_picture',  EVENT_HANDLER_PRIORITY_NEUTRAL, 20 );
139function hr_glass_xl_picture($content, $element_info)
140{
141  global $template;
142  $template->set_prefilter('default_content', 'hr_glass_xl_prefilter_picture');
143  return $content;
144}
145function hr_glass_xl_prefilter_picture($content, &$smarty)
146{
147  global $pattern;
148  $r=$pattern['hr_glass_xl_prefilter_picture']['R'];
149  $ps=$pattern['hr_glass_xl_prefilter_picture']['S'];
150  foreach($r as $i => $pr)
151  {
152    $content = str_replace($ps[$i], $pr, $content);
153  }
154 
155  $content ='{define_derivative name=\'der_hr_glass_xl\' width=730 height=9999 crop=false}
156{assign var=der value=$pwg->derivative($der_hr_glass_xl, $current.src_image)}
157'.$content;
158  return $content;
159}
160
161
162?>
Note: See TracBrowser for help on using the repository browser.