1 | <?php |
---|
2 | function Juza_hook() { |
---|
3 | global $template; |
---|
4 | Juza_update(); |
---|
5 | $template->set_filenames(array('juza' => 'theme/Juza/script.tpl')); |
---|
6 | $template->parse('juza'); |
---|
7 | } |
---|
8 | |
---|
9 | function Juza_file($src) { |
---|
10 | global $conf; |
---|
11 | $remove = (isset($conf['thumbnail_dir'])) ? $conf['thumbnail_dir']:'thumbnail'; |
---|
12 | $remove .= '/' . $conf['prefix_thumbnail']; |
---|
13 | $remove = '#' . addslashes( $remove ) . '#'; |
---|
14 | $file = preg_replace( $remove, '', $src, 1 ); |
---|
15 | $pos = strrpos( $file , '.'); |
---|
16 | $ext = substr($file,$pos); |
---|
17 | $file_wo_ext = substr($file,0,$pos); |
---|
18 | if (is_file($file)) return $file; /* 80% have the same file extension */ |
---|
19 | if ($ext <> 'jpg') { |
---|
20 | if (is_file($file_wo_ext . 'jpg')) return $file;/* 90% */ |
---|
21 | } |
---|
22 | if ($ext <> 'JPG') { |
---|
23 | if (is_file($file_wo_ext . 'JPG')) return $file;/* 8% */ |
---|
24 | } |
---|
25 | if ($ext <> 'png') { |
---|
26 | if (is_file($file_wo_ext . 'png')) return $file;/* 1.8% */ |
---|
27 | } |
---|
28 | if ($ext <> 'PNG') { |
---|
29 | if (is_file($file_wo_ext . 'PNG')) return $file;/* 0.1% */ |
---|
30 | } |
---|
31 | if ($ext <> 'jpeg') { |
---|
32 | if (is_file($file_wo_ext . 'jpeg')) return $file;/* or 50% */ |
---|
33 | } |
---|
34 | if ($ext <> 'JPEG') { |
---|
35 | if (is_file($file_wo_ext . 'JPEG')) return $file;/* or 40% */ |
---|
36 | } |
---|
37 | if ($ext <> 'gif') { |
---|
38 | if (is_file($file_wo_ext . 'gif')) return $file;/* 0.0001% */ |
---|
39 | } |
---|
40 | if ($ext <> 'GIF') { |
---|
41 | if (is_file($file_wo_ext . 'GIF')) return $file;/* 0.0001% */ |
---|
42 | } |
---|
43 | return $src; |
---|
44 | } |
---|
45 | |
---|
46 | function remove_AkBookStyle_handlers() { |
---|
47 | global $public_content; |
---|
48 | remove_event_handler('loc_begin_index_thumbnails', array($public_content, 'loc_begin_index_thumbnails')); |
---|
49 | remove_event_handler('loc_end_index_thumbnails', array($public_content, 'loc_end_index_thumbnails')); |
---|
50 | remove_event_handler('loc_begin_index', array($public_content, 'page_force')); |
---|
51 | remove_event_handler('loc_end_picture', array($public_content, 'loc_end_picture')); |
---|
52 | } |
---|
53 | |
---|
54 | function Juza_update() { |
---|
55 | global $template, $conf, $user; |
---|
56 | $conf_Juza = Juza_default(); |
---|
57 | if (isset($conf['Juza Config'])) $conf_Juza = array_merge($conf_Juza, unserialize($conf['Juza Config'])); |
---|
58 | if (isset($_POST['Juza_submit'])) { |
---|
59 | $conf_Juza['Juza_handlers'] = isset($_POST['Juza_handlers']) ? true:false; |
---|
60 | $conf_Juza['Juza_width'] = isset($_POST['Juza_width']) ? (integer)$_POST['Juza_width'] : 885; |
---|
61 | $conf_Juza['Juza_width'] = ($conf_Juza['Juza_width'] > 885) ? 885 : $conf_Juza['Juza_width']; |
---|
62 | $conf_Juza['Juza_width'] = ($conf_Juza['Juza_width'] < 300) ? 300 : $conf_Juza['Juza_width']; |
---|
63 | $conf_Juza['Juza_height'] = isset($_POST['Juza_height']) ? (integer)$_POST['Juza_height'] : 400; |
---|
64 | $conf_Juza['Juza_height'] = ($conf_Juza['Juza_height'] > 400) ? 400 : $conf_Juza['Juza_height']; |
---|
65 | $conf_Juza['Juza_height'] = ($conf_Juza['Juza_height'] < 110) ? 110 : $conf_Juza['Juza_height']; |
---|
66 | $conf_Juza['Juza_shift'] = isset($_POST['Juza_shift']) ? (integer)$_POST['Juza_shift'] : -160; |
---|
67 | $conf_Juza['Juza_shift'] = ($conf_Juza['Juza_shift'] > 0) ? 0 : $conf_Juza['Juza_shift']; |
---|
68 | $conf_Juza['Juza_shift'] = ($conf_Juza['Juza_shift'] < -320) ? 320 : $conf_Juza['Juza_shift']; |
---|
69 | $conf_Juza['Juza_Auto_CS'] = isset($_POST['Juza_Auto_CS']) ? true:false; |
---|
70 | $conf['Juza Config'] = serialize($conf_Juza); |
---|
71 | $query = 'REPLACE INTO '.CONFIG_TABLE.' |
---|
72 | SET param = \'Juza Config\', |
---|
73 | value = \'' . $conf['Juza Config'] . '\', |
---|
74 | comment = \'Juza Theme Configuration Parameters\';'; |
---|
75 | pwg_query($query); |
---|
76 | } |
---|
77 | if (isset($_POST['Juza_reset'])) { |
---|
78 | $conf_Juza = Juza_default(); |
---|
79 | $conf['Juza Config'] = serialize($conf_Juza); |
---|
80 | $query = 'REPLACE INTO '.CONFIG_TABLE.' |
---|
81 | SET param = \'Juza Config\', |
---|
82 | value = \'' . $conf['Juza Config'] . '\', |
---|
83 | comment = \'Juza Theme Configuration Parameters\';'; |
---|
84 | pwg_query($query); |
---|
85 | } |
---|
86 | $conf['Juza_active'] = (!isset($conf_Juza['Juza_handlers'])) ? true:$conf_Juza['Juza_handlers']; |
---|
87 | |
---|
88 | if ( is_admin() ) { |
---|
89 | $template->append('footer_elements', '<form method="post" name="JuzaTC" action="' . make_index_url() . '"> |
---|
90 | <input name="Juza_config" type="submit" value="'. l10n('Juza Theme Configuration') .'" class="conf" /> |
---|
91 | <input type="hidden" value="true" name="Juza_conf" /> |
---|
92 | </form>'); |
---|
93 | } |
---|
94 | if ( isset($_POST['Juza_conf']) ) $template->assign('Juza_config', true); |
---|
95 | if ($conf['Juza_active']) $template->assign('Juza_active', true); |
---|
96 | if ($conf_Juza['Juza_handlers']) $template->assign('Juza_handlers', 'checked="checked"'); |
---|
97 | $user["expand"] = true; |
---|
98 | $template->assign('Juza_cats', get_categories_menu()); |
---|
99 | $user["expand"] = false; |
---|
100 | $template->assign('Juza_width', $conf_Juza['Juza_width']); |
---|
101 | $template->assign('Juza_height', $conf_Juza['Juza_height']); |
---|
102 | $template->assign('Juza_height2', 55+$conf_Juza['Juza_height']); |
---|
103 | $template->assign('Juza_height3', 325+$conf_Juza['Juza_height']); |
---|
104 | $template->assign('Juza_shift', $conf_Juza['Juza_shift']); |
---|
105 | $template->assign('Juza_shift2', 150-$conf_Juza['Juza_height']); |
---|
106 | $template->assign('Juza_shift3', -(12+$conf_Juza['Juza_height'])); |
---|
107 | if ($conf_Juza['Juza_Auto_CS']) $template->assign('Juza_Auto_CS', 'checked="checked"'); |
---|
108 | if (isset($_POST['Juza_close'])) { |
---|
109 | redirect(make_index_url()); |
---|
110 | } |
---|
111 | } |
---|
112 | function Juza_default() { |
---|
113 | return array( |
---|
114 | 'Juza_handlers' => true, |
---|
115 | 'Juza_width' => 885, |
---|
116 | 'Juza_height' => 240, |
---|
117 | 'Juza_shift' => -160, |
---|
118 | 'Juza_Auto_CS' => true,); |
---|
119 | } |
---|
120 | ?> |
---|