/**
		   * This function is used for drawing the html-code out to the templates.
		   * It just returns the code
		   * @param 		string	Optional parameters for the draw-function. There are none supported.
		   * @return		string	HTML-CODE to be written into the template.
		   */
		function draw($param = "") {			
			global $cds;
			$label = getDBCell("pgn_config_store", "TEXT1", "CLTI_ID=".$this->fkid);
			echo '<script language="javascript" type="text/javascript">
	<!--
	var win=null;
	
	function NewWindow(mypage,myname,w,h,scroll,pos){
		if(pos=="random")
			{LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
			TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
		if(pos=="center")
			{LeftPosition=(screen.width)?(screen.width-w)/2:100;
			TopPosition=(screen.height)?(screen.height-h)/2:100;}
	
		else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
	settings=\'width=\'+w+\',height=\'+h+\',top=\'+TopPosition+\',left=\'+LeftPosition+\',scrollbars=\'+scroll+\',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes\';
	win=window.open(mypage,myname,settings);}
	// -->
	</script>';
		
			echo '<div style="float:right;">';
			echo '&nbsp;&nbsp;<a class="breadcrumb" href="#" onclick="NewWindow'."('".$cds->docroot."/sys/tellafriend/recommend.popup.php','recommend','450','450','no','center');return false".'" onfocus="this.blur()">'.$label.'</a>&nbsp;&nbsp;';	
			echo '</div>';
		}	
function isLive($id)
{
    if (getDBCell("state_translation", "OUT_ID", "OUT_ID={$id}") != "") {
        return true;
    }
    return false;
}
/**
 * Create a image from a file. Do not add the file to the object library
 * @param string Path to the source file
 * @param string Description Text for ALT-Tag
 * @param string Copright text for the image
 * @param string Variation-ID of the image
 */
function createImageFromFile($sourceFile, $alt = "", $copyright = "", $variation = 1, $categoryId = 1)
{
    global $c, $db;
    $id = nextGUID();
    $info = pathinfo($sourceFile);
    $extension = $info["extension"];
    $extension2 = strtoupper($extension);
    $name = parseSQL($info["basename"]);
    if ($extension2 == "JPG" || $extension2 == "GIF" || $extension2 == "PNG") {
        $size = getimagesize($sourceFile);
        $width = $size[0];
        $height = $size[1];
        copy($sourceFile, $c["devfilespath"] . $id . "." . $extension);
        $thumb = new Img2Thumb($c["devfilespath"] . $id . "." . $extension, 120, 120, $c["devfilespath"] . "t" . $id);
        $sql = "INSERT INTO pgn_image (FKID, FILENAME, ALT, COPYRIGHT, WIDTH, HEIGHT) VALUES ";
        $sql .= "({$id}, '{$id}.{$extension}', '{$alt}', '{$copyright}', {$width}, {$height})";
        $query = new query($db, $sql);
        $query->free();
        // Create Library Entry for this image
        $cid = nextGUID();
        $imageModule = getDBCell("modules", "MODULE_ID", "MODULE_NAME='Image'");
        $sql = "INSERT INTO content (CID, MODULE_ID, NAME, CATEGORY_ID, MT_ID) VALUES ";
        $sql .= "({$cid}, {$imageModule}, '{$name}', {$categoryId}, 0)";
        $query = new query($db, $sql);
        $query->free();
        $sql = "INSERT INTO content_variations (CID, VARIATION_ID, FK_ID) VALUES ";
        $sql .= "({$cid}, {$variation}, {$id})";
        $query = new query($db, $sql);
        $query->free();
        return $cid;
    } else {
        return null;
    }
}
 /**
  * standard constructor
  * @param string Text that is to be shown as description or label with your object.
  * @param string Table, you want to connect with the object.
  * @param string $longitude,column, which stores the longitude
  * @param string $latitude, columnd, which stores the latitude
  * @param string $row_identifier Usually to be generated with form->setPK. Identifies the
  * row in db, you want to affect with operation. Keep empty for insert. (Example: stdEDForm)
  */
 function CoordinatesInput($label, $table, $longitude, $latitude, $row_identifier = "1")
 {
     global $page, $page_state, $forceLoadFromDB, $page_action;
     DBO::DBO($label, $table, $longitude, $row_identifier, "");
     $this->lng = $longitude;
     $this->lat = $latitude;
     $this->vlng = 0;
     $this->vlat = 0;
     if ($page_state == "processing" && value("changevariation") != "GO" && !($forceLoadFromDB == "yes")) {
         $this->vlng = value("coordY", "NUMERIC", "0");
         $this->vlat = value("coordX", "NUMERIC", "0");
     } else {
         if (($page_action == "UPDATE" || $page_action == "DELETE") && $this->row_identifier != "1") {
             $this->vlng = getDBCell($table, $longitude, $row_identifier);
             $this->vlat = getDBCell($table, $latitude, $row_identifier);
         }
     }
     include_once "nxgooglemapsapi.php";
     $this->api = new NXGoogleMapsAPI();
     $this->api->setWidth(590);
     $this->api->setHeight(350);
     $this->api->addControl(GLargeMapControl);
     $this->api->addControl(GOverviewMapControl);
     $this->api->addControl(GMapTypeControl);
     $this->api->setCenter(50, 10);
     $this->api->setZoomFactor(4);
     if ($this->vlng != 0 || $this->vlat != 0) {
         $this->api->addDragMarker($this->vlng, $this->vlat);
     }
     $page->headerPayload = $this->api->getHeadCode();
     $page->onLoad .= $this->api->getOnLoadCode();
 }
 function img($attr = null)
 {
     $fileinfo = pathinfo($attr["SRC"]);
     $id = substr($fileinfo["basename"], 0, strlen($fileinfo["basename"]) - 1 - strlen($fileinfo["extension"]));
     if (is_numeric($id)) {
         $cid = getDBCell("content_variations", "CID", "FK_ID = " . $id);
     }
     if (is_numeric($cid)) {
         $output = '{NX:IMAGE ID="' . $cid . '"';
         $manualattribs = array("ID", "SRC");
         foreach ($attr as $key => $value) {
             if (!in_array(strtoupper($key), $manualattribs) && strlen($key) > 0) {
                 $output .= " " . strtoupper($key) . "=\"" . $value . "\"";
             }
         }
         $output .= '}';
     } else {
         $oldlink = "<img";
         foreach ($attr as $key => $value) {
             $oldlink .= " {$key}=\"{$value}\"";
         }
         $oldlink .= ">";
         return $oldlink;
     }
     return $output;
 }
/**
 * Find all clusters having one from the given array included.
 * @params array Array with ClusterNodeIds to check for incluseion
 * @param integer used for recursion control, do not change manuallay.
 */
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;
}
 /**
  * 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}"));
 }
		/**
		 * standard constructor
		 * @param string Text that is to be shown as description or label with your object.
		 * @param string Table, you want to connect with the object.
		 * @param string column, you want to connect with the object.
		 * @param string $row_identifier Usually to be generated with form->setPK. Identifies the
		 * row in db, you want to affect with operation. Keep empty for insert. (Example: stdEDForm)
		 * @param string $params Allowed parameter is:
		 * param:<Name of form> needed for js-reasons.
		 * @param string $check Does checks on user input. Allowed are MANDATORY (=not null)|UNIQUE. Separate with &.
		 * @param string $db_datatype Datatype of the database, you want to use. Allowed is DATE only.
		 */
		function DateTimeInput($label, $table, $column, $row_identifier = "1", $params = "param:form1", $check = "", $db_datatype = "DATE") {
			DBO::DBO($label, $table, $column, $row_identifier, $params, $db_datatype, $check);

			// load the data of the field.
			global $page_state, $page_action;

			if ($page_state == "processing") {
				$this->value = value($this->name, "NOSPACES", "");
				if ($this->value != "") {
					$this->value.=" ".value($this->name."_time", "NOSPACES", "").":00";
					$this->value = str_replace("/", "-", $this->value);

					/** added 21.1.2002 */
					global $c_magic_quotes_gpc;

					if ($c_magic_quotes_gpc == 1)
						$this->value = str_replace("\\", "", $this->value);
					/** got rid of magic quotes! */
					$this->oldvalue = getDBCell($table, $column, $row_identifier);
				}
			} else {
				if (($page_action == "UPDATE" || $page_action == "DELETE") && $this->row_identifier != "1") {
					$this->value = getDBCell($table, $column, $row_identifier);

					if ($this->value == "0000-00-00 00:00:00"  || $this->value == "00:00:00" || $this->value=="")
						$this->value = "";
				}
			}

			$this->v_wuiobject = new DateTimebox($this->name, $this->value, $this->std_style, $this->parameter);
		}
		/**
		   * This function is used for drawing the html-code out to the templates.
		   * It just returns the code
		   * @param 		string	Optional parameters for the draw-function. There are none supported.
		   * @return		string	HTML-CODE to be written into the template.
		   */
		function draw($param = "") {			
			global $cds;
			$label = getDBCell("pgn_config_store", "TEXT1", "CLTI_ID=".$this->fkid);
			
			echo '<div style="float:right;">';
			echo '&nbsp;&nbsp;<a class="breadcrumb" href="#" onclick="window.print();return false;">'.$label.'</a>&nbsp;&nbsp;';	
			echo '</div>';
		}	
		/**
		 * Standard constructor
		 * @param string name of the table, the data is to be stored
		 * @param string name of the column, the data is to be stored
		 * @param string Where-Condition to select the record that is to be updated.
		 */
		function CLTISelector($table, $column, $row_identifier) {
			$this->table = $table;
			$this->column = $column;
			$this->cond = $row_identifier;
			$this->fk = getDBCell($table, $column, $row_identifier);

			global $lang, $db;
			
			$pattern = value("pattern");
			if ($pattern == "0") $pattern="%";
			$cltid = value("cltid", "NUMERIC");
			$searchin = value("searchin", "NUMERIC");
			
			$this->add(new Label("lbl1", $lang->get("sr_selectcli"), "informationheader", 2));

			$this->add(new Label("lbl", "<b>" . $lang->get("selectedinstance"). "</b>", "informationheader"));

			if ($this->fk != 0) {
				$this->idlabel = new Label("lbl0", getDBCell("cluster_node", "NAME", "CLNID = " . $this->fk), "informationheader");
			} else {
				$this->idlabel = new Label("lbl0", $lang->get("empty"), "informationheader");
			}

			$this->add($this->idlabel);

			$this->add(new Label("lbl2", $lang->get("clt_browse"), "standard"));
			$cltemplates = null;

			$this->createCLT($cltemplates, "/", 0);

			$this->add(new Dropdown("cltid", $cltemplates, "standard", $cltid, 220, 1));

			$searchins[0][0] = $lang->get("searchin");
			$searchins[0][1] = 0;
			$searchins[1][0] = $lang->get("name");
			$searchins[1][1] = 1;
			$searchins[2][0] = $lang->get("description");
			$searchins[2][1] = 2;

			$this->add(new Dropdown("searchin", $searchins, "standard", $searchin, 220, 1));
			$this->add(new Input("pattern", $pattern, "standard", 32, "", 250));
			$this->add(new Cell("clc", "standard", 1, 250));
			$this->add(new ButtonInCell("search", $lang->get("search"), "standard", "SUBMIT"));

			if (value("search") != "0") {

				// prepare search-pattern.
				$ppattern = strtoupper($pattern);

				$ppattern = ereg_replace(" ", "%", $ppattern);
				$ppattern = ereg_replace("\*", "%", $ppattern);

				$this->search("/", $cltid, $searchin, $ppattern);

				$this->add(new Label("lbl4", $lang->get("searchresults"), "standard"));
				$this->add(new Dropdown("CIDRES", $this->results, "standard", $CID, 250, 1));
			}
		}
		/**
		   * This function is used for drawing the html-code out to the templates.
		   * It just returns the code
		   * @param 		string	Optional parameters for the draw-function. There are none supported.
		   * @return		string	HTML-CODE to be written into the template.
		   */
		function draw($param = "") {
			$groupId = getDBCell("pgn_auth", "GROUP_ID", "FKID=".$this->fkid);
			$result = new authCommunity($groupId);
			if (value("logout") != "0") {
				$result->logout();
				$result = new authCommunity($groupId);				
			}
			return $result;
		}
		function journal($id, $isLive = false) {
			global $db, $auth, $insertstatements;

			if ($isLive) {
				$id = translateState($id, 10, false);
			}

			$this->id = $id;
			$this->userId = $auth->userId;

			$jnlCreated = getDBCell("journal", "CREATED", "ITEM_ID = $this->id");

			if ($jnlCreated == 0) {
				$nextSlot = count($insertstatements);

				$journalInsert = new InsertSet("journal");

				$journalInsert->setPK("JOURNAL_ID");

				$journalInsert->add("ITEM_ID", $this->id, "NUMBER");
				$journalInsert->add("CREATED", time(), "NUMBER");

				$insertstatements[$nextSlot] = $journalInsert;

				$this->itemStatus["created"]["time"] = 0;
				//$this->itemStatus["created"]["by"] = $rstJournal->getValue("CREATED_BY");
				$this->itemStatus["launched"]["time"] = 0;
				//$this->itemStatus["launched"]["by"] = $rstJournal->getValue("LAUNCHED_BY");
				$this->itemStatus["expired"]["time"] = 0;
				//$this->itemStatus["expired"]["by"] = $rstJournal->getValue("EXPIRED_BY");
				$this->itemStatus["changed"]["time"] = 0;
				//$this->itemStatus["changed"]["by"] = $rstJournal->getValue("CHANGED_BY");
				$this->itemStatus["deleted"]["time"] = 0;
				//$this->itemStatus["deleted"]["by"] = $rstJournal->getValue("DELETED_BY");
				$this->itemStatus["staged"]["time"] = 0;
				//$this->itemStatus["staged"]["by"] = $rstJournal->getValue("STAGED_BY");
				$this->itemStatus["locked"]["time"] = 0;
				$this->itemStatus["locked"]["by"] = 0;
			} else {
				$rstJournal = new Recordset("journal", "*", "ITEM_ID = $this->id");

				$this->itemStatus["created"]["time"] = $rstJournal->getValue("CREATED");
				//$this->itemStatus["created"]["by"] = $rstJournal->getValue("CREATED_BY");
				$this->itemStatus["launched"]["time"] = $rstJournal->getValue("LAUNCHED");
				//$this->itemStatus["launched"]["by"] = $rstJournal->getValue("LAUNCHED_BY");
				$this->itemStatus["expired"]["time"] = $rstJournal->getValue("EXPIRED");
				//$this->itemStatus["expired"]["by"] = $rstJournal->getValue("EXPIRED_BY");
				$this->itemStatus["changed"]["time"] = $rstJournal->getValue("CHANGED");
				//$this->itemStatus["changed"]["by"] = $rstJournal->getValue("CHANGED_BY");
				$this->itemStatus["deleted"]["time"] = $rstJournal->getValue("DELETED");
				//$this->itemStatus["deleted"]["by"] = $rstJournal->getValue("DELETED_BY");
				$this->itemStatus["staged"]["time"] = $rstJournal->getValue("STAGED");
				//$this->itemStatus["staged"]["by"] = $rstJournal->getValue("STAGED_BY");
				$this->itemStatus["locked"]["time"] = $rstJournal->getValue("LOCKED");
				$this->itemStatus["locked"]["by"] = $rstJournal->getValue("LOCKED_BY");
			}
		}
		/**
		   * This function is used for drawing the html-code out to the templates.
		   * It just returns the code
		   * @param 		string	Optional parameters for the draw-function. There are none supported.
		   * @return		string	HTML-CODE to be written into the template.
		   */
		function draw($param = "") {
			global $cds, $c;
			if ($cds->is_development) {
				$content = '<div style="border:1px solid black; background-color:#e0e0e0;align:center;vertical-align:middle;padding:10px;">Adsene Placeholder. <br>Avoids influences to your adsense statistics.</div>';
			} else {			  
			  $content = unhtmlspecialchars(getDBCell("pgn_adsense", "ADTEXT", "FKID = $this->fkid"));						  
			  $content.= '<script type="text/javascript">bug = new Image(); bug.src=\''.$c["livedocroot"]."sys/hit.php?id=".$this->fkid.'&scope=adsense\';</script>';
			}
			return $content;
		}
 /**
  * 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;
     }
 }
		/** 
		  * Used, for painting a preview of the content in the cms. Note, that the data
		  * is to be drawn in a table cell. Therefore you may design any html output, but
		  * you must return it as return value!
		  */
		function preview() {
			global $c, $lang;
	
	  	$filename = getDBCell("pgn_file", "FILENAME", "FKID = $this->fkid");
			$copyright = getDBCell("pgn_file", "COPYRIGHT", "FKID = $this->fkid");
			$name	  = getDBCell("pgn_file", "NAME", "FKID=$this->fkid");
      if ($filename=="") {
        return "<div align=\"center\">".$lang->get('nofile', 'No file uploaded yet.')."</div>";
      } else {			
			  return "<div align=\"center\"><a href=\"".$c['devfilesdocroot'].$filename."\" target=\"blank\">".$name."</a></div>";	
      }
			return $output;
		}
        /**
		 * Draw the input boxes needed for editing the contents in the envelope.
		 * @param integer id of cluster_content.CLCID
		 */
		function getSingleEdit($id) {
			global $specialID;
			if ($this->editState && $this->editor) {
				$viewOnly = false;
			} else {
				$viewOnly = true;	
			}
			$specialID = $id;
			$filterId = getDBCell("cluster_template_items", "FKID", "CLTI_ID = ".$this->clti);
			$filter = getDBCell("modules", "MODULE_NAME", "MODULE_ID = ".$filterId);
			$this->add(new LibrarySelect("cluster_content", "FKID", "CLCID=$id", $filter, 2, $viewOnly));
			$specialID = "";
			
		}
	/**
	 * 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
	}
		/**
		 * standard constructor
		 * @param string Text that is to be shown as description or label with your object.
		 * @param string Table, you want to connect with the object.
		 * @param string column, you want to connect with the object.
		 * @param string first $row_identifier Usually to be generated with form->setPK. Identifies the
		 * row in db, you want to affect with operation. Keep empty for insert. (Example: stdEDForm)
		 * @param string $params Allowed parameter is:
		 * param:<Name of form> needed for js-reasons.
		 * @param string $check Does checks on user input. Allowed are MANDATORY (=not null)|UNIQUE. Separate with &.
		 * @param string $db_datatype Datatype of the database, you want to use. TIME is allowed only
		 */
		function TimeInput($label, $table, $column, $row_identifier = "1", $style = "", $params = "", $check = "", $db_datatype = "TIME") {
			DBO::DBO($label, $table, $column, $row_identifier, $params, $db_datatype, $check);

			global $page_state;

			if ($page_state == "processing") {
				$fieldname = $this->name;

				if (value($fieldname) != "0")
					$this->value = value($fieldname);
			} else {
				$this->value = getDBCell($table, $column, $row_identifier);
			}

			$this->v_wuiobject = new Timebox($this->name, $this->std_style, "", substr($this->value, 0, 5));
		}
 /**
  * Checks, wheter a page is actually in INSERT or UPDATE mode an creates the corresponding
  * Saveset.
  */
 function process()
 {
     global $page_action;
     $this->posFilter = str_replace("<chcat>", "CHID = " . getvar("chsel"), $this->posFilter);
     $pos = getDBCell($this->table, $this->column, $this->posFilter . " AND " . $this->column . "=" . $this->value);
     if ($pos != "") {
         freeRowPosition($this->table, $this->column, $this->value, $this->posFilter);
     }
     if ($page_action == "INSERT") {
         addInsert($this->table, $this->column, $this->value, $this->datatype);
     } else {
         if ($page_action == "UPDATE") {
             addUpdate($this->table, $this->column, $this->value, $this->row_identifier, $this->datatype);
         }
     }
 }
/**
 * Import the XML as content to a plugin
 * @param string XML-Data to import.
 * @param integer GUID to use for this content or null for creation
 */
function XmlImportPlugin($xmlString, $id = null)
{
    if ($id == null) {
        $id = nextGUID;
    }
    $xmlOptions = array(XML_OPTION_CASE_FOLDING => TRUE, XML_OPTION_SKIP_WHITE => TRUE);
    $xml =& new XPath(FALSE, $xmlOptions);
    $xml->importFromString($xmlString);
    $type = strtoupper($xml->getAttributes('/NX:CONTENT[1]', "TYPE"));
    $moduleId = getDBCell("modules", "MODULE_ID", "UPPER(MODULE_NAME) = '{$type}'");
    if ($moduleId != "") {
        $pgn = createPGNRef($moduleId, $id);
        $pgn->import($xmlString);
        return $id;
    }
    return false;
}
 /**
  * Draw the information
  */
 function draw()
 {
     global $lang;
     $createdAt = "<b>" . formatDBTimeStamp(getDBCell("cluster_variations", "CREATED_AT", "CLID = " . $this->clid)) . "</b>";
     $createdBy = "<b>" . getDBCell("cluster_variations", "CREATE_USER", "CLID = " . $this->clid) . "</b>";
     $modifiedAt = "<b>" . formatDBTimeStamp(getDBCell("cluster_variations", "LAST_CHANGED", "CLID = " . $this->clid)) . "</b>";
     $modifiedBy = "<b>" . getDBCell("cluster_variations", "LAST_USER", "CLID = " . $this->clid) . "</b>";
     $launchedAt = "<b>" . formatDBTimeStamp(getDBCell("cluster_variations", "LAUNCHED_AT", "CLID = " . $this->clid)) . "</b>";
     $launchedBy = "<b>" . getDBCell("cluster_variations", "LAUNCH_USER", "CLID = " . $this->clid) . "</b>";
     echo '<td colspan="' . $this->columns . '" class="' . $this->css . '">';
     echo tableStart("100%", $this->css);
     echo '<td width="200">' . $lang->get("created_at", "Created at") . "</td><td width=\"200\">" . $createdAt . "</td><td width=\"50\">" . $lang->get("by", "by") . "</td><td>" . $createdBy . "</td></tr>";
     echo '<tr><td>' . $lang->get("last_mod_at", "Last Modified at") . "</td><td>" . $modifiedAt . "</td><td>" . $lang->get("by", "by") . "</td><td>" . $modifiedBy . "</td></tr>";
     echo '<tr><td>' . $lang->get("last_launched_at", "Last Launched at") . "</td><td>" . $launchedAt . "</td><td>" . $lang->get("by", "by") . "</td><td>" . $launchedBy . "</td></tr>";
     echo tableEnd();
     echo '</td>';
     return $this->columns;
 }
 /**
  * Store the data
  */
 function process()
 {
     // always update
     if ($this->value == 1) {
         $chid = 'NULL';
         $chcatid = 'NULL';
     } else {
         $tmp = getDBCell("channel_categories", "CHID", "CH_CAT_ID = " . $this->value);
         if ($tmp != 0 && $tmp != "") {
             $chid = $tmp;
             $chcatid = $this->value;
         } else {
             $chid = $this->value;
             $chcatid = 'NULL';
         }
     }
     addUpdate($this->table, "CHID", $chid, $this->row_identifier, "NUMBER");
     addUpdate($this->table, "CH_CAT_ID", $chcatid, $this->row_identifier, "NUMBER");
 }
		/**
		  * Standard constructor
		  * @param $oid ID of the content-item (content.CID)
		  * @param $cells number of cells to use, standard=2
		  * @param $linkset specifies which buttons to display. Possible values: LIB, SELECT, EDIT, USAGE, LAUNCH, DELETE, COPY, combination sparated by | e.g. "LIB|SELECT", Standard: LIB
		  * @param $filter specifies which plugins to display. Specify plugin name(s) e.g. IMAGE|TEXT
		  */
		function LibraryViewer($oid, $cells = 1, $linkset = "LIB", $filter = "") {
			$this->oid = $oid;

			$this->cells = $cells;
			$this->linkset = $linkset;

			//  initializing 
			global $variation;
			$variation_temp = $variation;
			$this->module_id = getDBCell("content", "MODULE_ID", "CID = $oid");
			$this->name = getDBCell("content", "NAME", "CID = $oid");
			$this->accesskey = getDBCell("content", "ACCESSKEY", "CID = $oid");
			$this->module_name = getDBCell("modules", "MODULE_NAME", "MODULE_ID = " . $this->module_id);			
			$check = getDBCell("content_variations", "VARIATION_ID", "VARIATION_ID = $variation AND CID = $oid");
			if ($check =="") {
				$variation_temp = getDBCell("content_variations", "VARIATION_ID", "CID = $oid");
			}
			$this->fkid = getDBCell("content_variations", "FK_ID", "VARIATION_ID = $variation_temp AND CID = $oid");
		}
	/**
	 * 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;
		if ($this->editState && $this->editor) {
			$specialID = $id;
			$this->add(new CLSelector($lang->get("select_cl"), "cluster_content", "FKID", "CLCID=$id", getModuleFromCLC($id), "", ""));
			$specialID = "";		
		} else {
			$name = "&lt;" . $lang->get("not_selected", "No item selected yet."). "&gt;";
			$myfk = getDBCell("cluster_content", "FKID", "CLCID = " . $id);
			if ($myfk != 0 && $myfk != "") {				
				$clt = getDBCell("cluster_node", "CLT_ID", "CLNID = " . $myfk);
				$cat = getDBCell("cluster_templates", "CATEGORY_ID", "CLT_ID = " . $clt);
				$name = "<br><b>" . $lang->get("cli"). "</b> " . 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\">goto cluster</a>";
			}
			$this->add(new Label("lbl", $name, "standardwhite", 2));
			$this->add(new AlignedLabel('lbl', $buttons, 'right', '', 1));
		}

	}
Exemple #25
0
/**
 * returns a path to the root folder of the system
 * @param $pnode integer ID of the current folder
 */
function pathToRootFolder($pnode, $baseNode = "0")
{
    global $c, $sid, $lang;
    if ($baseNode == "0") {
        $basehref = '<a href="?sid=' . $sid . '&pnode=';
        $str_base = $basehref . '0">Content &gt;</a> ';
    } else {
        if ($baseNode == "11") {
            $basehref = '<a href="?sid=' . $sid . '&pnode=';
            $str_base = $basehref . '11">' . $lang->get("shop") . ' &gt;</a> ';
        }
    }
    $str = "";
    $tmp = $pnode;
    while ($tmp != $baseNode && $tmp != "") {
        $str = $basehref . "{$tmp}\">" . getDBCell("categories", "CATEGORY_NAME", "CATEGORY_ID = {$tmp}") . "\t&gt; </a>&nbsp;&nbsp;" . $str;
        $tmp = getDBCell("categories", "PARENT_CATEGORY_ID", "CATEGORY_ID = {$tmp}");
    }
    $str = $str_base . $str;
    return $str;
}
 function IngredientEditor($table, $cond)
 {
     $this->values = array();
     $this->cond = $cond;
     $this->table = $table;
     global $page_state, $page_action, $db;
     if ($page_state == "processing") {
         // Get Values form PoST
         for ($i = 1; $i < 18; $i++) {
             $this->values[$i][0] = value("quantity" . $i, '', '');
             $this->values[$i][1] = value("ingredient" . $i, '', '');
         }
     } else {
         if (($page_action == "UPDATE" || $page_action == "DELETE") && $this->cond != "1") {
             // Load Values from database
             for ($i = 1; $i < 18; $i++) {
                 $this->values[$i][0] = getDBCell($this->table, "QUANTITY" . $i, $this->cond);
                 $this->values[$i][1] = getDBCell($this->table, "INGREDIENT" . $i, $this->cond);
             }
         }
     }
 }
 /**
  * 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;
     // create Channel/Categories Name-Value-Array
     $values = array();
     array_push($values, array($lang->get("latest", "Change Date, latest first."), 1));
     array_push($values, array($lang->get("oldest", "Change Date, oldest first"), 2));
     array_push($values, array($lang->get("random", "Random Order"), 3));
     array_push($values, array("A - Z", 4));
     array_push($values, array("Z - A", 5));
     array_push($values, array($lang->get("latest_created", "Article Date, latest first"), 6));
     array_push($values, array($lang->get("oldest_created", "Article Date, oldest first"), 7));
     array_push($values, array($lang->get("pos_asc", "Position ascending"), 8));
     array_push($values, array($lang->get("pos_desc", "Position descending"), 9));
     if ($this->editState && $this->editor) {
         $specialID = $id;
         $this->add(new SelectChannelCategory("STAGE_ID = {$id}"));
         $this->add(new SelectOneInputFixed($lang->get("orderart", "Order of Artciles"), "centerstage", "SORT_ALGORITHM", $values, "STAGE_ID = {$id}", "type:dropdown"));
         $this->add(new TextInput($lang->get("num_of_art", "Number of articles ( -1 =infinite)"), "centerstage", "MAXCARD", "STAGE_ID = {$id}", "type:text,size:3,width:40", "MANDATORY", "NUMBER"));
         $specialID = "";
     } else {
         $this->add(new Label("lbl", $lang->get("ch_cat2", "Channel and Category"), "standardwhite"));
         $chn = getDBCell("centerstage", "CHID", "STAGE_ID = {$id}");
         if ($chn == 0) {
             $chn = $lang->get("all");
         } else {
             $chn = getDBCell("channels", "NAME", "CHID = {$chn}");
         }
         $cat = getDBCell("centerstage", "CH_CAT_ID", "STAGE_ID = {$id}");
         if ($cat != 0) {
             $chn .= " - " . getDBCell("channel_categories", "NAME", "CH_CAT_ID = {$cat}");
         }
         $this->add(new Label("lbl", "<b>" . $chn . "</b>", ""));
         $this->add(new Label("lbl", $lang->get("orderart"), ""));
         $this->add(new Label("lbl", "<b>" . $values[getDBCell("centerstage", "SORT_ALGORITHM", "STAGE_ID = {$id}") - 1][0] . "</b>", "standardwhite"));
         $this->add(new Label("lbl", $lang->get("num_of_art"), "standardwhite"));
         $this->add(new Label("lbl", "<b>" . getDBCell("centerstage", "MAXCARD", "STAGE_ID = {$id}") . "</b>", "standardwhite"));
     }
 }
 function link($attr = null)
 {
     global $c;
     if (is_numeric($attr["PAGE"]) && $attr["PAGE"] != "") {
         $spm = getDBCell("sitepage", "SPM_ID", "SPID = " . $attr["PAGE"]);
         if ($spm != "") {
             $template = getDBCell("sitepage_master", "TEMPLATE_PATH", "SPM_ID = " . $spm);
             $live = getDBCell("state_translation", "OUT_ID", "OUT_ID = " . $attr["PAGE"] . " AND LEVEL = 10 AND EXPIRED=0");
             if ($live != "") {
                 $path = $c["livedocroot"];
             } else {
                 $path = $c["devdocroot"];
             }
             // first, we'll use standard-variation if nothing has been set in the original link
             if (!isset($attr["V"])) {
                 $attr["V"] = $this->variation;
             }
             // if the target sitepage is expired, we'll directly link to the www folder.
             if ($live && isSPExpired($attr["PAGE"], $attr["V"])) {
                 $output = "<a href=\"" . $path . "\"";
             } else {
                 // we need to manually add N/X-GetVars like page and v
                 $output = "<a href=\"" . $path . $template . "?page=" . $attr["PAGE"] . "&v=" . $attr["V"];
                 // append additional getvars.
                 $output .= $attr["GETVARS"] . "\"";
             }
             // other attributes are readded if they haven't already been manually treated
             $manualattribs = array("HREF", "PAGE", "V", "GETVARS", "VARIATION");
             foreach ($attr as $key => $value) {
                 if (!in_array($key, $manualattribs)) {
                     $output .= " " . $key . "=\"" . $value . "\"";
                 }
             }
             $output .= ">";
             return $output;
         }
     }
 }
		/** 
		  * Used, for painting a preview of the content in the cms. Note, that the data
		  * is to be drawn in a table cell. Therefore you may design any html output, but
		  * you must return it as return value!
		  */
		function preview() {
			global $variation, $c;

			$link_text = getDBCell("pgn_link", "LABEL", "FKID = $this->fkid");

			if ($link_text == "") {
				$content = "&lt;this item is empty&gt;";
			} else {
				$href = getDBCell("pgn_link", "HREF", "FKID = $this->fkid");

				$spid = getDBCell("pgn_link", "SPID", "FKID = $this->fkid");

				if ($href == "") {
					$spm = getDBCell("sitepage", "SPM_ID", "SPID = " . $spid);

					$path = getDBCell("sitepage_master", "TEMPLATE_PATH", "SPM_ID = $spm");
					$href = $c["devdocroot"] . $path . "?page=$spid&amp;v=$variation";
				}

				$content = "<a href=\"$href\" target=\"_blank\">$link_text</a>";
			}

			return $content;
		}
/**
 * Translate an old into a new GUID
 * @param integer old GUID
 * @param boolean set AntiCycle
 */
function translateXmlGUID($oldId)
{
    global $db, $provider, $c;
    if ($oldId < 1000) {
        // System data.
        $out = $oldId;
    } else {
        if (strtoupper($provider) == strtoupper($c["provider"])) {
            // own data.
            $out = $oldId;
        } else {
            $provider = strtoupper(parseSQL($provider));
            resetDBCache();
            $out = getDBCell("syndication", "OUT_ID", "IN_ID = {$oldId} AND PROVIDER = '{$provider}'");
            if ($out == "") {
                $out = nextGUID();
                $sql = "INSERT INTO syndication (IN_ID, OUT_ID, PROVIDER) VALUES ({$oldId}, {$out}, '{$provider}')";
                $query = new query($db, $sql);
                $query->free();
            }
        }
    }
    return $out;
}