Example #1
0
/**
 * 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;
    }
}
/**
 * Create a new Page Template
 * @param string Name
 * @param string Description
 * @param string Filename of the template
 * @param string Template
 * @param integer GUID of Cluster Template
 * @param integer Id of Type (1=singlepage, 2=multipage)
 * @param integer OPtional key to use.
 */
function createSitepageMaster($name, $description, $templatePath, $template, $clt, $type, $id = null)
{
    global $db, $c, $errors;
    if ($id == null) {
        $id = nextGUID();
    }
    $name = makeCopyName("sitepage_master", "NAME", parseSQL($name), "VERSION=0 AND DELETED=0");
    $description = parseSQL($description);
    $filename = substr($templatePath, 0, strcspn($templatePath, "."));
    $filesuffix = $templatePath = substr($templatePath, strcspn($templatePath, ".") + 1);
    $templatePath = makeUniqueFilename($c["devpath"], parseSQL($filename), $filesuffix);
    $fp = @fopen($c["devpath"] . $templatePath, "w+");
    if ($fp != "") {
        @fwrite($fp, $template);
        @fclose($fp);
    } else {
        $errors .= "--Could not write spm: " . $templatePath;
    }
    $sql = "INSERT INTO sitepage_master (SPM_ID, NAME, DESCRIPTION, TEMPLATE_PATH, CLT_ID, SPMTYPE_ID) VALUES ";
    $sql .= "({$id}, '{$name}', '{$description}', '{$templatePath}', {$clt}, {$type})";
    $query = new query($db, $sql);
    $query->free();
    $variations = createDBCArray("variations", "VARIATION_ID", "1");
    for ($i = 0; $i < count($variations); $i++) {
        $sql = "INSERT INTO sitepage_variations (SPM_ID, VARIATION_ID) VALUES ( {$id}, " . $variations[$i] . ")";
        $query = new query($db, $sql);
        $query->free();
    }
    return $id;
}
Example #3
0
/**
 * Create a figure in a Meta-Template
 * @param integer ID of the Meta-Template
 * @param string NAme
 * @param string Description
 * @param integer Position
 * @param integer Datatype-Id, compare table meta_template_item_types
 */
function createMetaTemplateFigure($mtid, $name, $position, $type)
{
    global $db;
    $newId = nextGUID();
    $name = makeCopyName("meta_template_items", "NAME", parseSQL($name), "MT_ID = {$mtid}");
    $sql = "INSERT INTO meta_template_items (MTI_ID, MT_ID, NAME, POSITION, MTYPE_ID, VERSION) VALUES ({$newId}, {$mtid}, '{$name}', {$position}, {$type}, 0)";
    $query = new query($db, $sql);
    $query->free();
    return $newId;
}
Example #4
0
		/**
		 * Add a column-value-pair to the Set. The value is automatically
		 * formatted to match the given datatype.
		 * @param string Name of the column, you want to insert the value
		 * @param string Value of the column, you want to insert.
		 * @param string Kind of Datatype you want to insert.
		 * Allowed ar CHAR|NUMBER|DATE|DATETIME|TIMESTAMP|PASSWORD
		 */
		function add($column, $value, $datatype) {
			global $c;

			$datatype = strtoupper($datatype);
			if ($datatype == "TEXT") {
				$this->values[$this->counter] = "'" . parseSQL($value). "'";

				$this->columns[$this->counter] = $column;
				$this->counter++;
			} else if ($datatype == "BLOB") {
				$this->values[$this->counter] = "'" . parseSQL($value). "'";

				$this->columns[$this->counter] = $column;
				$this->counter++;
			} else if ($datatype == "NUMBER") {
                if (count($value) == 0) $value = 'NULL';
                $this->values[$this->counter] = $value;

				$this->columns[$this->counter] = $column;
				$this->counter++;
			} else if ($datatype == "DATE") {
				$this->values[$this->counter] = "'$value'";

				$this->columns[$this->counter] = $column;
				$this->counter++;
			} else if ($datatype == "TIME") {
				$this->values[$this->counter] = "'$value'";

				$this->columns[$this->counter] = $column;
				$this->counter++;
			} else if ($datatype == "DATETIME") {
                if (stristr($value, '()')) {
                   $this->values[$this->counter] = " $value ";
                } else if ($value == "" || $value==0) {
                   $this->values[$this->counter] = " NULL ";
                } else {
                   $this->values[$this->counter] = "'$value'";
                }

				$this->columns[$this->counter] = $column;
				$this->counter++;
			} else if ($datatype == "TIMESTAMP") {
				$this->values[$this->counter] = "NOW()";

				$this->columns[$this->counter] = $column;
				$this->counter++;
			} else if ($datatype == "PASSWORD") {
				$this->values[$this->counter] = "encode('$value', '" . $c["dbcode"] . "')";

				$this->columns[$this->counter] = $column;
				$this->counter++;
			}
		}
Example #5
0
/**
 * Creates a cluster and a cluster-node for the given clt. returns the clnid.
 * Can only import dynamic content and dynamic clusters (GUIDs of Cluster_node!).
 * @param string name of the cluster
 * @param string GUID of Cluster template
 * @param string ID od Variation to use
 * @param string array with data to post to plugins, like array("Headline" => "Test Headline", ...)
 * @param string Username to use for create
 */
function createCluster2($name, $clt, $variationId, $data, $createUser = "******")
{
    $name = makeCopyName("cluster_node", "NAME", parseSQL($name), "CLT_ID = {$clt}");
    if (!is_numeric($clt)) {
        exit;
    }
    if (!is_numeric($variationId)) {
        exit;
    }
    $clnid = createClusterNode($name, $clt);
    $clid = createCluster($clnid, $variationId, $createUser);
    $datarows = array_keys($data);
    for ($i = 0; $i < count($datarows); $i++) {
        $type = getDBCell("cluster_template_items", "CLTITYPE_ID", "CLT_ID = {$clt} AND UPPER(NAME) = UPPER('" . $datarows[$i] . "')");
        $clti = getDBCell("cluster_template_items", "CLTI_ID", "CLT_ID = {$clt} AND UPPER(NAME) = UPPER('" . $datarows[$i] . "')");
        $clcid = getDBCell("cluster_content", "CLCID", "CLID={$clid} AND CLTI_ID = {$clti}");
        if ($type == 2) {
            $pgType = strtoupper(getDBCell("modules", "MODULE_NAME", "MODULE_ID = " . getDBCell("cluster_template_items", "FKID", "CLT_ID = {$clt} AND UPPER(NAME) = UPPER('" . $datarows[$i] . "')")));
            $moduleId = getDBCell("cluster_template_items", "FKID", "CLT_ID = {$clt} AND UPPER(NAME) = UPPER('" . $datarows[$i] . "')");
            if ($pgType == "TEXT" || $pgType == "LABEL") {
                $data[$datarows[$i]] = urlencode($data[$datarows[$i]]);
            }
            $xml = '<NX:CONTENT TYPE="' . $pgType . '">' . $data[$datarows[$i]] . '</NX:CONTENT>';
            $pgn = createPGNRef($moduleId, $clcid);
            $pgn->import($xml);
        } else {
            if ($type == 4) {
                if (is_numeric($data[$datarows[$i]])) {
                    $sql = "UPDATE cluster_content SET FKID=" . $data[$datarows[$i]] . " WHERE CLCID = {$clcid}";
                    global $db;
                    $query = new query($db, $sql);
                    $query->free();
                }
            }
        }
    }
    return $clnid;
}
Example #6
0
		/**
		 * @param string db-table, on which you want to filter
		 * @param string primary key of the table
		 */
		function Filter($table, $pk) {
			global $lang;
			$this->table = $table;

			$this->pk = $pk;
			$this->icon = "li_standard.gif"; // 14x11 pixels.
			$this->type_name = "Records";
			// get the action template to use.
			$temp = explode("?", $_SERVER["REQUEST_URI"]);
			$temp2 = explode("/", $temp[0]);
			$this->link_action = $temp2[count($temp2) - 1];
			$this->new_action = $this->link_action;
			$this->newLabel = $lang->get("new");

			// check and initialize filter variables.
			$filter_rule = parseSQL(value("filter_rule", "", ""));
			$filter_column = value("filter_column", "NOSPACES");
			$filter_page = value("filter_page");

			if ($filter_rule != "0") {
				pushVar($this->link_action . "filter_rule", value("filter_rule", "", ""));

				pushVar($this->link_action . "filter_page", 1);
			}

			if ($filter_column != "0") {
				pushVar($this->link_action . "filter_column", value("filter_column"));

				pushVar($this->link_action . "filter_page", 1);
			}

			if ($filter_page != "0")
				pushVar($this->link_action . "filter_page", value("filter_page"));

			$this->filter_rule = getVar($this->link_action . "filter_rule");
			$this->filter_column = getVar($this->link_action . "filter_column");
		}
/**
 * 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;
}
Example #8
0
function install_sql()
{
    global $db_pre;
    //安装配置信息
    $db_address = url_get('db_address');
    $db_user = url_get('db_user');
    $db_pwd = url_get('db_pwd');
    $db_name = url_get('db_name');
    $db_pre = url_get('db_pre');
    $admin_user = url_get('admin_user');
    $admin_pwd = url_get('admin_pwd');
    $install_type = url_get('install_type');
    //链接mysql数据库
    $mysql_link = @mysql_connect($db_address, $db_user, $db_pwd);
    if (!$mysql_link) {
        showProgress(array('isError' => true, 'message' => 'mysql链接失败' . mysql_error()));
    }
    //检测SQL安装文件
    $sql_file = ROOT_PATH . './install/iwebshop.sql';
    if (!file_exists($sql_file)) {
        showProgress(array('isError' => true, 'message' => '安装的SQL文件' . basename($sql_file) . '不存在'));
    }
    //检测测试数据SQL文件
    $sql_test_file = ROOT_PATH . './install/iwebshop_test.sql';
    if ($install_type == 'all' && !file_exists($sql_test_file)) {
        showProgress(array('isError' => true, 'message' => '测试数据SQL文件' . basename($sql_test_file) . '不存在'));
    }
    //执行SQL,创建数据库操作
    mysql_query("set names 'UTF8'");
    if (!@mysql_select_db($db_name)) {
        $DATABASESQL = '';
        if (version_compare(mysql_get_server_info(), '4.1.0', '>=')) {
            $DATABASESQL = "DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci";
        }
        if (!mysql_query('CREATE DATABASE `' . $db_name . '` ' . $DATABASESQL)) {
            showProgress(array('isError' => true, 'message' => '用户权限受限,创建' . $db_name . '数据库失败,请手动创建数据表'));
        }
    }
    if (!@mysql_select_db($db_name)) {
        showProgress(array('isError' => true, 'message' => $db_name . '数据库不存在' . mysql_error()));
    }
    //安装SQL
    parseSQL($sql_file);
    //安装测试数据
    if ($install_type == 'all') {
        parseSQL($sql_test_file);
    }
    //插入管理员数据
    $adminSql = 'insert into `' . $db_pre . 'admin` (`admin_name`,`password`,`role_id`,`create_time`) values ("' . $admin_user . '","' . md5($admin_pwd) . '",0,"' . date('Y-m-d H:i:s') . '")';
    if (!mysql_query($adminSql)) {
        showProgress(array('isError' => true, 'message' => '创建管理员失败' . mysql_error(), 'percent' => 0.9));
    }
    //写入配置文件
    $configDefFile = ROOT_PATH . './config/config_default.php';
    $configFile = ROOT_PATH . './config/config.php';
    $updateData = array('{TABLE_PREFIX}' => $db_pre, '{DB_R_ADDRESS}' => $db_address, '{DB_R_USER}' => $db_user, '{DB_R_PWD}' => $db_pwd, '{DB_R_NAME}' => $db_name, '{DB_W_ADDRESS}' => $db_address, '{DB_W_USER}' => $db_user, '{DB_W_PWD}' => $db_pwd, '{DB_W_NAME}' => $db_name, '{ENCRYPTKEY}' => md5(rand(1000000000, 9999999999)));
    $is_success = create_config($configFile, $configDefFile, $updateData);
    if (!$is_success) {
        showProgress(array('isError' => true, 'message' => '更新配置文件失败', 'percent' => 0.9));
    }
    //修改index.php首页
    $index_file = ROOT_PATH . './index.php';
    $index_content = '<?php
$iweb = dirname(__FILE__)."/lib/iweb.php";
$config = dirname(__FILE__)."/config/config.php";
require($iweb);
IWeb::createWebApp($config)->run();
?>';
    $is_success = file_put_contents($index_file, $index_content);
    if (!$is_success) {
        showProgress(array('isError' => true, 'message' => '生成index.php页面出错', 'percent' => 0.9));
    }
    //执行完毕
    showProgress(array('isError' => false, 'message' => '安装完成', 'percent' => 1));
}
 /**
  * Updates the changes towards the object with the given id.
  * @param integer Id of the item, to be deleted.
  */
 function process_object_update($id)
 {
     global $lang, $errors, $db, $page_action, $page_state;
     $cond = $this->item_pkname . " = {$id}";
     // configure DBO
     $page_action = "UPDATE";
     $page_state = "processing";
     $tip = new TextInput($lang->get("name"), $this->item_table, $this->item_name, $cond, "type:text,size:32,width:200", "UNIQUE&MANDATORY");
     $this->add($tip);
     $this->add(new Hidden("editing", $id));
     $this->check();
     $this->drawPage = "editing";
     if ($errors == "") {
         $name = value($this->item_table . "_" . $this->item_name);
         global $c_magic_quotes_gpc;
         if ($c_magic_quotes_gpc == 1) {
             $name = str_replace("\\", "", $name);
         }
         $pname = parseSQL($name);
         $sql = "UPDATE " . $this->item_table . " SET " . $this->item_name . " = '" . $pname . "' WHERE " . $this->item_pkname . " = {$id}";
         $query = new query($db, $sql);
         $query->free();
     }
     if ($errors == "") {
         $this->addToTopText($lang->get("savesuccess"));
     } else {
         $this->addToTopText($lang->get("procerror"));
         $this->setTopStyle("errorheader");
     }
 }
Example #10
0
}
$tempName = substr($query[0], stripos($query[0], 'from') + 5, stripos($query[0], $delimeter) - stripos($query[0], 'from') - 5);
$subquery = $xml->queries->xpath('query[@name="' . $tempName . '"]');
if (!$subquery) {
    $tableName = trim($tempName);
} else {
    if (stripos($subquery[0], 'where')) {
        $delimeter = 'where';
    } else {
        $delimeter = ';';
    }
    $tableName = trim(substr($subquery[0], stripos($subquery[0], 'from') + 5, stripos($subquery[0], $delimeter) - stripos($subquery[0], 'from') - 6));
}
//connect sourceTableName
$queryInfo = ['nodesId' => $nodesId, 'docId' => $docId, 'querySQL' => trim(strval($query[0])), 'subQuerySQL' => trim(strval($subquery[0]))];
$queryInfo['ParsedSQL'] = parseSQL($query[0], $subquery[0]);
//Вывод результата обработки
//echo SqlFormatter::format($query);
echo '<span class="querySQL">' . SqlFormatter::format($queryInfo['querySQL']) . '</span> <hr>';
//Текст запроса
echo '<span class="querySQL">' . SqlFormatter::format($queryInfo['subQuerySQL']) . '</span> <hr>';
//Подзапрос
if ($queryInfo['ParsedSQL']['subList']) {
    echo "<pre>";
    //print_r($queryInfo['ParsedSQL']['subList']);
    foreach ($queryInfo['ParsedSQL']['subList'] as $key => $value) {
        $key = strtoupper(trim($key));
        $alias = array_search($key, $fieldAlias);
        if ($alias === false) {
            $result[$key] = $value;
        } else {
Example #11
0
    unlink($sqlite_db);
}
//
// Initialisation de la base de données
//
$fs = sqlite_open($sqlite_db, 0666, $errstr);
if (!is_resource($fs)) {
    echo "Unable to create SQLite DB ({$errstr})\n";
    exit(0);
}
chmod($sqlite_db, 0666);
//
// Création de la structure de base
//
$sqldata = file_get_contents($schemas_dir . '/sqlite_tables.sql');
$queries = parseSQL($sqldata);
foreach ($queries as $query) {
    sqlite_exec($fs, $query);
}
//
// Injection des données en provenance de la base MySQL
//
$db = WaDatabase($dsn);
$tableList = array('wa_abo_liste', 'wa_abonnes', 'wa_admin', 'wa_auth_admin', 'wa_ban_list', 'wa_config', 'wa_forbidden_ext', 'wa_joined_files', 'wa_liste', 'wa_log', 'wa_log_files');
$tableList = str_replace('wa_', $prefixe, $tableList);
foreach ($tableList as $table) {
    printf("Populate table %s...\n", $table);
    flush();
    $fields = array();
    $result = sqlite_query($fs, "PRAGMA table_info({$table})");
    for ($i = 0, $m = sqlite_num_rows($result); $i < $m; $i++) {
Example #12
0
    displayLocalImage("images/warning.png", "view");
    exit;
}
$format = $_REQUEST['format'];
$type = $_REQUEST['type'];
$out = "";
$arr = array();
$style = "";
if ($_REQUEST['src'] == "form") {
    $arr = parseForm($_POST);
    $out = exportArray($arr, $format, "dataform", ".dataform {width:800px;height:auto !important;margin:auto;} .dataform tr td:nth-child(2) {width:200px;}");
} elseif ($_REQUEST['src'] == "memsql") {
    if (isset($_REQUEST['sqlid'])) {
        if (isset($_SESSION[$_REQUEST['sqlid']])) {
            $sql = $_SESSION[$_REQUEST['sqlid']];
            $arr = parseSQL($sql);
            $out = exportArray($arr, $format, "datatable", ".datatable {margin:auto;width:100%;} .datatable tr td {min-width:75px;}");
        } else {
            displayLocalImage("images/warning.png", "view");
            exit;
        }
    } else {
        displayLocalImage("images/warning.png", "view");
        exit;
    }
} elseif ($_REQUEST['src'] == "csv") {
    if (isset($_REQUEST['data'])) {
        $arr = parseCSV($_REQUEST['data']);
        $out = exportArray($arr, $format);
    } else {
        displayLocalImage("images/warning.png", "view");
	/**
	 * 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, $aclf, $db, $lang;
        global $forceLoadFromDB, $auth;

       $clt = getDBCell("cluster_template_items", "FKID", "CLTI_ID = ".$this->clti);

       if ($this->saction == "createCluster" && $id == value("id")) {
                $name = parseSQL(value("cluster_node_NAME".$id));
                if ($name=="0") $name = "Cluster";
                $name = makeCopyName("cluster_node", "NAME", $name, "1", "", false);
                $clnid = createClusterNode($name, $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->free();
                $forceLoadFromDB = "yes";
        }

        if ($this->editState && $this->editor) {
            $chclbox = new Container(4);
				$compoundEnvelope = new Container(3);
				$compoundContainer = new Container(3);

                $specialID = $id;
                $cpselector = new CPCLSelector($lang->get("select_cl"), "cluster_content", "FKID", "CLCID=$id", getModuleFromCLC($id), "", "");
                $cpselector->additionalAttribute = "onchange=\" if ( !confirm('".$lang->get("confirm_unsaved_changes_linkedcluster", "Note: When changing the linked cluster, any changes you apply on the currently linked cluster will be lost. If you want to save these canges, save your work first and change the linked cluster then. Proceed ?")."') ) { for(i=0; i<document.form1.cluster_content_FKID$specialID.length; i++)  if(document.form1.cluster_content_FKID$specialID.options[i].defaultSelected == true) document.form1.cluster_content_FKID$specialID.options[i].selected=true; }\"";
                $variation = variation();
                // force save in dbo.
                //$clnid = getDBCell("cluster_content", "FKID", "CLCID = ".$id);
                if (!isset($clnid)) {
                    $clnid = $cpselector->value;
                } else {
                    $cpselector->value = $clnid;
                }
                $clid = getClusterFromNode($clnid, $variation);
                $chclbox->add( $cpselector );
                $forceLoadFromDB = "no";


                if ($clnid != "" && $clnid != "0") {
				    $clid = getClusterFromNode($clnid, $variation);
                    $name = getDBCell("cluster_node", "NAME", "CLNID = $clnid");
                }
                
				$infoboxid = $id;
				$chclboxid = $id;

				$table = '<table width="100% border="0" cellpadding="0" cellspacing="0"><tr><td>';
				$table.= $lang->get("cllink", "This box is linked to ")."&nbsp; <b>".$name."</b>";
				$table.= '</td><td align="right">';
				// Add-Button
				$ShowInfoButton = new LinkButtonInline("toggle_info_".$infoboxid, "show info", "box", "button", "toggle('showinfo_".$infoboxid."')");
				$CHCLButton = new LinkButtonInline("toggle_chcl_".$chclboxid, "change cluster", "box", "button", "toggle('chcl_".$chclboxid."')");
				$table.= $ShowInfoButton->draw()."&nbsp;".$CHCLButton->draw();
				$table.= '</td></tr></table>';
				
				$this->add(new Label("lbl", $table, "headbox", 2));

				if (getDBCell("cluster_content", "FKID", "CLCID = ".$id) != $clnid)
					$forceLoadFromDB = "yes";
	

			    $chclbox->add(new Cell("spacer", "standardlight", 1));
			    $chclbox->add(new Label("lbl", "or create a new instance called", "standardlight"));
			    $chclbox->add(new Input("cluster_node_NAME$id", "", "standardlight", 32));
			    $chclbox->add(new SingleHidden("clt", ""));
			    $chclbox->add(new SingleHidden("id", ""));
			    $chclbox->add(new LinkButtonInCell("neueInstanz", "Create Instance", "standardlight navelement", "button", "javascript:if (confirm('".$lang->get("confirm_unsaved_changes")."')) { document.form1.saction.value='createCluster';document.form1.id.value='$id';document.form1.clt.value='$clt';document.form1.submit(); };", "form1", 1));

			    $sql = "SELECT * FROM variations WHERE 1";
			    $variations = new query($db, $sql);
			    while ($variations->getrow()) {
				    $chclbox->add(new Hidden("cluster_variations_VARIATION_ID_".$variations->field("VARIATION_ID"), "1"));
			    }

			    $specialID = "";
                $compoundContainer->add(new IDWrapper("chcl_".$chclboxid, $chclbox, "embedded", ' style="display:'.(($clid == 0) ? "" : "none" ).';" ', 3));

                if ($clid != "0" && $clid != "") {
        			// GET CONTENT OF THE CLUSTER
    				// set variables that will contain the content later to null.
    				$clusters = null;
    				$plugins = null;
    				$types = null;

    				// get the structure of the content.
    				$sql = "SELECT CLTI_ID, CLTITYPE_ID FROM cluster_template_items WHERE CLT_ID = $clt AND FKID!=0 ORDER BY POSITION";

    				$query = new query($db, $sql);

    				while ($query->getrow()) {
    					$cltitype = $query->field("CLTITYPE_ID");

    					$ni = count($plugins);
    					$plugins[$ni] = $query->field("CLTI_ID");
    					$types[$ni] = $cltitype;
    				}

    				$query->free();

    				// we don't want to draw an additional back link in clusters-editor
    				// if (! $sitepage && ! $isArticle) {
    				//	$compoundContainer->add(new LinkLabel("link1", $lang->get("back_to_cv", "Back to cluster overview"), "modules/cluster/clusterbrowser.php?sid=$sid&clt=$clt", "_self", "informationheader", 2));
    				// }

    				$infobox = new Container(3);

    				// draw some cluster-information.
    				$infobox->add(new Subtitle("", $lang->get("cluster_information", "Information about this record"), 3));
    				$infobox->add(new ClusterInformation($clid));

    				$compoundContainer->add(new IDWrapper("showinfo_".$infoboxid, $infobox, "embedded", ' style="display:none;" ', 3));
    				// draw plugin preview.

    				$len = count($plugins);
    				if ($clid) {
    					for ($i = 0; $i < $len; $i++) {

                            if ($types[$i] == 2)
    							$compoundContainer->add(new ContentEnvelope($plugins[$i], $clid, true));

    						if ($types[$i] == 4)
    							$compoundContainer->add(new ClusterEnvelope($plugins[$i], $clid, true));

    						if ($types[$i] == 5)
    							$compoundContainer->add(new LibraryEnvelope($plugins[$i], $clid, true));

    						if ($types[$i] == 6)
    							$compoundContainer->add(new CompoundClusterEnvelope($plugins[$i], $clid, true));

    				        if ($types[$i] == 8)
    				          $compoundContainer->add(new ChannelEnvelope($plugins[$i], $clid, true));
    					}
    					if ($isArticle || $action == $lang->get("edit_all") || ($action == $lang->get("save")) || $action == $lang->get("save_back")) {
    				       	$compoundContainer->add(new NonDisplayedValue("cluster_variations", "LAST_CHANGED", "CLID = ".$clid, "(NOW()+0)", "NUMBER"));
    						$compoundContainer->add(new NonDisplayedValue("cluster_variations", "LAST_USER", "CLID = ".$clid, $auth->userName, "TEXT"));
    					}
    				}
                }
                $compoundEnvelope->add(new IDWrapper("compoundEnvelope_$id", $compoundContainer, "embedded sub", '', 3));
                $this->add(new IDWrapper("compoundCluster_$id", $compoundEnvelope, "boxed", '', 3));

		} 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);
				$cltname = getDBCell("cluster_templates", "NAME", "CLT_ID = ".$clt);
				$cat = getDBCell("cluster_templates", "CATEGORY_ID", "CLT_ID = " . $clt);
				$name = "<br><b>" . $lang->get("cli"). "</b> " .$cltname."/".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\">".$lang->get("goto_cl", "Goto Cluster")."</a>";
				if ($aclf->checkAccessToFunction("B_PREVIEW_PAGE")) $buttons .= drawSpacer(10, 1). "<a href=\"#\" onClick=\"window.open('" . $c["docroot"] . "modules/cluster/previewcpcl.php?sid=$sid&oid=$myfk', 'cppreview', 'width=400,height=400,location=no,menubar=no,toolbar=no');return false;\"  class=\"box\">".$lang->get("preview")."</a>";
			}
			$this->add(new Label("lbl", $name, "", 1));
			$this->add(new AlignedLabel('lbl', $buttons, 'right', '', 1));
		}

	}
		/**
		 * creates a new object in the container.
		 */
		function process_new() {
			global $errors, $db, $go, $oid, $newitem, $lang;
			$newitem = value("newitem", "NUMERIC");
			$go = value("go");
			$oid = value("oid", "NUMERIC");

			// check, if any errors happened, while checking and drawing the form.
			if ($errors == "") {
				$maxpos = $this->getMaxPos();

				$position = value($this->item_table . "_POSITION", "NUMERIC");
				global $c_magic_quotes_gpc;
				$name = value($this->item_table . "_" . $this->item_name);

				if ($c_magic_quotes_gpc == 1)
					$name = str_replace("\\", "", $name);

				if ($position == 0)
					$position = 1;

				if ($position > $maxpos) {
					$position = $maxpos + 1;
				} else {
					// reorder the positions of the item.
					$sql = "UPDATE " . $this->item_table . " SET POSITION = (POSITION+1) WHERE " . $this->item_parentKeyName . " = $oid AND POSITION >= $position";
					$query = new query($db, $sql);
				}

				// create new record in db.
				$nextId = nextGUID();
				$pname = parseSQL($name);
				$sql = "INSERT INTO " . $this->item_table . " (" . $this->item_pkname . "," . $this->item_parentKeyName . "," . $this->item_name . ", POSITION," . $this->item_fkname . ") VALUES  (" . $nextId . "," . $oid . ",'" . $pname . "'," . $position . "," . $newitem . ")";
				$query = new query($db, $sql);
				$this->synchronize();

				if ($errors == "") {
					$text = "";
					
					$text .= "<br><b>" . $lang->get("name"). ":</b> " . $name . "<br>";
					$text .= "<b>" . $lang->get("cltposition", "Position"). ":</b> " . $position . "<br>";
					$text .= "<b>" . $lang->get("type"). ":</b> " . getDBCell($this->new_table, $this->new_name, $this->new_pkname . "=" . $newitem). "<br><br>";
					echo '<tr><td colspan="2"><br></td></tr>';
					echo '<tr><td colspan="2" class="headbox">'.$lang->get('created_item', 'The following Placeholder was created:').'</td></tr>';
					echo '<tr><td colspan="2">'.$text.'</td></tr>';
					
				}
			}
		}
				/**
				 * Updates the changes towards the object with the given id.
				 * @param integer Id of the item, to be deleted.
				 */
				function process_object_update($id) {
					global $lang, $errors, $db, $page_action, $page_state, $selectci;
					$selectci = value("selectci");
					$cond = $this->item_pkname . " = $id";
					// configure DBO
					$page_action = "UPDATE";
					$page_state = "processing";					
					$this->add(new Hidden("editing", $id));
					$this->check();
					$this->drawPage = "editing";
					if ($errors == "") {
						$name = value($this->item_table . "_" . $this->item_name);

						global $c_magic_quotes_gpc;

						if ($c_magic_quotes_gpc == 1)
							$name = str_replace("\\", "", $name);

						$pname = parseSQL($name);
						$type = value($this->item_table . "_FKID", "NUMERIC");
						$mincard = value($this->item_table . "_MINCARD", "NUMERIC");
						$maxcard = value($this->item_table . "_MAXCARD", "NUMERIC");
						$exclusive = value($this->item_table . "_EXCLUSIVE", "NUMERIC", "0");
						// SWAP
						if ($mincard > $maxcard) {
							$temp = $mincard;

							$mincard = $maxcard;
							$maxcard = $temp;
						}
						$cltitypeId = getDBCell($this->item_table, "CLTITYPE_ID", $cond);
						$fkId = getDBCell($this->item_table, "FKID", $cond);

						$uds = new UpdateSet("cluster_template_items", "CLTI_ID = $id");

						switch ($cltitypeId) {
							case 1: // static content
								$uds->add("NAME", $pname, "TEXT");

								global $sel_object;
								
								$sel_object = value("cluster_template_items_FKID");
								$uds->add("FKID", $sel_object, "NUMBER");																		
								break;

							case 2: // dynamic content
								if ($fkId == 0)
									$uds->add("FKID", $type, "NUMBER");

								$uds->add("MINCARD", $mincard, "NUMBER");
								$uds->add("MAXCARD", $maxcard, "NUMBER");
								$uds->add("NAME", $pname, "TEXT");
								$uds->add("EXCLUSIVE", $exclusive, "NUMBER");
								if ($fkId != 0) {
									$classname = getDBCell("modules", "CLASS", "MODULE_ID = ".$fkId);									
									$ref = new $classname(0, $id);								
									$ref->editConfig();
									$ref->processConfig();

								}	
								break;

							case 3: // static cluster
								$uds->add("NAME", $pname, "TEXT");

								global $sel_object;
								$sel_object = value("sel_object", "NUMERIC");

								if ($sel_object != 0) {
									$uds->add("FKID", $sel_object, "NUMBER");
									
								}

								break;

							case 4: //dynamic cluster
								if ($fkId == 0) {
									global $cluster_template_items_FKID;
									
									$cluster_template_items_FKID = value("cluster_template_items_FKID", "NUMERIC");
									$uds->add("FKID", $cluster_template_items_FKID, "NUMBER");
								}

								$uds->add("MINCARD", $mincard, "NUMBER");
								$uds->add("MAXCARD", $maxcard, "NUMBER");
								$uds->add("NAME", $pname, "TEXT");
								$uds->add("EXCLUSIVE", $exclusive, "NUMBER");
								break;

							case 5:
								if ($fkId == 0)
									$uds->add("FKID", $type, "NUMBER");

								$uds->add("MINCARD", $mincard, "NUMBER");
								$uds->add("MAXCARD", $maxcard, "NUMBER");
								$uds->add("NAME", $pname, "TEXT");
								$uds->add("EXCLUSIVE", $exclusive, "NUMBER");
								break;
							case 6: // compound
								if ($fkId == 0) {
									global $cluster_template_items_FKID;
									$cluster_template_items_FKID = value("cluster_template_items_FKID", "NUMERIC");
									$uds->add("FKID", $cluster_template_items_FKID, "NUMBER");
								}

								$uds->add("MINCARD", $mincard, "NUMBER");
								$uds->add("MAXCARD", $maxcard, "NUMBER");
								$uds->add("NAME", $pname, "TEXT");
								$uds->add("EXCLUSIVE", $exclusive, "NUMBER");
								break;
							case 7: // compound group

								global $cluster_template_items_FKID;
								$cluster_template_items_FKID = value("cluster_template_items_FKID", "NUMERIC");
								$uds->add("FKID", $cluster_template_items_FKID, "NUMBER");
								$uds->add("MINCARD", 1, "NUMBER");
								$uds->add("MAXCARD", 1, "NUMBER");
								$uds->add("NAME", $pname, "TEXT");								
								break;

                          		  case 8: //channel                               			
                               			 $uds->add("MINCARD", $mincard, "NUMBER");
                               			 $uds->add("MAXCARD", $maxcard, "NUMBER");
                               			 $uds->add("FKID", 1, "NUMBER");
                               			 $uds->add("NAME", $pname, "TEXT");
                               			 $uds->add("EXCLUSIVE", $exclusive, "NUMBER");
                              			  break;
						}

						global $search;											
						$search = value("search");
						if ($search == "0") {
							$uds->execute();							
							if ($errors == "") {
								$this->ready = true;	
								$this->addToTopText($lang->get("savesuccess"));
							} else {
								$this->addToTopText($lang->get("procerror"));
								$this->setTopStyle("errorheader");
							}
						}
					} else {
						// display errors.
					}
					$this->draw_edit($id);
				}
		/**
		 * Import the data
		 * @param string XML, generated with export function.
		 */
		function import($data) {
			$xmlOptions = array(XML_OPTION_CASE_FOLDING => TRUE, XML_OPTION_SKIP_WHITE => TRUE);
    		$xml =& new XPath(FALSE, $xmlOptions);
    		$xml->importFromString($data);
    		$content = urldecode($xml->getData('/NX:CONTENT[@type="LABEL"]'));
    		if ($content != false) {
    			$content = parseSQL($content);
    			$sql = "UPDATE $this->management_table SET CONTENT = '$content' WHERE $this->pk_name = $this->fkid";
    			global $db;
    			$query = new query($db, $sql);
    			$query->free();    			
    		}
		}
Example #17
0
         $data = decompress_filedata($tmp_filename, $file_ext);
         //
         // S'il y a une restriction d'accés par l'open_basedir, et que c'est un fichier uploadé,
         // nous avons dù le déplacer dans le dossier des fichiers temporaires du script, on le supprime.
         //
         if ($unlink) {
             require WA_ROOTDIR . '/includes/class.attach.php';
             Attach::remove_file($tmp_filename);
         }
     } else {
         $output->redirect('./tools.php?mode=restore', 4);
         $message = $lang['Message']['No_data_received'];
         $message .= '<br /><br />' . sprintf($lang['Click_return_back'], '<a href="' . sessid('./tools.php?mode=restore') . '">', '</a>');
         $output->message($message);
     }
     $queries = parseSQL($data);
     $db->beginTransaction();
     fake_header(false);
     foreach ($queries as $query) {
         $db->query($query) || trigger_error('Erreur sql lors de la restauration', ERROR);
         fake_header(true);
     }
     $db->commit();
     $output->message('Success_restore');
 }
 $output->addHiddenField('sessid', $session->session_id);
 $output->set_filenames(array('tool_body' => 'restore_body.tpl'));
 $output->assign_vars(array('L_TITLE_RESTORE' => $lang['Title']['restore'], 'L_EXPLAIN_RESTORE' => nl2br($lang['Explain']['restore']), 'L_FILE_LOCAL' => $lang['File_local'], 'L_VALID_BUTTON' => $lang['Button']['valid'], 'L_RESET_BUTTON' => $lang['Button']['reset'], 'S_HIDDEN_FIELDS' => $output->getHiddenFields(), 'S_ENCTYPE' => FILE_UPLOADS_ON ? 'multipart/form-data' : 'application/x-www-form-urlencoded'));
 if (FILE_UPLOADS_ON) {
     //
     // L'upload est disponible sur le serveur
/**
 * Create a figure for a cluster-tempalte
 * @param string name of the figur
 * @param integer GUID of the Template
 * @param integer Position in the template
 * @param integer minimum cardinality of this figure
 * @param integer maximum cardinality of this figure
 * @param integer configuration value for this figure
 * @param integer type-ID of this figure (actually 1-8). Refer to table cluster_template_item_types
 */
function createClusterTemplateFigure($name, $clt, $position, $maxcard, $mincard, $config, $type)
{
    global $db;
    $name = makeCopyName("cluster_template_items", "NAME", parseSQL($name), "CLT_ID = {$clt}");
    $newId = nextGUID();
    $sql = "INSERT INTO cluster_template_items (CLTI_ID, CLT_ID, NAME, POSITION, MINCARD, MAXCARD, FKID, CLTITYPE_ID, DELETED, VERSION) VALUES ({$newId}, {$clt}, '{$name}', {$position}, {$mincard}, {$maxcard}, {$config}, {$type}, 0,0)";
    $query = new query($db, $sql);
    $query->free();
    return $newId;
}
Example #19
0
		/**
		 * Creates a cluster and a cluster-node for the given clt. returns the clnid.
	 	 * Can only import dynamic content and dynamic clusters (GUIDs of Cluster_node!).
	 	 * @param string name of the cluster
	 	 * @param string GUID of Cluster template
	 	 * @param string ID od Variation to use
	 	 * @param string array with data to post to plugins, like array("Headline" => "Test Headline", ...)
	 	 * @param string Username to use for create
		 */
		function createCluster($name, $clt, $variationId, $data, $createUser="******") {
			$name = parseSQL($name);
			return createCluster2($name, $clt, $variationId, $data, $createUser);		
		}
 /**
  * Search the cluster for a keyword
  * @param string Searchphrase
  */
  function search($searchphrase) {
     global $db;
     $result = array();
     $searchphrase = strtoupper(parseSQL($searchphrase));                
     if ($this->pluginTableName != "" && is_array($this->index)) {
       if (count($this->index) > 0 ) {
          $sql = "SELECT FKID FROM ".$this->pluginTableName." $columns WHERE UPPER(CONTENT) LIKE '%" . $searchphrase . "%' AND FKID IN (".implode(",", $this->index).")";   
          $query = new query($db, $sql);
          while ($query->getrow()) {
             $result[] = $query->field("FKID");
           }
           $result = createCLNIDsFromCLCIDs($result);
         }
     }
     return $result;
  }