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

Revision 12408, 5.0 KB checked in by flop25, 8 years ago (diff)

adding config for strpped 2.0

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  'admin_icon_dir' => 'themes/default/icon/admin',
19  'mime_icon_dir' => 'themes/default/icon/mimetypes/',
20  'local_head' => 'local_head.tpl',
21  'load_parent_local_head' => true,
22);
23global $stripped;
24$stripped['themeStyle']='original';
25
26load_language('theme.lang', PHPWG_THEMES_PATH.'stripped_black_bloc/');
27
28// Need upgrade?
29
30include(PHPWG_THEMES_PATH.'stripped_black_bloc/admin/upgrade.inc.php');
31
32add_event_handler('loc_begin_page_header', 'set_config_values_stripped_black_bloc');
33
34function set_config_values_stripped_black_bloc()
35{
36  global $conf, $template;
37  $config = unserialize( $conf['stripped_black_bloc'] );
38  $template->assign( 'stripped_black_bloc', $config );
39}
40
41/// EVENT
42
43/************************************ thumbnails and category_thumbnails ************************************/
44add_event_handler('loc_end_index_category_thumbnails', 'stripped_black_bloc');
45add_event_handler('loc_end_index_thumbnails', 'stripped_black_bloc');
46function stripped_black_bloc($tpl_thumbnails_var)
47{
48  global $template, $conf;
49  $config = unserialize( $conf['stripped_black_bloc'] );
50  $new_tplvar=array();
51  $i=1;
52  foreach ($tpl_thumbnails_var as $tplvar)
53  {
54    list($width, $height, $type, $attr) = getimagesize( $tplvar['TN_SRC'] );
55    $tplvar['TN_WIDTH']=$width;
56    $tplvar['TN_HEIGHT']=$height;
57    if (!isset($tplvar['CAPTION_NB_IMAGES']))
58    {
59      $conf_thumbnail_width=($i==$config['starting_to']) ? $config['column_width']+$config['thumbnail_width'] : $config['thumbnail_width'];
60      $tplvar['TN_CLASS']=($i==$config['starting_to']) ? "bloc_big" : "bloc";
61    }
62    else
63    {
64      $conf_thumbnail_width=$config['thumbnail_width'];
65    }
66    if (isset($config['thumbnail']))
67    {
68      switch ($config['thumbnail'])
69      {
70        case 'generated':
71          if (isset($tplvar['FILE_WIDTH']))
72          {
73           $tplvar['TN_SRC']=PHPWG_THEMES_PATH."stripped_black_bloc/library/phpthumb/phpThumb.php?src=../../../../".$tplvar['FILE_PATH']."&w=".$conf_thumbnail_width;
74          }
75          else
76          {
77           $tplvar['TN_SRC']=PHPWG_THEMES_PATH."stripped_black_bloc/library/phpthumb/phpThumb.php?src=../../../../".$tplvar['TN_SRC']."&w=".$conf_thumbnail_width;
78          }
79          $tplvar['TN_HEIGHT']=floor($tplvar['TN_HEIGHT']*($conf_thumbnail_width/$tplvar['TN_WIDTH']));
80          $tplvar['TN_WIDTH']=$conf_thumbnail_width;
81         break;
82         case 'auto':
83          if($tplvar['TN_WIDTH']<=$conf_thumbnail_width)
84          {
85            if (isset($tplvar['FILE_WIDTH']))
86            {
87             $tplvar['TN_SRC']=PHPWG_THEMES_PATH."stripped_black_bloc/library/phpthumb/phpThumb.php?src=../../../../".$tplvar['FILE_PATH']."&w=".$conf_thumbnail_width;
88            }
89            else
90            {
91             $tplvar['TN_SRC']=PHPWG_THEMES_PATH."stripped_black_bloc/library/phpthumb/phpThumb.php?src=../../../../".$tplvar['TN_SRC']."&w=".$conf_thumbnail_width;
92            }
93            $tplvar['TN_HEIGHT']=floor($tplvar['TN_HEIGHT']*($conf_thumbnail_width/$tplvar['TN_WIDTH']));
94            $tplvar['TN_WIDTH']=$conf_thumbnail_width;
95          }
96        break;
97        case 'piwigo':break;
98      }
99    }
100   $new_tplvar[]=$tplvar;
101    if ($i==$config['every_x'])
102    {
103      $i=1;
104    }
105    else {
106      $i++;   
107    }
108  }
109  return $new_tplvar;
110}
111add_event_handler('init', 'stripped_black_bloc_init');
112function stripped_black_bloc_init()
113{
114  remove_event_handler('loc_begin_index', 'modify_nb_thumbnail_page');
115}
116
117/************************************ index.tpl ************************************/
118add_event_handler('loc_end_index', 'stripped_black_bloc_index');
119function stripped_black_bloc_index()
120{
121    global $template;
122    $template->set_prefilter('index', 'stripped_black_bloc_prefilter_index');
123}
124function stripped_black_bloc_prefilter_index($content, &$smarty)
125{
126  $search = '#Menu</span>#'; 
127  $replacement = "{'Show/hide menu'|@translate}</span>";
128  $content = preg_replace($search, $replacement, $content);
129  $search = '#<div id="subcontent">#'; 
130  $replacement = "";
131  $content = preg_replace($search, $replacement, $content);
132  $search = '#\{if \!empty\(\$CONTENT_DESCRIPTION\) \}#'; 
133  $replacement = ' <div id="subcontent">
134
135  {if !empty($CONTENT_DESCRIPTION) }';
136  $content = preg_replace($search, $replacement, $content);
137  $search = '#\{if \!empty\(\$navbar\) \}[\s]*\{include file=\'navigation_bar\.tpl\'\|@get_extent:\'navbar\'\}[\s]*\{/if\}#'; 
138  $replacement = '';
139  $content = preg_replace($search, $replacement, $content);
140
141  $search = '#{\$PLUGIN_INDEX_CONTENT_AFTER}</div>{/if}.*</div>#s'; 
142  $replacement = '{$PLUGIN_INDEX_CONTENT_AFTER}</div>{/if}
143        </div>
144 {if !empty($navbar) }
145  {include file=\'navigation_bar.tpl\'|@get_extent:\'navbar\'}
146 {/if}';
147  return preg_replace($search, $replacement, $content);
148}
149
150?>
Note: See TracBrowser for help on using the repository browser.