/** * Perform the export. */ function execute() { global $errors, $lang, $sid; $minus = 0; $pages = createDBCArray("sitepage", "SPID", "MENU_ID = " . $this->menuId); for ($i = 0; $i < count($pages); $i++) { $cluster = getDBCell("sitepage", "CLNID", "SPID=" . $pages[$i]); $articles = countRows("channel_articles", "ARTICLE_ID", "ARTICLE_ID=" . $cluster); if ($articles == 0) { importClusterToArticle($pages[$i], $this->channelId, $this->categoryId); } else { $minus++; $error = $lang->get("already_imported", "At least one page has not been imported, because it already exists in an channel."); } } if ($errors == "") { $this->add(new WZLabel($lang->get("ch_imp_success", "The data was successfully imported to the channel."))); if (strlen($error) > 0) { $this->add(new WZLabel($error)); } $this->add(new WZLabel($lang->get("num_imp_pages", "Total number of imported pages:") . " " . (count($pages) - $minus))); } else { $this->add(new WZLabel($lang->get("ch_imp_failed", "There was an error while importing the data to the channel."))); } $this->parent->finished = true; $this->add(new WZLabel($lang->get("back_to_channels", "Back to Article Overview") . " >>", "modules/channels/overview.php?sid={$sid}")); }
function parentClusters($clArray, $level = 0) { $clnids = array(); if ($level > 5) { return $clnids; } for ($i = 0; $i < count($clArray); $i++) { $cl = $clArray[$i]; // find dynamic clusters.... $clids = createDBCArray("cluster_content", "CLID", "FKID = {$cl}"); for ($j = 0; $j < count($clids); $j++) { array_push($clnids, getDBCell("cluster_variations", "CLNID", "CLID = " . $clids[$j])); } // find static clusters... $clts = createDBCArray("cluster_template_items", "CLT_ID", "FKID = " . $cl); for ($j = 0; $j < count($clts); $j++) { $clns = createDBCArray("cluster_node", "CLNID", "CLT_ID = " . $clts[$j]); $clnids = array_merge($clnids, $clns); } } if (is_array($clnids)) { $clnids = array_unique($clnids); } // traverse down the tree, max 10 levels... $parents = parentClusters($clnids, $level + 1); $clnids = array_merge($clnids, $parents); if (is_array($clnids)) { $clnids = array_unique($clnids); } return $clnids; }
/** * returns an field containing arrays containg the ids of clusters of this channel. * Use cluster->getById() to retrieve the content of the cluster. * @param string Name of the cluster * @param integer ID of the Variation to query. Leave Blank or set to zero for Page-Variation. * @param string name of the column to order the cluster-nodes. */ function getField($name, $variation = 0, $order = "POSITION ASC") { global $c; if ($variation == 0) { $variation = $this->variation; } $name = strtolower($name); // get the clti.. $clid = getDBCell("cluster_variations", "CLID", "CLNID = " . $this->parent->pageClusterNodeId . " AND VARIATION_ID = {$variation}"); $clt = getDBCell("cluster_node", "CLT_ID", "CLNID = " . $this->parent->pageClusterNodeId); $clti = getDBCell("cluster_template_items", "CLTI_ID", "CLT_ID = {$clt} AND UPPER(NAME) = '{$name}'"); if ($clti == "") { return "Field not defined!"; } $type = getDBCell("cluster_template_items", "CLTITYPE_ID", "CLTI_ID = {$clti}"); if ($type == 8) { // query parameters... $stageIds = createDBCArray("cluster_content", "CLCID", "CLTI_ID = {$clti} AND CLID = {$clid} ORDER BY POSITION ASC"); $result = array(); for ($i = 0; $i < count($stageIds); $i++) { $result[] = $this->_getArticleClusters($stageIds[$i], $variation); } return $result; } else { echo "This field is not a channel-centerstage!"; } }
/** * Apply the filter-plugins on a given input * @param string Text to filter */ function applyFilterPlugins($text) { $objectParser = new ObjectParser(); $text = $objectParser->parse($text); $plugins = createDBCArray("modules", "MODULE_ID", "MODULE_TYPE_ID=4"); for ($i = 0; $i < count($plugins); $i++) { includePGNSources(); $plugin = createPGNRef($plugins[$i], 0); $text = $plugin->parseText($text); } return $text; }
/** * Add a page to the Sitemap and start adding the children */ function addWebsite($startNode, &$map) { global $c, $variations; $childs = createDBCArray("sitemap", "MENU_ID", "PARENT_ID=" . $startNode . " AND VERSION=10 AND DELETED=0"); for ($i = 0; $i < count($childs); $i++) { for ($j = 0; $j < count($variations); $j++) { if (!isMenuExpired($childs[$i], $variations[$j])) { $url = $c["livehost"] . $c["livedocroot"] . getPageURL($childs[$i], $variations[$j]); $map->AddURL($url); } addWebsite($childs[$i], $map); } } }
function TagEditor($title, $store_table, $pkKey, $pkValue, $fkKey, $values) { $this->title = $title; $this->store_table = $store_table; $this->pkKey = $pkKey; $this->pkValue = $pkValue; $this->fkKey = $fkKey; $this->values = $values; global $page_state, $page_action, $db; if ($page_state == "processing") { // Get Values form PoST $this->selectedValues = explode(",", value($this->store_table.$this->pkKey.'selection', "NOSPACES")); } else { if (($page_action == "UPDATE" || $page_action == "DELETE") && $this->cond != "1") { // Load Values from database $this->selectedValues = createDBCArray($this->store_table, $this->fkKey, $this->pkKey.'='.$this->pkValue); } } // selected values jetzt fett machen.... if (is_array($this->selectedValues)) { $this->selectedValues = createNameValueArrayEx("pgn_recipes_tags", "TAG", "TAG_ID", "TAG_ID IN (".implode(",", $this->selectedValues).")", "ORDER BY TAG ASC"); } else { $this->selectedValues = array(); } // extract selected Values from given values $newValues = array(); for ($i=0; $i<count($this->values); $i++) { $found = false; for ($j=0; $j<count($this->selectedValues); $j++) { if ($this->values[$i][1] == $this->selectedValues[$j][1]) $found = true; } if (!$found) $newValues[] = $this->values[$i]; } $this->values = $newValues; }
/** * To be used in start file (e.g. index.php) to determine the first pageId * to use. * @param integer ID of the variation the Startpage should be find in. * @returns integer Sitepage-ID of the first sitepage to use. */ function getStartPage($variation=0) { global $c; if ($variation == 0) $variation = $c["stdvariation"]; $zeroTrans = getDBCell("state_translation", "OUT_ID", "IN_ID=0 AND LEVEL=10"); if ($this->parent->level < 10) { $menues = createDBCArray("sitemap", "MENU_ID", "IS_DISPLAYED=1 AND PARENT_ID=0 ORDER BY POSITION"); } else { $menues = createDBCArray("sitemap", "MENU_ID", "IS_DISPLAYED=1 AND PARENT_ID=$zeroTrans ORDER BY POSITION"); } for ($i = 0; $i < count($menues); $i++) { $spids = createDBCArray("sitepage", "SPID", "MENU_ID = " . $menues[$i] . " ORDER BY POSITION"); for ($j = 0; $j < count($spids); $j++) { if (!$this->isSPExpired($spids[$j], $variation, $this->level)) return $spids[$j]; } } return 0; }
/** * standard constructor */ function Configurator() { // load the data of the field. global $page_state, $page_action, $oid; if ($page_state == "processing") { $keys = createDBCArray("sys_functions", "FUNCTION_ID", "1"); $this->configData = array (); for ($i = 0; $i < count($keys); $i++) { if (value($keys[$i]) != "0") array_push($this->configData, $keys[$i]); } $this->resolveParents(); } else { // fetch values from the database... $this->configData = createDBCArray("role_sys_functions", "FUNCTION_ID", "ROLE_ID = $oid"); if (!is_array($this->configData)) $this->configData = array (); } }
function syncLanguages() { global $db, $auth; $variations = createDBCArray('variations', 'VARIATION_ID'); // enable languages in all templates $spms = createDBCArray('sitepage_master', 'SPM_ID', 'VERSION=0'); for ($i=0; $i<count($spms); $i++) { for ($j=0; $j<count($variations); $j++) { $check = getDBCell("sitepage_variations", "VARIATION_ID", "SPM_ID=".$spms[$i]." AND VARIATION_ID=".$variations[$j]); if ($check=="") { $update = new query($db, 'INSERT INTO sitepage_variations (SPM_ID, VARIATION_ID) VALUES ('.$spms[$i].','.$variations[$j].')'); } } } // enable languages for all contents $cids = createDBCArray("content", "CID", "VERSION=0"); for ($i=0; $i<count($cids); $i++) { $module = getDBCell("content", "MODULE_ID", "CID=".$cids[$i]); for ($j=0; $j<count($variations); $j++) { $check = getDBCell("content_variations", "VARIATION_ID", "CID=".$cids[$i]." AND VARIATION_ID=".$variations[$j]); if ($check=="") { $fk = nextGUID(); $sql = "INSERT INTO content_variations (CID, VARIATION_ID, FK_ID, DELETED) VALUES ( $cids[$i], $variations[$j], $fk, 0)"; $PGNRef = createPGNRef($module, $fk); $PGNRef->sync(); $update = new query($db, $sql); } } } // enable languages for all clusters $clnids = createDBCArray('cluster_node', 'CLNID', 'VERSION=0 AND DELETED=0'); for ($i=0; $i<count($clnids); $i++) { for ($j=0; $j<count($variations); $j++) { $check = getDBCell("cluster_variations", 'VARIATION_ID', 'CLNID='.$clnids[$i].' AND VARIATION_ID='.$variations[$j]); if ($check=="") { $fk = nextGUID(); $sql = "INSERT INTO cluster_variations (CLNID, VARIATION_ID, CLID, DELETED,CREATED_AT, CREATE_USER ) VALUES ( $clnids[$i], $variations[$j], $fk, 0, NOW()+0, '".$auth->userName."')"; $update = new query($db, $sql); syncCluster($fk); } } } // enable languages for all menutexts $spids = createDBCArray("sitepage", "SPID", "VERSION=0 AND DELETED=0"); for ($i=0; $i<count($spids); $i++) { for ($j=0; $j<count($variations); $j++) { $check = getDBCell("sitepage_names", "VARIATION_ID", "VARIATION_ID= $variations[$j] AND SPID=$spids[$i]"); if ($check =="") { $update = new query($db, 'INSERT INTO sitepage_names (SPID,VARIATION_ID,NAME,HELP,DELETED,VERSION) VALUES ('.$spids[$i].','.$variations[$j].',"","",0,0)'); } } } }
/** * Launch a Content-Item * @param integer CID to launch * @param integer ID of the level to launch to. * @param integer ID of the variation to launch. * @returns integer Translated ID after launch */ function launchContent($in, $level, $variation) { global $db, $auth; if (!checkACL($in)) { $out = translateState($in, $level); $sql = "SELECT * FROM content WHERE CID = $in"; $query = new query($db, $sql); $query->getrow(); $module = $query->field("MODULE_ID"); $category = $query->field("CATEGORY_ID"); $mtid = $query->field("MT_ID"); $name = addslashes($query->field("NAME")); $keywords = addslashes($query->field("KEYWORDS")); $description = addslashes($query->field("DESCRIPTION")); $delme = $query->field("DELETED"); $accesskey = $query->field("ACCESSKEY"); // do some launches $mtTrans = launchMetaTemplate($mtid, $level); $sql = "DELETE FROM content WHERE CID = $out"; $query = new query($db, $sql); $sql = "INSERT INTO content (CID, MODULE_ID, CATEGORY_ID, MT_ID, NAME, DESCRIPTION, KEYWORDS, CREATED, LAST_MODIFIER, VERSION, DELETED, ACCESSKEY) VALUES "; $sql .= "($out, $module, $category, $mtTrans, '$name', '$description', '$keywords', NOW(), '$auth->user', $level, $delme, '$accesskey')"; $query = new query($db, $sql); // launch the content. $dbc = createDBCArray("content_variations", "VARIATION_ID", "DELETED=0 AND CID=".$in); for ($i=0; $i<count($dbc);$i++) { launchContentVariation($in, $module, $level, $dbc[$i]); } // launch metas $sql = "SELECT MID FROM meta WHERE CID = $in AND DELETED=0"; $query = new query($db, $sql); while ($query->getrow()) { launchMeta($query->field("MID"), $level); } $query->free(); return $out; } else return translateState($in, $level); }
$handler = new ActionHandler("INSERT"); $handler->addFncAction("syncClusterVariations"); $form->registerActionHandler($handler); $page->add($form); // edit the properties of an object. $handled = true; } else if ($action != "foo" && ($action != "0" || $view != "0")) { if ($action == "") $action = value("acstate"); if ($action == "createCluster") { $id = value("id"); $clnid = createClusterNode(value("cluster_node_NAME".$id), $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->getrow(); // Trying to set action to Edit All, but it obviously doesn't work. $action = value("acstate"); } $handled = true; $page_action = "UPDATE";
/** * Return an array containing all Meta-Field-Names of this cluster */ function getFieldnames() { $clt = getDBCell("cluster_node", "CLT_ID", "CLNID = ".$this->pageClusterNodeId); $mt = getDBCell("cluster_templates", "MT_ID", "CLT_ID = $clt"); return createDBCArray("meta_template_items", "NAME", "MT_ID = $mt", "ORDER BY POSITION ASC"); }
/** * Query for the selected values */ function querySelectedValues() { $this->selectedValues = array(); if ($this->cond != "1") { $ids = createDBCArray($this->table, $this->idcolumn, $this->cond, "ORDER BY POSITION"); for ($i=0; $i < count($ids); $i++) { $sub[0] = getDBCell($this->lookupTable, $this->lookupName, $this->lookupID." = ".$ids[$i]); $sub[1] = $ids[$i]; $tmp = array(); foreach ($this->selectValues as $key) { if ($sub[1] != $key[1]) $tmp[] = $key; } $this->selectValues = $tmp; $this->selectedValues[] = $sub; } } }
/** * Returns an array with the GUIDs of all channels in the system */ function getChannels() { return createDBCArray("channels", "CHID"); }
$editPanel->add(new Label("lbl", "<b>Translate: </b>" . getDBCell("internal_resources", "VALUE", "RESID='" . $items[$i] . "' AND LANGID='EN'"), "standardlight", 2)); $editPanel->add(new TextInput($items[$i], "internal_resources", "VALUE", "RESID='" . $items[$i] . "' AND LANGID='$oid'", "type:textarea,size:2,width:400")); $editPanel->add(new TextInput("Tooltip", "internal_resources", "TOOLTIP", "RESID='" . $items[$i] . "' AND LANGID='$oid'", "type:textarea,size:2,width:400")); $editPanel->add(new Separator()); } $editPanel->add(new FormButtons(true)); $editPanel->add(new Hidden("oid", $oid)); // add the panel to the form and the form to the page. $form->addPanel($editPanel); $page->add($form); } else { $form = new Form($lang->get("stats", "Statistics")); $page_action = "UPDATE"; $langs = createDBCArray("internal_resources_languages", "LANGID", "1"); for ($i = 0; $i < count($langs); $i++) { if ($vs != "0") syncronizeLanguage ($langs[$i]); $langname = getDBCell("internal_resources_languages", "NAME", "LANGID = '" . $langs[$i] . "'"); $form->add(new Label("lbl", "Statistics for " . $langname, "standard", 2)); $translated = countRows("internal_resources", "RESID", "LANGID='" . $langs[$i] . "' AND VALUE IS NOT NULL AND VALUE <>''"); $nottranslated1 = countRows("internal_resources", "RESID", "LANGID='" . $langs[$i] . "' AND VALUE IS NULL"); $nottranslated2 = countRows("internal_resources", "RESID", "LANGID='" . $langs[$i] . "' AND VALUE =''"); $nottranslated = $nottranslated1 + $nottranslated2; $form->add(new Label("lbl", "Translated: " . $translated, "standardlight")); $form->add(new Label("lbl", "Not translated: " . $nottranslated, "standardlight")); $form->add(new Separator()); }
$page = new page("Compound Groups"); $filter = new Filter("compound_groups", "CGID"); $filter->addRule($lang->get("name"), "NAME", "NAME"); $filter->setAdditionalCondition("VERSION = 0"); $filter->type_name = $lang->get("cp_group");; $filter->icon = "li_cggroup.gif"; $filtermenu = new Filtermenu($lang->get("cp_group"), $filter); $name = getDBCell("compound_groups", "NAME", "CGID = $oid"); $form = new stdEDForm($lang->get("ed_cpgroup", "Edit Compound Group").":".$name); $cond = $form->setPK("compound_groups", "CGID"); if ($oid != "") { $form->headerlink = crHeaderLink($lang->get("ed_cpgroupgeneral", "Edit Group General"), "modules/compoundgroup/compound_groups.php?sid=$sid&oid=$oid&go=update"); } $compoundClts = createDBCArray("cluster_templates", "CLT_ID", "CLT_TYPE_ID=1"); if (count($compoundClts) > 0 ) { $members = createNameValueArrayEx("cluster_node", "NAME", "CLNID", "VERSION=0 AND CLT_ID IN (".implode(", ", $compoundClts).")", "ORDER BY NAME ASC"); } else { $members = array(); } $form->add(new SelectMultipleInputPos($lang->get("cpg_members_select", "Select members of this compound group"), $members, "compound_group_members", "CGMID", "CGID", $cond, "cluster_node", "CLNID", "NAME", "standardlight", 2)); $form->forbidDelete(true); $page->addMenu($filtermenu); $page->add($form); $page->draw(); $db->close(); ?>
/** * Called to get the necessary html-headers of the plugins that are used within * the class on which the page is based */ function _autoInitPlugins() { $clt = getDBCell('cluster_node', 'CLT_ID', 'CLNID='.$this->parent->pageClusterNodeId); $ar = createDBCArray('cluster_template_items', 'FKID', 'CLT_ID='.$clt.' AND CLTITYPE_ID IN (1,2,5)'); for ($i=0; $i < count($ar); $i++) { $ref = createPGNRef($ar[$i], 0); if (is_object($ref)) { $out = $ref->getHTMLHeader(); if (strlen($out) > 0 ) $this->header.= "\n".$ref->getHTMLHeader(); unset($ref); } } }
if (count($modules) > 0) { $f = 0; $module_id = getDBCell("modules", "MODULE_ID", "UPPER(MODULE_NAME) = '" . $modules[$f] . "'"); $filtersql = " AND (MODULE_ID = $module_id "; for ($f = 1; $f < count($modules); $f++) { $module_id = getDBCell("modules", "MODULE_ID", "UPPER(MODULE_NAME) = '" . $modules[$f] . "'"); $filtersql .= "OR MODULE_ID = $module_id "; } $filtersql .= ")"; } } $content = createDBCArray("content", "CID", "VERSION=0 AND DELETED=0 AND CATEGORY_ID = " . $pnode . $filtersql, "ORDER BY NAME"); includePGNSources(); for ($i = 0; $i < count($content); $i++) { $form->add(new LibraryViewer($content[$i], 1, $linkset, "image")); } if (count($content) == 0) { $form->add(new Label("lbl", "<center>" . $lang->get("no_contents", "No Contents available in this folder."). "</center>", "standard", 3)); } if (isset($topText)) { $form->addToTopText($topText); $form->topicon = "ii_success.gif"; }
/** * DEPRECATED! use getLowerLevel instead. * Gets the IDs of the child-pages and returns them as linear array. * @param integer Sitepage-ID to get the children from. * @param string Column, to order the results. */ function getChildrenPages($spid) { $menuId = getDBCell("sitepage", "MENU_ID", "SPID = $spid"); $childs = createDBCArray("sitepage sp, sitemap sm", "SPID", "sm.PARENT_ID = $menuId AND sp.MENU_ID = sm.MENU_ID AND sm.IS_DISPLAYED=1 ORDER BY sm.POSITION"); global $splevel, $v; if ($splevel == 10) { // check live-pages for expiration. $checked = array (); for ($i = 0; $i < count($childs); $i++) { // get clid $myspid = $childs[$i]; $clnid = getDBCell("sitepage", "CLNID", "SPID = $myspid"); $clid = getDBCell("cluster_variations", "CLID", "CLNID = $clnid AND VARIATION_ID = $v"); if (!isExpired($clid)) array_push($checked, $myspid); } return $checked; } else return $childs; }
/** * Loads the source code of all Plugins with input-fields */ function includePGNISources() { global $c; require_once $c["path"]."plugin/plugin.inc.php"; $sources = createDBCArray("modules", "SOURCE", "MODULE_TYPE_ID=1"); for ($i = 0; $i < count($sources); $i++) { require_once $c["path"] . "plugin/" . $sources[$i]; } }
/** * Check, whether an accessor is allowed to perform a special operation on the Object. * @param integer GUID of the user or group * @param string Title of the action to check for. */ function checkAccessToFunction2($guid, $action) { global $db, $auth; if ($auth->user == "Administrator") return true; $action = strtoupper($action); $result = false; $accessor = new Accessor($guid); // determine accessors the user is in. $accessorGroups = $accessor->isInGroups(); $accessorGroupsStr = implode(',', $accessorGroups); // check for owner if (in_array($this->owner, $accessorGroups)) { if ($accessor->canDoInGroup($action, $this->owner)) return true; } // determine roles, the function is in. $actionRoles = createDBCArray("role_sys_functions", "ROLE_ID", "UPPER(FUNCTION_ID) = '$action'"); if (! is_array($actionRoles)) { $actionRoles = array(); } array_push($actionRoles, 1); // Administrator Role $actionRolesStr = implode(",", $actionRoles); $resourceGroups = array(); for ($i=0; $i < count($this->accessors); $i++) { if (in_array($this->accessors[$i]["ROLE"], $actionRoles)) { array_push($resourceGroups, $this->accessors[$i]["ACCESSOR"]); } } $bothGroups = array(); if (is_array($resourceGroups)) $bothGroups = array_intersect($resourceGroups, $accessorGroups); if (is_array($bothGroups)) { foreach ($bothGroups as $group) { $sql = "SELECT up.USER_ID FROM user_permissions up, acl_relations r WHERE up.USER_ID = $guid AND up.GROUP_ID = ".$group." AND up.ROLE_ID IN ($actionRolesStr) AND r.ROLE_ID IN ($actionRolesStr) AND r.ACCESSOR_GUID IN ($accessorGroupsStr) AND r.GUID= ".$this->effectiveACLGuid; $query = new query($db, $sql); if ($query->getrow()) { return true; } else { } $query->free(); } } /** // check for foreign relations.... if ($accessorGroupsStr != "") { $accessorRolesOnResource = createDBCArray("acl_relations", "ROLE_ID", "GUID = $this->guid AND ACCESSOR_GUID IN ($accessorGroupsStr)"); if (in_array(1, $accessorRolesOnResource)) // Admin Rechte $result = true; if (is_array($accessorRolesOnResource)) { $accessorRolesOnResourceStr = implode(',', $accessorRolesOnResource); $accessorFunctionsOnResource = createDBCArray("role_sys_functions", "FUNCTION_ID", "ROLE_ID IN ($accessorRolesOnResourceStr)"); if (is_array($accessorFunctionsOnResource)) { if (in_array(strtoupper($action), $accessorFunctionsOnResource)) $result = true; } } }*/ return false; }
/** * Export a cluster-Node with all its variations * @param integer GUID of the Cluster-Node (CLNID) */ function XmlExportClusterNode($clnid) { global $db, $xmlExchange; $xmlOptions = array(XML_OPTION_CASE_FOLDING => TRUE, XML_OPTION_SKIP_WHITE => TRUE); $xml =& new XPath(FALSE, $xmlOptions); $sql = "SELECT * FROM cluster_node WHERE CLNID = {$clnid}"; $query = new query($db, $sql); if ($query->getrow()) { $name = urlencode($query->field("NAME")); $clt = $query->field("CLT_ID"); $xmlExchange[] = array("clt" => $clt); $xml->appendChild('', "<NX:CLUSTERNODE ID=\"{$clnid}\" NAME=\"{$name}\" CLUSTERTEMPLATE=\"{$clt}\"/>"); $variations = createDBCArray("cluster_variations", "CLID", "CLNID = {$clnid}"); for ($i = 0; $i < count($variations); $i++) { $cluster = XmlExportCluster($variations[$i]); if ($cluster != false) { $xml->appendChild('/NX:CLUSTERNODE[1]', $cluster); } } return $xml->exportAsXml('', ''); } return false; }
/** * Retrieves the output of a field as defined in Cluster-Template. * To be used for Items with every cardinality. Returns an array with the results. * @param string name of the field to query the content from. * @param string additional parameters for this plugin. * @param integer ID of the Variation to query. Leave Blank or set to zero for Page-Variation. * @param string Column, you want to order the output of. * @returns string The output of the module. */ function getField($name, $params = null, $variation = 0, $order = "POSITION ASC") { global $sid, $lang, $c; $linkadd = ""; if ($variation == 0) $variation = $this->variation; // $myclid = getCLID($this->pageClusterNodeId, $this->variation); // determine, if static or dynamic content. $clt = getDBCell("cluster_node", "CLT_ID", "CLNID = $this->pageClusterNodeId"); $clti = getDBCell("cluster_template_items", "CLTI_ID", "CLT_ID = $clt AND UPPER(NAME) = UPPER('$name')"); if ($clti == "") { $res[0] = "$name is not defined!"; return $res; } $type = getDBCell("cluster_template_items", "CLTITYPE_ID", "CLTI_ID = $clti"); $res = array (); if ($type == 1) $res[0] = "$name is a static content and therefore not a field!"; if ($type == 2) { // dynamic field $plugin = getDBCell("cluster_template_items", "FKID", "CLTI_ID = $clti"); $field = createDBCArray("cluster_content", "CLCID", "CLTI_ID = $clti AND CLID = $this->pageClusterId ORDER BY $order"); if (count($field) == 0 && $this->variation != $this->parent->stdVariation) $res = $this->getField($name, $params, $order, $this->parent->stdVariation); for ($i = 0; $i < count($field); $i++) { if ($field[$i] != "" && $plugin != "") { $linkadd = "<a href=\"#\" onClick=\"window.open('" . $c["docroot"] . "modules/sitepages/sma_editor.php?sid=$sid&oid=" . $field[$i] . "', 'sma', 'top=100,width=650,height=380,toolbar=no,menubar=no,status=no,location=no,dependent=yes,scrollbars=yes');\"><img src=\"" . $c["docroot"] . "img/icons/sma_edit.gif\" alt=\"" . $lang->get("sma_ext_edit", "Open edit window. Save all inline edited texts before!"). "\" width=\"16\" height=\"16\" border=\"0\"></a>"; $ref = createPGNRef($plugin, $field[$i]); $content = $ref->drawLiveAuthoring($param); if ($param == "") $content .= $linkadd; unset ($ref); array_push($res, $content); } } } else if ($type == 5) { $plugin = getDBCell("cluster_template_items", "FKID", "CLTI_ID = $clti"); $field = createDBCArray("cluster_content", "FKID", "CLTI_ID = $clti AND CLID = $this->pageClusterId ORDER BY $order"); if (count($field) == 0 && $this->variation != $this->parent->stdVariation) $res = $this->getField($name, $params, $order, $this->parent->stdVariation); for ($i = 0; $i < count($field); $i++) { if ($field[$i] != "" && $plugin != "") { $oid = getDBCell("content_variations", "FK_ID", "CID = ".$field[$i]." AND VARIATION_ID = $this->variation AND DELETED=0"); $ref = createPGNRef($plugin, $oid); $content = $ref->drawLiveAuthoring($params); unset ($ref); array_push($res, $content); } } } else { $res[0] = "$name is not a content-field!"; } return $res; }
/** * 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(); } }
/** * Create a form for smart translation and return the form reference. * */ function createSmartTranslateForm() { global $c, $page_action, $specialID, $page_state; $page_action = 'UPDATE'; if (value('tsaving', '', '') != 'yes') $page_state = ''; $oldvalues = value('oldfields', '', '0'); if ($oldvalues != '0') { $commas2 = $oldvalues; $commas = "'" . str_replace(",", "','", $oldvalues) . "'"; } else { $commas = implode(',', $this->smarttranslator); $commas2 = str_replace("'", '', $commas); } $tform = new EditForm('N/X Smarttranslator', '', 'smarttranslator'); $oid = $c["smarttranslate"]; $items = createDBCArray('internal_resources', 'RESID', "LANGID='".$oid."' AND UPPER(RESID) IN (".$commas.")", 'ORDER BY RESID ASC'); for ($i = 0; $i < count($items); $i++) { $specialID = $items[$i]; $tform->add(new Label("lbl", "<b>Translate: </b>" . getDBCell("internal_resources", "VALUE", "RESID='" . $items[$i] . "' AND LANGID='EN'"), "standardlight", 2)); $tform->add(new TextInput($items[$i], "internal_resources", "VALUE", "RESID='" . $items[$i] . "' AND LANGID='$oid'", "type:textarea,size:2,width:400")); $tform->add(new TextInput("Tooltip".$items[$i], "internal_resources", "TOOLTIP", "RESID='" . $items[$i] . "' AND LANGID='$oid'", "type:textarea,size:2,width:400")); $tform->add(new Spacer(2)); } $tform->add(new Hidden('oldfields', $commas2)); $tform->add(new Hidden('tsaving', 'yes')); return $tform; }
function exportLanguages() { global $export, $recordsets; $variations = createDBCArray("variations", "VARIATION_ID", '1', 'ORDER BY VARIATION_ID ASC'); $variations2 = createDBCArray("variations", "SHORTTEXT", '1', 'ORDER BY VARIATION_ID ASC'); $export = 'TYPE|KEY1|KEY2'; for ($i = 0; $i < count($variations2); $i++) { $export .= '|' . $variations2[$i]; } $export .= "\n"; // getPluginIds $lp = getDBCell("modules", "MODULE_ID", "MODULE_NAME='Label'", false); $tp = getDBCell("modules", "MODULE_ID", "MODULE_NAME='Text'", false); // export contents $cids = createDBCArray("content", "CID", "VERSION=0"); for ($i = 0; $i < count($cids); $i++) { $module = getDBCell("content", "MODULE_ID", "CID=" . $cids[$i]); $moduleTable = ''; if ($module == $tp) { $moduleTable = 'pgn_text'; } if ($module == $lp) { $moduleTable = 'pgn_label'; } if ($moduleTable != '') { $export .= 'C|' . $cids[$i] . '|'; for ($j = 0; $j < count($variations); $j++) { $fk = getDBCell("content_variations", "FK_ID", "CID={$cids[$i]} AND VARIATION_ID={$variations[$j]}", false); $content = getDBCell($moduleTable, "CONTENT", "FKID=" . $fk, false); $export .= '|' . preg_replace("/\r|\n/s", "", $content); } $export .= "\n"; } } // export menues $spids = createDBCArray("sitepage", "SPID", "VERSION=0 AND DELETED=0"); for ($i = 0; $i < count($spids); $i++) { $export .= 'M|' . $spids[$i] . '|'; for ($j = 0; $j < count($variations); $j++) { $menu = getDBCell("sitepage_names", "NAME", "SPID={$spids[$i]} AND VARIATION_ID={$variations[$j]}", false); $export .= '|' . $menu; } $export .= "\n"; } // export cluster-content $clnids = createDBCArray('cluster_node', 'CLNID', 'VERSION=0 AND DELETED=0'); for ($i = 0; $i < count($clnids); $i++) { $clt = getDBCell("cluster_node", 'CLT_ID', 'CLNID=' . $clnids[$i], false); $cltis = createDBCArray('cluster_template_items', 'CLTI_ID', 'CLT_ID=' . $clt . ' AND FKID IN (' . $tp . ',' . $lp . ') AND CLTITYPE_ID=2'); for ($k = 0; $k < count($cltis); $k++) { $module = getDBCell('cluster_template_items', 'FKID', 'CLTI_ID=' . $cltis[$k]); $moduleTable = ''; if ($module == $tp) { $moduleTable = 'pgn_text'; } if ($module == $lp) { $moduleTable = 'pgn_label'; } if ($moduleTable != '') { $export .= 'O|' . $clnids[$i] . '|' . $cltis[$k]; for ($j = 0; $j < count($variations); $j++) { $clid = getDBCell("cluster_variations", 'CLID', 'CLNID=' . $clnids[$i] . ' AND VARIATION_ID=' . $variations[$j], false); $clcid = getDBCell("cluster_content", "CLCID", "CLID=" . $clid . ' AND CLTI_ID=' . $cltis[$k], false); $content = getDBCell($moduleTable, "CONTENT", "FKID=" . $clcid, false); $export .= '|' . preg_replace("/\r|\n/s", "", $content); } $export .= "\n"; } } } }
/** * standard constructor * @param array Name-Value Array for first table * @param array Name-Value Array for second table * @param array String-Array with all the Headlines ("head1, head1_selected, head2") * @param string Name of the table the combinations are stored in. * @param array Keys to select ("name", "value", "datatype") * @param string Name of column corresponding to values1 * @param string Datatype of column1 * @param string Name of column corresponding to values2 * @param string Datatype of column2 */ function CombinationEditor($values1, $values2, $headlines, $table, $keys, $column1, $column1_datatype, $column2, $column2_datatype, $colspan = "3", $css = "standard") { global $page_action, $page_state, $formname, $page; $this->formname = $formname; if ($this->formname == "") $this->formname = "form1"; $page->setJS("SELECT"); $this->values1 = $values1; $this->values2 = $values2; $this->headlines = $headlines; $this->table = $table; $this->keys = $keys; $this->column1 = $column1; $this->column2 = $column2; $this->column1_dt = $column1_datatype; $this->column2_dt = $column2_datatype; $this->colspan = $colspan; $this->css = $css; $whereClause = ""; for ($i = 0; $i < count($keys); $i++) { if ($i > 0) $whereClause .= " AND "; $whereClause .= $keys[$i][0] . " = "; if (strtoupper($keys[$i][2]) == "NUMBER") { $whereClause .= $keys[$i][1]; } else { $whereClause .= "'" . $keys[$i][1] . "'"; } } // end for $this->row_identifier = $whereClause; if ($page_state == "processing") { $this->configdata = value("configdata"); $checklist = array (); for ($i = 1; $i < count($values1); $i++) { $checklist[$values1[$i][1]] = false; } if ($this->configdata != "" && $this->configdata != "0") { $accessors = explode(";", $this->configdata); for ($i = 0; $i < count($accessors); $i++) { $entry = explode(",", $accessors[$i]); $checklist[$entry[0]] = true; for ($j = 1; $j < count($entry); $j++) { $this->properties[$entry[0]][$j - 1] = $entry[$j]; } } } // build the inlist and outlist now. $this->outlist1 = array (); for ($i = 1; $i < count($values1); $i++) { if (!$checklist[$values1[$i][1]]) array_push($this->outlist1, $values1[$i]); } $this->inlist1 = array (); for ($i = 1; $i < count($values1); $i++) { if ($checklist[$values1[$i][1]]) array_push($this->inlist1, $values1[$i]); } } else { //load from databae; $in1 = createDBCArray($table, $column1, $whereClause); $checklist = array (); for ($j = 1; $j < count($values1); $j++)$checklist[$j] = false; for ($i = 0; $i < count($in1); $i++) { $this->inlist1[$i][1] = $in1[$i]; for ($j = 1; $j < count($values1); $j++) { if ($in1[$i] == $values1[$j][1]) { $this->inlist1[$i][0] = $values1[$j][0]; $checklist[$j] = true; } } } // filter outlist with help of checklist $this->outlist1 = array (); for ($i = 1; $i < count($values1); $i++) { if (!$checklist[$i]) array_push($this->outlist1, $values1[$i]); } $this->configdata = ""; // now get properties for the inlist.... for ($i = 0; $i < count($this->inlist1); $i++) { $iid = $this->inlist1[$i][1]; if ($this->configdata != "") $this->configdata .= ";"; $this->configdata .= $iid; if ($column1_datatype == "NUMBER") { $whereCL = $whereClause . " AND $column1 = $iid"; } else { $whereCL = $whereClause . " AND $column1 = '$iid'"; } $props = createDBCArray($table, $column2, $whereCL); for ($j = 0; $j < count($props); $j++) { $this->properties[$iid][$j] = $props[$j]; $this->configdata .= "," . $props[$j]; } } // end of fetching data... } }
/** * Retrieves the output of a field as defined in Cluster-Template. * To be used for Items with every cardinality. Returns an array with the results. * @param string name of the field to query the content from. * @param string additional parameters for this plugin. * @param string Column, you want to order the output of. * @param integer ID of the Cluster-Node to query. Leave Blank or set to zero for Page-Cluster. * @param integer ID of the Variation to query. Leave Blank or set to zero for Page-Variation. * @returns string The output of the module. */ function getContentField($name, $param = "", $order = "POSITION ASC", $cclnid = 0, $cvariation = 0) { global $clnid, $v, $clid, $c; if ($cclnid == 0) $cclnid = $clnid; if ($cvariation == 0) $cvariation = $v; $myclid = getCLID($cclnid, $cvariation); // determine, if static or dynamic content. $clt = getDBCell("cluster_node", "CLT_ID", "CLNID = $cclnid"); $clti = getDBCell("cluster_template_items", "CLTI_ID", "CLT_ID = $clt AND UPPER(NAME) = UPPER('$name')"); if ($clti == "") { $res[0] = "$name is not defined!"; return $res; } $type = getDBCell("cluster_template_items", "CLTITYPE_ID", "CLTI_ID = $clti"); $res = array (); if ($type == 1) $res[0] = "$name is a static content and therefore not a field!"; if ($type == 2) { // dynamic field $plugin = getDBCell("cluster_template_items", "FKID", "CLTI_ID = $clti"); $field = createDBCArray("cluster_content", "CLCID", "CLTI_ID = $clti AND CLID = $myclid ORDER BY $order"); if (count($field) == 0 && $cvariation != $c["stdvariation"]) $res = getContentField($name, $param, $order, $cclnid, $c["stdvariation"]); for ($i = 0; $i < count($field); $i++) { if ($field[$i] != "" && $plugin != "") { $ref = createPGNRef($plugin, $field[$i]); $content = $ref->draw($param); unset ($ref); array_push($res, $content); } } } if ($type > 2) $res[0] = "$name is not a content-field!"; return $res; }
/** * Creates an array with all group-ids, the user is in. * @return integer scalar array with all group-ids. */ function getGroups() { global $db; return createDBCArray("user_permissions", "GROUP_ID", "USER_ID = {$this->userId}"); }
/** * Retrieves the CLuster-Node-IDs (CLNID) from included Clusters. * To be used for clusters with any cardinatlity. Returns an array. * @param string name of the field to query the cluster-node-id from. * @param string name of the column to order the cluster-nodes. * @param integer ID of the Cluster-Node to query. Leave Blank or set to zero for Page-Cluster. * @param integer ID of the Variation to query. Leave Blank or set to zero for Page-Variation. * @returns integer CLNID of the included cluster. */ function getContentClusterField($name, $order = "POSITION ASC", $cclnid = 0, $cvariation = 0) { global $clnid, $v, $clid, $c; if ($cclnid == 0) $cclnid = $clnid; if ($cvariation == 0) $cvariation = $v; $myclid = getCLID($cclnid, $cvariation); // get the clti.. $res = array (); $clt = getDBCell("cluster_node", "CLT_ID", "CLNID = $cclnid"); $clti = getDBCell("cluster_template_items", "CLTI_ID", "CLT_ID = $clt AND UPPER(NAME) = UPPER('$name')"); if ($clti == "") { $res[0] = "$name is not defined!"; return $res; } $type = getDBCell("cluster_template_items", "CLTITYPE_ID", "CLTI_ID = $clti"); if ($type == 3) $res[0] = "$name is a static cluster and therefore not a field!"; if ($type == 4) { $res = createDBCArray("cluster_content", "FKID", "CLTI_ID = $clti AND CLID = $myclid ORDER BY $order"); if (count($res) == 0 && $cvariation != $c["stdvariation"]) $res = getContentClusterField($name, $order, $cclnid, $c["stdvariation"]); } if ($type < 3 || $type > 4) $res[0] = "$name is not a cluster-field!"; return $res; }