Exemple #1
0
 /**
  * Get the filename and optionnaly path of a file given its original name
  * Cleans the name and add the directory where files should reside (when page is un USERSPACE location)
  *
  * @param string $originalName The original name of the file
  * @param CMS_page &$page The page which contains the block
  * @param string &$clientspace The clientspace which contains the block
  * @param string &$row The row which contains the block
  * @param string &$block The block
  * @param boolean $withPath If false, only the filename will be returned
  * @param boolean $isEnlarged Is it the enlarged image we want the path of ?
  * @return string The full pathname
  * @access private
  */
 function getFilePath($originalName, &$page, &$clientspace, &$row, &$block, $withPath = true, $isEnlarged = false)
 {
     $name = md5(mt_rand() . microtime());
     $name .= SensitiveIO::sanitizeAsciiString($originalName);
     $name = "p" . $page->getID() . "_" . $name;
     if (io::strlen($name) > 255) {
         $name = sensitiveIO::ellipsis($name, 255, '-', true);
     }
     if ($withPath) {
         return PATH_MODULES_FILES_STANDARD_FS . "/edition/" . $name;
     } else {
         return $name;
     }
 }
    /**
     * get HTML admin (used to enter object values in admin)
     *
     * @param integer $fieldID, the current field id (only for poly object compatibility)
     * @param CMS_language $language, the current admin language
     * @param string prefixname : the prefix to use for post names
     * @return string : the html admin
     * @access public
     */
    function getHTMLAdmin($fieldID, $language, $prefixName)
    {
        //get module codename
        $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
        //is this field mandatory ?
        $mandatory = $this->_field->getValue('required') ? '<span class="atm-red">*</span> ' : '';
        $desc = $this->getFieldDescription($language);
        if (POLYMOD_DEBUG) {
            $values = array();
            foreach (array_keys($this->_subfieldValues) as $subFieldID) {
                if (is_object($this->_subfieldValues[$subFieldID])) {
                    $values[$subFieldID] = sensitiveIO::ellipsis(strip_tags($this->_subfieldValues[$subFieldID]->getValue()), 50);
                }
            }
            $desc .= $desc ? '<br />' : '';
            $desc .= '<span class="atm-red">Field : ' . $fieldID . ' - Value(s) : <ul>';
            foreach ($values as $subFieldID => $value) {
                $desc .= '<li>' . $subFieldID . '&nbsp;:&nbsp;' . $value . '</li>';
            }
            $desc .= '</ul></span>';
        }
        $label = $desc ? '<span class="atm-help" ext:qtip="' . io::htmlspecialchars($desc) . '">' . $mandatory . $this->getFieldLabel($language) . '</span>' : $mandatory . $this->getFieldLabel($language);
        $ids = 'oembed-' . md5(mt_rand() . microtime());
        $oembedURL = PATH_ADMIN_MODULES_WR . '/' . MOD_POLYMOD_CODENAME . '/oembed.php';
        $loadingURL = PATH_ADMIN_IMAGES_WR . '/loading-old.gif';
        $params = $this->getParamsValues();
        $fields = array();
        $fields[] = array('fieldLabel' => '<span class="atm-help" ext:qtip="' . io::htmlspecialchars($language->getMessage(self::MESSAGE_OBJECT_OEMBED_MEDIA_URL_DESC, false, MOD_POLYMOD_CODENAME)) . '">' . $language->getMessage(self::MESSAGE_OBJECT_OEMBED_MEDIA_URL, false, MOD_POLYMOD_CODENAME) . '</span>', 'xtype' => 'textfield', 'name' => 'polymodFieldsValue[' . $prefixName . $this->_field->getID() . '_0]', 'value' => $this->_subfieldValues[0]->getValue() ? sensitiveIO::decodeEntities($this->_subfieldValues[0]->getValue()) : '', 'enableKeyEvents' => true, 'listeners' => array('blur' => array('fn' => sensitiveIO::sanitizeJSString('function(el){
						/*call server for oembed HTML content*/
						Ext.get(\'' . $ids . '-view\').update(\'<img src="' . $loadingURL . '" />\');
						Automne.server.call({
							url:			\'' . $oembedURL . '\',
							scope:			this,
							fcnCallback:	function(response, options, htmlResponse){
								Ext.get(\'' . $ids . '-view\').update(htmlResponse);
							},
							params:			{
								module:			\'' . $moduleCodename . '\',
								url:			el.getValue(),
								width:			600,
								height:			250,
								key:			\'' . $params['embedlyKey'] . '\'
							}
						});
					}', false, false), 'buffer' => 600)));
        $fields[] = array('xtype' => 'panel', 'border' => false, 'html' => '<div id="' . $ids . '-view" style="overflow:auto;text-align:center;">' . ($this->getValue('hasValue') ? $this->getValue('html', '600,250') : '') . '</div>');
        $return = array();
        $return = array('title' => $label, 'xtype' => 'fieldset', 'autoHeight' => true, 'defaultType' => 'textfield', 'defaults' => array('anchor' => '97%', 'allowBlank' => !$this->_field->getValue('required')), 'items' => $fields);
        return $return;
    }
 /**
  * get HTML admin (used to enter object values in admin)
  *
  * @param integer $fieldID, the current field id (only for poly object compatibility)
  * @param CMS_language $language, the current admin language
  * @param string prefixname : the prefix to use for post names
  * @return string : the html admin
  * @access public
  */
 function getHTMLAdmin($fieldID, $language, $prefixName)
 {
     //is this field mandatory ?
     $mandatory = $this->_field->getValue('required') ? '<span class="atm-red">*</span> ' : '';
     $desc = $this->getFieldDescription($language);
     if (POLYMOD_DEBUG) {
         $values = array();
         foreach (array_keys($this->_subfieldValues) as $subFieldID) {
             if (is_object($this->_subfieldValues[$subFieldID])) {
                 $values[$subFieldID] = sensitiveIO::ellipsis(strip_tags($this->_subfieldValues[$subFieldID]->getValue()), 50);
             }
         }
         $desc .= $desc ? '<br />' : '';
         $desc .= '<span class="atm-red">Field : ' . $fieldID . ' - Value(s) : <ul>';
         foreach ($values as $subFieldID => $value) {
             $desc .= '<li>' . $subFieldID . '&nbsp;:&nbsp;' . $value . '</li>';
         }
         $desc .= '</ul></span>';
     }
     $label = $desc ? '<span class="atm-help" ext:qtip="' . io::htmlspecialchars($desc) . '">' . $mandatory . $this->getFieldLabel($language) . '</span>' : $mandatory . $this->getFieldLabel($language);
     $return = array();
     if (sizeof($this->_subfields) === 1) {
         $return = array('allowBlank' => !$this->_field->getValue('required'), 'fieldLabel' => $label, 'xtype' => 'textfield', 'name' => 'polymodFieldsValue[' . $prefixName . $this->_field->getID() . '_0]', 'value' => $this->_subfieldValues[0]->getValue() ? sensitiveIO::decodeEntities($this->_subfieldValues[0]->getValue()) : '');
     } else {
         $fields = array();
         foreach ($this->_subfields as $subFieldID => $subFieldDefinition) {
             if (is_object($this->_subfieldValues[$subFieldID])) {
                 $fields[] = array('hideLabel' => true, 'xtype' => 'textfield', 'name' => 'polymodFieldsValue[' . $prefixName . $this->_field->getID() . '_' . $subFieldID . ']', 'value' => $this->_subfieldValues[$subFieldID]->getValue() ? sensitiveIO::decodeEntities($this->_subfieldValues[$subFieldID]->getValue()) : '');
             }
         }
         $return = array('title' => $label, 'xtype' => 'fieldset', 'autoHeight' => true, 'defaultType' => 'textfield', 'defaults' => array('anchor' => '97%', 'allowBlank' => !$this->_field->getValue('required')), 'items' => $fields);
     }
     return $return;
 }
Exemple #4
0
 function getJSonDescription($user, $cms_language, $withDefinition = false)
 {
     //get websites
     $websites = CMS_websitesCatalog::getAll();
     $hasPages = $this->hasPages();
     $websitesList = '';
     $websitesDenied = $this->getWebsitesDenied();
     foreach ($websites as $id => $website) {
         if (!isset($websitesDenied[$id])) {
             $websitesList .= $websitesList ? ', ' : '';
             $websitesList .= $website->getLabel();
         }
     }
     /*$shortdesc = sensitiveIO::ellipsis($this->getDescription(), 60);
     		if ($shortdesc != nl2br($this->getDescription())) {
     			$shortdesc = '<span class="atm-help" ext:qtip="'.nl2br(io::htmlspecialchars($this->getDescription())).'">'.$shortdesc.'</span>';
     		}
     		$shortdesc = $shortdesc ? $shortdesc.'<br />' : '';*/
     $mediumdesc = sensitiveIO::ellipsis($this->getDescription(), 200);
     if ($mediumdesc != $this->getDescription()) {
         $mediumdesc = '<span class="atm-help" ext:qtip="' . nl2br(io::htmlspecialchars(strip_tags($this->getDescription()))) . '">' . nl2br(io::htmlspecialchars($mediumdesc)) . '</span>';
     } else {
         $mediumdesc = io::htmlspecialchars($mediumdesc);
     }
     $mediumdesc = $mediumdesc ? $mediumdesc . '<br />' : '';
     //append template definition if needed
     $definitionDatas = $withDefinition ? $this->getDefinition() : '';
     if ($user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDIT_TEMPLATES)) {
         $edit = array('url' => 'template.php', 'params' => array('template' => $this->getID()));
     } else {
         $edit = false;
     }
     return array('id' => $this->getID(), 'label' => $this->getLabel(), 'type' => $cms_language->getMessage(self::MESSAGE_DESC_TEMPLATE), 'image' => PATH_TEMPLATES_IMAGES_WR . '/' . ($this->getImage() ? $this->getImage() : 'nopicto.gif'), 'groups' => implode(', ', $this->getGroups()), 'websites' => $websitesList, 'desc' => io::htmlspecialchars($this->getDescription()), 'filter' => $this->getLabel() . ' ' . implode(', ', $this->getGroups()), 'description' => '<div' . (!$this->isUseable() ? ' class="atm-inactive"' : '') . '>' . '<img src="' . (PATH_TEMPLATES_IMAGES_WR . '/' . ($this->getImage() ? $this->getImage() : 'nopicto.gif')) . '" style="float:left;margin-right:3px;width:80px;" />' . $mediumdesc . $cms_language->getMessage(self::MESSAGE_DESC_WEBSITES) . ' <strong>' . $websitesList . '</strong><br />' . $cms_language->getMessage(self::MESSAGE_DESC_GROUPS) . ' <strong>' . ($this->getGroups() ? implode(', ', $this->getGroups()) : $cms_language->getMessage(self::MESSAGE_DESC_NONE)) . '</strong><br />' . $cms_language->getMessage(self::MESSAGE_DESC_ACTIVE) . ' <strong>' . ($this->isUseable() ? $cms_language->getMessage(self::MESSAGE_DESC_YES) : $cms_language->getMessage(self::MESSAGE_DESC_NO)) . '</strong><br />' . $cms_language->getMessage(self::MESSAGE_DESC_USED) . ' <strong>' . ($hasPages ? $cms_language->getMessage(self::MESSAGE_DESC_YES) : $cms_language->getMessage(self::MESSAGE_DESC_NO)) . '</strong>' . ($hasPages ? ' - <a href="#" onclick="Automne.view.search(\'template:' . $this->getID() . '\');return false;">' . $cms_language->getMessage(self::MESSAGE_DESC_SEE) . '</a>' . ($user->hasAdminClearance(CLEARANCE_ADMINISTRATION_REGENERATEPAGES) ? ' / <a href="#" onclick="Automne.server.call(\'templates-controler.php\', \'\', {templateId:' . $this->getID() . ', action:\'regenerate\'});return false;">' . $cms_language->getMessage(self::MESSAGE_DESC_REGENERATE) . '</a>' : '') . ' ' . $cms_language->getMessage(self::MESSAGE_DESC_PAGES) : '') . '<br />' . $cms_language->getMessage(self::MESSAGE_DESC_XML_FILE) . ': <strong>' . ($this->getDefinitionFile() ? $this->getDefinitionFile() : $cms_language->getMessage(self::MESSAGE_DESC_NONE)) . '</strong>' . '<br class="x-form-clear" />' . '</div>', 'activated' => $this->isUseable() ? true : false, 'used' => $hasPages, 'definition' => $definitionDatas, 'edit' => $edit);
 }
    /**
     * get HTML admin (used to enter object values in admin)
     *
     * @param CMS_language $language, the current admin language
     * @param string prefixname : the prefix to use for post names
     * @return string : the html admin
     * @access public
     */
    function getHTMLAdmin($fieldID, $language, $prefixName)
    {
        global $cms_user;
        $params = $this->getParamsValues();
        //is this field mandatory ?
        $mandatory = $this->_field->getValue('required') ? '<span class="atm-red">*</span> ' : '';
        $desc = $this->getFieldDescription($language);
        if (POLYMOD_DEBUG) {
            $values = array();
            foreach (array_keys($this->_subfieldValues) as $subFieldID) {
                if (is_object($this->_subfieldValues[$subFieldID])) {
                    $values[$subFieldID] = sensitiveIO::ellipsis(strip_tags($this->_subfieldValues[$subFieldID]->getValue()), 50);
                }
            }
            $desc .= $desc ? '<br />' : '';
            $desc .= '<span class="atm-red">Field : ' . $fieldID . ' - Value(s) : <ul>';
            foreach ($values as $subFieldID => $value) {
                $desc .= '<li>' . $subFieldID . '&nbsp;:&nbsp;' . $value . '</li>';
            }
            $desc .= '</ul></span>';
        }
        $label = $desc ? '<span class="atm-help" ext:qtip="' . io::htmlspecialchars($desc) . '">' . $mandatory . $this->getFieldLabel($language) . '</span>' : $mandatory . $this->getFieldLabel($language);
        $listId = 'list' . md5(mt_rand() . microtime());
        $listId2 = 'list' . md5(mt_rand() . microtime());
        if ($params['editable']) {
            //get object definition
            $objectDef = $this->getObjectDefinition();
            $associatedItems = array();
            foreach (array_keys($this->_subfieldValues) as $subFieldID) {
                if (is_object($this->_subfieldValues[$subFieldID])) {
                    $associatedItems[$this->_subfieldValues[$subFieldID]->getValue()] = $this->_subfieldValues[$subFieldID]->getValue();
                }
            }
            $items = array();
            $editURL = PATH_ADMIN_MODULES_WR . '/' . MOD_POLYMOD_CODENAME . '/item.php';
            $associateURL = PATH_ADMIN_MODULES_WR . '/' . MOD_POLYMOD_CODENAME . '/associate-items.php';
            $searchURL = PATH_ADMIN_MODULES_WR . '/' . MOD_POLYMOD_CODENAME . '/search.php';
            $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
            if (!$cms_user->hasModuleClearance($moduleCodename, CLEARANCE_MODULE_EDIT)) {
                define("MESSAGE_ERROR_MODULE_RIGHTS", 570);
                $module = CMS_modulesCatalog::getByCodename($moduleCodename);
                $items[] = array('width' => '100%', 'layout' => 'fit', 'border' => false, 'bodyStyle' => 'margin:5px 0 3px 0', 'html' => $language->getMessage(MESSAGE_ERROR_MODULE_RIGHTS, array($module->getLabel($language))));
            } else {
                $items[] = array('width' => '100%', 'layout' => 'fit', 'border' => false, 'bodyStyle' => 'margin:5px 0 3px 0', 'html' => $language->getMessage(self::MESSAGE_MULTI_OBJECT_LIST_ZONE, array($objectDef->getObjectLabel($language)), MOD_POLYMOD_CODENAME));
                $items[] = array('xtype' => "multiselect2", 'hideLabel' => true, 'id' => $listId2, 'name' => 'polymodFieldsValue[list' . $prefixName . $this->_field->getID() . '_0]', 'allowBlank' => !$this->_field->getValue('required'), 'valueField' => 'id', 'displayField' => 'label', 'tpl' => sensitiveIO::sanitizeJSString('<tpl for="rows">
						<dl>
							<tpl for="parent.columns">
								<dt style="width:100%;text-align:{align};white-space:normal;" class="MultiselectDD">
									<div unselectable="on" class="atm-result x-unselectable" id="object-{parent.id}">
										<div class="atm-title">
											<table>
												<tr>
													<td class="atm-label" ext:qtip="ID: {parent.id}">{parent.status}&nbsp;{parent.label}</td>
													<td class="atm-pubrange">{parent.pubrange}</td>
													<td class="atm-drag">&nbsp;</td>
												</tr>
											</table>
										</div>
										<div class="atm-description">{parent.description}<div style="clear:both;height:1px;">&nbsp;</div></div>
									</div>
								</dt>
							</tpl>
							<div class="x-clear"></div>
						</dl>
	                </tpl>'), 'store' => array('xtype' => 'atmJsonstore', 'root' => 'results', 'totalProperty' => 'total', 'url' => $searchURL, 'id' => 'id', 'remoteSort' => true, 'baseParams' => array('module' => $moduleCodename, 'objectId' => $this->_objectID), 'fields' => array('id', 'status', 'pubrange', 'label', 'description', 'locked', 'deleted', 'previz', 'edit')), 'value' => implode(',', $associatedItems), 'width' => 'auto', 'height' => 'auto', 'cls' => 'x-list-body', 'tbar' => array(!$params['doNotUseExternalSubObjects'] ? array('text' => $language->getMessage(self::MESSAGE_PAGE_ACTION_ASSOCIATE), 'tooltip' => $language->getMessage(self::MESSAGE_MULTI_OBJECT_CHOOSE_ELEMENT, array($objectDef->getObjectLabel($language)), MOD_POLYMOD_CODENAME), 'handler' => sensitiveIO::sanitizeJSString('function(button){
								var windowId = \'module' . $moduleCodename . 'AssociateWindow\';
								/*create window element*/
								var window = new Automne.Window({
									id:				windowId,
									objectId:		\'\',
									autoLoad:		{
										url:			\'' . $associateURL . '\',
										params:			{
											winId:			windowId,
											module:			\'' . $moduleCodename . '\',
											type:			\'' . $this->_objectID . '\'
										},
										nocache:		true,
										scope:			this
									},
									modal:			true,
									width:			750,
									height:			580,
									animateTarget:	button,
									listeners:{\'close\':function(window){
										var cmp = Ext.getCmp(\'' . $listId2 . '\');
										if (window.selectedItems && window.selectedItems.split) {
											var values = cmp.getRawValue();
											var items = window.selectedItems.split(\',\');
											for (var i = 0, itemsLen = items.length; i < itemsLen; i++) {
												if (values.indexOf(items[i]) === -1) {
													values.unshift(items[i]);
												}
											}
											cmp.setValue(values.join(cmp.delimiter));
										}
									}}
								});
								/*display window*/
								window.show(button.getEl());
							}', false, false), 'scope' => 'this') : '', array('text' => $language->getMessage(self::MESSAGE_PAGE_ACTION_DESASSOCIATE), 'tooltip' => $language->getMessage(self::MESSAGE_MULTI_OBJECT_DISASSOCIATE_ELEMENT, false, MOD_POLYMOD_CODENAME), 'handler' => sensitiveIO::sanitizeJSString('function(button){
								var cmp = Ext.getCmp(\'' . $listId2 . '\');
								var selected = cmp.view.getSelectedRecords();
								if (!selected.length || selected.length > 1) {
									Automne.message.popup({
										msg: 				\'' . $language->getJSMessage(self::MESSAGE_MULTI_OBJECT_SELECT_BEFORE, false, MOD_POLYMOD_CODENAME) . '\',
										buttons: 			Ext.MessageBox.OKCANCEL,
										animEl: 			button.getEl(),
										closable: 			false,
										icon: 				Ext.MessageBox.INFO
									});
									return;
								}
								Automne.message.popup({
									msg: 				\'' . io::htmlspecialchars($language->getMessage(self::MESSAGE_PAGE_ACTION_DESASSOCIATE_CONFIRM, array($objectDef->getObjectLabel($language)), MOD_POLYMOD_CODENAME)) . '\',
									buttons: 			Ext.MessageBox.OKCANCEL,
									animEl: 			button.getEl(),
									closable: 			false,
									icon: 				Ext.MessageBox.WARNING,
									scope:				this,
									fn: 				function (button) {
										if (button == \'ok\') {
											var cmp = Ext.getCmp(\'' . $listId2 . '\');
											var selected = cmp.view.getSelectedRecords();
											if (!selected.length || selected.length > 1) {
												return;
											}
											var objectId = selected[0].id;
											var values = cmp.getRawValue();
											values.remove(objectId);
											cmp.setValue(values.join(cmp.delimiter));
											if (\'' . $listId . '\') {
												var list = Ext.getCmp(\'' . $listId . '\');
												if (list) {
													list.store.baseParams.removeIds = values.join(cmp.delimiter);
													list.store.load();
												}
											}
										}
									}
								});
							}', false, false), 'scope' => 'this'), '->', array('text' => $language->getMessage(self::MESSAGE_PAGE_ACTION_MODIFIY), 'tooltip' => $language->getMessage(self::MESSAGE_MULTI_OBJECT_EDIT_ELEMENT, false, MOD_POLYMOD_CODENAME), 'iconCls' => 'atm-pic-modify', 'handler' => sensitiveIO::sanitizeJSString('function(button){
								var cmp = Ext.getCmp(\'' . $listId2 . '\');
								var selected = cmp.view.getSelectedRecords();
								if (!selected.length || selected.length > 1) {
									Automne.message.popup({
										msg: 				\'' . $language->getJSMessage(self::MESSAGE_MULTI_OBJECT_SELECT_BEFORE, false, MOD_POLYMOD_CODENAME) . '\',
										buttons: 			Ext.MessageBox.OKCANCEL,
										animEl: 			button.getEl(),
										closable: 			false,
										icon: 				Ext.MessageBox.INFO
									});
									return;
								}
								var objectId = selected[0].id;
								var windowId = \'module' . $moduleCodename . 'EditWindow\'+objectId;
								/*create window element*/
								var window = new Automne.Window({
									id:				windowId,
									objectId:		objectId,
									autoLoad:		{
										url:			\'' . $editURL . '\',
										params:			{
											winId:			windowId,
											module:			\'' . $moduleCodename . '\',
											type:			\'' . $this->_objectID . '\',
											item:			objectId
										},
										nocache:		true,
										scope:			this
									},
									modal:			true,
									width:			750,
									height:			580,
									animateTarget:	button,
									listeners:{\'close\':function(window){
										var cmp = Ext.getCmp(\'' . $listId2 . '\');
										cmp.store.reload();
									}}
								});
								/*display window*/
								window.show(button.getEl());
							}', false, false), 'scope' => 'this'), array('text' => $language->getMessage(self::MESSAGE_PAGE_ACTION_NEW), 'tooltip' => $language->getMessage(self::MESSAGE_MULTI_OBJECT_CREATE_ZONE, array($objectDef->getObjectLabel($language)), MOD_POLYMOD_CODENAME), 'iconCls' => 'atm-pic-add', 'handler' => sensitiveIO::sanitizeJSString('function(button){
								var objectId = \'create' . $moduleCodename . $this->_objectID . '\';
								var windowId = \'module' . $moduleCodename . 'EditWindow\'+objectId;
								/*create window element*/
								var window = new Automne.Window({
									id:				windowId,
									objectId:		\'\',
									autoLoad:		{
										url:			\'' . $editURL . '\',
										params:			{
											winId:			windowId,
											module:			\'' . $moduleCodename . '\',
											type:			\'' . $this->_objectID . '\'
										},
										nocache:		true,
										scope:			this
									},
									modal:			true,
									width:			750,
									height:			580,
									animateTarget:	button,
									listeners:{\'close\':function(window){
										var cmp = Ext.getCmp(\'' . $listId2 . '\');
										if (window.objectId) {
											var values = cmp.getRawValue();
											values.unshift(window.objectId);
											cmp.setValue(values.join(cmp.delimiter));
										}
									}}
								});
								/*display window*/
								window.show(button.getEl());
							}', false, false), 'scope' => 'this')), 'ddReorder' => true);
            }
            $return = array('title' => $label, 'xtype' => 'fieldset', 'autoHeight' => true, 'layout' => 'form', 'defaults' => array('anchor' => '97%'), 'items' => $items);
            return $return;
        } else {
            $return = array('allowBlank' => !$this->_field->getValue('required'), 'fieldLabel' => $label, 'name' => 'polymodFieldsValue[list' . $prefixName . $this->_field->getID() . '_0]');
            //get searched objects conditions
            $searchedObjects = is_array($params['searchedObjects']) ? $params['searchedObjects'] : array();
            $objectsNames = CMS_poly_object_catalog::getListOfNamesForObject($this->_objectID, false, $searchedObjects);
            $associatedItems = $availableItems = array();
            if (is_array($objectsNames) && $objectsNames) {
                foreach (array_keys($this->_subfieldValues) as $subFieldID) {
                    if (is_object($this->_subfieldValues[$subFieldID])) {
                        $associatedItems[$this->_subfieldValues[$subFieldID]->getValue()] = $this->_subfieldValues[$subFieldID]->getValue();
                    }
                }
                foreach ($objectsNames as $id => $name) {
                    $availableItems[] = array($id, $name);
                }
            } else {
                $availableItems[] = array('', $language->getMessage(self::MESSAGE_EMPTY_OBJECTS_SET));
                $return['disabled'] = true;
            }
            /*$return['xtype'] 			= 'multiselect';
            		$return['dataFields'] 		= array('id', 'label');
            		$return['data'] 			= $availableItems;
            		$return['value'] 			= implode(',',$associatedItems);
            		$return['valueField'] 		= "id";
            		$return['displayField'] 	= "label";
            		$return['width'] 			= '100%';*/
            $return['xtype'] = 'superboxselect';
            $return['dataFields'] = array('id', 'label');
            $return['store'] = $availableItems;
            $return['mode'] = 'local';
            $return['value'] = implode(',', $associatedItems);
            $return['valueField'] = "id";
            $return['displayField'] = "label";
            $return['width'] = '100%';
            $return['stackItems'] = true;
            return $return;
        }
    }
Exemple #6
0
 function getJSonDescription($user, $cms_language, $withDefinition = false)
 {
     $hasClientSpaces = $this->hasClientSpaces();
     $shortdesc = sensitiveIO::ellipsis($this->getDescription(), 60);
     if ($shortdesc != nl2br($this->getDescription())) {
         $shortdesc = '<span class="atm-help" ext:qtip="' . nl2br(io::htmlspecialchars(strip_tags($this->getDescription()))) . '">' . io::htmlspecialchars($shortdesc) . '</span>';
     }
     $shortdesc = $shortdesc ? $shortdesc . '<br />' : '';
     $mediumdesc = sensitiveIO::ellipsis($this->getDescription(), 200);
     if ($mediumdesc != $this->getDescription()) {
         $mediumdesc = '<span class="atm-help" ext:qtip="' . nl2br(io::htmlspecialchars(strip_tags($this->getDescription()))) . '">' . nl2br(io::htmlspecialchars($mediumdesc)) . '</span>';
     } else {
         $mediumdesc = io::htmlspecialchars($mediumdesc);
     }
     $mediumdesc = $mediumdesc ? $mediumdesc . '<br />' : '';
     //append template definition if needed
     $definitionDatas = $withDefinition ? $this->getDefinition() : '';
     //templates filters
     $filteredTemplates = '';
     if ($this->getFilteredTemplates()) {
         foreach ($this->getFilteredTemplates() as $tplId) {
             $template = CMS_pageTemplatesCatalog::getByID($tplId);
             if (is_object($template) && !$template->hasError()) {
                 $filteredTemplates .= $filteredTemplates ? ', ' : '';
                 $filteredTemplates .= $template->getLabel();
             }
         }
     }
     $filtersInfos = '';
     $filtersInfos .= $filteredTemplates ? $cms_language->getMessage(self::MESSAGE_DESC_TEMPLATES) . ' ' . $filteredTemplates : '';
     $filtersInfos = $filtersInfos ? '<br />' . $cms_language->getMessage(self::MESSAGE_DESC_USAGE_RESTRICTION) . ' <strong>' . $filtersInfos . '</strong>' : '';
     if ($user->hasAdminClearance(CLEARANCE_ADMINISTRATION_TEMPLATES)) {
         $edit = array('url' => 'row.php', 'params' => array('row' => $this->getID()));
     } else {
         $edit = false;
     }
     return array('id' => $this->getID(), 'label' => $this->getLabel(), 'type' => $cms_language->getMessage(self::MESSAGE_DESC_ROW_TEMPLATE), 'image' => $this->getImage(), 'groups' => implode(', ', $this->getGroups()), 'filter' => $this->getLabel() . ' ' . implode(', ', $this->getGroups()), 'tplfilter' => implode(',', $this->getFilteredTemplates()), 'description' => '<div' . (!$this->isUseable() ? ' class="atm-inactive"' : '') . '>' . '<img src="' . $this->getImage() . '" style="float:left;margin-right:3px;width:70px;" />' . $mediumdesc . $cms_language->getMessage(self::MESSAGE_DESC_GROUPS) . ' <strong>' . ($this->getGroups() ? implode(', ', $this->getGroups()) : $cms_language->getMessage(self::MESSAGE_DESC_NONE)) . '</strong><br />' . $cms_language->getMessage(self::MESSAGE_DESC_ACTIVE) . ' <strong>' . ($this->isUseable() ? $cms_language->getMessage(self::MESSAGE_DESC_YES) : $cms_language->getMessage(self::MESSAGE_DESC_NO)) . '</strong><br />' . $cms_language->getMessage(self::MESSAGE_DESC_USED) . ' <strong>' . ($hasClientSpaces ? $cms_language->getMessage(self::MESSAGE_DESC_YES) : $cms_language->getMessage(self::MESSAGE_DESC_NO)) . '</strong>' . ($hasClientSpaces ? ' - <a href="#" onclick="Automne.view.search(\'row:' . $this->getID() . '\');return false;">' . $cms_language->getMessage(self::MESSAGE_DESC_SEE) . '</a>' . ($user->hasAdminClearance(CLEARANCE_ADMINISTRATION_REGENERATEPAGES) ? ' / <a href="#" onclick="Automne.server.call(\'rows-controler.php\', \'\', {rowId:' . $this->getID() . ', action:\'regenerate\'});return false;">' . $cms_language->getMessage(self::MESSAGE_DESC_REGENERATE) . '</a>' : '') . ' ' . $cms_language->getMessage(self::MESSAGE_DESC_PAGES) : '') . '<br />' . $cms_language->getMessage(self::MESSAGE_DESC_FILE) . ' <strong>' . $this->getDefinitionFileName() . '</strong>' . $filtersInfos . '<br class="x-form-clear" />' . '</div>', 'activated' => $this->isUseable() ? true : false, 'used' => $hasClientSpaces, 'definition' => $definitionDatas, 'edit' => $edit, 'shortdesc' => $shortdesc);
 }
Exemple #7
0
 /**
  * set object Values
  *
  * @param array $values : the POST result values
  * @param string prefixname : the prefix used for post names
  * @param boolean newFormat : new automne v4 format (default false for compatibility)
  * @param integer $objectID : the current object id. Must be set, but default is blank for compatibility with other objects
  * @return boolean true on success, false on failure
  * @access public
  */
 function setValues($values, $prefixName, $newFormat = false, $objectID = '')
 {
     if (!sensitiveIO::isPositiveInteger($objectID)) {
         $this->raiseError('ObjectID must be a positive integer : ' . $objectID);
         return false;
     }
     //get field parameters
     $params = $this->getParamsValues();
     //get module codename
     $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
     if ($newFormat) {
         //delete old images ?
         //thumbnail
         if ($this->_subfieldValues[0]->getValue() && (!$values[$prefixName . $this->_field->getID() . '_0'] || pathinfo($values[$prefixName . $this->_field->getID() . '_0'], PATHINFO_BASENAME) != $this->_subfieldValues[0]->getValue())) {
             @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[0]->getValue());
             $this->_subfieldValues[0]->setValue('');
         }
         //image zoom
         if ($this->_subfieldValues[2]->getValue() && (!isset($values[$prefixName . $this->_field->getID() . '_2']) || !$values[$prefixName . $this->_field->getID() . '_2'] || pathinfo($values[$prefixName . $this->_field->getID() . '_2'], PATHINFO_BASENAME) != $this->_subfieldValues[2]->getValue())) {
             @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[2]->getValue());
             $this->_subfieldValues[2]->setValue('');
         }
         //set label from label field
         if (!$this->_subfieldValues[1]->setValue(io::htmlspecialchars($values[$prefixName . $this->_field->getID() . '_1']))) {
             return false;
         }
         //image zoom (if needed)
         if ((!isset($values[$prefixName . $this->_field->getID() . '_makeZoom']) || $values[$prefixName . $this->_field->getID() . '_makeZoom'] != 1) && isset($values[$prefixName . $this->_field->getID() . '_2']) && $values[$prefixName . $this->_field->getID() . '_2'] && io::strpos($values[$prefixName . $this->_field->getID() . '_2'], PATH_UPLOAD_WR . '/') !== false) {
             $filename = $values[$prefixName . $this->_field->getID() . '_2'];
             //check for image type before doing anything
             if (!in_array(io::strtolower(pathinfo($filename, PATHINFO_EXTENSION)), $this->_allowedExtensions)) {
                 return false;
             }
             //destroy old image if any
             if ($this->_subfieldValues[2]->getValue()) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[2]->getValue());
                 $this->_subfieldValues[2]->setValue('');
             }
             //move and rename uploaded file
             $filename = str_replace(PATH_UPLOAD_WR . '/', PATH_UPLOAD_FS . '/', $filename);
             $basename = pathinfo($filename, PATHINFO_BASENAME);
             //set thumbnail
             $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED;
             $zoomBasename = "r" . $objectID . "_" . $this->_field->getID() . "_" . io::strtolower(SensitiveIO::sanitizeAsciiString($basename));
             if (io::strlen($zoomBasename) > 255) {
                 $zoomBasename = sensitiveIO::ellipsis($zoomBasename, 255, '-', true);
             }
             $zoomFilename = $path . '/' . $zoomBasename;
             CMS_file::moveTo($filename, $zoomFilename);
             CMS_file::chmodFile(FILES_CHMOD, $zoomFilename);
             //set it
             if (!$this->_subfieldValues[2]->setValue($zoomBasename)) {
                 return false;
             }
         }
         //thumbnail
         if ($values[$prefixName . $this->_field->getID() . '_0'] && io::strpos($values[$prefixName . $this->_field->getID() . '_0'], PATH_UPLOAD_WR . '/') !== false) {
             $filename = $values[$prefixName . $this->_field->getID() . '_0'];
             //check for image type before doing anything
             if (!in_array(io::strtolower(pathinfo($filename, PATHINFO_EXTENSION)), $this->_allowedExtensions)) {
                 return false;
             }
             //destroy old image if any
             if ($this->_subfieldValues[0]->getValue()) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[0]->getValue());
                 $this->_subfieldValues[0]->setValue('');
             }
             //move and rename uploaded file
             $filename = str_replace(PATH_UPLOAD_WR . '/', PATH_UPLOAD_FS . '/', $filename);
             $basename = pathinfo($filename, PATHINFO_BASENAME);
             //set thumbnail
             $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED;
             $newBasename = "r" . $objectID . "_" . $this->_field->getID() . "_" . io::strtolower(SensitiveIO::sanitizeAsciiString($basename));
             //rename image
             $path_parts = pathinfo($newBasename);
             $extension = io::strtolower($path_parts['extension']);
             $newBasename = io::substr($path_parts['basename'], 0, -(io::strlen($extension) + 1)) . '_thumbnail.' . $extension;
             if (io::strlen($newBasename) > 255) {
                 $newBasename = sensitiveIO::ellipsis($newBasename, 255, '-', true);
             }
             $newFilename = $path . '/' . $newBasename;
             //move file from upload dir to new dir
             CMS_file::moveTo($filename, $newFilename);
             CMS_file::chmodFile(FILES_CHMOD, $newFilename);
             //if we use original image as image zoom, set it
             if (isset($values[$prefixName . $this->_field->getID() . '_makeZoom']) && $values[$prefixName . $this->_field->getID() . '_makeZoom'] == 1) {
                 $zoomFilename = str_replace('_thumbnail.' . $extension, '.' . $extension, $newFilename);
                 //copy image as zoom
                 CMS_file::copyTo($newFilename, $zoomFilename);
                 $zoomBasename = pathinfo($zoomFilename, PATHINFO_BASENAME);
                 //set image zoom
                 if (!$this->_subfieldValues[2]->setValue($zoomBasename)) {
                     return false;
                 }
             }
             //resize thumbnail if needed
             if ($params['maxWidth'] > 0 || $params['maxHeight'] > 0) {
                 $oImage = new CMS_image($newFilename);
                 //get current file size
                 $sizeX = $oImage->getWidth();
                 $sizeY = $oImage->getHeight();
                 //check thumbnail size
                 if ($params['maxWidth'] && $sizeX > $params['maxWidth'] || $params['maxHeight'] && $sizeY > $params['maxHeight']) {
                     $newSizeX = $sizeX;
                     $newSizeY = $sizeY;
                     // Check width
                     if ($params['maxWidth'] && $newSizeX > $params['maxWidth']) {
                         $newSizeY = round($params['maxWidth'] * $newSizeY / $newSizeX);
                         $newSizeX = $params['maxWidth'];
                     }
                     if ($params['maxHeight'] && $newSizeY > $params['maxHeight']) {
                         $newSizeX = round($params['maxHeight'] * $newSizeX / $newSizeY);
                         $newSizeY = $params['maxHeight'];
                     }
                     if (!$oImage->resize($newSizeX, $newSizeY, $newFilename)) {
                         return false;
                     }
                 }
             }
             //set thumbnail
             if (!$this->_subfieldValues[0]->setValue($newBasename)) {
                 return false;
             }
         }
         // If label not set yet, set it
         /*if(!$this->_subfieldValues[1]->getValue()){
         			if($this->_subfieldValues[0]->getValue()){
         				$this->_subfieldValues[1]->setValue($this->_subfieldValues[0]->getValue());
         			}
         		}*/
         //if we had an imagezoom, check his size
         if ($this->_subfieldValues[2]->getValue() && ($params['maxZoomWidth'] > 0 || $params['maxZoomHeight'] > 0)) {
             //resize zoom if needed
             $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED;
             $basename = $this->_subfieldValues[2]->getValue();
             $filename = $path . '/' . $basename;
             $extension = io::strtolower(pathinfo($basename, PATHINFO_EXTENSION));
             $oImage = new CMS_image($filename);
             //get current file size
             $sizeX = $oImage->getWidth();
             $sizeY = $oImage->getHeight();
             //check zoom size
             if ($params['maxZoomWidth'] && $sizeX > $params['maxZoomWidth'] || $params['maxZoomHeight'] && $sizeY > $params['maxZoomHeight']) {
                 $newSizeX = $sizeX;
                 $newSizeY = $sizeY;
                 // Check width
                 if ($params['maxZoomWidth'] && $newSizeX > $params['maxZoomWidth']) {
                     $newSizeY = round($params['maxZoomWidth'] * $newSizeY / $newSizeX);
                     $newSizeX = $params['maxZoomWidth'];
                 }
                 if ($params['maxZoomHeight'] && $newSizeY > $params['maxZoomHeight']) {
                     $newSizeX = round($params['maxZoomHeight'] * $newSizeX / $newSizeY);
                     $newSizeY = $params['maxZoomHeight'];
                 }
                 if (!$oImage->resize($newSizeX, $newSizeY, $filename)) {
                     return false;
                 }
             }
         }
         //update files infos if needed
         if ($this->_subfieldValues[0]->getValue() && file_exists(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[0]->getValue())) {
             $file = new CMS_file(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[0]->getValue());
             $imageDatas = array('filename' => $file->getName(false), 'filepath' => $file->getFilePath(CMS_file::WEBROOT), 'filesize' => $file->getFileSize(), 'fileicon' => $file->getFileIcon(CMS_file::WEBROOT), 'extension' => $file->getExtension());
         } else {
             $imageDatas = array('filename' => '', 'filepath' => '', 'filesize' => '', 'fileicon' => '', 'extension' => '');
         }
         $imageDatas['module'] = $moduleCodename;
         $imageDatas['visualisation'] = RESOURCE_DATA_LOCATION_EDITED;
         if ($params['useDistinctZoom'] || $this->_subfieldValues[2]->getValue()) {
             //update files infos if needed
             if ($this->_subfieldValues[2]->getValue() && file_exists(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[2]->getValue())) {
                 $file = new CMS_file(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[2]->getValue());
                 $zoomDatas = array('filename' => $file->getName(false), 'filepath' => $file->getFilePath(CMS_file::WEBROOT), 'filesize' => $file->getFileSize(), 'fileicon' => $file->getFileIcon(CMS_file::WEBROOT), 'extension' => $file->getExtension());
             } else {
                 $zoomDatas = array('filename' => '', 'filepath' => '', 'filesize' => '', 'fileicon' => '', 'extension' => '');
             }
             $zoomDatas['module'] = $moduleCodename;
             $zoomDatas['visualisation'] = RESOURCE_DATA_LOCATION_EDITED;
         } else {
             $zoomDatas = '';
         }
         $content = array('datas' => array('polymodFieldsValue[' . $prefixName . $this->_field->getID() . '_0]' => $imageDatas, 'polymodFieldsValue[' . $prefixName . $this->_field->getID() . '_2]' => $zoomDatas, 'polymodFieldsValue[' . $prefixName . $this->_field->getID() . '_1]' => sensitiveIO::decodeEntities($this->_subfieldValues[1]->getValue())));
         $view = CMS_view::getInstance();
         $view->addContent($content);
         return true;
     } else {
         //Old format
         //delete old images ?
         if (isset($values[$prefixName . $this->_field->getID() . '_delete']) && $values[$prefixName . $this->_field->getID() . '_delete'] == 1) {
             if ($this->_subfieldValues[0]->getValue()) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[0]->getValue());
                 $this->_subfieldValues[0]->setValue('');
             } elseif (isset($values[$prefixName . $this->_field->getID() . '_0_hidden']) && $values[$prefixName . $this->_field->getID() . '_0_hidden']) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $values[$prefixName . $this->_field->getID() . '_0_hidden']);
                 $this->_subfieldValues[0]->setValue('');
             }
             if ($this->_subfieldValues[2]->getValue()) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[2]->getValue());
                 $this->_subfieldValues[2]->setValue('');
             } elseif (isset($values[$prefixName . $this->_field->getID() . '_2_hidden']) && $values[$prefixName . $this->_field->getID() . '_2_hidden']) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $values[$prefixName . $this->_field->getID() . '_2_hidden']);
                 $this->_subfieldValues[2]->setValue('');
             }
         }
         //set label from label field
         if (!$this->_subfieldValues[1]->setValue(io::htmlspecialchars(@$values[$prefixName . $this->_field->getID() . '_1']))) {
             return false;
         }
         //thumbnail
         if (isset($_FILES[$prefixName . $this->_field->getID() . '_0']) && $_FILES[$prefixName . $this->_field->getID() . '_0']['name'] && !$_FILES[$prefixName . $this->_field->getID() . '_0']['error']) {
             //check for image type before doing anything
             if (!in_array(io::strtolower(pathinfo($_FILES[$prefixName . $this->_field->getID() . '_0']["name"], PATHINFO_EXTENSION)), $this->_allowedExtensions)) {
                 return false;
             }
             //set label as image name if none set
             /*if (!$values[$prefixName.$this->_field->getID().'_1']) {
             			if (!$this->_subfieldValues[1]->setValue(io::htmlspecialchars($_FILES[$prefixName.$this->_field->getID().'_0']["name"]))) {
             				return false;
             			}
             		}*/
             //destroy all old images if any
             if ($this->_subfieldValues[0]->getValue()) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[0]->getValue());
                 $this->_subfieldValues[0]->setValue('');
             } elseif (isset($values[$prefixName . $this->_field->getID() . '_0_hidden']) && $values[$prefixName . $this->_field->getID() . '_0_hidden']) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $values[$prefixName . $this->_field->getID() . '_0_hidden']);
                 $this->_subfieldValues[0]->setValue('');
             }
             if ($this->_subfieldValues[2]->getValue()) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[2]->getValue());
                 $this->_subfieldValues[2]->setValue('');
             } elseif (isset($values[$prefixName . $this->_field->getID() . '_2_hidden']) && $values[$prefixName . $this->_field->getID() . '_2_hidden']) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $values[$prefixName . $this->_field->getID() . '_2_hidden']);
                 $this->_subfieldValues[2]->setValue('');
             }
             //set thumbnail (resize it if needed)
             //create thumbnail path
             $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED;
             $filename = "r" . $objectID . "_" . $this->_field->getID() . "_" . io::strtolower(SensitiveIO::sanitizeAsciiString($_FILES[$prefixName . $this->_field->getID() . '_0']["name"]));
             if (io::strlen($filename) > 255) {
                 $filename = sensitiveIO::ellipsis($filename, 255, '-', true);
             }
             //move uploaded file
             $fileDatas = CMS_file::uploadFile($prefixName . $this->_field->getID() . '_0', PATH_TMP_FS);
             if ($fileDatas['error']) {
                 return false;
             }
             if (!CMS_file::moveTo(PATH_TMP_FS . '/' . $fileDatas['filename'], $path . "/" . $filename)) {
                 return false;
             }
             if ($params['maxWidth'] > 0) {
                 $oImage = new CMS_image($path . "/" . $filename);
                 //get current file size
                 $sizeX = $oImage->getWidth();
                 $sizeY = $oImage->getHeight();
                 //check thumbnail size
                 if ($sizeX > $params['maxWidth'] || $sizeY > $params['maxHeight']) {
                     $newSizeX = $sizeX;
                     $newSizeY = $sizeY;
                     // Check width
                     if ($params['maxWidth'] && $newSizeX > $params['maxWidth']) {
                         $newSizeY = round($params['maxWidth'] * $newSizeY / $newSizeX);
                         $newSizeX = $params['maxWidth'];
                     }
                     if ($params['maxHeight'] && $newSizeY > $params['maxHeight']) {
                         $newSizeX = round($params['maxHeight'] * $newSizeX / $newSizeY);
                         $newSizeY = $params['maxHeight'];
                     }
                     //resize image
                     $srcfilepath = $path . "/" . $filename;
                     $path_parts = pathinfo($srcfilepath);
                     $thumbnailFilename = io::substr($path_parts['basename'], 0, -(io::strlen($path_parts['extension']) + 1)) . '_thumbnail.' . $path_parts['extension'];
                     $destfilepath = $path . "/" . $thumbnailFilename;
                     $extension = io::strtolower($path_parts['extension']);
                     if (!$oImage->resize($newSizeX, $newSizeY, $destfilepath)) {
                         return false;
                     }
                     //if we use original image as image zoom, set it
                     if ($values[$prefixName . $this->_field->getID() . '_makeZoom'] == 1) {
                         //set image zoom
                         if (!$this->_subfieldValues[2]->setValue($filename)) {
                             return false;
                         }
                     } else {
                         //destroy original image
                         unlink($srcfilepath);
                     }
                     //set resized thumbnail
                     if (!$this->_subfieldValues[0]->setValue($thumbnailFilename)) {
                         return false;
                     }
                 } else {
                     //no need to resize thumbnail (below the maximum width), so set it
                     if (!$this->_subfieldValues[0]->setValue($filename)) {
                         return false;
                     }
                     //if we use original image as image zoom, set it
                     if ($values[$prefixName . $this->_field->getID() . '_makeZoom'] == 1) {
                         //set image zoom
                         if (!$this->_subfieldValues[2]->setValue($filename)) {
                             return false;
                         }
                     }
                 }
             } else {
                 //no need to resize thumbnail, so set it
                 if (!$this->_subfieldValues[0]->setValue($filename)) {
                     return false;
                 }
                 //if we use original image as image zoom, set it
                 if ($values[$prefixName . $this->_field->getID() . '_makeZoom'] == 1) {
                     //set image zoom
                     if (!$this->_subfieldValues[2]->setValue($filename)) {
                         return false;
                     }
                 }
             }
         } elseif (isset($_FILES[$prefixName . $this->_field->getID() . '_0']) && $_FILES[$prefixName . $this->_field->getID() . '_0']['name'] && $_FILES[$prefixName . $this->_field->getID() . '_0']['error'] != 0) {
             return false;
         } elseif (isset($values[$prefixName . $this->_field->getID() . '_0_hidden']) && $values[$prefixName . $this->_field->getID() . '_0_hidden'] && (!isset($values[$prefixName . $this->_field->getID() . '_delete']) || $values[$prefixName . $this->_field->getID() . '_delete'] != 1)) {
             //set label as image name if none set
             if (!$this->_subfieldValues[0]->setValue($values[$prefixName . $this->_field->getID() . '_0_hidden'])) {
                 return false;
             }
         }
         //image zoom (if needed)
         if (isset($values[$prefixName . $this->_field->getID() . '_makeZoom']) && $values[$prefixName . $this->_field->getID() . '_makeZoom'] != 1 && isset($_FILES[$prefixName . $this->_field->getID() . '_2']['name']) && $_FILES[$prefixName . $this->_field->getID() . '_2']['name'] && !$_FILES[$prefixName . $this->_field->getID() . '_2']['error']) {
             //check for image type before doing anything
             if (!in_array(io::strtolower(pathinfo($_FILES[$prefixName . $this->_field->getID() . '_2']["name"], PATHINFO_EXTENSION)), $this->_allowedExtensions)) {
                 return false;
             }
             //create thumbnail path
             $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED;
             $filename = "r" . $objectID . "_" . $this->_field->getID() . "_" . io::strtolower(SensitiveIO::sanitizeAsciiString($_FILES[$prefixName . $this->_field->getID() . '_2']["name"]));
             if (io::strlen($filename) > 255) {
                 $filename = sensitiveIO::ellipsis($filename, 255, '-', true);
             }
             //move uploaded file
             $fileDatas = CMS_file::uploadFile($prefixName . $this->_field->getID() . '_2', PATH_TMP_FS);
             if ($fileDatas['error']) {
                 return false;
             }
             if (!CMS_file::moveTo(PATH_TMP_FS . '/' . $fileDatas['filename'], $path . "/" . $filename)) {
                 return false;
             }
             //set it
             if (!$this->_subfieldValues[2]->setValue($filename)) {
                 return false;
             }
         } elseif (isset($_FILES[$prefixName . $this->_field->getID() . '_2']) && $_FILES[$prefixName . $this->_field->getID() . '_2']['name'] && $_FILES[$prefixName . $this->_field->getID() . '_2']['error'] != 0) {
             return false;
         } elseif (isset($values[$prefixName . $this->_field->getID() . '_2_hidden']) && $values[$prefixName . $this->_field->getID() . '_2_hidden'] && (!isset($values[$prefixName . $this->_field->getID() . '_delete']) || $values[$prefixName . $this->_field->getID() . '_delete'] != 1)) {
             if (!$this->_subfieldValues[2]->setValue($values[$prefixName . $this->_field->getID() . '_2_hidden'])) {
                 return false;
             }
         }
         return true;
     }
 }
Exemple #8
0
                $panelEditable = 'true';
                break;
            case 'edited':
                $panelTitle = $cms_language->getMessage(MESSAGE_PAGE_PREVIZ);
                $panelPicto = 'atm-pic-big-edited';
                $panelDisabled = $hasPreviz && !$hasRedirect ? 'false' : 'true';
                $panelTipTitle = $cms_language->getMessage(MESSAGE_PAGE_PREVIZ_TIP_TITLE);
                $panelTip = $cms_language->getMessage(MESSAGE_PAGE_PREVIZ_TIP_DESC);
                if (!$hasPreviz) {
                    $panelTip .= '<br /><br />' . $cms_language->getMessage(MESSAGE_PAGE_PREVIZ_TIP_DISABLED_DESC);
                }
                $panelURL = PATH_ADMIN_WR . '/page-previsualization.php?currentPage=' . $cms_page->getID() . ($querystring ? '&' . $querystring : '');
                break;
            case 'public':
                $icon = $cms_page->getStatus()->getHTML(true, $cms_user, MOD_STANDARD_CODENAME, $cms_page->getID(), true, false);
                $panelTitle = '<span class="atm-tab">' . $icon . '&nbsp;&nbsp;' . sensitiveIO::ellipsis($cms_page->getTitle() . ' (' . $cms_page->getID() . ')', 52, '...', true) . '</span>';
                $panelDisabled = $hasPublic ? 'false' : 'true';
                $pageTemplateLabel = $cms_page->getTemplate() ? $cms_page->getTemplate()->getLabel() : '';
                //page panel tip content
                $panelTipTitle = '<div id="tip-header-img">' . $cms_page->getStatus()->getHTML() . '</div>
				<div id="tip-header-text">
				<strong>' . $cms_language->getMessage(MESSAGE_PAGE_PUBLIC_TIP_TITLE) . ' : </strong>' . $cms_page->getTitle() . '<br />
				<strong>' . $cms_language->getMessage(MESSAGE_PAGE_PUBLIC_TIP_LINKTITLE) . ' : </strong>' . $cms_page->getLinkTitle() . '</div>';
                $panelTip = '<strong>' . $cms_language->getMessage(MESSAGE_PAGE_PUBLIC_TIP_ID) . ' : </strong>' . $cms_page->getID() . '<br />';
                if ($cms_page->getCodename()) {
                    $panelTip .= '<strong>' . $cms_language->getMessage(MESSAGE_PAGE_CODENAME) . ' : </strong>' . $cms_page->getCodename() . '<br />';
                }
                $panelTip .= '
				<strong>' . $cms_language->getMessage(MESSAGE_PAGE_PUBLIC_TIP_STATUS) . ' : </strong>' . $cms_page->getStatus()->getStatusLabel($cms_language) . '<br />
				<strong>' . $cms_language->getMessage(MESSAGE_PAGE_PUBLIC_TIP_TEMPLATE) . ' : </strong>' . $pageTemplateLabel . '<br />
				<strong>' . $cms_language->getMessage(MESSAGE_PAGE_PUBLIC_TIP_PUBLICATION) . ' : </strong>' . $cms_page->getStatus()->getPublicationRange($cms_language) . '<br />';
Exemple #9
0
 /**
  * set object Values
  *
  * @param array $values : the POST result values
  * @param string prefixname : the prefix used for post names
  * @param boolean newFormat : new automne v4 format (default false for compatibility)
  * @param integer $objectID : the current object id. Must be set, but default is blank for compatibility with other objects
  * @return boolean true on success, false on failure
  * @access public
  */
 function setValues($values, $prefixName, $newFormat = false, $objectID = '')
 {
     if (!sensitiveIO::isPositiveInteger($objectID)) {
         $this->raiseError('ObjectID must be a positive integer : ' . $objectID);
         return false;
     }
     //get field parameters
     $params = $this->getParamsValues();
     //get module codename
     $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
     if ($newFormat) {
         //delete old files ?
         //thumbnail
         if ($this->_subfieldValues[1]->getValue() && (!$values[$prefixName . $this->_field->getID() . '_1'] || pathinfo($values[$prefixName . $this->_field->getID() . '_1'], PATHINFO_BASENAME) != $this->_subfieldValues[1]->getValue())) {
             @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[1]->getValue());
             $this->_subfieldValues[1]->setValue('');
         }
         //file
         if ($this->_subfieldValues[4]->getValue() && (!$values[$prefixName . $this->_field->getID() . '_4'] || pathinfo($values[$prefixName . $this->_field->getID() . '_4'], PATHINFO_BASENAME) != $this->_subfieldValues[4]->getValue())) {
             @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[4]->getValue());
             $this->_subfieldValues[4]->setValue('');
             //reset filesize
             if (!$this->_subfieldValues[2]->setValue(0)) {
                 return false;
             }
         }
         if (!(isset($values[$prefixName . $this->_field->getID() . '_0']) && $this->_subfieldValues[0]->setValue(io::htmlspecialchars($values[$prefixName . $this->_field->getID() . '_0'])))) {
             return false;
         }
         //thumbnail
         if (isset($values[$prefixName . $this->_field->getID() . '_1']) && $values[$prefixName . $this->_field->getID() . '_1'] && io::strpos($values[$prefixName . $this->_field->getID() . '_1'], PATH_UPLOAD_WR . '/') !== false) {
             $filename = $values[$prefixName . $this->_field->getID() . '_1'];
             //check for image type before doing anything
             if (!in_array(io::strtolower(pathinfo($filename, PATHINFO_EXTENSION)), $this->_allowedExtensions)) {
                 return false;
             }
             //destroy old image if any
             if ($this->_subfieldValues[1]->getValue()) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[1]->getValue());
                 $this->_subfieldValues[1]->setValue('');
             }
             //move and rename uploaded file
             $filename = str_replace(PATH_UPLOAD_WR . '/', PATH_UPLOAD_FS . '/', $filename);
             $basename = pathinfo($filename, PATHINFO_BASENAME);
             //set thumbnail
             $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED;
             $newBasename = "r" . $objectID . "_" . $this->_field->getID() . "_" . io::strtolower(SensitiveIO::sanitizeAsciiString($basename));
             //rename image
             $path_parts = pathinfo($newBasename);
             $extension = io::strtolower($path_parts['extension']);
             $newBasename = io::substr($path_parts['basename'], 0, -(io::strlen($extension) + 1)) . '_thumbnail.' . $extension;
             if (io::strlen($newBasename) > 255) {
                 $newBasename = sensitiveIO::ellipsis($newBasename, 255, '-', true);
             }
             $newFilename = $path . '/' . $newBasename;
             //move file from upload dir to new dir
             CMS_file::moveTo($filename, $newFilename);
             CMS_file::chmodFile(FILES_CHMOD, $newFilename);
             //resize thumbnail if needed
             if ($params['thumbMaxWidth'] > 0 || $params['thumbMaxHeight'] > 0) {
                 $oImage = new CMS_image($newFilename);
                 //get current file size
                 $sizeX = $oImage->getWidth();
                 $sizeY = $oImage->getHeight();
                 //check thumbnail size
                 list($sizeX, $sizeY) = @getimagesize($newFilename);
                 if ($params['thumbMaxWidth'] && $sizeX > $params['thumbMaxWidth'] || $params['thumbMaxHeight'] && $sizeY > $params['thumbMaxHeight']) {
                     $newSizeX = $sizeX;
                     $newSizeY = $sizeY;
                     // Check width
                     if ($params['thumbMaxWidth'] && $newSizeX > $params['thumbMaxWidth']) {
                         $newSizeY = round($params['thumbMaxWidth'] * $newSizeY / $newSizeX);
                         $newSizeX = $params['thumbMaxWidth'];
                     }
                     if ($params['thumbMaxHeight'] && $newSizeY > $params['thumbMaxHeight']) {
                         $newSizeX = round($params['thumbMaxHeight'] * $newSizeX / $newSizeY);
                         $newSizeY = $params['thumbMaxHeight'];
                     }
                     if (!$oImage->resize($newSizeX, $newSizeY, $newFilename)) {
                         return false;
                     }
                 }
             }
             //set thumbnail
             if (!$this->_subfieldValues[1]->setValue($newBasename)) {
                 return false;
             }
         }
         //File
         //1- from external location
         if (isset($values[$prefixName . $this->_field->getID() . '_externalfile']) && $values[$prefixName . $this->_field->getID() . '_externalfile']) {
             //from FTP directory
             $filename = $values[$prefixName . $this->_field->getID() . '_externalfile'];
             //check file extension
             if ($params['allowedType'] || $params['disallowedType']) {
                 $extension = io::strtolower(pathinfo($filename, PATHINFO_EXTENSION));
                 if (!$extension) {
                     return false;
                 }
                 //extension must be in allowed list
                 if ($params['allowedType'] && !in_array($extension, explode(',', io::strtolower($params['allowedType'])))) {
                     return false;
                 }
                 //extension must not be in disallowed list
                 if ($params['disallowedType'] && in_array($extension, explode(',', io::strtolower($params['disallowedType'])))) {
                     return false;
                 }
             }
             //destroy old file if any
             if ($this->_subfieldValues[4]->getValue()) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[4]->getValue());
                 $this->_subfieldValues[4]->setValue('');
             }
             $new_filename = 'r' . $objectID . "_" . $this->_field->getID() . "_" . io::strtolower(SensitiveIO::sanitizeAsciiString($filename));
             if (io::strlen($new_filename) > 255) {
                 $new_filename = sensitiveIO::ellipsis($new_filename, 255, '-', true);
             }
             $destination_path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/';
             $ftp_dir = PATH_REALROOT_FS . $params['ftpDir'];
             if (@file_exists($ftp_dir . $filename) && is_file($ftp_dir . $filename)) {
                 if (CMS_file::moveTo($ftp_dir . $filename, $destination_path . '/' . $new_filename)) {
                     CMS_file::chmodFile(FILES_CHMOD, $destination_path . '/' . $new_filename);
                     //set label as file name if none set
                     if (!$values[$prefixName . $this->_field->getID() . '_0']) {
                         if (!$this->_subfieldValues[0]->setValue(io::htmlspecialchars($filename))) {
                             return false;
                         }
                     }
                     //set it
                     if (!$this->_subfieldValues[4]->setValue($new_filename)) {
                         return false;
                     }
                     //and set filesize
                     $filesize = @filesize($destination_path . '/' . $new_filename);
                     if ($filesize !== false && $filesize > 0) {
                         //convert in MB
                         $filesize = round($filesize / 1048576, 2);
                     } else {
                         $filesize = '0';
                     }
                     if (!$this->_subfieldValues[2]->setValue($filesize)) {
                         return false;
                     }
                     //set file type
                     if (!$this->_subfieldValues[3]->setValue(self::OBJECT_FILE_TYPE_INTERNAL)) {
                         return false;
                     }
                 } else {
                     return false;
                 }
             } else {
                 return false;
             }
         } else {
             //2- from post
             if ($values[$prefixName . $this->_field->getID() . '_4'] && io::strpos($values[$prefixName . $this->_field->getID() . '_4'], PATH_UPLOAD_WR . '/') !== false) {
                 //check file extension
                 if ($params['allowedType'] || $params['disallowedType']) {
                     $extension = io::strtolower(pathinfo($values[$prefixName . $this->_field->getID() . '_4'], PATHINFO_EXTENSION));
                     if (!$extension) {
                         return false;
                     }
                     //extension must be in allowed list
                     if ($params['allowedType'] && !in_array($extension, explode(',', io::strtolower($params['allowedType'])))) {
                         return false;
                     }
                     //extension must not be in disallowed list
                     if ($params['disallowedType'] && in_array($extension, explode(',', io::strtolower($params['disallowedType'])))) {
                         return false;
                     }
                 }
                 //set file type
                 if (!$this->_subfieldValues[3]->setValue(self::OBJECT_FILE_TYPE_INTERNAL)) {
                     return false;
                 }
                 //destroy old file if any
                 if ($this->_subfieldValues[4]->getValue()) {
                     @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[4]->getValue());
                     $this->_subfieldValues[4]->setValue('');
                 }
                 //move and rename uploaded file
                 $filename = str_replace(PATH_UPLOAD_WR . '/', PATH_UPLOAD_FS . '/', $values[$prefixName . $this->_field->getID() . '_4']);
                 $basename = pathinfo($filename, PATHINFO_BASENAME);
                 //create file path
                 $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED;
                 $newBasename = "r" . $objectID . "_" . $this->_field->getID() . "_" . io::strtolower(SensitiveIO::sanitizeAsciiString($basename));
                 if (io::strlen($newBasename) > 255) {
                     $newBasename = sensitiveIO::ellipsis($newBasename, 255, '-', true);
                 }
                 $newFilename = $path . '/' . $newBasename;
                 if (!CMS_file::moveTo($filename, $newFilename)) {
                     return false;
                 }
                 CMS_file::chmodFile(FILES_CHMOD, $newFilename);
                 //set it
                 if (!$this->_subfieldValues[4]->setValue($newBasename)) {
                     return false;
                 }
                 //and set filesize
                 $filesize = @filesize($newFilename);
                 if ($filesize !== false && $filesize > 0) {
                     //convert in MB
                     $filesize = round($filesize / 1048576, 2);
                 } else {
                     $filesize = '0';
                 }
                 if (!$this->_subfieldValues[2]->setValue($filesize)) {
                     return false;
                 }
             }
         }
         // If label not set yet, set it
         if (!$this->_subfieldValues[0]->getValue()) {
             if ($this->_subfieldValues[4]->getValue()) {
                 $this->_subfieldValues[0]->setValue($this->_subfieldValues[4]->getValue());
             }
         }
         //update files infos if needed
         if ($this->_subfieldValues[1]->getValue() && file_exists(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[1]->getValue())) {
             $file = new CMS_file(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[1]->getValue());
             $imageDatas = array('filename' => $file->getName(false), 'filepath' => $file->getFilePath(CMS_file::WEBROOT), 'filesize' => $file->getFileSize(), 'fileicon' => $file->getFileIcon(CMS_file::WEBROOT), 'extension' => $file->getExtension());
         } else {
             $imageDatas = array('filename' => '', 'filepath' => '', 'filesize' => '', 'fileicon' => '', 'extension' => '');
         }
         //update files infos if needed
         if ($this->_subfieldValues[4]->getValue() && file_exists(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[4]->getValue())) {
             $file = new CMS_file(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[4]->getValue());
             $fileDatas = array('filename' => $file->getName(false), 'filepath' => $file->getFilePath(CMS_file::WEBROOT), 'filesize' => $file->getFileSize(), 'fileicon' => $file->getFileIcon(CMS_file::WEBROOT), 'extension' => $file->getExtension());
         } else {
             $fileDatas = array('filename' => '', 'filepath' => '', 'filesize' => '', 'fileicon' => '', 'extension' => '');
         }
         $imageDatas['module'] = $fileDatas['module'] = $moduleCodename;
         $imageDatas['visualisation'] = $fileDatas['visualisation'] = RESOURCE_DATA_LOCATION_EDITED;
         $content = array('datas' => array('polymodFieldsValue[' . $prefixName . $this->_field->getID() . '_1]' => $imageDatas, 'polymodFieldsValue[' . $prefixName . $this->_field->getID() . '_4]' => $fileDatas, 'polymodFieldsValue[' . $prefixName . $this->_field->getID() . '_externalfile]' => '', 'polymodFieldsValue[' . $prefixName . $this->_field->getID() . '_0]' => sensitiveIO::decodeEntities($this->_subfieldValues[0]->getValue())));
         $view = CMS_view::getInstance();
         $view->addContent($content);
         return true;
     } else {
         //Old format
         //delete old files ?
         if (isset($values[$prefixName . $this->_field->getID() . '_delete']) && $values[$prefixName . $this->_field->getID() . '_delete'] == 1) {
             //thumbnail
             if ($this->_subfieldValues[1]->getValue()) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[1]->getValue());
                 $this->_subfieldValues[1]->setValue('');
             } elseif ($values[$prefixName . $this->_field->getID() . '_1_hidden']) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $values[$prefixName . $this->_field->getID() . '_1_hidden']);
                 $this->_subfieldValues[1]->setValue('');
             }
             //file
             if ($this->_subfieldValues[4]->getValue()) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[4]->getValue());
                 $this->_subfieldValues[4]->setValue('');
             } elseif ($values[$prefixName . $this->_field->getID() . '_4_hidden']) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $values[$prefixName . $this->_field->getID() . '_4_hidden']);
                 $this->_subfieldValues[4]->setValue('');
             }
             //reset filesize
             if (!$this->_subfieldValues[2]->setValue(0)) {
                 return false;
             }
         }
         if (!(isset($values[$prefixName . $this->_field->getID() . '_0']) && $this->_subfieldValues[0]->setValue(io::htmlspecialchars($values[$prefixName . $this->_field->getID() . '_0'])))) {
             return false;
         }
         //thumbnail
         if (isset($_FILES[$prefixName . $this->_field->getID() . '_1']) && $_FILES[$prefixName . $this->_field->getID() . '_1']['name'] && !$_FILES[$prefixName . $this->_field->getID() . '_1']['error']) {
             //check for image type before doing anything
             if (!in_array(io::strtolower(pathinfo($_FILES[$prefixName . $this->_field->getID() . '_1']["name"], PATHINFO_EXTENSION)), $this->_allowedExtensions)) {
                 return false;
             }
             //destroy old image if any
             if ($this->_subfieldValues[1]->getValue()) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[1]->getValue());
                 $this->_subfieldValues[1]->setValue('');
             } elseif ($values[$prefixName . $this->_field->getID() . '_1_hidden']) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $values[$prefixName . $this->_field->getID() . '_1_hidden']);
                 $this->_subfieldValues[1]->setValue('');
             }
             //set thumbnail (resize it if needed)
             //create thumbnail path
             $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED;
             $filename = "r" . $objectID . "_" . $this->_field->getID() . "_" . io::strtolower(SensitiveIO::sanitizeAsciiString($_FILES[$prefixName . $this->_field->getID() . '_1']["name"]));
             if (io::strlen($filename) > 255) {
                 $filename = sensitiveIO::ellipsis($filename, 255, '-', true);
             }
             //move uploaded file
             $fileDatas = CMS_file::uploadFile($prefixName . $this->_field->getID() . '_1', PATH_TMP_FS);
             if ($fileDatas['error']) {
                 return false;
             }
             if (!CMS_file::moveTo(PATH_TMP_FS . '/' . $fileDatas['filename'], $path . "/" . $filename)) {
                 return false;
             }
             if ($params['thumbMaxWidth'] > 0 || $params['thumbMaxHeight'] > 0) {
                 $oImage = new CMS_image($path . "/" . $filename);
                 //get current file size
                 $sizeX = $oImage->getWidth();
                 $sizeY = $oImage->getHeight();
                 //check thumbnail size
                 if ($sizeX > $params['thumbMaxWidth'] || $sizeX > $params['thumbMaxHeight']) {
                     $newSizeX = $sizeX;
                     $newSizeY = $sizeY;
                     // Check width
                     if ($params['thumbMaxWidth'] && $newSizeX > $params['thumbMaxWidth']) {
                         $newSizeY = round($params['thumbMaxWidth'] * $newSizeY / $newSizeX);
                         $newSizeX = $params['thumbMaxWidth'];
                     }
                     if ($params['thumbMaxHeight'] && $newSizeY > $params['thumbMaxHeight']) {
                         $newSizeX = round($params['thumbMaxHeight'] * $newSizeX / $newSizeY);
                         $newSizeY = $params['thumbMaxHeight'];
                     }
                     //resize image
                     $srcfilepath = $path . "/" . $filename;
                     $path_parts = pathinfo($srcfilepath);
                     $thumbnailFilename = io::substr($path_parts['basename'], 0, -(io::strlen($path_parts['extension']) + 1)) . '.png';
                     $destfilepath = $path . "/" . $thumbnailFilename;
                     if (!$oImage->resize($newSizeX, $newSizeY, $destfilepath)) {
                         return false;
                     }
                     //destroy original image
                     @unlink($srcfilepath);
                     //set resized thumbnail
                     if (!$this->_subfieldValues[1]->setValue($thumbnailFilename)) {
                         return false;
                     }
                 } else {
                     //no need to resize thumbnail (below the maximum width), so set it
                     if (!$this->_subfieldValues[1]->setValue($filename)) {
                         return false;
                     }
                 }
             } else {
                 //no need to resize thumbnail (no size limit), so set it
                 if (!$this->_subfieldValues[1]->setValue($filename)) {
                     return false;
                 }
             }
         } elseif (isset($_FILES[$prefixName . $this->_field->getID() . '_1']) && $_FILES[$prefixName . $this->_field->getID() . '_1']['name'] && $_FILES[$prefixName . $this->_field->getID() . '_1']['error'] != 0) {
             return false;
         } elseif (isset($values[$prefixName . $this->_field->getID() . '_1_hidden']) && $values[$prefixName . $this->_field->getID() . '_1_hidden'] && $values[$prefixName . $this->_field->getID() . '_delete'] != 1) {
             if (!$this->_subfieldValues[1]->setValue($values[$prefixName . $this->_field->getID() . '_1_hidden'])) {
                 return false;
             }
         }
         //File
         //1- from external location
         if (isset($values[$prefixName . $this->_field->getID() . '_externalfile']) && $values[$prefixName . $this->_field->getID() . '_externalfile']) {
             //destroy old file if any
             if ($this->_subfieldValues[4]->getValue()) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[4]->getValue());
                 $this->_subfieldValues[4]->setValue('');
             } elseif ($values[$prefixName . $this->_field->getID() . '_4_hidden']) {
                 @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $values[$prefixName . $this->_field->getID() . '_4_hidden']);
                 $this->_subfieldValues[4]->setValue('');
             }
             //from FTP directory
             $filename = $values[$prefixName . $this->_field->getID() . '_externalfile'];
             //io::substr($values[$prefixName.$this->_field->getID().'_externalfile'], 1);
             //check file extension
             if ($params['allowedType'] || $params['disallowedType']) {
                 $extension = io::strtolower(pathinfo($filename, PATHINFO_EXTENSION));
                 if (!$extension) {
                     return false;
                 }
                 //extension must be in allowed list
                 if ($params['allowedType'] && !in_array($extension, explode(',', io::strtolower($params['allowedType'])))) {
                     return false;
                 }
                 //extension must not be in disallowed list
                 if ($params['disallowedType'] && in_array($extension, explode(',', io::strtolower($params['disallowedType'])))) {
                     return false;
                 }
             }
             $new_filename = 'r' . $objectID . "_" . $this->_field->getID() . "_" . io::strtolower(SensitiveIO::sanitizeAsciiString($filename));
             if (io::strlen($new_filename) > 255) {
                 $new_filename = sensitiveIO::ellipsis($new_filename, 255, '-', true);
             }
             $destination_path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/';
             $ftp_dir = PATH_REALROOT_FS . $params['ftpDir'];
             if (@file_exists($ftp_dir . $filename) && is_file($ftp_dir . $filename)) {
                 if (@copy($ftp_dir . $filename, $destination_path . '/' . $new_filename)) {
                     @chmod($destination_path . '/' . $new_filename, octdec(FILES_CHMOD));
                     //set label as file name if none set
                     if (!$values[$prefixName . $this->_field->getID() . '_0']) {
                         if (!$this->_subfieldValues[0]->setValue(io::htmlspecialchars($filename))) {
                             return false;
                         }
                     }
                     //set it
                     if (!$this->_subfieldValues[4]->setValue($new_filename)) {
                         return false;
                     }
                     //and set filesize
                     $filesize = @filesize($destination_path . '/' . $new_filename);
                     if ($filesize !== false && $filesize > 0) {
                         //convert in MB
                         $filesize = round($filesize / 1048576, 2);
                     } else {
                         $filesize = '0';
                     }
                     if (!$this->_subfieldValues[2]->setValue($filesize)) {
                         return false;
                     }
                     //set file type
                     if (!$this->_subfieldValues[3]->setValue(self::OBJECT_FILE_TYPE_INTERNAL)) {
                         return false;
                     }
                 } else {
                     return false;
                 }
             } else {
                 return false;
             }
         } else {
             //2- from post
             if (isset($_FILES[$prefixName . $this->_field->getID() . '_4']) && $_FILES[$prefixName . $this->_field->getID() . '_4']['name'] && !$_FILES[$prefixName . $this->_field->getID() . '_4']['error']) {
                 //check file extension
                 if ($params['allowedType'] || $params['disallowedType']) {
                     $extension = io::strtolower(pathinfo($_FILES[$prefixName . $this->_field->getID() . '_4']['name'], PATHINFO_EXTENSION));
                     if (!$extension) {
                         return false;
                     }
                     //extension must be in allowed list
                     if ($params['allowedType'] && !in_array($extension, explode(',', io::strtolower($params['allowedType'])))) {
                         return false;
                     }
                     //extension must not be in disallowed list
                     if ($params['disallowedType'] && in_array($extension, explode(',', io::strtolower($params['disallowedType'])))) {
                         return false;
                     }
                 }
                 //set label as image name if none set
                 if (!$values[$prefixName . $this->_field->getID() . '_0']) {
                     if (!$this->_subfieldValues[0]->setValue(io::htmlspecialchars($_FILES[$prefixName . $this->_field->getID() . '_4']["name"]))) {
                         return false;
                     }
                 }
                 //set file type
                 if (!$this->_subfieldValues[3]->setValue(self::OBJECT_FILE_TYPE_INTERNAL)) {
                     return false;
                 }
                 //destroy old file if any
                 if ($this->_subfieldValues[4]->getValue()) {
                     @unlink(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[4]->getValue());
                     $this->_subfieldValues[4]->setValue('');
                 }
                 //create thumnail path
                 $path = PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED;
                 $filename = "r" . $objectID . "_" . $this->_field->getID() . "_" . io::strtolower(SensitiveIO::sanitizeAsciiString($_FILES[$prefixName . $this->_field->getID() . '_4']["name"]));
                 if (io::strlen($filename) > 255) {
                     $filename = sensitiveIO::ellipsis($filename, 255, '-', true);
                 }
                 //move uploaded file
                 $fileDatas = CMS_file::uploadFile($prefixName . $this->_field->getID() . '_4', PATH_TMP_FS);
                 if ($fileDatas['error']) {
                     return false;
                 }
                 if (!CMS_file::moveTo(PATH_TMP_FS . '/' . $fileDatas['filename'], $path . "/" . $filename)) {
                     return false;
                 }
                 //set it
                 if (!$this->_subfieldValues[4]->setValue($filename)) {
                     return false;
                 }
                 //and set filesize
                 $filesize = @filesize($path . "/" . $filename);
                 if ($filesize !== false && $filesize > 0) {
                     //convert in MB
                     $filesize = round($filesize / 1048576, 2);
                 } else {
                     $filesize = '0';
                 }
                 if (!$this->_subfieldValues[2]->setValue($filesize)) {
                     return false;
                 }
             } elseif (isset($_FILES[$prefixName . $this->_field->getID() . '_4']) && $_FILES[$prefixName . $this->_field->getID() . '_4']['name'] && $_FILES[$prefixName . $this->_field->getID() . '_4']['error'] != 0) {
                 return false;
             } else {
                 //from hidden fields (previously set but not already saved)
                 if (isset($values[$prefixName . $this->_field->getID() . '_4_hidden']) && $values[$prefixName . $this->_field->getID() . '_4_hidden'] && (!isset($values[$prefixName . $this->_field->getID() . '_delete']) || $values[$prefixName . $this->_field->getID() . '_delete'] != 1)) {
                     //set label as image name if none set
                     if ($values[$prefixName . $this->_field->getID() . '_0']) {
                         if (!$this->_subfieldValues[0]->setValue(io::htmlspecialchars($values[$prefixName . $this->_field->getID() . '_0']))) {
                             return false;
                         }
                     }
                     //set filesize
                     if (!$this->_subfieldValues[2]->setValue($values[$prefixName . $this->_field->getID() . '_2_hidden'])) {
                         return false;
                     }
                     //set file type
                     if (!$this->_subfieldValues[3]->setValue($values[$prefixName . $this->_field->getID() . '_3_hidden'])) {
                         return false;
                     }
                     if (!$this->_subfieldValues[4]->setValue($values[$prefixName . $this->_field->getID() . '_4_hidden'])) {
                         return false;
                     }
                 }
             }
         }
         // If label not set yet, set it
         if (!$this->_subfieldValues[0]->getValue()) {
             if ($this->_subfieldValues[4]->getValue()) {
                 $this->_subfieldValues[0]->setValue($this->_subfieldValues[4]->getValue());
             }
         }
         return true;
     }
 }
    foreach ($tplReplacements['nomatch'] as $noMatchTpl) {
        $src = PATH_TEMPLATES_IMAGES_WR . '/' . ($noMatchTpl->getImage() ? $noMatchTpl->getImage() : 'nopicto.gif');
        $description = sensitiveIO::ellipsis($noMatchTpl->getDescription(), 100);
        if ($description != $noMatchTpl->getDescription()) {
            $description = '<span ext:qtip="' . io::htmlspecialchars(strip_tags($noMatchTpl->getDescription())) . '">' . io::htmlspecialchars($description) . '</span>';
        } else {
            $description = io::htmlspecialchars($description);
        }
        $description = $description ? $description . '<br />' : '';
        $templates[] = array('id' => $noMatchTpl->getID(), 'label' => $noMatchTpl->getLabel(), 'image' => $src, 'groups' => implode(', ', $noMatchTpl->getGroups()), 'compatible' => false, 'description' => '<div' . (!$noMatchTpl->isUseable() ? ' class="atm-inactive"' : '') . '>' . '<img src="' . (PATH_TEMPLATES_IMAGES_WR . '/' . ($noMatchTpl->getImage() ? $noMatchTpl->getImage() : 'nopicto.gif')) . '" style="float:left;margin-right:3px;max-width:80px;" />' . '<strong><span class="atm-red">' . $cms_language->getMessage(MESSAGE_PAGE_UNMATCHING_TEMPLATE) . '</span></strong><br />' . $description . $cms_language->getMessage(MESSAGE_PAGE_GROUPS) . ' : <strong>' . implode(', ', $noMatchTpl->getGroups()) . '</strong><br />' . '<br class="x-form-clear" />' . '</div>');
    }
    //if page template no set in list, add it in first position
    if ($pageTplId === 0) {
        $pageTplId = CMS_pageTemplatesCatalog::getTemplateIDForCloneID($pageTemplate->getID());
        $src = PATH_TEMPLATES_IMAGES_WR . '/' . ($pageTemplate->getImage() ? $pageTemplate->getImage() : 'nopicto.gif');
        $description = sensitiveIO::ellipsis($pageTemplate->getDescription(), 100);
        if ($description != $pageTemplate->getDescription()) {
            $description = '<span ext:qtip="' . io::htmlspecialchars(strip_tags($pageTemplate->getDescription())) . '">' . io::htmlspecialchars($description) . '</span>';
        } else {
            $description = io::htmlspecialchars($description);
        }
        $description = $description ? $description . '<br />' : '';
        array_unshift($templates, array('id' => $pageTplId, 'label' => $pageTemplate->getLabel(), 'image' => $src, 'groups' => implode(', ', $pageTemplate->getGroups()), 'compatible' => true, 'description' => '<div' . (!$pageTemplate->isUseable() ? ' class="atm-inactive"' : '') . '>' . '<img src="' . (PATH_TEMPLATES_IMAGES_WR . '/' . ($pageTemplate->getImage() ? $pageTemplate->getImage() : 'nopicto.gif')) . '" style="float:left;margin-right:3px;max-width:80px;" />' . '<strong>' . $cms_language->getMessage(MESSAGE_PAGE_MATCHING_TEMPLATE) . '</strong><br />' . $description . $cms_language->getMessage(MESSAGE_PAGE_GROUPS) . ' : <strong>' . implode(', ', $pageTemplate->getGroups()) . '</strong><br />' . '<br class="x-form-clear" />' . '</div>'));
    }
    $templatesDatas = array();
    $templatesDatas = array('results' => $templates);
} else {
    if (!$items) {
        //filter by page if needed
        $pageTplIds = array();
        if ($pageId) {
 * 
 * @package Automne
 * @subpackage admin
 * @author Sébastien Pauchet <*****@*****.**>
 */
require_once dirname(__FILE__) . '/../../cms_rc_admin.php';
//load interface instance
$view = CMS_view::getInstance();
//set default display mode for this page
$view->setDisplayMode(CMS_view::SHOW_RAW);
//This file is an admin file. Interface must be secure
$view->setSecure();
define('MESSAGE_PAGE_NO_BOOKMARKS', 645);
$content = '';
$favorites = $cms_user->getFavorites();
if ($favorites) {
    foreach ($favorites as $pageId) {
        $page = CMS_tree::getPageById($pageId);
        if (is_object($page) && $page->getTitle() && !$page->hasError()) {
            $content .= '<li><a href="#" atm:action="favorite" atm:page="' . $pageId . '" alt="' . io::htmlspecialchars($page->getTitle()) . '" title="' . io::htmlspecialchars($page->getTitle()) . '">' . $page->getStatus()->getHTML(true, $cms_user, MOD_STANDARD_CODENAME, $page->getID()) . '&nbsp;' . sensitiveIO::ellipsis($page->getTitle(), 32) . '&nbsp;(' . $pageId . ')</a></li>';
        }
    }
}
if ($content) {
    $content = '<ul>' . $content . '</ul>';
} else {
    $content .= $cms_language->getMessage(MESSAGE_PAGE_NO_BOOKMARKS);
}
//send content
$view->setContent($content);
$view->show();
Exemple #12
0
 /**
  * get HTML admin (used to enter object values in admin)
  *
  * @param integer $fieldID, the current field id (only for poly object compatibility)
  * @param CMS_language $language, the current admin language
  * @param string prefixname : the prefix to use for post names
  * @return string : the html admin
  * @access public
  */
 function getHTMLAdmin($fieldID, $language, $prefixName)
 {
     $return = parent::getHTMLAdmin($fieldID, $language, $prefixName);
     $params = $this->getParamsValues();
     //is this field mandatory ?
     $mandatory = $this->_field->getValue('required') ? '<span class="atm-red">*</span> ' : '';
     $desc = $this->getFieldDescription($language);
     //create object CMS_date
     $date = new CMS_date();
     $date->setFromDBValue($this->_subfieldValues[0]->getValue());
     $dateFormat = $language->getDateFormat();
     $dateMask = $language->getDateFormatMask();
     $wasNull = $date->isNull() ? true : false;
     if ($date->isNull() && ($params['setNow'] || $params['creationDate'])) {
         $date->setNow();
     }
     if ($params['updateDate']) {
         $date->setNow();
     }
     if ($params['moveDate'] && ($params['setNow'] && $wasNull || $params['creationDate'] && $wasNull || $params['updateDate'])) {
         $date->moveDate($params['moveDate']);
     }
     if (!$params['creationDate'] && !$params['updateDate']) {
         $desc .= ($desc ? ' - ' : '') . $language->getMessage(self::MESSAGE_OBJECT_DATE_DATE_COMMENT, array($dateMask));
     }
     if (POLYMOD_DEBUG) {
         $values = array();
         foreach (array_keys($this->_subfieldValues) as $subFieldID) {
             if (is_object($this->_subfieldValues[$subFieldID])) {
                 $values[$subFieldID] = sensitiveIO::ellipsis(strip_tags($this->_subfieldValues[$subFieldID]->getValue()), 50);
             }
         }
         $desc .= $desc ? '<br />' : '';
         $desc .= '<span class="atm-red">Field : ' . $fieldID . ' - Value(s) : <ul>';
         foreach ($values as $subFieldID => $value) {
             $desc .= '<li>' . $subFieldID . '&nbsp;:&nbsp;' . $value . '</li>';
         }
         $desc .= '</ul></span>';
     }
     $label = $desc ? '<span class="atm-help" ext:qtip="' . io::htmlspecialchars($desc) . '">' . $mandatory . $this->getFieldLabel($language) . '</span>' : $mandatory . $this->getFieldLabel($language);
     if ($params['withHMS']) {
         $hms = !$date->isNull() ? $date->getHour() . ':' . $date->getMinute() . ':' . $date->getSecond() : '';
         $return = array('layout' => 'column', 'xtype' => 'panel', 'border' => false, 'items' => array(array('width' => 230, 'layout' => 'form', 'border' => false, 'items' => array(array('allowBlank' => !$this->_field->getValue('required'), 'name' => $return['name'], 'xtype' => 'datefield', 'fieldLabel' => $label, 'value' => !$date->isNull() ? $date->getLocalizedDate($dateFormat) : '', 'format' => $dateFormat, 'disabled' => $params['creationDate'] || $params['updateDate']))), array('columnWidth' => 1, 'layout' => 'form', 'border' => false, 'labelWidth' => 55, 'items' => array(array('xtype' => 'textfield', 'fieldLabel' => '<span class="atm-help" ext:qtip="' . io::htmlspecialchars($language->getMessage(self::MESSAGE_OBJECT_DATE_DATE_COMMENT, array($language->getMessage(self::MESSAGE_OBJECT_DATE_HMS_FORMAT, false, MOD_POLYMOD_CODENAME)))) . '">' . $language->getMessage(self::MESSAGE_OBJECT_DATE_HOURS, false, MOD_POLYMOD_CODENAME) . '</span>', 'value' => $hms, 'name' => 'polymodFieldsValue[' . $prefixName . $this->_field->getID() . '_1]', 'disabled' => $params['creationDate'] || $params['updateDate'])))));
     } else {
         $return['fieldLabel'] = $label;
         $return['xtype'] = 'datefield';
         $return['value'] = !$date->isNull() ? $date->getLocalizedDate($dateFormat) : '';
         $return['format'] = $dateFormat;
         $return['width'] = 100;
         $return['anchor'] = false;
         $return['disabled'] = $params['creationDate'] || $params['updateDate'];
     }
     return $return;
 }
 /**
  * Upload a file with as much as security we can
  *
  * @param string $fileVarName, var name in which we can found the file in $_FILES
  * @param string $destinationDirFS, the destination dir in which we want the file to be moved
  * @return array of uploaded file meta datas
  */
 function uploadFile($fileVarName = 'Filedata', $destinationDirFS = PATH_UPLOAD_FS)
 {
     //for security, clean all files older than 4h in both uploads directories
     $yesterday = time() - 14400;
     //4h
     try {
         foreach (new DirectoryIterator(PATH_UPLOAD_FS) as $file) {
             if ($file->isFile() && $file->getFilename() != ".htaccess" && $file->getMTime() < $yesterday) {
                 @unlink($file->getPathname());
             }
         }
     } catch (Exception $e) {
     }
     try {
         foreach (new DirectoryIterator(PATH_UPLOAD_VAULT_FS) as $file) {
             if ($file->isFile() && $file->getFilename() != ".htaccess" && $file->getMTime() < $yesterday) {
                 @unlink($file->getPathname());
             }
         }
     } catch (Exception $e) {
     }
     //init returned file datas
     $fileDatas = array('error' => 0, 'filename' => '', 'filepath' => '', 'filesize' => '', 'fileicon' => '', 'success' => false);
     // Check if the upload exists
     if (!isset($_FILES[$fileVarName]) || !is_uploaded_file($_FILES[$fileVarName]["tmp_name"]) || $_FILES[$fileVarName]["error"] != 0) {
         CMS_grandFather::raiseError('Uploaded file has an error : ' . print_r($_FILES, true));
         $fileDatas['error'] = CMS_file::UPLOAD_UPLOAD_FAILED;
         $view->setContent($fileDatas);
         $view->show();
     }
     //move uploaded file to upload vault (and rename it with a clean name if needed)
     $originalFilename = io::sanitizeAsciiString($_FILES[$fileVarName]["name"]);
     if (io::strlen($originalFilename) > 250) {
         $originalFilename = sensitiveIO::ellipsis($originalFilename, 250, '-');
     }
     //remove multiple extensions to avoid double extension threat (cf. http://www.acunetix.com/websitesecurity/upload-forms-threat.htm)
     if (substr_count('.', $originalFilename) > 1) {
         $parts = pathinfo($originalFilename);
         $originalFilename = str_replace('.', '-', $parts['filename']) . '.' . $parts['extension'];
     }
     $count = 2;
     $filename = $originalFilename;
     while (file_exists(PATH_UPLOAD_VAULT_FS . '/' . $filename) || file_exists($destinationDirFS . '/' . $filename)) {
         $pathinfo = pathinfo($originalFilename);
         $filename = $pathinfo['filename'] . '-' . $count++ . '.' . $pathinfo['extension'];
     }
     if (!@move_uploaded_file($_FILES[$fileVarName]["tmp_name"], PATH_UPLOAD_VAULT_FS . '/' . $filename)) {
         CMS_grandFather::raiseError('Can\'t move uploaded file to : ' . PATH_UPLOAD_VAULT_FS . '/' . $filename);
         $fileDatas['error'] = CMS_file::UPLOAD_FILE_VALIDATION_FAILED;
         return $fileDatas;
     }
     $file = new CMS_file(PATH_UPLOAD_VAULT_FS . '/' . $filename);
     $file->chmod(FILES_CHMOD);
     //check uploaded file
     if (!$file->checkUploadedFile()) {
         $file->delete();
         $fileDatas['error'] = CMS_file::UPLOAD_SECURITY_ERROR;
         return $fileDatas;
     }
     //move file to final directory
     if (!CMS_file::moveTo(PATH_UPLOAD_VAULT_FS . '/' . $filename, $destinationDirFS . '/' . $filename)) {
         $fileDatas['error'] = CMS_file::UPLOAD_FILE_VALIDATION_FAILED;
         return $fileDatas;
     }
     $file = new CMS_file($destinationDirFS . '/' . $filename);
     $file->chmod(FILES_CHMOD);
     //return file datas
     $fileDatas = array('error' => 0, 'filename' => $file->getName(false), 'filepath' => $file->getFilePath(CMS_file::WEBROOT), 'filesize' => $file->getFileSize(), 'fileicon' => $file->getFileIcon(CMS_file::WEBROOT), 'extension' => $file->getExtension(), 'success' => true);
     return $fileDatas;
 }