Initial Commit of AgileBill Open Source

This commit is contained in:
unknown
2008-11-26 14:50:40 -08:00
parent ae5a0fc25e
commit 02306ccc47
2954 changed files with 410976 additions and 0 deletions

View File

@@ -0,0 +1,562 @@
<?php
// vim: set expandtab tabstop=4 shiftwidth=4:
// This code that was derived from the original PHPLIB Template class
// is copyright by Kristian Koehntopp, NetUSE AG and was released
// under the LGPL.
//
// Authors: Kristian Koehntopp <kris@koehntopp.de> (original from PHPLIB)
// Bjoern Schotte <bjoern@rent-a-phpwizard.de> (PEARification)
// Martin Jansen <mj@php.net> (PEAR conformance)
//
// $Id: PHPLIB.php,v 1.14 2003/06/11 06:03:32 bjoern Exp $
//
set_include_path(get_include_path().PATH_SEPARATOR.PATH_INCLUDES."pear");
require_once "PEAR.php";
/**
* Converted PHPLIB Template class
*
* For those who want to use PHPLIB's fine template class,
* here's a PEAR conforming class with the original PHPLIB
* template code from phplib-stable CVS. Original author
* was Kristian Koehntopp <kris@koehntopp.de>
*
* @author Bjoern Schotte <bjoern@rent-a-phpwizard.de>
* @author Martin Jansen <mj@php.net> (PEAR conformance)
* @version 1.0
*/
class Template_PHPLIB
{
/**
* If set, echo assignments
* @var bool
*/
var $debug = false;
/**
* $file[handle] = "filename";
* @var array
*/
var $file = array();
/**
* fallback paths that should be defined in a child class
* @var array
*/
var $file_fallbacks = array();
/**
* Relative filenames are relative to this pathname
* @var string
*/
var $root = "";
/*
* $_varKeys[key] = "key"
* @var array
*/
var $_varKeys = array();
/**
* $_varVals[key] = "value";
* @var array
*/
var $_varVals = array();
/**
* "remove" => remove undefined variables
* "comment" => replace undefined variables with comments
* "keep" => keep undefined variables
* @var string
*/
var $unknowns = "remove";
/**
* "yes" => halt, "report" => report error, continue, "no" => ignore error quietly
* @var string
*/
var $haltOnError = "report";
/**
* The last error message is retained here
* @var string
* @see halt
*/
var $_lastError = "";
/**
* Constructor
*
* @access public
* @param string template root directory
* @param string how to handle unknown variables
* @param array fallback paths
*/
function Template_PHPLIB($root = ".", $unknowns = "remove", $fallback="")
{
$this->setRoot($root);
$this->setUnknowns($unknowns);
if (is_array($fallback)) $this->file_fallbacks = $fallback;
}
/**
* Sets the template directory
*
* @access public
* @param string new template directory
* @return bool
*/
function setRoot($root)
{
if (!is_dir($root)) {
$this->halt("setRoot: $root is not a directory.");
return false;
}
$this->root = $root;
return true;
}
/**
* What to do with unknown variables
*
* three possible values:
*
* - "remove" will remove unknown variables
* (don't use this if you define CSS in your page)
* - "comment" will replace undefined variables with comments
* - "keep" will keep undefined variables as-is
*
* @access public
* @param string unknowns
*/
function setUnknowns($unknowns = "keep")
{
$this->unknowns = $unknowns;
}
/**
* Set appropriate template files
*
* With this method you set the template files you want to use.
* Either you supply an associative array with key/value pairs
* where the key is the handle for the filname and the value
* is the filename itself, or you define $handle as the file name
* handle and $filename as the filename if you want to define only
* one template.
*
* @access public
* @param mixed handle for a filename or array with handle/name value pairs
* @param string name of template file
* @return bool
*/
function setFile($handle, $filename = "")
{
if (!is_array($handle)) {
if ($filename == "") {
$this->halt("setFile: For handle $handle filename is empty.");
return false;
}
$this->file[$handle] = $this->_filename($filename);
} else {
reset($handle);
while (list($h, $f) = each($handle)) {
$this->file[$h] = $this->_filename($f);
}
}
}
/**
* Set a block in the appropriate template handle
*
* By setting a block like that:
*
* &lt;!-- BEGIN blockname --&gt;
* html code
* &lt;!-- END blockname --&gt;
*
* you can easily do repeating HTML code, i.e. output
* database data nice formatted into a HTML table where
* each DB row is placed into a HTML table row which is
* defined in this block.
* It extracts the template $handle from $parent and places
* variable {$name} instead.
*
* @access public
* @param string parent handle
* @param string block name handle
* @param string variable substitution name
*/
function setBlock($parent, $handle, $name = "")
{
if (!$this->_loadFile($parent)) {
$this->halt("setBlock: unable to load $parent.");
return false;
}
if ($name == "") {
$name = $handle;
}
$str = $this->getVar($parent);
$reg = "/[ \t]*<!--\s+BEGIN $handle\s+-->\s*?\n?(\s*.*?\n?)\s*<!--\s+END $handle\s+-->\s*?\n?/sm";
preg_match_all($reg, $str, $m);
$str = preg_replace($reg, "{" . "$name}", $str);
if (isset($m[1][0])) $this->setVar($handle, $m[1][0]);
$this->setVar($parent, $str);
}
/**
* Set corresponding substitutions for placeholders
*
* @access public
* @param string name of a variable that is to be defined or an array of variables with value substitution as key/value pairs
* @param string value of that variable
* @param boolean if true, the value is appended to the variable's existing value
*/
function setVar($varname, $value = "", $append = false)
{
if (!is_array($varname)) {
if (!empty($varname))
if ($this->debug) print "scalar: set *$varname* to *$value*<br>\n";
$this->_varKeys[$varname] = $this->_varname($varname);
($append) ? $this->_varVals[$varname] .= $value : $this->_varVals[$varname] = $value;
} else {
reset($varname);
while (list($k, $v) = each($varname)) {
if (!empty($k))
if ($this->debug) print "array: set *$k* to *$v*<br>\n";
$this->_varKeys[$k] = $this->_varname($k);
($append) ? $this->_varVals[$k] .= $v : $this->_varVals[$k] = $v;
}
}
}
/**
* Substitute variables in handle $handle
*
* @access public
* @param string name of handle
* @return mixed string substituted content of handle
*/
function subst($handle)
{
if (!$this->_loadFile($handle)) {
$this->halt("subst: unable to load $handle.");
return false;
}
return @str_replace($this->_varKeys, $this->_varVals, $this->getVar($handle));
}
/**
* Same as subst but printing the result
*
* @access public
* @brother subst
* @param string handle of template
* @return bool always false
*/
function pSubst($handle)
{
print $this->subst($handle);
return false;
}
/**
* Parse handle into target
*
* Parses handle $handle into $target, eventually
* appending handle at $target if $append is defined
* as TRUE.
*
* @access public
* @param string target handle to parse into
* @param string which handle should be parsed
* @param boolean append it to $target or not?
* @return string parsed handle
*/
function parse($target, $handle, $append = false)
{
if (!is_array($handle)) {
$str = $this->subst($handle);
($append) ? $this->setVar($target, $this->getVar($target) . $str) : $this->setVar($target, $str);
} else {
reset($handle);
while (list(, $h) = each($handle)) {
$str = $this->subst($h);
$this->setVar($target, $str);
}
}
return $str;
}
/**
* Same as parse, but printing it.
*
* @access public
* @brother parse
* @param string target to parse into
* @param string handle which should be parsed
* @param should $handle be appended to $target?
* @return bool
*/
function pParse($target, $handle, $append = false)
{
print $this->finish($this->parse($target, $handle, $append));
return false;
}
/**
* Return all defined variables and their values
*
* @access public
* @return array with all defined variables and their values
*/
function getVars()
{
reset($this->_varKeys);
while (list($k, ) = each($this->_varKeys)) {
$result[$k] = $this->getVar($k);
}
return $result;
}
/**
* Return one or more specific variable(s) with their values.
*
* @access public
* @param mixed array with variable names or one variable name as a string
* @return mixed array of variable names with their values or value of one specific variable
*/
function getVar($varname)
{
if (!is_array($varname)) {
if (isset($this->_varVals[$varname])) {
return $this->_varVals[$varname];
} else {
return "";
}
} else {
reset($varname);
while (list($k, ) = each($varname)) {
$result[$k] = (isset($this->_varVals[$k])) ? $this->_varVals[$k] : "";
}
return $result;
}
}
/**
* Get undefined values of a handle
*
* @access public
* @param string handle name
* @return mixed false if an error occured or the undefined values
*/
function getUndefined($handle)
{
if (!$this->_loadFile($handle)) {
$this->halt("getUndefined: unable to load $handle.");
return false;
}
preg_match_all("/{([^ \t\r\n}]+)}/", $this->getVar($handle), $m);
$m = $m[1];
if (!is_array($m)) {
return false;
}
reset($m);
while (list(, $v) = each($m)) {
if (!isset($this->_varKeys[$v])) {
$result[$v] = $v;
}
}
if (isset($result) && count($result)) {
return $result;
} else {
return false;
}
}
/**
* Finish string
*
* @access public
* @param string string to finish
* @return finished, i.e. substituted string
*/
function finish($str)
{
switch ($this->unknowns) {
case "remove":
$str = preg_replace('/{[^ \t\r\n}]+}/', "", $str);
break;
case "comment":
$str = preg_replace('/{([^ \t\r\n}]+)}/', "<!-- Template $handle: Variable \\1 undefined -->", $str);
break;
}
return $str;
}
/**
* Print variable to the browser
*
* @access public
* @param string name of variable to print
*/
function p($varname)
{
print $this->finish($this->getVar($varname));
}
/**
* Get finished variable
*
* @access public public
* @param string variable to get
* @return string string with finished variable
*/
function get($varname)
{
return $this->finish($this->getVar($varname));
}
/**
* Complete filename
*
* Complete filename, i.e. testing it for slashes
*
* @access private
* @param string filename to be completed
* @return string completed filename
*/
function _filename($filename)
{
if (substr($filename, 0, 1) != "/") {
$filename = $this->root."/".$filename;
}
if (file_exists($filename)) return $filename;
if (is_array($this->file_fallbacks) && count($this->file_fallbacks) > 0) {
reset($this->file_fallbacks);
while (list(,$v) = each($this->file_fallbacks)) {
if (file_exists($v.basename($filename))) return $v.basename($filename);
}
$this->halt(sprintf("filename: file %s does not exist in the fallback paths %s.",$filename,implode(",",$this->file_fallbacks)));
return false;
} else {
$this->halt(sprintf("filename: file %s does not exist.",$filename));
return false;
}
return $filename;
}
/**
* Protect a replacement variable
*
* @access private
* @param string name of replacement variable
* @return string replaced variable
*/
function _varname($varname)
{
return "{".$varname."}";
}
/**
* load file defined by handle if it is not loaded yet
*
* @access private
* @param string handle
* @return bool FALSE if error, true if all is ok
*/
function _loadFile($handle)
{
if (isset($this->_varKeys[$handle]) and !empty($this->_varVals[$handle])) {
return true;
}
if (!isset($this->file[$handle])) {
$this->halt("loadfile: $handle is not a valid handle.");
return false;
}
$filename = $this->file[$handle];
if (function_exists("file_get_contents")) {
$str = file_get_contents($filename);
} else {
if (!$fp = @fopen($filename,"r")) {
$this->halt("loadfile: couldn't open $filename");
return false;
}
$str = fread($fp,filesize($filename));
fclose($fp);
}
if ($str=='') {
$this->halt("loadfile: While loading $handle, $filename does not exist or is empty.");
return false;
}
$this->setVar($handle, $str);
return true;
}
/**
* Error function. Halt template system with message to show
*
* @access public
* @param string message to show
* @return bool
*/
function halt($msg)
{
$this->_lastError = $msg;
if ($this->haltOnError != "no") {
return $this->haltMsg($msg);
}
return false;
}
/**
* printf error message to show
*
* @access public
* @param string message to show
* @return object PEAR error object
*/
function haltMsg($msg)
{
PEAR::raiseError(sprintf("<b>Template Error:</b> %s<br>\n", $msg));
}
}
?>

View File

@@ -0,0 +1,955 @@
<?php
// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
/**
* This file contains the code of the LayersMenuCommon class.
* @package PHPLayersMenu
*/
/**
* This is the "common" class of the PHP Layers Menu library.
*
* You need to include PEAR.php and DB.php if (and only if) you want to use the DB support provided by ths class.
*
* @version 3.2.0-rc
* @package PHPLayersMenu
*/
class LayersMenuCommon
{
/**
* The name of the package
* @access private
* @var string
*/
var $_packageName;
/**
* The version of the package
* @access private
* @var string
*/
var $version;
/**
* The copyright of the package
* @access private
* @var string
*/
var $copyright;
/**
* The author of the package
* @access private
* @var string
*/
var $author;
/**
* URL to be prepended to the menu hrefs
* @access private
* @var string
*/
var $prependedUrl = '';
/**
* Do you want that code execution halts on error?
* @access private
* @var string
*/
var $haltOnError = 'yes';
/**
* The base directory where the package is installed
* @access private
* @var string
*/
var $dirroot;
/**
* The "libjs" directory of the package
* @access private
* @var string
*/
var $libjsdir;
/**
* The directory where images related to the menu can be found
* @access private
* @var string
*/
var $imgdir;
/**
* The http path corresponding to imgdir
* @access private
* @var string
*/
var $imgwww;
/**
* The directory where icons of menu items can be found
* @access private
* @var string
*/
var $icondir;
/**
* The http path corresponding to icondir
* @access private
* @var string
*/
var $iconwww;
/**
* This array may contain width and height of all icons
* @access private
* @var integer
*/
var $iconsize = array();
/**
* If this var is false, width and height of icons have to be detected; if this var is true, width and height of icons are not detected and are retrieved from the iconsize array
* @access private
* @var boolean
*/
var $issetIconsize = false;
/**
* The directory where templates can be found
* @access private
* @var string
*/
var $tpldir;
/**
* The string containing the menu structure
* @access private
* @var string
*/
var $menuStructure;
/**
* It counts nodes for all menus
* @access private
* @var integer
*/
var $_nodesCount;
/**
* A multi-dimensional array to store informations for each menu entry
* @access private
* @var array
*/
var $tree;
/**
* A multi-dimensional array used only with the DB support; for each $menu_name, it stores the $cnt associated to each item id
*
* This array is needed for selection of the current item
* through the corresponding id (see the DB table structure)
* as, internally, items are stored, sorted and addressed in terms of $cnt
*
* @access private
* @var array
*/
var $treecnt;
/**
* The maximum hierarchical level of menu items
* @access private
* @var integer
*/
var $_maxLevel;
/**
* An array that counts the number of first level items for each menu
* @access private
* @var array
*/
var $_firstLevelCnt;
/**
* An array containing the number identifying the first item of each menu
* @access private
* @var array
*/
var $_firstItem;
/**
* An array containing the number identifying the last item of each menu
* @access private
* @var array
*/
var $_lastItem;
/**
* Data Source Name: the connection string for PEAR DB
* @access private
* @var string
*/
var $dsn = 'pgsql://dbuser:dbpass@dbhost/dbname';
/**
* DB connections are either persistent or not persistent
* @access private
* @var boolean
*/
var $persistent = false;
/**
* Name of the table storing data describing the menu
* @access private
* @var string
*/
var $tableName = 'phplayersmenu';
/**
* Name of the i18n table corresponding to $tableName
* @access private
* @var string
*/
var $tableName_i18n = 'phplayersmenu_i18n';
/**
* Names of fields of the table storing data describing the menu
*
* default field names correspond to the same field names foreseen
* by the menu structure format
*
* @access private
* @var array
*/
var $tableFields = array(
'id' => 'id',
'parent_id' => 'parent_id',
'text' => 'text',
'href' => 'href',
'title' => 'title',
'icon' => 'icon',
'target' => 'target',
'orderfield' => 'orderfield',
'expanded' => 'expanded'
);
/**
* Names of fields of the i18n table corresponding to $tableName
* @access private
* @var array
*/
var $tableFields_i18n = array(
'language' => 'language',
'id' => 'id',
'text' => 'text',
'title' => 'title'
);
/**
* A temporary array to store data retrieved from the DB and to perform the depth-first search
* @access private
* @var array
*/
var $_tmpArray = array();
/**
* The constructor method; it initializates the menu system
* @return void
*/
function LayersMenuCommon()
{
$this->_packageName = 'PHP Layers Menu';
$this->version = '3.2.0-rc';
$this->copyright = '(C) 2001-2004';
$this->author = 'Marco Pratesi - http://www.marcopratesi.it/';
$this->prependedUrl = '';
$this->dirroot = './';
$this->libjsdir = 'includes/phplayers/libjs/';
$this->imgdir = 'includes/phplayers/menuimages/';
$this->imgwww = 'includes/phplayers/menuimages/';
$this->icondir = 'includes/phplayers/menuicons/';
$this->iconwww = 'includes/phplayers/menuicons/';
$this->tpldir = './templates/';
$this->menuStructure = '';
$this->separator = '|';
$this->_nodesCount = 0;
$this->tree = array();
$this->treecnt = array();
$this->_maxLevel = array();
$this->_firstLevelCnt = array();
$this->_firstItem = array();
$this->_lastItem = array();
}
/**
* The method to set the prepended URL
* @access public
* @return boolean
*/
function setPrependedUrl($prependedUrl)
{
// We do not perform any check
$this->prependedUrl = $prependedUrl;
return true;
}
/**
* The method to set the dirroot directory
* @access public
* @return boolean
*/
function setDirrootCommon($dirroot)
{
if (!is_dir($dirroot)) {
$this->error("setDirroot: $dirroot is not a directory.");
return false;
}
if (substr($dirroot, -1) != '/') {
$dirroot .= '/';
}
$oldlength = strlen($this->dirroot);
$foobar = strpos($this->libjsdir, $this->dirroot);
if (!($foobar === false || $foobar != 0)) {
$this->libjsdir = $dirroot . substr($this->libjsdir, $oldlength);
}
$foobar = strpos($this->imgdir, $this->dirroot);
if (!($foobar === false || $foobar != 0)) {
$this->imgdir = $dirroot . substr($this->imgdir, $oldlength);
}
$foobar = strpos($this->icondir, $this->dirroot);
if (!($foobar === false || $foobar != 0)) {
$this->icondir = $dirroot . substr($this->icondir, $oldlength);
}
$foobar = strpos($this->tpldir, $this->dirroot);
if (!($foobar === false || $foobar != 0)) {
$this->tpldir = $dirroot . substr($this->tpldir, $oldlength);
}
$this->dirroot = $dirroot;
return true;
}
/**
* The method to set the libjsdir directory
* @access public
* @return boolean
*/
function setLibjsdir($libjsdir)
{
if ($libjsdir != '' && substr($libjsdir, -1) != '/') {
$libjsdir .= '/';
}
if ($libjsdir == '' || substr($libjsdir, 0, 1) != '/') {
$foobar = strpos($libjsdir, $this->dirroot);
if ($foobar === false || $foobar != 0) {
$libjsdir = $this->dirroot . $libjsdir;
}
}
if (!is_dir($libjsdir)) {
$this->error("setLibjsdir: $libjsdir is not a directory.");
return false;
}
$this->libjsdir = $libjsdir;
return true;
}
/**
* The method to set the imgdir directory
* @access public
* @return boolean
*/
function setImgdir($imgdir)
{
if ($imgdir != '' && substr($imgdir, -1) != '/') {
$imgdir .= '/';
}
if ($imgdir == '' || substr($imgdir, 0, 1) != '/') {
$foobar = strpos($imgdir, $this->dirroot);
if ($foobar === false || $foobar != 0) {
$imgdir = $this->dirroot . $imgdir;
}
}
if (!is_dir($imgdir)) {
$this->error("setImgdir: $imgdir is not a directory.");
return false;
}
$this->imgdir = $imgdir;
return true;
}
/**
* The method to set imgwww
* @access public
* @return void
*/
function setImgwww($imgwww)
{
if ($imgwww != '' && substr($imgwww, -1) != '/') {
$imgwww .= '/';
}
$this->imgwww = $imgwww;
}
/**
* The method to set the icondir directory
* @access public
* @return boolean
*/
function setIcondir($icondir)
{
if ($icondir != '' && substr($icondir, -1) != '/') {
$icondir .= '/';
}
if ($icondir == '' || substr($icondir, 0, 1) != '/') {
$foobar = strpos($icondir, $this->dirroot);
if ($foobar === false || $foobar != 0) {
$icondir = $this->dirroot . $icondir;
}
}
if (!is_dir($icondir)) {
$this->error("setIcondir: $icondir is not a directory.");
return false;
}
$this->icondir = $icondir;
return true;
}
/**
* The method to set iconwww
* @access public
* @return void
*/
function setIconwww($iconwww)
{
if ($iconwww != '' && substr($iconwww, -1) != '/') {
$iconwww .= '/';
}
$this->iconwww = $iconwww;
}
/**
* The method to set the iconsize array
* @access public
* @return void
*/
function setIconsize($width, $height)
{
$this->iconsize['width'] = ($width == (int) $width) ? $width : 0;
$this->iconsize['height'] = ($height == (int) $height) ? $height : 0;
$this->issetIconsize = true;
}
/**
* The method to unset the iconsize array
* @access public
* @return void
*/
function unsetIconsize()
{
unset($this->iconsize['width']);
unset($this->iconsize['height']);
$this->issetIconsize = false;
}
/**
* The method to set the tpldir directory
* @access public
* @return boolean
*/
function setTpldirCommon($tpldir)
{
if ($tpldir != '' && substr($tpldir, -1) != '/') {
$tpldir .= '/';
}
if ($tpldir == '' || substr($tpldir, 0, 1) != '/') {
$foobar = strpos($tpldir, $this->dirroot);
if ($foobar === false || $foobar != 0) {
$tpldir = $this->dirroot . $tpldir;
}
}
if (!is_dir($tpldir)) {
$this->error("setTpldir: $tpldir is not a directory.");
return false;
}
$this->tpldir = $tpldir;
return true;
}
/**
* The method to read the menu structure from a file
* @access public
* @param string $tree_file the menu structure file
* @return boolean
*/
function setMenuStructureFile($tree_file)
{
if (!($fd = fopen($tree_file, 'r'))) {
$this->error("setMenuStructureFile: unable to open file $tree_file.");
return false;
}
$this->menuStructure = '';
while ($buffer = fgets($fd, 4096)) {
$buffer = ereg_replace(chr(13), '', $buffer); // Microsoft Stupidity Suppression
$this->menuStructure .= $buffer;
}
fclose($fd);
if ($this->menuStructure == '') {
$this->error("setMenuStructureFile: $tree_file is empty.");
return false;
}
return true;
}
/**
* The method to set the menu structure passing it through a string
* @access public
* @param string $tree_string the menu structure string
* @return boolean
*/
function setMenuStructureString($tree_string)
{
$this->menuStructure = ereg_replace(chr(13), '', $tree_string); // Microsoft Stupidity Suppression
if ($this->menuStructure == '') {
$this->error('setMenuStructureString: empty string.');
return false;
}
return true;
}
/**
* The method to set the value of separator
* @access public
* @return void
*/
function setSeparator($separator)
{
$this->separator = $separator;
}
/**
* The method to set parameters for the DB connection
* @access public
* @param string $dns Data Source Name: the connection string for PEAR DB
* @param bool $persistent DB connections are either persistent or not persistent
* @return boolean
*/
function setDBConnParms($dsn, $persistent=false)
{
if (!is_string($dsn)) {
$this->error('initdb: $dsn is not an string.');
return false;
}
if (!is_bool($persistent)) {
$this->error('initdb: $persistent is not a boolean.');
return false;
}
$this->dsn = $dsn;
$this->persistent = $persistent;
return true;
}
/**
* The method to set the name of the table storing data describing the menu
* @access public
* @param string
* @return boolean
*/
function setTableName($tableName)
{
if (!is_string($tableName)) {
$this->error('setTableName: $tableName is not a string.');
return false;
}
$this->tableName = $tableName;
return true;
}
/**
* The method to set the name of the i18n table corresponding to $tableName
* @access public
* @param string
* @return boolean
*/
function setTableName_i18n($tableName_i18n)
{
if (!is_string($tableName_i18n)) {
$this->error('setTableName_i18n: $tableName_i18n is not a string.');
return false;
}
$this->tableName_i18n = $tableName_i18n;
return true;
}
/**
* The method to set names of fields of the table storing data describing the menu
* @access public
* @param array
* @return boolean
*/
function setTableFields($tableFields)
{
if (!is_array($tableFields)) {
$this->error('setTableFields: $tableFields is not an array.');
return false;
}
if (count($tableFields) == 0) {
$this->error('setTableFields: $tableFields is a zero-length array.');
return false;
}
reset ($tableFields);
while (list($key, $value) = each($tableFields)) {
$this->tableFields[$key] = ($value == '') ? "''" : $value;
}
return true;
}
/**
* The method to set names of fields of the i18n table corresponding to $tableName
* @access public
* @param array
* @return boolean
*/
function setTableFields_i18n($tableFields_i18n)
{
if (!is_array($tableFields_i18n)) {
$this->error('setTableFields_i18n: $tableFields_i18n is not an array.');
return false;
}
if (count($tableFields_i18n) == 0) {
$this->error('setTableFields_i18n: $tableFields_i18n is a zero-length array.');
return false;
}
reset ($tableFields_i18n);
while (list($key, $value) = each($tableFields_i18n)) {
$this->tableFields_i18n[$key] = ($value == '') ? "''" : $value;
}
return true;
}
/**
* The method to parse the current menu structure and correspondingly update related variables
* @access public
* @param string $menu_name the name to be attributed to the menu
* whose structure has to be parsed
* @return void
*/
function parseStructureForMenu(
$menu_name = '' // non consistent default...
)
{
$this->_maxLevel[$menu_name] = 0;
$this->_firstLevelCnt[$menu_name] = 0;
$this->_firstItem[$menu_name] = $this->_nodesCount + 1;
$cnt = $this->_firstItem[$menu_name];
$menuStructure = $this->menuStructure;
/* *********************************************** */
/* Partially based on a piece of code taken from */
/* TreeMenu 1.1 - Bjorge Dijkstra (bjorge@gmx.net) */
/* *********************************************** */
while ($menuStructure != '') {
$before_cr = strcspn($menuStructure, "\n");
$buffer = substr($menuStructure, 0, $before_cr);
$menuStructure = substr($menuStructure, $before_cr+1);
if (substr($buffer, 0, 1) == '#') {
continue; // commented item line...
}
$tmp = rtrim($buffer);
$node = explode($this->separator, $tmp);
for ($i=count($node); $i<=6; $i++) {
$node[$i] = '';
}
$this->tree[$cnt]['level'] = strlen($node[0]);
$this->tree[$cnt]['text'] = $node[1];
$this->tree[$cnt]['href'] = $node[2];
$this->tree[$cnt]['title'] = $node[3];
$this->tree[$cnt]['icon'] = $node[4];
$this->tree[$cnt]['target'] = $node[5];
$this->tree[$cnt]['expanded'] = $node[6];
$cnt++;
}
/* *********************************************** */
$this->_lastItem[$menu_name] = count($this->tree);
$this->_nodesCount = $this->_lastItem[$menu_name];
$this->tree[$this->_lastItem[$menu_name]+1]['level'] = 0;
$this->_postParse($menu_name);
}
/**
* The method to parse the current menu table and correspondingly update related variables
* @access public
* @param string $menu_name the name to be attributed to the menu
* whose structure has to be parsed
* @param string $language i18n language; either omit it or pass
* an empty string ('') if you do not want to use any i18n table
* @return void
*/
function scanTableForMenu(
$menu_name = '', // non consistent default...
$language = ''
)
{
$this->_maxLevel[$menu_name] = 0;
$this->_firstLevelCnt[$menu_name] = 0;
unset($this->tree[$this->_nodesCount+1]);
$this->_firstItem[$menu_name] = $this->_nodesCount + 1;
/* BEGIN BENCHMARK CODE
$time_start = $this->_getmicrotime();
/* END BENCHMARK CODE */
$db = DB::connect($this->dsn, $this->persistent);
if (DB::isError($db)) {
$this->error('scanTableForMenu: ' . $db->getMessage());
}
$dbresult = $db->query('
SELECT ' .
$this->tableFields['id'] . ' AS id, ' .
$this->tableFields['parent_id'] . ' AS parent_id, ' .
$this->tableFields['text'] . ' AS text, ' .
$this->tableFields['href'] . ' AS href, ' .
$this->tableFields['title'] . ' AS title, ' .
$this->tableFields['icon'] . ' AS icon, ' .
$this->tableFields['target'] . ' AS target, ' .
$this->tableFields['expanded'] . ' AS expanded
FROM ' . $this->tableName . '
WHERE ' . $this->tableFields['id'] . ' <> 1
ORDER BY ' . $this->tableFields['orderfield'] . ', ' . $this->tableFields['text'] . ' ASC
');
$this->_tmpArray = array();
while ($dbresult->fetchInto($row, DB_FETCHMODE_ASSOC)) {
$this->_tmpArray[$row['id']]['parent_id'] = $row['parent_id'];
$this->_tmpArray[$row['id']]['text'] = $row['text'];
$this->_tmpArray[$row['id']]['href'] = $row['href'];
$this->_tmpArray[$row['id']]['title'] = $row['title'];
$this->_tmpArray[$row['id']]['icon'] = $row['icon'];
$this->_tmpArray[$row['id']]['target'] = $row['target'];
$this->_tmpArray[$row['id']]['expanded'] = $row['expanded'];
}
if ($language != '') {
$dbresult = $db->query('
SELECT ' .
$this->tableFields_i18n['id'] . ' AS id, ' .
$this->tableFields_i18n['text'] . ' AS text, ' .
$this->tableFields_i18n['title'] . ' AS title
FROM ' . $this->tableName_i18n . '
WHERE ' . $this->tableFields_i18n['id'] . ' <> 1
AND ' . $this->tableFields_i18n['language'] . ' = ' . "'$language'" . '
');
while ($dbresult->fetchInto($row, DB_FETCHMODE_ASSOC)) {
if (isset($this->_tmpArray[$row['id']])) {
$this->_tmpArray[$row['id']]['text'] = $row['text'];
$this->_tmpArray[$row['id']]['title'] = $row['title'];
}
}
}
unset($dbresult);
unset($row);
$this->_depthFirstSearch($menu_name, $this->_tmpArray, 1, 1);
/* BEGIN BENCHMARK CODE
$time_end = $this->_getmicrotime();
$time = $time_end - $time_start;
print "TIME ELAPSED = $time\n<br>";
/* END BENCHMARK CODE */
$this->_lastItem[$menu_name] = count($this->tree);
$this->_nodesCount = $this->_lastItem[$menu_name];
$this->tree[$this->_lastItem[$menu_name]+1]['level'] = 0;
$this->_postParse($menu_name);
}
function _getmicrotime()
{
list($usec, $sec) = explode(' ', microtime());
return ((float) $usec + (float) $sec);
}
/**
* Recursive method to perform the depth-first search of the tree data taken from the current menu table
* @access private
* @param string $menu_name the name to be attributed to the menu
* whose structure has to be parsed
* @param array $tmpArray the temporary array that stores data to perform
* the depth-first search
* @param integer $parent_id id of the item whose children have
* to be searched for
* @param integer $level the hierarchical level of children to be searched for
* @return void
*/
function _depthFirstSearch($menu_name, $tmpArray, $parent_id=1, $level=1)
{
reset ($tmpArray);
while (list($id, $foobar) = each($tmpArray)) {
if ($foobar['parent_id'] == $parent_id) {
unset($tmpArray[$id]);
unset($this->_tmpArray[$id]);
$cnt = count($this->tree) + 1;
$this->tree[$cnt]['level'] = $level;
$this->tree[$cnt]['text'] = $foobar['text'];
$this->tree[$cnt]['href'] = $foobar['href'];
$this->tree[$cnt]['title'] = $foobar['title'];
$this->tree[$cnt]['icon'] = $foobar['icon'];
$this->tree[$cnt]['target'] = $foobar['target'];
$this->tree[$cnt]['expanded'] = $foobar['expanded'];
$this->treecnt[$menu_name][$id] = $cnt;
unset($foobar);
if ($id != $parent_id) {
$this->_depthFirstSearch($menu_name, $this->_tmpArray, $id, $level+1);
}
}
}
}
/**
* A method providing parsing needed after both file/string parsing and DB table parsing
* @access private
* @param string $menu_name the name of the menu for which the parsing
* has to be performed
* @return void
*/
function _postParse(
$menu_name = '' // non consistent default...
)
{
for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
$this->tree[$cnt]['child_of_root_node'] = ($this->tree[$cnt]['level'] == 1);
$this->tree[$cnt]['parsed_text'] = stripslashes($this->tree[$cnt]['text']);
$this->tree[$cnt]['parsed_href'] = (ereg_replace(' ', '', $this->tree[$cnt]['href']) == '') ? '#' : $this->prependedUrl . $this->tree[$cnt]['href'];
$this->tree[$cnt]['parsed_title'] = ($this->tree[$cnt]['title'] == '') ? '' : ' title="' . stripslashes($this->tree[$cnt]['title']) . '"';
$fooimg = $this->icondir . $this->tree[$cnt]['icon'];
if ($this->tree[$cnt]['icon'] != '' && (substr($this->tree[$cnt]['icon'], 0, 7) == 'http://' || substr($this->tree[$cnt]['icon'], 0, 8) == 'https://')) {
$this->tree[$cnt]['parsed_icon'] = $this->tree[$cnt]['icon'];
if ($this->issetIconsize) {
$this->tree[$cnt]['iconwidth'] = $this->iconsize['width'];
$this->tree[$cnt]['iconheight'] = $this->iconsize['height'];
} else {
$foobar = getimagesize($this->tree[$cnt]['icon']);
$this->tree[$cnt]['iconwidth'] = $foobar[0];
$this->tree[$cnt]['iconheight'] = $foobar[1];
}
} elseif ($this->tree[$cnt]['icon'] != '' && file_exists($fooimg)) {
$this->tree[$cnt]['parsed_icon'] = $this->iconwww . $this->tree[$cnt]['icon'];
if ($this->issetIconsize) {
$this->tree[$cnt]['iconwidth'] = $this->iconsize['width'];
$this->tree[$cnt]['iconheight'] = $this->iconsize['height'];
} else {
$foobar = getimagesize($fooimg);
$this->tree[$cnt]['iconwidth'] = $foobar[0];
$this->tree[$cnt]['iconheight'] = $foobar[1];
}
} else {
$this->tree[$cnt]['parsed_icon'] = '';
}
$this->tree[$cnt]['parsed_target'] = ($this->tree[$cnt]['target'] == '') ? '' : ' target="' . $this->tree[$cnt]['target'] . '"';
// $this->tree[$cnt]['expanded'] = ($this->tree[$cnt]['expanded'] == '') ? 0 : $this->tree[$cnt]['expanded'];
$this->_maxLevel[$menu_name] = max($this->_maxLevel[$menu_name], $this->tree[$cnt]['level']);
if ($this->tree[$cnt]['level'] == 1) {
$this->_firstLevelCnt[$menu_name]++;
}
}
}
/**
* A method to replace strings in all URLs (hrefs) of a menu
* @access public
* @param string $menu_name the name of the menu for which the replacement
* has to be performed
* @param string $string the string to be replaced
* @param string $value the replacement string
* @return void
*/
function replaceStringInUrls($menu_name, $string, $value)
{
for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
$this->tree[$cnt]['parsed_href'] = str_replace($string, $value, $this->tree[$cnt]['parsed_href']);
}
}
/**
* A method to set the same target for all links of a menu
* @access public
* @param string $menu_name the name of the menu for which the targets
* have to be set
* @param string $target the target to be set for all links
* of the $menu_name menu
* @return void
*/
function setLinksTargets($menu_name, $target)
{
for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
$this->tree[$cnt]['parsed_target'] = ' target="' . $target . '"';
}
}
/**
* A method to select the current item of $menu_name in terms of $cnt, i.e., very likely, in terms of its line number in the corresponding menu structure file (excluding from the count commented out lines, if any)
* @access public
* @param string $menu_name the name of the menu for which the current item
* has to be selected
* @param integer $count the line number of the current item
* in the corresponding menu structure file
* (excluding from the count commented out lines, if any)
* @return void
*/
function setSelectedItemByCount($menu_name, $count)
{
if ($count < 1) {
$this->error("setSelectedItemByCount: the \$count argument is $count, but \$count can not be lower than 1");
return;
}
if ($count > $this->_lastItem[$menu_name] - $this->_firstItem[$menu_name] + 1) {
$this->error("setSelectedItemByCount: the \$count argument is $count and is larger than the number of items of the '$menu_name' menu");
return;
}
$cnt = $this->_firstItem[$menu_name] + $count - 1;
$this->tree[$cnt]['selected'] = true;
}
/**
* A method to select the current item of $menu_name in terms of the corresponding id (see the DB table structure); obviously, this method can be used only together with the DB support
* @access public
* @param string $menu_name the name of the menu for which the current item
* has to be selected
* @param integer $id the id of the current item in the corresponding DB table
* @return void
*/
function setSelectedItemById($menu_name, $id)
{
if (!isset($this->treecnt[$menu_name][$id])) {
$this->error("setSelectedItemById: there is not any item with \$id = $id in the '$menu_name' menu");
return;
}
$cnt = $this->treecnt[$menu_name][$id];
$this->tree[$cnt]['selected'] = true;
}
/**
* A method to select the current item of $menu_name specifying a string that occurs in the current URL
* @access public
* @param string $menu_name the name of the menu for which the current item
* has to be selected
* @param string $url a string that occurs in the current URL
* @return void
*/
function setSelectedItemByUrl($menu_name, $url)
{
for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
if (!(strpos($this->tree[$cnt]['parsed_href'], $url) === false)) {
$this->tree[$cnt]['selected'] = true;
break;
}
}
}
/**
* A method to select the current item of $menu_name specifying a regular expression that matches (a substring of) the current URL; just the same as the setSelectedItemByUrl() method, but using eregi() instead of strpos()
* @access public
* @param string $menu_name the name of the menu for which the current item
* has to be selected
* @param string $url_eregi the regular expression that matches
* (a substring of) the current URL
* @return void
*/
function setSelectedItemByUrlEregi($menu_name, $url_eregi)
{
for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) { // this counter scans all nodes of the new menu
if (eregi($url_eregi, $this->tree[$cnt]['parsed_href'])) {
$this->tree[$cnt]['selected'] = true;
break;
}
}
}
/**
* Method to handle errors
* @access private
* @param string $errormsg the error message
* @return void
*/
function error($errormsg)
{
print "<b>LayersMenu Error:</b> $errormsg<br />\n";
if ($this->haltOnError == 'yes') {
die("<b>Halted.</b><br />\n");
}
}
} /* END OF CLASS */
?>

View File

@@ -0,0 +1,5 @@
.imgs {
border: 0px;
width: 16px;
height: 18px;
}

View File

@@ -0,0 +1,76 @@
.treemenudiv {
display: block;
white-space: nowrap;
}
.phplmnormal {
font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;
font-size: 13px;
color: black;
}
a.phplmnormal:hover {
font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;
font-size: 13px;
color: black;
}
a.phplm:link {
font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;
font-size: 13px;
color: #006699;
text-decoration: none;
}
a.phplm:visited {
font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;
font-size: 13px;
text-decoration: none;
color: #006699;
}
a.phplm:hover {
font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;
font-size: 13px;
color: #006699;
background-color: #eee;
text-decoration: none;
}
a.phplm:active {
font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;
font-size: 13px;
text-decoration: none;
color: #006699;
}
a.phplmselected:link {
font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;
font-size: 13px;
color: #8e8e8e;
text-decoration: none;
}
a.phplmselected:visited {
font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;
font-size: 13px;
text-decoration: none;
}
a.phplmselected:hover {
font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;
font-size: 13px;
color: #9999cc;
text-decoration: none;
}
a.phplmselected:active {
font-family: 'Trebuchet MS', 'Lucida Grande', Verdana, Arial, Sans-Serif;
font-size: 13px;
text-decoration: none;
}

View File

@@ -0,0 +1,33 @@
// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
DOM = (document.getElementById) ? 1 : 0;
NS4 = (document.layers) ? 1 : 0;
// We need to explicitly detect Konqueror
// because Konqueror 3 sets IE = 1 ... AAAAAAAAAARGHHH!!!
Konqueror = (navigator.userAgent.indexOf('Konqueror') > -1) ? 1 : 0;
// We need to detect Konqueror 2.2 as it does not handle the window.onresize event
Konqueror22 = (navigator.userAgent.indexOf('Konqueror 2.2') > -1 || navigator.userAgent.indexOf('Konqueror/2.2') > -1) ? 1 : 0;
Konqueror30 =
(
navigator.userAgent.indexOf('Konqueror 3.0') > -1
|| navigator.userAgent.indexOf('Konqueror/3.0') > -1
|| navigator.userAgent.indexOf('Konqueror 3;') > -1
|| navigator.userAgent.indexOf('Konqueror/3;') > -1
|| navigator.userAgent.indexOf('Konqueror 3)') > -1
|| navigator.userAgent.indexOf('Konqueror/3)') > -1
)
? 1 : 0;
Konqueror31 = (navigator.userAgent.indexOf('Konqueror 3.1') > -1 || navigator.userAgent.indexOf('Konqueror/3.1') > -1) ? 1 : 0;
// We need to detect Konqueror 3.2 and 3.3 as they are affected by the see-through effect only for 2 form elements
Konqueror32 = (navigator.userAgent.indexOf('Konqueror 3.2') > -1 || navigator.userAgent.indexOf('Konqueror/3.2') > -1) ? 1 : 0;
Konqueror33 = (navigator.userAgent.indexOf('Konqueror 3.3') > -1 || navigator.userAgent.indexOf('Konqueror/3.3') > -1) ? 1 : 0;
Opera = (navigator.userAgent.indexOf('Opera') > -1) ? 1 : 0;
Opera5 = (navigator.userAgent.indexOf('Opera 5') > -1 || navigator.userAgent.indexOf('Opera/5') > -1) ? 1 : 0;
Opera6 = (navigator.userAgent.indexOf('Opera 6') > -1 || navigator.userAgent.indexOf('Opera/6') > -1) ? 1 : 0;
Opera56 = Opera5 || Opera6;
IE = (navigator.userAgent.indexOf('MSIE') > -1) ? 1 : 0;
IE = IE && !Opera;
IE5 = IE && DOM;
IE4 = (document.all) ? 1 : 0;
IE4 = IE4 && IE && !DOM;

View File

@@ -0,0 +1,11 @@
<!-- beginning of menu footer - {packageName} {version} {copyright} {author} -->
{footer}
<script language="JavaScript" type="text/javascript">
<!--
loaded = 1;
// -->
</script>
<!-- end of menu footer - {packageName} {version} {copyright} {author} -->

View File

@@ -0,0 +1,57 @@
<!-- beginning of menu header - {packageName} {version} {copyright} {author} -->
<script language="JavaScript" type="text/javascript">
<!--
menuTopShift = {menuTopShift};
menuRightShift = {menuRightShift};
menuLeftShift = {menuLeftShift};
var thresholdY = {thresholdY};
var abscissaStep = {abscissaStep};
toBeHidden = new Array();
toBeHiddenLeft = new Array();
toBeHiddenTop = new Array();
{listl}
var numl = listl.length;
father = new Array();
for (i=1; i<={nodesCount}; i++) {
father['L' + i] = '';
}
{father_keys}
{father_vals}
for (i=0; i<father_keys.length; i++) {
father[father_keys[i]] = father_vals[i];
}
lwidth = new Array();
var lwidthDetected = 0;
function moveLayers()
{
if (!lwidthDetected) {
for (i=0; i<numl; i++) {
lwidth[listl[i]] = getOffsetWidth(listl[i]);
}
lwidthDetected = 1;
}
if (IE4) {
for (i=0; i<numl; i++) {
setWidth(listl[i], abscissaStep);
}
}
{moveLayers}
}
back = new Array();
for (i=1; i<={nodesCount}; i++) {
back['L' + i] = 0;
}
// -->
</script>
<!-- end of menu header - {packageName} {version} {copyright} {author} -->

View File

@@ -0,0 +1,248 @@
// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
layerLeft = new Array();
layerTop = new Array();
function setVisibility(layer, on)
{
if (on) {
if (DOM) {
document.getElementById(layer).style.visibility = 'visible';
} else if (NS4) {
document.layers[layer].visibility = 'show';
} else {
document.all[layer].style.visibility = 'visible';
}
} else {
if (DOM) {
document.getElementById(layer).style.visibility = 'hidden';
} else if (NS4) {
document.layers[layer].visibility = 'hide';
} else {
document.all[layer].style.visibility = 'hidden';
}
}
}
function isVisible(layer)
{
if (DOM) {
return (document.getElementById(layer).style.visibility == 'visible');
} else if (NS4) {
return (document.layers[layer].visibility == 'show');
} else {
return (document.all[layer].style.visibility == 'visible');
}
}
function setLeft(layer, x)
{
layerLeft[layer] = x;
if (DOM && !Opera5) {
document.getElementById(layer).style.left = x + 'px';
} else if (Opera5) {
document.getElementById(layer).style.left = x;
} else if (NS4) {
document.layers[layer].left = x;
} else {
document.all[layer].style.pixelLeft = x;
}
}
function getOffsetLeft(layer)
{
var value = 0;
if (DOM) { // Mozilla, Konqueror >= 2.2, Opera >= 5, IE
object = document.getElementById(layer);
value = object.offsetLeft;
//alert (object.tagName + ' --- ' + object.offsetLeft);
while (object.tagName != 'BODY' && object.offsetParent) {
object = object.offsetParent;
//alert (object.tagName + ' --- ' + object.offsetLeft);
value += object.offsetLeft;
}
} else if (NS4) {
value = document.layers[layer].pageX;
} else { // IE4 IS SIMPLY A BASTARD !!!
if (document.all['IE4' + layer]) {
layer = 'IE4' + layer;
}
object = document.all[layer];
value = object.offsetLeft;
while (object.tagName != 'BODY') {
object = object.offsetParent;
value += object.offsetLeft;
}
}
return (value);
}
function setTop(layer, y)
{
layerTop[layer] = y;
if (DOM && !Opera5) {
document.getElementById(layer).style.top = y + 'px';
} else if (Opera5) {
document.getElementById(layer).style.top = y;
} else if (NS4) {
document.layers[layer].top = y;
} else {
document.all[layer].style.pixelTop = y;
}
}
function getOffsetTop(layer)
{
// IE 5.5 and 6.0 behaviour with this function is really strange:
// in some cases, they return a really too large value...
// ... after all, IE is buggy, nothing new
var value = 0;
if (DOM) {
object = document.getElementById(layer);
value = object.offsetTop;
while (object.tagName != 'BODY' && object.offsetParent) {
object = object.offsetParent;
value += object.offsetTop;
}
} else if (NS4) {
value = document.layers[layer].pageY;
} else { // IE4 IS SIMPLY A BASTARD !!!
if (document.all['IE4' + layer]) {
layer = 'IE4' + layer;
}
object = document.all[layer];
value = object.offsetTop;
while (object.tagName != 'BODY') {
object = object.offsetParent;
value += object.offsetTop;
}
}
return (value);
}
function setWidth(layer, w)
{
if (DOM) {
document.getElementById(layer).style.width = w;
} else if (NS4) {
// document.layers[layer].width = w;
} else {
document.all[layer].style.pixelWidth = w;
}
}
function getOffsetWidth(layer)
{
var value = 0;
if (DOM && !Opera56) {
value = document.getElementById(layer).offsetWidth;
} else if (NS4) {
value = document.layers[layer].document.width;
} else if (Opera56) {
value = document.getElementById(layer).style.pixelWidth;
} else { // IE4 IS SIMPLY A BASTARD !!!
if (document.all['IE4' + layer]) {
layer = 'IE4' + layer;
}
value = document.all[layer].offsetWidth;
}
return (value);
}
function setHeight(layer, h) // unused, not tested
{
if (DOM) {
document.getElementById(layer).style.height = h;
} else if (NS4) {
// document.layers[layer].height = h;
} else {
document.all[layer].style.pixelHeight = h;
}
}
function getOffsetHeight(layer)
{
var value = 0;
if (DOM && !Opera56) {
value = document.getElementById(layer).offsetHeight;
} else if (NS4) {
value = document.layers[layer].document.height;
} else if (Opera56) {
value = document.getElementById(layer).style.pixelHeight;
} else { // IE4 IS SIMPLY A BASTARD !!!
if (document.all['IE4' + layer]) {
layer = 'IE4' + layer;
}
value = document.all[layer].offsetHeight;
}
return (value);
}
function getWindowWidth()
{
var value = 0;
if ((DOM && !IE) || NS4 || Konqueror || Opera) {
value = window.innerWidth;
// } else if (NS4) {
// value = document.width;
} else { // IE
if (document.documentElement && document.documentElement.clientWidth) {
value = document.documentElement.clientWidth;
} else if (document.body) {
value = document.body.clientWidth;
}
}
if (isNaN(value)) {
value = window.innerWidth;
}
return (value);
}
function getWindowXOffset()
{
var value = 0;
if ((DOM && !IE) || NS4 || Konqueror || Opera) {
value = window.pageXOffset;
} else { // IE
if (document.documentElement && document.documentElement.scrollLeft) {
value = document.documentElement.scrollLeft;
} else if (document.body) {
value = document.body.scrollLeft;
}
}
return (value);
}
function getWindowHeight()
{
var value = 0;
if ((DOM && !IE) || NS4 || Konqueror || Opera) {
value = window.innerHeight;
} else { // IE
if (document.documentElement && document.documentElement.clientHeight) {
value = document.documentElement.clientHeight;
} else if (document.body) {
value = document.body.clientHeight;
}
}
if (isNaN(value)) {
value = window.innerHeight;
}
return (value);
}
function getWindowYOffset()
{
var value = 0;
if ((DOM && !IE) || NS4 || Konqueror || Opera) {
value = window.pageYOffset;
} else { // IE
if (document.documentElement && document.documentElement.scrollTop) {
value = document.documentElement.scrollTop;
} else if (document.body) {
value = document.body.scrollTop;
}
}
return (value);
}

View File

@@ -0,0 +1,65 @@
// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
function scanChildren(element)
{
var counter = element.childNodes.length;
for (var i=0; i<counter; i++) {
foobar = element.childNodes.item(i);
if ( ( (Konqueror22 || Konqueror30 || Konqueror31) &&
( foobar.nodeName == 'INPUT' || foobar.nodeName == 'input'
|| foobar.nodeName == 'SELECT' || foobar.nodeName == 'select'
|| foobar.nodeName == 'TEXTAREA' || foobar.nodeName == 'textarea'
)
)
||
// Konqueror 3.2 and 3.3 need hiding only for the following two form elements, but, alas,
// at the time of this writing (Konqueror 3.2.3 and 3.3.0-rc2), hiding of such two form elements
// on Konqueror 3.2 and 3.3 does not work, it is affected by the following bug: http://bugs.kde.org/72885
( (Konqueror32 || Konqueror33) &&
( ((foobar.nodeName == 'SELECT' || foobar.nodeName == 'select') && foobar.size > 1)
|| foobar.nodeName == 'TEXTAREA' || foobar.nodeName == 'textarea'
)
)
||
( IE &&
( foobar.nodeName == 'SELECT' || foobar.nodeName == 'select' )
)
) {
toBeHidden[toBeHidden.length] = foobar;
}
if (foobar.childNodes.length > 0) {
scanChildren(foobar);
}
}
}
function seeThroughCoordinatesDetection()
{
if (!((Konqueror && !Konqueror22) || IE5)) {
return;
}
for (i=0; i<toBeHidden.length; i++) {
object = toBeHidden[i];
toBeHiddenLeft[i] = object.offsetLeft;
while (object.tagName != 'BODY' && object.offsetParent) {
object = object.offsetParent;
toBeHiddenLeft[i] += object.offsetLeft;
}
object = toBeHidden[i];
toBeHiddenTop[i] = object.offsetTop;
while (object.tagName != 'BODY' && object.offsetParent) {
object = object.offsetParent;
toBeHiddenTop[i] += object.offsetTop;
}
}
}
//document.write("<br />\nSCANNING STARTED<br />\n");
//scanChildren(document.getElementsByTagName('BODY').item(0));
if ((Konqueror || IE5) && document.getElementById('phplmseethrough')) {
scanChildren(document.getElementById('phplmseethrough'));
}
//document.write("<br />\nSCANNING COMPLETED<br />\n");
seeThroughCoordinatesDetection();

View File

@@ -0,0 +1,316 @@
// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
useTimeouts = 1;
timeoutLength = 1000; // time in ms; not significant if useTimeouts = 0;
shutdownOnClick = 0;
loaded = 0;
layersMoved = 0;
layerPoppedUp = '';
timeoutFlag = 0;
if (Opera56 || IE4) {
useTimeouts = 0;
}
if (NS4 || Opera56 || IE4) {
shutdownOnClick = 1;
}
currentY = 0;
function grabMouse(e) // for NS4
{
currentY = e.pageY;
}
if (NS4) {
document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE);
document.onmousemove = grabMouse;
}
function seeThroughElements(show)
{
if (show) {
foobar = 'visible';
} else {
foobar = 'hidden';
}
for (i=0; i<toBeHidden.length; i++) {
toBeHidden[i].style.visibility = foobar;
}
}
function shutdown()
{
for (i=0; i<numl; i++) {
LMPopUpL(listl[i], false);
}
layerPoppedUp = '';
if (Konqueror || IE5) {
seeThroughElements(true);
}
}
if (shutdownOnClick) {
if (NS4) {
document.onmousedown = shutdown;
} else {
document.onclick = shutdown;
}
}
function setLMTO()
{
if (useTimeouts) {
timeoutFlag = setTimeout('shutdown()', timeoutLength);
}
}
function clearLMTO()
{
if (useTimeouts) {
clearTimeout(timeoutFlag);
}
}
function moveLayerX(menuName)
{
if (!loaded || (isVisible(menuName) && menuName != layerPoppedUp)) {
return;
}
if (father[menuName] != '') {
if (!Opera5 && !IE4) {
width0 = lwidth[father[menuName]];
width1 = lwidth[menuName];
} else if (Opera5) {
// Opera 5 stupidly and exaggeratedly overestimates layers widths
// hence we consider a default value equal to $abscissaStep
width0 = abscissaStep;
width1 = abscissaStep;
} else if (IE4) {
width0 = getOffsetWidth(father[menuName]);
width1 = getOffsetWidth(menuName);
}
onLeft = getOffsetLeft(father[menuName]) - width1 + menuLeftShift;
onRight = getOffsetLeft(father[menuName]) + width0 - menuRightShift;
windowWidth = getWindowWidth();
windowXOffset = getWindowXOffset();
// if (NS4 && !DOM) {
// windowXOffset = 0;
// }
if (onLeft < windowXOffset && onRight + width1 > windowWidth + windowXOffset) {
if (onRight + width1 - windowWidth - windowXOffset > windowXOffset - onLeft) {
onLeft = windowXOffset;
} else {
onRight = windowWidth + windowXOffset - width1;
}
}
if (back[father[menuName]]) {
if (onLeft < windowXOffset) {
back[menuName] = 0;
} else {
back[menuName] = 1;
}
} else {
//alert(onRight + ' - ' + width1 + ' - ' + windowWidth + ' - ' + windowXOffset);
if (onRight + width1 > windowWidth + windowXOffset) {
back[menuName] = 1;
} else {
back[menuName] = 0;
}
}
if (back[menuName]) {
setLeft(menuName, onLeft);
} else {
setLeft(menuName, onRight);
}
}
moveLayerY(menuName); // workaround needed for Mozilla < 1.4 for MS Windows
}
function moveLayerY(menuName)
{
if (!loaded || (isVisible(menuName) && menuName != layerPoppedUp)) {
return;
}
if (!layersMoved) {
moveLayers();
layersMoved = 1;
}
if (!NS4) {
newY = getOffsetTop('ref' + menuName);
} else {
newY = currentY;
}
newY += menuTopShift;
layerHeight = getOffsetHeight(menuName);
windowHeight = getWindowHeight();
windowYOffset = getWindowYOffset();
if (newY + layerHeight > windowHeight + windowYOffset) {
if (layerHeight > windowHeight) {
newY = windowYOffset;
} else {
newY = windowHeight + windowYOffset - layerHeight;
}
}
if (Math.abs(getOffsetTop(menuName) - newY) > thresholdY) {
setTop(menuName, newY);
}
}
function moveLayerX1(menuName, father)
{
if (!lwidthDetected) {
return;
}
if (!Opera5 && !IE4) {
width1 = lwidth[menuName];
} else if (Opera5) {
// Opera 5 stupidly and exaggeratedly overestimates layers widths
// hence we consider a default value equal to $abscissaStep
width1 = abscissaStep;
}
foobar = getOffsetLeft(father + menuName);
if (!IE4) {
windowWidth = getWindowWidth();
windowXOffset = getWindowXOffset();
if (foobar + width1 > windowWidth + windowXOffset) {
foobar = windowWidth + windowXOffset - width1;
}
if (foobar < windowXOffset) {
foobar = windowXOffset;
}
}
setLeft(menuName, foobar);
}
function layersOverlap(layer, i)
{
if (Konqueror22) {
return true;
}
// xa1 = getOffsetLeft(layer);
//setLeft(layer, xa1);
xa1 = layerLeft[layer];
xa2 = xa1 + getOffsetWidth(layer);
//setWidth(layer, xa2-xa1);
// ya1 = getOffsetTop(layer);
//setTop(layer, ya1);
ya1 = layerTop[layer];
ya2 = ya1 + getOffsetHeight(layer);
//setHeight(layer, ya2-ya1);
//alert(':' + xa1 + ':' + xa2 + ':' + ya1 + ':' + ya2 + ':');
xb1 = toBeHiddenLeft[i];
xb2 = xb1 + toBeHidden[i].offsetWidth;
yb1 = toBeHiddenTop[i];
yb2 = yb1 + toBeHidden[i].offsetHeight;
//alert(':' + xb1 + ':' + xb2 + ':' + yb1 + ':' + yb2 + ':');
if(xb1>xa1) xa1=xb1; if(xb2<xa2) xa2=xb2;
if(yb1>ya1) ya1=yb1; if(yb2<ya2) ya2=yb2;
return (xa2>xa1 && ya2>ya1);
}
function seeThroughWorkaround(menuName, on)
{
for (i=0; i<toBeHidden.length; i++) {
if (layersOverlap(menuName, i)) {
if (on) {
toBeHidden[i].style.visibility = 'hidden';
} else {
toBeHidden[i].style.visibility = 'visible';
}
}
}
}
function LMPopUpL(menuName, on)
{
if (!loaded) {
return;
}
if (!layersMoved) {
moveLayers();
layersMoved = 1;
}
setVisibility(menuName, on);
}
function LMPopUp(menuName, isCurrent)
{
if (!loaded || menuName == layerPoppedUp || (isVisible(menuName) && !isCurrent)) {
return;
}
if (menuName == father[layerPoppedUp]) {
LMPopUpL(layerPoppedUp, false);
// seeThroughWorkaround(menuName, false);
} else if (father[menuName] == layerPoppedUp) {
LMPopUpL(menuName, true);
seeThroughWorkaround(menuName, true);
} else {
shutdown();
foobar = menuName;
do {
LMPopUpL(foobar, true);
seeThroughWorkaround(foobar, true);
foobar = father[foobar];
} while (foobar != '')
}
/*
if (layerPoppedUp == '') {
seeThroughElements(false);
}
*/
layerPoppedUp = menuName;
}
function resizeHandler()
{
if (NS4) {
window.location.reload();
}
shutdown();
for (i=0; i<numl; i++) {
setLeft(listl[i], 0);
setTop(listl[i], 0);
}
if (toBeHidden != null && toBeHidden.length > 0) {
seeThroughCoordinatesDetection();
}
// moveLayers();
layersMoved = 0;
}
window.onresize = resizeHandler;
function yaresizeHandler()
{
if (window.innerWidth != origWidth || window.innerHeight != origHeight) {
if (Konqueror22 || Opera5) {
window.location.reload(); // Opera 5 often fails this
}
origWidth = window.innerWidth;
origHeight = window.innerHeight;
resizeHandler();
}
setTimeout('yaresizeHandler()', 500);
}
function loadHandler()
{
if (Konqueror22 || Opera56) {
origWidth = window.innerWidth;
origHeight = window.innerHeight;
yaresizeHandler();
}
}
window.onload = loadHandler;
function fixieflm(menuName)
{
if (DOM) {
setWidth(menuName, '100%');
} else { // IE4 IS SIMPLY A BASTARD !!!
document.write('</div>');
document.write('<div id="IE4' + menuName + '" style="position: relative; width: 100%; visibility: visible;">');
}
}

View File

@@ -0,0 +1,70 @@
// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
function setLMCookie(name, value)
{
document.cookie = name + '=' + value + ';path=/';
}
function getLMCookie(name)
{
foobar = document.cookie.split(name + '=');
if (foobar.length < 2) {
return null;
}
tempString = foobar[1];
if (tempString.indexOf(';') == -1) {
return tempString;
}
yafoobar = tempString.split(';');
return yafoobar[0];
}
function parseExpandString()
{
expandString = getLMCookie('phplm_expand');
phplm_expand = new Array();
if (expandString) {
expanded = expandString.split('|');
for (i=0; i<expanded.length-1; i++) {
phplm_expand[expanded[i]] = 1;
}
}
}
function parseCollapseString()
{
collapseString = getLMCookie('phplm_collapse');
phplm_collapse = new Array();
if (collapseString) {
collapsed = collapseString.split('|');
for (i=0; i<collapsed.length-1; i++) {
phplm_collapse[collapsed[i]] = 1;
}
}
}
parseExpandString();
parseCollapseString();
function saveExpandString()
{
expandString = '';
for (i=0; i<phplm_expand.length; i++) {
if (phplm_expand[i] == 1) {
expandString += i + '|';
}
}
setLMCookie('phplm_expand', expandString);
}
function saveCollapseString()
{
collapseString = '';
for (i=0; i<phplm_collapse.length; i++) {
if (phplm_collapse[i] == 1) {
collapseString += i + '|';
}
}
setLMCookie('phplm_collapse', collapseString);
}

View File

@@ -0,0 +1,52 @@
// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
function {toggle_function_name}(nodeid)
{
if ((!DOM || Opera56 || Konqueror22) && !IE4) {
return;
}
layersMoved = 0;
parseExpandString();
parseCollapseString();
if (!IE4) {
sonLayer = document.getElementById('jt' + nodeid + 'son');
nodeLayer = document.getElementById('jt' + nodeid + 'node');
folderLayer = document.getElementById('jt' + nodeid + 'folder');
} else {
sonLayer = document.all('jt' + nodeid + 'son');
nodeLayer = document.all('jt' + nodeid + 'node');
folderLayer = document.all('jt' + nodeid + 'folder');
}
if (sonLayer.style.display == 'none') {
sonLayer.style.display = 'block';
if (nodeLayer.src.indexOf('{img_expand}') > -1) {
nodeLayer.src = '{img_collapse}';
} else if (nodeLayer.src.indexOf('{img_expand_first}') > -1) {
nodeLayer.src = '{img_collapse_first}';
} else if (nodeLayer.src.indexOf('{img_expand_corner}') > -1) {
nodeLayer.src = '{img_collapse_corner}';
} else {
nodeLayer.src = '{img_collapse_corner_first}';
}
folderLayer.src = '{img_folder_open}';
phplm_expand[nodeid] = 1;
phplm_collapse[nodeid] = 0;
} else {
sonLayer.style.display = 'none';
if (nodeLayer.src.indexOf('{img_collapse}') > -1) {
nodeLayer.src = '{img_expand}';
} else if (nodeLayer.src.indexOf('{img_collapse_first}') > -1) {
nodeLayer.src = '{img_expand_first}';
} else if (nodeLayer.src.indexOf('{img_collapse_corner}') > -1) {
nodeLayer.src = '{img_expand_corner}';
} else {
nodeLayer.src = '{img_expand_corner_first}';
}
folderLayer.src = '{img_folder_closed}';
phplm_expand[nodeid] = 0;
phplm_collapse[nodeid] = 1;
}
saveExpandString();
saveCollapseString();
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 665 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 829 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 B

View File

@@ -0,0 +1,352 @@
<?php
// PHP Layers Menu 3.2.0-rc (C) 2001-2004 Marco Pratesi - http://www.marcopratesi.it/
/**
* This file contains the code of the TreeMenu class.
* @package PHPLayersMenu
*/
/**
* This is the TreeMenu class of the PHP Layers Menu library.
*
* This class depends on the LayersMenuCommon class and on the PEAR conforming version of the PHPLib Template class, i.e. on HTML_Template_PHPLIB
*
* @version 3.2.0-rc
* @package PHPLayersMenu
*/
class TreeMenu extends LayersMenuCommon
{
/**
* Type of images used for the Tree Menu
* @access private
* @var string
*/
var $treeMenuImagesType;
/**
* Prefix for filenames of images of a theme
* @access private
* @var string
*/
var $treeMenuTheme;
/**
* An array where we store the Tree Menu code for each menu
* @access private
* @var array
*/
var $_treeMenu;
/**
* The constructor method; it initializates the menu system
* @return void
*/
function TreeMenu()
{
$this->LayersMenuCommon();
$this->treeMenuImagesType = 'png';
$this->treeMenuTheme = '';
$this->_treeMenu = array();
$this->_nodesCount = 0;
$this->tree = array();
$this->_maxLevel = array();
$this->_firstLevelCnt = array();
$this->_firstItem = array();
$this->_lastItem = array();
}
/**
* The method to set the dirroot directory
* @access public
* @return boolean
*/
function setDirroot($dirroot)
{
return $this->setDirrootCommon($dirroot);
}
/**
* The method to set the type of images used for the Tree Menu
* @access public
* @return void
*/
function setTreeMenuImagesType($treeMenuImagesType)
{
$this->treeMenuImagesType = $treeMenuImagesType;
}
/**
* The method to set the prefix for filenames of images of a theme
* @access public
* @return void
*/
function setTreeMenuTheme($treeMenuTheme)
{
$this->treeMenuTheme = $treeMenuTheme;
}
/**
* Method to prepare a new Tree Menu.
*
* This method processes items of a menu to prepare and return
* the corresponding Tree Menu code.
*
* @access public
* @param string $menu_name the name of the menu whose items have to be processed
* @return string
*/
function newTreeMenu(
$menu_name = '' // non consistent default...
)
{
if (!isset($this->_firstItem[$menu_name]) || !isset($this->_lastItem[$menu_name])) {
$this->error("newTreeMenu: the first/last item of the menu '$menu_name' is not defined; please check if you have parsed its menu data.");
return 0;
}
$this->_treeMenu[$menu_name] = '';
$img_collapse = $this->imgwww . $this->treeMenuTheme . 'tree_collapse.' . $this->treeMenuImagesType;
$alt_collapse = '--';
$img_collapse_corner = $this->imgwww . $this->treeMenuTheme . 'tree_collapse_corner.' . $this->treeMenuImagesType;
$alt_collapse_corner = '--';
$img_collapse_corner_first = $this->imgwww . $this->treeMenuTheme . 'tree_collapse_corner_first.' . $this->treeMenuImagesType;
$alt_collapse_corner_first = '--';
$img_collapse_first = $this->imgwww . $this->treeMenuTheme . 'tree_collapse_first.' . $this->treeMenuImagesType;
$alt_collapse_first = '--';
$img_corner = $this->imgwww . $this->treeMenuTheme . 'tree_corner.' . $this->treeMenuImagesType;
$alt_corner = '`-';
$img_expand = $this->imgwww . $this->treeMenuTheme . 'tree_expand.' . $this->treeMenuImagesType;
$alt_expand = '+-';
$img_expand_corner = $this->imgwww . $this->treeMenuTheme . 'tree_expand_corner.' . $this->treeMenuImagesType;
$alt_expand_corner = '+-';
$img_expand_corner_first = $this->imgwww . $this->treeMenuTheme . 'tree_expand_corner_first.' . $this->treeMenuImagesType;
$alt_expand_corner_first = '+-';
$img_expand_first = $this->imgwww . $this->treeMenuTheme . 'tree_expand_first.' . $this->treeMenuImagesType;
$alt_expand_first = '+-';
$img_folder_closed = $this->imgwww . $this->treeMenuTheme . 'tree_folder_closed.' . $this->treeMenuImagesType;
$alt_folder_closed = '->';
$img_folder_open = $this->imgwww . $this->treeMenuTheme . 'tree_folder_open.' . $this->treeMenuImagesType;
$alt_folder_open = '->';
$img_leaf = $this->imgwww . $this->treeMenuTheme . 'tree_leaf.' . $this->treeMenuImagesType;
$alt_leaf = '->';
$img_space = $this->imgwww . $this->treeMenuTheme . 'tree_space.' . $this->treeMenuImagesType;
$alt_space = ' ';
$img_split = $this->imgwww . $this->treeMenuTheme . 'tree_split.' . $this->treeMenuImagesType;
$alt_split = '|-';
$img_split_first = $this->imgwww . $this->treeMenuTheme . 'tree_split_first.' . $this->treeMenuImagesType;
$alt_split_first = '|-';
$img_vertline = $this->imgwww . $this->treeMenuTheme . 'tree_vertline.' . $this->treeMenuImagesType;
$alt_vertline = '| ';
for ($i=0; $i<=$this->_maxLevel[$menu_name]; $i++) {
$levels[$i] = 0;
}
// Find last nodes of subtrees
$last_level = $this->_maxLevel[$menu_name];
for ($i=$this->_lastItem[$menu_name]; $i>=$this->_firstItem[$menu_name]; $i--) {
if ($this->tree[$i]['level'] < $last_level) {
for ($j=$this->tree[$i]['level']+1; $j<=$this->_maxLevel[$menu_name]; $j++) {
$levels[$j] = 0;
}
}
if ($levels[$this->tree[$i]['level']] == 0) {
$levels[$this->tree[$i]['level']] = 1;
$this->tree[$i]['last_item'] = 1;
} else {
$this->tree[$i]['last_item'] = 0;
}
$last_level = $this->tree[$i]['level'];
}
$toggle = '';
$toggle_function_name = 'toggle' . $menu_name;
for ($cnt=$this->_firstItem[$menu_name]; $cnt<=$this->_lastItem[$menu_name]; $cnt++) {
if ($this->tree[$cnt]['text'] == '---') {
continue; // separators are significant only for layers-based menus
}
if (isset($this->tree[$cnt]['selected']) && $this->tree[$cnt]['selected']) {
$linkstyle = 'phplmselected';
} else {
$linkstyle = 'phplm';
}
$this->_treeMenu[$menu_name] .= '<div id="jt' . $cnt . '" class="treemenudiv">' . "\n";
// vertical lines from higher levels
for ($i=0; $i<$this->tree[$cnt]['level']-1; $i++) {
if ($levels[$i] == 1) {
$img = $img_vertline;
$alt = $alt_vertline;
} else {
$img = $img_space;
$alt = $alt_space;
}
$this->_treeMenu[$menu_name] .= '<img align="top" border="0" class="imgs" src="' . $img . '" alt="' . $alt . '" />';
}
$not_a_leaf = $cnt<$this->_lastItem[$menu_name] && $this->tree[$cnt+1]['level']>$this->tree[$cnt]['level'];
if ($this->tree[$cnt]['last_item'] == 1) {
// corner at end of subtree or t-split
if ($not_a_leaf) {
if ($cnt == $this->_firstItem[$menu_name]) {
$img = $img_collapse_corner_first;
$alt = $alt_collapse_corner_first;
} else {
$img = $img_collapse_corner;
$alt = $alt_collapse_corner;
}
$this->_treeMenu[$menu_name] .= '<a onmousedown="' . $toggle_function_name . "('" . $cnt . "')" . '"><img align="top" border="0" class="imgs" id="jt' . $cnt . 'node" src="' . $img . '" alt="' . $alt . '" /></a>';
} else {
$this->_treeMenu[$menu_name] .= '<img align="top" border="0" class="imgs" src="' . $img_corner . '" alt="' . $alt_corner . '" />';
}
$levels[$this->tree[$cnt]['level']-1] = 0;
} else {
if ($not_a_leaf) {
if ($cnt == $this->_firstItem[$menu_name]) {
$img = $img_collapse_first;
$alt = $alt_collapse_first;
} else {
$img = $img_collapse;
$alt = $alt_collapse;
}
$this->_treeMenu[$menu_name] .= '<a onmousedown="' . $toggle_function_name . "('" . $cnt . "');" . '"><img align="top" border="0" class="imgs" id="jt' . $cnt . 'node" src="' . $img . '" alt="' . $alt . '" /></a>';
} else {
if ($cnt == $this->_firstItem[$menu_name]) {
$img = $img_split_first;
$alt = $alt_split_first;
} else {
$img = $img_split;
$alt = $alt_split;
}
$this->_treeMenu[$menu_name] .= '<img align="top" border="0" class="imgs" id="jt' . $cnt . 'node" src="' . $img . '" alt="' . $alt . '" />';
}
$levels[$this->tree[$cnt]['level']-1] = 1;
}
if ($this->tree[$cnt]['parsed_href'] == '' || $this->tree[$cnt]['parsed_href'] == '#') {
$a_href_open_img = '';
$a_href_close_img = '';
$a_href_open = '<a class="phplmnormal">';
$a_href_close = '</a>';
} else {
$a_href_open_img = '<a href="' . $this->tree[$cnt]['parsed_href'] . '"' . $this->tree[$cnt]['parsed_title'] . $this->tree[$cnt]['parsed_target'] . '>';
$a_href_close_img = '</a>';
$a_href_open = '<a href="' . $this->tree[$cnt]['parsed_href'] . '"' . $this->tree[$cnt]['parsed_title'] . $this->tree[$cnt]['parsed_target'] . ' class="' . $linkstyle . '">';
$a_href_close = '</a>';
}
if ($not_a_leaf) {
$this->_treeMenu[$menu_name] .= $a_href_open_img . '<img align="top" border="0" class="imgs" id="jt' . $cnt . 'folder" src="' . $img_folder_open . '" alt="' . $alt_folder_open . '" />' . $a_href_close_img;
} else {
if ($this->tree[$cnt]['parsed_icon'] != '') {
$this->_treeMenu[$menu_name] .= $a_href_open_img . '<img align="top" border="0" src="' . $this->tree[$cnt]['parsed_icon'] . '" width="' . $this->tree[$cnt]['iconwidth'] . '" height="' . $this->tree[$cnt]['iconheight'] . '" alt="' . $alt_leaf . '" />' . $a_href_close_img;
} else {
$this->_treeMenu[$menu_name] .= $a_href_open_img . '<img align="top" border="0" class="imgs" src="' . $img_leaf . '" alt="' . $alt_leaf . '" />' . $a_href_close_img;
}
}
$this->_treeMenu[$menu_name] .= '&nbsp;' . $a_href_open . $this->tree[$cnt]['text'] . $a_href_close . "\n";
$this->_treeMenu[$menu_name] .= '</div>' . "\n";
if ($cnt<$this->_lastItem[$menu_name] && $this->tree[$cnt]['level']<$this->tree[$cnt+1]['level']) {
$this->_treeMenu[$menu_name] .= '<div id="jt' . $cnt . 'son" class="treemenudiv">' . "\n";
if ($this->tree[$cnt]['expanded'] != 1) {
$toggle .= 'if (phplm_expand[' . $cnt . '] != 1) ' . $toggle_function_name . "('" . $cnt . "');\n";
} else {
$toggle .= 'if (phplm_collapse[' . $cnt . '] == 1) ' . $toggle_function_name . "('" . $cnt . "');\n";
}
}
if ($cnt>$this->_firstItem[$menu_name] && $this->tree[$cnt]['level']>$this->tree[$cnt+1]['level']) {
for ($i=max(1, $this->tree[$cnt+1]['level']); $i<$this->tree[$cnt]['level']; $i++) {
$this->_treeMenu[$menu_name] .= '</div>' . "\n";
}
}
}
/*
$this->_treeMenu[$menu_name] =
'<div class="phplmnormal">' . "\n" .
$this->_treeMenu[$menu_name] .
'</div>' . "\n";
*/
// Some (old) browsers do not support the "white-space: nowrap;" CSS property...
$this->_treeMenu[$menu_name] =
'<table cellspacing="0" cellpadding="0" border="0">' . "\n" .
'<tr>' . "\n" .
'<td class="phplmnormal" nowrap="nowrap">' . "\n" .
$this->_treeMenu[$menu_name] .
'</td>' . "\n" .
'</tr>' . "\n" .
'</table>' . "\n";
$t = new Template_PHPLIB();
$t->setFile('tplfile', $this->libjsdir . 'layerstreemenu.ijs');
$t->setVar(array(
'toggle_function_name' => $toggle_function_name,
'img_collapse' => $img_collapse,
'img_collapse_corner' => $img_collapse_corner,
'img_collapse_corner_first' => $img_collapse_corner_first,
'img_collapse_first' => $img_collapse_first,
'img_expand' => $img_expand,
'img_expand_corner' => $img_expand_corner,
'img_expand_corner_first' => $img_expand_corner_first,
'img_expand_first' => $img_expand_first,
'img_folder_closed' => $img_folder_closed,
'img_folder_open' => $img_folder_open
));
$toggle_function = $t->parse('out', 'tplfile');
$toggle_function =
'<script language="JavaScript" type="text/javascript">' . "\n" .
'<!--' . "\n" .
$toggle_function .
'// -->' . "\n" .
'</script>' . "\n";
$toggle =
'<script language="JavaScript" type="text/javascript">' . "\n" .
'<!--' . "\n" .
'if ((DOM && !Opera56 && !Konqueror22) || IE4) {' . "\n" .
$toggle .
'}' . "\n" .
'if (NS4) alert("Only the accessibility is provided to Netscape 4 on the JavaScript Tree Menu.\nWe *strongly* suggest you to upgrade your browser.");' . "\n" .
'// -->' . "\n" .
'</script>' . "\n";
$this->_treeMenu[$menu_name] = $toggle_function . "\n" . $this->_treeMenu[$menu_name] . "\n" . $toggle;
return $this->_treeMenu[$menu_name];
}
/**
* Method that returns the code of the requested Tree Menu
* @access public
* @param string $menu_name the name of the menu whose Tree Menu code
* has to be returned
* @return string
*/
function getTreeMenu($menu_name)
{
return $this->_treeMenu[$menu_name];
}
/**
* Method that prints the code of the requested Tree Menu
* @access public
* @param string $menu_name the name of the menu whose Tree Menu code
* has to be printed
* @return void
*/
function printTreeMenu($menu_name)
{
print $this->_treeMenu[$menu_name];
}
} /* END OF CLASS */
?>