} else { $version = isset($objectsInfo['version']) ? $objectsInfo['version'] : 4; if (isset($objectsInfo['description'])) { $description = ' ext:qtip="' . io::htmlspecialchars($objectsInfo['description']) . '"'; unset($objectsInfo['description']); } else { $description = ''; } if (isset($objectsInfo['adminLabel'])) { $label = io::htmlspecialchars($objectsInfo['adminLabel']); unset($objectsInfo['adminLabel']); } else { $label = $cms_language->getMessage(MESSAGE_PAGE_MODULE_ADMIN, array(io::htmlspecialchars($module->getLabel($cms_language)))); } $class = isset($objectsInfo['class']) ? $objectsInfo['class'] : 'atm-modules'; $contentEl .= '<li><div class="' . $class . ' atm-sidepic"></div><a atm:action="module"' . $description . ' atm:module="' . $module->getCodename() . '" atm:version="' . $version . '" atm:options="' . io::htmlspecialchars(sensitiveIO::jsonEncode($objectsInfo)) . '" href="#">' . $label . '</a></li>'; } } } $contentEl .= ' </ul> </div>'; //panel $modulesPanels .= "{\n\t\t\t\tid:\t\t\t\t\t'module{$module->getCodename()}SidePanel',\n\t\t\t\tframe:\t\t\t\ttrue,\n\t\t\t\ttitle: \t\t\t\t'{$modLabel}',\n\t\t\t\tcollapsible:\t\ttrue,\n\t\t\t\ttitleCollapse: \t\ttrue,\n\t\t\t\tcollapsed:\t\t\ttrue,\n\t\t\t\thtml:\t\t\t\t'" . sensitiveIO::sanitizeJSString($contentEl) . "',\n\t\t\t\tlisteners:\t\t\t{'expand': scrollPanel}"; //add modules parameters if ($cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { $modulesPanels .= ",\n\t\t\t\thideCollapseTool:\ttrue,\n\t\t\t\ttools: [{\n\t\t\t\t\tid:\t\t\t\t'gear',\n\t\t\t\t\thandler:\t\tfunction(e, toolEl, panel){\n\t\t\t\t\t\tvar window = new Automne.frameWindow({\n\t\t\t\t\t\t\tid:\t\t\t\t'modulesWindow',\n\t\t\t\t\t\t\tframeURL:\t\t'" . PATH_MAIN_WR . "/admin-v3/modules_admin.php?moduleCodename={$module->getCodename()}',\n\t\t\t\t\t\t\tallowFrameNav:\ttrue,\n\t\t\t\t\t\t\twidth:\t\t\t750,\n\t\t\t\t\t\t\theight:\t\t\t580,\n\t\t\t\t\t\t\tanimateTarget:\te\n\t\t\t\t\t\t});\n\t\t\t\t\t\twindow.show();\n\t\t\t\t\t},\n\t\t\t\t\tqtip:\t\t\t'" . $cms_language->getMessage(MESSAGE_PAGE_MODULE_PARAMETERS) . "'\n\t\t\t\t}, {\n\t\t\t\t\tid:\t\t\t\t'toggle',\n\t\t\t\t\thandler:\t\tfunction(e, toolEl, panel){\n\t\t\t\t\t\tpanel.toggleCollapse(true);\n\t\t\t\t\t}\n\t\t\t\t}]"; } $modulesPanels .= "\n\t\t\t},"; } }
if (!$module || !$module->isPolymod()) { CMS_grandFather::raiseError('Unknown module or module is not polymod for codename : ' . $codename); $view->show(); } //CHECKS user has module clearance if (!$cms_user->hasModuleClearance($codename, CLEARANCE_MODULE_EDIT)) { CMS_grandFather::raiseError('User has no rights on module : ' . $codename); $view->setActionMessage($cms_language->getmessage(MESSAGE_ERROR_MODULE_RIGHTS, array($module->getLabel($cms_language)))); $view->show(); } //load current object definition $object = CMS_poly_object_catalog::getObjectDefinition($objectId); $winLabel = sensitiveIO::sanitizeJSString($cms_language->getMessage(MESSAGE_MULTI_OBJECT_CHOOSE_ELEMENT, array($object->getObjectLabel($cms_language)), MOD_POLYMOD_CODENAME)); $md5 = md5(mt_rand() . microtime()); $url = PATH_ADMIN_MODULES_WR . '/polymod/item-selector.php'; $params = sensitiveIO::jsonEncode(array('winId' => 'selector-' . $md5, 'objectId' => $object->getID(), 'module' => $codename, 'multiple' => $unique ? 0 : 1)); $unique = $unique ? '1' : '0'; //this is only an single item selection, so help selection a little $jscontent = <<<END \tvar window = Ext.getCmp('{$winId}'); \t//set window title \twindow.setTitle('{$winLabel}'); \t//set help button on top of page \twindow.tools['help'].show(); \t//add a tooltip on button \tvar propertiesTip = new Ext.ToolTip({ \t\ttarget:\t\t window.tools['help'], \t\ttitle:\t\t\t '{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP)}', \t\thtml:\t\t\t '{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP_DESC, false, MOD_POLYMOD_CODENAME)}', \t\tdismissDelay:\t0 \t});
$maxFileSize = CMS_file::getMaxUploadFileSize('K'); if ($rawDatas['file'] && file_exists(PATH_MODULES_FILES_STANDARD_FS . '/edition/' . $rawDatas['file'])) { $file = new CMS_file(PATH_MODULES_FILES_STANDARD_FS . '/edition/' . $rawDatas['file']); $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' => ''); } $filePath = $fileDatas['filepath']; $fileDatas = sensitiveIO::jsonEncode($fileDatas); if ($rawDatas['enlargedFile'] && file_exists(PATH_MODULES_FILES_STANDARD_FS . '/edition/' . $rawDatas['enlargedFile'])) { $file = new CMS_file(PATH_MODULES_FILES_STANDARD_FS . '/edition/' . $rawDatas['enlargedFile']); $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 = sensitiveIO::jsonEncode($zoomDatas); $linkDatas = sensitiveIO::sanitizeJSString($rawDatas['externalLink']); $imageLabel = sensitiveIO::sanitizeJSString($rawDatas["label"]); $jscontent = <<<END \tvar blockWindow = Ext.getCmp('{$winId}'); \t//set window title \t \tblockWindow.setTitle('{$cms_language->getJsMessage(MESSAGE_EDIT_IMG)}'); \t//set help button on top of page \tblockWindow.tools['help'].show(); \t//add a tooltip on button \tvar propertiesTip = new Ext.ToolTip({ \t\ttarget:\t\t blockWindow.tools['help'], \t\ttitle:\t\t\t '{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP)}', \t\thtml:\t\t\t '{$cms_language->getJsMessage(MESSAGE_WINDOW_IMG_INFO)}', \t\tdismissDelay:\t0
CMS_grandFather::raiseError('Error, user has no rights item ' . $itemId); $jscontent = "\n\t\tvar window = Ext.getCmp('{$winId}');\n\t\tif (window) {\n\t\t\twindow.close();\n\t\t}\n\t\tAutomne.message.popup({\n\t\t\tmsg: \t\t\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_ELEMENT_EDIT_RIGHTS_ERROR, array($itemLabel), MOD_POLYMOD_CODENAME)}',\n\t\t\tbuttons: \t\t\tExt.MessageBox.OK,\n\t\t\tclosable: \t\t\tfalse,\n\t\t\ticon: \t\t\t\tExt.MessageBox.ERROR\n\t\t});"; $view->addJavascript($jscontent); $view->show(); } } else { //instanciate clean object (creation) $item = new CMS_poly_object($object->getID(), ''); } $winLabel = sensitiveIO::sanitizeJSString($cms_language->getMessage(MESSAGE_PAGE_TITLE_MODULE, array($cms_module->getLabel($cms_language))) . " :: " . $cms_language->getMessage(MESSAGE_PAGE_TITLE, array($object->getLabel($cms_language)), MOD_POLYMOD_CODENAME)); $fieldsObjects = $item->getFieldsObjects(); $itemFields = ''; foreach ($fieldsObjects as $fieldID => $aFieldObject) { $fieldAdmin = $item->getHTMLAdmin($fieldID, $cms_language, ''); if (is_array($fieldAdmin)) { $itemFields .= sensitiveIO::jsonEncode($fieldAdmin) . ','; } } //do some search and replace to allow use of js functions in returned code $itemFields = str_replace('"scope":"this"', '"scope":this', $itemFields); function replaceCallBack($parts) { return 'function(' . str_replace(array('\\"', '\\/'), array('"', '/'), $parts[1]) . '}'; } $itemFields = preg_replace_callback('#"function\\((.*)}"#U', 'replaceCallBack', $itemFields); //Append pub dates if object is a primary resource $saveAndValidate = ''; $saveIconCls = $saveTooltip = ''; if ($object->isPrimaryResource()) { if (!$item->getID()) { $dt = new CMS_date();
foreach ($allGroups as $aGroup) { $searchPanel .= "{boxLabel: '{$aGroup}', inputValue:'{$aGroup}', name: 'groups[]', listeners: {'check':rowWindow.search}},"; } //remove last comma from groups $searchPanel = io::substr($searchPanel, 0, -1); $searchPanel .= "\n\t\t]\n\t},"; } $modules = CMS_modulesCatalog::getAll(); if (sizeof($modules) > 1) { $modulesDatas = array(); $modulesDatas['module'] = array(array('id' => 0, 'label' => '-')); foreach ($modules as $module) { $modulesDatas['module'][] = array('id' => $module->getCodename(), 'label' => $module->getLabel($cms_language)); } //json encode websites datas $modulesDatas = sensitiveIO::jsonEncode($modulesDatas); $searchPanel .= "{\n\t\txtype:\t\t\t\t'combo',\n\t\tid:\t\t\t\t\t'moduleField',\n\t\tname:\t\t\t\t'module',\n\t\tfieldLabel:\t\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_MODULES)}',\n\t\tanchor:\t\t\t\t'-20px',\n\t\tforceSelection:\t\ttrue,\n\t\tmode:\t\t\t\t'local',\n\t\ttriggerAction:\t\t'all',\n\t\tvalueField:\t\t\t'id',\n\t\thiddenName: \t\t'module',\n\t\tdisplayField:\t\t'label',\n\t\tstore:\t\t\t\tnew Ext.data.JsonStore({\n\t\t\tid:\t\t\t\t'id',\n\t\t\troot: \t\t\t'module',\n\t\t\tfields: \t\t['id', 'label'],\n\t\t\tdata:\t\t\t{$modulesDatas}\n\t\t}),\n\t\tvalidateOnBlur:\t\tfalse,\n\t\tallowBlank: \t\ttrue,\n\t\tselectOnFocus:\t\ttrue,\n\t\teditable:\t\t\ttrue,\n\t\ttypeAhead:\t\t\ttrue,\n\t\tlisteners:\t\t\t{'valid':rowWindow.search}\n\t},"; } $searchPanel .= "{\n\txtype:\t\t\t'atmPageField',\n\tfieldLabel:\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_PAGE)}',\n\tname:\t\t\t'page',\n\tvalue:\t\t\t'',\n\tanchor:\t\t\t'-20px',\n\tallowBlank:\t\ttrue,\n\tvalidateOnBlur:\tfalse,\n\tlisteners:\t\t{'valid':{\n\t\tfn: \t\t\trowWindow.search,\n\t\toptions:\t\t{buffer:300}\n\t}}\n},"; $searchPanel .= "{\n\thideLabel:\t\ttrue,\n\tlabelSeparator:\t'',\n\tlabelAlign:\t\t'left',\n\txtype:\t\t\t'checkbox',\n\tboxLabel: \t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_VIEW_INACTIVE_ROWS)}',\n\tname: \t\t\t'viewinactive',\n\tinputValue:\t\t'1',\n\tchecked:\t\ttrue,\n\tlisteners: \t\t{'check':rowWindow.search}\n}"; //$searchPanel = io::substr($searchPanel, 0, -1); $jscontent = <<<END \tvar rowWindow = Ext.getCmp('{$winId}'); \tvar fatherWindow = Ext.getCmp('{$fatherId}'); \t//define update function into window (to be accessible by parent window) \trowWindow.updateTab = function() { \t\t//reload search \t\trowWindow.search(); \t} \t//define search function into window (to be accessible by parent window)
if ($searchParamContent) { $items[] = array('title' => $cms_language->getMessage(MESSAGE_PAGE_SUBTITLE, array($searchName), MOD_POLYMOD_CODENAME), 'xtype' => 'fieldset', 'autoHeight' => true, 'defaults' => array('anchor' => '97%'), 'items' => $searchParamContent); } } else { $cms_message .= $cms_language->getMessage(MESSAGE_PAGE_SEARCH_ROW_ERROR, array($searchName, $row->getLabel()), MOD_POLYMOD_CODENAME) . "\n"; } } } $items = sensitiveIO::jsonEncode($items); $itemControler = PATH_ADMIN_MODULES_WR . '/' . MOD_POLYMOD_CODENAME . '/items-controler.php'; if (sizeof($rowParams) == 1 && $rowParams[0] == 'item') { $md5 = md5(mt_rand() . microtime()); $url = PATH_ADMIN_MODULES_WR . '/polymod/item-selector.php'; $fieldName = $searchParamContent[0]['name']; $selectedItem = $searchParamContent[0]['value']; $params = sensitiveIO::jsonEncode(array('winId' => 'selector-' . $md5, 'objectId' => $object->getID(), 'selectedItem' => $selectedItem, 'module' => $codename)); //this is only an single item selection, so help selection a little $jscontent = <<<END \t\tvar window = Ext.getCmp('{$winId}'); \t\t//set window title \t\twindow.setTitle('{$winLabel}'); \t\t//set help button on top of page \t\twindow.tools['help'].show(); \t\t//add a tooltip on button \t\tvar propertiesTip = new Ext.ToolTip({ \t\t\ttarget:\t\t window.tools['help'], \t\t\ttitle:\t\t\t '{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP)}', \t\t\thtml:\t\t\t '{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP_DESC, false, MOD_POLYMOD_CODENAME)}', \t\t\tdismissDelay:\t0 \t\t}); \t\tvar selectedItem = '{$selectedItem}';
$view->show(); } //get records / pages $recordsPerPage = CMS_session::getRecordsPerPage(); //special users Id $rootProfileUserId = ROOT_PROFILEUSER_ID; $anonymousProfileUserId = ANONYMOUS_PROFILEUSER_ID; //user groups $userGroups = array(); $userGroups['groups'] = array(array('id' => 0, 'label' => '-', 'description' => '{$cms_language->getJsMessage(MESSAGE_PAGE_NO_GROUP)}')); $groups = CMS_profile_usersGroupsCatalog::getAll(); foreach ($groups as $group) { $userGroups['groups'][] = array('id' => $group->getGroupId(), 'label' => $group->getLabel(), 'description' => $group->getDescription()); } //json encode groups datas $userGroups = sensitiveIO::jsonEncode($userGroups); //users letters $letters = CMS_profile_usersCatalog::getLettersForLastName(); //$letters = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'); $lettersButtons = ''; foreach ($letters as $letter) { $lettersButtons .= '{ text: \'' . io::strtoupper($letter) . '\', enableToggle: true, handler: clickLetter },'; } //remove last comma $lettersButtons = io::substr($lettersButtons, 0, -1); $jscontent = <<<END \tvar usersWindow = Ext.getCmp('{$winId}');
$cstags = array(); } $clientspaces = array(); $printableCS = array(); $print_clientspaces = $template->getPrintingClientSpaces(); foreach ($cstags as $tag) { $id = $tag->getAttribute("id"); //$module = $tag->getAttribute("module"); if (!in_array($id, $print_clientspaces)) { $clientspaces[] = array($id); } else { $printableCS[] = array($id); } } $clientspaces = sensitiveIO::jsonEncode($clientspaces); $printableCS = sensitiveIO::jsonEncode($printableCS); $printTab = ",{\n\tid:\t\t\t\t'printcs-{$templateId}',\n\ttitle:\t\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_PRINT)}',\n\tlayout: \t\t'form',\n\txtype:\t\t\t'atmForm',\n\turl:\t\t\t'templates-controler.php',\n\tbodyStyle: \t\t'padding:5px',\n\tlabelAlign:\t\t'right',\n\tborder:\t\t\tfalse,\n\tbuttonAlign:\t'center',\n\titems:[{\n\t\txtype:\t\t\t'panel',\n\t\tborder:\t\t\tfalse,\n\t\thtml:\t\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_PRINT_DESC)}',\n\t\tbodyStyle: \t\t'padding:10px 0 10px 0'\n\t},{\n\t\txtype:\t\t\t'itemselector',\n\t\tname:\t\t\t'printableCS',\n\t\tfieldLabel:\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_PRINT_ZONES)}',\n\t\tdataFields:\t\t['code'],\n\t\ttoData:\t\t\t{$printableCS},\n\t\tmsWidth:\t\t250,\n\t\tmsHeight:\t\t130,\n\t\theight:\t\t\t140,\n\t\tvalueField:\t\t'code',\n\t\tdisplayField:\t'code',\n\t\ttoLegend:\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_SELECT)}',\n\t\tfromLegend:\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_AVAILABLE)}',\n\t\tfromData:\t\t{$clientspaces}\n\t}],\n\tbuttons:[{\n\t\ttext:\t\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_SAVE)}',\n\t\ticonCls:\t\t'atm-pic-validate',\n\t\txtype:\t\t\t'button',\n\t\tname:\t\t\t'submitAdmin',\n\t\thandler:\t\tfunction() {\n\t\t\tvar form = Ext.getCmp('printcs-{$templateId}').getForm();\n\t\t\tform.submit({\n\t\t\t\tparams:{\n\t\t\t\t\taction:\t\t'printcs',\n\t\t\t\t\ttemplateId:\ttemplateWindow.templateId\n\t\t\t\t},\n\t\t\t\tscope:this\n\t\t\t});\n\t\t}\n\t}]\n}"; $automnePath = PATH_MAIN_WR; $jscontent = <<<END \tvar templateWindow = Ext.getCmp('{$winId}'); \ttemplateWindow.templateId = '{$templateId}'; \t//set window title \ttemplateWindow.setTitle('{$title}'); \t//set help button on top of page \ttemplateWindow.tools['help'].show(); \t//add a tooltip on button \tvar propertiesTip = new Ext.ToolTip({ \t\ttarget:\t\t templateWindow.tools['help'], \t\ttitle:\t\t\t '{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP)}', \t\thtml:\t\t\t '{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP_DESC)}', \t\tdismissDelay:\t0
} $comboLanguages = sensitiveIO::jsonEncode($comboLanguages); $datesFormat = array(array('format' => '', 'label' => '-'), array('format' => 'd/m/Y', 'label' => date('d/m/Y') . ' (d/m/Y)'), array('format' => 'm/d/Y', 'label' => date('m/d/Y') . ' (m/d/Y)'), array('format' => 'Y/m/d', 'label' => date('Y/m/d') . ' (Y/m/d)')); $datesFormat = sensitiveIO::jsonEncode($datesFormat); $modules = CMS_modulesCatalog::getAll(); $modulesDenied = $language->getModulesDenied(); $availableModules = $excludedModules = array(); foreach ($modules as $codename => $module) { if (in_array($codename, $modulesDenied)) { $excludedModules[] = array($codename, $module->getLabel($cms_language)); } else { $availableModules[] = array($codename, $module->getLabel($cms_language)); } } $availableModules = sensitiveIO::jsonEncode($availableModules); $excludedModules = sensitiveIO::jsonEncode($excludedModules); $selectLanguageDisabled = $language->getCode() ? 'true' : 'false'; $isAvailableForBackoffice = $language->isAvailableForBackoffice() ? 'true' : 'false'; $itemFields = "{\n\txtype:\t\t\t\t'combo',\n\tname:\t\t\t\t'selectedCode',\n\thiddenName:\t\t \t'selectedCode',\n\tforceSelection:\t\ttrue,\n\tfieldLabel:\t\t\t'<span class=\"atm-red\">*</span> {$cms_language->getJSMessage(MESSAGE_PAGE_LANGUAGE)}',\n\tmode:\t\t\t\t'local',\n\ttriggerAction:\t\t'all',\n\tvalueField:\t\t\t'code',\n\tdisplayField:\t\t'label',\n\tvalue:\t\t\t\t'{$language->getCode()}',\n\tanchor:\t\t\t\t'-20px',\n\tstore:\t\t\t\tnew Ext.data.JsonStore({\n\t\tfields:\t\t\t\t['code', 'label'],\n\t\tdata:\t\t\t\t{$comboLanguages}\n\t}),\n\tallowBlank:\t\t \tfalse,\n\tselectOnFocus:\t\ttrue,\n\teditable:\t\t\ttrue,\n\ttypeAhead:\t\t\ttrue,\n\tvalidateOnBlur:\t\tfalse,\n\tdisabled:\t\t\t{$selectLanguageDisabled}\n},{\n\txtype:\t\t\t\t'atmCombo',\n\tname:\t\t\t\t'dateformat',\n\thiddenName:\t\t \t'dateformat',\n\tforceSelection:\t\ttrue,\n\tfieldLabel:\t\t\t'<span class=\"atm-red\">*</span> {$cms_language->getJSMessage(MESSAGE_PAGE_DATE_FORMAT)}',\n\tmode:\t\t\t\t'local',\n\ttriggerAction:\t\t'all',\n\tvalueField:\t\t\t'format',\n\tdisplayField:\t\t'label',\n\tvalue:\t\t\t\t'{$language->getDateFormat()}',\n\tanchor:\t\t\t\t'-20px',\n\tstore:\t\t\t\tnew Ext.data.JsonStore({\n\t\tfields:\t\t\t\t['format', 'label'],\n\t\tdata:\t\t\t\t{$datesFormat}\n\t}),\n\tallowBlank:\t\t \tfalse,\n\tselectOnFocus:\t\ttrue,\n\teditable:\t\t\tfalse,\n\tvalidateOnBlur:\t\tfalse\n},{\n\txtype:\t\t\t'itemselector',\n\tname:\t\t\t'modulesDenied',\n\tfieldLabel:\t\t'<span class=\"atm-help\" ext:qtip=\"{$cms_language->getJSMessage(MESSAGE_PAGE_SELECT_MODULES)}\">{$cms_language->getJSMessage(MESSAGE_PAGE_EXCLUDED_MODULES)}</span>',\n\tdataFields:\t\t['code', 'label'],\n\ttoData:\t\t\t{$excludedModules},\n\tmsWidth:\t\t250,\n\tmsHeight:\t\t130,\n\theight:\t\t\t140,\n\tvalueField:\t\t'code',\n\tdisplayField:\t'label',\n\ttoLegend:\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_EXCLUDED)}',\n\tfromLegend:\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_AVAILABLE)}',\n\tfromData:\t\t{$availableModules}\n},{\n\txtype: \t\t'checkbox', \n\tboxLabel: \t'{$cms_language->getJSMessage(MESSAGE_PAGE_LANGUE_AVAILABLE_FOR_ADMIN)}', \n\tinputValue:\t'1',\n\tchecked:\t{$isAvailableForBackoffice},\n\tname: \t\t'admin'\n},"; //remove last comma $itemFields = io::substr($itemFields, 0, -1); $itemsControlerURL = PATH_ADMIN_WR . '/languages-controler.php'; $jscontent = <<<END \tvar window = Ext.getCmp('{$winId}'); \t//set window title \twindow.setTitle('{$winLabel}'); \t//set help button on top of page \twindow.tools['help'].show(); \t//add a tooltip on button \tvar propertiesTip = new Ext.ToolTip({ \t\ttarget:\t\t window.tools['help'],
$protectedItem['listeners'] = array('check' => sensitiveIO::sanitizeJSString('function(el, checked) { if (checked) { Automne.message.popup({ msg: \'' . io::htmlspecialchars($cms_language->getMessage(MESSAGE_PAGE_PROTECTED_ALERT)) . '\', buttons: Ext.MessageBox.OK, closable: false, icon: Ext.MessageBox.WARNING }); } }', false, false)); } $items[] = $protectedItem; } $count++; } $items = sensitiveIO::jsonEncode($items); //do some search and replace to allow use of js functions in returned code $items = str_replace('"scope":"this"', '"scope":this', $items); function replaceCallBack($parts) { return 'function(' . str_replace(array('\\"', '\\/'), array('"', '/'), $parts[1]) . '}'; } $items = preg_replace_callback('#"function\\((.*)}"#U', 'replaceCallBack', $items); $jscontent = <<<END \tvar window = Ext.getCmp('{$winId}'); \t//set window title \twindow.setTitle('{$cms_language->getJsMessage(MESSAGE_PAGE_TITLE)}'); \t//set help button on top of page \twindow.tools['help'].show(); \t//add a tooltip on button \tvar propertiesTip = new Ext.ToolTip({
if (isset($logs[1])) { $welcomeMsg .= '<br /><br />' . $cms_language->getJsMessage(MESSAGE_PAGE_PREVIOUS_LOGIN) . ' ' . $logs[1]->getDateTime()->getLocalizedDate($cms_language->getDateFormat() . ' H:i:s'); } //validations if ($userSessionsInfos['hasValidations']) { $welcomeMsg .= '<br /><br />' . ($userSessionsInfos['awaitingValidation'] ? $cms_language->getJsMessage(MESSAGE_PAGE_USER_VALIDATIONS, array($userSessionsInfos['awaitingValidation'])) : $cms_language->getJsMessage(MESSAGE_PAGE_USER_NOVALIDATION)); } //debug if (SYSTEM_DEBUG && $cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { $welcomeMsg .= '<br /><br /><span class="atm-red">' . $cms_language->getJsMessage(MESSAGE_PAGE_DEBUG) . '</span> ' . $cms_language->getJsMessage(MESSAGE_PAGE_PRESS_F2_FOR_LOG); } //then set context, remove login window and load Automne interface $jscontent = '/*remove event closeAndBack on window*/ Ext.WindowMgr.get(\'loginWindow\').un(\'beforeclose\', Ext.WindowMgr.get(\'loginWindow\').closeAndBack); /*add event to load Automne interface after close*/ Ext.WindowMgr.get(\'loginWindow\').on(\'close\', Automne.load.createDelegate(this, [' . sensitiveIO::jsonEncode($userSessionsInfos) . '])); /*display welcome message*/ Automne.message.show(\'' . sensitiveIO::sanitizeJSString($welcome) . '\', \'' . sensitiveIO::sanitizeJSString($welcomeMsg) . '\', \'\', 6); try {delete Ext.Element.cache[\'loginField\'];} catch (e) {} '; //add all JS locales $jscontent .= CMS_session::getJSLocales(); $jscontent .= ' /*show front page in tab*/ if (Automne.tabPanels.getActiveTab().id != \'edit\') { Automne.tabPanels.getActiveTab().reload(); } /*close login window*/ Ext.WindowMgr.get(\'loginWindow\').close();'; //eval content into parent
foreach ($allGroups as $aGroup) { $searchPanel .= "{boxLabel: '{$aGroup}', inputValue:'{$aGroup}', name: 'groups[]', listeners: {'check':templateWindow.search}},"; } //remove last comma from groups $searchPanel = io::substr($searchPanel, 0, -1); $searchPanel .= "\n\t\t]\n\t},"; } $websites = CMS_websitesCatalog::getAll(); if (sizeof($websites) > 1) { $websitesDatas = array(); $websitesDatas['website'] = array(array('id' => 0, 'label' => '-')); foreach ($websites as $website) { $websitesDatas['website'][] = array('id' => $website->getID(), 'label' => $website->getLabel()); } //json encode websites datas $websitesDatas = sensitiveIO::jsonEncode($websitesDatas); $searchPanel .= "{\n\t\txtype:\t\t\t\t'combo',\n\t\tid:\t\t\t\t\t'websiteField',\n\t\tname:\t\t\t\t'website',\n\t\tfieldLabel:\t\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_WEBSITES)}',\n\t\tanchor:\t\t\t\t'-20px',\n\t\tforceSelection:\t\ttrue,\n\t\tmode:\t\t\t\t'local',\n\t\ttriggerAction:\t\t'all',\n\t\tvalueField:\t\t\t'id',\n\t\thiddenName: \t\t'website',\n\t\tdisplayField:\t\t'label',\n\t\tstore:\t\t\t\tnew Ext.data.JsonStore({\n\t\t\tid:\t\t\t\t'id',\n\t\t\troot: \t\t\t'website',\n\t\t\tfields: \t\t['id', 'label'],\n\t\t\tdata:\t\t\t{$websitesDatas}\n\t\t}),\n\t\tvalidateOnBlur:\t\tfalse,\n\t\tallowBlank: \t\ttrue,\n\t\tselectOnFocus:\t\ttrue,\n\t\teditable:\t\t\ttrue,\n\t\ttypeAhead:\t\t\ttrue,\n\t\tlisteners:\t\t\t{'valid':templateWindow.search}\n\t},"; } $searchPanel .= "{\n\txtype:\t\t\t'atmPageField',\n\tfieldLabel:\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_PAGE)}',\n\tname:\t\t\t'page',\n\tvalidateOnBlur:\tfalse,\n\tvalue:\t\t\t'',\n\tanchor:\t\t\t'-20px',\n\tallowBlank:\t\ttrue,\n\tlisteners:\t\t{'valid':{\n\t\tfn: \t\t\ttemplateWindow.search, \n\t\toptions:\t\t{buffer:300}\n\t}}\n},{\n\thideLabel:\t\ttrue,\n\tlabelSeparator:\t'',\n\tlabelAlign:\t\t'left',\n\txtype:\t\t\t'checkbox',\n\tboxLabel: \t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_VIEW_INACTIVES)}',\n\tname: \t\t\t'viewinactive',\n\tchecked:\t\ttrue,\n\tinputValue:\t\t'1',\n\tlisteners: \t\t{'check':templateWindow.search}\n}"; //$searchPanel = io::substr($searchPanel, 0, -1); $jscontent = <<<END \tvar templateWindow = Ext.getCmp('{$winId}'); \tvar fatherWindow = Ext.getCmp('{$fatherId}'); \t \t//define update function into window (to be accessible by parent window) \ttemplateWindow.updateTab = function() { \t\t//reload search \t\ttemplateWindow.search(); \t} \t//define search function into window (to be accessible by parent window) \ttemplateWindow.search = function() {
} //json encode groups datas $modules = sensitiveIO::jsonEncode($modules); //types $types = array(); $types['types'][] = array('id' => 'all', 'label' => $cms_language->getMessage(MESSAGE_PAGE_TYPE_ALL)); $types['types'][] = array('id' => 'admin', 'label' => $cms_language->getMessage(MESSAGE_PAGE_TYPE_ADMIN)); $types['types'][] = array('id' => 'resource', 'label' => $cms_language->getMessage(MESSAGE_PAGE_TYPE_PUBLICATION)); $types['types'][] = array('id' => 'login', 'label' => $cms_language->getMessage(MESSAGE_PAGE_TYPE_IDENTIFICATION)); $types['types'][] = array('id' => 'email', 'label' => $cms_language->getMessage(MESSAGE_PAGE_TYPE_EMAILS)); $modulesActions = CMS_log_catalog::getModulesActions($cms_language); if ($modulesActions) { $types['types'][] = array('id' => 'modules', 'label' => $cms_language->getMessage(MESSAGE_PAGE_TYPE_MODULES)); } //json encode groups datas $types = sensitiveIO::jsonEncode($types); if ($cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { $purgeLogs = ",'->',{\n\t\t\txtype:\t\t'button',\n\t\t\ticonCls:\t'atm-pic-deletion',\n\t\t\ttext:\t\t'{$cms_language->getJsMessage(MESSAGE_ACTION_PURGE)}',\n\t\t\ttooltip:\t'{$cms_language->getJsMessage(MESSAGE_ACTION_PURGE_DESC)}',\n\t\t\thandler:\tfunction(button) {\n\t\t\t\tAutomne.message.popup({\n\t\t\t\t\tmsg: \t\t\t\t'{$cms_language->getJsMessage(MESSAGE_ACTION_PURGE_CONFIRM)}',\n\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OKCANCEL,\n\t\t\t\t\tanimEl: \t\t\tbutton.getEl(),\n\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.WARNING,\n\t\t\t\t\tfn: \t\t\t\tfunction (button) {\n\t\t\t\t\t\tif (button == 'ok') {\n\t\t\t\t\t\t\tvar formValues = Ext.getCmp('logsSearchPanel').getForm().getValues();\n\t\t\t\t\t\t\tparams = Ext.apply(formValues, {\n\t\t\t\t\t\t\t\tdel:\t\t\ttrue,\n\t\t\t\t\t\t\t\tlimit:\t\t\t0,\n\t\t\t\t\t\t\t\tstart:\t\t\t0\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tAutomne.server.call('logs-datas.php', function() {\n\t\t\t\t\t\t\t\tlogWindow.launchSearch();\n\t\t\t\t\t\t\t}, params);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t}"; } else { $purgeLogs = ''; } $dateFormat = $cms_language->getDateFormat(); $jscontent = <<<END \tvar logWindow = Ext.getCmp('{$winId}'); \t \t//set window title \tlogWindow.setTitle('{$cms_language->getJsMessage(MESSAGE_PAGE_TITLE)}'); \t//set help button on top of page \tlogWindow.tools['help'].show(); \t//add a tooltip on button \tvar propertiesTip = new Ext.ToolTip({
$validationsSorted[$validation->getValidationTypeLabel()][] = $validation; } ksort($validationsSorted); foreach ($validationsSorted as $label => $validations) { $label = io::decodeEntities($label); $validation = $validations[0]; $validationsType['validationsType'][] = array('id' => $count, 'module' => $codename, 'editions' => $validation->getEditions(), 'label' => $modLabel . ' : ' . $label . ' : ' . sizeof($validations) . ' ' . $cms_language->getMessage(MESSAGE_PAGE_VALIDATIONS_PENDING_COUNT)); if ($codename == $module && $validation->getEditions() & $editions) { $selectedValidations = $count; } $count++; } } } //json encode validations types $validationsType = sensitiveIO::jsonEncode($validationsType); //get records / pages $recordsPerPage = CMS_session::getRecordsPerPage(); $jscontent = <<<END \tvar validationsWindow = Ext.getCmp('{$winId}'); \t//set window title \tvalidationsWindow.setTitle('{$cms_language->getJSMessage(MESSAGE_PAGE_VALIDATIONS_PENDING)}'); \t//set help button on top of page \tvalidationsWindow.tools['help'].show(); \t//add a tooltip on button \tvar propertiesTip = new Ext.ToolTip({ \t\ttarget: \t\tvalidationsWindow.tools['help'], \t\ttitle: \t\t\t'{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP)}', \t\thtml: \t\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_VALIDATION_PENDING_INFO)}', \t\tdismissDelay:\t0 \t});
\***************************************/ $logs = ", {\n\t\t\ttitle:\t'" . $cms_language->getMessage(MESSAGE_PAGE_LOG_LABEL) . "',\n\t\t\txtype:\t'atmPanel',\n\t\t\tlayout:\t'fit',\n\t\t\tid:\t\t'logPanel',\n\t\t\tautoLoad:\t\t{\n\t\t\t\turl:\t\t'page-logs.php',\n\t\t\t\tparams:\t\t{\n\t\t\t\t\twinId:\t\t'logPanel',\n\t\t\t\t\tcurrentPage:'{$pageId}',\n\t\t\t\t\taction:\t\t'view'\n\t\t\t\t},\n\t\t\t\tnocache:\ttrue,\n\t\t\t\tscope:\t\tthis\n\t\t\t}\n }"; /***************************************\ * MODULES TABS * \***************************************/ $modules = CMS_modulesCatalog::getALL(); $modulesTabs = ''; foreach ($modules as $aModule) { if ($aModule->getCodename() != MOD_STANDARD_CODENAME && $cms_user->hasModuleClearance($aModule->getCodename(), CLEARANCE_MODULE_EDIT) && method_exists($aModule, 'getPageTabsProperties')) { $tabsInfos = $aModule->getPageTabsProperties($cms_page, $cms_user); foreach ($tabsInfos as $tabInfos) { $label = $tabInfos['description'] ? '<span ext:qtip="' . sensitiveIO::sanitizeJSString($tabInfos['description']) . '">' . sensitiveIO::sanitizeJSString($tabInfos['label']) . '</span>' : sensitiveIO::sanitizeJSString($tabInfos['label']); $url = $tabInfos['url']; $tabInfos['winId'] = $objectWinId = 'module' . $aModule->getCodename() . (isset($tabInfos['tabId']) ? $tabInfos['tabId'] : '') . 'TabPanel'; $tabInfos['fatherId'] = $winId; $params = sensitiveIO::jsonEncode($tabInfos); if (!isset($tabInfos['frame']) || $tabInfos['frame'] == false) { $modulesTabs .= ",{\n\t\t\t\t\ttitle:\t'{$label}',\n\t\t\t\t\tid:\t\t'{$objectWinId}',\n\t\t\t\t\txtype:\t'atmPanel',\n\t\t\t\t\tlayout:\t'atm-border',\n\t\t\t\t\tautoLoad:\t\t{\n\t\t\t\t\t\turl:\t\t'{$url}',\n\t\t\t\t\t\tparams:\t\t{$params},\n\t\t\t\t\t\tnocache:\ttrue,\n\t\t\t\t\t\tscope:\t\tcenter\n\t\t\t\t\t}\n\t\t\t\t}"; } else { $modulesTabs .= ",{\n\t\t\t\t\ttitle:\t\t\t'{$label}',\n\t\t\t\t\tid:\t\t\t\t'{$objectWinId}',\n\t\t\t\t\txtype:\t\t\t'framePanel',\n\t\t\t\t\tframeURL:\t\t'{$url}',\n\t\t\t\t\tallowFrameNav:\ttrue\n\t\t\t\t}"; } } } } //sanitize some js string $pageTitle = sensitiveIO::sanitizeJSString($pageTitle); $pageLinkTitle = sensitiveIO::sanitizeJSString($pageLinkTitle); $pageTplLabel = sensitiveIO::sanitizeJSString($pageTplLabel); $jscontent = <<<END \tvar propertiesWindow = Ext.getCmp('{$winId}'); \t//set window title
$sortValues[] = array('id' => $key, 'label' => $label); } $sortValues = sensitiveIO::jsonEncode($sortValues); $sortItem = "{\n\t\txtype:\t\t\t\t'combo',\n\t\tname:\t\t\t\t'sort_{$object->getID()}',\n\t\thiddenName:\t\t \t'sort_{$object->getID()}',\n\t\tforceSelection:\t\ttrue,\n\t\tfieldLabel:\t\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_FIELD_SORT, false, MOD_POLYMOD_CODENAME)}',\n\t\tmode:\t\t\t\t'local',\n\t\ttriggerAction:\t\t'all',\n\t\tvalueField:\t\t\t'id',\n\t\tdisplayField:\t\t'label',\n\t\tvalue:\t\t\t\t'{$sortValue}',\n\t\tanchor:\t\t\t\t'98%',\n\t\tstore:\t\t\t\tnew Ext.data.JsonStore({\n\t\t\tfields:\t\t\t\t['id', 'label'],\n\t\t\tdata:\t\t\t\t{$sortValues}\n\t\t}),\n\t\tallowBlank:\t\t \tfalse,\n\t\tselectOnFocus:\t\ttrue,\n\t\teditable:\t\t\tfalse,\n\t\tvalidateOnBlur:\t\tfalse,\n\t\tlisteners:\t\t\t{'valid':moduleObjectWindow.search}\n\t}"; } else { $sortItem = "{\n\t\txtype:\t\t\t\t'textfield',\n\t\tfieldLabel:\t\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_FIELD_SORT, false, MOD_POLYMOD_CODENAME)}',\n\t\tanchor:\t\t\t\t'98%',\n\t\tdisabled:\t\t\ttrue,\n\t\tvalue:\t\t\t\t'{$items_possible['objectID']}',\n\t\tlisteners:\t\t\t{'valid':moduleObjectWindow.search}\n\t}"; } // build direction select $items_possible = array('asc' => $cms_language->getMessage(MESSAGE_PAGE_FIELD_ASC, false, MOD_POLYMOD_CODENAME), 'desc' => $cms_language->getMessage(MESSAGE_PAGE_FIELD_DESC, false, MOD_POLYMOD_CODENAME)); $dirValue = CMS_session::getSessionVar('direction_' . $object->getID()); $dirValue = $dirValue ? $dirValue : 'desc'; $dirValues = array(); foreach ($items_possible as $key => $label) { $dirValues[] = array('id' => $key, 'label' => $label); } $dirValues = sensitiveIO::jsonEncode($dirValues); $searchPanel .= "{\n\tlayout:\t\t\t'column',\n\txtype:\t\t\t'panel',\n\tborder:\t\t\tfalse,\n\tanchor:\t\t\t'-20px',\n\titems:[{\n\t\tcolumnWidth:\t.65,\n\t\tlayout: \t\t'form',\n\t\tborder:\t\t\tfalse,\n\t\titems: \t\t\t[{$sortItem}]\n\t},{\n\t\tcolumnWidth:\t.35,\n\t\tlayout: \t\t'form',\n\t\tborder:\t\t\tfalse,\n\t\titems: [{\n\t\t\txtype:\t\t\t\t'combo',\n\t\t\tname:\t\t\t\t'direction_{$object->getID()}',\n\t\t\thiddenName:\t\t \t'direction_{$object->getID()}',\n\t\t\tforceSelection:\t\ttrue,\n\t\t\tfieldLabel:\t\t\t' ',\n\t\t\tlabelSeparator:\t\t'',\n\t\t\tmode:\t\t\t\t'local',\n\t\t\ttriggerAction:\t\t'all',\n\t\t\tvalueField:\t\t\t'id',\n\t\t\tdisplayField:\t\t'label',\n\t\t\tvalue:\t\t\t\t'{$dirValue}',\n\t\t\tanchor:\t\t\t\t'100%',\n\t\t\tstore:\t\t\t\tnew Ext.data.JsonStore({\n\t\t\t\tfields:\t\t\t\t['id', 'label'],\n\t\t\t\tdata:\t\t\t\t{$dirValues}\n\t\t\t}),\n\t\t\tvalidateOnBlur:\t\tfalse,\n\t\t\tallowBlank:\t\t \tfalse,\n\t\t\tselectOnFocus:\t\ttrue,\n\t\t\teditable:\t\t\tfalse,\n\t\t\tlisteners:\t\t\t{'valid':moduleObjectWindow.search}\n\t\t}]\n\t}]\n},"; $description = sensitiveIO::sanitizeJSString($object->getDescription($cms_language)); if ($description) { $searchPanel .= "{\n\t\txtype:\t\t\t'panel',\n\t\tborder:\t\t\tfalse,\n\t\thtml:\t\t\t'<div style=\"color:grey;padding-top:15px;\">{$description}</div>'\n\t},"; } //check for included file $filename = PATH_ADMIN_FS . '/inc/' . $codename . "_" . $objectId . "_" . $cms_language->getCode() . ".inc.php"; if (file_exists($filename)) { ob_start(); include_once $filename; $return = ob_get_clean(); $includeDesc = sensitiveIO::sanitizeJSString($return); $searchPanel .= "{\n\t\txtype:\t\t\t'panel',\n\t\tborder:\t\t\tfalse,\n\t\thtml:\t\t\t'<div style=\"color:grey;padding-top:15px;\">{$includeDesc}</div>'\n\t},"; } //help for multiple selection
$options = json_decode($options, true); } $moduleLabel = sensitiveIO::sanitizeJSString(io::htmlspecialchars($module->getLabel($cms_language))); //create item for each objects $objectsInfos = $module->getObjectsInfos($cms_user); $items = ''; $activeTab = 0; foreach ($objectsInfos as $objectsInfo) { if (!isset($objectsInfo['class']) || $objectsInfo['class'] != 'atm-separator') { $items .= $items ? ',' : ''; $label = $objectsInfo['description'] ? '<span ext:qtip="' . sensitiveIO::sanitizeJSString($objectsInfo['description']) . '">' . sensitiveIO::sanitizeJSString($objectsInfo['label']) . '</span>' : sensitiveIO::sanitizeJSString($objectsInfo['label']); $url = isset($objectsInfo['url']) ? $objectsInfo['url'] : PATH_ADMIN_MODULES_WR . '/' . $codename . '/items.php'; $objectWinId = 'module' . $codename . $objectsInfo['objectId'] . 'Panel'; $objectsInfo['winId'] = $objectWinId; $objectsInfo['fatherId'] = $winId; $params = sensitiveIO::jsonEncode($objectsInfo); if (isset($options['objectId']) && $options['objectId'] == $objectsInfo['objectId']) { $activeTab = $objectWinId; } elseif ($activeTab === 0) { $activeTab = $objectWinId; } if ($objectsInfo['objectId'] == 'categories') { $url = 'modules-categories.php'; } if (!isset($objectsInfo['frame']) || $objectsInfo['frame'] == false) { $items .= "{\n\t\t\t\ttitle:\t'{$label}',\n\t\t\t\tid:\t\t'{$objectWinId}',\n\t\t\t\txtype:\t'atmPanel',\n\t\t\t\tlayout:\t'atm-border',\n\t\t\t\tautoLoad:\t\t{\n\t\t\t\t\turl:\t\t'{$url}',\n\t\t\t\t\tparams:\t\t{$params},\n\t\t\t\t\tnocache:\ttrue,\n\t\t\t\t\tscope:\t\tcenter\n\t\t\t\t}\n\t\t\t}"; } else { $items .= "{\n\t\t\t\ttitle:\t\t\t'{$label}',\n\t\t\t\tid:\t\t\t\t'{$objectWinId}',\n\t\t\t\txtype:\t\t\t'framePanel',\n\t\t\t\tframeURL:\t\t'{$url}',\n\t\t\t\tallowFrameNav:\ttrue\n\t\t\t}"; } } }
$welcomeMsg .= '<br /><br />' . $cms_language->getJsMessage(MESSAGE_PAGE_PREVIOUS_LOGIN) . ' ' . $logs[1]->getDateTime()->getLocalizedDate($cms_language->getDateFormat() . ' H:i:s'); } //validations if ($userSessionsInfos['hasValidations']) { $welcomeMsg .= '<br /><br />' . ($userSessionsInfos['awaitingValidation'] ? $cms_language->getJsMessage(MESSAGE_PAGE_USER_VALIDATIONS, array($userSessionsInfos['awaitingValidation'])) : $cms_language->getJsMessage(MESSAGE_PAGE_USER_NOVALIDATION)); } //debug if (SYSTEM_DEBUG && $cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { $welcomeMsg .= '<br /><br /><span class="atm-red">' . $cms_language->getJsMessage(MESSAGE_PAGE_DEBUG) . '</span> ' . $cms_language->getJsMessage(MESSAGE_PAGE_PRESS_F2_FOR_LOG); } $jscontent = ' //show front page in tab Automne.tabPanels.getActiveTab().setFrameURL(\'' . PATH_REALROOT_WR . '/\'); Automne.tabPanels.getActiveTab().reload(); //load interface Automne.load(' . sensitiveIO::jsonEncode($userSessionsInfos) . '); //display welcome message Automne.message.show(\'' . sensitiveIO::sanitizeJSString($welcome) . '\', \'' . sensitiveIO::sanitizeJSString($welcomeMsg) . '\', \'\', 6); '; //add all JS locales $jscontent .= CMS_session::getJSLocales(); $view->addJavascript($jscontent); $view->show(CMS_view::SHOW_RAW); } else { unset($cms_user); } break; } //Send Login form window $applicationLabel = io::htmlspecialchars(APPLICATION_LABEL); $loginURL = PATH_ADMIN_WR . '/login-form.php?_ts=' . time();
$iconsField = io::substr($iconsField, 0, -1); $iconsField .= "\n\t\t]\n\t},"; } //Templates filters $filteredTemplates = $row->getFilteredTemplates(); $templates = CMS_pageTemplatesCatalog::getAll(true, '', array(), '', array(), $cms_user, 0, 0, true); $availableTemplates = $selectedTemplates = array(); foreach ($templates as $id => $template) { if (in_array($id, $filteredTemplates)) { $selectedTemplates[] = array($id, $template->getLabel()); } else { $availableTemplates[] = array($id, $template->getLabel()); } } $availableTemplates = sensitiveIO::jsonEncode($availableTemplates); $selectedTemplates = sensitiveIO::jsonEncode($selectedTemplates); //DEFINITION TAB $rowDefinition = $rowDefinition ? $rowDefinition : '<row></row>'; $content = '<textarea id="row-definition-' . $rowId . '" style="display:none;">' . htmlspecialchars($rowDefinition) . '</textarea>'; $view->setContent($content); $title = sensitiveIO::sanitizeJSString(sensitiveIO::isPositiveInteger($rowId) ? $cms_language->getMessage(MESSAGE_PAGE_ROW) . ' ' . $label : $cms_language->getMessage(MESSAGE_PAGE_ROW_CREATE)); $label = sensitiveIO::sanitizeJSString($label); $automnePath = PATH_MAIN_WR; $jscontent = <<<END \tvar rowWindow = Ext.getCmp('{$winId}'); \trowWindow.rowId = '{$rowId}'; \t//set window title \trowWindow.setTitle('{$title}'); \t//set help button on top of page \trowWindow.tools['help'].show(); \t//add a tooltip on button
$selectedWebsites[] = array($id, $website->getURL()); } } else { $exists = false; foreach ($availableWebsites as $data) { if ($data[1] == $website->getURL()) { $exists = true; } } if (!$exists) { $availableWebsites[] = array($id, $website->getURL()); } } } $availableWebsites = sensitiveIO::jsonEncode($availableWebsites); $selectedWebsites = sensitiveIO::jsonEncode($selectedWebsites); $subAliasesDisabled = $item->hasSubAliases() ? 'disabled:true,' : ''; //add an alert on protected option for non admin users $protectedAlert = ''; if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITVALIDATEALL)) { $protectedAlert = ",\n\t\tlisteners:\t{\n\t\t\t'check':function(el, checked) {\n\t\t\t\tif (checked) {\n\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\tmsg: \t\t\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_PROTECTED_ALERT)}',\n\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OK,\n\t\t\t\t\t\tclosable: \t\t\tfalse,\n\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.WARNING\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t},\n\t\t\tscope:this\n\t\t}"; } $jscontent = <<<END \tvar window = Ext.getCmp('{$winId}'); \t//set window title \twindow.setTitle('{$cms_language->getJsMessage(MESSAGE_PAGE_TITLE, false, "cms_aliases")}'); \t//set help button on top of page \twindow.tools['help'].show(); \t//add a tooltip on button \tvar propertiesTip = new Ext.ToolTip({ \t\ttarget:\t\t window.tools['help'],
$onClick = sensitiveIO::sanitizeJSString(' Automne.utils.getPageById(%s); if (Ext.getCmp(\'' . $winId . '\').closable) { Ext.getCmp(\'' . $winId . '\').close(); } '); } else { $onClick = sensitiveIO::sanitizeJSString($onClick); } } else { $onClick = ''; } $onSelect = $onSelect ? sensitiveIO::sanitizeJSString($onSelect) : ''; $rootnode = array('id' => 'root' . $rootId, 'leaf' => false, 'expanded' => true); //encode nodes array in json $rootnode = sensitiveIO::jsonEncode($rootnode); $rootvisible = $cms_user->hasPageClearance($root->getID(), CLEARANCE_PAGE_VIEW) ? 'true' : 'false'; $scriptRoot = dirname($_SERVER['SCRIPT_NAME']); $heading = $heading ? '\'' . sensitiveIO::sanitizeJSString($heading) . '\'' : 'null'; $imgPath = PATH_ADMIN_IMAGES_WR; if ($hideMenu) { $tbar = "''"; } else { $tbar = "new Ext.Toolbar({\n\t\t\tid:\t\t\t\t'treeToolbar',\n\t\t\titems:\t\t\t["; if (!$editable) { $tbar .= "\n\t\t\t\t{\n\t\t\t\t\ticonCls:\t'atm-pic-filter',\n\t\t\t\t\ttext:\t\t'{$cms_language->getJsMessage(MESSAGE_TOOLBAR_FILTER)}',\n\t\t\t\t\ttooltip:\t'{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP_FILTER)}',\n\t\t\t\t\tmenu: new Ext.menu.Menu({\n\t\t\t\t\t\tid: \t'filterMenu',\n\t\t\t\t\t\titems: [{\n\t\t\t\t\t\t\t\t\ttext: \t\t'{$cms_language->getJsMessage(MESSAGE_TOOLBAR_DISPLAY_VISIBLE)}',\n\t\t\t\t\t\t\t\t\tchecked: \ttrue,\n\t\t\t\t\t\t\t\t\tgroup: \t\t'visibility',\n\t\t\t\t\t\t\t\t\tvalue:\t\t0\n\t\t\t\t\t\t\t\t}, {\n\t\t\t\t\t\t\t\t\ttext:\t\t'{$cms_language->getJsMessage(MESSAGE_TOOLBAR_DISPLAY_EDITABLE)}',\n\t\t\t\t\t\t\t\t\tchecked: \tfalse,\n\t\t\t\t\t\t\t\t\tgroup: \t\t'visibility',\n\t\t\t\t\t\t\t\t\tvalue:\t\t1\n\t\t\t\t\t\t\t\t}]\n\t\t\t\t\t})\n\t\t\t\t},"; } $tbar .= "\n\t\t\t\tnew Ext.Toolbar.Fill(),\n\t\t\t\tnew Automne.ComboBox({\n\t\t\t\t\tid: \t'searchBox',\n\t\t\t\t\tstore: new Ext.data.Store({\n\t\t\t\t\t\tproxy: new Ext.data.HttpProxy({\n\t\t\t\t\t\t\turl: \t\t\t\t'{$scriptRoot}/search-pages.php',\n\t\t\t\t\t\t\tdisableCaching:\t\ttrue\n\t\t\t\t\t\t}),\n\t\t\t\t\t\treader: new Automne.JsonReader({\n\t\t\t\t\t\t\troot: \t\t\t\t'pages',\n\t\t\t\t\t\t\ttotalProperty: \t\t'totalCount',\n\t\t\t\t\t\t\tid: \t\t\t\t'pageId'\n\t\t\t\t\t\t}, [\n\t\t\t\t\t\t\t{name: 'title', \tmapping: 'title'},\n\t\t\t\t\t\t\t{name: 'status',\tmapping: 'status'}\n\t\t\t\t\t\t])\n\t\t\t\t\t}),\n\t\t\t\t\tlisteners: {'specialkey':function(field, e) {\n\t\t\t\t\t\t\tif (Ext.EventObject.getKey() == Ext.EventObject.ENTER) {\n\t\t\t\t\t\t\t\tfield.doQuery(field.getValue());\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t\tscope:this\n\t\t\t\t\t},\n\t\t\t\t\tdisplayField:\t\t'title',\n\t\t\t\t\tautoLoad:\t\t\tfalse,\n\t\t\t\t\ttypeAhead: \t\t\tfalse,\n\t\t\t\t\twidth: \t\t\t\t320,\n\t\t\t\t\tminListWidth:\t\t320,\n\t\t\t\t\tresizable: \t\t\ttrue,\n\t\t\t\t\tloadingText:\t\t'{$cms_language->getJsMessage(MESSAGE_SEARCH_LOADING)}',\n\t\t\t\t\tminChars:\t\t\t3,\n\t\t\t\t\tmaxHeight:\t\t\t400,\n\t\t\t\t\tqueryDelay:\t\t\t350,\n\t\t\t\t\tpageSize:\t\t\t10,\n\t\t\t\t\thideTrigger:\t\ttrue,\n\t\t\t\t\temptyText:\t\t\t'{$cms_language->getJsMessage(MESSAGE_TOOLBAR_SEARCH_PAGE)}',\n\t\t\t\t\ttpl: new Ext.XTemplate(\n\t\t\t\t\t\t'<tpl for=\".\"><div class=\"search-item atm-search-item\">',\n\t\t\t\t\t\t\t'<h3>{status} {title}</h3>',\n\t\t\t\t\t\t'</div></tpl>'\n\t\t\t\t\t),\n\t\t\t\t\titemSelector: \t\t'div.atm-search-item'\n\t\t\t\t}),\n\t\t\t\tnew Ext.Toolbar.Spacer(),\n\t\t\t\t{\n\t\t\t\t\ticon: \t\t'{$imgPath}/help.gif',\n\t\t\t\t\tcls: \t\t'x-btn-icon',\n\t\t\t\t\ttooltip: \t{\n\t\t\t\t\t\ttitle:\t\t\t'{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP)}',\n\t\t\t\t\t\ttext:\t\t\t'{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP_SEARCH)}',\n\t\t\t\t\t\tdismissDelay:\t30000\n\t\t\t\t\t}\n\t\t\t }\n\t\t\t]\n\t\t})\n\t"; } $jscontent = <<<END \tvar treeWindow = Ext.getCmp('{$winId}');
$items .= $items ? ',' : ''; $objectWinId = 'module' . $aPolyModuleCodename . '-' . $id . 'Plugin'; if ($pluginDefinition->needSelection() && !$content && $selectedPluginID != $id) { $disabled = 'disabled:true,'; $label = '<span ext:qtip="' . sensitiveIO::sanitizeJSString($polymodule->getLabel($cms_language) . ' : ' . $pluginDefinition->getDescription($cms_language) . '<br /><br /><strong>' . $cms_language->getMessage(MESSAGE_PAGE_TAB_DISABLED_SELECT_TEXT, false, MOD_POLYMOD_CODENAME)) . '</strong>">' . sensitiveIO::sanitizeJSString($pluginDefinition->getLabel($cms_language)) . '</span>'; } elseif (!$pluginDefinition->needSelection() && $content && $selectedPluginID != $id) { $disabled = 'disabled:true,'; $label = '<span ext:qtip="' . sensitiveIO::sanitizeJSString($polymodule->getLabel($cms_language) . ' : ' . $pluginDefinition->getDescription($cms_language) . '<br /><br /><strong>' . $cms_language->getMessage(MESSAGE_PAGE_TAB_DISABLED_NO_SELECT_TEXT, false, MOD_POLYMOD_CODENAME)) . '</strong>">' . sensitiveIO::sanitizeJSString($pluginDefinition->getLabel($cms_language)) . '</span>'; } else { if ($selectedPluginID == $id || $activeTab === 0) { $activeTab = $objectWinId; } $disabled = ''; $label = '<span ext:qtip="' . sensitiveIO::sanitizeJSString($polymodule->getLabel($cms_language) . ' : ' . $pluginDefinition->getDescription($cms_language)) . '">' . sensitiveIO::sanitizeJSString($pluginDefinition->getLabel($cms_language)) . '</span>'; } $params = sensitiveIO::jsonEncode(array('winId' => $objectWinId, 'objectId' => $pluginDefinition->getValue('objectID'), 'plugin' => $id, 'selectedItem' => $selectedItem, 'content' => $content, 'module' => $aPolyModuleCodename)); $items .= "{\n\t\t\t\t{$disabled}\n\t\t\t\ttitle:\t'{$label}',\n\t\t\t\tid:\t\t'{$objectWinId}',\n\t\t\t\txtype:\t'atmPanel',\n\t\t\t\tlayout:\t'atm-border',\n\t\t\t\tautoLoad:\t\t{\n\t\t\t\t\turl:\t\t'{$url}',\n\t\t\t\t\tparams:\t\t{$params},\n\t\t\t\t\tnocache:\ttrue,\n\t\t\t\t\tscope:\t\tcenter\n\t\t\t\t},\n\t\t\t\tselectItem:\t\tfunction(id, params) {\n\t\t\t\t\tfieldPluginCode.setValue('');\n\t\t\t\t\tif (id) {\n\t\t\t\t\t\t//grab code to paste from selected item id\n\t\t\t\t\t\tAutomne.server.call('{$pluginControler}', function(response, option, content){\n\t\t\t\t\t\t\tfieldPluginCode.setValue(content);\n\t\t\t\t\t\t}, Ext.apply({\n\t\t\t\t\t\t\titem:\t\tid,\n\t\t\t\t\t\t\ttype:\t\tparams.objectId,\n\t\t\t\t\t\t\taction:\t\t'pluginSelection'\n\t\t\t\t\t\t}, params), this);\n\t\t\t\t\t}\n\t\t\t\t}.createDelegate(this, [{$params}], true)\n\t\t\t}"; } } } $jscontent = <<<END \tvar moduleWindow = Ext.getCmp('{$winId}'); \t//create center panel \tvar center = new Ext.TabPanel({ activeTab: \t\t\t'{$activeTab}', id:\t\t\t\t\t'modulePluginsPanel', \t\tregion:\t\t\t\t'center', \t\tplain:\t\t\t\ttrue, enableTabScroll:\ttrue, \t\tplugins:\t\t\t[ new Ext.ux.TabScrollerMenu() ], \t\tdefaults:\t\t\t{
} if (io::strpos($search, 'row:') !== false && isset($elements['templates'])) { $checkedElements['templates'] = true; } $searchPanel .= "{\n\t\txtype: \t\t'checkboxgroup',\n\t\tid: \t\t'searchCheckboxgroup',\n\t\tfieldLabel: '" . $cms_language->getJsMessage(MESSAGE_PAGE_FIELD_SEARCH_IN) . "',\n\t\tcolumns: \t1,\n\t\titems: [\n\t\t\t{boxLabel: '<em style=\"font-style:italic;\">" . $cms_language->getJSMessage(MESSAGE_PAGE_CHECK_ALL) . "</em>', checked: " . (sizeof($elements) == sizeof($checkedElements) ? 'true' : 'false') . ", listeners: {'check':function(field, checked) {\n\t\t\t\tif (searchWindow.ok) {\n\t\t\t\t\tsearchWindow.ok = false;\n\t\t\t\t\tExt.getCmp('searchCheckboxgroup').items.each(function(el, group, index){\n\t\t\t\t\t\tif (index == 0) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tel.setValue(checked);\n\t\t\t\t\t}, this);\n\t\t\t\t\tsearchWindow.ok = true;\n\t\t\t\t\t//launch search\n\t\t\t\t\tsearchWindow.search();\n\t\t\t\t}\n\t\t\t}, scope:this}},\n\t\t"; foreach ($elements as $element => $label) { $label = io::htmlspecialchars($label); //if search use special search code, only search on standard module $checked = !$search || isset($checkedElements[$element]) && $checkedElements[$element] ? 'true' : 'false'; $searchPanel .= "{boxLabel: '{$label}', ctCls:'x-masked', inputValue:'{$element}', checked: {$checked}, name: 'elements[]', listeners: {'check':searchWindow.search}},"; } //remove last comma from groups $searchPanel = substr($searchPanel, 0, -1); $searchPanel .= "]\n\t},"; } $searchCodes = sensitiveIO::jsonEncode($searchCodes); $searchPanel = io::substr($searchPanel, 0, -1); $appTitle = sensitiveIO::sanitizeJSString(APPLICATION_LABEL); $jscontent = <<<END \tvar searchWindow = Ext.getCmp('{$winId}'); \t \t//set window title \tsearchWindow.setTitle('{$cms_language->getJsMessage(MESSAGE_PAGE_FIELD_SEARCH_INTO, array($appTitle))}'); \t//set help button on top of page \tsearchWindow.tools['help'].show(); \t//add a tooltip on button \tvar propertiesTip = new Ext.ToolTip({ \t\ttarget: \t\tsearchWindow.tools['help'], \t\ttitle: \t\t\t'{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP)}', \t\thtml: \t\t\t'{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP_DESC)}', \t\tdismissDelay:\t0
$cms_block = new $blockClass(); $cms_block->initializeFromBasicAttributes($blockId); $rawDatas = $cms_block->getRawData($cms_page->getID(), $cs, $rowTag, RESOURCE_LOCATION_EDITION, false); } else { CMS_grandFather::raiseError('Error, can\'t get block class : ' . $blockClass); $view->show(); } $maxFileSize = CMS_file::getMaxUploadFileSize('K'); if ($rawDatas['file'] && file_exists(PATH_MODULES_FILES_STANDARD_FS . '/edition/' . $rawDatas['file'])) { $file = new CMS_file(PATH_MODULES_FILES_STANDARD_FS . '/edition/' . $rawDatas['file']); $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' => ''); } $filePath = $fileDatas['filepath']; $fileDatas = sensitiveIO::jsonEncode($fileDatas); $flashvars = sensitiveIO::sanitizeJSString($rawDatas["flashvars"]); $params = sensitiveIO::sanitizeJSString($rawDatas["params"]); $attributes = sensitiveIO::sanitizeJSString($rawDatas["attributes"]); $jscontent = <<<END \tvar blockWindow = Ext.getCmp('{$winId}'); \t//set window title \tblockWindow.setTitle('{$cms_language->getJsMessage(MESSAGE_EDIT_FLASH)}'); \t//set help button on top of page \tblockWindow.tools['help'].show(); \t//add a tooltip on button \tvar propertiesTip = new Ext.ToolTip({ \t\ttarget:\t\t blockWindow.tools['help'], \t\ttitle:\t\t\t '{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP)}', \t\thtml:\t\t\t '{$cms_language->getJsMessage(MESSAGE_WINDOW_INFO)}', \t\tdismissDelay:\t0
//get accordion datas from module $moduleDatas = $aModule->getUserAccordionProperties($userId, $cms_language); $moduleURL = false; if (isset($moduleDatas['url'])) { $moduleURL = $moduleDatas['url']; } $moduleLabel = io::sanitizeJSString($aModule->getLabel($cms_language)); if (isset($moduleDatas['label'])) { $moduleLabel = io::sanitizeJSString($moduleDatas['label']); } $moduleFields = array(); if (isset($moduleDatas['fields']) && is_array($moduleDatas['fields'])) { $moduleFields = $moduleDatas['fields']; } if (is_array($moduleFields)) { $moduleFields = sensitiveIO::jsonEncode($moduleFields); } //do some search and replace to allow use of js functions in returned code $moduleFields = str_replace('"scope":"this"', '"scope":this', $moduleFields); $moduleFields = preg_replace_callback('#"function\\((.*)}"#U', 'replaceCallBack', $moduleFields); $button = $moduleURL ? ",\n\t\t\t\tbuttons:[{\n\t\t\t\t\ttext:\t\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_SAVE)}',\n\t\t\t\t\ticonCls:\t\t'atm-pic-validate',\n\t\t\t\t\txtype:\t\t\t'button',\n\t\t\t\t\tname:\t\t\t'submit{$moduleCodename}User',\n\t\t\t\t\tscope:\t\t\tthis,\n\t\t\t\t\thandler:\t\tfunction() {\n\t\t\t\t\t\tvar form = Ext.getCmp('userPanel-{$moduleCodename}-{$userId}').getForm();\n\t\t\t\t\t\tform.submit({params:{\n\t\t\t\t\t\t\taction:\t\t'update-user',\n\t\t\t\t\t\t\tuserId:\t\tuserWindow.userId\n\t\t\t\t\t\t}});\n\t\t\t\t\t}\n\t\t\t\t}]" : ''; $modulesAccordion .= ",{\n\t\t\t\ttitle:\t\t\t'{$moduleLabel}',\n\t\t\t\tid:\t\t\t\t'userPanel-{$moduleCodename}-{$userId}',\n\t\t\t\tlayout: \t\t'form',\n\t\t\t\txtype:\t\t\t'atmForm',\n\t\t\t\turl:\t\t\t'{$moduleURL}',\n\t\t\t\tcollapsible:\ttrue,\n\t\t\t\tdefaultType:\t'textfield',\n\t\t\t\tcollapsed:\t\ttrue,\n\t\t\t\tautoWidth:\t\ttrue,\n\t\t\t\tautoScroll:\t\ttrue,\n\t\t\t\tbuttonAlign:\t'center',\n\t\t\t\tlabelAlign:\t\t'right',\n\t\t\t\tautoScroll:\t\ttrue,\n\t\t\t\tdefaults: {\n\t\t\t\t\txtype:\t\t\t'textfield',\n\t\t\t\t\tanchor:\t\t\t'97%'\n\t\t\t\t},\n\t\t\t\titems:[{$moduleFields}]\n\t\t\t\t{$button}\n\t\t\t}"; } } } $title = sensitiveIO::isPositiveInteger($userId) ? $cms_language->getJsMessage(MESSAGE_PAGE_USER_PROFILE) . ' : ' . $fullname : $cms_language->getJsMessage(MESSAGE_PAGE_USER_CREATION); $jscontent = <<<END \tvar userWindow = Ext.getCmp('{$winId}'); \tuserWindow.userId = '{$userId}'; \t//set window title \tuserWindow.setTitle('{$title}');
/** * Get the HTML form given the block HTML example data. * * @param CMS_language &$language The language of the administration frontend * @param CMS_page &$page The page which contains the client space * @param CMS_clientSpace &$clientSpace The client space which contains the row * @param CMS_row &$row The row which contains the block * @param integer $blockID The tag ID of the block * @param string $data The data to show as example * @return string The HTML form which can send to the page that will modify the block * @access private */ protected function _getHTMLForm($language, &$page, &$clientSpace, &$row, $blockID, $data) { global $cms_user; //append atm-block class and block-id to all first level tags found in block datas $domdocument = new CMS_DOMDocument(); try { $domdocument->loadXML('<block>' . $data . '</block>'); } catch (DOMException $e) { $this->raiseError('Parse error for ' . get_class($this) . ' : Page ' . $page->getID() . ' - Row "' . $row->getTagID() . '" - Block "' . $blockID . '" : ' . $e->getMessage()); $data = '<div class="atm-error-block atm-block-helper">' . $language->getMessage(self::MESSAGE_BLOCK_CONTENT_ERROR) . '</div>'; $domdocument = new CMS_DOMDocument(); $domdocument->loadXML('<block>' . $data . '</block>'); } $blockNodes = $domdocument->getElementsByTagName('block'); if ($blockNodes->length == 1) { $blockXML = $blockNodes->item(0); } //check for valid tags nodes inside current block tag $hasNode = false; foreach ($blockXML->childNodes as $blockChildNode) { //scripts tags and p tags are not correctly handled by javascript if (is_a($blockChildNode, 'DOMElement') && $blockChildNode->tagName != 'script') { $hasNode = true; } } foreach ($blockXML->childNodes as $blockChildNode) { //scripts tags and p tags are not correctly handled by javascript if (is_a($blockChildNode, 'DOMElement') && ($blockChildNode->tagName != 'p' || io::substr($blockChildNode->tagName, 0, 4) != 'atm-')) { $hasNode = false; } } if (!$hasNode) { //append div with atm-empty-block class around datas $domdocument = new CMS_DOMDocument(); try { $domdocument->loadXML('<block><div class="atm-empty-block atm-block-helper">' . $data . '</div></block>'); } catch (DOMException $e) { $this->raiseError('Parse error for block : ' . $e->getMessage() . " :\n" . $data, true); return ''; } $blockNodes = $domdocument->getElementsByTagName('block'); if ($blockNodes->length == 1) { $blockXML = $blockNodes->item(0); } } $elements = array(); $uniqueId = 'block-' . md5(mt_rand() . microtime()); foreach ($blockXML->childNodes as $blockChildNode) { if (is_a($blockChildNode, 'DOMElement') && $blockChildNode->tagName != 'script' && $blockChildNode->tagName != 'p' && io::substr($blockChildNode->tagName, 0, 4) != 'atm-') { if ($blockChildNode->hasAttribute('class')) { $blockChildNode->setAttribute('class', $blockChildNode->getAttribute('class') . ' atm-block ' . $uniqueId); } else { $blockChildNode->setAttribute('class', 'atm-block ' . $uniqueId); } $elementId = 'el-' . md5(mt_rand() . microtime()); $blockChildNode->setAttribute('id', $elementId); $elements[] = $elementId; } } $data = CMS_DOMDocument::DOMElementToString($blockXML, true); //add block JS specification $data = ' <script type="text/javascript"> atmBlocksDatas[\'' . $uniqueId . '\'] = { page: \'' . $page->getID() . '\', document: document, clientSpaceTagID: \'' . $clientSpace->getTagID() . '\', row: \'' . $row->getTagID() . '\', id: \'' . $blockID . '\', jsBlockClass: \'' . $this->_jsBlockClass . '\', hasContent: \'' . $this->_hasContent . '\', editable: \'' . $this->_editable . '\', administrable: \'' . $this->_administrable . '\', options: ' . io::jsonEncode($this->_options) . ', value: ' . (is_array($this->_value) ? sensitiveIO::jsonEncode($this->_value) : '\'' . sensitiveIO::sanitizeJSString($this->_value) . '\'') . ', elements: [' . ($elements ? '\'' . implode('\',\'', $elements) . '\'' : '') . '] }; </script> ' . $data; return $data; }
/** * Shows body of html page * * @return void * @access private */ private function _showBody($returnValue = false) { switch ($this->_displayMode) { case self::SHOW_JSON: $return = ''; if ($this->_jscontent) { $return .= ' <jscontent><![CDATA[' . $this->_espaceCdata($this->_jscontent) . ']]></jscontent>' . "\n"; } if ($this->_content) { $return .= ' <' . $this->_contentTags[$this->_displayMode] . '><![CDATA[' . $this->_espaceCdata(sensitiveIO::jsonEncode($this->_content)) . ']]></' . $this->_contentTags[$this->_displayMode] . '>' . "\n"; } if (!$returnValue) { echo $return; } else { return $return; } break; case self::SHOW_RAW: $return = ''; if ($this->_jscontent) { $return .= ' <jscontent><![CDATA[' . $this->_espaceCdata($this->_jscontent) . ']]></jscontent>' . "\n"; } if ($this->_content) { $return .= ' <' . $this->_contentTags[$this->_displayMode] . '><![CDATA[' . $this->_espaceCdata($this->_content) . ']]></' . $this->_contentTags[$this->_displayMode] . '>' . "\n"; } if (!$returnValue) { echo $return; } else { return $return; } break; case self::SHOW_XML: $return = ''; if ($this->_jscontent) { $return .= ' <jscontent><![CDATA[' . $this->_espaceCdata($this->_jscontent) . ']]></jscontent>' . "\n"; } if ($this->_content) { //TODOV4 : check for XML conformity of $this->_content $return .= ' <' . $this->_contentTags[$this->_displayMode] . '>' . $this->_content . '</' . $this->_contentTags[$this->_displayMode] . '>' . "\n"; } if (!$returnValue) { echo $return; } else { return $return; } break; case self::SHOW_HTML: default: echo '<body>'; //display errors if ($this->hasErrors()) { echo $this->getErrors(true); } //display raw datas if ($this->hasRawDatas()) { echo $this->getRawDatas(true); } //display action message if ($this->_actionmessage) { echo $this->_actionmessage; } //display content echo $this->_content; echo '</body>'; break; } }