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

Last change on this file since 17932 was 16380, checked in by flop25, 12 years ago

drop down menu styled and successfully placed (relative positions changed)
custom size for the picture page :
pattern added
concatenation of the 'define derivative'
css to center the picture

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