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

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

2.7 compat: colorscheme and 2.7 only OS_default

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  'colorscheme' => 'clear',
18);
19//// [update check]
20if (!isset($conf['hr_os']))
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" , "'.pwg_db_real_escape_string(serialize($config)).'" , "hr_os 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(730,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
53// thx to P@t
54add_event_handler('loc_begin_page_header', 'set_hr_os_header');
55
56function set_hr_os_header()
57{
58  global $page, $conf, $template;
59
60  $config = unserialize($conf['hr_os']);
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_os_banner', $header);
76}
77// function load_pattern
78// include the right ***.pattern.php
79// not compatible 2.2and<2.2
80
81function load_pattern()
82{
83  global $pattern;
84  $pwgversion=str_replace('.','',PHPWG_VERSION);
85  $pwgversion_array=explode('.', PHPWG_VERSION);
86  if (file_exists($pwgversion.'pattern.php'))
87  {
88    include($pwgversion.'.pattern.php');
89    return true;
90  }
91  elseif (file_exists(PHPWG_ROOT_PATH.'themes/hr_os/'.$pwgversion_array[0].$pwgversion_array[1].'x.pattern.php'))
92  {
93    include(PHPWG_ROOT_PATH.'themes/hr_os/'.$pwgversion_array[0].$pwgversion_array[1].'x.pattern.php');
94    return true;
95  }
96  else
97  {
98    $list_pattern_path=array();
99    $dir=PHPWG_ROOT_PATH.'themes/hr_os';
100    $dh = opendir($dir);
101    while (($file = readdir ($dh)) !== false ) {
102      if ($file !== '.' && $file !== '..') {
103        $path =$dir.'/'.$file;
104        if (!is_dir ($path)) { 
105          if(strpos($file,'pattern.php')!==false) { //On ne prend que les .pattern.php
106            $list_pattern_path[]=$file;
107          }
108        }
109      }
110    }
111    closedir($dh);
112    $f=0;
113    for($i = 10; $i >=0; $i--)
114    {
115      if (in_array($pwgversion_array[0].$i.'.pattern.php',$list_pattern_path))
116      {
117        include($pwgversion_array[0].$i.'.pattern.php');
118        return true;
119        $f=1;
120        break;
121      }
122    }
123    if ($f=0)
124    {
125      return false;
126    }
127  }
128 
129}
130if(!load_pattern())
131{
132  global $page;
133  $page['errors'][]='Theme not compatible';
134}
135
136/************************************ picture.tpl ************************************/
137//add_event_handler('render_element_content', 'hr_os_picture',  EVENT_HANDLER_PRIORITY_NEUTRAL, 20 );
138function hr_os_picture($content, $element_info)
139{
140  global $template;
141  $template->set_prefilter('default_content', 'hr_os_prefilter_picture');
142  return $content;
143}
144function hr_os_prefilter_picture($content, &$smarty)
145{
146  global $pattern;
147  $r=$pattern['hr_os_prefilter_picture']['R'];
148  $ps=$pattern['hr_os_prefilter_picture']['S'];
149  foreach($r as $i => $pr)
150  {
151    $content = str_replace($ps[$i], $pr, $content);
152  }
153 
154  $content ='{define_derivative name=\'der_hr_os\' width=730 height=9999 crop=false}
155{assign var=der value=$pwg->derivative($der_hr_os, $current.src_image)}
156'.$content;
157  return $content;
158}
159
160
161?>
Note: See TracBrowser for help on using the repository browser.