예제 #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
$availableWebsites = sensitiveIO::jsonEncode($availableWebsites);
$selectedWebsites = sensitiveIO::jsonEncode($selectedWebsites);
//DEFINITION TAB
$content = '
<textarea id="tpl-definition-' . $templateId . '" style="display:none;">' . htmlspecialchars($templateDefinition) . '</textarea>';
$view->setContent($content);
$title = sensitiveIO::isPositiveInteger($templateId) ? $cms_language->getJSMessage(MESSAGE_PAGE_TEMPLATE) . ' ' . $label : $cms_language->getJSMessage(MESSAGE_PAGE_CREATE_TEMPLATE);
$rowsURL = PATH_ADMIN_WR . '/templates-rows.php';
$printTab = '';
$cstags = $template->getClientSpacesTags();
if (!is_array($cstags)) {
    $cstags = array();
}
$clientspaces = array();
$printableCS = array();
$print_clientspaces = $template->getPrintingClientSpaces();
foreach ($cstags as $tag) {
    $id = $tag->getAttribute("id");
    //$module = $tag->getAttribute("module");
    if (!in_array($id, $print_clientspaces)) {
        $clientspaces[] = array($id);
    } else {
        $printableCS[] = array($id);
    }
}
$clientspaces = sensitiveIO::jsonEncode($clientspaces);
$printableCS = sensitiveIO::jsonEncode($printableCS);
$printTab = ",{\n\tid:\t\t\t\t'printcs-{$templateId}',\n\ttitle:\t\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_PRINT)}',\n\tlayout: \t\t'form',\n\txtype:\t\t\t'atmForm',\n\turl:\t\t\t'templates-controler.php',\n\tbodyStyle: \t\t'padding:5px',\n\tlabelAlign:\t\t'right',\n\tborder:\t\t\tfalse,\n\tbuttonAlign:\t'center',\n\titems:[{\n\t\txtype:\t\t\t'panel',\n\t\tborder:\t\t\tfalse,\n\t\thtml:\t\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_PRINT_DESC)}',\n\t\tbodyStyle: \t\t'padding:10px 0 10px 0'\n\t},{\n\t\txtype:\t\t\t'itemselector',\n\t\tname:\t\t\t'printableCS',\n\t\tfieldLabel:\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_PRINT_ZONES)}',\n\t\tdataFields:\t\t['code'],\n\t\ttoData:\t\t\t{$printableCS},\n\t\tmsWidth:\t\t250,\n\t\tmsHeight:\t\t130,\n\t\theight:\t\t\t140,\n\t\tvalueField:\t\t'code',\n\t\tdisplayField:\t'code',\n\t\ttoLegend:\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_SELECT)}',\n\t\tfromLegend:\t\t'{$cms_language->getJsMessage(MESSAGE_PAGE_AVAILABLE)}',\n\t\tfromData:\t\t{$clientspaces}\n\t}],\n\tbuttons:[{\n\t\ttext:\t\t\t'{$cms_language->getJSMessage(MESSAGE_PAGE_SAVE)}',\n\t\ticonCls:\t\t'atm-pic-validate',\n\t\txtype:\t\t\t'button',\n\t\tname:\t\t\t'submitAdmin',\n\t\thandler:\t\tfunction() {\n\t\t\tvar form = Ext.getCmp('printcs-{$templateId}').getForm();\n\t\t\tform.submit({\n\t\t\t\tparams:{\n\t\t\t\t\taction:\t\t'printcs',\n\t\t\t\t\ttemplateId:\ttemplateWindow.templateId\n\t\t\t\t},\n\t\t\t\tscope:this\n\t\t\t});\n\t\t}\n\t}]\n}";
$automnePath = PATH_MAIN_WR;
$jscontent = <<<END
\tvar templateWindow = Ext.getCmp('{$winId}');
예제 #3
0
 /**
  * public static getCloneFromID
  *
  * Clones a Template, changes some attributes
  * and writes it to persistence (MySQL for now)
  *
  * @param anyTemplateID as the ID of Template to be cloned
  * @param String label receive a new label for this Template
  * @param boolean $setPrivate Should the template be set as a private one ?  ALSO determines if the new template should point to the same file
  * @param boolean $dontCopyClientSpaces Should the clientspaces be copied ?
  * @param integer $tplFrom the original template ID to get good rows
  * @return a valid new CMS_pageTemplate
  */
 static function getCloneFromID($templateID = 0, $label = false, $setPrivate = false, $dontCopyClientSpaces = false, $tplFrom = false)
 {
     $ret = false;
     $model = new CMS_pageTemplate($templateID);
     if ($model->getID() > 0) {
         //New blank one
         $tpl = new CMS_pageTemplate();
         //First write a new object to get it's ID
         $tpl->writeToPersistence();
         //Setting label
         $label = $label ? $label : $model->getLabel();
         $tpl->setLabel($label);
         //Copying template definition file (if not private template)
         if ($setPrivate) {
             $filename = $model->getDefinitionFile();
         } else {
             $filename = "pt" . $tpl->getID() . "_" . SensitiveIO::sanitizeAsciiString($tpl->getLabel()) . ".xml";
         }
         if ($setPrivate || CMS_file::copyTo(PATH_TEMPLATES_FS . "/" . $model->getDefinitionFile(), PATH_TEMPLATES_FS . "/" . $filename)) {
             $tpl->setDefinitionFile($filename);
             //Copying groupsStack from database
             foreach ($model->getGroups() as $grp) {
                 $tpl->addGroup($grp);
             }
             //Copying image file from model to a new one
             if ($setPrivate) {
                 $tpl->setImage($model->getImage());
             } else {
                 if ($model->getImage()) {
                     $ext = io::substr($model->getImage(), strrpos($model->getImage(), "."));
                     $imagefilename = "pt" . $tpl->getID() . "_" . SensitiveIO::sanitizeAsciiString($tpl->getLabel()) . $ext;
                     if (CMS_file::copyTo(PATH_TEMPLATES_IMAGES_FS . "/" . $model->getImage(), PATH_TEMPLATES_IMAGES_FS . "/" . $imagefilename)) {
                         $tpl->setImage($imagefilename);
                     }
                 } else {
                     $tpl->setImage();
                 }
             }
             //set private if asked to.
             if ($setPrivate) {
                 $tpl->setPrivate(true);
             }
             //copy description
             $tpl->setDescription($model->getDescription());
             //websites denied
             $websitesDenied = $model->getWebsitesDenied();
             foreach ($websitesDenied as $websiteId) {
                 if (CMS_websitesCatalog::exists($websiteId)) {
                     //to check if website still exists
                     $tpl->denyWebsite($websiteId);
                 }
             }
             //Copy printing definition
             $tpl->setPrintingClientSpaces($model->getPrintingClientSpaces());
             //Partial update for groups and image
             $tpl->writeToPersistence();
             //Copying template clientspaces rows definitions
             if (!$dontCopyClientSpaces) {
                 $suffixes = array('archived', 'deleted', 'edited', 'edition', 'public');
                 foreach ($suffixes as $suffix) {
                     if ($tplFrom) {
                         $sql = "\n\t\t\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t\t\t*\n\t\t\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t\t\t`mod_standard_clientSpaces_" . $suffix . "`\n\t\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\t\t`template_cs`='" . $tplFrom . "'\n\t\t\t\t\t\t\t";
                     } else {
                         $sql = "\n\t\t\t\t\t\t\t\tselect\n\t\t\t\t\t\t\t\t\t*\n\t\t\t\t\t\t\t\tfrom\n\t\t\t\t\t\t\t\t\t`mod_standard_clientSpaces_" . $suffix . "`\n\t\t\t\t\t\t\t\twhere\n\t\t\t\t\t\t\t\t\t`template_cs`='" . $model->getID() . "'\n\t\t\t\t\t\t\t";
                     }
                     $q = new CMS_query($sql);
                     while ($arr = $q->getArray()) {
                         $sql1 = "\n\t\t\t\t\t\t\t\tinsert into\n\t\t\t\t\t\t\t\t\t`mod_standard_clientSpaces_" . $suffix . "`\n\t\t\t\t\t\t\t\tset\n\t\t\t\t\t\t\t\t\t`template_cs`='" . $tpl->getID() . "',\n\t\t\t\t\t\t\t\t\t`tagID_cs`='" . SensitiveIO::sanitizeSQLString($arr["tagID_cs"]) . "',\n\t\t\t\t\t\t\t\t\t`rowsDefinition_cs`='" . SensitiveIO::sanitizeSQLString($arr["rowsDefinition_cs"]) . "',\n\t\t\t\t\t\t\t\t\t`type_cs`='" . $arr["type_cs"] . "',\n\t\t\t\t\t\t\t\t\t`order_cs`='" . $arr["order_cs"] . "'\n\t\t\t\t\t\t\t";
                         $q1 = new CMS_query($sql1);
                         unset($q1);
                     }
                     unset($q);
                 }
             }
             //CMS_Template to return
             $ret = $tpl;
         }
         unset($model);
     }
     if ($tpl) {
         //Clean if any error when out
         if (!$ret) {
             $tpl->destroy();
         }
         unset($tpl);
     }
     return $ret;
 }