Пример #1
0
if ($pageId) {
    $href->setLinkType(RESOURCE_LINK_TYPE_INTERNAL);
    $href->setInternalLink($pageId);
    $redirDisabled = 'disabled:true,';
    $redirHidden = "{\n\t\txtype:\t\t\t'hidden',\n\t\tname:\t\t\t'page',\n\t\tvalue:\t\t\t'{$pageId}'\n\t},";
} else {
    if (io::isPositiveInteger($item->getPageID())) {
        $href->setLinkType(RESOURCE_LINK_TYPE_INTERNAL);
        $href->setInternalLink($item->getPageID());
    } elseif ($item->getURL()) {
        $href->setLinkType(RESOURCE_LINK_TYPE_EXTERNAL);
        $href->setExternalLink($item->getURL());
    }
    $redirDisabled = $redirHidden = '';
}
$redirectValue = io::sanitizeJSString($href->getTextDefinition());
$visualmode = RESOURCE_DATA_LOCATION_EDITED;
//Websites
$currentWebsites = $item->getWebsites();
$websites = CMS_websitesCatalog::getAll();
$availableWebsites = $selectedWebsites = array();
foreach ($websites as $id => $website) {
    if (in_array($website->getId(), $currentWebsites)) {
        $exists = false;
        foreach ($selectedWebsites as $data) {
            if ($data[1] == $website->getURL()) {
                $exists = true;
            }
        }
        if (!$exists) {
            $selectedWebsites[] = array($id, $website->getURL());
Пример #2
0
            foreach ($deniedWebsites as $deniedWebsite) {
                $template->denyWebsite($deniedWebsite);
            }
            //XML definition file
            if ($definitionfile && io::strpos($definitionfile, PATH_UPLOAD_WR . '/') !== false) {
                //read uploaded file
                $definitionfile = new CMS_file($definitionfile, CMS_file::WEBROOT);
                $template->setDebug(false);
                $template->setLog(false);
                $error = $template->setDefinition($definitionfile->readContent());
                if ($error !== true) {
                    $cms_message = $cms_language->getMessage(MESSAGE_PAGE_MALFORMED_DEFINITION_FILE);
                    //send message to inform user
                    $jscontent = '
						Automne.message.popup({
							msg: 				\'' . $cms_language->getJSMessage(MESSAGE_PAGE_MALFORMED_DEFINITION_FILE) . '<br />' . io::sanitizeJSString($error) . '\',
							buttons: 			Ext.MessageBox.OK,
							closable: 			false,
							icon: 				Ext.MessageBox.ERROR
						});';
                    $view->addJavascript($jscontent);
                }
            }
            if (!$cms_message && !$template->hasError()) {
                if ($template->writeToPersistence()) {
                    $log = new CMS_log();
                    $log->logMiscAction(CMS_log::LOG_ACTION_TEMPLATE_EDIT, $cms_user, "Template : " . $template->getLabel() . " (edit base data)");
                    $content = array('success' => true);
                    $cms_message = $cms_language->getMessage(MESSAGE_ACTION_SAVE_DONE);
                    $view->setContent($content);
                } else {
Пример #3
0
 function replaceCallBack($parts)
 {
     return 'function(' . str_replace(array('\\"', '\\/'), array('"', '/'), $parts[1]) . '}';
 }
 foreach ($modules as $aModule) {
     if (method_exists($aModule, 'getUserAccordionProperties')) {
         $moduleCodename = $aModule->getCodename();
         //get accordion datas from module
         $moduleDatas = $aModule->getUserAccordionProperties($userId, $cms_language);
         $moduleURL = false;
         if (isset($moduleDatas['url'])) {
             $moduleURL = $moduleDatas['url'];
         }
         $moduleLabel = io::sanitizeJSString($aModule->getLabel($cms_language));
         if (isset($moduleDatas['label'])) {
             $moduleLabel = io::sanitizeJSString($moduleDatas['label']);
         }
         $moduleFields = array();
         if (isset($moduleDatas['fields']) && is_array($moduleDatas['fields'])) {
             $moduleFields = $moduleDatas['fields'];
         }
         if (is_array($moduleFields)) {
             $moduleFields = sensitiveIO::jsonEncode($moduleFields);
         }
         //do some search and replace to allow use of js functions in returned code
         $moduleFields = str_replace('"scope":"this"', '"scope":this', $moduleFields);
         $moduleFields = preg_replace_callback('#"function\\((.*)}"#U', 'replaceCallBack', $moduleFields);
         $button = $moduleURL ? ",\n\t\t\t\tbuttons:[{\n\t\t\t\t\ttext:\t\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_SAVE)}',\n\t\t\t\t\ticonCls:\t\t'atm-pic-validate',\n\t\t\t\t\txtype:\t\t\t'button',\n\t\t\t\t\tname:\t\t\t'submit{$moduleCodename}User',\n\t\t\t\t\tscope:\t\t\tthis,\n\t\t\t\t\thandler:\t\tfunction() {\n\t\t\t\t\t\tvar form = Ext.getCmp('userPanel-{$moduleCodename}-{$userId}').getForm();\n\t\t\t\t\t\tform.submit({params:{\n\t\t\t\t\t\t\taction:\t\t'update-user',\n\t\t\t\t\t\t\tuserId:\t\tuserWindow.userId\n\t\t\t\t\t\t}});\n\t\t\t\t\t}\n\t\t\t\t}]" : '';
         $modulesAccordion .= ",{\n\t\t\t\ttitle:\t\t\t'{$moduleLabel}',\n\t\t\t\tid:\t\t\t\t'userPanel-{$moduleCodename}-{$userId}',\n\t\t\t\tlayout: \t\t'form',\n\t\t\t\txtype:\t\t\t'atmForm',\n\t\t\t\turl:\t\t\t'{$moduleURL}',\n\t\t\t\tcollapsible:\ttrue,\n\t\t\t\tdefaultType:\t'textfield',\n\t\t\t\tcollapsed:\t\ttrue,\n\t\t\t\tautoWidth:\t\ttrue,\n\t\t\t\tautoScroll:\t\ttrue,\n\t\t\t\tbuttonAlign:\t'center',\n\t\t\t\tlabelAlign:\t\t'right',\n\t\t\t\tautoScroll:\t\ttrue,\n\t\t\t\tdefaults: {\n\t\t\t\t\txtype:\t\t\t'textfield',\n\t\t\t\t\tanchor:\t\t\t'97%'\n\t\t\t\t},\n\t\t\t\titems:[{$moduleFields}]\n\t\t\t\t{$button}\n\t\t\t}";
     }
 }
Пример #4
0
 /**
  * Gets the data in HTML mode.
  *
  * @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 $visualizationMode The visualization mode used
  * @return string the HTML data
  * @access public
  */
 function getData(&$language, &$page, &$clientSpace, &$row, $visualizationMode)
 {
     parent::getData($language, $page, $clientSpace, $row, $visualizationMode);
     //get the data
     switch ($visualizationMode) {
         case PAGE_VISUALMODE_HTML_PUBLIC:
         case PAGE_VISUALMODE_PRINT:
             $data = $this->getRawData($page->getID(), $clientSpace->getTagID(), $row->getTagID(), RESOURCE_LOCATION_USERSPACE, true);
             break;
         case PAGE_VISUALMODE_HTML_EDITED:
             $data = $this->getRawData($page->getID(), $clientSpace->getTagID(), $row->getTagID(), RESOURCE_LOCATION_USERSPACE, false);
             break;
         case PAGE_VISUALMODE_HTML_EDITION:
         case PAGE_VISUALMODE_FORM:
         case PAGE_VISUALMODE_CLIENTSPACES_FORM:
             $data = $this->getRawData($page->getID(), $clientSpace->getTagID(), $row->getTagID(), RESOURCE_LOCATION_EDITION, false);
             break;
     }
     //build the HTML
     switch ($visualizationMode) {
         case PAGE_VISUALMODE_HTML_PUBLIC:
         case PAGE_VISUALMODE_HTML_EDITED:
         case PAGE_VISUALMODE_HTML_EDITION:
         case PAGE_VISUALMODE_PRINT:
             if ($data && $data["value"]) {
                 $html = io::htmlspecialchars($data["value"]);
                 $replace = array('{{data}}' => $html, '{{jsdata}}' => io::sanitizeJSString($html));
                 return str_replace(array_keys($replace), $replace, $this->_definition);
             }
             break;
             //case PAGE_VISUALMODE_CLIENTSPACES_FORM:
         //case PAGE_VISUALMODE_CLIENTSPACES_FORM:
         case PAGE_VISUALMODE_FORM:
             if ($data && $data["value"]) {
                 $html = io::htmlspecialchars($data["value"]);
             } elseif (isset($this->_attributes['default'])) {
                 $html = '<span class=\\"atm-ipsum\\">' . $this->_attributes['default'] . '</span>';
             } else {
                 $html = "<span class=\"atm-ipsum\">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diem nonummy.</span>";
             }
             $replace = array('{{data}}' => $html, '{{jsdata}}' => io::sanitizeJSString($html));
             $form_data = str_replace(array_keys($replace), $replace, $this->_definition);
             $this->_hasContent = $data && $data["value"] ? true : false;
             $this->_editable = true;
             return $this->_getHTMLForm($language, $page, $clientSpace, $row, $this->_tagID, $form_data);
             break;
         case PAGE_VISUALMODE_CLIENTSPACES_FORM:
             if (isset($this->_attributes['default'])) {
                 $html = '<span class=\\"atm-ipsum\\">' . $this->_attributes['default'] . '</span>';
             } else {
                 $html = "<span class=\"atm-ipsum\">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diem nonummy.</span>";
             }
             $replace = array('{{data}}' => $html, '{{jsdata}}' => io::sanitizeJSString($html));
             $form_data = str_replace(array_keys($replace), $replace, $this->_definition);
             $this->_hasContent = false;
             $this->_editable = false;
             return $this->_getHTMLForm($language, $page, $clientSpace, $row, $this->_tagID, $form_data);
             break;
     }
 }
Пример #5
0
 /**
  * Gets the data in HTML mode.
  *
  * @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 $visualizationMode The visualization mode used
  * @return string the HTML data
  * @access public
  */
 function getData(&$language, &$page, &$clientSpace, &$row, $visualizationMode)
 {
     parent::getData($language, $page, $clientSpace, $row, $visualizationMode);
     //get the data
     switch ($visualizationMode) {
         case PAGE_VISUALMODE_HTML_PUBLIC:
         case PAGE_VISUALMODE_PRINT:
             $data = $this->getRawData($page->getID(), $clientSpace->getTagID(), $row->getTagID(), RESOURCE_LOCATION_USERSPACE, true);
             break;
         case PAGE_VISUALMODE_HTML_EDITED:
             $data = $this->getRawData($page->getID(), $clientSpace->getTagID(), $row->getTagID(), RESOURCE_LOCATION_USERSPACE, false);
             break;
         case PAGE_VISUALMODE_HTML_EDITION:
         case PAGE_VISUALMODE_FORM:
         case PAGE_VISUALMODE_CLIENTSPACES_FORM:
             $data = $this->getRawData($page->getID(), $clientSpace->getTagID(), $row->getTagID(), RESOURCE_LOCATION_EDITION, false);
             break;
     }
     //We need to encode { and } to avoid vars detection in texts blocks
     $replace = array('{' => '&#123;', '}' => '&#125;');
     //build the HTML
     switch ($visualizationMode) {
         case PAGE_VISUALMODE_HTML_PUBLIC:
         case PAGE_VISUALMODE_PRINT:
         case PAGE_VISUALMODE_HTML_EDITED:
         case PAGE_VISUALMODE_HTML_EDITION:
             if ($data && $data["value"]) {
                 $html = str_replace(array_keys($replace), $replace, $data["value"]);
                 $replace = array('{{data}}' => $html, '{{jsdata}}' => io::sanitizeJSString($html));
                 return str_replace(array_keys($replace), $replace, $this->_definition);
             }
             break;
         case PAGE_VISUALMODE_FORM:
             if ($data && $data["value"]) {
                 $html = str_replace(array_keys($replace), $replace, $data["value"]);
             } elseif (isset($this->_attributes['default'])) {
                 $html = '<span class=\\"atm-ipsum\\">' . $this->_attributes['default'] . '</span>';
             } else {
                 $html = "<span class=\"atm-ipsum\">Duis autem dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla";
                 $html .= "facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit au gue duis";
                 $html .= "dolore te feugat nulla facilisi.</span>";
             }
             //This is used to avoid replacing {vars:type:value} inside text but to keep those vars inside block definition
             //decoded into CMS_block_text::_getHTMLForm
             $replace = array('||bovd||{data||bcvd||}' => $html, '||bovd||{jsdata||bcvd||}' => io::sanitizeJSString($html));
             $this->_definition = preg_replace('#{([a-zA-Z0-9._{}:-]*)}#U', '||bovd||\\1||bcvd||', $this->_definition);
             $form_data = str_replace(array_keys($replace), $replace, $this->_definition);
             $this->_hasContent = $data && $data["value"] ? true : false;
             $this->_editable = true;
             return $this->_getHTMLForm($language, $page, $clientSpace, $row, $this->_tagID, $form_data);
             break;
         case PAGE_VISUALMODE_CLIENTSPACES_FORM:
             if (isset($this->_attributes['default'])) {
                 $html = '<span class=\\"atm-ipsum\\">' . $this->_attributes['default'] . '</span>';
             } else {
                 $html = "<span class=\"atm-ipsum\">Duis autem dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla";
                 $html .= "facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit au gue duis";
                 $html .= "dolore te feugat nulla facilisi.</span>";
             }
             $replace = array('{{data}}' => $html, '{{jsdata}}' => io::sanitizeJSString($html));
             $form_data = str_replace(array_keys($replace), $replace, $this->_definition);
             $this->_hasContent = false;
             $this->_editable = false;
             return $this->_getHTMLForm($language, $page, $clientSpace, $row, $this->_tagID, $form_data);
             break;
     }
 }
Пример #6
0
$modulesAccordion = '';
//usefull temporary function
function replaceCallBack($parts)
{
    return 'function(' . str_replace(array('\\"', '\\/'), array('"', '/'), $parts[1]) . '}';
}
foreach ($modules as $aModule) {
    if (method_exists($aModule, 'getGroupAccordionProperties')) {
        $moduleCodename = $aModule->getCodename();
        //get accordion datas from module
        $moduleDatas = $aModule->getGroupAccordionProperties($groupId, $cms_language);
        $moduleURL = false;
        if (isset($moduleDatas['url'])) {
            $moduleURL = $moduleDatas['url'];
        }
        $moduleLabel = io::sanitizeJSString($aModule->getLabel($cms_language));
        if (isset($moduleDatas['label'])) {
            $moduleLabel = $moduleDatas['label'];
        }
        $moduleFields = array();
        if (isset($moduleDatas['fields']) && is_array($moduleDatas['fields'])) {
            $moduleFields = $moduleDatas['fields'];
        }
        if (is_array($moduleFields)) {
            $moduleFields = sensitiveIO::jsonEncode($moduleFields);
        }
        //do some search and replace to allow use of js functions in returned code
        $moduleFields = str_replace('"scope":"this"', '"scope":this', $moduleFields);
        $moduleFields = preg_replace_callback('#"function\\((.*)}"#U', 'replaceCallBack', $moduleFields);
        $button = $moduleURL ? ",\n\t\t\tbuttons:[{\n\t\t\t\ttext:\t\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_SAVE)}',\n\t\t\t\ticonCls:\t\t'atm-pic-validate',\n\t\t\t\txtype:\t\t\t'button',\n\t\t\t\tname:\t\t\t'submit{$moduleCodename}Group',\n\t\t\t\tscope:\t\t\tthis,\n\t\t\t\thandler:\t\tfunction() {\n\t\t\t\t\tvar form = Ext.getCmp('groupPanel-{$moduleCodename}-{$groupId}').getForm();\n\t\t\t\t\tform.submit({params:{\n\t\t\t\t\t\taction:\t\t'update-group',\n\t\t\t\t\t\tgroupId:\tgroupWindow.groupId\n\t\t\t\t\t}});\n\t\t\t\t}\n\t\t\t}]" : '';
        $modulesAccordion .= ",{\n\t\t\ttitle:\t\t\t'{$moduleLabel}',\n\t\t\tid:\t\t\t\t'groupPanel-{$moduleCodename}-{$groupId}',\n\t\t\tlayout: \t\t'form',\n\t\t\txtype:\t\t\t'atmForm',\n\t\t\turl:\t\t\t'{$moduleURL}',\n\t\t\tcollapsible:\ttrue,\n\t\t\tdefaultType:\t'textfield',\n\t\t\tcollapsed:\t\ttrue,\n\t\t\tautoWidth:\t\ttrue,\n\t\t\tautoScroll:\t\ttrue,\n\t\t\tbuttonAlign:\t'center',\n\t\t\tlabelAlign:\t\t'right',\n\t\t\tautoScroll:\t\ttrue,\n\t\t\tdefaults: {\n\t\t\t\txtype:\t\t\t'textfield',\n\t\t\t\tanchor:\t\t\t'97%'\n\t\t\t},\n\t\t\titems:[{$moduleFields}]\n\t\t\t{$button}\n\t\t}";