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

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

[Update] For Juza - Juza Theme Configuration Menu is working at 98% at least

  • Localization

Pendings:

  • Menubar
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1<?php
2function Juza_hook() {
3  global $template;
4  Juza_update();
5  $template->set_filenames(array('juza' => 'theme/Juza/script.tpl'));
6  $template->parse('juza');
7}
8
9function 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}
45function Juza_update() {
46  global $template, $conf;
47  $conf_Juza = Juza_default();
48  if (isset($conf['Juza Config'])) $conf_Juza = array_merge($conf_Juza, unserialize($conf['Juza Config']));
49  if (isset($_POST['Juza_submit'])) {
50    $conf_Juza['Juza_handlers'] = isset($_POST['Juza_handlers']) ? true:false;
51    $conf_Juza['Juza_width'] = isset($_POST['Juza_width']) ? (integer)$_POST['Juza_width'] : 885;
52    $conf_Juza['Juza_width'] = ($conf_Juza['Juza_width'] > 885) ? 885 : $conf_Juza['Juza_width'];
53    $conf_Juza['Juza_width'] = ($conf_Juza['Juza_width'] < 300) ? 300 : $conf_Juza['Juza_width'];
54    $conf_Juza['Juza_height'] = isset($_POST['Juza_height']) ? (integer)$_POST['Juza_height'] : 400;
55    $conf_Juza['Juza_height'] = ($conf_Juza['Juza_height'] > 400) ? 400 : $conf_Juza['Juza_height'];
56    $conf_Juza['Juza_height'] = ($conf_Juza['Juza_height'] < 110) ? 110 : $conf_Juza['Juza_height'];
57    $conf_Juza['Juza_shift'] = isset($_POST['Juza_shift']) ? (integer)$_POST['Juza_shift'] : -160;
58    $conf_Juza['Juza_shift'] = ($conf_Juza['Juza_shift'] > 0) ? 0 : $conf_Juza['Juza_shift'];
59    $conf_Juza['Juza_shift'] = ($conf_Juza['Juza_shift'] < -320) ? 320 : $conf_Juza['Juza_shift'];
60    $conf_Juza['Juza_Auto_CS'] = isset($_POST['Juza_Auto_CS']) ? true:false;
61    $conf['Juza Config'] = serialize($conf_Juza);
62    $query = 'REPLACE INTO '.CONFIG_TABLE.'
63      SET param = \'Juza Config\',
64      value = \'' . $conf['Juza Config'] . '\',
65      comment = \'Juza Theme Configuration Parameters\';';
66    pwg_query($query);
67  }
68  if (isset($_POST['Juza_reset'])) {
69    $conf_Juza = Juza_default();
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  $conf['Juza_active'] = (!isset($conf_Juza['Juza_handlers'])) ? true:$conf_Juza['Juza_handlers'];
78
79  if ( is_admin() ) {
80    $template->append('footer_elements', '<form method="post" name="JuzaTC"  action="' . make_index_url() . '">
81<input name="Juza_config" type="submit" value="'. l10n('Juza Theme Configuration') .'" class="conf" />
82<input type="hidden" value="true" name="Juza_conf" />
83</form>');
84  }
85  if ( isset($_POST['Juza_conf']) ) $template->assign('Juza_config', true);
86  if ($conf['Juza_active']) $template->assign('Juza_active', true);
87  if ($conf_Juza['Juza_handlers']) $template->assign('Juza_handlers', 'checked="checked"');
88  $template->assign('Juza_width', $conf_Juza['Juza_width']);
89  $template->assign('Juza_height', $conf_Juza['Juza_height']);
90  $template->assign('Juza_height2', 55+$conf_Juza['Juza_height']);
91  $template->assign('Juza_height3', 325+$conf_Juza['Juza_height']);
92  $template->assign('Juza_shift', $conf_Juza['Juza_shift']);
93  $template->assign('Juza_shift2', 150-$conf_Juza['Juza_height']);
94  $template->assign('Juza_shift3', -(12+$conf_Juza['Juza_height']));
95  if ($conf_Juza['Juza_Auto_CS']) $template->assign('Juza_Auto_CS', 'checked="checked"');
96  if (isset($_POST['Juza_close'])) {
97    redirect(make_index_url());
98  }
99}
100function Juza_default() {
101  return array(
102    'Juza_handlers' => true,
103    'Juza_width'    => 885,
104    'Juza_height'   => 240,
105    'Juza_shift'    => -160,
106    'Juza_Auto_CS'  => true,);
107}
108?>
Note: See TracBrowser for help on using the repository browser.