Merge lp:~julien-breux/automne/410a into lp:~automne-team/automne/trunk
- 410a
- Merge into trunk
Status: | Merged |
---|---|
Merge reported by: | Sébastien Pauchet |
Merged at revision: | not available |
Proposed branch: | lp:~julien-breux/automne/410a |
Merge into: | lp:~automne-team/automne/trunk |
Diff against target: |
858 lines (+294/-178) 5 files modified
CHANGELOG (+2/-1) automne/admin/rows-controler.php (+21/-5) automne/admin/templates-row.php (+22/-5) automne/classes/modules/standard/row.php (+18/-5) automne/classes/modules/standard/rowscatalog.php (+231/-162) |
To merge this branch: | bzr merge lp:~julien-breux/automne/410a |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Julien Breux (community) | Needs Resubmitting | ||
Sébastien Pauchet | Disapprove | ||
Review via email: mp+36420@code.launchpad.net |
This proposal supersedes a proposal from 2010-09-21.
Commit message
Description of the change
Fixed error loading images ;-)
Sébastien Pauchet (sebastien-pauchet) wrote : Posted in a previous version of this proposal | # |
Julien Breux (julien-breux) wrote : Posted in a previous version of this proposal | # |
> In file automne/
> imagePath:
> calculate image path because it can be used from automne/
> directories.
In this context, it's unable to use "Automne" object.
How do I ?
FN: It's same problem with "automne/
Sébastien Pauchet (sebastien-pauchet) wrote : Posted in a previous version of this proposal | # |
You should use Automne.
Sébastien Pauchet (sebastien-pauchet) wrote : Posted in a previous version of this proposal | # |
In file automne/
this.iconUp = this.imagePath + (this.iconUp || 'up2.gif');
All other changes are good
Julien Breux (julien-breux) wrote : Posted in a previous version of this proposal | # |
It's ok for me :)
Sébastien Pauchet (sebastien-pauchet) : Posted in a previous version of this proposal | # |
Sébastien Pauchet (sebastien-pauchet) wrote : | # |
In file automne/
Julien Breux (julien-breux) wrote : | # |
I'm sorry, but i thing that Automne is not i18n because this untranslated string exist too in automne/
I this this is irrelevant to the proposed feature ?
Sébastien Pauchet (sebastien-pauchet) wrote : | # |
ok this is a mistake, it should be translated too in automne/
I will test the rest of your proposal later today.
Julien Breux (julien-breux) wrote : | # |
No no, i leave you translate later on a run.
Thx 4 your time :)
Preview Diff
1 | === modified file 'CHANGELOG' |
2 | --- CHANGELOG 2010-09-06 16:07:24 +0000 |
3 | +++ CHANGELOG 2010-09-23 09:23:46 +0000 |
4 | @@ -5,6 +5,7 @@ |
5 | [FEATURE] : Add Google coordinates field for Polymod |
6 | [FEATURE] : Add vhost subfolder support for Automne installation |
7 | [FEATURE] : Add import/export of polymod modules structures |
8 | +[FEATURE] : Add duplicating rows |
9 | |
10 | V4.0.2 (25/05/2010) |
11 | [BUG] : Corrected bugs : 269, 270, 486, 497 (see http://www.automne.ws/bug/) |
12 | @@ -100,4 +101,4 @@ |
13 | [FEATURE] : Add mysql fulltext search on users, groups, templates, rows, standard and polymod modules |
14 | |
15 | --------------------------------------------------------- |
16 | -View V3.X.X changelog for previous Automne versions |
17 | \ No newline at end of file |
18 | +View V3.X.X changelog for previous Automne versions |
19 | |
20 | === modified file 'automne/admin/rows-controler.php' |
21 | --- automne/admin/rows-controler.php 2010-08-25 16:09:23 +0000 |
22 | +++ automne/admin/rows-controler.php 2010-09-23 09:23:46 +0000 |
23 | @@ -9,10 +9,8 @@ |
24 | // | LICENSE-GPL, and is available through the world-wide-web at | |
25 | // | http://www.gnu.org/copyleft/gpl.html. | |
26 | // +----------------------------------------------------------------------+ |
27 | -// | Author: Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr> | |
28 | +// | Author: Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr> | |
29 | // +----------------------------------------------------------------------+ |
30 | -// |
31 | -// $Id: rows-controler.php,v 1.6 2010/03/08 16:41:20 sebastien Exp $ |
32 | |
33 | /** |
34 | * PHP controler : Receive actions on templates |
35 | @@ -20,7 +18,8 @@ |
36 | * |
37 | * @package Automne |
38 | * @subpackage admin |
39 | - * @author Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr> |
40 | + * @author Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr> |
41 | + * @author Julien Breux <julien.breux@gmail.com> |
42 | */ |
43 | |
44 | require_once(dirname(__FILE__).'/../../cms_rc_admin.php'); |
45 | @@ -33,10 +32,11 @@ |
46 | define("MESSAGE_ACTION_XML_UPDATED", 732); |
47 | define("MESSAGE_ACTION_N_PAGES_REGEN", 733); |
48 | define("MESSAGE_ACTION_NO_PAGES", 734); |
49 | +define("MESSAGE_ACTION_DUPICATION_DONE", 1485); |
50 | define("MESSAGE_ERROR_WRITE_ROW", 1551); |
51 | |
52 | //Controler vars |
53 | -$action = sensitiveIO::request('action', array('properties', 'definition', 'regenerate')); |
54 | +$action = sensitiveIO::request('action', array('properties', 'definition', 'regenerate', 'copy')); |
55 | $rowId = sensitiveIO::request('rowId', ''); |
56 | |
57 | //Properties vars vars |
58 | @@ -185,6 +185,22 @@ |
59 | $cms_message = $cms_language->getMessage(MESSAGE_ACTION_NO_PAGES); |
60 | } |
61 | break; |
62 | + case 'copy': |
63 | + if (is_a($row, "CMS_row") && !$row->hasError()) { |
64 | + //Dupplicate selected row with given label |
65 | + $label = 'Copie de '.$row->getLabel(); |
66 | + $row = CMS_rowsCatalog::getCloneFromID($rowId, $label); |
67 | + |
68 | + $log = new CMS_log(); |
69 | + $log->logMiscAction(CMS_log::LOG_ACTION_TEMPLATE_EDIT, $cms_user, "Row : ".$label." (create row)"); |
70 | + |
71 | + $content = array('success' => array('rowId' => $row->getID())); |
72 | + $cms_message = $cms_language->getMessage(MESSAGE_ACTION_DUPICATION_DONE, array($label)); |
73 | + $view->setContent($content); |
74 | + } else { |
75 | + $cms_message = $cms_language->getMessage(MESSAGE_ERROR_UNKNOWN_ROW); |
76 | + } |
77 | + break; |
78 | } |
79 | |
80 | //set user message if any |
81 | |
82 | === modified file 'automne/admin/templates-row.php' |
83 | --- automne/admin/templates-row.php 2010-08-25 16:09:23 +0000 |
84 | +++ automne/admin/templates-row.php 2010-09-23 09:23:46 +0000 |
85 | @@ -9,10 +9,8 @@ |
86 | // | LICENSE-GPL, and is available through the world-wide-web at | |
87 | // | http://www.gnu.org/copyleft/gpl.html. | |
88 | // +----------------------------------------------------------------------+ |
89 | -// | Author: Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr> | |
90 | +// | Author: Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr> | |
91 | // +----------------------------------------------------------------------+ |
92 | -// |
93 | -// $Id: templates-row.php,v 1.12 2010/03/08 16:41:21 sebastien Exp $ |
94 | |
95 | /** |
96 | * PHP page : Load page rows search window. |
97 | @@ -20,7 +18,8 @@ |
98 | * |
99 | * @package Automne |
100 | * @subpackage admin |
101 | - * @author Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr> |
102 | + * @author Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr> |
103 | + * @author Julien Breux <julien.breux@gmail.com> |
104 | */ |
105 | |
106 | require_once(dirname(__FILE__).'/../../cms_rc_admin.php'); |
107 | @@ -49,6 +48,8 @@ |
108 | define("MESSAGE_PAGE_DESACTIVATE", 1518); |
109 | define("MESSAGE_PAGE_VIEW_INACTIVE_ROWS", 1522); |
110 | define("MESSAGE_PAGE_DELETE_CONFIRM", 1523); |
111 | +define("MESSAGE_PAGE_DUPLICATE", 1520); |
112 | +define("MESSAGE_ACTION_DUPLICATE_SELECTED", 1521); |
113 | |
114 | //load interface instance |
115 | $view = CMS_view::getInstance(); |
116 | @@ -380,7 +381,17 @@ |
117 | }, |
118 | scope: resultsPanel, |
119 | disabled: true |
120 | - }, '->', { |
121 | + },{ |
122 | + id: '{$winId}copyItem', |
123 | + xtype: 'button', |
124 | + text: '{$cms_language->getJSMessage(MESSAGE_PAGE_DUPLICATE)}', |
125 | + handler: function(button) { |
126 | + //copy selected template and then refresh search results |
127 | + Automne.server.call('rows-controler.php', rowWindow.search, {rowId:selectedObjects, action:'copy'}) |
128 | + }, |
129 | + scope: resultsPanel, |
130 | + disabled: true |
131 | + },'->', { |
132 | id: '{$winId}createItem', |
133 | xtype: 'button', |
134 | text: '{$cms_language->getJSMessage(MESSAGE_PAGE_NEW)}', |
135 | @@ -453,6 +464,10 @@ |
136 | target: Ext.getCmp('{$winId}createItem').getEl(), |
137 | html: '{$cms_language->getJSMessage(MESSAGE_ACTION_CREATE_SELECTED)}' |
138 | }); |
139 | + qtips['copy'] = new Ext.ToolTip({ |
140 | + target: Ext.getCmp('{$winId}copyItem').getEl(), |
141 | + html: '{$cms_language->getJSMessage(MESSAGE_ACTION_DUPLICATE_SELECTED)}' |
142 | + }); |
143 | |
144 | resultsPanel.dv.on('selectionchange', function(dv, selections){ |
145 | selectedObjects = []; |
146 | @@ -480,7 +495,9 @@ |
147 | Ext.getCmp('{$winId}deleteItem').disable(); |
148 | Ext.getCmp('{$winId}activateItem').disable(); |
149 | Ext.getCmp('{$winId}desactivateItem').disable(); |
150 | + Ext.getCmp('{$winId}copyItem').disable(); |
151 | } else { //enable / disable buttons allowed by selection |
152 | + Ext.getCmp('{$winId}copyItem').setDisabled(selectLen != 1); |
153 | Ext.getCmp('{$winId}editItem').enable(); |
154 | Ext.getCmp('{$winId}deleteItem').setDisabled(!hasDelete); |
155 | Ext.getCmp('{$winId}activateItem').setDisabled(!hasActivate); |
156 | |
157 | === modified file 'automne/classes/modules/standard/row.php' |
158 | --- automne/classes/modules/standard/row.php 2010-09-09 13:31:57 +0000 |
159 | +++ automne/classes/modules/standard/row.php 2010-09-23 09:23:46 +0000 |
160 | @@ -10,10 +10,8 @@ |
161 | // | http://www.gnu.org/copyleft/gpl.html. | |
162 | // +----------------------------------------------------------------------+ |
163 | // | Author: Antoine Pouch <antoine.pouch@ws-interactive.fr> & | |
164 | -// | Author: Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr> | |
165 | +// | Author: Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr> | |
166 | // +----------------------------------------------------------------------+ |
167 | -// |
168 | -// $Id: row.php,v 1.12 2010/03/08 16:43:29 sebastien Exp $ |
169 | |
170 | /** |
171 | * Class CMS_row |
172 | @@ -23,7 +21,8 @@ |
173 | * @package Automne |
174 | * @subpackage standard |
175 | * @author Antoine Pouch <antoine.pouch@ws-interactive.fr> & |
176 | - * @author Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr> |
177 | + * @author Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr> |
178 | + * @author Julien Breux <julien.breux@gmail.com> |
179 | */ |
180 | |
181 | class CMS_row extends CMS_grandFather |
182 | @@ -251,13 +250,18 @@ |
183 | /** |
184 | * Gets the row image. |
185 | * |
186 | + * @param string $form location of image |
187 | + * @param boolean $fileOnly for return just filename |
188 | * @return string the row image filename |
189 | * @access public |
190 | */ |
191 | - function getImage($from = CMS_file::WEBROOT) { |
192 | + function getImage($from = CMS_file::WEBROOT, $fileOnly = false) { |
193 | if (!file_exists(PATH_TEMPLATES_ROWS_FS.'/images/'.$this->_image)) { |
194 | $this->_image = 'nopicto.gif'; |
195 | } |
196 | + if ($fileOnly) { |
197 | + return $this->_image; |
198 | + } |
199 | return ($from == CMS_file::FILE_SYSTEM) ? PATH_TEMPLATES_ROWS_FS.'/images/'.$this->_image : PATH_TEMPLATES_ROWS_WR.'/images/'.$this->_image; |
200 | } |
201 | |
202 | @@ -552,6 +556,15 @@ |
203 | } |
204 | |
205 | /** |
206 | + * Set filename of row |
207 | + * |
208 | + * @param string $filename Filename |
209 | + */ |
210 | + public function setDefinitionFile($filename) { |
211 | + $this->_definitionFile = $filename; |
212 | + } |
213 | + |
214 | + /** |
215 | * Gets the data, using the specified visualization mode. |
216 | * The data is taken from the blocks and reintroduced into the definition file which may itself contain HTML instructions. |
217 | * |
218 | |
219 | === modified file 'automne/classes/modules/standard/rowscatalog.php' |
220 | --- automne/classes/modules/standard/rowscatalog.php 2010-09-06 15:20:52 +0000 |
221 | +++ automne/classes/modules/standard/rowscatalog.php 2010-09-23 09:23:46 +0000 |
222 | @@ -1,4 +1,5 @@ |
223 | <?php |
224 | + |
225 | // +----------------------------------------------------------------------+ |
226 | // | Automne (TM) | |
227 | // +----------------------------------------------------------------------+ |
228 | @@ -9,34 +10,30 @@ |
229 | // | LICENSE-GPL, and is available through the world-wide-web at | |
230 | // | http://www.gnu.org/copyleft/gpl.html. | |
231 | // +----------------------------------------------------------------------+ |
232 | - |
233 | // | Author: Antoine Pouch <antoine.pouch@ws-interactive.fr> | |
234 | // +----------------------------------------------------------------------+ |
235 | -// |
236 | -// $Id: rowscatalog.php,v 1.5 2010/03/08 16:43:29 sebastien Exp $ |
237 | |
238 | /** |
239 | - * Class CMS_rowsCatalog |
240 | - * |
241 | - * Represents a collection of rows |
242 | - * |
243 | - * @package Automne |
244 | - * @subpackage standard |
245 | - * @author Antoine Pouch <antoine.pouch@ws-interactive.fr> |
246 | - */ |
247 | + * Class CMS_rowsCatalog |
248 | + * |
249 | + * Represents a collection of rows |
250 | + * |
251 | + * @package Automne |
252 | + * @subpackage standard |
253 | + * @author Antoine Pouch <antoine.pouch@ws-interactive.fr> |
254 | + * @author Julien Breux <julien.breux@gmail.com> |
255 | + */ |
256 | +class CMS_rowsCatalog extends CMS_grandFather { |
257 | |
258 | -class CMS_rowsCatalog extends CMS_grandFather |
259 | -{ |
260 | /** |
261 | - * Return a row by its ID (and tagID) |
262 | - * |
263 | - * @param integer $id The DB ID of the wanted row |
264 | - * @param integer $tagID The tag ID attribute of the wanted row |
265 | - * @return CMS_row |
266 | - * @access public |
267 | - */ |
268 | - function getByID($id, $tagID = false) |
269 | - { |
270 | + * Return a row by its ID (and tagID) |
271 | + * |
272 | + * @param integer $id The DB ID of the wanted row |
273 | + * @param integer $tagID The tag ID attribute of the wanted row |
274 | + * @return CMS_row |
275 | + * @access public |
276 | + */ |
277 | + function getByID($id, $tagID = false) { |
278 | $row = new CMS_row($id, $tagID); |
279 | if (!$row->hasError()) { |
280 | return $row; |
281 | @@ -46,16 +43,16 @@ |
282 | } |
283 | |
284 | /** |
285 | - * Return all the rows available |
286 | - * |
287 | - * @param CMS_profile_user $cms_user : restrict to user rights on modules (default : false) |
288 | - * @param integer $tplId : restrict to rows usable in given template (default : false) |
289 | - * @param string $csId : restrict to rows usable in given clientspace (default : false) |
290 | - * @param integer $start : start position |
291 | - * @param integer $limit : limit position |
292 | - * @param integer $count : number of rows founded (passed by reference) |
293 | - * @access public |
294 | - */ |
295 | + * Return all the rows available |
296 | + * |
297 | + * @param CMS_profile_user $cms_user : restrict to user rights on modules (default : false) |
298 | + * @param integer $tplId : restrict to rows usable in given template (default : false) |
299 | + * @param string $csId : restrict to rows usable in given clientspace (default : false) |
300 | + * @param integer $start : start position |
301 | + * @param integer $limit : limit position |
302 | + * @param integer $count : number of rows founded (passed by reference) |
303 | + * @access public |
304 | + */ |
305 | function getAll($includeInactive = false, $keyword = '', $groups = array(), $rowIds = array(), $user = false, $tplId = false, $csId = false, $start = 0, $limit = 0, $returnObjects = true, &$score = array()) { |
306 | $select = 'id_row'; |
307 | $where = ''; |
308 | @@ -63,12 +60,12 @@ |
309 | if ($keyword) { |
310 | //clean user keywords (never trust user input, user is evil) |
311 | $keyword = strtr($keyword, ",;", " "); |
312 | - $words=array(); |
313 | - $words=array_map("trim",array_unique(explode(" ", io::strtolower($keyword)))); |
314 | + $words = array(); |
315 | + $words = array_map("trim", array_unique(explode(" ", io::strtolower($keyword)))); |
316 | $cleanedWords = array(); |
317 | foreach ($words as $aWord) { |
318 | - if ($aWord && $aWord!='' && io::strlen($aWord) >= 3) { |
319 | - $aWord = str_replace(array('%','_'), array('\%','\_'), $aWord); |
320 | + if ($aWord && $aWord != '' && io::strlen($aWord) >= 3) { |
321 | + $aWord = str_replace(array('%', '_'), array('\%', '\_'), $aWord); |
322 | $cleanedWords[] = $aWord; |
323 | } |
324 | } |
325 | @@ -78,53 +75,53 @@ |
326 | } |
327 | $keywordWhere = ''; |
328 | foreach ($cleanedWords as $cleanedWord) { |
329 | - $keywordWhere .= ($keywordWhere) ? ' and ' : ''; |
330 | + $keywordWhere .= ( $keywordWhere) ? ' and ' : ''; |
331 | $keywordWhere .= " ( |
332 | - description_row like '%".sensitiveIO::sanitizeSQLString($cleanedWord)."%' |
333 | - or label_row like '%".sensitiveIO::sanitizeSQLString($cleanedWord)."%' |
334 | + description_row like '%" . sensitiveIO::sanitizeSQLString($cleanedWord) . "%' |
335 | + or label_row like '%" . sensitiveIO::sanitizeSQLString($cleanedWord) . "%' |
336 | )"; |
337 | } |
338 | - $where .= ($where) ? ' and ' : ''; |
339 | - $where .= " ((".$keywordWhere.") or MATCH (label_row, description_row) AGAINST ('".sensitiveIO::sanitizeSQLString($keyword)."') )"; |
340 | - $select .= " , MATCH (label_row, description_row) AGAINST ('".sensitiveIO::sanitizeSQLString($keyword)."') as m "; |
341 | + $where .= ( $where) ? ' and ' : ''; |
342 | + $where .= " ((" . $keywordWhere . ") or MATCH (label_row, description_row) AGAINST ('" . sensitiveIO::sanitizeSQLString($keyword) . "') )"; |
343 | + $select .= " , MATCH (label_row, description_row) AGAINST ('" . sensitiveIO::sanitizeSQLString($keyword) . "') as m "; |
344 | } |
345 | $sql = " |
346 | select |
347 | - ".$select." |
348 | + " . $select . " |
349 | from |
350 | mod_standard_rows |
351 | "; |
352 | //groups |
353 | if ($groups) { |
354 | foreach ($groups as $group) { |
355 | - $where .= ($where) ? ' and ' : ''; |
356 | + $where .= ( $where) ? ' and ' : ''; |
357 | $where .= " ( |
358 | - groupsStack_row='".sensitiveIO::sanitizeSQLString($group)."' |
359 | - or groupsStack_row like '%;".sensitiveIO::sanitizeSQLString($group).";%' |
360 | - or groupsStack_row like '".sensitiveIO::sanitizeSQLString($group).";%' |
361 | - or groupsStack_row like '%;".sensitiveIO::sanitizeSQLString($group)."' |
362 | + groupsStack_row='" . sensitiveIO::sanitizeSQLString($group) . "' |
363 | + or groupsStack_row like '%;" . sensitiveIO::sanitizeSQLString($group) . ";%' |
364 | + or groupsStack_row like '" . sensitiveIO::sanitizeSQLString($group) . ";%' |
365 | + or groupsStack_row like '%;" . sensitiveIO::sanitizeSQLString($group) . "' |
366 | )"; |
367 | } |
368 | } |
369 | |
370 | //useable |
371 | if (!$includeInactive) { |
372 | - $where .= ($where) ? ' and ' : ''; |
373 | + $where .= ( $where) ? ' and ' : ''; |
374 | $where .= " useable_row=1 "; |
375 | } |
376 | //rowIds |
377 | if ($rowIds) { |
378 | - $where .= ($where) ? ' and ' : ''; |
379 | - $where .= " id_row in (".implode(',',$rowIds).") "; |
380 | + $where .= ( $where) ? ' and ' : ''; |
381 | + $where .= " id_row in (" . implode(',', $rowIds) . ") "; |
382 | } |
383 | if ($tplId) { |
384 | - $where .= ($where) ? ' and ' : ''; |
385 | + $where .= ( $where) ? ' and ' : ''; |
386 | $where .= " ( |
387 | tplfilter_row='' |
388 | - or tplfilter_row='".sensitiveIO::sanitizeSQLString($tplId)."' |
389 | - or tplfilter_row like '%;".sensitiveIO::sanitizeSQLString($tplId).";%' |
390 | - or tplfilter_row like '".sensitiveIO::sanitizeSQLString($tplId).";%' |
391 | - or tplfilter_row like '%;".sensitiveIO::sanitizeSQLString($tplId)."' |
392 | + or tplfilter_row='" . sensitiveIO::sanitizeSQLString($tplId) . "' |
393 | + or tplfilter_row like '%;" . sensitiveIO::sanitizeSQLString($tplId) . ";%' |
394 | + or tplfilter_row like '" . sensitiveIO::sanitizeSQLString($tplId) . ";%' |
395 | + or tplfilter_row like '%;" . sensitiveIO::sanitizeSQLString($tplId) . "' |
396 | ) "; |
397 | } |
398 | //user |
399 | @@ -132,20 +129,20 @@ |
400 | $groupsDenied = $user->getRowGroupsDenied(); |
401 | $groupsDenied = $groupsDenied->getElements(); |
402 | if ($groupsDenied) { |
403 | - $where .= ($where) ? ' and (' : '('; |
404 | + $where .= ( $where) ? ' and (' : '('; |
405 | foreach ($groupsDenied as $group) { |
406 | $where .= " ( |
407 | - groupsStack_row != '".sensitiveIO::sanitizeSQLString($group[0])."' |
408 | - and groupsStack_row not like '%;".sensitiveIO::sanitizeSQLString($group[0]).";%' |
409 | - and groupsStack_row not like '".sensitiveIO::sanitizeSQLString($group[0]).";%' |
410 | - and groupsStack_row not like '%;".sensitiveIO::sanitizeSQLString($group[0])."' |
411 | + groupsStack_row != '" . sensitiveIO::sanitizeSQLString($group[0]) . "' |
412 | + and groupsStack_row not like '%;" . sensitiveIO::sanitizeSQLString($group[0]) . ";%' |
413 | + and groupsStack_row not like '" . sensitiveIO::sanitizeSQLString($group[0]) . ";%' |
414 | + and groupsStack_row not like '%;" . sensitiveIO::sanitizeSQLString($group[0]) . "' |
415 | ) and"; |
416 | } |
417 | //remove last "or" and append ) |
418 | - $where = io::substr($where, 0, -3).')'; |
419 | + $where = io::substr($where, 0, -3) . ')'; |
420 | } |
421 | } |
422 | - $sql = $sql.($where ? ' where '.$where : ''); |
423 | + $sql = $sql . ($where ? ' where ' . $where : ''); |
424 | //order |
425 | if (io::strpos($sql, 'MATCH') === false) { |
426 | $sql .= " order by label_row "; |
427 | @@ -154,7 +151,7 @@ |
428 | } |
429 | //limit |
430 | if ($start || $limit) { |
431 | - $sql .= " limit ".sensitiveIO::sanitizeSQLString($start).",".sensitiveIO::sanitizeSQLString($limit); |
432 | + $sql .= " limit " . sensitiveIO::sanitizeSQLString($start) . "," . sensitiveIO::sanitizeSQLString($limit); |
433 | } |
434 | //pr($sql); |
435 | $q = new CMS_query($sql); |
436 | @@ -178,17 +175,17 @@ |
437 | } |
438 | |
439 | /** |
440 | - * Get All Groups |
441 | - * Static function |
442 | - * |
443 | - * @return array(string) |
444 | - * @access public |
445 | - */ |
446 | + * Get All Groups |
447 | + * Static function |
448 | + * |
449 | + * @return array(string) |
450 | + * @access public |
451 | + */ |
452 | function getAllGroups($returnStack = false, $reset = false) { |
453 | static $rowGroups; |
454 | if (!isset($rowGroups) || $reset) { |
455 | $rowGroups = array(); |
456 | - $sql =' |
457 | + $sql = ' |
458 | select distinct |
459 | groupsStack_row |
460 | from |
461 | @@ -200,7 +197,7 @@ |
462 | $groupStack = new CMS_stack(); |
463 | $groupStack->setTextDefinition($groupStackString); |
464 | foreach ($groupStack->getElements() as $group) { |
465 | - if (!SensitiveIO::isInSet($group[0],$rowGroups) && $group[0]) { |
466 | + if (!SensitiveIO::isInSet($group[0], $rowGroups) && $group[0]) { |
467 | $rowGroups[] = $group[0]; |
468 | } |
469 | } |
470 | @@ -219,29 +216,97 @@ |
471 | } |
472 | |
473 | /** |
474 | - * Return pages IDs coresponding of a given row ID |
475 | - * |
476 | - * @param integer rowID : the row to get pagesIDs |
477 | - * @param boolean returnObjects : to return pages objects or pages IDs |
478 | - * @param boolean public : targets edited or public clientspaces |
479 | - * @return array : pages IDs or pages objects |
480 | - * @access public |
481 | - */ |
482 | + * public static getCloneFromID |
483 | + * |
484 | + * Clones a Row, changes some attributes |
485 | + * and writes it to persistence (MySQL for now) |
486 | + * |
487 | + * @param anyRowID as the ID of Row to be cloned |
488 | + * @param String label receive a new label for this Row |
489 | + * @param boolean $setPrivate Should the template be set as a private one ? ALSO determines if the new row should point to the same file |
490 | + * @return a valid new CMS_row |
491 | + */ |
492 | + function getCloneFromID($rowID = 0, $label = false, $setPrivate = false) { |
493 | + $ret = false; |
494 | + $model = new CMS_row($rowID); |
495 | + if ($model->getID() > 0) { |
496 | + //New blank one |
497 | + $row = new CMS_row(); |
498 | + |
499 | + //First write a new object to get it's ID |
500 | + $row->writeToPersistence(); |
501 | + |
502 | + //Setting label |
503 | + $label = ($label) ? $label : $model->getLabel(); |
504 | + $row->setLabel($label); |
505 | + |
506 | + //Copying template definition file (if not private template) |
507 | + if ($setPrivate) { |
508 | + $filename = $model->getDefinitionFileName(); |
509 | + } else { |
510 | + $filename = "r" . $row->getID() . "_" . SensitiveIO::sanitizeAsciiString($row->getLabel()) . ".xml"; |
511 | + } |
512 | + if ($setPrivate || CMS_file::copyTo(PATH_ROWS_FS . "/" . $model->getDefinitionFileName(), PATH_ROWS_FS . "/" . $filename)) { |
513 | + $row->setDefinitionFile($filename); |
514 | + |
515 | + //Copying groupsStack from database |
516 | + foreach ($model->getGroups() as $grp) { |
517 | + $row->addGroup($grp); |
518 | + } |
519 | + |
520 | + //Copying image |
521 | + $row->setImage($model->getImage(CMS_file::WEBROOT, true)); |
522 | + |
523 | + //set private if asked to. |
524 | + if ($setPrivate) { |
525 | + $row->setPrivate(true); |
526 | + } |
527 | + //copy description |
528 | + $row->setDescription($model->getDescription()); |
529 | + |
530 | + //add filtered templates |
531 | + $row->setFilteredTemplates($model->getFilteredTemplates()); |
532 | + |
533 | + //Partial update for groups and image |
534 | + $row->writeToPersistence(); |
535 | + $ret = $row; |
536 | + } |
537 | + unset($model); |
538 | + } |
539 | + if ($row) { |
540 | + //Clean if any error when out |
541 | + if (!$ret) { |
542 | + $row->destroy(); |
543 | + } |
544 | + unset($row); |
545 | + } |
546 | + return $ret; |
547 | + } |
548 | + |
549 | + /** |
550 | + * Return pages IDs coresponding of a given row ID |
551 | + * |
552 | + * @param integer rowID : the row to get pagesIDs |
553 | + * @param boolean returnObjects : to return pages objects or pages IDs |
554 | + * @param boolean public : targets edited or public clientspaces |
555 | + * @return array : pages IDs or pages objects |
556 | + * @access public |
557 | + */ |
558 | function getPagesByRow($rowID, $returnObjects = false, $public = false) { |
559 | $return = array(); |
560 | - if(!SensitiveIO::isPositiveInteger($rowID)){ |
561 | + if (!SensitiveIO::isPositiveInteger($rowID)) { |
562 | CMS_grandFather::raiseError('rowID must be a positive integer'); |
563 | return $return; |
564 | } |
565 | $clientSpacesTable = ($public) ? 'mod_standard_clientSpaces_public' : 'mod_standard_clientSpaces_edited'; |
566 | - $sql=" |
567 | + $sql = " |
568 | select |
569 | distinct id_pag |
570 | from |
571 | pages, |
572 | - ".$clientSpacesTable." |
573 | + " . $clientSpacesTable . " |
574 | where |
575 | - type_cs = '".$rowID."' |
576 | + type_cs = '" . $rowID . "' |
577 | and template_cs = template_pag |
578 | order by |
579 | id_pag |
580 | @@ -249,8 +314,8 @@ |
581 | $q = new CMS_query($sql); |
582 | if ($q->getNumRows()) { |
583 | while ($id = $q->getValue('id_pag')) { |
584 | - if($returnObjects){ |
585 | - if($page = CMS_tree::getPageByID($id)){ |
586 | + if ($returnObjects) { |
587 | + if ($page = CMS_tree::getPageByID($id)) { |
588 | $return[$id] = $page; |
589 | } |
590 | } else { |
591 | @@ -262,16 +327,16 @@ |
592 | } |
593 | |
594 | /** |
595 | - * Return rows ID used by a given page |
596 | - * |
597 | - * @param integer pageId : the row to get pagesIDs |
598 | - * @param boolean returnObjects : to return rows objects or rows IDs (default : false) |
599 | - * @return array : rows IDs or rows objects |
600 | - * @access public |
601 | - */ |
602 | + * Return rows ID used by a given page |
603 | + * |
604 | + * @param integer pageId : the row to get pagesIDs |
605 | + * @param boolean returnObjects : to return rows objects or rows IDs (default : false) |
606 | + * @return array : rows IDs or rows objects |
607 | + * @access public |
608 | + */ |
609 | function getRowsByPage($pageId, $returnObjects = false) { |
610 | $rows = array(); |
611 | - if(!SensitiveIO::isPositiveInteger($pageId)){ |
612 | + if (!SensitiveIO::isPositiveInteger($pageId)) { |
613 | CMS_grandFather::raiseError('pageId must be a positive integer'); |
614 | return $rows; |
615 | } |
616 | @@ -281,14 +346,14 @@ |
617 | 'mod_standard_clientSpaces_edition' |
618 | ); |
619 | foreach ($clientSpacesTables as $clientSpacesTable) { |
620 | - $sql=" |
621 | + $sql = " |
622 | select |
623 | type_cs |
624 | from |
625 | pages, |
626 | - ".$clientSpacesTable." |
627 | + " . $clientSpacesTable . " |
628 | where |
629 | - id_pag = ".$pageId." |
630 | + id_pag = " . $pageId . " |
631 | and template_cs = template_pag |
632 | order by |
633 | type_cs |
634 | @@ -297,8 +362,8 @@ |
635 | if ($q->getNumRows()) { |
636 | while (($id = $q->getValue('type_cs')) !== false) { |
637 | if (!isset($rows[$id])) { |
638 | - if($returnObjects){ |
639 | - if($row = CMS_rowsCatalog::getByID($id)){ |
640 | + if ($returnObjects) { |
641 | + if ($row = CMS_rowsCatalog::getByID($id)) { |
642 | $rows[$id] = $row; |
643 | } |
644 | } else { |
645 | @@ -312,33 +377,35 @@ |
646 | } |
647 | |
648 | /** |
649 | - * Return all rows icons available on the server |
650 | - * |
651 | - * @return array : rows images path (from webroot) |
652 | - * @access public |
653 | - */ |
654 | + * Return all rows icons available on the server |
655 | + * |
656 | + * @return array : rows images path (from webroot) |
657 | + * @access public |
658 | + */ |
659 | function getAllIcons() { |
660 | //read img dir |
661 | $availableExtensions = array('gif', 'png', 'jpg'); |
662 | - try{ |
663 | - foreach ( new DirectoryIterator(PATH_TEMPLATES_ROWS_FS.'/images/') as $file) { |
664 | + try { |
665 | + foreach (new DirectoryIterator(PATH_TEMPLATES_ROWS_FS . '/images/') as $file) { |
666 | if ($file->isFile() && in_array(io::strtolower(pathinfo($file->getFilename(), PATHINFO_EXTENSION)), $availableExtensions)) { |
667 | - $images[] = PATH_TEMPLATES_ROWS_WR.'/images/'.$file->getFilename(); |
668 | + $images[] = PATH_TEMPLATES_ROWS_WR . '/images/' . $file->getFilename(); |
669 | } |
670 | } |
671 | - } catch(Exception $e) {} |
672 | + } catch (Exception $e) { |
673 | + |
674 | + } |
675 | |
676 | return $images; |
677 | } |
678 | - |
679 | + |
680 | /** |
681 | - * Return all rows which uses given modules |
682 | - * |
683 | - * @param array modules : the modules codename to search rows for |
684 | - * @param boolean returnObjects : does the function return array of ids or array of objects (default) |
685 | - * @return array : rows |
686 | - * @access public |
687 | - */ |
688 | + * Return all rows which uses given modules |
689 | + * |
690 | + * @param array modules : the modules codename to search rows for |
691 | + * @param boolean returnObjects : does the function return array of ids or array of objects (default) |
692 | + * @return array : rows |
693 | + * @access public |
694 | + */ |
695 | function getByModules($modules= array(), $returnObjects = true) { |
696 | if (!is_array($modules) && is_string($modules) && $modules) { |
697 | $modules = array($modules); |
698 | @@ -347,8 +414,8 @@ |
699 | CMS_grandFather::raiseError('No modules set'); |
700 | return array(); |
701 | } |
702 | - |
703 | - $sql =' |
704 | + |
705 | + $sql = ' |
706 | select |
707 | id_row, modulesStack_row |
708 | from |
709 | @@ -384,39 +451,39 @@ |
710 | } |
711 | return $rows; |
712 | } |
713 | - |
714 | + |
715 | /** |
716 | - * Import module from given array datas |
717 | - * |
718 | - * @param array $data The module datas to import |
719 | - * @param array $params The import parameters. |
720 | - * array( |
721 | - * module => false|true : the module to create rows (required) |
722 | - * create => false|true : create missing objects (default : true) |
723 | - * update => false|true : update existing objects (default : true) |
724 | - * files => false|true : use files from PATH_TMP_FS (default : true) |
725 | - * ) |
726 | - * @param CMS_language $cms_language The CMS_langage to use |
727 | - * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids |
728 | - * @param string $infos : Reference : The import infos returned |
729 | - * @return boolean : true on success, false on failure |
730 | - * @access public |
731 | - */ |
732 | + * Import module from given array datas |
733 | + * |
734 | + * @param array $data The module datas to import |
735 | + * @param array $params The import parameters. |
736 | + * array( |
737 | + * module => false|true : the module to create rows (required) |
738 | + * create => false|true : create missing objects (default : true) |
739 | + * update => false|true : update existing objects (default : true) |
740 | + * files => false|true : use files from PATH_TMP_FS (default : true) |
741 | + * ) |
742 | + * @param CMS_language $cms_language The CMS_langage to use |
743 | + * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids |
744 | + * @param string $infos : Reference : The import infos returned |
745 | + * @return boolean : true on success, false on failure |
746 | + * @access public |
747 | + */ |
748 | function fromArray($data, $params, $cms_language, &$idsRelation, &$infos) { |
749 | if (!isset($params['module'])) { |
750 | - $infos .= 'Error : missing module codename for rows importation ...'."\n"; |
751 | + $infos .= 'Error : missing module codename for rows importation ...' . "\n"; |
752 | return false; |
753 | } |
754 | $module = CMS_modulesCatalog::getByCodename($params['module']); |
755 | if ($module->hasError()) { |
756 | - $infos .= 'Error : invalid module for rows importation : '.$params['module']."\n"; |
757 | + $infos .= 'Error : invalid module for rows importation : ' . $params['module'] . "\n"; |
758 | return false; |
759 | } |
760 | $return = true; |
761 | foreach ($data as $rowDatas) { |
762 | $importType = ''; |
763 | if (isset($rowDatas['uuid']) |
764 | - && ($id = CMS_rowsCatalog::rowExists($params['module'], $rowDatas['uuid']))) { |
765 | + && ($id = CMS_rowsCatalog::rowExists($params['module'], $rowDatas['uuid']))) { |
766 | //row already exist : load it if we can update it |
767 | if (!isset($params['update']) || $params['update'] == true) { |
768 | $row = CMS_rowsCatalog::getByID($id); |
769 | @@ -433,25 +500,25 @@ |
770 | if (isset($row)) { |
771 | if ($row->fromArray($rowDatas, $params, $cms_language, $idsRelation, $infos)) { |
772 | $return &= true; |
773 | - $infos .= 'Row '.$row->getLabel().' successfully imported'.$importType."\n"; |
774 | + $infos .= 'Row ' . $row->getLabel() . ' successfully imported' . $importType . "\n"; |
775 | } else { |
776 | $return = false; |
777 | - $infos .= 'Error during import of row '.$rowDatas['id'].$importType."\n"; |
778 | + $infos .= 'Error during import of row ' . $rowDatas['id'] . $importType . "\n"; |
779 | } |
780 | } |
781 | } |
782 | return $return; |
783 | } |
784 | - |
785 | + |
786 | /** |
787 | - * Does a row exists with given parameters |
788 | - * this method is use by fromArray import method to know if an imported row already exist or not |
789 | - * |
790 | - * @param string $module The module codename to check |
791 | - * @param string $uuid The row uuid to check |
792 | - * @return mixed : integer id if exists, false otherwise |
793 | - * @access public |
794 | - */ |
795 | + * Does a row exists with given parameters |
796 | + * this method is use by fromArray import method to know if an imported row already exist or not |
797 | + * |
798 | + * @param string $module The module codename to check |
799 | + * @param string $uuid The row uuid to check |
800 | + * @return mixed : integer id if exists, false otherwise |
801 | + * @access public |
802 | + */ |
803 | function rowExists($module, $uuid) { |
804 | if (!$module) { |
805 | CMS_grandFather::raiseError("module must be set"); |
806 | @@ -467,11 +534,11 @@ |
807 | from |
808 | mod_standard_rows |
809 | where |
810 | - uuid_row='".io::sanitizeSQLString($uuid)."' |
811 | - and (modulesStack_row like '".io::sanitizeSQLString($module).";%' |
812 | - or modulesStack_row = '".io::sanitizeSQLString($module)."' |
813 | - or modulesStack_row like '%;".io::sanitizeSQLString($module)."' |
814 | - or modulesStack_row like '%;".io::sanitizeSQLString($module).";%' |
815 | + uuid_row='" . io::sanitizeSQLString($uuid) . "' |
816 | + and (modulesStack_row like '" . io::sanitizeSQLString($module) . ";%' |
817 | + or modulesStack_row = '" . io::sanitizeSQLString($module) . "' |
818 | + or modulesStack_row like '%;" . io::sanitizeSQLString($module) . "' |
819 | + or modulesStack_row like '%;" . io::sanitizeSQLString($module) . ";%' |
820 | ) |
821 | "); |
822 | if ($q->getNumRows()) { |
823 | @@ -479,14 +546,14 @@ |
824 | } |
825 | return false; |
826 | } |
827 | - |
828 | + |
829 | /** |
830 | - * Does given uuid already exists for rows |
831 | - * |
832 | - * @param string $uuid The uuid to check |
833 | - * @return boolean |
834 | - * @access public |
835 | - */ |
836 | + * Does given uuid already exists for rows |
837 | + * |
838 | + * @param string $uuid The uuid to check |
839 | + * @return boolean |
840 | + * @access public |
841 | + */ |
842 | function uuidExists($uuid) { |
843 | if (!$uuid) { |
844 | CMS_grandFather::raiseError("uuid must be set"); |
845 | @@ -498,9 +565,11 @@ |
846 | from |
847 | mod_standard_rows |
848 | where |
849 | - uuid_row='".io::sanitizeSQLString($uuid)."' |
850 | + uuid_row='" . io::sanitizeSQLString($uuid) . "' |
851 | "); |
852 | return $q->getNumRows() ? true : false; |
853 | } |
854 | + |
855 | } |
856 | + |
857 | ?> |
858 | \ No newline at end of file |
In file automne/ admin/js/ ext/MultiSelect .js "img/multiselec t/", should use the variable Automne. context. path to calculate image path because it can be used from automne/ admin/modules/ .../ directories.
imagePath: