Subversion Repositories eFlore/Applications.cel

Rev

Rev 419 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
419 aurelien 1
<?php
2
 
3
/*
4
 * phpMyEdit - instant MySQL table editor and code generator
5
 *
6
 * extensions/phpMyEdit-slide.class.php - slide show extension for phpMyEdit
7
 * ____________________________________________________________
8
 *
9
 * Developed by Ondrej Jombik <nepto@platon.sk>
10
 * Copyright (c) 2002-2006 Platon Group, http://platon.sk/
11
 * All rights reserved.
12
 *
13
 * See README file for more information about this software.
14
 * See COPYING file for license information.
15
 *
16
 * Download the latest version from
17
 * http://platon.sk/projects/phpMyEdit/
18
 */
19
 
20
/* $Platon: phpMyEdit/extensions/phpMyEdit-slide.class.php,v 1.10 2006-01-22 21:44:24 nepto Exp $ */
21
 
22
/*
23
 * Coding elapsed time: from 8:30 to 10:30 at 30th October 2002
24
 * with heavy patching phpMyEdit core class.
25
 *
26
 * Music used: E-Type (Campione, This is the Way and others)
27
 */
28
 
29
require_once dirname(__FILE__).'/../phpMyEdit.class.php';
30
 
31
class phpMyEdit_slide extends phpMyEdit
32
{
33
	// Extension options array
34
	var $ext;
35
 
36
	function phpMyEdit_slide($opts) /* {{{ */
37
	{
38
		$execute = 1;
39
		isset($opts['execute']) && $execute = $opts['execute'];
40
		$opts['execute'] = 0;
41
		parent::phpMyEdit($opts);
42
 
43
		$this->ext = $opts['ext'];
44
 
45
		$execute && $this->execute($opts);
46
	} /* }}} */
47
 
48
	function display_record_buttons() /* {{{ */
49
	{
50
		// TODO: classify this table and cells
51
		echo '<table border=0 cellpadding=0 cellspacing=0 width="100%" style="border:0;padding:0;">';
52
		echo '<tr><td align=left style="text-align:left;border:0;padding:0;" nowrap>' . "\n";
53
		if ($this->change_operation()) {
54
			echo '<input type="submit" name="savechange" value="'.$this->labels['Save'].'" />'."\n";
55
			echo '<input type="submit" name="morechange" value="'.$this->labels['Apply'].'" />'."\n";
56
			echo '<input type="button" name="cancel" value="'.$this->labels['Cancel'].'" onClick="form.submit();" />'."\n";
57
			echo '<input type="hidden" name="rec_change" value="1">';
58
		} elseif ($this->view_operation()) {
59
			if ($this->change_enabled()) {
60
				echo '<input type="submit" name="operation" value="'.$this->labels['Change'].'" />'."\n";
61
			}
62
			echo '<input type="submit" name="cancel" value="'.$this->labels['Cancel'].'" />'."\n";
63
		}
64
 
65
		if (! $this->ext['prev_disable']) {
66
			$disabled = $this->ext['prev'] ? '' : ' disabled';
67
			echo '<input'.$disabled.' type="submit" name="'.ltrim($disabled).'prev" value="'
68
				.$this->labels['Prev'].'">&nbsp;';
69
			echo '<input type="hidden" name="rec_prev" value="'.$this->ext['prev'].'">';
70
		}
71
		if (! $this->ext['next_disable']) {
72
			$disabled = $this->ext['next'] ? '' : ' disabled';
73
			echo '<input'.$disabled.' type="submit" name="'.ltrim($disabled).'next" value="'
74
				.$this->labels['Next'].'">';
75
			echo '<input type="hidden" name="rec_next" value="'.$this->ext['next'].'">';
76
		}
77
		echo '</td></tr></table>'."\n";
78
	} /* }}} */
79
 
80
	function execute($opts) /* {{{ */
81
	{
82
		if ($this->get_cgi_var('rec_change')
83
				&& ($this->next_operation() || $this->prev_operation())) {
84
			$this->operation = $this->labels['Change'];
85
		}
86
		if (! $this->change_operation()) {
87
			$this->operation = $this->labels['View'];
88
		}
89
		if ($this->prev_operation()) {
90
			! $this->ext['prev_disabled'] && $this->rec = $this->get_cgi_var('rec_prev');
91
			$this->prev = '';
92
		}
93
		if ($this->next_operation()) {
94
			! $this->ext['next_disabled'] && $this->rec = $this->get_cgi_var('rec_next');
95
			$this->next = '';
96
		}
97
		if (! $this->rec) {
98
			$this->rec = $this->ext['rec'];
99
		}
100
 
101
		if (! $this->rec
102
				|| (! $this->ext['prev_disable'] && ! $this->ext['prev'])
103
				|| (! $this->ext['next_disable'] && ! $this->ext['next'])) {
104
			if ($this->connect() == false) {
105
				return false;
106
			}
107
			$query_parts = array(
108
					'type'   => 'select',
109
					// XXX FIXME - simplify query
110
					'select' => 'PMEtable0.'.$this->key,
111
					'from'   => $this->get_SQL_join_clause(),
112
					'where'  => $this->get_SQL_where_from_query_opts());
113
			// TODO: order by clausule according to default sort order options
114
			$res = $this->myquery($this->get_SQL_query($query_parts), __LINE__);
115
			$ids = array();
116
			while (($row = @mysql_fetch_array($res, MYSQL_NUM)) !== false) {
117
				$ids[] = $row[0];
118
			}
119
			@mysql_free_result($res);
120
			if ($this->rec) {
121
				$idx = array_search($this->rec, $ids);
122
				$idx === false && $idx = 0;
123
			} else {
124
				$idx = 0;
125
			}
126
 
127
			$this->rec = $ids[$idx];
128
			! $this->ext['prev'] && $this->ext['prev'] = $ids[$idx - 1];
129
			! $this->ext['next'] && $this->ext['next'] = $ids[$idx + 1];
130
		}
131
 
132
		$this->recreate_fdd();
133
		$this->recreate_displayed();
134
		parent::execute();
135
	} /* }}} */
136
 
137
}
138
 
139
/* Modeline for ViM {{{
140
 * vim:set ts=4:
141
 * vim600:fdm=marker fdl=0 fdc=0:
142
 * }}} */
143
 
144
?>