Ejemplo n.º 1
0
                     $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);
         $codeTopaste = $definitionParsing->getContent(CMS_polymod_definition_parsing::OUTPUT_RESULT, $parameters);
         //add some attributes to images to prevent resizing into editor
         $codeTopaste = str_replace('<img ', '<img contenteditable="false" unselectable="on" ', $codeTopaste);
         //encode all ampersand without reencode already encoded ampersand
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);
        //set objectID
Ejemplo n.º 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 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;
     }
 }