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

Last change on this file since 13378 was 13015, checked in by flop25, 13 years ago

compatible with stripped 2.1

File size: 5.2 KB
RevLine 
[10851]1<?php
2/*
[11679]3Theme Name: Stripped & Columns
[11680]4Version: auto
[10851]5Description: stripped_black_bloc
[11680]6Theme URI: http://piwigo.org/ext/extension_view.php?eid=568
7Author: flop25
8Author URI: http://www.planete-flop.fr
[10851]9*/
10
11
[12048]12 
[10851]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',
[12408]21  'load_parent_local_head' => true,
[10851]22);
[12408]23global $stripped;
24$stripped['themeStyle']='original';
[11696]25
26load_language('theme.lang', PHPWG_THEMES_PATH.'stripped_black_bloc/');
27
[11699]28// Need upgrade?
[11696]29
[11823]30include(PHPWG_THEMES_PATH.'stripped_black_bloc/admin/upgrade.inc.php');
[11699]31
32add_event_handler('loc_begin_page_header', 'set_config_values_stripped_black_bloc');
33
34function set_config_values_stripped_black_bloc()
35{
[12048]36  global $conf, $template;
37  $config = unserialize( $conf['stripped_black_bloc'] );
38  $template->assign( 'stripped_black_bloc', $config );
[11699]39}
40
41/// EVENT
[12048]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)
[10851]47{
[12048]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  {
[12948]54    list($width, $height, $type, $attr) = getimagesize( str_replace("../", "", $tplvar['TN_SRC']) );
[12048]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          {
[12948]73           $tplvar['TN_SRC']=get_root_url().PHPWG_THEMES_PATH."stripped_black_bloc/library/phpthumb/phpThumb.php?src=../../../../".$tplvar['FILE_PATH']."&w=".$conf_thumbnail_width;
[12048]74          }
75          else
76          {
[12948]77           $tplvar['TN_SRC']=get_root_url().PHPWG_THEMES_PATH."stripped_black_bloc/library/phpthumb/phpThumb.php?src=../../../../".str_replace("../", "", $tplvar['TN_SRC'])."&w=".$conf_thumbnail_width;
[12048]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            {
[12948]87             $tplvar['TN_SRC']=get_root_url().PHPWG_THEMES_PATH."stripped_black_bloc/library/phpthumb/phpThumb.php?src=../../../../".$tplvar['FILE_PATH']."&w=".$conf_thumbnail_width;
[12048]88            }
89            else
90            {
[12948]91             $tplvar['TN_SRC']=get_root_url().PHPWG_THEMES_PATH."stripped_black_bloc/library/phpthumb/phpThumb.php?src=../../../../".str_replace("../", "", $tplvar['TN_SRC'])."&w=".$conf_thumbnail_width;
[12048]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;
[10851]110}
[12048]111add_event_handler('init', 'stripped_black_bloc_init');
112function stripped_black_bloc_init()
[11498]113{
[12048]114  remove_event_handler('loc_begin_index', 'modify_nb_thumbnail_page');
[11498]115}
[11696]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{
[13015]126  $search = "#\{\'Menu\'\|@translate\}#"; 
[11823]127  $replacement = "{'Show/hide menu'|@translate}</span>";
128  $content = preg_replace($search, $replacement, $content);
[11843]129  $search = '#<div id="subcontent">#'; 
[11842]130  $replacement = "";
131  $content = preg_replace($search, $replacement, $content);
[11843]132  $search = '#\{if \!empty\(\$CONTENT_DESCRIPTION\) \}#'; 
[12048]133  $replacement = ' <div id="subcontent">
[11843]134
[12048]135  {if !empty($CONTENT_DESCRIPTION) }';
[11843]136  $content = preg_replace($search, $replacement, $content);
[11696]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
[12406]141  $search = '#{\$PLUGIN_INDEX_CONTENT_AFTER}</div>{/if}.*</div>#s'; 
142  $replacement = '{$PLUGIN_INDEX_CONTENT_AFTER}</div>{/if}
143        </div>
[12048]144 {if !empty($navbar) }
145  {include file=\'navigation_bar.tpl\'|@get_extent:\'navbar\'}
146 {/if}';
[11696]147  return preg_replace($search, $replacement, $content);
148}
149
[10851]150?>
Note: See TracBrowser for help on using the repository browser.