[4516] | 1 | <?php |
---|
| 2 | function Juza_hook() { |
---|
| 3 | global $template; |
---|
| 4 | Juza_update(); |
---|
[4659] | 5 | $template->set_filenames(array( |
---|
| 6 | 'juza' => 'theme/Juza/script.tpl', |
---|
| 7 | 'juzabar' => 'theme/Juza/Juzabar.tpl', |
---|
| 8 | 'juzaconfig' => 'theme/Juza/include/Juzaconfig.tpl', |
---|
| 9 | )); |
---|
| 10 | include_once(PHPWG_ROOT_PATH.'include/menubar.inc.php'); |
---|
[4516] | 11 | $template->parse('juza'); |
---|
[4659] | 12 | $template->parse('juzabar'); |
---|
| 13 | $template->parse('juzaconfig'); |
---|
[4516] | 14 | } |
---|
| 15 | |
---|
| 16 | function Juza_file($src) { |
---|
| 17 | global $conf; |
---|
| 18 | $remove = (isset($conf['thumbnail_dir'])) ? $conf['thumbnail_dir']:'thumbnail'; |
---|
| 19 | $remove .= '/' . $conf['prefix_thumbnail']; |
---|
| 20 | $remove = '#' . addslashes( $remove ) . '#'; |
---|
| 21 | $file = preg_replace( $remove, '', $src, 1 ); |
---|
| 22 | $pos = strrpos( $file , '.'); |
---|
| 23 | $ext = substr($file,$pos); |
---|
| 24 | $file_wo_ext = substr($file,0,$pos); |
---|
| 25 | if (is_file($file)) return $file; /* 80% have the same file extension */ |
---|
| 26 | if ($ext <> 'jpg') { |
---|
| 27 | if (is_file($file_wo_ext . 'jpg')) return $file;/* 90% */ |
---|
| 28 | } |
---|
| 29 | if ($ext <> 'JPG') { |
---|
| 30 | if (is_file($file_wo_ext . 'JPG')) return $file;/* 8% */ |
---|
| 31 | } |
---|
| 32 | if ($ext <> 'png') { |
---|
| 33 | if (is_file($file_wo_ext . 'png')) return $file;/* 1.8% */ |
---|
| 34 | } |
---|
| 35 | if ($ext <> 'PNG') { |
---|
| 36 | if (is_file($file_wo_ext . 'PNG')) return $file;/* 0.1% */ |
---|
| 37 | } |
---|
| 38 | if ($ext <> 'jpeg') { |
---|
| 39 | if (is_file($file_wo_ext . 'jpeg')) return $file;/* or 50% */ |
---|
| 40 | } |
---|
| 41 | if ($ext <> 'JPEG') { |
---|
| 42 | if (is_file($file_wo_ext . 'JPEG')) return $file;/* or 40% */ |
---|
| 43 | } |
---|
| 44 | if ($ext <> 'gif') { |
---|
| 45 | if (is_file($file_wo_ext . 'gif')) return $file;/* 0.0001% */ |
---|
| 46 | } |
---|
| 47 | if ($ext <> 'GIF') { |
---|
| 48 | if (is_file($file_wo_ext . 'GIF')) return $file;/* 0.0001% */ |
---|
| 49 | } |
---|
| 50 | return $src; |
---|
| 51 | } |
---|
[4537] | 52 | |
---|
[4659] | 53 | function Juza_common_tags($max_tags) |
---|
| 54 | { |
---|
| 55 | $query = ' |
---|
| 56 | SELECT t.*, count(*) AS counter |
---|
| 57 | FROM '.IMAGE_TAG_TABLE.' |
---|
| 58 | INNER JOIN '.TAGS_TABLE.' t ON tag_id = id |
---|
| 59 | GROUP BY tag_id |
---|
| 60 | ORDER BY counter DESC |
---|
| 61 | LIMIT 0,' . $max_tags . ';'; |
---|
| 62 | $result = pwg_query($query); |
---|
| 63 | $tags = array(); |
---|
| 64 | while($row = mysql_fetch_assoc($result)) { |
---|
| 65 | array_push($tags, $row); |
---|
| 66 | } |
---|
| 67 | usort($tags, 'tag_alpha_compare'); |
---|
| 68 | return $tags; |
---|
| 69 | } |
---|
| 70 | |
---|
| 71 | function Juza_tags( $ref_back ) { |
---|
| 72 | $menu = & $ref_back[0]; |
---|
| 73 | $block = $menu->get_block( 'mbTags' ); |
---|
| 74 | if ( count($block->data) > 0 ) return; |
---|
| 75 | $tags = Juza_common_tags(10); |
---|
| 76 | $tags = add_level_to_tags($tags); |
---|
| 77 | foreach ($tags as $tag) { |
---|
| 78 | $block->data[] = array_merge( str_replace(' ', ' ', $tag), |
---|
| 79 | array( |
---|
| 80 | 'URL' => make_index_url( array( 'tags' => array($tag) ) ), |
---|
| 81 | 'U_ADD' => make_index_url( array( 'tags' => array($tag) ) ), |
---|
| 82 | ) |
---|
| 83 | ); |
---|
| 84 | } |
---|
| 85 | $block->template = 'menubar_tags.tpl'; |
---|
| 86 | } |
---|
| 87 | |
---|
[4516] | 88 | function Juza_update() { |
---|
[4537] | 89 | global $template, $conf, $user; |
---|
[4516] | 90 | $conf_Juza = Juza_default(); |
---|
| 91 | if (isset($conf['Juza Config'])) $conf_Juza = array_merge($conf_Juza, unserialize($conf['Juza Config'])); |
---|
| 92 | if (isset($_POST['Juza_submit'])) { |
---|
| 93 | $conf_Juza['Juza_width'] = isset($_POST['Juza_width']) ? (integer)$_POST['Juza_width'] : 885; |
---|
| 94 | $conf_Juza['Juza_width'] = ($conf_Juza['Juza_width'] > 885) ? 885 : $conf_Juza['Juza_width']; |
---|
| 95 | $conf_Juza['Juza_width'] = ($conf_Juza['Juza_width'] < 300) ? 300 : $conf_Juza['Juza_width']; |
---|
| 96 | $conf_Juza['Juza_height'] = isset($_POST['Juza_height']) ? (integer)$_POST['Juza_height'] : 400; |
---|
| 97 | $conf_Juza['Juza_height'] = ($conf_Juza['Juza_height'] > 400) ? 400 : $conf_Juza['Juza_height']; |
---|
| 98 | $conf_Juza['Juza_height'] = ($conf_Juza['Juza_height'] < 110) ? 110 : $conf_Juza['Juza_height']; |
---|
| 99 | $conf_Juza['Juza_shift'] = isset($_POST['Juza_shift']) ? (integer)$_POST['Juza_shift'] : -160; |
---|
| 100 | $conf_Juza['Juza_shift'] = ($conf_Juza['Juza_shift'] > 0) ? 0 : $conf_Juza['Juza_shift']; |
---|
| 101 | $conf_Juza['Juza_shift'] = ($conf_Juza['Juza_shift'] < -320) ? 320 : $conf_Juza['Juza_shift']; |
---|
| 102 | $conf['Juza Config'] = serialize($conf_Juza); |
---|
| 103 | $query = 'REPLACE INTO '.CONFIG_TABLE.' |
---|
| 104 | SET param = \'Juza Config\', |
---|
| 105 | value = \'' . $conf['Juza Config'] . '\', |
---|
| 106 | comment = \'Juza Theme Configuration Parameters\';'; |
---|
| 107 | pwg_query($query); |
---|
| 108 | } |
---|
| 109 | if (isset($_POST['Juza_reset'])) { |
---|
| 110 | $conf_Juza = Juza_default(); |
---|
| 111 | $conf['Juza Config'] = serialize($conf_Juza); |
---|
| 112 | $query = 'REPLACE INTO '.CONFIG_TABLE.' |
---|
| 113 | SET param = \'Juza Config\', |
---|
| 114 | value = \'' . $conf['Juza Config'] . '\', |
---|
| 115 | comment = \'Juza Theme Configuration Parameters\';'; |
---|
| 116 | pwg_query($query); |
---|
| 117 | } |
---|
| 118 | |
---|
[4659] | 119 | $template->assign('Juza_config', true); |
---|
| 120 | |
---|
[4537] | 121 | $user["expand"] = true; |
---|
| 122 | $template->assign('Juza_cats', get_categories_menu()); |
---|
| 123 | $user["expand"] = false; |
---|
[4516] | 124 | $template->assign('Juza_width', $conf_Juza['Juza_width']); |
---|
| 125 | $template->assign('Juza_height', $conf_Juza['Juza_height']); |
---|
| 126 | $template->assign('Juza_height2', 55+$conf_Juza['Juza_height']); |
---|
| 127 | $template->assign('Juza_height3', 325+$conf_Juza['Juza_height']); |
---|
| 128 | $template->assign('Juza_shift', $conf_Juza['Juza_shift']); |
---|
| 129 | $template->assign('Juza_shift2', 150-$conf_Juza['Juza_height']); |
---|
| 130 | $template->assign('Juza_shift3', -(12+$conf_Juza['Juza_height'])); |
---|
| 131 | } |
---|
| 132 | function Juza_default() { |
---|
| 133 | return array( |
---|
| 134 | 'Juza_width' => 885, |
---|
| 135 | 'Juza_height' => 240, |
---|
[4716] | 136 | 'Juza_shift' => -160,); |
---|
[4516] | 137 | } |
---|
| 138 | ?> |
---|