/** 
  * Get the default language code for this module
  * Comes from parameters or Constant
  * Upgrades constant with parameter found
  *
  * @return String the language codename
  * @access public
  */
 function getDefaultLanguageCodename()
 {
     if (!defined("MOD_" . io::strtoupper($this->getCodename()) . "_DEFAULT_LANGUAGE")) {
         $polymodLanguages = CMS_object_i18nm::getAvailableLanguages();
         define("MOD_" . io::strtoupper($this->getCodename()) . "_DEFAULT_LANGUAGE", $polymodLanguages[0]);
     }
     return constant("MOD_" . io::strtoupper($this->getCodename()) . "_DEFAULT_LANGUAGE");
 }
Beispiel #2
0
define("MESSAGE_PAGE_TREEH1", 1049);
define("MESSAGE_FIELD_NO", 1083);
define("MESSAGE_FIELD_YES", 1082);
//Polymod messages
define("MESSAGE_PAGE_FIELD_INDEXABLE", 322);
//checks rights
if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) {
    header("Location: " . PATH_ADMIN_SPECIAL_ENTRY_WR . "?cms_message_id=" . MESSAGE_PAGE_CLEARANCE_ERROR . "&" . session_name() . "=" . session_id());
    exit;
}
//load page objects and vars
$moduleCodename = $_POST["moduleCodename"] ? $_POST["moduleCodename"] : $_GET["moduleCodename"];
$object = new CMS_poly_object_definition($_POST["object"]);
$field = new CMS_poly_object_field($_POST["field"]);
$label = new CMS_object_i18nm($field->getValue("labelID"));
$description = new CMS_object_i18nm($field->getValue("descriptionID"));
$availableLanguagesCodes = CMS_object_i18nm::getAvailableLanguages();
$cms_message = "";
// ****************************************************************
// ** ACTIONS MANAGEMENT                                         **
// ****************************************************************
switch ($_POST["cms_action"]) {
    case "validate":
        //checks and assignments
        $field->setDebug(false);
        if (!$_POST["label" . $availableLanguagesCodes[0]] || !$_POST["type"]) {
            $cms_message .= $cms_language->getMessage(MESSAGE_FORM_ERROR_MANDATORY_FIELDS);
        }
    case 'switchexplanation':
    case "newtype":
        if ($_POST["label" . $availableLanguagesCodes[0]]) {
 /**
  * Import field from given array datas
  *
  * @param array $data The module datas to import
  * @param array $params The import parameters.
  *		array(
  *				create	=> false|true : create missing objects (default : true)
  *				update	=> false|true : update existing objects (default : true)
  *				files	=> false|true : use files from PATH_TMP_FS (default : true)
  *			)
  * @param CMS_language $cms_language The CMS_langage to use
  * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids
  * @param string $infos : Reference : The import infos returned
  * @return boolean : true on success, false on failure
  * @access public
  */
 function fromArray($data, $params, $cms_language, &$idsRelation, &$infos)
 {
     if (isset($data['labels'])) {
         $label = new CMS_object_i18nm($this->getValue("labelID"));
         $label->setValues($data['labels']);
         $label->writeToPersistence();
         $this->setValue("labelID", $label->getID());
     }
     if (isset($data['descriptions'])) {
         $description = new CMS_object_i18nm($this->getValue("descriptionID"));
         $description->setValues($data['descriptions']);
         $description->writeToPersistence();
         $this->setValue("descriptionID", $description->getID());
     }
     if (isset($data['type']) && $data['type']) {
         $type = !io::isPositiveInteger($data['type']) ? $data['type'] : (isset($data['multi']) && $data['multi'] ? 'multi|' . $data['type'] : $data['type']);
         if (!io::isPositiveInteger($data['type'])) {
             $type = $data['type'];
         } else {
             if (isset($idsRelation['objects'][$data['type']])) {
                 $objectId = $idsRelation['objects'][$data['type']];
                 $type = isset($data['multi']) && $data['multi'] ? 'multi|' . $objectId : $objectId;
             } else {
                 // Use UUID to look for the linked object
                 if (isset($data['params']['linkedObjectUuid'])) {
                     //$this->setValue("order", $data['params']['order']);
                     $linkedObjectDef = CMS_poly_object_catalog::getDefinitionFromUuid($data['params']['linkedObjectUuid']);
                     if ($linkedObjectDef) {
                         $objectId = $linkedObjectDef->getID();
                         $type = isset($data['multi']) && $data['multi'] ? 'multi|' . $objectId : $objectId;
                     } else {
                         $type = 'Unknown imported type ' . $data['type'];
                     }
                 } else {
                     $type = 'Unknown imported type ' . $data['type'];
                 }
             }
         }
         $this->setValue("type", $type);
     } else {
         $infos .= 'Error : missing or invalid type for field importation ...' . "\n";
         return false;
     }
     if (!$this->getID() && CMS_poly_object_catalog::fieldUuidExists($data['uuid'])) {
         //check imported uuid. If objects does not have an Id, the uuid must be unique or must be regenerated
         $uuid = io::uuid();
         //store old uuid relation
         $idsRelation['fields-uuid'][$data['uuid']] = $uuid;
         $data['uuid'] = $uuid;
     }
     //set object uuid if not exists
     if (!$this->_objectFieldValues["uuid"]) {
         $this->_objectFieldValues["uuid"] = $data['uuid'];
     }
     //if current object id has changed from imported id, set relation
     if (isset($idsRelation['objects'][$data['objectID']]) && $idsRelation['objects'][$data['objectID']]) {
         $this->setValue("objectID", $idsRelation['objects'][$data['objectID']]);
     } else {
         $this->setValue("objectID", $data['objectID']);
     }
     if (isset($data['params']['order'])) {
         $this->setValue("order", $data['params']['order']);
     }
     if (isset($data['params']['required'])) {
         $this->setValue("required", $data['params']['required']);
     }
     if (isset($data['params']['indexable'])) {
         $this->setValue("indexable", $data['params']['indexable']);
     }
     if (isset($data['params']['searchlist'])) {
         $this->setValue("searchlist", $data['params']['searchlist']);
     }
     if (isset($data['params']['searchable'])) {
         $this->setValue("searchable", $data['params']['searchable']);
     }
     //parameters
     if (!io::isPositiveInteger($data['type']) || isset($data['multi']) && $data['multi']) {
         $fieldObject = $this->getTypeObject();
         $GLOBALS['moduleCodename'] = $params['module'];
         if ($fieldObject && isset($data['params']['params']) && $data['params']['params']) {
             if (method_exists($fieldObject, 'treatParams')) {
                 $params = $fieldObject->treatParams($data['params']['params'], '');
                 if ($params) {
                     $this->setValue("params", $params);
                     //set this object into definition to convert array so it can be converted again at end of import process
                     $idsRelation['definitionToConvert'][] = $this;
                     //store field to convert params at end of import
                     if (method_exists($fieldObject, 'importParams')) {
                         $idsRelation['paramsFieldsToConvert'][] = $this;
                     }
                 } else {
                     $infos .= 'Error : missing or invalid parameters for field importation ...' . "\n";
                     return false;
                 }
             }
         }
     }
     //write field
     if (!$this->writeToPersistence()) {
         $infos .= 'Error : can not write object field ...' . "\n";
         return false;
     }
     //if current field id has changed from imported id, set relation
     if (isset($data['id']) && $data['id'] && $this->getID() != $data['id']) {
         $idsRelation['fields'][$data['id']] = $this->getID();
         if (isset($data['uuid']) && $data['uuid']) {
             $idsRelation['fields'][$data['uuid']] = $this->getID();
         }
     }
     return true;
 }
Beispiel #4
0
    /**
     * get HTML admin subfields parameters (used to enter object parameters values in admin)
     *
     * @return string : the html admin
     * @access public
     */
    function getHTMLSubFieldsParameters($language, $prefixName)
    {
        if (!is_a($language, 'CMS_language')) {
            $this->raiseError("Language must be a CMS_language object : " . print_r($language, true));
            return false;
        }
        $values = $this->_parameterValues;
        $html = '';
        $parameters = $this->getSubFieldParameters();
        foreach ($parameters as $parameterID => $parameter) {
            $paramValue = $values[$parameterID];
            switch ($parameter['type']) {
                case 'boolean':
                    $yes = $paramValue ? ' selected="selected"' : '';
                    $input = '<select name="' . $prefixName . $parameter['internalName'] . '" class="admin_input_text">
						<option value="0">' . $language->getMessage(self::MESSAGE_FIELD_NO) . '</option>
						<option value="1"' . $yes . '>' . $language->getMessage(self::MESSAGE_FIELD_YES) . '</option>
					</select>';
                    break;
                case 'integer':
                case 'date':
                case 'string':
                    $input = '<input type="text" size="30" name="' . $prefixName . $parameter['internalName'] . '" class="admin_input_text" value="' . io::htmlspecialchars($paramValue) . '" />';
                    break;
                case 'text':
                    $input = '<textarea cols="70" rows="4" name="' . $prefixName . $parameter['internalName'] . '" class="admin_input_text">' . io::htmlspecialchars($paramValue) . '</textarea>';
                    break;
                case 'fields':
                    //get all fields for current object
                    $fields = CMS_poly_object_catalog::getFieldsDefinition($this->_field->getValue('objectID'));
                    $selectValues = array();
                    foreach ($fields as $field) {
                        $label = new CMS_object_i18nm($field->getValue("labelID"));
                        $selectValues[$field->getID()] = $label->getValue($language->getCode());
                    }
                    $selectedValues = explode(';', $paramValue);
                    $listboxesParameters = array('field_name' => $prefixName . $parameter['internalName'], 'items_possible' => $selectValues, 'items_selected' => $selectedValues, 'select_width' => '300px', 'select_height' => '200px', 'form_name' => 'frm');
                    $input = CMS_dialog_listboxes::getListBoxes($listboxesParameters);
                    break;
                default:
                    if ($parameter['type'] && method_exists($this, "getHTMLSubFieldsParameters" . $parameter['type'])) {
                        $method = "getHTMLSubFieldsParameters" . $parameter['type'];
                        $input = $this->{$method}($language, $prefixName, $parameter);
                    } else {
                        $this->raiseError("Can't get parameter HTML for type : " . $parameter['type']);
                        return false;
                    }
                    break;
            }
            if ($input) {
                $paramLabel = sensitiveIO::isPositiveInteger($parameter['externalName']) ? $language->getMessage($parameter['externalName'], false, $this->_messagesModule) : 'Undefined';
                $paramDescription = isset($parameter['description']) && sensitiveIO::isPositiveInteger($parameter['description']) ? '<br /><small>' . $language->getMessage($parameter['description'], false, $this->_messagesModule) . '</small>' : '';
                $required = $parameter['required'] ? '<span class="admin_text_alert">*</span>' : '';
                $html .= '
				<tr>
					<td class="admin" align="right" valign="top">' . $required . $paramLabel . '</td>
					<td class="admin" valign="top">' . $input . $paramDescription . '</td>
				</tr>';
            }
        }
        $html = $html ? '<table border="0" cellpadding="3" cellspacing="0" style="border-left:1px solid #4d4d4d;">' . $html . '</table>' : '';
        return $html;
    }
Beispiel #5
0
     $searchParamContent[] = array('fieldLabel' => $mandatory . $cms_language->getMessage(MESSAGE_PAGE_FIELD_LIMIT, false, MOD_POLYMOD_CODENAME), 'name' => 'value[search][' . $searchName . '][' . $paramType . ']', 'anchor' => '99%', 'allowNegative' => false, 'allowDecimals' => false, 'xtype' => 'numberfield', 'allowBlank' => !$mandatory, 'value' => $value);
     break;
 case 'order':
     if (sizeof($paramValue)) {
         $orderNameList = array('objectID' => MESSAGE_PAGE_FIELD_ORDER_OBJECTID, 'random' => MESSAGE_PAGE_FIELD_ORDER_RANDOM, 'publication date after' => MESSAGE_PAGE_FIELD_ORDER_PUBLICATION_START, 'publication date before' => MESSAGE_PAGE_FIELD_ORDER_PUBLICATION_END);
         $searchOrderContent = array();
         foreach ($paramValue as $orderName => $orderValue) {
             $fieldLabel = '';
             if (in_array($orderName, CMS_object_search::getStaticOrderConditionTypes())) {
                 $fieldLabel = $cms_language->getMessage($orderNameList[$orderName], false, MOD_POLYMOD_CODENAME);
             } else {
                 $orderName = trim($orderName, '()');
                 if (io::isPositiveInteger($orderName)) {
                     $field = new CMS_poly_object_field($orderName);
                     if ($field && !$field->hasError()) {
                         $label = new CMS_object_i18nm($field->getValue('labelID'));
                         $fieldLabel = $label->getValue($cms_language->getCode());
                     }
                 }
             }
             if ($fieldLabel) {
                 // Order direction
                 $mandatory = $paramValue == true ? '<span class="atm-red">*</span> ' : '';
                 $value = isset($data["value"]['search'][$searchName][$paramType][$orderName]) ? $data["value"]['search'][$searchName][$paramType][$orderName] : '';
                 $searchOrderContent[] = array('xtype' => 'atmCombo', 'fieldLabel' => $mandatory . $fieldLabel, 'name' => 'value[search][' . $searchName . '][' . $paramType . '][' . $orderName . ']', 'hiddenName' => 'value[search][' . $searchName . '][' . $paramType . '][' . $orderName . ']', 'forceSelection' => true, 'mode' => 'local', 'valueField' => 'id', 'displayField' => 'name', 'triggerAction' => 'all', 'allowBlank' => !$mandatory, 'selectOnFocus' => true, 'editable' => false, 'value' => $value, 'store' => array('xtype' => 'arraystore', 'fields' => array('id', 'name'), 'data' => array(array('', '-'), array('asc', $cms_language->getMessage(MESSAGE_PAGE_FIELD_ORDER_ASC, false, MOD_POLYMOD_CODENAME)), array('desc', $cms_language->getMessage(MESSAGE_PAGE_FIELD_ORDER_DESC, false, MOD_POLYMOD_CODENAME)))));
             } else {
                 $cms_message .= $cms_language->getMessage(MESSAGE_PAGE_SEARCH_ORDERTYPE_ERROR, array($searchName, $row->getLabel(), $orderName), MOD_POLYMOD_CODENAME) . "\n";
             }
         }
         $searchParamContent[] = array('title' => $cms_language->getMessage(MESSAGE_PAGE_FIELD_ORDER, false, MOD_POLYMOD_CODENAME), 'xtype' => 'fieldset', 'autoHeight' => true, 'defaults' => array('anchor' => '97%'), 'items' => $searchOrderContent);
     }
 /**
  * get object description
  *
  * @param mixed $language the language code (string) or the CMS_language (object) to use for description
  * @return string, the description
  * @access public
  */
 function getDescription($language)
 {
     //get object definition
     $objectDef = $this->getObjectDefinition();
     $description = new CMS_object_i18nm($objectDef->getValue("descriptionID"));
     if (is_a($language, "CMS_language")) {
         $subdesc = $description->getValue($language->getCode());
         return $language->getMessage($this->_objectDescription, array($subdesc), MOD_POLYMOD_CODENAME);
     } else {
         $subdesc = $description->getValue($language);
         $tmplanguage = new CMS_language($language);
         return $tmplanguage->getMessage($this->_objectDescription, array($subdesc), MOD_POLYMOD_CODENAME);
     }
 }
Beispiel #7
0
            $content .= '
					<th width="70" class="admin">' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_INDEXABLE, false, MOD_POLYMOD_CODENAME) . '</th>';
        }
        $content .= '
			<th width="150" class="admin">' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_ACTIONS) . '</th>
			<th width="36" class="admin">' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_ORDER) . '</th>
		</tr>
		</table>
		<ul id="fields" class="sortable">
		';
        $count = 0;
        foreach ($fields as $field) {
            $count++;
            $td_class = $count % 2 == 0 ? "admin_lightgreybg" : "admin_darkgreybg";
            $type = $field->getValue("type");
            $label = new CMS_object_i18nm($field->getValue("labelID"));
            $typeObject = $field->getTypeObject(true);
            if (is_object($typeObject)) {
                $content .= '
				<li id="f' . $field->getID() . '" alt="ID : ' . $field->getID() . '" title="ID : ' . $field->getID() . '">
					<table border="0" cellpadding="2" cellspacing="2">
					<tr>
						<td width="150" class="' . $td_class . '">' . $label->getValue($cms_language->getCode());
                if (POLYMOD_DEBUG) {
                    $content .= ' <span class="admin_text_alert"><small>(FieldID : ' . $field->getID() . ')</small></span>';
                }
                $content .= '
						</td>
						<td width="150" class="' . $td_class . '">' . $typeObject->getObjectLabel($cms_language) . '</td>
						<td width="200" class="' . $td_class . '">' . $typeObject->getDescription($cms_language) . '</td>';
                //if ASE module exists, add field indexation options
Beispiel #8
0
 /**
  * get an object value
  *
  * @param string $name : the name of the value to get
  * @param string $parameters (optional) : parameters for the value to get
  * @return mixed : the object values structure
  * @access public
  */
 function getValue($name, $parameters = '')
 {
     global $cms_language;
     // @TODOV4 : Manage language into database !
     $languages = array();
     $languages['fr'] = array('January' => 'Janvier', 'February' => 'F&eacute;vrier', 'March' => 'Mars', 'April' => 'Avril', 'May' => 'Mai', 'June' => 'Juin', 'July' => 'Juillet', 'August' => 'Ao&ucirc;t', 'September' => 'Septembre', 'October' => 'Octobre', 'November' => 'Novembre', 'December' => 'D&eacute;cembre', 'Monday' => 'Lundi', 'Tuesday' => 'Mardi', 'Wednesday' => 'Mercredi', 'Thursday' => 'Jeudi', 'Friday' => 'Vendredi', 'Saturday' => 'Samedi', 'Sunday' => 'Dimanche', 'Jan' => 'Jan', 'Feb' => 'F&eacute;v', 'Mar' => 'Mar', 'Apr' => 'Avr', 'May' => 'Mai', 'Jun' => 'Jui', 'Jul' => 'Jui', 'Aug' => 'Ao&ucirc;', 'Sep' => 'Sep', 'Oct' => 'Oct', 'Nov' => 'Nov', 'Dec' => 'D&eacute;c', 'Mon' => 'Lun', 'Tue' => 'Mar', 'Wed' => 'Mer', 'Thu' => 'Jeu', 'Fri' => 'Ven', 'Sat' => 'Sam', 'Sun' => 'Dim');
     switch ($name) {
         case 'id':
             return (string) $this->_ID;
             break;
         case 'label':
             if ($parameters == 'js') {
                 return sensitiveIO::sanitizeJSString($this->getLabel());
             } else {
                 return $this->getLabel();
             }
             break;
         case 'objectname':
             return $this->getFieldLabel($cms_language);
             break;
         case 'objectdescription':
             return $this->getFieldDesc($cms_language);
             break;
         case 'objecttype':
             return $this->_objectID;
             break;
         case 'resource':
             if ($this->_objectResourceStatus == 1) {
                 return parent::getID();
             }
             return;
             break;
         case 'formatedDateStart':
             if ($this->_objectResourceStatus == 1) {
                 $date = parent::getPublicationDateStart();
                 if (io::strtolower($parameters) == 'rss') {
                     $date = date('r', $date->getTimeStamp());
                 } else {
                     $date = date($parameters, $date->getTimeStamp());
                     if (is_object($cms_language) && isset($languages[$cms_language->getCode()])) {
                         $date = str_replace(array_keys($languages[$cms_language->getCode()]), $languages[$cms_language->getCode()], $date);
                     }
                 }
                 return io::htmlspecialchars($date);
             }
             break;
         case 'formatedDateEnd':
             if ($this->_objectResourceStatus == 1) {
                 $date = parent::getPublicationDateEnd();
                 if (is_a($date, 'CMS_date')) {
                     if (io::strtolower($parameters) == 'rss') {
                         $date = date('r', $date->getTimeStamp());
                     } else {
                         $date = date($parameters, $date->getTimeStamp());
                         if (is_object($cms_language) && isset($languages[$cms_language->getCode()])) {
                             $date = str_replace(array_keys($languages[$cms_language->getCode()]), $languages[$cms_language->getCode()], $date);
                         }
                     }
                     return io::htmlspecialchars($date);
                 }
             }
             break;
         case 'dateStartNotNull':
             if ($this->_objectResourceStatus == 1) {
                 $date = parent::getPublicationDateStart();
                 return !$date->isNull();
             }
             break;
         case 'dateStartTimestamp':
             if ($this->_objectResourceStatus == 1) {
                 $date = parent::getPublicationDateStart();
                 return $date->getTimestamp();
             }
             break;
         case 'dateEndNotNull':
             if ($this->_objectResourceStatus == 1) {
                 $date = parent::getPublicationDateEnd();
                 return !$date->isNull();
             }
             break;
         case 'dateEndTimestamp':
             if ($this->_objectResourceStatus == 1) {
                 $date = parent::getPublicationDateEnd();
                 return $date->getTimestamp();
             }
             break;
             //field related values, may not exists ...
         //field related values, may not exists ...
         case 'fieldID':
             if (!is_a($this->_field, 'CMS_poly_object_field')) {
                 $this->raiseError("Can't get 'fieldID' value for an object which is not a field of another object ...");
                 return '';
             }
             return $this->_field->getID();
             break;
         case 'description':
             if (!is_a($this->_field, 'CMS_poly_object_field')) {
                 $this->raiseError("Can't get 'description' value for an object which is not a field of another object ...");
                 return '';
             }
             return io::htmlspecialchars($this->_field->getFieldDescription($cms_language));
             break;
         case 'required':
             if (!is_a($this->_field, 'CMS_poly_object_field')) {
                 $this->raiseError("Can't get 'required' value for an object which is not a field of another object ...");
                 return false;
             }
             return $this->_field->getValue("required") ? true : false;
             break;
         case 'fieldname':
             if (!is_a($this->_field, 'CMS_poly_object_field')) {
                 $this->raiseError("Can't get 'fieldname' value for an object which is not a field of another object ...");
                 return '';
             }
             //get label of current field
             $fieldLabel = new CMS_object_i18nm($this->_field->getValue("labelID"));
             return $fieldLabel->getValue($cms_language->getCode());
             break;
         default:
             $this->raiseError("Unknown value to get : " . $name);
             return false;
             break;
     }
 }
Beispiel #9
0
 /**
  * Return a list of objects infos to be displayed in module index according to user privileges
  *
  * @return string : HTML scripts infos
  * @access public
  */
 function getObjectsInfos($user)
 {
     $objectsInfos = array();
     $cms_language = $user->getLanguage();
     $catFieldsNames = array();
     //objects
     $objects = $this->getObjects();
     if (APPLICATION_ENFORCES_ACCESS_CONTROL === false || APPLICATION_ENFORCES_ACCESS_CONTROL === true && $user->hasModuleClearance($this->getCodename(), CLEARANCE_MODULE_EDIT)) {
         foreach ($objects as $anObjectType) {
             //if object is editable or if user has full privileges
             if ($anObjectType->getValue("admineditable") == 0 || $anObjectType->getValue("admineditable") == 2 && $user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) {
                 //load fields objects for object
                 $objectFields = CMS_poly_object_catalog::getFieldsDefinition($anObjectType->getID());
                 if (sizeof($objectFields)) {
                     $objectsInfos[] = array('label' => $anObjectType->getLabel($cms_language), 'adminLabel' => $anObjectType->getLabel($cms_language), 'description' => $anObjectType->getDescription($cms_language), 'objectId' => $anObjectType->getID(), 'url' => PATH_ADMIN_MODULES_WR . '/' . MOD_POLYMOD_CODENAME . '/items.php', 'module' => $this->getCodename(), 'class' => 'atm-elements');
                     //get categories fields for object
                     if (count($catFieldsNames) < 3) {
                         $thisFieldsCategories = CMS_poly_object_catalog::objectHasCategories($anObjectType->getID());
                         if ($thisFieldsCategories) {
                             $fields = CMS_poly_object_catalog::getFieldsDefinition($anObjectType->getID());
                             foreach ($thisFieldsCategories as $catField) {
                                 if (isset($fields[$catField]) && is_object($fields[$catField])) {
                                     $label = new CMS_object_i18nm($fields[$catField]->getValue("labelID"));
                                     $catFieldsNames[] = $label->getValue($cms_language->getCode()) . ' (' . $anObjectType->getLabel($cms_language) . ')';
                                 }
                             }
                         }
                     } else {
                         if (!in_array('...', $catFieldsNames)) {
                             $catFieldsNames[] = '...';
                         }
                     }
                 }
             }
         }
     }
     //Categories
     //if user has some categories to manage
     $userManageCategories = $user->getRootModuleCategoriesManagable($this->getCodename());
     if ($catFieldsNames && (is_array($userManageCategories) && $userManageCategories || $user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL))) {
         $objectsInfos[] = array('label' => $cms_language->getMessage(self::MESSAGE_PAGE_CATEGORIES), 'adminLabel' => $cms_language->getMessage(self::MESSAGE_PAGE_ADMIN_CATEGORIES), 'description' => $cms_language->getMessage(self::MESSAGE_PAGE_CATEGORIES_USED, false, MOD_POLYMOD_CODENAME) . io::htmlspecialchars(implode(', ', $catFieldsNames)), 'objectId' => 'categories', 'url' => PATH_ADMIN_WR . '/modules-categories.php', 'module' => $this->getCodename(), 'class' => 'atm-categories');
     }
     return $objectsInfos;
 }
 /**
  * Import object from given array datas
  *
  * @param array $data The object datas to import
  * @param array $params The import parameters.
  *		array(
  *				module	=> false|true : the module to create object (required)
  *				create	=> false|true : create missing objects (default : true)
  *				update	=> false|true : update existing objects (default : true)
  *				files	=> false|true : use files from PATH_TMP_FS (default : true)
  *			)
  * @param CMS_language $cms_language The CMS_langage to use
  * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids
  * @param string $infos : Reference : The import infos returned
  * @return boolean : true on success, false on failure
  * @access public
  */
 function fromArray($data, $params, $cms_language, &$idsRelation, &$infos)
 {
     if (!isset($params['module'])) {
         $infos .= 'Error : missing module codename for object importation ...' . "\n";
         return false;
     }
     $module = CMS_modulesCatalog::getByCodename($params['module']);
     if ($module->hasError()) {
         $infos .= 'Error : invalid module for object importation : ' . $params['module'] . "\n";
         return false;
     }
     if (!$this->getID() && CMS_poly_object_catalog::objectUuidExists($data['uuid'])) {
         //check imported uuid. If objects does not have an Id, the uuid must be unique or must be regenerated
         $uuid = io::uuid();
         //store old uuid relation
         $idsRelation['objects-uuid'][$data['uuid']] = $uuid;
         $data['uuid'] = $uuid;
     }
     //set object uuid if not exists
     if (!$this->_objectValues["uuid"]) {
         $this->_objectValues["uuid"] = $data['uuid'];
     }
     if (isset($data['labels'])) {
         $label = new CMS_object_i18nm($this->getValue("labelID"));
         $label->setValues($data['labels']);
         $label->writeToPersistence();
         $this->setValue("labelID", $label->getID());
     }
     if (isset($data['descriptions'])) {
         $description = new CMS_object_i18nm($this->getValue("descriptionID"));
         $description->setValues($data['descriptions']);
         $description->writeToPersistence();
         $this->setValue("descriptionID", $description->getID());
     }
     if (isset($data['params']['resourceUsage'])) {
         $this->setValue("resourceUsage", $data['params']['resourceUsage']);
     }
     if (isset($data['params']['admineditable'])) {
         $this->setValue("admineditable", $data['params']['admineditable']);
     }
     if (isset($data['params']['indexable'])) {
         $this->setValue("indexable", $data['params']['indexable']);
     }
     if (isset($data['params']['multilanguage'])) {
         $this->setValue("multilanguage", $data['params']['multilanguage']);
     }
     if (isset($data['params']['composedLabel'])) {
         $this->setValue("composedLabel", $module->convertDefinitionString($data['params']['composedLabel'], false));
     }
     if (isset($data['params']['previewURL'])) {
         $this->setValue("previewURL", $module->convertDefinitionString($data['params']['previewURL'], false));
     }
     if (isset($data['params']['indexURL'])) {
         $this->setValue("indexURL", $module->convertDefinitionString($data['params']['indexURL'], false));
     }
     if (isset($data['params']['resultsDefinition'])) {
         $this->setValue("resultsDefinition", $module->convertDefinitionString($data['params']['resultsDefinition'], false));
     }
     //write object
     if (!$this->writeToPersistence()) {
         $infos .= 'Error : can not write object ...' . "\n";
         return false;
     }
     //if current object id has changed from imported id, set relation
     if (isset($data['id']) && $data['id'] && $this->getID() != $data['id']) {
         $idsRelation['objects'][$data['id']] = $this->getID();
     }
     //set this object into definition to convert array so it can be converted again at end of import process
     $idsRelation['definitionToConvert'][] = $this;
     $return = true;
     //object fields
     if (isset($data['fields'])) {
         foreach ($data['fields'] as $fieldDatas) {
             $importType = '';
             if (isset($fieldDatas['type'])) {
                 if (isset($fieldDatas['uuid']) && ($id = CMS_poly_object_catalog::fieldExists($params['module'], $fieldDatas['uuid']))) {
                     //field already exist : load it if we can update it
                     if (!isset($params['update']) || $params['update'] == true) {
                         $field = new CMS_poly_object_field($id);
                         $importType = ' (Update)';
                     }
                 } else {
                     //create new field if we can
                     if (!isset($params['create']) || $params['create'] == true) {
                         $field = new CMS_poly_object_field();
                         $importType = ' (Creation)';
                     }
                 }
                 if (isset($field)) {
                     if ($field->fromArray($fieldDatas, $params, $cms_language, $idsRelation, $infos)) {
                         $return &= true;
                         $infos .= 'Field "' . $field->getLabel($cms_language) . '" successfully imported' . $importType . "\n";
                     } else {
                         $return = false;
                         $infos .= 'Error during import of field ...' . $importType . "\n";
                     }
                 }
             } else {
                 $return = false;
                 $infos .= 'Error during import of field : missing type' . "\n";
             }
         }
     }
     //object rss feeds
     if (isset($data['rss'])) {
         foreach ($data['rss'] as $rssDatas) {
             $importType = '';
             if (isset($rssDatas['uuid']) && ($id = CMS_poly_object_catalog::rssExists($params['module'], $rssDatas['uuid']))) {
                 //rss already exist : load it if we can update it
                 if (!isset($params['update']) || $params['update'] == true) {
                     $rss = new CMS_poly_rss_definitions($id);
                     $importType = ' (Update)';
                 }
             } else {
                 //create new rss if we can
                 if (!isset($params['create']) || $params['create'] == true) {
                     $rss = new CMS_poly_rss_definitions();
                     $importType = ' (Creation)';
                 }
             }
             if (isset($rss)) {
                 if ($rss->fromArray($rssDatas, $params, $cms_language, $idsRelation, $infos)) {
                     $return &= true;
                     $infos .= 'RSS feed "' . $rss->getLabel($cms_language) . '" successfully imported' . $importType . "\n";
                 } else {
                     $return = false;
                     $infos .= 'Error during import of rss feed ...' . $importType . "\n";
                 }
             }
         }
     }
     //plugins wysiwyg
     if (isset($data['plugins'])) {
         foreach ($data['plugins'] as $pluginDatas) {
             $importType = '';
             if (isset($pluginDatas['uuid']) && ($id = CMS_poly_object_catalog::pluginExists($params['module'], $pluginDatas['uuid']))) {
                 //plugin already exist : load it if we can update it
                 if (!isset($params['update']) || $params['update'] == true) {
                     $plugin = new CMS_poly_plugin_definitions($id);
                     $importType = ' (Update)';
                 }
             } else {
                 //create new plugin if we can
                 if (!isset($params['create']) || $params['create'] == true) {
                     $plugin = new CMS_poly_plugin_definitions();
                     $importType = ' (Creation)';
                 }
             }
             if (isset($plugin)) {
                 if ($plugin->fromArray($pluginDatas, $params, $cms_language, $idsRelation, $infos)) {
                     $return &= true;
                     $infos .= 'Plugin Wysiwyg "' . $plugin->getLabel($cms_language) . '" successfully imported' . $importType . "\n";
                 } else {
                     $return = false;
                     $infos .= 'Error during import of plugin wysiwyg ...' . $importType . "\n";
                 }
             }
         }
     }
     return $return;
 }
define("MESSAGE_PAGE_FIELD_OBJECT", 1234);
define("MESSAGE_PAGE_FIELD_OBJECT_USEAGE", 1281);
define("MESSAGE_PAGE_FIELD_OBJECT_USED", 1282);
define("MESSAGE_PAGE_FIELD_OBJECT_GRAYED_INFOS", 1292);
define("MESSAGE_PAGE_FIELD_COMPOSED_LABEL", 1294);
define("MESSAGE_PAGE_FIELD_ONLY_FOR_ADMIN", 1276);
//Polymod messages
define("MESSAGE_PAGE_FIELD_MULTI", 190);
//checks
if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) {
    header("Location: " . PATH_ADMIN_SPECIAL_ENTRY_WR . "?cms_message_id=" . MESSAGE_PAGE_CLEARANCE_ERROR . "&" . session_name() . "=" . session_id());
    exit;
}
$moduleCodename = $_POST["moduleCodename"] ? $_POST["moduleCodename"] : $_GET["moduleCodename"];
$object = new CMS_poly_object_definition($_POST["object"]);
$availableLanguagesCodes = CMS_object_i18nm::getAvailableLanguages();
$objectsStructure = CMS_poly_module_structure::getModuleStructure($moduleCodename, true);
if ($moduleCodename) {
    $polymod = CMS_modulesCatalog::getByCodename($moduleCodename);
}
$dialog = new CMS_dialog();
$content = '';
$dialog->setTitle($cms_language->getMessage(MESSAGE_PAGE_TITLE_APPLICATIONS) . " :: " . $polymod->getLabel($cms_language) . " :: " . $cms_language->getMessage(MESSAGE_PAGE_TITLE, array($object->getLabel($cms_language))), 'picto_modules.gif');
$dialog->setBacklink("modules_admin.php?moduleCodename=" . $moduleCodename . "&object=" . $object->getID());
if ($cms_message) {
    $dialog->setActionMessage($cms_message);
}
$resourceStatus = array(0 => MESSAGE_PAGE_FIELD_RESOURCE_NONE, 1 => MESSAGE_PAGE_FIELD_RESOURCE_PRIMARY, 2 => MESSAGE_PAGE_FIELD_RESOURCE_SECONDARY);
$adminEditableStatus = array(0 => MESSAGE_PAGE_FIELD_YES, 1 => MESSAGE_PAGE_FIELD_NO, 2 => MESSAGE_PAGE_FIELD_ONLY_FOR_ADMIN);
$objectUseage = CMS_poly_object_catalog::getObjectUsage($object->getID(), true);
if (!sizeof($objectUseage)) {
 /**
  * Import plugin from given array datas
  *
  * @param array $data The plugin datas to import
  * @param array $params The import parameters.
  *		array(
  *				module	=> false|true : the module to create plugin (required)
  *				create	=> false|true : create missing objects (default : true)
  *				update	=> false|true : update existing objects (default : true)
  *				files	=> false|true : use files from PATH_TMP_FS (default : true)
  *			)
  * @param CMS_language $cms_language The CMS_langage to use
  * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids
  * @param string $infos : Reference : The import infos returned
  * @return boolean : true on success, false on failure
  * @access public
  */
 function fromArray($data, $params, $cms_language, &$idsRelation, &$infos)
 {
     if (!isset($params['module'])) {
         $infos .= 'Error : missing module codename for rss feed importation ...' . "\n";
         return false;
     }
     $module = CMS_modulesCatalog::getByCodename($params['module']);
     if ($module->hasError()) {
         $infos .= 'Error : invalid module for rss feed importation : ' . $params['module'] . "\n";
         return false;
     }
     if (!$this->getID() && CMS_poly_object_catalog::pluginUuidExists($data['uuid'])) {
         //check imported uuid. If plugin does not have an Id, the uuid must be unique or must be regenerated
         $uuid = io::uuid();
         //store old uuid relation
         $idsRelation['plugins-uuid'][$data['uuid']] = $uuid;
         $data['uuid'] = $uuid;
     }
     //set plugin uuid if not exists
     if (!$this->_objectValues["uuid"]) {
         $this->_objectValues["uuid"] = $data['uuid'];
     }
     if (isset($data['labels'])) {
         $label = new CMS_object_i18nm($this->getValue("labelID"));
         $label->setValues($data['labels']);
         $label->writeToPersistence();
         $this->setValue("labelID", $label->getID());
     }
     if (isset($data['descriptions'])) {
         $description = new CMS_object_i18nm($this->getValue("descriptionID"));
         $description->setValues($data['descriptions']);
         $description->writeToPersistence();
         $this->setValue("descriptionID", $description->getID());
     }
     //if current object id has changed from imported id, set relation
     if (isset($idsRelation['objects'][$data['objectID']]) && $idsRelation['objects'][$data['objectID']]) {
         $this->setValue("objectID", $idsRelation['objects'][$data['objectID']]);
     } else {
         $this->setValue("objectID", $data['objectID']);
     }
     //values
     if (isset($data['params']['query'])) {
         //translate ids if needed
         $query = array();
         foreach ($data['params']['query'] as $objectId => $value) {
             if (isset($idsRelation['objects'][$objectId])) {
                 //object exists with a translated id
                 $query[$idsRelation['objects'][$objectId]] = $value;
             } else {
                 $query[$objectId] = $value;
             }
         }
         $this->setValue("query", $query);
     }
     if (isset($data['params']['definition'])) {
         $this->setValue("definition", $module->convertDefinitionString($data['params']['definition'], false));
     }
     //write object
     if (!$this->writeToPersistence()) {
         $infos .= 'Error : can not write object ...' . "\n";
         return false;
     }
     //if current object id has changed from imported id, set relation
     if (isset($data['id']) && $data['id'] && $this->getID() != $data['id']) {
         $idsRelation['plugins'][$data['id']] = $this->getID();
     }
     //set this object into definition to convert array so it can be converted again at end of import process
     $idsRelation['definitionToConvert'][] = $this;
     return true;
 }
 /**
  * Import rss feed from given array datas
  *
  * @param array $data The rss feed datas to import
  * @param array $params The import parameters.
  *		array(
  *				module	=> false|true : the module to create rss feed (required)
  *				create	=> false|true : create missing objects (default : true)
  *				update	=> false|true : update existing objects (default : true)
  *				files	=> false|true : use files from PATH_TMP_FS (default : true)
  *			)
  * @param CMS_language $cms_language The CMS_langage to use
  * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids
  * @param string $infos : Reference : The import infos returned
  * @return boolean : true on success, false on failure
  * @access public
  */
 function fromArray($data, $params, $cms_language, &$idsRelation, &$infos)
 {
     if (!isset($params['module'])) {
         $infos .= 'Error : missing module codename for rss feed importation ...' . "\n";
         return false;
     }
     $module = CMS_modulesCatalog::getByCodename($params['module']);
     if ($module->hasError()) {
         $infos .= 'Error : invalid module for rss feed importation : ' . $params['module'] . "\n";
         return false;
     }
     if (!$this->getID() && CMS_poly_object_catalog::rssUuidExists($data['uuid'])) {
         //check imported uuid. If rss does not have an Id, the uuid must be unique or must be regenerated
         $uuid = io::uuid();
         //store old uuid relation
         $idsRelation['rss-uuid'][$data['uuid']] = $uuid;
         $data['uuid'] = $uuid;
     }
     //set object uuid if not exists
     if (!$this->_objectValues["uuid"]) {
         $this->_objectValues["uuid"] = $data['uuid'];
     }
     if (isset($data['labels'])) {
         $label = new CMS_object_i18nm($this->getValue("labelID"));
         $label->setValues($data['labels']);
         $label->writeToPersistence();
         $this->setValue("labelID", $label->getID());
     }
     if (isset($data['descriptions'])) {
         $description = new CMS_object_i18nm($this->getValue("descriptionID"));
         $description->setValues($data['descriptions']);
         $description->writeToPersistence();
         $this->setValue("descriptionID", $description->getID());
     }
     //if current object id has changed from imported id, set relation
     if (isset($idsRelation['objects'][$data['objectID']]) && $idsRelation['objects'][$data['objectID']]) {
         $this->setValue("objectID", $idsRelation['objects'][$data['objectID']]);
     } else {
         $this->setValue("objectID", $data['objectID']);
     }
     //values
     if (isset($data['params']['link'])) {
         $this->setValue("link", $data['params']['link']);
     }
     if (isset($data['params']['author'])) {
         $this->setValue("author", $data['params']['author']);
     }
     if (isset($data['params']['copyright'])) {
         $this->setValue("copyright", $data['params']['copyright']);
     }
     if (isset($data['params']['namespaces'])) {
         $this->setValue("namespaces", $data['params']['namespaces']);
     }
     if (isset($data['params']['categories'])) {
         $this->setValue("categories", $data['params']['categories']);
     }
     if (isset($data['params']['ttl'])) {
         $this->setValue("ttl", $data['params']['ttl']);
     }
     if (isset($data['params']['email'])) {
         $this->setValue("email", $data['params']['email']);
     }
     if (isset($data['params']['definition'])) {
         //do not use set value for this because it try to compile definition and fail
         //$this->setValue("definition", $module->convertDefinitionString($data['params']['definition'], false));
         $this->_objectValues['definition'] = $module->convertDefinitionString($data['params']['definition'], false);
     }
     //write object
     if (!$this->writeToPersistence()) {
         $infos .= 'Error : can not write object ...' . "\n";
         return false;
     }
     //if current object id has changed from imported id, set relation
     if (isset($data['id']) && $data['id'] && $this->getID() != $data['id']) {
         $idsRelation['rss'][$data['id']] = $this->getID();
     }
     //set this object into definition to convert array so it can be converted again at end of import process
     $idsRelation['definitionToConvert'][] = $this;
     return true;
 }