source: extensions/stripped_black_bloc/themeconf.inc.php @ 31146

Last change on this file since 31146 was 30456, checked in by plg, 10 years ago

avoid calling load_conf_from_db() which may break some plugin config

File size: 4.4 KB
Line 
1<?php
2/*
3Theme Name: Stripped & Columns
4Version: auto
5Description: stripped_black_bloc
6Theme URI: http://piwigo.org/ext/extension_view.php?eid=568
7Author: flop25
8Author URI: http://www.planete-flop.fr
9*/
10
11
12 
13$themeconf = array(
14  'parent' => 'stripped',
15  'name' => 'stripped_black_bloc',
16  'theme_dir' => 'stripped_black_bloc',
17  'icon_dir' => 'themes/stripped/icon',
18  'img_dir' => 'themes/stripped_black_bloc/img',
19  'admin_icon_dir' => 'themes/default/icon/admin',
20  'mime_icon_dir' => 'themes/default/icon/mimetypes/',
21  'local_head' => 'local_head.tpl',
22  'load_parent_local_head' => true,
23);
24global $stripped;
25$stripped['themeStyle']='original';
26
27load_language('theme.lang', PHPWG_THEMES_PATH.'stripped_black_bloc/');
28
29// Need upgrade?
30
31include(PHPWG_THEMES_PATH.'stripped_black_bloc/admin/upgrade.inc.php');
32
33add_event_handler('init', 'set_config_values_stripped_black_bloc');
34
35function set_config_values_stripped_black_bloc()
36{
37  global $conf, $template;
38  $config = safe_unserialize( $conf['stripped_black_bloc'] );
39  $template->assign( 'stripped_black_bloc', $config );
40}
41
42/// EVENT
43
44/************************************ thumbnails and category_thumbnails ************************************/
45add_event_handler('loc_end_index_category_thumbnails', 'stripped_black_bloc');
46add_event_handler('loc_end_index_thumbnails', 'stripped_black_bloc');
47function stripped_black_bloc($tpl_thumbnails_var)
48{
49  global $template, $conf;
50  if (defined('RVTS_VERSION'))
51  {
52    $template->func_combine_script( array(
53        'id'=> 'sc_tscroller',
54        'load'=> 'async',
55        'path'=> PHPWG_THEMES_PATH.'stripped_black_bloc/js/tscroller.min.js',
56        'require' => 'jquery',
57      ), $template->smarty);
58  }
59 
60  $config = safe_unserialize( $conf['stripped_black_bloc'] );
61  $template->assign( 'stripped_black_bloc', $config );
62  $new_tplvar=array();
63  $i=1;
64  foreach ($tpl_thumbnails_var as $tplvar)
65  {
66    $tplvar['TN_CLASS']=($i==$config['starting_to']) ? "twocol" : "onecol";
67    $new_tplvar[]=$tplvar;
68    $i= ($i==$config['every_x']) ? 1 : $i+1 ;
69  }
70  return $new_tplvar;
71}
72add_event_handler('init', 'stripped_black_bloc_init');
73function stripped_black_bloc_init()
74{
75  remove_event_handler('loc_begin_index', 'modify_nb_thumbnail_page');
76}
77
78/************************************ index.tpl ************************************/
79add_event_handler('loc_end_index', 'stripped_black_bloc_index');
80function stripped_black_bloc_index()
81{
82    global $template;
83    $template->set_prefilter('index', 'stripped_black_bloc_prefilter_index');
84}
85function stripped_black_bloc_prefilter_index($content, &$smarty)
86{
87  global $page;
88  $search = "#\{\'Menu\'\|@translate\}#"; 
89  $replacement = "{'Show/hide menu'|@translate}</span>";
90  $content = preg_replace($search, $replacement, $content);
91  $search = '#<div id="subcontent">#'; 
92  $replacement = "";
93  $content = preg_replace($search, $replacement, $content);
94  $search = '#\{if \!empty\(\$CONTENT_DESCRIPTION\) \}#'; 
95  $replacement = ' <div id="subcontent">
96
97  {if !empty($CONTENT_DESCRIPTION) }';
98  $content = preg_replace($search, $replacement, $content);
99  $search = '#\{if \!empty\(\$thumb_navbar\) \}[\s]*\{include file=\'navigation_bar\.tpl\'\|@get_extent:\'navbar\' navbar=\$thumb_navbar\}[\s]*\{/if\}#'; 
100  $replacement = '';
101  $content = preg_replace($search, $replacement, $content);
102
103  $search = '#\{\$PLUGIN_INDEX_CONTENT_AFTER\}</div>\{/if\}.*</div>#s'; 
104
105  $replacement = '{$PLUGIN_INDEX_CONTENT_AFTER}</div>{/if}
106    </div>
107  {if !empty($thumb_navbar) }
108  <div id="thumb_navbar">
109  {include file=\'navigation_bar.tpl\'|@get_extent:\'navbar\' navbar=$thumb_navbar}
110  </div>
111  {/if}';
112
113  $content = preg_replace($search, $replacement, $content);
114  if ( isset($page['chronology_view']))
115  {
116    $search = '#\{if isset\(\$chronology\.TITLE\)#s';
117    $replacement = '<div class="bloc_stuff">
118{if isset($chronology.TITLE)';
119    $content = preg_replace($search, $replacement, $content);
120    $search = '#\{if \!empty\(\$PLUGIN_INDEX_CONTENT_BEGIN\)\}#s';
121    $replacement = '</div>
122{if !empty($PLUGIN_INDEX_CONTENT_BEGIN)}';
123    $content = preg_replace($search, $replacement, $content);
124    $search = '#calendar_block"#s';
125    if ($page['chronology_view']=='calendar')
126    {
127     $replacement = 'calendar_block" class="bloc_stuff" style="width:100%;padding:5px"';
128    }
129    else {
130     $replacement = 'calendar_block" class="bloc_stuff" style="padding:5px 0"';
131    }
132    $content = preg_replace($search, $replacement, $content);
133  }
134
135  return $content;
136}
137
138?>
Note: See TracBrowser for help on using the repository browser.