source: extensions/Juza/include/functions.inc.php @ 15555

Last change on this file since 15555 was 4716, checked in by vdigital, 14 years ago

[Update] - Juza Theme is full working (Not tested with plugins).

Recommended organization: Don't mixed Pictures and subcategories in a category.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.9 KB
Line 
1<?php
2function Juza_hook() {
3  global $template;
4  Juza_update();
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');
11  $template->parse('juza');
12  $template->parse('juzabar');
13  $template->parse('juzaconfig');
14}
15
16function 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}
52
53function Juza_common_tags($max_tags)
54{
55   $query = '
56SELECT 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
71function 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('&nbsp;', ' ', $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
88function Juza_update() {
89  global $template, $conf, $user;
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
119  $template->assign('Juza_config', true);
120
121  $user["expand"] = true;
122  $template->assign('Juza_cats', get_categories_menu());
123  $user["expand"] = false;
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}
132function Juza_default() {
133  return array(
134    'Juza_width'    => 885,
135    'Juza_height'   => 240,
136    'Juza_shift'    => -160,);
137}
138?>
Note: See TracBrowser for help on using the repository browser.