Exemple #1
0
 /**
  * Pseudo-constructor, initializes the tag with its definition from tag and row id
  *
  * @param string $blockID, the block id to initialise
  * @param integer $rowID, the row id which contain the block to load
  * @return boolean true on success, false on failure.
  * @access public
  */
 function initializeFromID($blockID, $rowID)
 {
     if (!sensitiveIO::isPositiveInteger($rowID)) {
         $this->raiseError("rowID must be a positive integer : " . $rowID);
         return false;
     }
     //instanciate row to get block definition
     $row = new CMS_row($rowID);
     $blockTag = $row->getBlockTagById($blockID);
     if (!is_object($blockTag)) {
         $this->raiseError('Can\'t get block ' . $blockID . ' from row id : ' . $rowID);
         return false;
     }
     $this->initializeFromTag($blockTag->getAttributes(), $blockTag->getInnerContent());
     return true;
 }
Exemple #2
0
 /**
  * Import module from given array datas
  *
  * @param array $data The module datas to import
  * @param array $params The import parameters.
  * 		array(
  * 				module	=> false|true : the module to create rows (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
  */
 static function fromArray($data, $params, $cms_language, &$idsRelation, &$infos)
 {
     if (!isset($params['module'])) {
         $infos .= 'Error : missing module codename for rows importation ...' . "\n";
         return false;
     }
     $module = CMS_modulesCatalog::getByCodename($params['module']);
     if ($module->hasError()) {
         $infos .= 'Error : invalid module for rows importation : ' . $params['module'] . "\n";
         return false;
     }
     $return = true;
     foreach ($data as $rowDatas) {
         $importType = '';
         if (isset($rowDatas['uuid']) && ($id = CMS_rowsCatalog::rowExists($params['module'], $rowDatas['uuid']))) {
             //row already exist : load it if we can update it
             if (!isset($params['update']) || $params['update'] == true) {
                 $row = CMS_rowsCatalog::getByID($id);
                 $importType = ' (Update)';
             }
         } else {
             //create new row if we can
             if (!isset($params['create']) || $params['create'] == true) {
                 //create row
                 $row = new CMS_row();
                 $importType = ' (Creation)';
             }
         }
         if (isset($row)) {
             if ($row->fromArray($rowDatas, $params, $cms_language, $idsRelation, $infos)) {
                 $return &= true;
                 $infos .= 'Row ' . $row->getLabel() . ' successfully imported' . $importType . "\n";
             } else {
                 $return = false;
                 $infos .= 'Error during import of row ' . $rowDatas['id'] . $importType . "\n";
             }
         }
     }
     return $return;
 }
//ARGUMENTS CHECK
if (!$cs || !$rowTag || !$rowId || !$blockId) {
    CMS_grandFather::raiseError('Data missing ...');
    $view->show();
}
//instanciate block
$cms_block = new CMS_block_polymod();
$cms_block->initializeFromID($blockId, $rowId);
//instanciate block module
$cms_module = CMS_modulesCatalog::getByCodename($codename);
//get block datas if any
$data = $cms_block->getRawData($cms_page->getID(), $cs, $rowTag, RESOURCE_LOCATION_EDITION, false);
//get block parameters requirements
$blockParamsDefinition = $cms_block->getBlockParametersRequirement($data["value"], $cms_page, true);
//instanciate row
$row = new CMS_row($rowId);
$winLabel = sensitiveIO::sanitizeJSString($cms_language->getMessage(MESSAGE_PAGE_TITLE, array($row->getLabel(), $cms_module->getLabel($cms_language)), MOD_POLYMOD_CODENAME));
$items = array();
$rowParams = array();
if (isset($blockParamsDefinition['var'])) {
    $blockVarContent = array();
    foreach ($blockParamsDefinition['var'] as $varId => $variables) {
        foreach ($variables as $varName => $varAttributes) {
            // indicate that a row param is found
            $rowParams[] = $varName;
            // check mandatory attribute
            $mandatory = $varAttributes['mandatory'] == "true" ? '<span class="atm-red">*</span> ' : '';
            // handle description
            $description = isset($varAttributes['description']) ? '<span class="atm-help" ext:qtip="' . sensitiveIO::sanitizeHTMLString(strip_tags($varAttributes['description'])) . '">' . sensitiveIO::sanitizeHTMLString(strip_tags($varAttributes['label'])) . '</span>' : $varAttributes['label'];
            // create label
            $label = $mandatory . $description;
Exemple #4
0
if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_TEMPLATES)) {
    //rows
    CMS_grandFather::raiseError('User has no rights on rows editions');
    $view->setActionMessage($cms_language->getMessage(MESSAGE_ERROR_NO_RIGHTS_FOR_ROWS));
    $view->show();
}
//load row if any
if (sensitiveIO::isPositiveInteger($rowId)) {
    $row = CMS_rowsCatalog::getByID($rowId);
    if (!$row || $row->hasError()) {
        CMS_grandFather::raiseError('Unknown row for given Id : ' . $rowId);
        $view->show();
    }
} else {
    //create new row
    $row = new CMS_row();
}
//MAIN TAB
//Need to sanitize all datas which can contain single quotes
$label = $row->getLabel();
$description = sensitiveIO::sanitizeJSString($row->getDescription(), false, true, true);
//this is a textarea, we must keep cariage return
$rowDefinition = $row->getDefinition();
$rowGroups = $row->getGroups();
//image
$maxFileSize = CMS_file::getMaxUploadFileSize('K');
$imageDatas = array('filename' => '', 'filepath' => '', 'filesize' => '', 'fileicon' => '', 'extension' => '');
$imageDatas = sensitiveIO::jsonEncode($imageDatas);
//Groups
$allGroups = CMS_rowsCatalog::getAllGroups();
$groupsfield = '';