/**
	 * 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 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;
	}