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