source: extensions/floOS/OS_default/themeconf.inc.php @ 14974

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

PHPWG_VERSION assigned and correction of the use of strpos in tpl

File size: 4.5 KB
RevLine 
[9237]1<?php
2/*
3Theme Name: OS_default
[10053]4Version: auto
[9237]5Description:
6Theme URI: http://piwigo.org/ext/extension_view.php?eid=497
7Author: flop25
8Author URI: http://www.planete-flop.fr
9*/
10$themeconf = array(
11  'name'         => 'OS_default',
12  'parent'        => 'default',
13  'icon_dir'      => 'themes/OS_default/icon',
14  'mime_icon_dir' => 'themes/OS_default/icon/mimetypes/',
15  'local_head'    => 'local_head.tpl',
16  'activable' => false,
17        'add_menu_on_public_pages'                      => true,        # activation
18        'Exclude'                       => array('theNBMPage','thePicturePage','thePopuphelpPage',),    # Excluded pages
19);
[14974]20
21
22
23add_event_handler('loc_begin_picture', 'pwg_v');
24function  pwg_v() {
25  global $template;
26  $template->assign(
27  array(
28    'PHPWG_VERSION' => PHPWG_VERSION,
29  ));
30}
[10450]31/*********************************menu on every pages ************************************/
[9237]32// thx to Vdigital and his plugin spreadmenus
33if ( !function_exists( 'add_menu_on_public_pages' ) ) {
34        if ( defined('IN_ADMIN') and IN_ADMIN ) return false;
35        add_event_handler('loc_after_page_header', 'add_menu_on_public_pages', 20);
36
37        function  add_menu_on_public_pages() {
38          if ( function_exists( 'initialize_menu') ) return false; # The current page has already the menu
39          if ( !get_themeconf('add_menu_on_public_pages') ) return false; # The current page has already the menu
40          global $template, $page, $conf;
41          if ( isset($page['body_id']) and in_array($page['body_id'], get_themeconf('Exclude')) ) return false;
42
43          $template->set_filenames(array(
44                'add_menu_on_public_pages' => dirname(__FILE__) . '/template/add_menu_on_public_pages.tpl',
45          ));
46          include_once(PHPWG_ROOT_PATH.'include/menubar.inc.php');
47          $template->parse('add_menu_on_public_pages');
48         
49          if (is_admin())
50                {
51          $template->assign(
52        'U_ADMIN', get_root_url().'admin.php?page=picture_modify'
53      .'&amp;cat_id='.(isset($page['category']) ? $page['category']['id'] : '')
54      .( isset($page['image_id']) ? '&amp;image_id='.$page['image_id'] : '')
55      );
56                }
57         
58        }
59}
[14390]60
61
62// function load_pattern
63// include the right ***.pattern.php
64// not compatible 2.2and<2.2
65
66function load_pattern()
67{
68  global $pattern;
69  $pwgversion=str_replace('.','',PHPWG_VERSION);
70  $pwgversion_array=explode('.', PHPWG_VERSION);
71  if (file_exists($pwgversion.'pattern.php'))
72  {
73    include($pwgversion.'.pattern.php');
74    return true;
75  }
76  elseif (file_exists(PHPWG_ROOT_PATH.'themes/OS_default/'.$pwgversion_array[0].$pwgversion_array[1].'x.pattern.php'))
77  {
78    include(PHPWG_ROOT_PATH.'themes/OS_default/'.$pwgversion_array[0].$pwgversion_array[1].'x.pattern.php');
79    return true;
80  }
81  else
82  {
83    $list_pattern_path=array();
84    $dir=PHPWG_ROOT_PATH.'themes/OS_default';
85    $dh = opendir($dir);
86    while (($file = readdir ($dh)) !== false ) {
87      if ($file !== '.' && $file !== '..') {
88        $path =$dir.'/'.$file;
89        if (!is_dir ($path)) { 
90          if(strpos($file,'pattern.php')!==false) { //On ne prend que les .pattern.php
91            $list_pattern_path[]=$file;
92          }
93        }
94      }
95    }
96    closedir($dh);
97    $f=0;
98    for($i = 10; $i >=0; $i--)
99    {
100      if (in_array($pwgversion_array[0].$i.'.pattern.php',$list_pattern_path))
101      {
102        include($pwgversion_array[0].$i.'.pattern.php');
103        return true;
104        $f=1;
105        break;
106      }
107    }
108    if ($f=0)
109    {
110      return false;
111    }
112  }
113 
114}
115if(!load_pattern())
116{
117  global $page;
118  $page['errors'][]='Theme not compatible';
119}
120
121
[10450]122/************************************ index.tpl ************************************/
123add_event_handler('loc_end_index', 'OS_default_index');
124function OS_default_index()
125{
[14652]126  global $template;
127  $template->set_prefilter('index', 'OS_default_prefilter_index');
[10450]128}
129function OS_default_prefilter_index($content, &$smarty)
130{
[14390]131  global $pattern;
132  $r=$pattern['OS_default_prefilter_index']['R'];
133  $ps=$pattern['OS_default_prefilter_index']['S'];
134  foreach($r as $i => $pr)
135  {
136    $content = str_replace($ps[$i], $pr, $content);
137  }
138  return $content;
[10450]139}
[11929]140
141/************************************ picture.tpl ************************************/
142add_event_handler('loc_begin_picture', 'OS_default_picture');
143function OS_default_picture()
144{
[14652]145  global $template;
146  $template->set_prefilter('picture', 'OS_default_prefilter_picture');
[11929]147}
148function OS_default_prefilter_picture($content, &$smarty)
149{
[14390]150  global $pattern;
151  $r=$pattern['OS_default_prefilter_picture']['R'];
152  $ps=$pattern['OS_default_prefilter_picture']['S'];
153  foreach($r as $i => $pr)
154  {
155    $content = preg_replace($ps[$i], $pr, $content);
156  }
157  return $content;
[11929]158}
159
[9237]160?>
Note: See TracBrowser for help on using the repository browser.