/** * syncronize variations with entered data to the database. * The configuration for this function must be set manually. * I.E. there must be the $oid-Variable set and there must(!) * be also the global vars content_variations_VARIATION_ID_XX * and content_MODULE_ID * set which are automatically set by the SelectMultiple2Input. */ function syncVariations() { global $db, $oid, $content_MODULE_ID; $module = value("content_MODULE_ID", "NUMERIC"); if ($module == "0") { $module = $content_MODULE_ID; } includePGNSource($module); //delete all variations first. $del = "UPDATE content_variations SET DELETED=1 WHERE CID = {$oid}"; $query = new query($db, $del); // get list of variations $variations = createNameValueArray("variations", "NAME", "VARIATION_ID", "DELETED=0"); for ($i = 0; $i < count($variations); $i++) { $id = $variations[$i][1]; if (value("content_variations_VARIATION_ID_" . $id) != "0") { // create or restore variation // check, if variations already exists and is set to deleted. $sql = "SELECT COUNT(CID) AS ANZ FROM content_variations WHERE CID = {$oid} AND VARIATION_ID = {$id}"; $query = new query($db, $sql); $query->getrow(); $amount = $query->field("ANZ"); if ($amount > 0) { $sql = "UPDATE content_variations SET DELETED=0 WHERE CID = {$oid} AND VARIATION_ID = {$id}"; } else { $fk = nextGUID(); $sql = "INSERT INTO content_variations (CID, VARIATION_ID, FK_ID, DELETED) VALUES ( {$oid}, {$id}, {$fk}, 0)"; $PGNRef = createPGNRef($module, $fk); $PGNRef->sync(); } $query = new query($db, $sql); } } }
/** * Get the API-Object of a type 3 Plugin * @param string name of the Type-3 Plugin * @param mixed parameters as assosiative array ("id" => 12); */ function getAPI($name, $parameters = null) { $pluginId = getDBCell("modules", "MODULE_ID", "UPPER(MODULE_NAME) = '" . strtoupper($name) . "' AND MODULE_TYPE_ID = 3"); includePGNSource($pluginId); $ref = createPGNRef($pluginId, 0); if (is_object($ref)) { return $ref->draw($parameters); } else { return null; } }
/** * Standard Constructor * * @param string Name to display on top. * @param string Table where the FK is saved in * @param string Column where the FK id saved in to reference the plugin. * @param string Where-Clause to select a FK * @param string Name of the plugin. * @param string A reference to the form ýou are using. * @param boolean show preview of the plugin. * @param string style of the control. */ function PluginInput($label, $table, $column, $cond, $pgnname, & $form, $showpreview=false, $style="standard") { global $page_state, $page_action; $this->label = $label; $this->table = $table; $this->column = $column; $this->cond = $cond; $this->pgnname = $pgnname; $this->style = $style; $this->form = &$form; $this->v_label = new Label("lbl_".$column, $label, $this->style,2); //now retrieve the values.... $this->pgntypeid = getDBCell("modules", "MODULE_ID", "UPPER(MODULE_NAME) = '".strtoupper($pgnname)."'"); if ($this->pgntypeid =="") { $this->errortext = "<center> The Plugin $pgnname is not installed. </center>"; } else { includePGNSource($this->pgntypeid); $form->add($this->v_label); if ($page_action == "UPDATE") { $fkid = getDBCell($table, $column, $cond); if ($fkid !="") { $ref = createPGNRef($this->pgntypeid, $fkid); if ($showpreview) { $preview = $ref->preview(); $this->form->add(new Label("lbl", $preview, "", 2)); } $ref->edit($this->form); } } else { $fkid=value("PGFK".$this->table.$this->column, "NUMERIC"); if ($fkid=="0") { $fkid = nextGUID(); $ref = createPGNRef($this->pgntypeid, $fkid); } else { $ref = createPGNRef($this->pgntypeid, $fkid); } $ref->edit($this->form); $this->form->add(new Hidden("PGFK".$this->table.$this->column, $fkid)); global $page_state; if ($page_state == "processing") { // was commented out somewhat. addInsert($ref->management_table, $ref->pk_name, $fkid, "NUMBER"); addInsert($table, $column, $fkid, "NUMBER"); } } } // plugin does exist }
/** * Uninstalls a Plugin * @param integer GUID of the plugin to uninstall. */ function uninstallPlugin($oid) { global $db; // module uninstall handler includePGNSource($oid); $modRef = createPGNRef($oid, 0); if ($modRef != null) { $modRef->registration(); $modRef->_uninstaller(); // content deletion $delHandler = new ActionHandler("DELETE"); $sql = "SELECT CID FROM content WHERE MODULE_ID = {$oid}"; $query = new query($db, $sql); while ($query->getrow()) { $cid = $query->field("CID"); $delHandler->addDBAction("DELETE FROM meta WHERE CID = {$cid}"); $delHandler->addDBAction("UPDATE cluster_template_items SET FKID=0 WHERE FKID={$cid}"); $delHandler->addDBAction("DELETE FROM content_variations WHERE CID = {$cid}"); $delHandler->addDBAction("DELETE FROM content WHERE CID = {$cid}"); } // meta-templates deletion. $mtid = getDBCell("modules", "MT_ID", "MODULE_ID = {$oid}"); if ($mtid != 0) { $delHandler->addDBAction("DELETE FROM meta_template_items WHERE MT_ID = {$mtid}"); $delHandler->addDBAction("DELETE FROM meta_templates WHERE MT_ID = {$mtid}"); } $delHandler->addDBAction("DELETE FROM modules WHERE MODULE_ID = {$oid}"); $delHandler->process("DELETE"); $delHandler = new ActionHandler("DELETE"); // cluster deletion. $delHandler->addDBAction("UPDATE cluster_template_items SET FKID = 0 WHERE FKID = {$oid} AND CLTITYPE_ID=2"); $cltis = createDBCArray("cluster_template_items", "CLTI_ID", "CLTITYPE_ID = 2 AND FKID = {$oid}"); for ($i = 0; $i < count($cltis); $i++) { $id = $cltis[$i]; $delHandler->addDBAction("DELETE FROM cluster_content WHERE CLTI_ID = {$id}"); } $delHandler->process("DELETE"); writeDataTypeArray(); } }
/** * Creates an instance of the Selected module and variation. * returns the plugin-Class * @param integer ID of the content * @param integer Variation ID to select appropriate recordset for. * @return Object Object of type Plugin. */ function createPGNRef2($contentId, $variation=0) { global $c, $cds; if ($variation==0 && ! is_object($cds)) $variation = variation(); $modId = getDBCell("content", "MODULE_ID", "CID=".$contentId); $check = getDBCell("content_variations", "VARIATION_ID", "VARIATION_ID = $variation AND CID = $contentId"); if ($check =="") { $variation = getDBCell("content_variations", "VARIATION_ID", "CID = $contentId"); } $fkid = getDBCell("content_variations", "FK_ID", "CID = $contentId AND VARIATION_ID = ".$variation); if ($modId != "") { includePGNSource($modId); return createPGNRef($modId, $fkid); } }
if ($aclf->checkAccessToFunction("EDIT_OBJECT")) { $editpanel = new Panel($lang->get("edit_content")); $buttonbar = new ButtonBar("variations"); $buttonbar->selectBoxDescr = true; $buttonbar->setVariationSelector(createNameValueArrayEx("variations", "NAME", "VARIATION_ID", "1"), $variation); $editpanel->add($buttonbar); $editpanel->add(new Subtitle("st", $lang->get("title"))); $oname = new TextInput($lang->get("o_name"), "content", "NAME", $cond, "type:text,width:200,size:32", "MANDATORY&UNIQUE"); $oname->setFilter("CATEGORY_ID = $category_id"); $editpanel->add($oname); $editpanel->add(new TextInput($lang->get('access_key', 'Access Key', 'Key-Value with which you can access this content from the editor by typing [key].'), 'content', 'ACCESSKEY', $cond, "type:text,width:100,size:16",'UNIQUE')); $editpanel->backto = $c["docroot"] . "modules/content/objectbrowser.php?sid=$sid&resetfilter=1&pnode=$category_id"; // Edit $editpanel->add(new Subtitle("st", $lang->get("edit_content"))); includePGNSource ($content_MODULE_ID); $ref = createPGNRef($content_MODULE_ID, $fkid); if ($ref != "") { $ref->edit($editpanel); } else { $editpanel->add(new Label("std", $lang->get("error_init", "Could not initialize the content"), "standardlight")); } // Description $editpanel->add(new Subtitle("st", $lang->get("content_desc", "Description of Content"))); //$editpanel->add(new TextInput($lang->get("description"), "content", "DESCRIPTION", $cond, "type:textarea,width:300,size:3", "")); $editpanel->add(new TextInput($lang->get("keywords"), "content", "KEYWORDS", $cond, "type:textarea,width:300,size:3", "")); // MetaData $editpanel->add(new Hidden("resetfilter", '1')); $editpanel->add(new MetaDataEditor($oid, $template, 2));
/** * Draws the presentation or edit-fields in the body. */ function draw_myBody() { global $lang; $module = getDBCell("content", "MODULE_ID", "CID = " . $this->oid); if ($this->editor == $lang->get("ed_meta")) { // edit meta information syncMetas($this->oid, "OBJECT"); $std = 0; $mod = getDBCell("modules", "MT_ID", "MODULE_ID = $module"); $add = getDBCell("content", "MT_ID", "CID = " . $this->oid); $this->draw_metaInput($lang->get("mt_base"), $std); $this->draw_metaInput($lang->get("mt_module"), $mod); $this->draw_metaInput($lang->get("mt_additional"), $add); } else { // edit content includePGNSource ($module); $fkid = getDBCell("content_variations", "FK_ID", "CID = $this->oid AND VARIATION_ID = $this->variation"); $this->contentObject = createPGNRef($module, $fkid); // dispatching between preview and editing mode. global $editvariation, $updatevariation; if (isset($editvariation) || isset($updatevariation)) { global $page_state, $specialID; if (isset($editvariation)) $page_state = "start"; $this->add(new FormSplitter($lang->get("o_edit"). "<i> " . $this->title . "</i>", "i_edit.gif")); $specialID = $fkid; $this->contentObject->edit($this); $specialID = ""; $container = new HTMLContainer("container", "informationheader", 1); $container->add("<input type=\"SUBMIT\" name=\"updatevariation\" value=\"" . $lang->get("commit"). "\">"); $container->add("<input type=\"SUBMIT\" name=\"preview\" value=\"" . $lang->get("preview"). "\">"); $this->add($container); $this->add(new ButtonInCell("reset", $lang->get("reset"), "informationheader", "RESET")); } else { $this->add(new FormSplitter($lang->get("o_preview"). "<i>" . $this->title . "</i>", "i_edit.gif")); $this->add(new ButtonInCell("editvariation", $lang->get("o_edit"), "informationheader", "SUBMIT", "", 2)); $this->add(new Label("preview", $this->contentObject->preview(), "standardlight", 2)); $this->add(new ButtonInCell("editvariation", $lang->get("o_edit"), "informationheader", "SUBMIT", "", 2)); } } }