Merge lp:~julien-breux/automne/410a into lp:~automne-team/automne/trunk

Proposed by Julien Breux
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
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.

Description of the change

Fixed error loading images ;-)

To post a comment you must log in.
Revision history for this message
Sébastien Pauchet (sebastien-pauchet) wrote : Posted in a previous version of this proposal

In file automne/admin/js/ext/MultiSelect.js
imagePath:"img/multiselect/", should use the variable Automne.context.path to calculate image path because it can be used from automne/admin/modules/.../ directories.

review: Disapprove
Revision history for this message
Julien Breux (julien-breux) wrote : Posted in a previous version of this proposal

> In file automne/admin/js/ext/MultiSelect.js
> imagePath:"img/multiselect/", should use the variable Automne.context.path to
> calculate image path because it can be used from automne/admin/modules/.../
> directories.

In this context, it's unable to use "Automne" object.

How do I ?

FN: It's same problem with "automne/admin/js/ext/conf.js", "Automne" object is undefined or not declared.

review: Needs Information
Revision history for this message
Sébastien Pauchet (sebastien-pauchet) wrote : Posted in a previous version of this proposal

You should use Automne.context.path directly in onRender method instead.

Revision history for this message
Sébastien Pauchet (sebastien-pauchet) wrote : Posted in a previous version of this proposal

In file automne/admin/js/ext/MultiSelect.js you mistakenly remove the following line (arround line 322) :
this.iconUp = this.imagePath + (this.iconUp || 'up2.gif');

All other changes are good

review: Disapprove
Revision history for this message
Julien Breux (julien-breux) wrote : Posted in a previous version of this proposal

It's ok for me :)

Revision history for this message
Sébastien Pauchet (sebastien-pauchet) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Sébastien Pauchet (sebastien-pauchet) wrote :

In file automne/admin/rows-controler.php : untranslated string "Copie de " arround line 185

review: Disapprove
Revision history for this message
Julien Breux (julien-breux) wrote :

I'm sorry, but i thing that Automne is not i18n because this untranslated string exist too in automne/admin/templates-controler.php file on line 367.

I this this is irrelevant to the proposed feature ?

Revision history for this message
Sébastien Pauchet (sebastien-pauchet) wrote :

ok this is a mistake, it should be translated too in automne/admin/templates-controler.php. I will translate this in the two files later unless you want to do it?
I will test the rest of your proposal later today.

Revision history for this message
Julien Breux (julien-breux) wrote :

No no, i leave you translate later on a run.

Thx 4 your time :)

review: Needs Resubmitting

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CHANGELOG'
--- CHANGELOG 2010-09-06 16:07:24 +0000
+++ CHANGELOG 2010-09-23 09:23:46 +0000
@@ -5,6 +5,7 @@
5[FEATURE] : Add Google coordinates field for Polymod5[FEATURE] : Add Google coordinates field for Polymod
6[FEATURE] : Add vhost subfolder support for Automne installation6[FEATURE] : Add vhost subfolder support for Automne installation
7[FEATURE] : Add import/export of polymod modules structures7[FEATURE] : Add import/export of polymod modules structures
8[FEATURE] : Add duplicating rows
89
9V4.0.2 (25/05/2010)10V4.0.2 (25/05/2010)
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/)
@@ -100,4 +101,4 @@
100[FEATURE] : Add mysql fulltext search on users, groups, templates, rows, standard and polymod modules101[FEATURE] : Add mysql fulltext search on users, groups, templates, rows, standard and polymod modules
101102
102---------------------------------------------------------103---------------------------------------------------------
103View V3.X.X changelog for previous Automne versions
104\ No newline at end of file104\ No newline at end of file
105View V3.X.X changelog for previous Automne versions
105106
=== modified file 'automne/admin/rows-controler.php'
--- automne/admin/rows-controler.php 2010-08-25 16:09:23 +0000
+++ automne/admin/rows-controler.php 2010-09-23 09:23:46 +0000
@@ -9,10 +9,8 @@
9// | LICENSE-GPL, and is available through the world-wide-web at |9// | LICENSE-GPL, and is available through the world-wide-web at |
10// | http://www.gnu.org/copyleft/gpl.html. |10// | http://www.gnu.org/copyleft/gpl.html. |
11// +----------------------------------------------------------------------+11// +----------------------------------------------------------------------+
12// | Author: Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr> |12// | Author: Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr> |
13// +----------------------------------------------------------------------+13// +----------------------------------------------------------------------+
14//
15// $Id: rows-controler.php,v 1.6 2010/03/08 16:41:20 sebastien Exp $
1614
17/**15/**
18 * PHP controler : Receive actions on templates16 * PHP controler : Receive actions on templates
@@ -20,7 +18,8 @@
20 *18 *
21 * @package Automne19 * @package Automne
22 * @subpackage admin20 * @subpackage admin
23 * @author Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr>21 * @author Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr>
22 * @author Julien Breux <julien.breux@gmail.com>
24 */23 */
2524
26require_once(dirname(__FILE__).'/../../cms_rc_admin.php');25require_once(dirname(__FILE__).'/../../cms_rc_admin.php');
@@ -33,10 +32,11 @@
33define("MESSAGE_ACTION_XML_UPDATED", 732);32define("MESSAGE_ACTION_XML_UPDATED", 732);
34define("MESSAGE_ACTION_N_PAGES_REGEN", 733);33define("MESSAGE_ACTION_N_PAGES_REGEN", 733);
35define("MESSAGE_ACTION_NO_PAGES", 734);34define("MESSAGE_ACTION_NO_PAGES", 734);
35define("MESSAGE_ACTION_DUPICATION_DONE", 1485);
36define("MESSAGE_ERROR_WRITE_ROW", 1551);36define("MESSAGE_ERROR_WRITE_ROW", 1551);
3737
38//Controler vars38//Controler vars
39$action = sensitiveIO::request('action', array('properties', 'definition', 'regenerate'));39$action = sensitiveIO::request('action', array('properties', 'definition', 'regenerate', 'copy'));
40$rowId = sensitiveIO::request('rowId', '');40$rowId = sensitiveIO::request('rowId', '');
4141
42//Properties vars vars42//Properties vars vars
@@ -185,6 +185,22 @@
185 $cms_message = $cms_language->getMessage(MESSAGE_ACTION_NO_PAGES);185 $cms_message = $cms_language->getMessage(MESSAGE_ACTION_NO_PAGES);
186 }186 }
187 break;187 break;
188 case 'copy':
189 if (is_a($row, "CMS_row") && !$row->hasError()) {
190 //Dupplicate selected row with given label
191 $label = 'Copie de '.$row->getLabel();
192 $row = CMS_rowsCatalog::getCloneFromID($rowId, $label);
193
194 $log = new CMS_log();
195 $log->logMiscAction(CMS_log::LOG_ACTION_TEMPLATE_EDIT, $cms_user, "Row : ".$label." (create row)");
196
197 $content = array('success' => array('rowId' => $row->getID()));
198 $cms_message = $cms_language->getMessage(MESSAGE_ACTION_DUPICATION_DONE, array($label));
199 $view->setContent($content);
200 } else {
201 $cms_message = $cms_language->getMessage(MESSAGE_ERROR_UNKNOWN_ROW);
202 }
203 break;
188}204}
189205
190//set user message if any206//set user message if any
191207
=== modified file 'automne/admin/templates-row.php'
--- automne/admin/templates-row.php 2010-08-25 16:09:23 +0000
+++ automne/admin/templates-row.php 2010-09-23 09:23:46 +0000
@@ -9,10 +9,8 @@
9// | LICENSE-GPL, and is available through the world-wide-web at |9// | LICENSE-GPL, and is available through the world-wide-web at |
10// | http://www.gnu.org/copyleft/gpl.html. |10// | http://www.gnu.org/copyleft/gpl.html. |
11// +----------------------------------------------------------------------+11// +----------------------------------------------------------------------+
12// | Author: Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr> |12// | Author: Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr> |
13// +----------------------------------------------------------------------+13// +----------------------------------------------------------------------+
14//
15// $Id: templates-row.php,v 1.12 2010/03/08 16:41:21 sebastien Exp $
1614
17/**15/**
18 * PHP page : Load page rows search window.16 * PHP page : Load page rows search window.
@@ -20,7 +18,8 @@
20 *18 *
21 * @package Automne19 * @package Automne
22 * @subpackage admin20 * @subpackage admin
23 * @author Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr>21 * @author Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr>
22 * @author Julien Breux <julien.breux@gmail.com>
24 */23 */
2524
26require_once(dirname(__FILE__).'/../../cms_rc_admin.php');25require_once(dirname(__FILE__).'/../../cms_rc_admin.php');
@@ -49,6 +48,8 @@
49define("MESSAGE_PAGE_DESACTIVATE", 1518);48define("MESSAGE_PAGE_DESACTIVATE", 1518);
50define("MESSAGE_PAGE_VIEW_INACTIVE_ROWS", 1522);49define("MESSAGE_PAGE_VIEW_INACTIVE_ROWS", 1522);
51define("MESSAGE_PAGE_DELETE_CONFIRM", 1523);50define("MESSAGE_PAGE_DELETE_CONFIRM", 1523);
51define("MESSAGE_PAGE_DUPLICATE", 1520);
52define("MESSAGE_ACTION_DUPLICATE_SELECTED", 1521);
5253
53//load interface instance54//load interface instance
54$view = CMS_view::getInstance();55$view = CMS_view::getInstance();
@@ -380,7 +381,17 @@
380 },381 },
381 scope: resultsPanel,382 scope: resultsPanel,
382 disabled: true383 disabled: true
383 }, '->', {384 },{
385 id: '{$winId}copyItem',
386 xtype: 'button',
387 text: '{$cms_language->getJSMessage(MESSAGE_PAGE_DUPLICATE)}',
388 handler: function(button) {
389 //copy selected template and then refresh search results
390 Automne.server.call('rows-controler.php', rowWindow.search, {rowId:selectedObjects, action:'copy'})
391 },
392 scope: resultsPanel,
393 disabled: true
394 },'->', {
384 id: '{$winId}createItem',395 id: '{$winId}createItem',
385 xtype: 'button',396 xtype: 'button',
386 text: '{$cms_language->getJSMessage(MESSAGE_PAGE_NEW)}',397 text: '{$cms_language->getJSMessage(MESSAGE_PAGE_NEW)}',
@@ -453,6 +464,10 @@
453 target: Ext.getCmp('{$winId}createItem').getEl(),464 target: Ext.getCmp('{$winId}createItem').getEl(),
454 html: '{$cms_language->getJSMessage(MESSAGE_ACTION_CREATE_SELECTED)}'465 html: '{$cms_language->getJSMessage(MESSAGE_ACTION_CREATE_SELECTED)}'
455 });466 });
467 qtips['copy'] = new Ext.ToolTip({
468 target: Ext.getCmp('{$winId}copyItem').getEl(),
469 html: '{$cms_language->getJSMessage(MESSAGE_ACTION_DUPLICATE_SELECTED)}'
470 });
456471
457 resultsPanel.dv.on('selectionchange', function(dv, selections){472 resultsPanel.dv.on('selectionchange', function(dv, selections){
458 selectedObjects = [];473 selectedObjects = [];
@@ -480,7 +495,9 @@
480 Ext.getCmp('{$winId}deleteItem').disable();495 Ext.getCmp('{$winId}deleteItem').disable();
481 Ext.getCmp('{$winId}activateItem').disable();496 Ext.getCmp('{$winId}activateItem').disable();
482 Ext.getCmp('{$winId}desactivateItem').disable();497 Ext.getCmp('{$winId}desactivateItem').disable();
498 Ext.getCmp('{$winId}copyItem').disable();
483 } else { //enable / disable buttons allowed by selection499 } else { //enable / disable buttons allowed by selection
500 Ext.getCmp('{$winId}copyItem').setDisabled(selectLen != 1);
484 Ext.getCmp('{$winId}editItem').enable();501 Ext.getCmp('{$winId}editItem').enable();
485 Ext.getCmp('{$winId}deleteItem').setDisabled(!hasDelete);502 Ext.getCmp('{$winId}deleteItem').setDisabled(!hasDelete);
486 Ext.getCmp('{$winId}activateItem').setDisabled(!hasActivate);503 Ext.getCmp('{$winId}activateItem').setDisabled(!hasActivate);
487504
=== modified file 'automne/classes/modules/standard/row.php'
--- automne/classes/modules/standard/row.php 2010-09-09 13:31:57 +0000
+++ automne/classes/modules/standard/row.php 2010-09-23 09:23:46 +0000
@@ -10,10 +10,8 @@
10// | http://www.gnu.org/copyleft/gpl.html. |10// | http://www.gnu.org/copyleft/gpl.html. |
11// +----------------------------------------------------------------------+11// +----------------------------------------------------------------------+
12// | Author: Antoine Pouch <antoine.pouch@ws-interactive.fr> & |12// | Author: Antoine Pouch <antoine.pouch@ws-interactive.fr> & |
13// | Author: Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr> |13// | Author: Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr> |
14// +----------------------------------------------------------------------+14// +----------------------------------------------------------------------+
15//
16// $Id: row.php,v 1.12 2010/03/08 16:43:29 sebastien Exp $
1715
18/**16/**
19 * Class CMS_row17 * Class CMS_row
@@ -23,7 +21,8 @@
23 * @package Automne21 * @package Automne
24 * @subpackage standard22 * @subpackage standard
25 * @author Antoine Pouch <antoine.pouch@ws-interactive.fr> &23 * @author Antoine Pouch <antoine.pouch@ws-interactive.fr> &
26 * @author Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr>24 * @author Sébastien Pauchet <sebastien.pauchet@ws-interactive.fr>
25 * @author Julien Breux <julien.breux@gmail.com>
27 */26 */
2827
29class CMS_row extends CMS_grandFather28class CMS_row extends CMS_grandFather
@@ -251,13 +250,18 @@
251 /**250 /**
252 * Gets the row image.251 * Gets the row image.
253 *252 *
253 * @param string $form location of image
254 * @param boolean $fileOnly for return just filename
254 * @return string the row image filename255 * @return string the row image filename
255 * @access public256 * @access public
256 */257 */
257 function getImage($from = CMS_file::WEBROOT) {258 function getImage($from = CMS_file::WEBROOT, $fileOnly = false) {
258 if (!file_exists(PATH_TEMPLATES_ROWS_FS.'/images/'.$this->_image)) {259 if (!file_exists(PATH_TEMPLATES_ROWS_FS.'/images/'.$this->_image)) {
259 $this->_image = 'nopicto.gif';260 $this->_image = 'nopicto.gif';
260 }261 }
262 if ($fileOnly) {
263 return $this->_image;
264 }
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;
262 }266 }
263267
@@ -552,6 +556,15 @@
552 }556 }
553557
554 /**558 /**
559 * Set filename of row
560 *
561 * @param string $filename Filename
562 */
563 public function setDefinitionFile($filename) {
564 $this->_definitionFile = $filename;
565 }
566
567 /**
555 * Gets the data, using the specified visualization mode.568 * Gets the data, using the specified visualization mode.
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.
557 *570 *
558571
=== modified file 'automne/classes/modules/standard/rowscatalog.php'
--- automne/classes/modules/standard/rowscatalog.php 2010-09-06 15:20:52 +0000
+++ automne/classes/modules/standard/rowscatalog.php 2010-09-23 09:23:46 +0000
@@ -1,4 +1,5 @@
1<?php1<?php
2
2// +----------------------------------------------------------------------+3// +----------------------------------------------------------------------+
3// | Automne (TM) |4// | Automne (TM) |
4// +----------------------------------------------------------------------+5// +----------------------------------------------------------------------+
@@ -9,34 +10,30 @@
9// | LICENSE-GPL, and is available through the world-wide-web at |10// | LICENSE-GPL, and is available through the world-wide-web at |
10// | http://www.gnu.org/copyleft/gpl.html. |11// | http://www.gnu.org/copyleft/gpl.html. |
11// +----------------------------------------------------------------------+12// +----------------------------------------------------------------------+
12
13// | Author: Antoine Pouch <antoine.pouch@ws-interactive.fr> |13// | Author: Antoine Pouch <antoine.pouch@ws-interactive.fr> |
14// +----------------------------------------------------------------------+14// +----------------------------------------------------------------------+
15//
16// $Id: rowscatalog.php,v 1.5 2010/03/08 16:43:29 sebastien Exp $
1715
18/**16/**
19 * Class CMS_rowsCatalog17 * Class CMS_rowsCatalog
20 *18 *
21 * Represents a collection of rows19 * Represents a collection of rows
22 *20 *
23 * @package Automne21 * @package Automne
24 * @subpackage standard22 * @subpackage standard
25 * @author Antoine Pouch <antoine.pouch@ws-interactive.fr>23 * @author Antoine Pouch <antoine.pouch@ws-interactive.fr>
26 */24 * @author Julien Breux <julien.breux@gmail.com>
25 */
26class CMS_rowsCatalog extends CMS_grandFather {
2727
28class CMS_rowsCatalog extends CMS_grandFather
29{
30 /**28 /**
31 * Return a row by its ID (and tagID)29 * Return a row by its ID (and tagID)
32 *30 *
33 * @param integer $id The DB ID of the wanted row31 * @param integer $id The DB ID of the wanted row
34 * @param integer $tagID The tag ID attribute of the wanted row32 * @param integer $tagID The tag ID attribute of the wanted row
35 * @return CMS_row33 * @return CMS_row
36 * @access public34 * @access public
37 */35 */
38 function getByID($id, $tagID = false)36 function getByID($id, $tagID = false) {
39 {
40 $row = new CMS_row($id, $tagID);37 $row = new CMS_row($id, $tagID);
41 if (!$row->hasError()) {38 if (!$row->hasError()) {
42 return $row;39 return $row;
@@ -46,16 +43,16 @@
46 }43 }
4744
48 /**45 /**
49 * Return all the rows available46 * Return all the rows available
50 *47 *
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)
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)
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)
54 * @param integer $start : start position51 * @param integer $start : start position
55 * @param integer $limit : limit position52 * @param integer $limit : limit position
56 * @param integer $count : number of rows founded (passed by reference)53 * @param integer $count : number of rows founded (passed by reference)
57 * @access public54 * @access public
58 */55 */
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()) {
60 $select = 'id_row';57 $select = 'id_row';
61 $where = '';58 $where = '';
@@ -63,12 +60,12 @@
63 if ($keyword) {60 if ($keyword) {
64 //clean user keywords (never trust user input, user is evil)61 //clean user keywords (never trust user input, user is evil)
65 $keyword = strtr($keyword, ",;", " ");62 $keyword = strtr($keyword, ",;", " ");
66 $words=array();63 $words = array();
67 $words=array_map("trim",array_unique(explode(" ", io::strtolower($keyword))));64 $words = array_map("trim", array_unique(explode(" ", io::strtolower($keyword))));
68 $cleanedWords = array();65 $cleanedWords = array();
69 foreach ($words as $aWord) {66 foreach ($words as $aWord) {
70 if ($aWord && $aWord!='' && io::strlen($aWord) >= 3) {67 if ($aWord && $aWord != '' && io::strlen($aWord) >= 3) {
71 $aWord = str_replace(array('%','_'), array('\%','\_'), $aWord);68 $aWord = str_replace(array('%', '_'), array('\%', '\_'), $aWord);
72 $cleanedWords[] = $aWord;69 $cleanedWords[] = $aWord;
73 }70 }
74 }71 }
@@ -78,53 +75,53 @@
78 }75 }
79 $keywordWhere = '';76 $keywordWhere = '';
80 foreach ($cleanedWords as $cleanedWord) {77 foreach ($cleanedWords as $cleanedWord) {
81 $keywordWhere .= ($keywordWhere) ? ' and ' : '';78 $keywordWhere .= ( $keywordWhere) ? ' and ' : '';
82 $keywordWhere .= " (79 $keywordWhere .= " (
83 description_row like '%".sensitiveIO::sanitizeSQLString($cleanedWord)."%'80 description_row like '%" . sensitiveIO::sanitizeSQLString($cleanedWord) . "%'
84 or label_row like '%".sensitiveIO::sanitizeSQLString($cleanedWord)."%'81 or label_row like '%" . sensitiveIO::sanitizeSQLString($cleanedWord) . "%'
85 )";82 )";
86 }83 }
87 $where .= ($where) ? ' and ' : '';84 $where .= ( $where) ? ' and ' : '';
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) . "') )";
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 ";
90 }87 }
91 $sql = "88 $sql = "
92 select89 select
93 ".$select."90 " . $select . "
94 from91 from
95 mod_standard_rows92 mod_standard_rows
96 ";93 ";
97 //groups94 //groups
98 if ($groups) {95 if ($groups) {
99 foreach ($groups as $group) {96 foreach ($groups as $group) {
100 $where .= ($where) ? ' and ' : '';97 $where .= ( $where) ? ' and ' : '';
101 $where .= " (98 $where .= " (
102 groupsStack_row='".sensitiveIO::sanitizeSQLString($group)."'99 groupsStack_row='" . sensitiveIO::sanitizeSQLString($group) . "'
103 or groupsStack_row like '%;".sensitiveIO::sanitizeSQLString($group).";%'100 or groupsStack_row like '%;" . sensitiveIO::sanitizeSQLString($group) . ";%'
104 or groupsStack_row like '".sensitiveIO::sanitizeSQLString($group).";%'101 or groupsStack_row like '" . sensitiveIO::sanitizeSQLString($group) . ";%'
105 or groupsStack_row like '%;".sensitiveIO::sanitizeSQLString($group)."'102 or groupsStack_row like '%;" . sensitiveIO::sanitizeSQLString($group) . "'
106 )";103 )";
107 }104 }
108 }105 }
109106
110 //useable107 //useable
111 if (!$includeInactive) {108 if (!$includeInactive) {
112 $where .= ($where) ? ' and ' : '';109 $where .= ( $where) ? ' and ' : '';
113 $where .= " useable_row=1 ";110 $where .= " useable_row=1 ";
114 }111 }
115 //rowIds112 //rowIds
116 if ($rowIds) {113 if ($rowIds) {
117 $where .= ($where) ? ' and ' : '';114 $where .= ( $where) ? ' and ' : '';
118 $where .= " id_row in (".implode(',',$rowIds).") ";115 $where .= " id_row in (" . implode(',', $rowIds) . ") ";
119 }116 }
120 if ($tplId) {117 if ($tplId) {
121 $where .= ($where) ? ' and ' : '';118 $where .= ( $where) ? ' and ' : '';
122 $where .= " (119 $where .= " (
123 tplfilter_row=''120 tplfilter_row=''
124 or tplfilter_row='".sensitiveIO::sanitizeSQLString($tplId)."'121 or tplfilter_row='" . sensitiveIO::sanitizeSQLString($tplId) . "'
125 or tplfilter_row like '%;".sensitiveIO::sanitizeSQLString($tplId).";%'122 or tplfilter_row like '%;" . sensitiveIO::sanitizeSQLString($tplId) . ";%'
126 or tplfilter_row like '".sensitiveIO::sanitizeSQLString($tplId).";%'123 or tplfilter_row like '" . sensitiveIO::sanitizeSQLString($tplId) . ";%'
127 or tplfilter_row like '%;".sensitiveIO::sanitizeSQLString($tplId)."'124 or tplfilter_row like '%;" . sensitiveIO::sanitizeSQLString($tplId) . "'
128 ) ";125 ) ";
129 }126 }
130 //user127 //user
@@ -132,20 +129,20 @@
132 $groupsDenied = $user->getRowGroupsDenied();129 $groupsDenied = $user->getRowGroupsDenied();
133 $groupsDenied = $groupsDenied->getElements();130 $groupsDenied = $groupsDenied->getElements();
134 if ($groupsDenied) {131 if ($groupsDenied) {
135 $where .= ($where) ? ' and (' : '(';132 $where .= ( $where) ? ' and (' : '(';
136 foreach ($groupsDenied as $group) {133 foreach ($groupsDenied as $group) {
137 $where .= " (134 $where .= " (
138 groupsStack_row != '".sensitiveIO::sanitizeSQLString($group[0])."'135 groupsStack_row != '" . sensitiveIO::sanitizeSQLString($group[0]) . "'
139 and groupsStack_row not like '%;".sensitiveIO::sanitizeSQLString($group[0]).";%'136 and groupsStack_row not like '%;" . sensitiveIO::sanitizeSQLString($group[0]) . ";%'
140 and groupsStack_row not like '".sensitiveIO::sanitizeSQLString($group[0]).";%'137 and groupsStack_row not like '" . sensitiveIO::sanitizeSQLString($group[0]) . ";%'
141 and groupsStack_row not like '%;".sensitiveIO::sanitizeSQLString($group[0])."'138 and groupsStack_row not like '%;" . sensitiveIO::sanitizeSQLString($group[0]) . "'
142 ) and";139 ) and";
143 }140 }
144 //remove last "or" and append )141 //remove last "or" and append )
145 $where = io::substr($where, 0, -3).')';142 $where = io::substr($where, 0, -3) . ')';
146 }143 }
147 }144 }
148 $sql = $sql.($where ? ' where '.$where : '');145 $sql = $sql . ($where ? ' where ' . $where : '');
149 //order146 //order
150 if (io::strpos($sql, 'MATCH') === false) {147 if (io::strpos($sql, 'MATCH') === false) {
151 $sql .= " order by label_row ";148 $sql .= " order by label_row ";
@@ -154,7 +151,7 @@
154 }151 }
155 //limit152 //limit
156 if ($start || $limit) {153 if ($start || $limit) {
157 $sql .= " limit ".sensitiveIO::sanitizeSQLString($start).",".sensitiveIO::sanitizeSQLString($limit);154 $sql .= " limit " . sensitiveIO::sanitizeSQLString($start) . "," . sensitiveIO::sanitizeSQLString($limit);
158 }155 }
159 //pr($sql);156 //pr($sql);
160 $q = new CMS_query($sql);157 $q = new CMS_query($sql);
@@ -178,17 +175,17 @@
178 }175 }
179176
180 /**177 /**
181 * Get All Groups178 * Get All Groups
182 * Static function179 * Static function
183 *180 *
184 * @return array(string)181 * @return array(string)
185 * @access public182 * @access public
186 */183 */
187 function getAllGroups($returnStack = false, $reset = false) {184 function getAllGroups($returnStack = false, $reset = false) {
188 static $rowGroups;185 static $rowGroups;
189 if (!isset($rowGroups) || $reset) {186 if (!isset($rowGroups) || $reset) {
190 $rowGroups = array();187 $rowGroups = array();
191 $sql ='188 $sql = '
192 select distinct189 select distinct
193 groupsStack_row190 groupsStack_row
194 from191 from
@@ -200,7 +197,7 @@
200 $groupStack = new CMS_stack();197 $groupStack = new CMS_stack();
201 $groupStack->setTextDefinition($groupStackString);198 $groupStack->setTextDefinition($groupStackString);
202 foreach ($groupStack->getElements() as $group) {199 foreach ($groupStack->getElements() as $group) {
203 if (!SensitiveIO::isInSet($group[0],$rowGroups) && $group[0]) {200 if (!SensitiveIO::isInSet($group[0], $rowGroups) && $group[0]) {
204 $rowGroups[] = $group[0];201 $rowGroups[] = $group[0];
205 }202 }
206 }203 }
@@ -219,29 +216,97 @@
219 }216 }
220217
221 /**218 /**
222 * Return pages IDs coresponding of a given row ID219 * public static getCloneFromID
223 *220 *
224 * @param integer rowID : the row to get pagesIDs221 * Clones a Row, changes some attributes
225 * @param boolean returnObjects : to return pages objects or pages IDs222 * and writes it to persistence (MySQL for now)
226 * @param boolean public : targets edited or public clientspaces223 *
227 * @return array : pages IDs or pages objects224 * @param anyRowID as the ID of Row to be cloned
228 * @access public225 * @param String label receive a new label for this Row
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
227 * @return a valid new CMS_row
228 */
229 function getCloneFromID($rowID = 0, $label = false, $setPrivate = false) {
230 $ret = false;
231 $model = new CMS_row($rowID);
232 if ($model->getID() > 0) {
233 //New blank one
234 $row = new CMS_row();
235
236 //First write a new object to get it's ID
237 $row->writeToPersistence();
238
239 //Setting label
240 $label = ($label) ? $label : $model->getLabel();
241 $row->setLabel($label);
242
243 //Copying template definition file (if not private template)
244 if ($setPrivate) {
245 $filename = $model->getDefinitionFileName();
246 } else {
247 $filename = "r" . $row->getID() . "_" . SensitiveIO::sanitizeAsciiString($row->getLabel()) . ".xml";
248 }
249 if ($setPrivate || CMS_file::copyTo(PATH_ROWS_FS . "/" . $model->getDefinitionFileName(), PATH_ROWS_FS . "/" . $filename)) {
250 $row->setDefinitionFile($filename);
251
252 //Copying groupsStack from database
253 foreach ($model->getGroups() as $grp) {
254 $row->addGroup($grp);
255 }
256
257 //Copying image
258 $row->setImage($model->getImage(CMS_file::WEBROOT, true));
259
260 //set private if asked to.
261 if ($setPrivate) {
262 $row->setPrivate(true);
263 }
264 //copy description
265 $row->setDescription($model->getDescription());
266
267 //add filtered templates
268 $row->setFilteredTemplates($model->getFilteredTemplates());
269
270 //Partial update for groups and image
271 $row->writeToPersistence();
272 $ret = $row;
273 }
274 unset($model);
275 }
276 if ($row) {
277 //Clean if any error when out
278 if (!$ret) {
279 $row->destroy();
280 }
281 unset($row);
282 }
283 return $ret;
284 }
285
286 /**
287 * Return pages IDs coresponding of a given row ID
288 *
289 * @param integer rowID : the row to get pagesIDs
290 * @param boolean returnObjects : to return pages objects or pages IDs
291 * @param boolean public : targets edited or public clientspaces
292 * @return array : pages IDs or pages objects
293 * @access public
294 */
230 function getPagesByRow($rowID, $returnObjects = false, $public = false) {295 function getPagesByRow($rowID, $returnObjects = false, $public = false) {
231 $return = array();296 $return = array();
232 if(!SensitiveIO::isPositiveInteger($rowID)){297 if (!SensitiveIO::isPositiveInteger($rowID)) {
233 CMS_grandFather::raiseError('rowID must be a positive integer');298 CMS_grandFather::raiseError('rowID must be a positive integer');
234 return $return;299 return $return;
235 }300 }
236 $clientSpacesTable = ($public) ? 'mod_standard_clientSpaces_public' : 'mod_standard_clientSpaces_edited';301 $clientSpacesTable = ($public) ? 'mod_standard_clientSpaces_public' : 'mod_standard_clientSpaces_edited';
237 $sql="302 $sql = "
238 select303 select
239 distinct id_pag304 distinct id_pag
240 from305 from
241 pages,306 pages,
242 ".$clientSpacesTable."307 " . $clientSpacesTable . "
243 where308 where
244 type_cs = '".$rowID."'309 type_cs = '" . $rowID . "'
245 and template_cs = template_pag310 and template_cs = template_pag
246 order by311 order by
247 id_pag312 id_pag
@@ -249,8 +314,8 @@
249 $q = new CMS_query($sql);314 $q = new CMS_query($sql);
250 if ($q->getNumRows()) {315 if ($q->getNumRows()) {
251 while ($id = $q->getValue('id_pag')) {316 while ($id = $q->getValue('id_pag')) {
252 if($returnObjects){317 if ($returnObjects) {
253 if($page = CMS_tree::getPageByID($id)){318 if ($page = CMS_tree::getPageByID($id)) {
254 $return[$id] = $page;319 $return[$id] = $page;
255 }320 }
256 } else {321 } else {
@@ -262,16 +327,16 @@
262 }327 }
263328
264 /**329 /**
265 * Return rows ID used by a given page330 * Return rows ID used by a given page
266 *331 *
267 * @param integer pageId : the row to get pagesIDs332 * @param integer pageId : the row to get pagesIDs
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)
269 * @return array : rows IDs or rows objects334 * @return array : rows IDs or rows objects
270 * @access public335 * @access public
271 */336 */
272 function getRowsByPage($pageId, $returnObjects = false) {337 function getRowsByPage($pageId, $returnObjects = false) {
273 $rows = array();338 $rows = array();
274 if(!SensitiveIO::isPositiveInteger($pageId)){339 if (!SensitiveIO::isPositiveInteger($pageId)) {
275 CMS_grandFather::raiseError('pageId must be a positive integer');340 CMS_grandFather::raiseError('pageId must be a positive integer');
276 return $rows;341 return $rows;
277 }342 }
@@ -281,14 +346,14 @@
281 'mod_standard_clientSpaces_edition'346 'mod_standard_clientSpaces_edition'
282 );347 );
283 foreach ($clientSpacesTables as $clientSpacesTable) {348 foreach ($clientSpacesTables as $clientSpacesTable) {
284 $sql="349 $sql = "
285 select350 select
286 type_cs351 type_cs
287 from352 from
288 pages,353 pages,
289 ".$clientSpacesTable."354 " . $clientSpacesTable . "
290 where355 where
291 id_pag = ".$pageId."356 id_pag = " . $pageId . "
292 and template_cs = template_pag357 and template_cs = template_pag
293 order by358 order by
294 type_cs359 type_cs
@@ -297,8 +362,8 @@
297 if ($q->getNumRows()) {362 if ($q->getNumRows()) {
298 while (($id = $q->getValue('type_cs')) !== false) {363 while (($id = $q->getValue('type_cs')) !== false) {
299 if (!isset($rows[$id])) {364 if (!isset($rows[$id])) {
300 if($returnObjects){365 if ($returnObjects) {
301 if($row = CMS_rowsCatalog::getByID($id)){366 if ($row = CMS_rowsCatalog::getByID($id)) {
302 $rows[$id] = $row;367 $rows[$id] = $row;
303 }368 }
304 } else {369 } else {
@@ -312,33 +377,35 @@
312 }377 }
313378
314 /**379 /**
315 * Return all rows icons available on the server380 * Return all rows icons available on the server
316 *381 *
317 * @return array : rows images path (from webroot)382 * @return array : rows images path (from webroot)
318 * @access public383 * @access public
319 */384 */
320 function getAllIcons() {385 function getAllIcons() {
321 //read img dir386 //read img dir
322 $availableExtensions = array('gif', 'png', 'jpg');387 $availableExtensions = array('gif', 'png', 'jpg');
323 try{388 try {
324 foreach ( new DirectoryIterator(PATH_TEMPLATES_ROWS_FS.'/images/') as $file) {389 foreach (new DirectoryIterator(PATH_TEMPLATES_ROWS_FS . '/images/') as $file) {
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)) {
326 $images[] = PATH_TEMPLATES_ROWS_WR.'/images/'.$file->getFilename();391 $images[] = PATH_TEMPLATES_ROWS_WR . '/images/' . $file->getFilename();
327 }392 }
328 }393 }
329 } catch(Exception $e) {}394 } catch (Exception $e) {
395
396 }
330397
331 return $images;398 return $images;
332 }399 }
333 400
334 /**401 /**
335 * Return all rows which uses given modules402 * Return all rows which uses given modules
336 *403 *
337 * @param array modules : the modules codename to search rows for404 * @param array modules : the modules codename to search rows for
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)
339 * @return array : rows406 * @return array : rows
340 * @access public407 * @access public
341 */408 */
342 function getByModules($modules= array(), $returnObjects = true) {409 function getByModules($modules= array(), $returnObjects = true) {
343 if (!is_array($modules) && is_string($modules) && $modules) {410 if (!is_array($modules) && is_string($modules) && $modules) {
344 $modules = array($modules);411 $modules = array($modules);
@@ -347,8 +414,8 @@
347 CMS_grandFather::raiseError('No modules set');414 CMS_grandFather::raiseError('No modules set');
348 return array();415 return array();
349 }416 }
350 417
351 $sql ='418 $sql = '
352 select 419 select
353 id_row, modulesStack_row420 id_row, modulesStack_row
354 from421 from
@@ -384,39 +451,39 @@
384 }451 }
385 return $rows;452 return $rows;
386 }453 }
387 454
388 /**455 /**
389 * Import module from given array datas456 * Import module from given array datas
390 *457 *
391 * @param array $data The module datas to import458 * @param array $data The module datas to import
392 * @param array $params The import parameters.459 * @param array $params The import parameters.
393 * array(460 * array(
394 * module => false|true : the module to create rows (required)461 * module => false|true : the module to create rows (required)
395 * create => false|true : create missing objects (default : true)462 * create => false|true : create missing objects (default : true)
396 * update => false|true : update existing objects (default : true)463 * update => false|true : update existing objects (default : true)
397 * files => false|true : use files from PATH_TMP_FS (default : true)464 * files => false|true : use files from PATH_TMP_FS (default : true)
398 * )465 * )
399 * @param CMS_language $cms_language The CMS_langage to use466 * @param CMS_language $cms_language The CMS_langage to use
400 * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids467 * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids
401 * @param string $infos : Reference : The import infos returned468 * @param string $infos : Reference : The import infos returned
402 * @return boolean : true on success, false on failure469 * @return boolean : true on success, false on failure
403 * @access public470 * @access public
404 */471 */
405 function fromArray($data, $params, $cms_language, &$idsRelation, &$infos) {472 function fromArray($data, $params, $cms_language, &$idsRelation, &$infos) {
406 if (!isset($params['module'])) {473 if (!isset($params['module'])) {
407 $infos .= 'Error : missing module codename for rows importation ...'."\n";474 $infos .= 'Error : missing module codename for rows importation ...' . "\n";
408 return false;475 return false;
409 }476 }
410 $module = CMS_modulesCatalog::getByCodename($params['module']);477 $module = CMS_modulesCatalog::getByCodename($params['module']);
411 if ($module->hasError()) {478 if ($module->hasError()) {
412 $infos .= 'Error : invalid module for rows importation : '.$params['module']."\n";479 $infos .= 'Error : invalid module for rows importation : ' . $params['module'] . "\n";
413 return false;480 return false;
414 }481 }
415 $return = true;482 $return = true;
416 foreach ($data as $rowDatas) {483 foreach ($data as $rowDatas) {
417 $importType = '';484 $importType = '';
418 if (isset($rowDatas['uuid'])485 if (isset($rowDatas['uuid'])
419 && ($id = CMS_rowsCatalog::rowExists($params['module'], $rowDatas['uuid']))) {486 && ($id = CMS_rowsCatalog::rowExists($params['module'], $rowDatas['uuid']))) {
420 //row already exist : load it if we can update it487 //row already exist : load it if we can update it
421 if (!isset($params['update']) || $params['update'] == true) {488 if (!isset($params['update']) || $params['update'] == true) {
422 $row = CMS_rowsCatalog::getByID($id);489 $row = CMS_rowsCatalog::getByID($id);
@@ -433,25 +500,25 @@
433 if (isset($row)) {500 if (isset($row)) {
434 if ($row->fromArray($rowDatas, $params, $cms_language, $idsRelation, $infos)) {501 if ($row->fromArray($rowDatas, $params, $cms_language, $idsRelation, $infos)) {
435 $return &= true;502 $return &= true;
436 $infos .= 'Row '.$row->getLabel().' successfully imported'.$importType."\n";503 $infos .= 'Row ' . $row->getLabel() . ' successfully imported' . $importType . "\n";
437 } else {504 } else {
438 $return = false;505 $return = false;
439 $infos .= 'Error during import of row '.$rowDatas['id'].$importType."\n";506 $infos .= 'Error during import of row ' . $rowDatas['id'] . $importType . "\n";
440 }507 }
441 }508 }
442 }509 }
443 return $return;510 return $return;
444 }511 }
445 512
446 /**513 /**
447 * Does a row exists with given parameters514 * Does a row exists with given parameters
448 * this method is use by fromArray import method to know if an imported row already exist or not515 * this method is use by fromArray import method to know if an imported row already exist or not
449 *516 *
450 * @param string $module The module codename to check517 * @param string $module The module codename to check
451 * @param string $uuid The row uuid to check518 * @param string $uuid The row uuid to check
452 * @return mixed : integer id if exists, false otherwise519 * @return mixed : integer id if exists, false otherwise
453 * @access public520 * @access public
454 */521 */
455 function rowExists($module, $uuid) {522 function rowExists($module, $uuid) {
456 if (!$module) {523 if (!$module) {
457 CMS_grandFather::raiseError("module must be set");524 CMS_grandFather::raiseError("module must be set");
@@ -467,11 +534,11 @@
467 from 534 from
468 mod_standard_rows 535 mod_standard_rows
469 where536 where
470 uuid_row='".io::sanitizeSQLString($uuid)."'537 uuid_row='" . io::sanitizeSQLString($uuid) . "'
471 and (modulesStack_row like '".io::sanitizeSQLString($module).";%'538 and (modulesStack_row like '" . io::sanitizeSQLString($module) . ";%'
472 or modulesStack_row = '".io::sanitizeSQLString($module)."'539 or modulesStack_row = '" . io::sanitizeSQLString($module) . "'
473 or modulesStack_row like '%;".io::sanitizeSQLString($module)."'540 or modulesStack_row like '%;" . io::sanitizeSQLString($module) . "'
474 or modulesStack_row like '%;".io::sanitizeSQLString($module).";%'541 or modulesStack_row like '%;" . io::sanitizeSQLString($module) . ";%'
475 )542 )
476 ");543 ");
477 if ($q->getNumRows()) {544 if ($q->getNumRows()) {
@@ -479,14 +546,14 @@
479 }546 }
480 return false;547 return false;
481 }548 }
482 549
483 /**550 /**
484 * Does given uuid already exists for rows551 * Does given uuid already exists for rows
485 *552 *
486 * @param string $uuid The uuid to check553 * @param string $uuid The uuid to check
487 * @return boolean554 * @return boolean
488 * @access public555 * @access public
489 */556 */
490 function uuidExists($uuid) {557 function uuidExists($uuid) {
491 if (!$uuid) {558 if (!$uuid) {
492 CMS_grandFather::raiseError("uuid must be set");559 CMS_grandFather::raiseError("uuid must be set");
@@ -498,9 +565,11 @@
498 from 565 from
499 mod_standard_rows 566 mod_standard_rows
500 where567 where
501 uuid_row='".io::sanitizeSQLString($uuid)."'568 uuid_row='" . io::sanitizeSQLString($uuid) . "'
502 ");569 ");
503 return $q->getNumRows() ? true : false;570 return $q->getNumRows() ? true : false;
504 }571 }
572
505}573}
574
506?>575?>
507\ No newline at end of file576\ No newline at end of file

Subscribers

People subscribed via source and target branches