/** * Create a new Page Template * @param string Name * @param string Description * @param string Filename of the template * @param string Template * @param integer GUID of Cluster Template * @param integer Id of Type (1=singlepage, 2=multipage) * @param integer OPtional key to use. */ function createSitepageMaster($name, $description, $templatePath, $template, $clt, $type, $id = null) { global $db, $c, $errors; if ($id == null) { $id = nextGUID(); } $name = makeCopyName("sitepage_master", "NAME", parseSQL($name), "VERSION=0 AND DELETED=0"); $description = parseSQL($description); $filename = substr($templatePath, 0, strcspn($templatePath, ".")); $filesuffix = $templatePath = substr($templatePath, strcspn($templatePath, ".") + 1); $templatePath = makeUniqueFilename($c["devpath"], parseSQL($filename), $filesuffix); $fp = @fopen($c["devpath"] . $templatePath, "w+"); if ($fp != "") { @fwrite($fp, $template); @fclose($fp); } else { $errors .= "--Could not write spm: " . $templatePath; } $sql = "INSERT INTO sitepage_master (SPM_ID, NAME, DESCRIPTION, TEMPLATE_PATH, CLT_ID, SPMTYPE_ID) VALUES "; $sql .= "({$id}, '{$name}', '{$description}', '{$templatePath}', {$clt}, {$type})"; $query = new query($db, $sql); $query->free(); $variations = createDBCArray("variations", "VARIATION_ID", "1"); for ($i = 0; $i < count($variations); $i++) { $sql = "INSERT INTO sitepage_variations (SPM_ID, VARIATION_ID) VALUES ( {$id}, " . $variations[$i] . ")"; $query = new query($db, $sql); $query->free(); } return $id; }
/** * Create a figure in a Meta-Template * @param integer ID of the Meta-Template * @param string NAme * @param string Description * @param integer Position * @param integer Datatype-Id, compare table meta_template_item_types */ function createMetaTemplateFigure($mtid, $name, $position, $type) { global $db; $newId = nextGUID(); $name = makeCopyName("meta_template_items", "NAME", parseSQL($name), "MT_ID = {$mtid}"); $sql = "INSERT INTO meta_template_items (MTI_ID, MT_ID, NAME, POSITION, MTYPE_ID, VERSION) VALUES ({$newId}, {$mtid}, '{$name}', {$position}, {$type}, 0)"; $query = new query($db, $sql); $query->free(); return $newId; }
/** * Creates a cluster and a cluster-node for the given clt. returns the clnid. * Can only import dynamic content and dynamic clusters (GUIDs of Cluster_node!). * @param string name of the cluster * @param string GUID of Cluster template * @param string ID od Variation to use * @param string array with data to post to plugins, like array("Headline" => "Test Headline", ...) * @param string Username to use for create */ function createCluster2($name, $clt, $variationId, $data, $createUser = "******") { $name = makeCopyName("cluster_node", "NAME", parseSQL($name), "CLT_ID = {$clt}"); if (!is_numeric($clt)) { exit; } if (!is_numeric($variationId)) { exit; } $clnid = createClusterNode($name, $clt); $clid = createCluster($clnid, $variationId, $createUser); $datarows = array_keys($data); for ($i = 0; $i < count($datarows); $i++) { $type = getDBCell("cluster_template_items", "CLTITYPE_ID", "CLT_ID = {$clt} AND UPPER(NAME) = UPPER('" . $datarows[$i] . "')"); $clti = getDBCell("cluster_template_items", "CLTI_ID", "CLT_ID = {$clt} AND UPPER(NAME) = UPPER('" . $datarows[$i] . "')"); $clcid = getDBCell("cluster_content", "CLCID", "CLID={$clid} AND CLTI_ID = {$clti}"); if ($type == 2) { $pgType = strtoupper(getDBCell("modules", "MODULE_NAME", "MODULE_ID = " . getDBCell("cluster_template_items", "FKID", "CLT_ID = {$clt} AND UPPER(NAME) = UPPER('" . $datarows[$i] . "')"))); $moduleId = getDBCell("cluster_template_items", "FKID", "CLT_ID = {$clt} AND UPPER(NAME) = UPPER('" . $datarows[$i] . "')"); if ($pgType == "TEXT" || $pgType == "LABEL") { $data[$datarows[$i]] = urlencode($data[$datarows[$i]]); } $xml = '<NX:CONTENT TYPE="' . $pgType . '">' . $data[$datarows[$i]] . '</NX:CONTENT>'; $pgn = createPGNRef($moduleId, $clcid); $pgn->import($xml); } else { if ($type == 4) { if (is_numeric($data[$datarows[$i]])) { $sql = "UPDATE cluster_content SET FKID=" . $data[$datarows[$i]] . " WHERE CLCID = {$clcid}"; global $db; $query = new query($db, $sql); $query->free(); } } } } return $clnid; }
/** * Makes Copy of a cluster_node * * @param integer ID of the Clusternode to copy * @param string New name of the Clusternode */ function copyClusterNode($clnid, $newName) { if ($newName == "") { $newName = getDBCell("cluster_node", "NAME", "CLNID={$clnid}"); } $clt = getDBCell("cluster_node", "CLT_ID", "CLNID={$clnid}"); $newName = makeCopyName("cluster_node", "NAME", $newName, "CLT_ID={$clt}"); $values["CLNID"] = nextGUID(); $values["NAME"] = $newName; copyRow("cluster_node", "CLNID={$clnid}", $values); copyMeta($clnid, $values["CLNID"]); copyClusterVariations($clnid, $values["CLNID"]); return $values["CLNID"]; }
/** * Create a figure for a cluster-tempalte * @param string name of the figur * @param integer GUID of the Template * @param integer Position in the template * @param integer minimum cardinality of this figure * @param integer maximum cardinality of this figure * @param integer configuration value for this figure * @param integer type-ID of this figure (actually 1-8). Refer to table cluster_template_item_types */ function createClusterTemplateFigure($name, $clt, $position, $maxcard, $mincard, $config, $type) { global $db; $name = makeCopyName("cluster_template_items", "NAME", parseSQL($name), "CLT_ID = {$clt}"); $newId = nextGUID(); $sql = "INSERT INTO cluster_template_items (CLTI_ID, CLT_ID, NAME, POSITION, MINCARD, MAXCARD, FKID, CLTITYPE_ID, DELETED, VERSION) VALUES ({$newId}, {$clt}, '{$name}', {$position}, {$mincard}, {$maxcard}, {$config}, {$type}, 0,0)"; $query = new query($db, $sql); $query->free(); return $newId; }
/** * Handler for creating a valid contentpage for a site. */ function createContentPage() { global $oid, $db, $variation, $auth; $checked = value("createpage"); if ($checked) { $spm = value("sitemap_SPM_ID"); // determine spm-type $type = getDBCell("sitepage_master", "SPMTYPE_ID", "SPM_ID = $spm"); $clt = getDBCEll("sitepage_master", "CLT_ID", "SPM_ID = $spm"); if ($type == 1) { // create contentpage $name = value("sitemap_NAME"); if ($name == "") $name = "Cluster"; $usename = makeCopyName("cluster_node", "NAME", $name, $filter = "CLT_ID = $clt", "", false); $nextId = nextGUID(); $sql = "INSERT INTO cluster_node (CLNID, CLT_ID, NAME, DELETED) VALUES($nextId, $clt, '$usename', 0)"; $query = new query($db, $sql); $spid = getDBCell("sitepage", "SPID", "MENU_ID = $oid"); $sql = "UPDATE sitepage SET CLNID = $nextId WHERE SPID = $spid"; $query = new query($db, $sql); $query->free(); $variations = createDBCArray("sitepage_variations", "VARIATION_ID", "SPM_ID = $spm"); for ($i = 0; $i < count($variations); $i++) { $fk = nextGUID(); $sql = "INSERT INTO cluster_variations (CLNID, VARIATION_ID, CLID, DELETED, CREATE_USER, CREATED_AT ) VALUES ( $nextId, $variations[$i], $fk, 0, '$auth->userName', Now()+0)"; $query = new query($db, $sql); } $query->free(); global $errors, $sid, $c, $mid; if ($errors == "") { header ("Location: " . $c["docroot"] . "modules/sitepages/sitepagebrowser.php?sid=$sid&go=update&action=editobject&oid=$spid&mid=$oid"); exit; } } } }
/** * Draw the input boxes needed for editing the contents in the envelope. * @param integer id of cluster_content.CLCID */ function getSingleEdit($id) { global $specialID, $lang, $c, $sid, $aclf, $db, $lang; global $forceLoadFromDB, $auth; $clt = getDBCell("cluster_template_items", "FKID", "CLTI_ID = ".$this->clti); if ($this->saction == "createCluster" && $id == value("id")) { $name = parseSQL(value("cluster_node_NAME".$id)); if ($name=="0") $name = "Cluster"; $name = makeCopyName("cluster_node", "NAME", $name, "1", "", false); $clnid = createClusterNode($name, $clt); $variations = createDBCArray("variations", "VARIATION_ID"); for ($varX=0; $varX < count($variations); $varX++) { $clid = createCluster($clnid, $variations[$varX], $auth->userName); } $sql = "UPDATE cluster_content SET FKID = $clnid WHERE CLCID = $id"; $query = new query($db, $sql); $query->free(); $forceLoadFromDB = "yes"; } if ($this->editState && $this->editor) { $chclbox = new Container(4); $compoundEnvelope = new Container(3); $compoundContainer = new Container(3); $specialID = $id; $cpselector = new CPCLSelector($lang->get("select_cl"), "cluster_content", "FKID", "CLCID=$id", getModuleFromCLC($id), "", ""); $cpselector->additionalAttribute = "onchange=\" if ( !confirm('".$lang->get("confirm_unsaved_changes_linkedcluster", "Note: When changing the linked cluster, any changes you apply on the currently linked cluster will be lost. If you want to save these canges, save your work first and change the linked cluster then. Proceed ?")."') ) { for(i=0; i<document.form1.cluster_content_FKID$specialID.length; i++) if(document.form1.cluster_content_FKID$specialID.options[i].defaultSelected == true) document.form1.cluster_content_FKID$specialID.options[i].selected=true; }\""; $variation = variation(); // force save in dbo. //$clnid = getDBCell("cluster_content", "FKID", "CLCID = ".$id); if (!isset($clnid)) { $clnid = $cpselector->value; } else { $cpselector->value = $clnid; } $clid = getClusterFromNode($clnid, $variation); $chclbox->add( $cpselector ); $forceLoadFromDB = "no"; if ($clnid != "" && $clnid != "0") { $clid = getClusterFromNode($clnid, $variation); $name = getDBCell("cluster_node", "NAME", "CLNID = $clnid"); } $infoboxid = $id; $chclboxid = $id; $table = '<table width="100% border="0" cellpadding="0" cellspacing="0"><tr><td>'; $table.= $lang->get("cllink", "This box is linked to ")." <b>".$name."</b>"; $table.= '</td><td align="right">'; // Add-Button $ShowInfoButton = new LinkButtonInline("toggle_info_".$infoboxid, "show info", "box", "button", "toggle('showinfo_".$infoboxid."')"); $CHCLButton = new LinkButtonInline("toggle_chcl_".$chclboxid, "change cluster", "box", "button", "toggle('chcl_".$chclboxid."')"); $table.= $ShowInfoButton->draw()." ".$CHCLButton->draw(); $table.= '</td></tr></table>'; $this->add(new Label("lbl", $table, "headbox", 2)); if (getDBCell("cluster_content", "FKID", "CLCID = ".$id) != $clnid) $forceLoadFromDB = "yes"; $chclbox->add(new Cell("spacer", "standardlight", 1)); $chclbox->add(new Label("lbl", "or create a new instance called", "standardlight")); $chclbox->add(new Input("cluster_node_NAME$id", "", "standardlight", 32)); $chclbox->add(new SingleHidden("clt", "")); $chclbox->add(new SingleHidden("id", "")); $chclbox->add(new LinkButtonInCell("neueInstanz", "Create Instance", "standardlight navelement", "button", "javascript:if (confirm('".$lang->get("confirm_unsaved_changes")."')) { document.form1.saction.value='createCluster';document.form1.id.value='$id';document.form1.clt.value='$clt';document.form1.submit(); };", "form1", 1)); $sql = "SELECT * FROM variations WHERE 1"; $variations = new query($db, $sql); while ($variations->getrow()) { $chclbox->add(new Hidden("cluster_variations_VARIATION_ID_".$variations->field("VARIATION_ID"), "1")); } $specialID = ""; $compoundContainer->add(new IDWrapper("chcl_".$chclboxid, $chclbox, "embedded", ' style="display:'.(($clid == 0) ? "" : "none" ).';" ', 3)); if ($clid != "0" && $clid != "") { // GET CONTENT OF THE CLUSTER // set variables that will contain the content later to null. $clusters = null; $plugins = null; $types = null; // get the structure of the content. $sql = "SELECT CLTI_ID, CLTITYPE_ID FROM cluster_template_items WHERE CLT_ID = $clt AND FKID!=0 ORDER BY POSITION"; $query = new query($db, $sql); while ($query->getrow()) { $cltitype = $query->field("CLTITYPE_ID"); $ni = count($plugins); $plugins[$ni] = $query->field("CLTI_ID"); $types[$ni] = $cltitype; } $query->free(); // we don't want to draw an additional back link in clusters-editor // if (! $sitepage && ! $isArticle) { // $compoundContainer->add(new LinkLabel("link1", $lang->get("back_to_cv", "Back to cluster overview"), "modules/cluster/clusterbrowser.php?sid=$sid&clt=$clt", "_self", "informationheader", 2)); // } $infobox = new Container(3); // draw some cluster-information. $infobox->add(new Subtitle("", $lang->get("cluster_information", "Information about this record"), 3)); $infobox->add(new ClusterInformation($clid)); $compoundContainer->add(new IDWrapper("showinfo_".$infoboxid, $infobox, "embedded", ' style="display:none;" ', 3)); // draw plugin preview. $len = count($plugins); if ($clid) { for ($i = 0; $i < $len; $i++) { if ($types[$i] == 2) $compoundContainer->add(new ContentEnvelope($plugins[$i], $clid, true)); if ($types[$i] == 4) $compoundContainer->add(new ClusterEnvelope($plugins[$i], $clid, true)); if ($types[$i] == 5) $compoundContainer->add(new LibraryEnvelope($plugins[$i], $clid, true)); if ($types[$i] == 6) $compoundContainer->add(new CompoundClusterEnvelope($plugins[$i], $clid, true)); if ($types[$i] == 8) $compoundContainer->add(new ChannelEnvelope($plugins[$i], $clid, true)); } if ($isArticle || $action == $lang->get("edit_all") || ($action == $lang->get("save")) || $action == $lang->get("save_back")) { $compoundContainer->add(new NonDisplayedValue("cluster_variations", "LAST_CHANGED", "CLID = ".$clid, "(NOW()+0)", "NUMBER")); $compoundContainer->add(new NonDisplayedValue("cluster_variations", "LAST_USER", "CLID = ".$clid, $auth->userName, "TEXT")); } } } $compoundEnvelope->add(new IDWrapper("compoundEnvelope_$id", $compoundContainer, "embedded sub", '', 3)); $this->add(new IDWrapper("compoundCluster_$id", $compoundEnvelope, "boxed", '', 3)); } else { $name = "<" . $lang->get("not_selected", "No item selected yet."). ">"; $myfk = getDBCell("cluster_content", "FKID", "CLCID = " . $id); if ($myfk != 0 && $myfk != "") { $clt = getDBCell("cluster_node", "CLT_ID", "CLNID = " . $myfk); $cltname = getDBCell("cluster_templates", "NAME", "CLT_ID = ".$clt); $cat = getDBCell("cluster_templates", "CATEGORY_ID", "CLT_ID = " . $clt); $name = "<br><b>" . $lang->get("cli"). "</b> " .$cltname."/".getDBCell("cluster_node", "NAME", "CLNID = " . $myfk); $buttons = "<br><a href=\"" . $c["docroot"] . "modules/cluster/clusterbrowser.php?sid=$sid&action=editobject&go=update&oid=$myfk&pnode=$cat&clt=$clt\" class=\"box\">".$lang->get("goto_cl", "Goto Cluster")."</a>"; if ($aclf->checkAccessToFunction("B_PREVIEW_PAGE")) $buttons .= drawSpacer(10, 1). "<a href=\"#\" onClick=\"window.open('" . $c["docroot"] . "modules/cluster/previewcpcl.php?sid=$sid&oid=$myfk', 'cppreview', 'width=400,height=400,location=no,menubar=no,toolbar=no');return false;\" class=\"box\">".$lang->get("preview")."</a>"; } $this->add(new Label("lbl", $name, "", 1)); $this->add(new AlignedLabel('lbl', $buttons, 'right', '', 1)); } }
header("Location: ". $c["docroot"]."modules/common/noaccess.php?sid=$sid&guid=$pnode"); //// ACL Check //// $editing = value("editing"); $action = value("action"); // process object actions. if ($action != "0") { if ($action == $lang->get("createcopy")) { $page_state="start"; if (value("prcstate") == "data") { $name = value("copyname"); if ($name=="0") $name = "Cluster"; $name = makeCopyName("cluster_templates", "NAME", $name, "CATEGORY_ID = ".$pnode); $oid = copyClusterTemplate($oid, $name); $action = "editobject"; } else { $page_action = "INSERT"; $form = new StdEDForm($lang->get("copyclt", "Copy cluster template")); $form->headerlink = crHeaderLink($lang->get('ed_clt'), "modules/clustertemplate/clustertemplates.php?sid=$sid&oid=".value("oid", "NUMERIC")."&action=editobject"); $form->add(new Label("lbl", $lang->get("source", "Source"), "standardlight")); $form->add(new Label("lbl", getDBCell("cluster_templates", "NAME", "CLT_ID = $oid"), "standardlight")); $form->add(new Label("lbl", $lang->get("newname", "New Name"), "standardlight")); $form->add(new Input("copyname", "Cluster Template", "standard")); $form->add(new Hidden("action", $lang->get("createcopy"))); $form->add(new Hidden("oid", $oid)); $form->add(new Hidden("prcstate", "data")); $form->forbidDelete(true); $page->add($form);