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