Example #1
0
         //then reload object
         if (sensitiveIO::IsPositiveInteger($objectID)) {
             $object = new CMS_poly_object_definition($objectID);
         }
         $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
     } else {
         $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_DELETE_FIELD_ERROR);
     }
     break;
 case 'deleteRSS':
     $RSSDefinition = new CMS_poly_rss_definitions($_POST['RSSDefinition']);
     $RSSDefinition->destroy();
     $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
     break;
 case 'deletePlugin':
     $pluginDefinition = new CMS_poly_plugin_definitions($_POST['pluginDefinition']);
     $pluginDefinition->destroy();
     $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
     break;
 case 'deleteOembed':
     $def = CMS_polymod_oembed_definition_catalog::getById($_POST['oembedId']);
     $def->destroy();
     $cms_message .= $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
     break;
 case "change_order":
     if (is_object($object)) {
         $fields = CMS_poly_object_catalog::getFieldsDefinition($object->getID());
         $count = 0;
         //construct array of new fields orders
         $newPagesOrder = array();
         $tmpPagesOrder = explode(',', $_POST["new_order"]);
Example #2
0
                     $validation = new CMS_resourceValidation($codename, RESOURCE_EDITION_CONTENT, $item);
                     $mod = CMS_modulesCatalog::getByCodename($codename);
                     $mod->processValidation($validation, VALIDATION_OPTION_ACCEPT);
                     //Log action
                     $log = new CMS_log();
                     $log->logResourceAction(CMS_log::LOG_ACTION_RESOURCE_DIRECT_VALIDATION, $cms_user, $codename, $item->getStatus(), 'Item \'' . $item->getLabel() . '\' (' . $item->getObjectDefinition()->getLabel($cms_language) . ')', $item);
                 }
             }
         }
     }
     break;
 case 'pluginSelection':
     $view->setDisplayMode(CMS_view::SHOW_RAW);
     $selectedContent = sensitiveIO::request('content');
     $pluginId = sensitiveIO::request('plugin');
     $selectedPlugin = new CMS_poly_plugin_definitions($pluginId);
     //then create the code to paste for the current selected object if any
     if (sensitiveIO::isPositiveInteger($itemId) && !$selectedPlugin->needSelection()) {
         //$item = CMS_poly_object_catalog::getObjectByID($selectedItem);
         $definition = $selectedPlugin->getValue('definition');
         $parameters = array();
         $parameters['itemID'] = $itemId;
         $parameters['module'] = $codename;
         $cms_page = CMS_session::getPage();
         if (is_object($cms_page) && !$cms_page->hasError()) {
             $parameters['pageID'] = $cms_page->getID();
         }
         $parameters['selection'] = io::decodeEntities($selectedContent);
         $parameters['public'] = false;
         $parameters['plugin-view'] = true;
         $definitionParsing = new CMS_polymod_definition_parsing($definition, true, CMS_polymod_definition_parsing::PARSE_MODE);
Example #3
0
 /**
  * Force compilation for all stored definitions
  *
  * @return void
  * @access public
  */
 function compileDefinitions()
 {
     //foreach definition, plugin and rss, recompile stored values if exists
     $modules = CMS_modulesCatalog::getAll("id", true);
     $hasPolyModule = false;
     foreach ($modules as $module) {
         if ($module->isPolymod()) {
             $hasPolyModule = true;
             //get objects definition for module
             $objects = CMS_poly_object_catalog::getObjectsForModule($module->getCodename());
             foreach ($objects as $object) {
                 if ($object->getValue('indexURL')) {
                     $object->compileDefinition();
                     $object->writeToPersistence();
                 }
             }
             //get plugins for module
             $plugins = CMS_poly_object_catalog::getAllPluginDefIDForModule($module->getCodename());
             foreach ($plugins as $pluginID) {
                 $plugin = new CMS_poly_plugin_definitions($pluginID);
                 if ($plugin->getValue('definition') && method_exists($plugin, 'compileDefinition')) {
                     $plugin->compileDefinition();
                     $plugin->writeToPersistence();
                 }
             }
         }
     }
     if ($hasPolyModule) {
         //get all RSS definition
         $rssDefinitions = CMS_poly_object_catalog::getAllRSSDefinitionsForObject();
         foreach ($rssDefinitions as $rssDefinition) {
             if ($rssDefinition->getValue('definition')) {
                 $rssDefinition->compileDefinition();
                 $rssDefinition->writeToPersistence();
             }
         }
     }
 }
 /**
  * Return a list of all plugins for a given object ID
  *
  * @param integer $objectID the object ID to get plugins (if none set : all plugins)
  * @return array(int objectID => CMS_poly_plugin_definitions)
  * @access public
  * @static
  */
 static function getAllPluginDefinitionsForObject($objectID = false)
 {
     if ($objectID && !sensitiveIO::isPositiveInteger($objectID)) {
         CMS_grandFather::raiseError("objectID is not a positive integer : " . $objectID);
         return false;
     }
     $sql = "select\n\t\t\t\t\t*\n\t\t\t\tfrom\n\t\t\t\t\tmod_object_plugin_definition";
     if ($objectID) {
         $sql .= "\n\t\t\t\twhere\n\t\t\t\t\tobject_id_mowd='" . sensitiveIO::sanitizeSQLString($objectID) . "'\n\t\t\t";
     }
     $q = new CMS_query($sql);
     $results = array();
     while ($r = $q->getArray()) {
         $object = new CMS_poly_plugin_definitions($r["id_mowd"], $r);
         $results[$object->getID()] = $object;
     }
     return $results;
 }
 /**
  * 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_WORKING_TAGS", 113);
define("MESSAGE_PAGE_WORKING_TAGS_EXPLANATION", 114);
define("MESSAGE_PAGE_BLOCK_GENRAL_VARS", 140);
define("MESSAGE_PAGE_BLOCK_GENRAL_VARS_EXPLANATION", 139);
define("MESSAGE_PAGE_FIELD_PLUGIN_DEF_EXPLANATION", 278);
define("MESSAGE_PAGE_PLUGIN_TAG", 287);
define("MESSAGE_PAGE_PLUGIN_TAG_EXPLANATION", 288);
//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"]);
$pluginDefinition = new CMS_poly_plugin_definitions($_POST["pluginDefinition"]);
$label = new CMS_object_i18nm($pluginDefinition->getValue("labelID"));
$description = new CMS_object_i18nm($pluginDefinition->getValue("descriptionID"));
$availableLanguagesCodes = CMS_object_i18nm::getAvailableLanguages();
if ($moduleCodename) {
    $polymod = CMS_modulesCatalog::getByCodename($moduleCodename);
}
$cms_message = "";
// ****************************************************************
// ** ACTIONS MANAGEMENT                                         **
// ****************************************************************
switch ($_POST["cms_action"]) {
    case "validate":
    case "switchexplanation":
        //checks and assignments
        $pluginDefinition->setDebug(false);
 /**
  * Return a wysiwyg plugin output for given parameters
  *
  * @param integer $pluginID : the plugin id to use
  * @param integer $itemID : the item id to use
  * @param string $selection : the selected wysiwyg text if any
  * @param boolean $public : the data status
  * @param boolean $pluginView : is this plugin is intended to be shown in wysiwyg view ? (default false)
  * @return string : the plugin output
  * @access public
  * @static
  */
 static function pluginCode($pluginID, $itemID, $selection, $public = false, $pluginView = false)
 {
     global $cms_user;
     //then create the code to paste for the current selected object if any
     if (sensitiveIO::isPositiveInteger($itemID) && sensitiveIO::isPositiveInteger($pluginID)) {
         //get plugin
         $plugin = new CMS_poly_plugin_definitions($pluginID);
         //set execution parameters
         $parameters = array();
         $parameters['itemID'] = $itemID;
         $parameters['public'] = $public;
         if ($pluginView) {
             $parameters['plugin-view'] = true;
         }
         //get originaly selected text
         if (!$plugin->needSelection()) {
             $parameters['selection'] = '';
         } else {
             $parameters['selection'] = io::decodeEntities($selection);
         }
         //this line is used to optimise text fields (see CMS_object_text) which use a lot of plugin codes.
         //in this case, items are searched before then put in this global var so it is not necessary to do one search for each of them
         if (isset($GLOBALS['polymod']['preparedItems'][$plugin->getValue('objectID')][$itemID])) {
             $parameters['item'] = $GLOBALS['polymod']['preparedItems'][$plugin->getValue('objectID')][$itemID];
         }
         //eval item content
         ob_start();
         eval(sensitiveIO::sanitizeExecCommand(sensitiveIO::stripPHPTags($plugin->getValue('compiledDefinition'))));
         $data = ob_get_contents();
         ob_end_clean();
         return $data;
     }
 }