예제 #1
0
 /**
  * Write to disk the linx file, i.e. the content for the specified page.
  * Doesn't translates the atm-linx tags.
  * Also writes the "print" linx file
  *
  * @return boolean true on success, false on failure to write the content to this file.
  * @access private
  */
 function writeLinxFile()
 {
     $defaultLanguage = CMS_languagesCatalog::getDefaultLanguage();
     //get public page content (without linxes process)
     $pageContent = $this->getContent($defaultLanguage, PAGE_VISUALMODE_HTML_PUBLIC);
     //then write the page linx file
     $linxFile = new CMS_file($this->getLinxFilePath());
     $linxFile->setContent($pageContent);
     if (!$linxFile->writeToPersistence()) {
         $this->raiseError("Can't write linx file : " . $this->getLinxFilePath());
         return false;
     }
     //writes the "print" linx file if any
     if (USE_PRINT_PAGES && $this->_template->getPrintingClientSpaces()) {
         //get print page content (without linxes process)
         $printPageContent = $this->getContent($defaultLanguage, PAGE_VISUALMODE_PRINT);
         //then write the print page linx file
         $linxFile = new CMS_file($this->getLinxFilePath() . ".print", CMS_file::FILE_SYSTEM, CMS_file::TYPE_FILE);
         $linxFile->setContent($printPageContent);
         if (!$linxFile->writeToPersistence()) {
             $this->raiseError("Can't write print linx file : " . $this->getLinxFilePath() . ".print");
             return false;
         }
     }
     return true;
 }
예제 #2
0
    CMS_grandFather::raiseError('Error on page : ' . $cms_page->getID());
    $view->show();
}
//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)}',
예제 #3
0
     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 {
             $cms_message = $cms_language->getMessage(MESSAGE_ERROR_WRITE_TEMPLATE);
         }
     }
 } elseif (is_a($template, "CMS_pageTemplate") && $template->hasError()) {
     $cms_message = $cms_language->getMessage(MESSAGE_ERROR_UNKNOWN_TEMPLATE);
 } else {
     //CREATION
     $template = new CMS_pageTemplate();
     if ($label) {
         $template->setlabel($label);
         $template->setDebug(false);
         $template->setLog(false);
     }
     if (!$cms_message) {
         //description
         $template->setDescription($description);
         //remove the old file if any and if new one is different
         if ($image) {
             if (is_file(PATH_TEMPLATES_IMAGES_FS . '/' . $template->getImage()) && $image != PATH_TEMPLATES_IMAGES_WR . '/' . $template->getImage() && $template->getImage() != 'nopicto.gif') {
                 unlink(PATH_TEMPLATES_IMAGES_FS . '/' . $template->getImage());
             }
         }
         if ($image && io::strpos($image, PATH_UPLOAD_WR . '/') !== false) {
예제 #4
0
if (!$cms_user->hasAdminClearance(CLEARANCE_ADMINISTRATION_EDIT_TEMPLATES)) {
    //templates
    CMS_grandFather::raiseError('User has no rights template editions');
    $view->setActionMessage($cms_language->getMessage(MESSAGE_ERROR_NO_RIGHTS_FOR_TEMPLATES));
    $view->show();
}
//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());
예제 #5
0
                        $logAction = CMS_log::LOG_ACTION_RESOURCE_EDIT_BASEDATA;
                        $cms_message = $cms_language->getMessage(MESSAGE_ACTION_OPERATION_DONE);
                    } else {
                        $cms_message .= $cms_language->getMessage(MESSAGE_FORM_ERROR_WRITING);
                        $cms_page->raiseError('Error during writing of page ' . $cms_page->getID() . '. Action : update pageContent');
                    }
                }
                //Page template update
                $tpl_original = $cms_page->getTemplate();
                //first check if page template is updated
                if (sensitiveIO::isPositiveInteger($template) && CMS_pageTemplatesCatalog::getTemplateIDForCloneID($tpl_original->getID()) != $template) {
                    //hack if page has no valid template attached
                    if (!is_a($tpl_original, "CMS_pageTemplate")) {
                        $tpl_original = new CMS_pageTemplate();
                    }
                    $tpl = new CMS_pageTemplate($template);
                    $tpl_copy = CMS_pageTemplatesCatalog::getCloneFromID($tpl->getID(), false, true, false, $tpl_original->getID());
                    $cms_page->setTemplate($tpl_copy->getID());
                    //destroy old template only if it's a copy
                    if ($tpl_original->isPrivate()) {
                        $tpl_original->destroy();
                    }
                    //save the page data
                    if (!$cms_page->writeToPersistence()) {
                        $cms_message = $cms_language->getMessage(MESSAGE_FORM_ERROR_WRITING);
                        $cms_page->raiseError('Error during writing of page ' . $cms_page->getID() . '. Action : update template. New template set : ' . $template);
                    } else {
                        $cms_page->regenerate(true);
                        $jscontent = '
					Automne.tabPanels.getActiveTab().reload();
					';
예제 #6
0
    $httpsField = ",{\n\t\t{$disabledHttps}\n\t\tfieldLabel:\t\t'<span ext:qtip=\"{$cms_language->getJSMessage(MESSAGE_PAGE_FIELD_HTTPS_INFO)}\" class=\"atm-help\">{$cms_language->getJSMessage(MESSAGE_PAGE_FIELD_HTTPS)}</span>',\n\t\tname:\t\t\t'https',\n\t\tinputValue:\t\t'1',\n\t\txtype:\t\t\t'checkbox',\n\t\tchecked:\t\t{$httpsValue},\n\t\tboxLabel:\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_FIELD_HTTPS_DESC)}'\n\t}";
}
/***************************************\
*             PAGE PROPERTIES           *
\***************************************/
$pageId = $cms_page->getID();
$pageTitle = $cms_page->getTitle();
$pageLinkTitle = $cms_page->getLinkTitle();
$website = $cms_page->getWebsite();
$status = $cms_page->getStatus()->getHTML(false, $cms_user, MOD_STANDARD_CODENAME, $cms_page->getID());
$lineage = CMS_tree::getLineage($website->getRoot(), $cms_page);
//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 = $pageTemplate->getLabel();
//print
$print = $cms_page->getPrintStatus() ? $cms_language->getMessage(MESSAGE_PAGE_FIELD_YES) : $cms_language->getMessage(MESSAGE_PAGE_FIELD_NO);
//page relations
$linksFrom = CMS_linxesCatalog::searchRelations(CMS_linxesCatalog::PAGE_LINK_FROM, $cms_page->getID());
$linksTo = CMS_linxesCatalog::searchRelations(CMS_linxesCatalog::PAGE_LINK_TO, $cms_page->getID());
//page redirection
$redirectlink = $cms_page->getRedirectLink();
$redirectValue = '';
$module = MOD_STANDARD_CODENAME;
$visualmode = RESOURCE_DATA_LOCATION_EDITED;
if ($redirectlink->hasValidHREF()) {
    $redirect = $cms_language->getMessage(MESSAGE_PAGE_FIELD_YES) . ' ' . $cms_language->getMessage(MESSAGE_PAGE_FIELD_TO) . ' : ';
예제 #7
0
 /**
  * Return pages IDs coresponding of a given template ID
  *
  * @param integer/CMS_pageTemplate templateID : the template to get pagesIDs
  * @param boolean returnObjects : to return pages objects or pages IDs
  * @return array : pages IDs or pages objects
  * @access public
  */
 static function getPagesByTemplate($template, $returnObjects = false)
 {
     $return = array();
     $error = false;
     if (SensitiveIO::isPositiveInteger($template)) {
         $template = new CMS_pageTemplate($template);
         if ($template->hasError()) {
             $error = true;
         }
     } elseif (!is_a($template, 'CMS_pageTemplate') || $template->hasError()) {
         $error = true;
     }
     if ($error) {
         CMS_grandFather::raiseError('Template must be a valid CMS_pageTemplate ID or a valid CMS_pageTemplate object (line ' . __LINE__ . ')');
         return $return;
     } elseif ($definition = $template->getDefinitionFile()) {
         $sql = "\n\t\t\t\tselect\n\t\t\t\t\tid_pag\n\t\t\t\tfrom\n\t\t\t\t\tpages,\n\t\t\t\t\tpageTemplates\n\t\t\t\twhere\n\t\t\t\t\tdefinitionFile_pt = '" . $definition . "'\n\t\t\t\t\tand template_pag = id_pt\n\t\t\t\torder by\n\t\t\t\t\tid_pag\n\t\t\t";
         $q = new CMS_query($sql);
         if ($q->getNumRows()) {
             while ($id = $q->getValue('id_pag')) {
                 if ($returnObjects) {
                     if ($page = CMS_tree::getPageByID($id)) {
                         $return[$id] = $page;
                     }
                 } else {
                     $return[$id] = $id;
                 }
             }
         }
     }
     return $return;
 }