Location: PHPKode > projects > PHPGEN > pcg/Include/FuncPage.php
<?php
/**
 * Functions to deal with Page.
 *
 * 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     Include
 * @version     $Id: FuncPage.php,v 1.4 2006/08/15 14:36:35 wangcs Exp $
 */
/**
 * Get the full path of one project's page's config files saving dir of a user.
 *
 * @author                      wwccss <hide@address.com>
 * @param   string  $UserName
 * @param   int     $ProjectID
 * @return  string              the full path of the tables' config file save dir.
 */
function pageGetHome($UserName, $ProjectID)
{
    global $_CFG;
    return prjGetHome($UserName, $ProjectID) . $_CFG["PageHome"];
}

/**
 * Get full path of pages index file of a project.
 *
 * @author                      wwccss <hide@address.com>
 * @param   string  $UserName
 * @param   int     $ProjectID
 * @return  string              the full path of the index file.
 */
function pageGetIndexFile($UserName, $ProjectID)
{
    global $_CFG;
    return prjGetHome($UserName, $ProjectID) . $_CFG["IndexPage"];
}

/**
 * Save pages indexes to file.
 *
 * @author                          wwccss <hide@address.com>
 * @param   string  $UserName
 * @param   int     $ProjectID
 * @param   string  $ArrayString    the array string created by array2String function.
 */
function pageSaveIndexFile($UserName, $ProjectID, $ArrayString)
{
    $IndexPage = pageGetIndexFile($UserName, $ProjectID);
    $FileID    = fopen($IndexPage, "w+");
    fwrite($FileID, $ArrayString);
    fclose($FileID);
}

/**
 * Get pages list of a project.
 *
 * @author                          wwccss <hide@address.com>
 * @param   string  $UserName
 * @param   int     $ProjectID
 * @return  array                   the pages list array.
 */
function pageGetList($UserName, $ProjectID)
{
    $IndexFile  = pageGetIndexFile($UserName, $ProjectID);
    if(file_exists($IndexFile))
    {
        require($IndexFile);
        sort($Pages);
        return $Pages;
    }
    else
    {
        return false;
    }
}

/**
 * Get the full path of the config file of a page.
 *
 * @author                      wwccss <hide@address.com>
 * @param   string  $UserName
 * @param   int     $ProjectID
 * @param   string  $PageCFG    the relative file name of a page's config file.
 * @return  string              the full path of the page's config file.
 */
function pageGetConfigFile($UserName, $ProjectID, $PageCFG)
{
    return pageGetHome($UserName, $ProjectID) . $PageCFG;
}

/**
 * Write defination of a page to file.
 *
 * @author                      wwccss <hide@address.com>
 * @param   string  $UserName
 * @param   int     $ProjectID
 * @param   string  $PageCFG    the relative file name of a page's config file.
 * @param   string  $ArraySting the array string created by array2String function.
 */
function pageSaveConfigFile($UserName, $ProjectID, $PageCFG, $ArrayString)
{
    $PageCFG = pageGetConfigFile($UserName, $ProjectID, $PageCFG);
    !file_exists(dirname($PageCFG)) ? sysMkdir(dirname($PageCFG)) : "";
    $FileID  = fopen($PageCFG, "w+");
    fwrite($FileID, $ArrayString);
    fclose($FileID);
}

/**
 * Get defination vars of a page.
 *
 * @author                      wwccss <hide@address.com>
 * @param   string  $UserName
 * @param   int     $ProjectID
 * @param   string  $PageCFG    the relative file name of a page's config file.
 * @return  array               the defination array of the page.
 */
function pageGetInfo($UserName, $ProjectID, $PageCFG)
{
    $PageCFG = pageGetConfigFile($UserName, $ProjectID, $PageCFG);
    if(file_exists($PageCFG))
    {
        require($PageCFG);
        return $Page;
    }
    else
    {
        return false;
    }
}
?>
<?php
/**
 * $Log: FuncPage.php,v $
 * Revision 1.4  2006/08/15 14:36:35  wangcs
 *  * Add copyright info.
 *
 * Revision 1.3  2006/04/22 03:54:54  wangcs
 *  * Change to PHPGEN.
 *
 * Revision 1.2  2006/02/01 08:25:56  wangcs
 *  * pageGetList(): sort the pages.
 *
 * Revision 1.1  2006/01/23 09:27:30  wangcs
 * *** empty log message ***
 *
 */
?>
Return current item: PHPGEN