Ejemplo n.º 1
0
        $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
\t});
\t
Ejemplo n.º 2
0
$cms_message = '';
switch ($action) {
    case 'save':
    case 'save-validate':
        //checks and assignments
        $item->setDebug(false);
        $fieldsObjects = $item->getFieldsObjects();
        //first, check mandatory values
        $allOK = true;
        foreach ($fieldsObjects as $fieldID => $aFieldObject) {
            $return = $item->checkMandatory($fieldID, $fieldsValues, '', true);
            if ($return !== true) {
                $allOK = false;
                $cms_message .= "<br />- " . $aFieldObject->getFieldLabel($cms_language);
                if ($return !== false) {
                    $jscontent = "\n\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\tmsg: \t\t\t\t'" . sensitiveIO::sanitizeJSString($return) . "',\n\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OK,\n\t\t\t\t\t\tclosable: \t\t\ttrue,\n\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.ERROR\n\t\t\t\t\t});";
                    $view->addJavascript($jscontent);
                }
            }
        }
        if (!$allOK) {
            $cms_message = $cms_language->getMessage(MESSAGE_FORM_ERROR_FOLLOWING_FIELDS_MANDATORY, false, MOD_POLYMOD_CODENAME) . $cms_message;
        } else {
            //second, set values for all fields
            foreach ($fieldsObjects as $fieldID => $aFieldObject) {
                if (!$item->setValues($fieldID, $fieldsValues, '', true)) {
                    $cms_message .= "\n" . $cms_language->getMessage(MESSAGE_FORM_ERROR_MALFORMED_FIELD, array($aFieldObject->getFieldLabel($cms_language)));
                }
            }
        }
        //set publication dates if needed
Ejemplo n.º 3
0
    /**
     * get HTML admin (used to enter object values in admin)
     *
     * @param integer $fieldID, the current field id (only for poly object compatibility)
     * @param CMS_language $language, the current admin language
     * @param string prefixname : the prefix to use for post names
     * @return string : the html admin
     * @access public
     */
    function getHTMLAdmin($fieldID, $language, $prefixName)
    {
        //get module codename
        $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
        //is this field mandatory ?
        $mandatory = $this->_field->getValue('required') ? '<span class="atm-red">*</span> ' : '';
        $desc = $this->getFieldDescription($language);
        if (POLYMOD_DEBUG) {
            $values = array();
            foreach (array_keys($this->_subfieldValues) as $subFieldID) {
                if (is_object($this->_subfieldValues[$subFieldID])) {
                    $values[$subFieldID] = sensitiveIO::ellipsis(strip_tags($this->_subfieldValues[$subFieldID]->getValue()), 50);
                }
            }
            $desc .= $desc ? '<br />' : '';
            $desc .= '<span class="atm-red">Field : ' . $fieldID . ' - Value(s) : <ul>';
            foreach ($values as $subFieldID => $value) {
                $desc .= '<li>' . $subFieldID . '&nbsp;:&nbsp;' . $value . '</li>';
            }
            $desc .= '</ul></span>';
        }
        $label = $desc ? '<span class="atm-help" ext:qtip="' . io::htmlspecialchars($desc) . '">' . $mandatory . $this->getFieldLabel($language) . '</span>' : $mandatory . $this->getFieldLabel($language);
        $ids = 'oembed-' . md5(mt_rand() . microtime());
        $oembedURL = PATH_ADMIN_MODULES_WR . '/' . MOD_POLYMOD_CODENAME . '/oembed.php';
        $loadingURL = PATH_ADMIN_IMAGES_WR . '/loading-old.gif';
        $params = $this->getParamsValues();
        $fields = array();
        $fields[] = array('fieldLabel' => '<span class="atm-help" ext:qtip="' . io::htmlspecialchars($language->getMessage(self::MESSAGE_OBJECT_OEMBED_MEDIA_URL_DESC, false, MOD_POLYMOD_CODENAME)) . '">' . $language->getMessage(self::MESSAGE_OBJECT_OEMBED_MEDIA_URL, false, MOD_POLYMOD_CODENAME) . '</span>', 'xtype' => 'textfield', 'name' => 'polymodFieldsValue[' . $prefixName . $this->_field->getID() . '_0]', 'value' => $this->_subfieldValues[0]->getValue() ? sensitiveIO::decodeEntities($this->_subfieldValues[0]->getValue()) : '', 'enableKeyEvents' => true, 'listeners' => array('blur' => array('fn' => sensitiveIO::sanitizeJSString('function(el){
						/*call server for oembed HTML content*/
						Ext.get(\'' . $ids . '-view\').update(\'<img src="' . $loadingURL . '" />\');
						Automne.server.call({
							url:			\'' . $oembedURL . '\',
							scope:			this,
							fcnCallback:	function(response, options, htmlResponse){
								Ext.get(\'' . $ids . '-view\').update(htmlResponse);
							},
							params:			{
								module:			\'' . $moduleCodename . '\',
								url:			el.getValue(),
								width:			600,
								height:			250,
								key:			\'' . $params['embedlyKey'] . '\'
							}
						});
					}', false, false), 'buffer' => 600)));
        $fields[] = array('xtype' => 'panel', 'border' => false, 'html' => '<div id="' . $ids . '-view" style="overflow:auto;text-align:center;">' . ($this->getValue('hasValue') ? $this->getValue('html', '600,250') : '') . '</div>');
        $return = array();
        $return = array('title' => $label, 'xtype' => 'fieldset', 'autoHeight' => true, 'defaultType' => 'textfield', 'defaults' => array('anchor' => '97%', 'allowBlank' => !$this->_field->getValue('required')), 'items' => $fields);
        return $return;
    }
} 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
\t});
\t
\t//create center panel
Ejemplo n.º 5
0
        } else {
            $item->lock($cms_user);
        }
    }
    //check user rights on item
    if (!$item->userHasClearance($cms_user, CLEARANCE_MODULE_EDIT)) {
        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);
Ejemplo n.º 6
0
    if ($polymodule) {
        foreach ($pluginDefinitions as $id => $pluginDefinition) {
            $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,
Ejemplo n.º 7
0
//check for view rights for user
if (!$cms_user->hasPageClearance($cms_page->getID(), CLEARANCE_PAGE_VIEW)) {
    CMS_grandFather::raiseError('Error, user has no rights on page : ' . $cms_page->getID());
    $view->show();
}
$pageId = $cms_page->getID();
$pageTitle = sensitiveIO::sanitizeJSString($cms_page->getTitle(true));
$onClick = base64_encode("\n\tthis.node.select();\n");
//Page templates replacement
$pageTemplate = $cms_page->getTemplate();
//hack if page has no valid template attached
if (!is_a($pageTemplate, "CMS_pageTemplate")) {
    $pageTemplate = new CMS_pageTemplate();
}
$pageTplId = CMS_pageTemplatesCatalog::getTemplateIDForCloneID($pageTemplate->getID());
$pageTplLabel = sensitiveIO::sanitizeJSString($pageTemplate->getLabel());
$jscontent = <<<END
\tvar copyPageWindow = Ext.getCmp('{$winId}');
\t//if we are in a window context
\t
\t//set window title
\tcopyPageWindow.setTitle('{$cms_language->getJsMessage(MESSAGE_PAGE_COPY)} \\'{$pageTitle}\\'');
\t//set help button on top of page
\tcopyPageWindow.tools['help'].show();
\t//add a tooltip on button
\tvar pageTip = new Ext.ToolTip({
\t\ttarget: \t\tcopyPageWindow.tools['help'],
\t\ttitle: \t\t\t'{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP)}',
\t\thtml: \t\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_COPY_INFO)}',
\t\tdismissDelay:\t0
\t});
Ejemplo n.º 8
0
    /**
     * get HTML admin (used to enter object values in admin)
     *
     * @param integer $fieldID, the current field id (only for poly object compatibility)
     * @param CMS_language $language, the current admin language
     * @param string prefixname : the prefix to use for post names
     * @return string : the html admin
     * @access public
     */
    function getHTMLAdmin($fieldID, $language, $prefixName)
    {
        $return = parent::getHTMLAdmin($fieldID, $language, $prefixName);
        global $cms_user;
        $params = $this->getParamsValues();
        $prefixName = isset($inputParams['prefix']) ? $inputParams['prefix'] : '';
        $rootCategory = isset($inputParams['root']) && SensitiveIO::isPositiveInteger($inputParams['root']) ? $inputParams['root'] : false;
        //get module codename
        $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
        if ($params['multiCategories']) {
            // Get categories
            $a_all_categories = $this->getAllCategoriesAsArray($language, false, $moduleCodename, CLEARANCE_MODULE_EDIT, $rootCategory, true);
            $checkedValues = array();
            if (isset($this->_subfieldValues[0]) && is_object($this->_subfieldValues[0]) && !is_null($this->_subfieldValues[0]->getValue()) && $this->_subfieldValues[0]->getID()) {
                foreach (array_keys($this->_subfieldValues) as $subFieldID) {
                    if (is_object($this->_subfieldValues[$subFieldID])) {
                        $checkedValues[$this->_subfieldValues[$subFieldID]->getValue()] = $this->_subfieldValues[$subFieldID]->getValue();
                    }
                }
            } elseif (sensitiveIO::isPositiveInteger($params['defaultValue'])) {
                $checkedValues[$params['defaultValue']] = $params['defaultValue'];
            }
            $valueString = implode(',', $checkedValues);
            if (is_array($a_all_categories) && $a_all_categories) {
                $fathers = array(0 => false);
                foreach ($a_all_categories as $id => $category) {
                    $level = substr_count($category, '-&nbsp;');
                    $father = false;
                    if ($level && isset($fathers[$level - 1])) {
                        $father = $fathers[$level - 1];
                    }
                    $cat = new stdClass();
                    $cat->id = $id;
                    $cat->checked = isset($checkedValues[$id]);
                    $cat->cls = isset($checkedValues[$id]) ? 'x-tree-checked' : '';
                    $cat->level = $level;
                    $cat->text = str_replace('-&nbsp;', '', $category);
                    if (strtolower(APPLICATION_DEFAULT_ENCODING) != 'utf-8') {
                        $cat->text = io::utf8Encode($cat->text);
                    }
                    $cat->leaf = true;
                    $fathers[$level] = $cat;
                    if ($father) {
                        $father->children[] = $cat;
                        $father->leaf = false;
                        $father->expanded = true;
                    } else {
                        $availableCategories[] = $cat;
                    }
                }
            } else {
                $availableCategories[] = array('id' => '', 'text' => $language->getMessage(self::MESSAGE_EMPTY_OBJECTS_SET), 'leaf' => true);
            }
            $fieldId = md5(mt_rand() . microtime());
            $field = array();
            $field['id'] = 'tree-' . $fieldId;
            $field['xtype'] = 'treepanel';
            $field['height'] = io::isPositiveInteger($params['selectHeight']) ? (int) $params['selectHeight'] : 150;
            $field['width'] = io::isPositiveInteger($params['selectWidth']) ? (int) $params['selectWidth'] : '100%';
            $field['autoScroll'] = true;
            $field['animate'] = true;
            $field['containerScroll'] = true;
            $field['rootVisible'] = false;
            $field['root'] = array('expanded' => true, 'children' => $availableCategories);
            $field['listeners'] = array('checkchange' => array('fn' => sensitiveIO::sanitizeJSString('function(node, checked){
						var tree = Ext.getCmp(\'tree-' . $fieldId . '\');
						var input = Ext.getCmp(\'cat-' . $fieldId . '\');
						if (tree && input) {
							input.setValue(tree.getChecked(\'id\').toString());
						}
						if(checked){
		                    node.getUI().addClass(\'x-tree-checked\');
		                }else{
		                    node.getUI().removeClass(\'x-tree-checked\');
		                }
					}', false, false)));
            $return['xtype'] = 'compositefield';
            $return['labelWidth'] = 120;
            $return['items'] = array($field, array('id' => 'cat-' . $fieldId, 'xtype' => 'hidden', 'name' => 'polymodFieldsValue[list' . $prefixName . $this->_field->getID() . '_0]', 'value' => $valueString));
        } else {
            if (isset($this->_subfieldValues[0]) && is_object($this->_subfieldValues[0]) && !is_null($this->_subfieldValues[0]->getValue()) && $this->_subfieldValues[0]->getID()) {
                $selectedValue = $this->_subfieldValues[0]->getValue() ? $this->_subfieldValues[0]->getValue() : '';
            } elseif (sensitiveIO::isPositiveInteger($params['defaultValue'])) {
                $selectedValue = $params['defaultValue'];
            } else {
                $selectedValue = '';
            }
            $return['xtype'] = 'atmCombo';
            $return['name'] = 'polymodFieldsValue[list' . $prefixName . $this->_field->getID() . '_0]';
            $return['hiddenName'] = $return['name'];
            $return['forceSelection'] = true;
            $return['mode'] = 'remote';
            $return['valueField'] = 'id';
            $return['displayField'] = 'label';
            $return['triggerAction'] = 'all';
            $return['allowBlank'] = true;
            $return['selectOnFocus'] = true;
            $return['editable'] = true;
            $return['typeAhead'] = true;
            $return['value'] = $selectedValue;
            $return['store'] = array('url' => PATH_ADMIN_MODULES_WR . '/' . MOD_POLYMOD_CODENAME . '/list-categories.php', 'baseParams' => array('fieldId' => $this->_field->getID(), 'module' => $moduleCodename, 'query' => ''), 'root' => 'objects', 'fields' => array('id', 'label'));
        }
        return $return;
    }
Ejemplo n.º 9
0
}
//load template if any
if (sensitiveIO::isPositiveInteger($templateId)) {
    $template = CMS_pageTemplatesCatalog::getByID($templateId);
    if (!$template || $template->hasError()) {
        CMS_grandFather::raiseError('Unknown template for given Id : ' . $templateId);
        $view->show();
    }
} else {
    //create new user
    $template = new CMS_pageTemplate();
}
//MAIN TAB
//Need to sanitize all datas which can contain single quotes
$label = sensitiveIO::sanitizeJSString($template->getLabel());
$description = sensitiveIO::sanitizeJSString($template->getDescription(), false, true, true);
//this is a textarea, we must keep cariage return
$templateDefinition = $template->getDefinition();
$imageName = $template->getImage();
$templateGroups = $template->getGroups();
$websitesDenied = $template->getWebsitesDenied();
//image
$maxFileSize = CMS_file::getMaxUploadFileSize('K');
if ($imageName && file_exists(PATH_TEMPLATES_IMAGES_FS . '/' . $imageName) && $imageName != 'nopicto.gif') {
    $image = new CMS_file(PATH_TEMPLATES_IMAGES_FS . '/' . $imageName);
    $imageDatas = array('filename' => $image->getName(false), 'filepath' => $image->getFilePath(CMS_file::WEBROOT), 'filesize' => $image->getFileSize(), 'fileicon' => $image->getFileIcon(CMS_file::WEBROOT), 'extension' => $image->getExtension());
} else {
    $imageDatas = array('filename' => '', 'filepath' => '', 'filesize' => '', 'fileicon' => '', 'extension' => '');
}
$imageDatas = sensitiveIO::jsonEncode($imageDatas);
$fileDatas = array('filename' => '', 'filepath' => '', 'filesize' => '', 'fileicon' => '', 'extension' => '');
Ejemplo n.º 10
0
    /**
     * get HTML admin (used to enter object values in admin)
     *
     * @param integer $fieldID, the current field id (only for poly object compatibility)
     * @param CMS_language $language, the current admin language
     * @param string prefixname : the prefix to use for post names
     * @return string : the html admin
     * @access public
     */
    function getHTMLAdmin($fieldID, $language, $prefixName)
    {
        $return = parent::getHTMLAdmin($fieldID, $language, $prefixName);
        $params = $this->getParamsValues();
        $maxFileSize = CMS_file::getMaxUploadFileSize('K');
        //get module codename
        $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
        //Image datas
        if ($this->_subfieldValues[0]->getValue() && file_exists(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[0]->getValue())) {
            $file = new CMS_file(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[0]->getValue());
            $imageDatas = array('filename' => $file->getName(false), 'filepath' => $file->getFilePath(CMS_file::WEBROOT), 'filesize' => $file->getFileSize(), 'fileicon' => $file->getFileIcon(CMS_file::WEBROOT), 'extension' => $file->getExtension());
        } else {
            $imageDatas = array('filename' => '', 'filepath' => '', 'filesize' => '', 'fileicon' => '', 'extension' => '');
        }
        //move title from offset 1 to offset 0
        $titleField = $return['items'][1];
        $return['items'][1] = $return['items'][0];
        $return['items'][0] = $titleField;
        //Title
        unset($return['items'][0]['hideLabel']);
        if (isset($params['legendMandatory']) && $params['legendMandatory']) {
            $return['items'][0]['fieldLabel'] = '<span class="atm-red">*</span> ' . $language->getMessage(self::MESSAGE_OBJECT_IMAGE_FIELD_LABEL, false, MOD_POLYMOD_CODENAME);
        } else {
            $return['items'][0]['fieldLabel'] = $language->getMessage(self::MESSAGE_OBJECT_IMAGE_FIELD_LABEL, false, MOD_POLYMOD_CODENAME);
        }
        $return['items'][0]['allowBlank'] = $this->_field->getValue('required') && isset($params['legendMandatory']) && $params['legendMandatory'] ? false : true;
        //Thumbnail
        unset($return['items'][1]['hideLabel']);
        $return['items'][1]['xtype'] = 'atmImageUploadField';
        $return['items'][1]['emptyText'] = $language->getMessage(self::MESSAGE_SELECT_PICTURE);
        $return['items'][1]['fieldLabel'] = $language->getMessage(self::MESSAGE_OBJECT_IMAGE_FIELD_THUMBNAIL, false, MOD_POLYMOD_CODENAME);
        if (!$params['makeZoom']) {
            if ($params['maxWidth']) {
                $return['items'][1]['maxWidth'] = $params['maxWidth'];
            }
            if ($params['maxHeight']) {
                $return['items'][1]['maxHeight'] = $params['maxHeight'];
            }
        }
        $return['items'][1]['uploadCfg'] = array('file_size_limit' => $maxFileSize, 'file_types' => '*.jpg;*.jpeg;*.png;*.gif', 'file_types_description' => $language->getMessage(self::MESSAGE_OBJECT_IMAGE_FIELD_THUMBNAIL, false, MOD_POLYMOD_CODENAME) . ' ...');
        $return['items'][1]['fileinfos'] = $imageDatas;
        $return['items'][1]['fileinfos']['module'] = $moduleCodename;
        $return['items'][1]['fileinfos']['visualisation'] = RESOURCE_DATA_LOCATION_EDITED;
        $checkBoxId = 'check' . md5(mt_rand() . microtime());
        //Image datas
        if ($params['useDistinctZoom'] || $params['makeZoom']) {
            $zoomId = 'zoom' . md5(mt_rand() . microtime());
            if ($this->_subfieldValues[2]->getValue() && file_exists(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[2]->getValue())) {
                $file = new CMS_file(PATH_MODULES_FILES_FS . '/' . $moduleCodename . '/' . RESOURCE_DATA_LOCATION_EDITED . '/' . $this->_subfieldValues[2]->getValue());
                $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' => '');
            }
            unset($return['items'][2]['hideLabel']);
            $return['items'][2]['id'] = $zoomId;
            $return['items'][2]['allowBlank'] = true;
            $return['items'][2]['xtype'] = 'atmImageUploadField';
            $return['items'][2]['emptyText'] = $language->getMessage(self::MESSAGE_SELECT_PICTURE);
            $return['items'][2]['fieldLabel'] = $language->getMessage(self::MESSAGE_OBJECT_IMAGE_FIELD_ZOOM, false, MOD_POLYMOD_CODENAME);
            $return['items'][2]['uploadCfg'] = array('file_size_limit' => $maxFileSize, 'file_types' => '*.jpg;*.jpeg;*.png;*.gif', 'file_types_description' => $language->getMessage(self::MESSAGE_OBJECT_IMAGE_FIELD_THUMBNAIL, false, MOD_POLYMOD_CODENAME) . ' ...');
            $return['items'][2]['fileinfos'] = $zoomDatas;
            $return['items'][2]['fileinfos']['module'] = $moduleCodename;
            $return['items'][2]['fileinfos']['visualisation'] = RESOURCE_DATA_LOCATION_EDITED;
            if ($params['maxZoomWidth']) {
                $return['items'][2]['maxWidth'] = $params['maxZoomWidth'];
            }
            if ($params['maxZoomHeight']) {
                $return['items'][2]['maxHeight'] = $params['maxZoomHeight'];
            }
            if (!$this->_subfieldValues[2]->getValue() && $params['makeZoom']) {
                $return['items'][2]['listeners'] = array('render' => sensitiveIO::sanitizeJSString('function(el){
					var fieldCt = el.label.parent();
					if (fieldCt) {
						fieldCt.setVisibilityMode(Ext.Element.DISPLAY);
						fieldCt.hide();
					}
				}', false, false));
            }
        } else {
            $return['items'][2]['xtype'] = 'hidden';
        }
        if ($params['makeZoom']) {
            $boxLabel = $language->getMessage(self::MESSAGE_OBJECT_IMAGE_FIELD_USE_ORIGINAL_AS_ZOOM, false, MOD_POLYMOD_CODENAME);
            if ($params['maxWidth'] > 0 && !$params['maxHeight']) {
                $boxLabel .= '&nbsp;<small>' . $language->getMessage(self::MESSAGE_OBJECT_IMAGE_FIELD_DESC, array($params['maxWidth']), MOD_POLYMOD_CODENAME) . '</small>';
            } elseif ($params['maxHeight'] && !$params['maxWidth']) {
                $boxLabel .= '&nbsp;<small>' . $language->getMessage(self::MESSAGE_OBJECT_IMAGE_FIELD_DESC_HEIGHT, array($params['maxHeight']), MOD_POLYMOD_CODENAME) . '</small>';
            } elseif ($params['maxWidth'] && $params['maxHeight']) {
                $boxLabel .= '&nbsp;<small>' . $language->getMessage(self::MESSAGE_OBJECT_IMAGE_FIELD_DESC_HEIGHT_AND_WIDTH, array($params['maxWidth'], $params['maxHeight']), MOD_POLYMOD_CODENAME) . '</small>';
            }
            $checkField = array('allowBlank' => true, 'xtype' => 'checkbox', 'id' => $checkBoxId, 'checked' => !$params['useDistinctZoom'] && !$this->_subfieldValues[2]->getValue(), 'inputValue' => 1, 'name' => 'polymodFieldsValue[' . $prefixName . $this->_field->getID() . '_makeZoom]', 'boxLabel' => $boxLabel, 'height' => 'auto', 'labelSeparator' => '');
            if (isset($zoomId)) {
                $checkField['listeners'] = array('check' => sensitiveIO::sanitizeJSString('function(el, checked){
					var fieldCt = Ext.getCmp(\'' . $zoomId . '\').label.parent();
					if (fieldCt) {
						fieldCt.setVisibilityMode(Ext.Element.DISPLAY);
						if (checked) {
							fieldCt.hide(true);
						} else {
							fieldCt.show(true);
							Ext.getCmp(\'' . $zoomId . '\').syncSize();
						}
					}
				}', false, false));
            }
            //set checkbox to offset 2
            $return['items'][3] = $return['items'][2];
            $return['items'][2] = $checkField;
        }
        //reset key numbers
        $return['items'] = array_values($return['items']);
        return $return;
    }
Ejemplo n.º 11
0
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'&nbsp;',\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
$searchPanel .= "{\n\txtype:\t\t\t'panel',\n\tborder:\t\t\tfalse,\n\thtml:\t\t\t'<div style=\"color:grey;padding-top:15px;font-size:x-small;\">{$cms_language->getJSMessage(MESSAGE_PAGE_HELP_MULTIPLE, false, MOD_POLYMOD_CODENAME)}</div>'\n},";
//remove last comma from search panel items
$searchPanel = io::substr($searchPanel, 0, -1);
$jscontent = <<<END
\tvar moduleObjectWindow = Ext.getCmp('{$winId}');
\tvar fatherWindow = Ext.getCmp('{$fatherId}');
\t
\t//define update function into window (to be accessible by parent window)
\tmoduleObjectWindow.updateTab = function() {
\t\t//reload all already loaded combos in search form
\t\tvar combos = searchPanel.findByType('atmCombo');
\t\tvar combosLen = combos.length;
Ejemplo n.º 12
0
}
//load module
$module = CMS_modulesCatalog::getByCodename($codename);
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)}',
Ejemplo n.º 13
0
$groupsTab = $modulesTab = $adminTab = $logsTab = '';
//Get modules and remove standard (which is already treated in this file)
$modules = CMS_modulesCatalog::getAll();
unset($modules[MOD_STANDARD_CODENAME]);
//OTHERS TABS
if ($cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDITUSERS)) {
    $groupsDisabled = '';
    if ($user->getUserId() == ROOT_PROFILEUSER_ID) {
        $groupsDisabled = "disabled:\t\t\ttrue,tabTip:'{$cms_language->getJSMessage(MESSAGE_PAGE_ADMIN_NO_GROUPS)}',";
    }
    //GROUPS TAB
    $groupsTab = ",{\n\t\t\tid:\t\t\t\t\t'userGroups-{$userId}',\n\t\t\ttitle:\t\t\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_GROUPS)}',\n\t\t\txtype:\t\t\t\t'grid',\n\t\t\tstore: \t\t\t\tstore,\n\t\t\t{$groupsDisabled}\n\t\t\tborder:\t\t\t\tfalse,\n\t\t\tautoExpandColumn:\t'description',\n\t\t\tcm: \t\t\t\tnew Ext.grid.ColumnModel([\n\t\t\t\tsm,\n\t\t\t\t{header: \"ID\", \t\t\t\t\t\t\t\t\t\t\t\twidth: 30, \tdataIndex: 'id', \t\t\tsortable: true, \thidden:true},\n\t\t\t\t{header: \"{$cms_language->getMessage(MESSAGE_PAGE_LABEL)}\", \twidth: 50, \tdataIndex: 'label', \t\tsortable: true,\t\t\t\t\t\trenderer:renderGroups},\n\t\t\t\t{header: \"{$cms_language->getMessage(MESSAGE_PAGE_DESC)}\", \twidth: 170, dataIndex: 'description',\tsortable: true, \t\t\t\t\trenderer:function(value) {return '<span ext:qtip=\"'+value+'\">'+value+'</span>';}}\n\t\t\t]),\n\t\t\tsm: \t\t\t\tsm,\n\t\t\tanchor:\t\t\t\t'100%',\n\t\t\tviewConfig: \t\t{\n\t\t\t\tforceFit:\t\t\ttrue\n\t\t\t},\n\t\t\ttbar:[{\n\t\t\t\txtype: \t\t\t'textfield',\n\t\t\t\temptyText:\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_SEARCH)} ...',\n\t\t\t\tid: \t\t\t'search-{$userId}',\n\t\t\t\tselectOnFocus: \ttrue,\n\t\t\t\twidth:\t\t\t300,\n\t\t\t\tlisteners: \t\t{\n\t\t\t\t\t'render': {fn:function(){\n\t\t\t\t\t\tExt.getCmp('search-{$userId}').getEl().on('keyup', filter, this, {buffer:500});\n\t\t\t\t\t}, scope:userWindow}\n\t\t\t\t}\n\t\t\t},'-',{\n\t\t\t\txtype:\t\t\t'checkbox',\n\t\t\t\tboxLabel:\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_ALL_GROUPS)}',\n\t\t\t\tlisteners:\t\t{'check': function(item, checked) {\n\t\t\t\t\tif (checked) {\n\t\t\t\t\t\tfilterUsersGroups = false;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tfilterUsersGroups = true;\n\t\t\t\t\t}\n\t\t\t\t\tfilter();\n\t\t\t\t}}\n\t\t\t}],\n\t\t\tbbar:\t\t\t\tnew Ext.PagingToolbar({\n\t\t\t\tpageSize: \t\t\t{$recordsPerPage},\n\t\t\t\tstore: \t\t\t\tstore,\n\t\t\t\tdisplayInfo: \t\ttrue,\n\t\t\t\tdisplayMsg: \t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_GROUP_X_ON)}',\n\t\t\t\temptyMsg: \t\t\t\"{$cms_language->getJsMessage(MESSAGE_PAGE_NO_SEARCHED_GROUP)}\"\n\t\t\t})\n\t\t}";
    //Modules tabs
    $modulesTab = ",{\n\t\t\tid:\t\t\t\t\t'userPages-{$userId}',\n\t\t\ttitle:\t\t\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_PAGE)}',\n\t\t\tborder:\t\t\t\tfalse,\n\t\t\txtype:\t\t\t\t'atmPanel',\n\t\t\tautoScroll:\t\t\ttrue,\n\t\t\tautoLoad:\t\t{\n\t\t\t\turl:\t\t'user-modules-rights.php',\n\t\t\t\tparams:\t\t\t{\n\t\t\t\t\tfatherId:\t\tuserWindow.id,\n\t\t\t\t\twinId:\t\t\t'userPages-{$userId}',\n\t\t\t\t\tuserId:\t\t\tuserWindow.userId\n\t\t\t\t},\n\t\t\t\tnocache:\ttrue\n\t\t\t}\n\t\t}";
    foreach ($modules as $codename => $module) {
        $label = sensitiveIO::sanitizeJSString($module->getLabel($cms_language));
        if ($label) {
            $modulesTab .= ",{\n\t\t\t\tid:\t\t\t\t\t'user-{$codename}-{$userId}',\n\t\t\t\ttitle:\t\t\t\t'{$label}',\n\t\t\t\tborder:\t\t\t\tfalse,\n\t\t\t\txtype:\t\t\t\t'atmPanel',\n\t\t\t\tautoScroll:\t\t\ttrue,\n\t\t\t\tautoLoad:\t\t{\n\t\t\t\t\turl:\t\t'user-modules-rights.php',\n\t\t\t\t\tparams:\t\t\t{\n\t\t\t\t\t\tfatherId:\t\tuserWindow.id,\n\t\t\t\t\t\tmodule:\t\t\t'{$codename}',\n\t\t\t\t\t\twinId:\t\t\t'user-{$codename}-{$userId}',\n\t\t\t\t\t\tuserId:\t\t\tuserWindow.userId\n\t\t\t\t\t},\n\t\t\t\t\tnocache:\ttrue\n\t\t\t\t}\n\t\t\t}";
        }
    }
    //ADMIN TAB
    $adminTab = ",{\n\t\t\tid:\t\t\t\t'userAdmin-{$userId}',\n\t\t\ttitle:\t\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_ADMINISTRATION)}',\n\t\t\tborder:\t\t\tfalse,\n\t\t\txtype:\t\t\t'atmPanel',\n\t\t\tautoScroll:\t\ttrue,\n\t\t\tautoLoad:\t\t{\n\t\t\t\turl:\t\t'user-admin-rights.php',\n\t\t\t\tparams:\t\t\t{\n\t\t\t\t\twinId:\t\t\t'userAdmin-{$userId}',\n\t\t\t\t\tuserId:\t\t\tuserWindow.userId\n\t\t\t\t},\n\t\t\t\tnocache:\ttrue\n\t\t\t}\n\t\t}";
    //LOGS TAB
    $logsTab = ", {\n\t\t\tid:\t\t\t\t'userLogs-{$userId}',\n\t\t\ttitle:\t\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_LOG_LABEL)}',\n\t\t\tborder:\t\t\tfalse,\n\t\t\txtype:\t\t\t'atmPanel',\n\t\t\tlayout:\t\t\t'fit',\n\t\t\tautoScroll:\t\ttrue,\n\t\t\tautoLoad:\t\t{\n\t\t\t\turl:\t\t\t'user-logs.php',\n\t\t\t\tparams:\t\t\t{\n\t\t\t\t\twinId:\t\t\t'userLogs-{$userId}',\n\t\t\t\t\tuser:\t\t\t'{$userId}',\n\t\t\t\t\taction:\t\t\t'view'\n\t\t\t\t},\n\t\t\t\tnocache:\t\ttrue,\n\t\t\t\tscope:\t\t\tthis\n\t\t\t}\n           }";
}
//create dynamic vars
// Local passwords (root password is allowed only for root, and disabled for anonymous user)
if ($user->getUserId() != ANONYMOUS_PROFILEUSER_ID && ($user->getUserId() != ROOT_PROFILEUSER_ID || $user->getUserId() == ROOT_PROFILEUSER_ID && $cms_user->getUserId() == ROOT_PROFILEUSER_ID)) {
    $authentificationField = "{\n\t\tlayout:\t\t\t'column',\n\t\txtype:\t\t\t'panel',\n\t\tborder:\t\t\tfalse,\n\t\titems:[{\n\t\t\tcolumnWidth:\t.5,\n\t\t\tlayout: \t\t'form',\n\t\t\tborder:\t\t\tfalse,\n\t\t\titems: [{\n\t\t\t\tfieldLabel:\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_PASSWORD)}',\n\t\t\t\txtype:\t\t\t'textfield',\n\t\t\t\tname:\t\t\t'pass1',\n\t\t\t\tinputType:\t\t'password',\n\t\t\t\tanchor:\t\t\t'98%',\n\t\t\t\tallowBlank:\t\ttrue\n\t\t\t}]\n\t\t},{\n\t\t\tcolumnWidth:\t.5,\n\t\t\tlayout: \t\t'form',\n\t\t\tborder:\t\t\tfalse,\n\t\t\titems: [{\n\t\t\t\tfieldLabel:\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_CONFIRM)}',\n\t\t\t\txtype:\t\t\t'textfield',\n\t\t\t\tname:\t\t\t'pass2',\n\t\t\t\tinputType:\t\t'password',\n\t\t\t\tanchor:\t\t\t'100%',\n\t\t\t\tallowBlank:\t\ttrue,\n\t\t\t\tvalidator:\t\tvalidatePass\n\t\t\t}]\n\t\t}]\n\t},";
    if (!$user->havePassword() && $user->getUserId()) {
        $authentificationField .= "{\n\t\t\tbodyStyle:\t\t'padding:0 0 10px 105px',\n\t\t\txtype:\t\t\t'panel',\n\t\t\thtml:\t\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_NO_PASSWORD)}',\n\t\t\tborder:\t\t\tfalse\n\t\t},";
    /**
     * get HTML admin (used to enter object values in admin)
     *
     * @param integer $fieldID, the current field id (only for poly object compatibility)
     * @param CMS_language $language, the current admin language
     * @param string prefixname : the prefix to use for post names
     * @return string : the html admin
     * @access public
     */
    function getHTMLAdmin($fieldID, $language, $prefixName)
    {
        $return = parent::getHTMLAdmin($fieldID, $language, $prefixName);
        $params = $this->getParamsValues();
        unset($return['items'][0]['hideLabel']);
        unset($return['items'][1]['hideLabel']);
        $return['items'][0]['fieldLabel'] = $language->getMessage(self::MESSAGE_OBJECT_COORDINATES_LONGITUDE_DESCRIPTION, false, $this->_messagesModule);
        $return['items'][1]['fieldLabel'] = $language->getMessage(self::MESSAGE_OBJECT_COORDINATES_LATITUDE_DESCRIPTION, false, $this->_messagesModule);
        $ids = 'coord-' . md5(mt_rand() . microtime());
        $return['items'][0]['id'] = $ids . '-long';
        $return['items'][1]['id'] = $ids . '-lat';
        //Move the first two fields
        $return['items'][2] = $return['items'][1];
        $return['items'][1] = $return['items'][0];
        //Add on change listeners to update image
        $return['items'][1]['listeners'] = $return['items'][2]['listeners'] = array('change' => sensitiveIO::sanitizeJSString('function(el){
			Ext.get(\'' . $ids . '-view\').update(\'<img style="border:1px solid #C0C7CB;" src="http://maps.google.com/maps/api/staticmap?center=\'+Ext.getCmp(\'' . $ids . '-lat\').getValue()+\',\'+Ext.getCmp(\'' . $ids . '-long\').getValue()+\'&zoom=15&size=600x200&markers=\'+Ext.getCmp(\'' . $ids . '-lat\').getValue()+\',\'+Ext.getCmp(\'' . $ids . '-long\').getValue()+\'&sensor=false" />\');
		}', false, false));
        //Create toolbar
        $return['items'][0] = array('xtype' => 'toolbar', 'items' => array());
        if ($params['useFieldsAsAddress']) {
            $return['items'][0]['items'][] = array('xtype' => 'button', 'text' => $language->getMessage(self::MESSAGE_OBJECT_COORDINATES_FIELD_UPDATE_FROM_ADDRESS, false, $this->_messagesModule), 'handler' => sensitiveIO::sanitizeJSString('function(button){
					var addrFields = \'' . $params['fieldsForAddress'] . '\'.split(\';\');
					var form = button.findParentByType(\'atmForm\').form;
					var addr = \'\';
					for(var i = 0; i < addrFields.length; i++) {
						var field = form.findField(\'polymodFieldsValue[\' + addrFields[i] + \'_0]\');
						var listfield = form.findField(\'polymodFieldsValue[list\' + addrFields[i] + \'_0]\');
						if (field) {
							addr += \' \' + Ext.util.Format.stripTags(field.getValue());
						} else if (listfield) {
							addr += \' \' + Ext.util.Format.stripTags(listfield.lastSelectionText);
						}
					}
					addr = Ext.util.Format.stripLines(addr);
					var geocoder = new google.maps.Geocoder();
					geocoder.geocode({address:addr}, function(results, status) {
						if (status == \'OK\') {
							Ext.getCmp(\'' . $ids . '-long\').setValue(results[0].geometry.location.lng());
							Ext.getCmp(\'' . $ids . '-lat\').setValue(results[0].geometry.location.lat());
							Ext.get(\'' . $ids . '-view\').update(\'<img style="border:1px solid #C0C7CB;" src="http://maps.google.com/maps/api/staticmap?center=\'+results[0].geometry.location.lat()+\',\'+results[0].geometry.location.lng()+\'&zoom=15&size=600x200&markers=\'+results[0].geometry.location.lat()+\',\'+results[0].geometry.location.lng()+\'&sensor=false" />\');
						} else {
							Automne.message.popup({
								msg: 				String.format(\'' . $language->getJsMessage(self::MESSAGE_OBJECT_COORDINATES_FIELD_UNKOWN_ADDRESS, false, $this->_messagesModule) . '\', addr),
								buttons: 			Ext.MessageBox.OK,
								closable: 			false,
								icon: 				Ext.MessageBox.ERROR
							});
						}
					});
				}', false, false), 'scope' => 'this');
        }
        $return['items'][0]['items'][] = '->';
        $return['items'][0]['items'][] = array('xtype' => 'button', 'text' => $language->getMessage(self::MESSAGE_OBJECT_COORDINATES_FIELD_PUT_ON_MAP, false, $this->_messagesModule), 'handler' => sensitiveIO::sanitizeJSString('function(button){
				var lat = Ext.getCmp(\'' . $ids . '-lat\').getValue();
				var long = Ext.getCmp(\'' . $ids . '-long\').getValue();
				if (lat && long) {
					var mapwin = new Automne.Window({
		                layout: \'fit\',
		                title: \'' . $language->getJSMessage(self::MESSAGE_OBJECT_COORDINATES_FIELD_MAP_WINDOW, false, $this->_messagesModule) . '\',
		                modal:true,
						width:600,
		                height:600,
		                items: {
		                    xtype: \'gmappanel\',
		                    zoomLevel: 13,
		                    gmapType: \'map\',
		                    id: \'map-' . $ids . '\',
		                    mapConfOpts: [\'enableScrollWheelZoom\',\'enableDoubleClickZoom\',\'enableDragging\'],
		                    mapControls: [\'GSmallMapControl\',\'GMapTypeControl\',\'NonExistantControl\'],
							setCenter: {
		                        lat: lat,
								lng: long,
								marker: {draggable: true}
		                    }
		                },
						listeners:{\'beforeclose\':function(window){
							var map = Ext.getCmp(\'map-' . $ids . '\');
							if (map.gmarks && map.gmarks[0]) {
								Ext.getCmp(\'' . $ids . '-long\').setValue(map.gmarks[0].getPosition().lng());
								Ext.getCmp(\'' . $ids . '-lat\').setValue(map.gmarks[0].getPosition().lat());
								Ext.get(\'' . $ids . '-view\').update(\'<img style="border:1px solid #C0C7CB;" src="http://maps.google.com/maps/api/staticmap?center=\'+map.gmarks[0].getPosition().lat()+\',\'+map.gmarks[0].getPosition().lng()+\'&zoom=15&size=600x200&markers=\'+map.gmarks[0].getPosition().lat()+\',\'+map.gmarks[0].getPosition().lng()+\'&sensor=false" />\');
							}
						}}
		            });
					mapwin.show(button);
				} else {
					var gmapWindow = function(button, value) {
					   	if (button == \'ok\') {
							var mapwin = new Automne.Window({
				                layout: \'fit\',
				                title: \'' . $language->getJSMessage(self::MESSAGE_OBJECT_COORDINATES_FIELD_MAP_WINDOW, false, $this->_messagesModule) . '\',
				                modal:true,
								width:600,
				                height:600,
				                items: {
				                    xtype: \'gmappanel\',
				                    zoomLevel: 13,
				                    gmapType: \'map\',
				                    id: \'map-' . $ids . '\',
				                    mapConfOpts: [\'enableScrollWheelZoom\',\'enableDoubleClickZoom\',\'enableDragging\'],
				                    mapControls: [\'GSmallMapControl\',\'GMapTypeControl\',\'NonExistantControl\'],
									setCenter: {
				                        geoCodeAddr: value,
										marker: {draggable: true}
				                    }
				                },
								listeners:{\'beforeclose\':function(window){
									var map = Ext.getCmp(\'map-' . $ids . '\');
									if (map.gmarks && map.gmarks[0]) {
										Ext.getCmp(\'' . $ids . '-long\').setValue(map.gmarks[0].getPosition().lng());
										Ext.getCmp(\'' . $ids . '-lat\').setValue(map.gmarks[0].getPosition().lat());
										Ext.get(\'' . $ids . '-view\').update(\'<img style="border:1px solid #C0C7CB;" src="http://maps.google.com/maps/api/staticmap?center=\'+map.gmarks[0].getPosition().lat()+\',\'+map.gmarks[0].getPosition().lng()+\'&zoom=15&size=600x200&markers=\'+map.gmarks[0].getPosition().lat()+\',\'+map.gmarks[0].getPosition().lng()+\'&sensor=false" />\');
									}
								}}
				          	});
							mapwin.show();
						}
					};
					Ext.MessageBox.prompt(\'' . $language->getJSMessage(self::MESSAGE_OBJECT_COORDINATES_FIELD_ADDRESS, false, $this->_messagesModule) . '\', \'' . $language->getJSMessage(self::MESSAGE_OBJECT_COORDINATES_FIELD_ENTER_ADDRESS, false, $this->_messagesModule) . '\', gmapWindow);
				}
			}', false, false), 'listeners' => array('render' => sensitiveIO::sanitizeJSString('function(){
				if (typeof google == \'undefined\' || typeof google.maps == \'undefined\' || typeof google.maps.Map == \'undefined\') {
					var script = document.createElement("script");
				    script.type = "text/javascript";
				    script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=isNaN";
				    document.body.appendChild(script);
				}
			}', false, false)), 'scope' => 'this');
        $return['items'][3] = array('xtype' => 'panel', 'border' => false, 'html' => '<div id="' . $ids . '-view" style="overflow:auto;text-align:center;">' . ($this->_subfieldValues[0]->getValue() && $this->_subfieldValues[1]->getValue() ? '<img style="border:1px solid #C0C7CB;" src="http://maps.google.com/maps/api/staticmap?center=' . $this->_subfieldValues[1]->getValue() . ',' . $this->_subfieldValues[0]->getValue() . '&zoom=15&size=600x200&markers=' . $this->_subfieldValues[1]->getValue() . ',' . $this->_subfieldValues[0]->getValue() . '&sensor=false" />' : '') . '</div>');
        return $return;
    }
Ejemplo n.º 15
0
        $codemirrorConf = '
			mode: "text/javascript",
		';
        $title = sensitiveIO::sanitizeJSString($fileCreation ? $cms_language->getMessage(MESSAGE_PAGE_CREATE_JS) : $cms_language->getMessage(MESSAGE_PAGE_EDIT_JS) . ' ' . $node);
        break;
    case 'xml':
        $codemirrorConf = '
			mode: "text/html",
		';
        $title = sensitiveIO::sanitizeJSString($cms_language->getMessage(MESSAGE_PAGE_EDIT_WYSIWYG) . ' ' . $node);
        break;
    default:
        $codemirrorConf = '
			mode: "text/html",
		';
        $title = sensitiveIO::sanitizeJSString($cms_language->getMessage(MESSAGE_PAGE_CREATE_FILE));
        break;
}
$automnePath = PATH_MAIN_WR;
$colorcoding = '';
if ($codemirrorConf) {
    $colorcoding = "{\n\t\txtype:\t\t\t'checkbox',\n\t\tboxLabel:\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_SYNTAX_COLOR)}',\n\t\thideLabel:\t\ttrue,\n\t\tlisteners:\t\t{'check':function(field, checked) {\n\t\t\tif (checked) {\n\t\t\t\tvar textarea = Ext.get('defText-{$fileId}');\n\t\t\t\tvar width = textarea.getWidth();\n\t\t\t\tvar height = textarea.getHeight();\n\t\t\t\tvar foldFunc = CodeMirror.newFoldFunction(CodeMirror.braceRangeFinder);\n\t\t\t\teditor = CodeMirror.fromTextArea(document.getElementById('defText-{$fileId}'), {\n\t\t\t        lineNumbers: true,\n\t\t\t        matchBrackets: true,\n\t\t\t        {$codemirrorConf}\n\t\t\t\t\tindentWithTabs: true,\n\t\t\t        enterMode: \"keep\",\n\t\t\t        tabMode: \"shift\",\n\t\t\t\t\ttabSize: 2,\n\t\t\t\t\tonGutterClick: foldFunc,\n\t\t\t\t\textraKeys: {\n\t\t\t\t\t\t\"Ctrl-Q\": function(cm){\n\t\t\t\t\t\t\tfoldFunc(cm, cm.getCursor().line);\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"Ctrl-S\": function() {\n\t\t\t\t\t\t\tExt.getCmp('save-{$fileId}').handler();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t    });\n\t\t\t\tExt.select('.CodeMirror-scroll').setHeight((height - 6));\n\t\t\t\tExt.select('.CodeMirror-scroll').setWidth(width);\n\t\t\t\t\n\t\t\t\tfield.disable();\n\t\t\t\tExt.getCmp('reindent-{$fileId}').show();\n\t\t\t}\n\t\t}, scope:this}\n\t},";
}
$jscontent = <<<END
\tvar fileWindow = Ext.getCmp('{$winId}');
\tfileWindow.fileId = '{$fileId}';
\t//set window title
\tfileWindow.setTitle('{$title}');
\t//set help button on top of page
\tfileWindow.tools['help'].show();
\t//add a tooltip on button
Ejemplo n.º 16
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;
     }
 }
Ejemplo n.º 17
0
    /**
     * get HTML admin (used to enter object values in admin)
     *
     * @param CMS_language $language, the current admin language
     * @param string prefixname : the prefix to use for post names
     * @return string : the html admin
     * @access public
     */
    function getHTMLAdmin($fieldID, $language, $prefixName)
    {
        global $cms_user;
        $params = $this->getParamsValues();
        //is this field mandatory ?
        $mandatory = $this->_field->getValue('required') ? '<span class="atm-red">*</span> ' : '';
        $desc = $this->getFieldDescription($language);
        if (POLYMOD_DEBUG) {
            $values = array();
            foreach (array_keys($this->_subfieldValues) as $subFieldID) {
                if (is_object($this->_subfieldValues[$subFieldID])) {
                    $values[$subFieldID] = sensitiveIO::ellipsis(strip_tags($this->_subfieldValues[$subFieldID]->getValue()), 50);
                }
            }
            $desc .= $desc ? '<br />' : '';
            $desc .= '<span class="atm-red">Field : ' . $fieldID . ' - Value(s) : <ul>';
            foreach ($values as $subFieldID => $value) {
                $desc .= '<li>' . $subFieldID . '&nbsp;:&nbsp;' . $value . '</li>';
            }
            $desc .= '</ul></span>';
        }
        $label = $desc ? '<span class="atm-help" ext:qtip="' . io::htmlspecialchars($desc) . '">' . $mandatory . $this->getFieldLabel($language) . '</span>' : $mandatory . $this->getFieldLabel($language);
        $listId = 'list' . md5(mt_rand() . microtime());
        $listId2 = 'list' . md5(mt_rand() . microtime());
        if ($params['editable']) {
            //get object definition
            $objectDef = $this->getObjectDefinition();
            $associatedItems = array();
            foreach (array_keys($this->_subfieldValues) as $subFieldID) {
                if (is_object($this->_subfieldValues[$subFieldID])) {
                    $associatedItems[$this->_subfieldValues[$subFieldID]->getValue()] = $this->_subfieldValues[$subFieldID]->getValue();
                }
            }
            $items = array();
            $editURL = PATH_ADMIN_MODULES_WR . '/' . MOD_POLYMOD_CODENAME . '/item.php';
            $associateURL = PATH_ADMIN_MODULES_WR . '/' . MOD_POLYMOD_CODENAME . '/associate-items.php';
            $searchURL = PATH_ADMIN_MODULES_WR . '/' . MOD_POLYMOD_CODENAME . '/search.php';
            $moduleCodename = CMS_poly_object_catalog::getModuleCodenameForField($this->_field->getID());
            if (!$cms_user->hasModuleClearance($moduleCodename, CLEARANCE_MODULE_EDIT)) {
                define("MESSAGE_ERROR_MODULE_RIGHTS", 570);
                $module = CMS_modulesCatalog::getByCodename($moduleCodename);
                $items[] = array('width' => '100%', 'layout' => 'fit', 'border' => false, 'bodyStyle' => 'margin:5px 0 3px 0', 'html' => $language->getMessage(MESSAGE_ERROR_MODULE_RIGHTS, array($module->getLabel($language))));
            } else {
                $items[] = array('width' => '100%', 'layout' => 'fit', 'border' => false, 'bodyStyle' => 'margin:5px 0 3px 0', 'html' => $language->getMessage(self::MESSAGE_MULTI_OBJECT_LIST_ZONE, array($objectDef->getObjectLabel($language)), MOD_POLYMOD_CODENAME));
                $items[] = array('xtype' => "multiselect2", 'hideLabel' => true, 'id' => $listId2, 'name' => 'polymodFieldsValue[list' . $prefixName . $this->_field->getID() . '_0]', 'allowBlank' => !$this->_field->getValue('required'), 'valueField' => 'id', 'displayField' => 'label', 'tpl' => sensitiveIO::sanitizeJSString('<tpl for="rows">
						<dl>
							<tpl for="parent.columns">
								<dt style="width:100%;text-align:{align};white-space:normal;" class="MultiselectDD">
									<div unselectable="on" class="atm-result x-unselectable" id="object-{parent.id}">
										<div class="atm-title">
											<table>
												<tr>
													<td class="atm-label" ext:qtip="ID: {parent.id}">{parent.status}&nbsp;{parent.label}</td>
													<td class="atm-pubrange">{parent.pubrange}</td>
													<td class="atm-drag">&nbsp;</td>
												</tr>
											</table>
										</div>
										<div class="atm-description">{parent.description}<div style="clear:both;height:1px;">&nbsp;</div></div>
									</div>
								</dt>
							</tpl>
							<div class="x-clear"></div>
						</dl>
	                </tpl>'), 'store' => array('xtype' => 'atmJsonstore', 'root' => 'results', 'totalProperty' => 'total', 'url' => $searchURL, 'id' => 'id', 'remoteSort' => true, 'baseParams' => array('module' => $moduleCodename, 'objectId' => $this->_objectID), 'fields' => array('id', 'status', 'pubrange', 'label', 'description', 'locked', 'deleted', 'previz', 'edit')), 'value' => implode(',', $associatedItems), 'width' => 'auto', 'height' => 'auto', 'cls' => 'x-list-body', 'tbar' => array(!$params['doNotUseExternalSubObjects'] ? array('text' => $language->getMessage(self::MESSAGE_PAGE_ACTION_ASSOCIATE), 'tooltip' => $language->getMessage(self::MESSAGE_MULTI_OBJECT_CHOOSE_ELEMENT, array($objectDef->getObjectLabel($language)), MOD_POLYMOD_CODENAME), 'handler' => sensitiveIO::sanitizeJSString('function(button){
								var windowId = \'module' . $moduleCodename . 'AssociateWindow\';
								/*create window element*/
								var window = new Automne.Window({
									id:				windowId,
									objectId:		\'\',
									autoLoad:		{
										url:			\'' . $associateURL . '\',
										params:			{
											winId:			windowId,
											module:			\'' . $moduleCodename . '\',
											type:			\'' . $this->_objectID . '\'
										},
										nocache:		true,
										scope:			this
									},
									modal:			true,
									width:			750,
									height:			580,
									animateTarget:	button,
									listeners:{\'close\':function(window){
										var cmp = Ext.getCmp(\'' . $listId2 . '\');
										if (window.selectedItems && window.selectedItems.split) {
											var values = cmp.getRawValue();
											var items = window.selectedItems.split(\',\');
											for (var i = 0, itemsLen = items.length; i < itemsLen; i++) {
												if (values.indexOf(items[i]) === -1) {
													values.unshift(items[i]);
												}
											}
											cmp.setValue(values.join(cmp.delimiter));
										}
									}}
								});
								/*display window*/
								window.show(button.getEl());
							}', false, false), 'scope' => 'this') : '', array('text' => $language->getMessage(self::MESSAGE_PAGE_ACTION_DESASSOCIATE), 'tooltip' => $language->getMessage(self::MESSAGE_MULTI_OBJECT_DISASSOCIATE_ELEMENT, false, MOD_POLYMOD_CODENAME), 'handler' => sensitiveIO::sanitizeJSString('function(button){
								var cmp = Ext.getCmp(\'' . $listId2 . '\');
								var selected = cmp.view.getSelectedRecords();
								if (!selected.length || selected.length > 1) {
									Automne.message.popup({
										msg: 				\'' . $language->getJSMessage(self::MESSAGE_MULTI_OBJECT_SELECT_BEFORE, false, MOD_POLYMOD_CODENAME) . '\',
										buttons: 			Ext.MessageBox.OKCANCEL,
										animEl: 			button.getEl(),
										closable: 			false,
										icon: 				Ext.MessageBox.INFO
									});
									return;
								}
								Automne.message.popup({
									msg: 				\'' . io::htmlspecialchars($language->getMessage(self::MESSAGE_PAGE_ACTION_DESASSOCIATE_CONFIRM, array($objectDef->getObjectLabel($language)), MOD_POLYMOD_CODENAME)) . '\',
									buttons: 			Ext.MessageBox.OKCANCEL,
									animEl: 			button.getEl(),
									closable: 			false,
									icon: 				Ext.MessageBox.WARNING,
									scope:				this,
									fn: 				function (button) {
										if (button == \'ok\') {
											var cmp = Ext.getCmp(\'' . $listId2 . '\');
											var selected = cmp.view.getSelectedRecords();
											if (!selected.length || selected.length > 1) {
												return;
											}
											var objectId = selected[0].id;
											var values = cmp.getRawValue();
											values.remove(objectId);
											cmp.setValue(values.join(cmp.delimiter));
											if (\'' . $listId . '\') {
												var list = Ext.getCmp(\'' . $listId . '\');
												if (list) {
													list.store.baseParams.removeIds = values.join(cmp.delimiter);
													list.store.load();
												}
											}
										}
									}
								});
							}', false, false), 'scope' => 'this'), '->', array('text' => $language->getMessage(self::MESSAGE_PAGE_ACTION_MODIFIY), 'tooltip' => $language->getMessage(self::MESSAGE_MULTI_OBJECT_EDIT_ELEMENT, false, MOD_POLYMOD_CODENAME), 'iconCls' => 'atm-pic-modify', 'handler' => sensitiveIO::sanitizeJSString('function(button){
								var cmp = Ext.getCmp(\'' . $listId2 . '\');
								var selected = cmp.view.getSelectedRecords();
								if (!selected.length || selected.length > 1) {
									Automne.message.popup({
										msg: 				\'' . $language->getJSMessage(self::MESSAGE_MULTI_OBJECT_SELECT_BEFORE, false, MOD_POLYMOD_CODENAME) . '\',
										buttons: 			Ext.MessageBox.OKCANCEL,
										animEl: 			button.getEl(),
										closable: 			false,
										icon: 				Ext.MessageBox.INFO
									});
									return;
								}
								var objectId = selected[0].id;
								var windowId = \'module' . $moduleCodename . 'EditWindow\'+objectId;
								/*create window element*/
								var window = new Automne.Window({
									id:				windowId,
									objectId:		objectId,
									autoLoad:		{
										url:			\'' . $editURL . '\',
										params:			{
											winId:			windowId,
											module:			\'' . $moduleCodename . '\',
											type:			\'' . $this->_objectID . '\',
											item:			objectId
										},
										nocache:		true,
										scope:			this
									},
									modal:			true,
									width:			750,
									height:			580,
									animateTarget:	button,
									listeners:{\'close\':function(window){
										var cmp = Ext.getCmp(\'' . $listId2 . '\');
										cmp.store.reload();
									}}
								});
								/*display window*/
								window.show(button.getEl());
							}', false, false), 'scope' => 'this'), array('text' => $language->getMessage(self::MESSAGE_PAGE_ACTION_NEW), 'tooltip' => $language->getMessage(self::MESSAGE_MULTI_OBJECT_CREATE_ZONE, array($objectDef->getObjectLabel($language)), MOD_POLYMOD_CODENAME), 'iconCls' => 'atm-pic-add', 'handler' => sensitiveIO::sanitizeJSString('function(button){
								var objectId = \'create' . $moduleCodename . $this->_objectID . '\';
								var windowId = \'module' . $moduleCodename . 'EditWindow\'+objectId;
								/*create window element*/
								var window = new Automne.Window({
									id:				windowId,
									objectId:		\'\',
									autoLoad:		{
										url:			\'' . $editURL . '\',
										params:			{
											winId:			windowId,
											module:			\'' . $moduleCodename . '\',
											type:			\'' . $this->_objectID . '\'
										},
										nocache:		true,
										scope:			this
									},
									modal:			true,
									width:			750,
									height:			580,
									animateTarget:	button,
									listeners:{\'close\':function(window){
										var cmp = Ext.getCmp(\'' . $listId2 . '\');
										if (window.objectId) {
											var values = cmp.getRawValue();
											values.unshift(window.objectId);
											cmp.setValue(values.join(cmp.delimiter));
										}
									}}
								});
								/*display window*/
								window.show(button.getEl());
							}', false, false), 'scope' => 'this')), 'ddReorder' => true);
            }
            $return = array('title' => $label, 'xtype' => 'fieldset', 'autoHeight' => true, 'layout' => 'form', 'defaults' => array('anchor' => '97%'), 'items' => $items);
            return $return;
        } else {
            $return = array('allowBlank' => !$this->_field->getValue('required'), 'fieldLabel' => $label, 'name' => 'polymodFieldsValue[list' . $prefixName . $this->_field->getID() . '_0]');
            //get searched objects conditions
            $searchedObjects = is_array($params['searchedObjects']) ? $params['searchedObjects'] : array();
            $objectsNames = CMS_poly_object_catalog::getListOfNamesForObject($this->_objectID, false, $searchedObjects);
            $associatedItems = $availableItems = array();
            if (is_array($objectsNames) && $objectsNames) {
                foreach (array_keys($this->_subfieldValues) as $subFieldID) {
                    if (is_object($this->_subfieldValues[$subFieldID])) {
                        $associatedItems[$this->_subfieldValues[$subFieldID]->getValue()] = $this->_subfieldValues[$subFieldID]->getValue();
                    }
                }
                foreach ($objectsNames as $id => $name) {
                    $availableItems[] = array($id, $name);
                }
            } else {
                $availableItems[] = array('', $language->getMessage(self::MESSAGE_EMPTY_OBJECTS_SET));
                $return['disabled'] = true;
            }
            /*$return['xtype'] 			= 'multiselect';
            		$return['dataFields'] 		= array('id', 'label');
            		$return['data'] 			= $availableItems;
            		$return['value'] 			= implode(',',$associatedItems);
            		$return['valueField'] 		= "id";
            		$return['displayField'] 	= "label";
            		$return['width'] 			= '100%';*/
            $return['xtype'] = 'superboxselect';
            $return['dataFields'] = array('id', 'label');
            $return['store'] = $availableItems;
            $return['mode'] = 'local';
            $return['value'] = implode(',', $associatedItems);
            $return['valueField'] = "id";
            $return['displayField'] = "label";
            $return['width'] = '100%';
            $return['stackItems'] = true;
            return $return;
        }
    }
Ejemplo n.º 18
0
						disabled:		' . $panelDisabled;
                if ($panelPicto) {
                    $jscontent .= ',
							iconCls:	\'' . $panelPicto . '\'';
                }
                $jscontent .= '
					});
					tabs.insert(' . $index . ', panel);
				}
				panel.setToolTip(\'' . sensitiveIO::sanitizeJSString($panelTipTitle) . '\', \'' . sensitiveIO::sanitizeJSString($panelTip) . '\');
				';
                break;
            default:
                if ($panelContent) {
                    $jscontent .= $panelContent . '
					panel.setToolTip(\'' . sensitiveIO::sanitizeJSString($panelTipTitle) . '\', \'' . sensitiveIO::sanitizeJSString($panelTip) . '\');';
                } else {
                    $jscontent .= '
					//then remove panel
					if (panel) tabs.remove(\'' . $panel . '\');
					';
                }
                break;
        }
    } else {
        $index--;
        //remove panel
        $jscontent .= '
		//then remove panel
		if (panel) tabs.remove(\'' . $panel . '\');
		';
Ejemplo n.º 19
0
    /**
     * Gets the data, using the specified visualization mode.
     * The data is taken from the blocks and reintroduced into the definition file which may itself contain HTML instructions.
     *
     * @param CMS_language &$language The language of the administration frontend
     * @param CMS_page &$page the page parsed
     * @param CMS_clientSpace &$clientSpace the client space parsed
     * @param integer $visualizationMode the visualization mode
     * @param boolean $templateHasPages, set to true will die access to up/down buttons
     * @param boolean $rowCanBeEdited determine we can edit it this page (Display form)
     * @return string the data from the blocks and the definition file.
     * @access public
     */
    function getData(&$language, &$page, &$clientSpace, $visualizationMode, $templateHasPages = false, $rowCanBeEdited = true)
    {
        global $cms_user;
        $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_BLOCK_TAGS, $visualizationMode, $this);
        $modulesTreatment->setTreatmentParameters(array("page" => $page, "language" => $language, "clientSpace" => $clientSpace));
        if (!$this->_parseDefinitionFile($modulesTreatment)) {
            //here we expect a false (otherwise, it is an error)
            $data = $modulesTreatment->treatContent();
            //if $visualizationMode is CLIENTSPACES_FORM and
            //no page uses the template calling this row, add the form here
            if ($visualizationMode == PAGE_VISUALMODE_CLIENTSPACES_FORM || $visualizationMode == PAGE_VISUALMODE_FORM) {
                //append atm-row class and row-id to all first level tags found in row datas
                $domdocument = new CMS_DOMDocument();
                try {
                    $domdocument->loadXML('<row>' . $data . '</row>');
                } catch (DOMException $e) {
                    //$this->raiseError('Parse error for row : Page '.$page->getID().' - Row "'.$this->getTagID().'" : '.$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('<row>'.$data.'</row>');
                    $this->raiseError('Parse error for row : ' . $e->getMessage() . " :\n" . $data, true);
                    return '';
                }
                $rowNodes = $domdocument->getElementsByTagName('row');
                if ($rowNodes->length == 1) {
                    $rowXML = $rowNodes->item(0);
                }
                //search for valid tags
                $hasNode = false;
                foreach ($rowXML->childNodes as $rowChildNode) {
                    //scripts tags and p tags are not correctly handled by javascript
                    if (is_a($rowChildNode, 'DOMElement') && $rowChildNode->tagName != 'script') {
                        $hasNode = true;
                    }
                }
                foreach ($rowXML->childNodes as $rowChildNode) {
                    //scripts tags and p tags are not correctly handled by javascript
                    if (is_a($rowChildNode, 'DOMElement') && ($rowChildNode->tagName != 'p' || io::substr($rowChildNode->tagName, 0, 4) != 'atm-')) {
                        $hasNode = false;
                    }
                }
                if (!$hasNode) {
                    //append atm-row class and row-id to all first level tags found in row datas
                    $domdocument = new CMS_DOMDocument();
                    try {
                        $domdocument->loadXML('<row><div class="atm-dummy-row-tag">' . $data . '</div></row>');
                    } catch (DOMException $e) {
                        $this->raiseError('Parse error for row : ' . $e->getMessage() . " :\n" . $data, true);
                        return '';
                    }
                    $rowNodes = $domdocument->getElementsByTagName('row');
                    if ($rowNodes->length == 1) {
                        $rowXML = $rowNodes->item(0);
                    }
                }
                $elements = array();
                $rowId = 'row-' . $this->_tagID;
                foreach ($rowXML->childNodes as $rowChildNode) {
                    if (is_a($rowChildNode, 'DOMElement') && $rowChildNode->tagName != 'script' && $rowChildNode->tagName != 'p' && io::substr($rowChildNode->tagName, 0, 4) != 'atm-') {
                        if ($rowChildNode->hasAttribute('id')) {
                            $elementId = $rowChildNode->getAttribute('id');
                        } else {
                            $elementId = 'el-' . md5(mt_rand() . microtime());
                            $rowChildNode->setAttribute('id', $elementId);
                        }
                        $elements[] = $elementId;
                    }
                }
                $data = CMS_DOMDocument::DOMElementToString($rowXML, true);
                //add row specification
                $data = '
				<script type="text/javascript">
					atmRowsDatas[\'' . $rowId . '\'] = {
						id:					\'' . $rowId . '\',
						template:			\'' . $clientSpace->getTemplateID() . '\',
						clientSpaceTagID:	\'' . $clientSpace->getTagID() . '\',
						rowTagID:			\'' . $this->_tagID . '\',
						rowType:			\'' . $this->_id . '\',
						label:				\'' . sensitiveIO::sanitizeJSString($this->getLabel()) . '\',
						userRight:			\'' . $this->hasUserRight($cms_user) . '\',
						visualMode:			\'' . $visualizationMode . '\',
						document:			document,
						elements:			[' . ($elements ? '\'' . implode('\',\'', $elements) . '\'' : '') . ']
					};
				</script>
				' . $data;
                //decode brackets encoded in CMS_block_text::_getHTMLForm
                $replace = array('||bo||' => '&#123;', '||bc||' => '&#125;');
                $data = str_replace(array_keys($replace), $replace, $data);
            }
            $data = '<?php /* Start row [' . $this->getLabel() . ' - ' . $this->getDefinitionFileName() . '] */?>' . $data . '<?php /* End row [' . $this->getLabel() . ' - ' . $this->getDefinitionFileName() . '] */?>';
            return $data;
        } else {
            $this->raiseError('Can not use row template file ' . $this->_definitionFile);
            return false;
        }
    }
Ejemplo n.º 20
0
 } else {
     $type = 'text';
     $value = $parameter;
 }
 if (defined(get_class($module) . '::MESSAGE_PARAM_' . $labelCode)) {
     $label = $cms_language->getMessage(constant(get_class($module) . '::MESSAGE_PARAM_' . $labelCode), false, $codename);
 } else {
     $label = str_replace('_', ' ', $labelCode);
 }
 if (defined(get_class($module) . '::MESSAGE_PARAM_' . $labelCode . '_DESC')) {
     $description = $cms_language->getMessage(constant(get_class($module) . '::MESSAGE_PARAM_' . $labelCode . '_DESC'), false, $codename);
     $fieldLabel = '<span ext:qtip="' . sensitiveIO::sanitizeJSString($description) . '" class="atm-help">' . sensitiveIO::sanitizeJSString($label) . '</span>';
 } else {
     $fieldLabel = sensitiveIO::sanitizeJSString($label);
 }
 $value = sensitiveIO::sanitizeJSString($value);
 switch ($type) {
     case 'email':
         $paramFields .= "{\n\t\t\t\tfieldLabel: '{$fieldLabel}',\n\t\t\t\tname: \t\t'params[{$labelCode}]',\n\t\t\t\tvalue:\t\t'{$value}',\n\t\t\t\tvtype:\t\t'email'\n\t\t\t},";
         break;
     case 'integer':
         $paramFields .= "{\n\t\t\t\txtype:\t\t'numberfield',\n\t\t\t\tfieldLabel: '{$fieldLabel}',\n\t\t\t\tname: \t\t'params[{$labelCode}]',\n\t\t\t\tvalue:\t\t'{$value}'\n\t\t\t},";
         break;
     case 'boolean':
         $checked = $value ? 'checked:true,' : '';
         $paramFields .= "{\n\t\t\t\t" . $checked . "\n\t\t\t\tboxLabel: \t\t'{$fieldLabel}',\n\t\t\t\tname: \t\t\t'params[{$labelCode}]',\n\t\t\t\txtype:\t\t\t'checkbox',\n\t\t\t\tinputValue:\t\t'1',\n\t\t\t\tfieldLabel: \t'',\n\t\t\t\thideLabel:\t\ttrue,\n\t\t\t\tlabelSeparator:\t''\n\t\t\t},";
         break;
     case 'text':
     default:
         $paramFields .= "{\n\t\t\t\tfieldLabel: '{$fieldLabel}',\n\t\t\t\tname: \t\t'params[{$labelCode}]',\n\t\t\t\tvalue:\t\t'{$value}'\n\t\t\t},";
         break;
    $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
\t});
\t
Ejemplo n.º 22
0
            //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();
$rootPath = PATH_REALROOT_WR;
$jscontent = <<<END
Ejemplo n.º 23
0
foreach ($modules as $module) {
    if (!$module->isPolymod() && $module->getCodename() != MOD_STANDARD_CODENAME) {
        $modulesInfo .= '<li>' . $module->getLabel($cms_language);
        if (file_exists(PATH_MODULES_FS . '/' . $module->getCodename() . '/VERSION')) {
            $modulesInfo .= ' - ' . $cms_language->getMessage(MESSAGE_PAGE_VERSION) . ' : ' . file_get_contents(PATH_MODULES_FS . '/' . $module->getCodename() . '/VERSION');
        }
        if ($module->getCodename() == 'mail' && file_exists(PATH_MODULES_FS . '/mailing/VERSION')) {
            $modulesInfo .= ' - ' . $cms_language->getMessage(MESSAGE_PAGE_VERSION) . ' : ' . file_get_contents(PATH_MODULES_FS . '/mailing/VERSION');
        }
        $modulesInfo .= '</li>';
    }
}
$modulesInfo .= '</ul>';
//Scripts content
$content = $cms_language->getMessage(MESSAGE_PAGE_ABOUT_MESSAGE, array(AUTOMNE_VERSION, $lastUpdate, APPLICATION_DEFAULT_ENCODING, LIBXML_DOTTED_VERSION, $modulesInfo));
$content = sensitiveIO::sanitizeJSString($content);
$jscontent = <<<END
\tvar serverWindow = Ext.getCmp('{$winId}');
\t//set window title
\tserverWindow.setTitle('{$cms_language->getJsMessage(MESSAGE_PAGE_TITLE)}');
\t//set help button on top of page
\tserverWindow.tools['help'].show();
\t//add a tooltip on button
\tvar propertiesTip = new Ext.ToolTip({
\t\ttarget:\t\t serverWindow.tools['help'],
\t\ttitle:\t\t\t '{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP)}',
\t\thtml:\t\t\t '{$cms_language->getJsMessage(MESSAGE_TOOLBAR_HELP_MESSAGE)}',
\t\tdismissDelay:\t0
\t});
\t
\t//create center panel
Ejemplo n.º 24
0
    CMS_grandFather::raiseError('Unknown window Id ...');
    $view->show();
}
//load module
$module = CMS_modulesCatalog::getByCodename($codename);
if (!$module) {
    CMS_grandFather::raiseError('Unknown module or module 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();
}
$moduleLabel = sensitiveIO::sanitizeJSString(io::htmlspecialchars($module->getLabel($cms_language)));
$jscontent = <<<END
\tvar moduleCategoriesWindow = Ext.getCmp('{$winId}');
\tvar fatherWindow = Ext.getCmp('{$fatherId}');
\t//do not allow change of maxDepth before layout is completely done
\tvar allowChangeMaxdepth = false;
\t
\tvar categoryWindows = [];
\t
\tvar tree = new Ext.tree.TreePanel({
\t\ttitle:\t\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_DRAG_DROP)}',
\t\tautoScroll:\t\ttrue,
        animate:\t\ttrue,
        region:\t\t\t'center',
\t\tborder:\t\t\tfalse,
\t\tenableDD:\t\ttrue,
Ejemplo n.º 25
0
    /**
     * Returns XHTML formatted form fields for this Href
     * 
     * @param CMS_language $cms_language, the language to build the form with
     * @param string $module, the module codename (default : MOD_STANDARD_CODENAME)
     * @param constant $dataLocation, the current data location (RESOURCE_DATA_LOCATION_EDITED (default), RESOURCE_DATA_LOCATION_PUBLIC, etc.)
     * @param array $options, array of possible link options (default false : all options actived)
     *	Example :
     * Array (
     *     'label' 		=> true|false,				// Link has label ?
     *     'internal' 	=> true|false,				// Link can target an Automne page ?
     *     'external' 	=> true|false,				// Link can target an external resource ?
     *     'file' 		=> true|false,				// Link can target a file ?
     *     'destination'=> true|false,				// Can select a destination for the link ?
     *     'no_admin' 	=> true|false,				// Deprecated : Remove all admin class reference (default = false)
     *     'admin' 		=> true|false,				// Use admin JS and classes instead of direct actions (default = true)
     *     'currentPage'=> int|false,				// Current page to open tree panel (default : CMS_tree::getRoot())
     * )
     * @return string HTML formated expected
     * @access public
     */
    function getHTMLFields($cms_language, $module = MOD_STANDARD_CODENAME, $dataLocation = RESOURCE_DATA_LOCATION_EDITED, $options = false)
    {
        global $cms_user;
        if (!is_a($this->_href, 'CMS_href')) {
            $this->raiseError("\$this->_href isn't a CMS_href");
            return '';
        }
        $tdClass = $tdClassLight = $tdClassDark = $inputClass = '';
        if (!isset($options['no_admin']) || $options['no_admin'] === false) {
            $tdClass = ' class="admin"';
            $tdClassLight = ' class="admin_lightgreybg"';
            $tdClassDark = ' class="admin_darkgreybg"';
            $inputClass = ' class="admin_input_text"';
        }
        $s = '';
        if (!isset($options['destination']) || $options['destination'] == true) {
            $s .= '
			<script type="text/javascript">
				if (typeof CMS_openPopUpPage != "function") {
					function CMS_openPopUpPage(href, id, width, height) {
						if (href != "") {
							pagePopupWin = window.open(href, \'CMS_page_\'+id, \'width=\'+width+\',height=\'+height+\',resizable=yes,menubar=no,toolbar=no,scrollbars=yes,status=no,left=0,top=0\');
						}
					}
				}
			</script>';
        }
        $s .= '
		<table>';
        if (!isset($options['label']) || $options['label'] == true) {
            $s .= '
				<!-- link label -->
				<tr>
					<th' . $tdClass . '><span class="admin_text_alert">*</span> ' . $cms_language->getMessage(self::MESSAGE_PAGE_LINK_LABEL) . '</th>
					<td' . $tdClassLight . ' colspan="2"><input style="width:100%;" type="text"' . $inputClass . ' name="' . $this->_prefix . 'link_label" value="' . io::htmlspecialchars($this->_href->getLabel()) . '" /></td>
				</tr>';
        }
        $checked = $this->_href->getLinkType() == RESOURCE_LINK_TYPE_NONE ? ' checked="checked"' : '';
        $rowspan = 4;
        if (isset($options['internal']) && $options['internal'] == false) {
            $rowspan--;
        }
        if (isset($options['external']) && $options['external'] == false) {
            $rowspan--;
        }
        if (isset($options['file']) && $options['file'] == false) {
            $rowspan--;
        }
        $s .= '
					<tr>
						<th' . $tdClass . ' rowspan="' . $rowspan . '"><span class="admin_text_alert">*</span> ' . $cms_language->getMessage(self::MESSAGE_PAGE_LINK_DESTINATION) . '</th>
						<td' . $tdClassDark . '><input type="radio" id="' . $this->_prefix . 'link_type_0" name="' . $this->_prefix . 'link_type" value="' . RESOURCE_LINK_TYPE_NONE . '"' . $checked . ' /></td>
						<td' . $tdClassDark . '><label for="' . $this->_prefix . 'link_type_0">' . $cms_language->getMessage(self::MESSAGE_PAGE_NOLINK) . '</label></td>
					</tr>
			';
        if (!isset($options['internal']) || $options['internal'] == true) {
            $checked = $this->_href->getLinkType() == RESOURCE_LINK_TYPE_INTERNAL ? ' checked="checked"' : '';
            // Build tree link
            $grand_root = isset($options['currentPage']) && sensitiveIO::isPositiveInteger($options['currentPage']) ? CMS_tree::getPageByID($options['currentPage']) : CMS_tree::getRoot();
            $grand_rootID = $grand_root->getID();
            if ($cms_user && is_a($cms_user, 'CMS_profile_user')) {
                if (!$cms_user->hasPageClearance($grand_rootID, CLEARANCE_PAGE_VIEW)) {
                    // If user don't have any clearance view for page root : search a "first root" and viewable page sections
                    $sections_roots = array();
                    $sections_roots = $cms_user->getViewablePageClearanceRoots();
                    if ($sections_roots) {
                        CMS_session::setSessionVar('sectionsRoots', $sections_roots);
                        $sections_roots = array_reverse($sections_roots);
                        foreach ($sections_roots as $pageID) {
                            $lineages[count(CMS_tree::getLineage($grand_rootID, $pageID, false))] = $pageID;
                        }
                    }
                    ksort($lineages);
                    $grand_rootID = array_shift($lineages);
                }
            }
            if (!isset($options['admin']) || $options['admin'] == false) {
                //build tree link
                $href = '/automne/admin-v3/tree.php';
                $href .= '?root=' . $grand_rootID;
                $href .= '&amp;heading=' . $cms_language->getMessage(self::MESSAGE_PAGE_TREEH1);
                $href .= '&amp;encodedOnClick=' . base64_encode("window.opener.document.getElementById('" . $this->_prefix . "link_internal').value = '%s';self.close();");
                $href .= '&encodedPageLink=' . base64_encode('false');
                $treeLink = '<a href="' . $href . '"' . $tdClass . ' target="_blank"><img src="' . PATH_ADMIN_IMAGES_WR . '/tree.gif" border="0" align="absmiddle" /></a>';
            } else {
                $treeLink = '<a href="#" onclick="Automne.view.tree(\'' . $this->_prefix . 'link_internal\', \'' . sensitiveIO::sanitizeJSString($cms_language->getMessage(self::MESSAGE_PAGE_TREEH1)) . '\', \'' . $grand_rootID . '\')"><img src="' . PATH_ADMIN_IMAGES_WR . '/tree.gif" border="0" align="absmiddle" /></a>';
            }
            $s .= '<tr>
						<td' . $tdClassLight . '><input type="radio" id="' . $this->_prefix . 'link_type_1" name="' . $this->_prefix . 'link_type" value="' . RESOURCE_LINK_TYPE_INTERNAL . '"' . $checked . ' /></td>
						<td' . $tdClassLight . '>
							<label for="' . $this->_prefix . 'link_type_1">' . $cms_language->getMessage(self::MESSAGE_PAGE_INTERNALLINK) . '</label>
							<input type="text"' . $inputClass . ' id="' . $this->_prefix . 'link_internal" name="' . $this->_prefix . 'link_internal" value="' . $this->_href->getInternalLink() . '" size="6" />
							' . $treeLink . '
						</td>
					</tr>';
        }
        if (!isset($options['external']) || $options['external'] == true) {
            $checked = $this->_href->getLinkType() == RESOURCE_LINK_TYPE_EXTERNAL ? ' checked="checked"' : '';
            $s .= '
					<tr>
						<td' . $tdClassDark . '><input type="radio" id="' . $this->_prefix . 'link_type_2" name="' . $this->_prefix . 'link_type" value="' . RESOURCE_LINK_TYPE_EXTERNAL . '"' . $checked . ' /></td>
						<td' . $tdClassDark . '>
							<label for="' . $this->_prefix . 'link_type_2">' . $cms_language->getMessage(self::MESSAGE_PAGE_EXTERNALLINK) . '</label>
							<input type="text"' . $inputClass . ' id="' . $this->_prefix . 'link_external" name="' . $this->_prefix . 'link_external" value="' . io::htmlspecialchars($this->_href->getExternalLink()) . '" size="30" />
						</td>
					</tr>
				';
        }
        if (!isset($options['file']) || $options['file'] == true) {
            $checked = $this->_href->getLinkType() == RESOURCE_LINK_TYPE_FILE ? ' checked="checked"' : '';
            $s .= '
					<tr>
						<td' . $tdClassLight . '><input type="radio" id="' . $this->_prefix . 'link_type_3" name="' . $this->_prefix . 'link_type" value="' . RESOURCE_LINK_TYPE_FILE . '"' . $checked . ' /></td>
						<td' . $tdClassLight . '>
							<label for="' . $this->_prefix . 'link_type_3">' . $cms_language->getMessage(self::MESSAGE_PAGE_LINKFILE) . '</label>
							<input type="file"' . $inputClass . ' name="' . $this->_prefix . 'link_file" /><br />
							<label for="' . $this->_prefix . 'link_edit_linkfile"><input type="checkbox" id="' . $this->_prefix . 'link_edit_linkfile" name="' . $this->_prefix . 'link_edit_linkfile" value="1" /> ' . $cms_language->getMessage(self::MESSAGE_PAGE_FIELD_EDITFILE) . '</label>';
            if ($this->_href->getFileLink(false, $module, $dataLocation)) {
                $s .= '<br />' . $cms_language->getMessage(self::MESSAGE_PAGE_EXISTING_FILE) . ' : <a href="' . $this->_href->getFileLink(true, $module, $dataLocation) . '" target="_blank">' . $this->_href->getFileLink(false, $module, $dataLocation) . '</a>';
            } else {
                $s .= '<br />' . $cms_language->getMessage(self::MESSAGE_PAGE_EXISTING_FILE) . ' : ' . $cms_language->getMessage(self::MESSAGE_PAGE_NO_FILE);
            }
            $s .= '	</td>
					</tr>';
        }
        if (!isset($options['destination']) || $options['destination'] == true) {
            $popup = $this->_href->getPopup();
            $checked_pop = isset($popup['width']) && $popup['width'] > 0 ? ' checked="checked"' : '';
            $checked_top = isset($popup['width']) && $popup['width'] <= 0 && $this->_href->getTarget() == '_top' ? ' checked="checked"' : '';
            $checked_bl = isset($popup['width']) && $popup['width'] <= 0 && $this->_href->getTarget() == '_blank' ? ' checked="checked"' : '';
            if (!$checked_pop && !$checked_top && !$checked_bl) {
                $checked_top = ' checked="checked"';
            }
            $width = isset($popup['width']) ? $popup['width'] : 0;
            $height = isset($popup['height']) ? $popup['height'] : 0;
            $s .= '
					<!-- Link target -->
					<tr>
						<th' . $tdClass . ' rowspan="3">' . $cms_language->getMessage(self::MESSAGE_PAGE_LINK_SHOW) . '</th>
						<td' . $tdClassDark . '><input type="radio" id="' . $this->_prefix . 'link_target_top" name="' . $this->_prefix . 'link_target" value="top"' . $checked_top . ' /></td>
						<td' . $tdClassDark . '>
							<label for="' . $this->_prefix . 'link_target_top"><img src="' . PATH_ADMIN_IMAGES_WR . '/pic_link_top.gif" alt="" border="0" align="absmiddle" />
							' . $cms_language->getMessage(self::MESSAGE_PAGE_TARGET_TOP) . '</label>
						</td>
					</tr>
					<tr>
						<td' . $tdClassLight . '><input type="radio" id="' . $this->_prefix . 'link_target_blank" name="' . $this->_prefix . 'link_target" value="blank"' . $checked_bl . ' /></td>
						<td' . $tdClassLight . '>
							<label for="' . $this->_prefix . 'link_target_blank"><img src="' . PATH_ADMIN_IMAGES_WR . '/pic_link_blank.gif" alt="" border="0" align="absmiddle" />
							' . $cms_language->getMessage(self::MESSAGE_PAGE_TARGET_BLANK) . '</label>
						</td>
					</tr>
					<tr>
						<td' . $tdClassDark . '><input type="radio" id="' . $this->_prefix . 'link_target_popup" name="' . $this->_prefix . 'link_target" value="popup"' . $checked_pop . ' /></td>
						<td' . $tdClassDark . '>
							<label for="' . $this->_prefix . 'link_target_popup"><img src="' . PATH_ADMIN_IMAGES_WR . '/pic_link_top.gif" alt="" border="0" align="absmiddle" />
							' . $cms_language->getMessage(self::MESSAGE_PAGE_TARGET_POPUP) . ' : </label>
							' . $cms_language->getMessage(self::MESSAGE_PAGE_POPUP_WIDTH) . ' <input type="text"' . $inputClass . ' name="' . $this->_prefix . 'link_popup_width" value="' . $width . '" size="3" />
							' . $cms_language->getMessage(self::MESSAGE_PAGE_POPUP_HEIGHT) . ' <input type="text"' . $inputClass . ' name="' . $this->_prefix . 'link_popup_height" value="' . $height . '" size="3" />
						</td>
					</tr>';
        }
        $s .= '</table>';
        return $s;
    }
Ejemplo n.º 26
0
    CMS_grandFather::raiseError('User has no rights template editions');
    $view->setActionMessage($cms_language->getMessage(MESSAGE_ERROR_NO_RIGHTS_FOR_TEMPLATES));
    $view->show();
}
//include modules codes in output file
$template = '';
$modulesCodes = new CMS_modulesCodes();
$modulesCodeInclude = $modulesCodes->getModulesCodes(MODULE_TREATMENT_TEMPLATES_EDITION_LABELS, PAGE_VISUALMODE_CLIENTSPACES_FORM, $template, array("language" => $cms_language, "user" => $cms_user));
$modulesTab = '';
if (is_array($modulesCodeInclude) && $modulesCodeInclude) {
    foreach ($modulesCodeInclude as $codename => $description) {
        //if user has rights on module
        if ($cms_user->hasModuleClearance($codename, CLEARANCE_MODULE_EDIT)) {
            $module = CMS_modulesCatalog::getByCodename($codename);
            $label = sensitiveIO::sanitizeJSString($module->getLabel($cms_language));
            $description = sensitiveIO::sanitizeJSString($description);
            $modulesTab .= "{\n\t\t\t\ttitle:\t\t\t\t'{$label}',\n\t\t\t\thtml:\t\t\t\t'{$description}'\n\t\t\t},";
        }
    }
}
//remove last comma
if ($modulesTab) {
    $modulesTab = io::substr($modulesTab, 0, -1);
}
$jscontent = <<<END
\tvar helpWindow = Ext.getCmp('{$winId}');
\t//set window title
\thelpWindow.setTitle('{$cms_language->getJsMessage(MESSAGE_PAGE_TITLE)}');
\t//set help button on top of page
\thelpWindow.tools['help'].show();
\t//add a tooltip on button
Ejemplo n.º 27
0
     } else {
         CMS_grandFather::raiseError('Can\'t get block class type ' . $blockClass . ' to update content');
         $view->setActionMessage($cms_language->getJsMessage(MESSAGE_PAGE_ERROR_UPDATE_BLOCK_CONTENT));
     }
     break;
 case 'update-block-text':
 case 'update-block-varchar':
     //update block content
     if (class_exists($blockClass)) {
         $cms_block = new $blockClass();
         $cms_block->initializeFromBasicAttributes($blockId);
         if ($action == 'update-block-text') {
             $errors = '';
             if (!sensitiveIO::checkXHTMLValue($value, $errors)) {
                 //Send an error to user about his content
                 $jscontent = "\n\t\t\t\t\tAutomne.message.popup({\n\t\t\t\t\t\tmsg: \t\t\t\t'" . $cms_language->getJsMessage(MESSAGE_PAGE_COPY_PASTE_ERROR) . ($errors ? "<br /><br />" . sensitiveIO::sanitizeJSString($errors) : '') . "',\n\t\t\t\t\t\tbuttons: \t\t\tExt.MessageBox.OK,\n\t\t\t\t\t\tclosable: \t\t\ttrue,\n\t\t\t\t\t\ticon: \t\t\t\tExt.MessageBox.ERROR\n\t\t\t\t\t});";
                 $view->addJavascript($jscontent);
                 $view->show();
             }
             $value = CMS_textEditor::parseOuterContent($value);
         }
         $cms_block->writeToPersistence($cms_page->getID(), $cs, $rowTag, RESOURCE_LOCATION_EDITION, false, array("value" => $value));
         //instanciate the clientspace
         $clientSpace = CMS_moduleClientSpace_standard_catalog::getByTemplateAndTagID($tpl, $cs, $visualMode == PAGE_VISUALMODE_FORM);
         //get block's row from CS
         $row = $clientSpace->getRow($rowId, $rowTag);
         if ($row) {
             //get row datas
             $datas = $row->getData($cms_language, $cms_page, $clientSpace, PAGE_VISUALMODE_FORM);
             //instanciate modules treatments for page content tags
             $modulesTreatment = new CMS_modulesTags(MODULE_TREATMENT_PAGECONTENT_TAGS, PAGE_VISUALMODE_FORM, $cms_page);
Ejemplo n.º 28
0
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;
            // retrieve the stored value or the default one, if any
Ejemplo n.º 29
0
    /**
     * 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;
    }
Ejemplo n.º 30
0
					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}&nbsp;{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}');
\t//if we are in a window context
\tif ({$window} && treeWindow) {
\t\t//set window title