source: extensions/hr_os/themeconf.inc.php @ 28566

Last change on this file since 28566 was 20153, checked in by flop25, 11 years ago

optimal size
switchlanguage style

todo lang file to spread

File size: 4.0 KB
Line 
1<?php
2/*
3Theme Name: hr_os
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=503
7Author: flop25
8Author URI: http://www.planete-flop.fr
9*/
10$themeconf = array(
11  'name'          => 'hr_os',
12  'parent'        => 'default',
13  'icon_dir'      => 'themes/hr_os/icon',
14  'mime_icon_dir' => 'themes/hr_os/icon/mimetypes/',
15  'local_head'    => 'local_head.tpl',
16  'activable'     => true,
17);
18//// [update check]
19if (!isset($conf['hr_os']))
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" , "'.pwg_db_real_escape_string(serialize($config)).'" , "hr_os 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(730,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
52// thx to P@t
53add_event_handler('loc_begin_page_header', 'set_hr_os_header');
54
55function set_hr_os_header()
56{
57  global $page, $conf, $template;
58
59  $config = unserialize($conf['hr_os']);
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_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/'.$pwgversion_array[0].$pwgversion_array[1].'x.pattern.php'))
91  {
92    include(PHPWG_ROOT_PATH.'themes/hr_os/'.$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';
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_picture',  EVENT_HANDLER_PRIORITY_NEUTRAL, 20 );
137function hr_os_picture($content, $element_info)
138{
139  global $template;
140  $template->set_prefilter('default_content', 'hr_os_prefilter_picture');
141  return $content;
142}
143function hr_os_prefilter_picture($content, &$smarty)
144{
145  global $pattern;
146  $r=$pattern['hr_os_prefilter_picture']['R'];
147  $ps=$pattern['hr_os_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\' width=730 height=9999 crop=false}
154{assign var=der value=$pwg->derivative($der_hr_os, $current.src_image)}
155'.$content;
156  return $content;
157}
158
159
160?>
Note: See TracBrowser for help on using the repository browser.