<?php
/**
 * Functions to deal with codes.
 *
 * 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 <wwccss@263.net>
 * @link        http://www.phpgen.com
 * @package     Include
 * @version     $Id: FuncCode.php,v 1.3 2006/08/15 14:36:35 wangcs Exp $
 */

/**
 * Get the full path of one project's codes saving dir of a user.
 *
 * @author                      wwccss <wwccss@263.net>
 * @param   string  $UserName
 * @param   int     $ProjectID
 * @return  string              the full path of the code save dir.
 */
function codeGetHome($UserName, $ProjectID)
{
    global $_CFG;
    return prjGetHome($UserName, $ProjectID) . $_CFG["CodeHome"] . prjGetCodeStyle($UserName, $ProjectID) . "/";
}

/**
 * Get the base url to demo the created php script.
 *
 * @author                      wwccss <wwccss@263.net>
 * @param   string  $UserName
 * @param   int     $ProjectID
 * @return  string              the relative url to BaseURL of PHPGEN system.
 */
function codeGetDemoBaseURL($UserName, $ProjectID)
{
    global $_CFG;
    return str_replace($_CFG["SysRoot"], "", codeGetHome($UserName, $ProjectID));
}

/**
 * Get the full pathes of the php and html file created by a page config file.
 *
 * Example: codeGetSavedFiles($_SESSION[UserName], $_SESSION[ProjectID], "Admin/BugFree_List.php")
 *
 * @author                      wwccss <wwccss@263.net>
 * @param   string  $UserName
 * @param   int     $ProjectID
 * @param   string  $PageCFG    the file name of the config file.
 * @return  array               an  array contains php file and html file.
 */
function codeGetSavedFiles($UserName, $ProjectID, $PageCFG)
{
    $Page = pageGetInfo($UserName, $ProjectID,   $PageCFG);
    if(!empty($Page))
    {
        $CodeFile["PHP"]  = codeGetHome($UserName, $ProjectID) . $Page["PhpFile"];
        $CodeFile["HTML"] = codeGetHome($UserName, $ProjectID) . "Templates/" . str_replace(".php", ".htm", $Page["PhpFile"]);
        return $CodeFile;
    }
    else
    {
        return false;
    }
}
?>
<?php
/**
 * $Log: FuncCode.php,v $
 * Revision 1.3  2006/08/15 14:36:35  wangcs
 *  * Add copyright info.
 *
 * Revision 1.2  2006/04/22 03:54:54  wangcs
 *  * Change to PHPGEN.
 *
 * Revision 1.1  2006/01/23 09:27:30  wangcs
 * *** empty log message ***
 *
 */
?>