/** * 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; }
/** * 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, $lang; 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 != "") { global $sid; $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); } } } if ($type > 2) $res[0] = "$name is not a content-field!"; return $res; }
/** * Retrieves the output of static field as defined in Cluster-Template. * To be used for Items with maximum cardinality of 1 only. Faster than getContent * @author Tim Haedke * @param string name of the field to query the content from. * @param string additional parameters for this plugin. * @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 getStaticContent($name, $param = "", $cclnid = 0, $cvariation = 0) { global $clnid, $v, $clid, $c, $db, $contentCounter; if ($cclnid == 0) $cclnid = $clnid; if ($cvariation == 0) $cvariation = $v; $myclid = getCLID($cclnid, $cvariation); $contentCounter['static']++; $sql = "SELECT cn.CLT_ID clt, cti.CLTI_ID clti, cti.FKID cid, c.MODULE_ID plugin, cv.FK_ID oid, cti.NAME FROM cluster_node cn, cluster_template_items cti, content c, content_variations cv WHERE cn.CLNID = $cclnid AND cti.CLT_ID = cn.CLT_ID AND UPPER(cti.NAME) = UPPER('$name') AND c.CID = cti.FKID AND cv.CID = cti.FKID AND cv.VARIATION_ID = $cvariation AND cv.DELETED=0;"; $query = new query($db, $sql); while ($query->getrow()) { $clt = $query->field("clt"); $clti = $query->field("clti"); $clti = $query->field("cid"); $plugin = $query->field("plugin"); $oid = $query->field("oid"); } $query->free(); if ($oid != "" && $plugin != "") { $ref = createPGNRef($plugin, $oid); $content = $ref->draw($param); unset ($ref); } else $content = ""; if ($content != "") return $content; // now the content seems to be empty. So we try standard variation. if ($cvariation != $c["stdvariation"]) $content = getStaticContent($name, $param, $cclnid, $c["stdvariation"]); return $content; }