<?php
/**
* List user's project.
*
* PHPGEN is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* PHPGEN is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PHPGEN; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @copyright EasySoft R&D Team (C) 2006
* @author Chunsheng Wang <hide@address.com>
* @link http://www.phpgen.com
* @package Project
* @version $Id: ListProject.php,v 1.6 2006/08/15 15:53:51 wangcs Exp $
*/
require_once("../Include/Init.php");
require_once("TreeMenu.class.php");
/* Init the TreeMenu class. */
$ImgDir = $_CFG["BaseURL"] . "Images/TreeMenu";
$LinkTarget = "main";
$Icon = 'folder.gif';
$ExpandedIcon = 'folder-expanded.gif';
$Menu = new HTML_TreeMenu();
if($_SESSION["Projects"])
{
/* Add projects info to the tree. */
foreach($_SESSION["Projects"] as $ProjectID => $Project)
{
unset($Node);
/* Add Project level node. */
$Node = new HTML_TreeNode(array("text" => $Project["Label"], "link" => "EditProject.php?ProjectID=$ProjectID&Mode=Edit", "linkTarget" => $LinkTarget, "icon" => $Icon, "expandedIcon" => $ExpandedIcon));
$Menu->addItem($Node);
/* Second level node: db and page. */
$NodeDB = &$Node->addItem(new HTML_TreeNode(array("text" => $_TPL["Database"] . $Project["DSN"]["Database"],
"link" => "../Table/ManageDB.php?ProjectID=$ProjectID",
"linkTarget" => $LinkTarget,
"icon" => $Icon,
"expandedIcon" => $ExpandedIcon)));
$NodePage = &$Node->addItem(new HTML_TreeNode(array("text" => $_TPL["Page"],
"link" => "../Page/ManagePage.php?ProjectID=$ProjectID",
"linkTarget" => $LinkTarget,
"icon" => $Icon,
"expandedIcon" => $ExpandedIcon)));
/* Add tables to db node. */
$UserDB = prjConnectDB($_SESSION["UserName"], $ProjectID);
$Tables = tblGetList($_SESSION["UserName"], $ProjectID);
if(empty($Tables))
{
$Tables = dbGetTables($UserDB);
foreach($Tables as $Key => $TableName)
{
unset($Tables[$Key]);
$Tables[$TableName]["Label"] = $TableName;
}
}
foreach($Tables as $TableName => $Table)
{
$NodeDB->addItem(new HTML_TreeNode(array("text" => "$Table[Label]",
"link" => "../Table/ManageTable.php?ProjectID=$ProjectID&TableName=$TableName",
"linkTarget" => $LinkTarget)));
}
/* Add pages to page node. */
$Pages = pageGetList($_SESSION["UserName"], $ProjectID);
foreach($Pages as $PageID => $Page)
{
$PageInfo = pageGetInfo($_SESSION["UserName"], $ProjectID, $Page);
$LinkURL = "../Page/Manage" . $PageInfo["Type"] . ".php?ProjectID=$ProjectID&TableName=$PageInfo[TableName]&PageCFG=$Page";
$NodePage->addItem(new HTML_TreeNode(array("text" => "$Page",
"link" => $LinkURL,
"linkTarget" => $LinkTarget)));
}
}
/* Build the TreeMenu to DHTML. */
$TreeMenu = &new HTML_TreeMenu_DHTML($Menu, array("images" => $ImgDir));
$ProjectTree = $TreeMenu->toHtml();
$MyTPL->assign("ProjectTree", $ProjectTree);
}
/* Display.*/
$MyTPL->display($_TPL["TplFile"]);
?>