source: extensions/hr_os_xl/themeconf.inc.php @ 30085

Last change on this file since 30085 was 30085, checked in by flop25, 10 years ago

2.7 compat: colorscheme and 2.7 only OS_default

File size: 4.1 KB
Line 
1<?php
2/*
3Theme Name: hr_os_xl
4Version: auto
5Description: A theme with an horizontal menu everywhere and a simple modern design
6Theme URI: http://fr.piwigo.org/ext/extension_view.php?eid=504
7Author: flop25
8Author URI: http://www.planete-flop.fr
9*/
10$themeconf = array(
11  'name'          => 'hr_os_xl',
12  'parent'        => 'default',
13  'icon_dir'      => 'themes/hr_os_xl/icon',
14  'mime_icon_dir' => 'themes/hr_os_xl/icon/mimetypes/',
15  'local_head'    => 'local_head.tpl',
16  'activable'     => true,
17  'colorscheme' => 'clear',
18);
19//// [update check]
20if (!isset($conf['hr_os_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_os_xl" , "'.pwg_db_real_escape_string(serialize($config)).'" , "hr_os_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}
50//// [/update check]
51
52// thx to P@t
53add_event_handler('loc_begin_page_header', 'set_hr_os_xl_header');
54
55function set_hr_os_xl_header()
56{
57  global $page, $conf, $template;
58
59  $config = unserialize($conf['hr_os_xl']);
60
61  if (isset($page['body_id']) and $page['body_id'] == 'theCategoryPage')
62  {
63    $header = isset($page['category']) ? $config['categories'] : $config['home'];
64  }
65  elseif (isset($page['body_id']) and $page['body_id'] == 'thePicturePage')
66  {
67    $header = $config['picture'];
68  }
69  else
70  {
71    $header = $config['other'];
72  }
73
74  $template->assign('display_hr_os_xl_banner', $header);
75}
76// function load_pattern
77// include the right ***.pattern.php
78// not compatible 2.2and<2.2
79
80function load_pattern()
81{
82  global $pattern;
83  $pwgversion=str_replace('.','',PHPWG_VERSION);
84  $pwgversion_array=explode('.', PHPWG_VERSION);
85  if (file_exists($pwgversion.'pattern.php'))
86  {
87    include($pwgversion.'.pattern.php');
88    return true;
89  }
90  elseif (file_exists(PHPWG_ROOT_PATH.'themes/hr_os_xl/'.$pwgversion_array[0].$pwgversion_array[1].'x.pattern.php'))
91  {
92    include(PHPWG_ROOT_PATH.'themes/hr_os_xl/'.$pwgversion_array[0].$pwgversion_array[1].'x.pattern.php');
93    return true;
94  }
95  else
96  {
97    $list_pattern_path=array();
98    $dir=PHPWG_ROOT_PATH.'themes/hr_os_xl';
99    $dh = opendir($dir);
100    while (($file = readdir ($dh)) !== false ) {
101      if ($file !== '.' && $file !== '..') {
102        $path =$dir.'/'.$file;
103        if (!is_dir ($path)) { 
104          if(strpos($file,'pattern.php')!==false) { //On ne prend que les .pattern.php
105            $list_pattern_path[]=$file;
106          }
107        }
108      }
109    }
110    closedir($dh);
111    $f=0;
112    for($i = 10; $i >=0; $i--)
113    {
114      if (in_array($pwgversion_array[0].$i.'.pattern.php',$list_pattern_path))
115      {
116        include($pwgversion_array[0].$i.'.pattern.php');
117        return true;
118        $f=1;
119        break;
120      }
121    }
122    if ($f=0)
123    {
124      return false;
125    }
126  }
127 
128}
129if(!load_pattern())
130{
131  global $page;
132  $page['errors'][]='Theme not compatible';
133}
134
135/************************************ picture.tpl ************************************/
136//add_event_handler('render_element_content', 'hr_os_xl_picture',  EVENT_HANDLER_PRIORITY_NEUTRAL, 20 );
137function hr_os_xl_picture($content, $element_info)
138{
139  global $template;
140  $template->set_prefilter('default_content', 'hr_os_xl_prefilter_picture');
141  return $content;
142}
143function hr_os_xl_prefilter_picture($content, &$smarty)
144{
145  global $pattern;
146  $r=$pattern['hr_os_xl_prefilter_picture']['R'];
147  $ps=$pattern['hr_os_xl_prefilter_picture']['S'];
148  foreach($r as $i => $pr)
149  {
150    $content = str_replace($ps[$i], $pr, $content);
151  }
152 
153  $content ='{define_derivative name=\'der_hr_os_xl\' width=900 height=9999 crop=false}
154{assign var=der value=$pwg->derivative($der_hr_os_xl, $current.src_image)}
155'.$content;
156  return $content;
157}
158
159
160?>
Note: See TracBrowser for help on using the repository browser.