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

Last change on this file since 20372 was 20153, checked in by flop25, 12 years ago

optimal size
switchlanguage style

todo lang file to spread

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