[9281] | 1 | <?php |
---|
| 2 | /* |
---|
| 3 | Theme Name: hr_os_xl |
---|
[9670] | 4 | Version: auto |
---|
[9281] | 5 | Description: A theme with an horizontal menu everywhere and a simple modern design |
---|
| 6 | Theme URI: http://fr.piwigo.org/ext/extension_view.php?eid=504 |
---|
| 7 | Author: flop25 |
---|
| 8 | Author URI: http://www.planete-flop.fr |
---|
| 9 | */ |
---|
| 10 | $themeconf = array( |
---|
[12266] | 11 | 'name' => 'hr_os_xl', |
---|
[9281] | 12 | 'parent' => 'default', |
---|
| 13 | 'icon_dir' => 'themes/hr_os_xl/icon', |
---|
| 14 | 'mime_icon_dir' => 'themes/hr_os_xl/icon/mimetypes/', |
---|
[12266] | 15 | 'local_head' => 'local_head.tpl', |
---|
| 16 | 'activable' => true, |
---|
[30085] | 17 | 'colorscheme' => 'clear', |
---|
[9281] | 18 | ); |
---|
[20153] | 19 | //// [update check] |
---|
| 20 | if (!isset($conf['hr_os_xl'])) |
---|
| 21 | { |
---|
| 22 | $config = array( |
---|
| 23 | 'home' => true, |
---|
| 24 | 'categories' => true, |
---|
| 25 | 'picture' => false, |
---|
| 26 | 'other' => true, |
---|
| 27 | ); |
---|
| 28 | |
---|
| 29 | $query = ' |
---|
[12266] | 30 | INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
| 31 | VALUES ("hr_os_xl" , "'.pwg_db_real_escape_string(serialize($config)).'" , "hr_os_xl parameters");'; |
---|
[9281] | 32 | |
---|
[20153] | 33 | pwg_query($query); |
---|
| 34 | load_conf_from_db(); |
---|
| 35 | } |
---|
| 36 | if (isset($conf['derivatives'])) { |
---|
| 37 | $new = @unserialize($conf['derivatives']); |
---|
| 38 | if(!isset($new['d']['Optimal'])) |
---|
| 39 | { |
---|
| 40 | $new['d']['Optimal']=ImageStdParams::get_custom(900,9999); |
---|
| 41 | $query = ' |
---|
| 42 | UPDATE '.CONFIG_TABLE.' |
---|
| 43 | SET value="'.addslashes(serialize($new)).'" |
---|
| 44 | WHERE param = "derivatives" |
---|
| 45 | LIMIT 1'; |
---|
[12266] | 46 | pwg_query($query); |
---|
| 47 | load_conf_from_db(); |
---|
| 48 | } |
---|
[20153] | 49 | } |
---|
| 50 | //// [/update check] |
---|
[12266] | 51 | |
---|
[10825] | 52 | // thx to P@t |
---|
| 53 | add_event_handler('loc_begin_page_header', 'set_hr_os_xl_header'); |
---|
| 54 | |
---|
| 55 | function set_hr_os_xl_header() |
---|
| 56 | { |
---|
| 57 | global $page, $conf, $template; |
---|
| 58 | |
---|
| 59 | $config = unserialize($conf['hr_os_xl']); |
---|
| 60 | |
---|
| 61 | if (isset($page['body_id']) and $page['body_id'] == 'theCategoryPage') |
---|
| 62 | { |
---|
| 63 | $header = isset($page['category']) ? $config['categories'] : $config['home']; |
---|
| 64 | } |
---|
| 65 | elseif (isset($page['body_id']) and $page['body_id'] == 'thePicturePage') |
---|
| 66 | { |
---|
| 67 | $header = $config['picture']; |
---|
| 68 | } |
---|
| 69 | else |
---|
| 70 | { |
---|
| 71 | $header = $config['other']; |
---|
| 72 | } |
---|
| 73 | |
---|
| 74 | $template->assign('display_hr_os_xl_banner', $header); |
---|
| 75 | } |
---|
[16380] | 76 | // function load_pattern |
---|
| 77 | // include the right ***.pattern.php |
---|
| 78 | // not compatible 2.2and<2.2 |
---|
| 79 | |
---|
| 80 | function load_pattern() |
---|
| 81 | { |
---|
| 82 | global $pattern; |
---|
| 83 | $pwgversion=str_replace('.','',PHPWG_VERSION); |
---|
| 84 | $pwgversion_array=explode('.', PHPWG_VERSION); |
---|
| 85 | if (file_exists($pwgversion.'pattern.php')) |
---|
| 86 | { |
---|
| 87 | include($pwgversion.'.pattern.php'); |
---|
| 88 | return true; |
---|
| 89 | } |
---|
| 90 | elseif (file_exists(PHPWG_ROOT_PATH.'themes/hr_os_xl/'.$pwgversion_array[0].$pwgversion_array[1].'x.pattern.php')) |
---|
| 91 | { |
---|
| 92 | include(PHPWG_ROOT_PATH.'themes/hr_os_xl/'.$pwgversion_array[0].$pwgversion_array[1].'x.pattern.php'); |
---|
| 93 | return true; |
---|
| 94 | } |
---|
| 95 | else |
---|
| 96 | { |
---|
| 97 | $list_pattern_path=array(); |
---|
| 98 | $dir=PHPWG_ROOT_PATH.'themes/hr_os_xl'; |
---|
| 99 | $dh = opendir($dir); |
---|
| 100 | while (($file = readdir ($dh)) !== false ) { |
---|
| 101 | if ($file !== '.' && $file !== '..') { |
---|
| 102 | $path =$dir.'/'.$file; |
---|
| 103 | if (!is_dir ($path)) { |
---|
| 104 | if(strpos($file,'pattern.php')!==false) { //On ne prend que les .pattern.php |
---|
| 105 | $list_pattern_path[]=$file; |
---|
| 106 | } |
---|
| 107 | } |
---|
| 108 | } |
---|
| 109 | } |
---|
| 110 | closedir($dh); |
---|
| 111 | $f=0; |
---|
| 112 | for($i = 10; $i >=0; $i--) |
---|
| 113 | { |
---|
| 114 | if (in_array($pwgversion_array[0].$i.'.pattern.php',$list_pattern_path)) |
---|
| 115 | { |
---|
| 116 | include($pwgversion_array[0].$i.'.pattern.php'); |
---|
| 117 | return true; |
---|
| 118 | $f=1; |
---|
| 119 | break; |
---|
| 120 | } |
---|
| 121 | } |
---|
| 122 | if ($f=0) |
---|
| 123 | { |
---|
| 124 | return false; |
---|
| 125 | } |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | } |
---|
| 129 | if(!load_pattern()) |
---|
| 130 | { |
---|
| 131 | global $page; |
---|
| 132 | $page['errors'][]='Theme not compatible'; |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | /************************************ picture.tpl ************************************/ |
---|
[20153] | 136 | //add_event_handler('render_element_content', 'hr_os_xl_picture', EVENT_HANDLER_PRIORITY_NEUTRAL, 20 ); |
---|
[16380] | 137 | function hr_os_xl_picture($content, $element_info) |
---|
| 138 | { |
---|
| 139 | global $template; |
---|
| 140 | $template->set_prefilter('default_content', 'hr_os_xl_prefilter_picture'); |
---|
| 141 | return $content; |
---|
| 142 | } |
---|
| 143 | function hr_os_xl_prefilter_picture($content, &$smarty) |
---|
| 144 | { |
---|
| 145 | global $pattern; |
---|
| 146 | $r=$pattern['hr_os_xl_prefilter_picture']['R']; |
---|
| 147 | $ps=$pattern['hr_os_xl_prefilter_picture']['S']; |
---|
| 148 | foreach($r as $i => $pr) |
---|
| 149 | { |
---|
| 150 | $content = str_replace($ps[$i], $pr, $content); |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | $content ='{define_derivative name=\'der_hr_os_xl\' width=900 height=9999 crop=false} |
---|
| 154 | {assign var=der value=$pwg->derivative($der_hr_os_xl, $current.src_image)} |
---|
| 155 | '.$content; |
---|
| 156 | return $content; |
---|
| 157 | } |
---|
| 158 | |
---|
| 159 | |
---|
[9281] | 160 | ?> |
---|