419 |
aurelien |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
* phpMyEdit - instant MySQL table editor and code generator
|
|
|
5 |
*
|
|
|
6 |
* extensions/phpMyEdit-htmlarea.class.php - phpMyEdit htmlArea extension
|
|
|
7 |
* ____________________________________________________________
|
|
|
8 |
*
|
|
|
9 |
* Contribution of Ezudin Kurtowich <ekurtovic@ieee.org>, Sarajevo
|
|
|
10 |
* Copyright (c) 2003-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-htmlarea.class.php,v 1.10 2006-01-22 21:44:18 nepto Exp $ */
|
|
|
21 |
|
|
|
22 |
/*
|
|
|
23 |
OVERVIEW
|
|
|
24 |
--------
|
|
|
25 |
|
|
|
26 |
NOTE...This extension will not work with the CVS version of PME. It has
|
|
|
27 |
been replaced by the mce_cal extension.
|
|
|
28 |
|
|
|
29 |
htmlArea is a free WYSIWYG textarea replacement from
|
|
|
30 |
http://www.interactivetools.com/ website.
|
|
|
31 |
|
|
|
32 |
REQUIREMENTS
|
|
|
33 |
------------
|
|
|
34 |
|
|
|
35 |
The extension requires a properly installed htmlArea script
|
|
|
36 |
as described on the http://www.interactivetools.com/ site.
|
|
|
37 |
|
|
|
38 |
USAGE
|
|
|
39 |
-----
|
|
|
40 |
|
|
|
41 |
This extension enables WYSIWYG editing of a textarea field.
|
|
|
42 |
In order to use it, you should:
|
|
|
43 |
|
|
|
44 |
1. Load htmlArea script in the <head>...</head> section of your
|
|
|
45 |
phpMyEdit calling program as described in the htmlarea manual.
|
|
|
46 |
|
|
|
47 |
NOTE: To avoid an unwanted side effect in css style produced
|
|
|
48 |
by phpMyEditSetup.php, delete 'table-width:100%' property.
|
|
|
49 |
|
|
|
50 |
2. Call to phpMyEdit-htmlarea.class.php instead
|
|
|
51 |
of phpMyEdit.class.php.
|
|
|
52 |
|
|
|
53 |
Example:
|
|
|
54 |
|
|
|
55 |
require_once 'extensions/phpMyEdit-htmlarea.class.php';
|
|
|
56 |
new phpMyEdit_htmlarea($opts);
|
|
|
57 |
|
|
|
58 |
3. Add 'html'=>true parameter to the textarea field definition
|
|
|
59 |
in your phpMyEdit calling program.
|
|
|
60 |
|
|
|
61 |
Example:
|
|
|
62 |
|
|
|
63 |
$opts['fdd']['col_name'] = array(
|
|
|
64 |
'name' => 'Column',
|
|
|
65 |
'select' => 'T',
|
|
|
66 |
'options' => 'ACPVD',
|
|
|
67 |
'required' => true,
|
|
|
68 |
'textarea' => array(
|
|
|
69 |
'html' => true,
|
|
|
70 |
'rows' => 11,
|
|
|
71 |
'cols' => 81)
|
|
|
72 |
);
|
|
|
73 |
|
|
|
74 |
SEARCH KEYWORD
|
|
|
75 |
--------------
|
|
|
76 |
|
|
|
77 |
Search for "htmlArea" string in this source code,
|
|
|
78 |
to find all extension related modifications.
|
|
|
79 |
*/
|
|
|
80 |
|
|
|
81 |
require_once dirname(__FILE__).'/../phpMyEdit.class.php';
|
|
|
82 |
|
|
|
83 |
class phpMyEdit_htmlarea extends phpMyEdit
|
|
|
84 |
{
|
|
|
85 |
|
|
|
86 |
/*
|
|
|
87 |
* Display functions overriding
|
|
|
88 |
*/
|
|
|
89 |
|
|
|
90 |
function display_add_record() /* {{{ */
|
|
|
91 |
{
|
|
|
92 |
for ($k = 0; $k < $this->num_fds; $k++) {
|
|
|
93 |
if ($this->hidden($k)) {
|
|
|
94 |
echo $this->htmlHidden($this->fds[$k], $row["qf$k"]);
|
|
|
95 |
continue;
|
|
|
96 |
}
|
|
|
97 |
if (! $this->displayed[$k]) {
|
|
|
98 |
continue;
|
|
|
99 |
}
|
|
|
100 |
$css_postfix = @$this->fdd[$k]['css']['postfix'];
|
|
|
101 |
$css_class_name = $this->getCSSclass('input', null, 'next', $css_postfix);
|
|
|
102 |
echo '<tr class="',$this->getCSSclass('row', null, true, $css_postfix),'">',"\n";
|
|
|
103 |
echo '<td class="',$this->getCSSclass('key', null, true, $css_postfix),'">',$this->fdd[$k]['name'],'</td>',"\n";
|
|
|
104 |
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'">'."\n";
|
|
|
105 |
if ($this->col_has_values($k)) {
|
|
|
106 |
$vals = $this->set_values($k);
|
|
|
107 |
$selected = @$this->fdd[$k]['default'];
|
|
|
108 |
$multiple = $this->fdd[$k]['select'] == 'M' && ! $this->fdd[$k]['values']['table'];
|
|
|
109 |
$readonly = $this->readonly($k);
|
|
|
110 |
echo $this->htmlSelect($this->fds[$k], $css_class_name, $vals, $selected, $multiple,$readonly);
|
|
|
111 |
} elseif (isset ($this->fdd[$k]['textarea'])) {
|
|
|
112 |
echo '<textarea class="',$css_class_name,'" name="'.$this->fds[$k].'"';
|
|
|
113 |
echo ($this->readonly($k) ? ' disabled' : '');
|
|
|
114 |
if (intval($this->fdd[$k]['textarea']['rows']) > 0) {
|
|
|
115 |
echo ' rows="',$this->fdd[$k]['textarea']['rows'],'"';
|
|
|
116 |
}
|
|
|
117 |
if (intval($this->fdd[$k]['textarea']['cols']) > 0) {
|
|
|
118 |
echo ' cols="',$this->fdd[$k]['textarea']['cols'],'"';
|
|
|
119 |
}
|
|
|
120 |
if (isset($this->fdd[$k]['textarea']['wrap'])) {
|
|
|
121 |
echo ' wrap="',$this->fdd[$k]['textarea']['wrap'],'"';
|
|
|
122 |
} else {
|
|
|
123 |
echo ' wrap="virtual"';
|
|
|
124 |
}
|
|
|
125 |
echo '>',htmlspecialchars($this->fdd[$k]['default']),'</textarea>',"\n";
|
|
|
126 |
|
|
|
127 |
// EK htmlArea code modification is here
|
|
|
128 |
if (isset($this->fdd[$k]['textarea']['html'])) {
|
|
|
129 |
echo '<script type="text/javascript" language="javascript1.2"><!--',"\n";
|
|
|
130 |
echo 'editor_generate("',$this->fds[$k],'");',"\n";
|
|
|
131 |
echo '// --></script>';
|
|
|
132 |
}
|
|
|
133 |
} else {
|
|
|
134 |
// Simple edit box required
|
|
|
135 |
$size_ml_props = '';
|
|
|
136 |
$maxlen = intval($this->fdd[$k]['maxlen']);
|
|
|
137 |
//$maxlen > 0 || $maxlen = 300;
|
|
|
138 |
$size = min($maxlen, 60);
|
|
|
139 |
$size && $size_ml_props .= ' size="'.$size.'"';
|
|
|
140 |
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"';
|
|
|
141 |
echo '<input class="',$css_class_name,'" type="text" ';
|
|
|
142 |
echo ($this->readonly($k) ? 'disabled ' : ''),' name="',$this->fds[$k],'"';
|
|
|
143 |
echo $size_ml_props,' value="';
|
|
|
144 |
echo htmlspecialchars($this->fdd[$k]['default']),'">';
|
|
|
145 |
}
|
|
|
146 |
echo '</td>',"\n";
|
|
|
147 |
if ($this->guidance) {
|
|
|
148 |
$css_class_name = $this->getCSSclass('help', null, true, $css_postfix);
|
|
|
149 |
$cell_value = $this->fdd[$k]['help'] ? $this->fdd[$k]['help'] : ' ';
|
|
|
150 |
echo '<td class="',$css_class_name,'">',$cell_value,'</td>',"\n";
|
|
|
151 |
}
|
|
|
152 |
echo '</tr>',"\n";
|
|
|
153 |
}
|
|
|
154 |
} /* }}} */
|
|
|
155 |
|
|
|
156 |
function display_change_field($row, $k) /* {{{ */
|
|
|
157 |
{
|
|
|
158 |
$css_postfix = @$this->fdd[$k]['css']['postfix'];
|
|
|
159 |
$css_class_name = $this->getCSSclass('input', null, true, $css_postfix);
|
|
|
160 |
echo '<td class="',$this->getCSSclass('value', null, true, $css_postfix),'">',"\n";
|
|
|
161 |
if ($this->col_has_values($k)) {
|
|
|
162 |
$vals = $this->set_values($k);
|
|
|
163 |
$multiple = $this->fdd[$k]['select'] == 'M' && ! $this->fdd[$k]['values']['table'];
|
|
|
164 |
$readonly = $this->readonly($k);
|
|
|
165 |
echo $this->htmlSelect($this->fds[$k], $css_class_name, $vals, $row["qf$k"], $multiple, $readonly);
|
|
|
166 |
} elseif (isset($this->fdd[$k]['textarea'])) {
|
|
|
167 |
echo '<textarea class="',$css_class_name,'" name="'.$this->fds[$k].'"';
|
|
|
168 |
echo ($this->readonly($k) ? ' disabled' : '');
|
|
|
169 |
if (intval($this->fdd[$k]['textarea']['rows']) > 0) {
|
|
|
170 |
echo ' rows="',$this->fdd[$k]['textarea']['rows'],'"';
|
|
|
171 |
}
|
|
|
172 |
if (intval($this->fdd[$k]['textarea']['cols']) > 0) {
|
|
|
173 |
echo ' cols="',$this->fdd[$k]['textarea']['cols'],'"';
|
|
|
174 |
}
|
|
|
175 |
if (isset($this->fdd[$k]['textarea']['wrap'])) {
|
|
|
176 |
echo ' wrap="',$this->fdd[$k]['textarea']['wrap'],'"';
|
|
|
177 |
} else {
|
|
|
178 |
echo ' wrap="virtual"';
|
|
|
179 |
}
|
|
|
180 |
echo '>',htmlspecialchars($row["qf$k"]),'</textarea>',"\n";
|
|
|
181 |
|
|
|
182 |
// EK htmlArea code modification is here
|
|
|
183 |
if (isset($this->fdd[$k]['textarea']['html'])) {
|
|
|
184 |
echo '<script type="text/javascript" language="javascript1.2"><!--',"\n";
|
|
|
185 |
echo 'editor_generate("',$this->fds[$k],'");',"\n";
|
|
|
186 |
echo '// --></script>';
|
|
|
187 |
}
|
|
|
188 |
} else {
|
|
|
189 |
$size_ml_props = '';
|
|
|
190 |
$maxlen = intval($this->fdd[$k]['maxlen']);
|
|
|
191 |
//$maxlen > 0 || $maxlen = 300;
|
|
|
192 |
$size = min($maxlen, 60);
|
|
|
193 |
$size && $size_ml_props .= ' size="'.$size.'"';
|
|
|
194 |
$maxlen && $size_ml_props .= ' maxlength="'.$maxlen.'"';
|
|
|
195 |
echo '<input class="',$css_class_name,'" type="text" ';
|
|
|
196 |
echo ($this->readonly($k) ? 'disabled ' : ''),'name="',$this->fds[$k],'" value="';
|
|
|
197 |
echo htmlspecialchars($row["qf$k"]),'" ',$size_ml_props,'>',"\n";
|
|
|
198 |
}
|
|
|
199 |
echo '</td>',"\n";
|
|
|
200 |
} /* }}} */
|
|
|
201 |
|
|
|
202 |
}
|
|
|
203 |
|
|
|
204 |
/* Modeline for ViM {{{
|
|
|
205 |
* vim:set ts=4:
|
|
|
206 |
* vim600:fdm=marker fdl=0 fdc=0:
|
|
|
207 |
* }}} */
|
|
|
208 |
|
|
|
209 |
?>
|