| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | Theme Name: Stripped & Columns |
|---|
| 4 | Version: auto |
|---|
| 5 | Description: stripped_black_bloc |
|---|
| 6 | Theme URI: http://piwigo.org/ext/extension_view.php?eid=568 |
|---|
| 7 | Author: flop25 |
|---|
| 8 | Author 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 | ); |
|---|
| 23 | global $stripped; |
|---|
| 24 | $stripped['themeStyle']='original'; |
|---|
| 25 | |
|---|
| 26 | load_language('theme.lang', PHPWG_THEMES_PATH.'stripped_black_bloc/'); |
|---|
| 27 | |
|---|
| 28 | // Need upgrade? |
|---|
| 29 | |
|---|
| 30 | include(PHPWG_THEMES_PATH.'stripped_black_bloc/admin/upgrade.inc.php'); |
|---|
| 31 | |
|---|
| 32 | add_event_handler('loc_begin_page_header', 'set_config_values_stripped_black_bloc'); |
|---|
| 33 | |
|---|
| 34 | function 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 ************************************/ |
|---|
| 44 | add_event_handler('loc_end_index_category_thumbnails', 'stripped_black_bloc'); |
|---|
| 45 | add_event_handler('loc_end_index_thumbnails', 'stripped_black_bloc'); |
|---|
| 46 | function 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( str_replace("../", "", $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']=get_root_url().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']=get_root_url().PHPWG_THEMES_PATH."stripped_black_bloc/library/phpthumb/phpThumb.php?src=../../../../".str_replace("../", "", $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']=get_root_url().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']=get_root_url().PHPWG_THEMES_PATH."stripped_black_bloc/library/phpthumb/phpThumb.php?src=../../../../".str_replace("../", "", $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 | } |
|---|
| 111 | add_event_handler('init', 'stripped_black_bloc_init'); |
|---|
| 112 | function stripped_black_bloc_init() |
|---|
| 113 | { |
|---|
| 114 | remove_event_handler('loc_begin_index', 'modify_nb_thumbnail_page'); |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | /************************************ index.tpl ************************************/ |
|---|
| 118 | add_event_handler('loc_end_index', 'stripped_black_bloc_index'); |
|---|
| 119 | function stripped_black_bloc_index() |
|---|
| 120 | { |
|---|
| 121 | global $template; |
|---|
| 122 | $template->set_prefilter('index', 'stripped_black_bloc_prefilter_index'); |
|---|
| 123 | } |
|---|
| 124 | function 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 | ?> |
|---|