/**
* The required files
*/
require_once(HTML_UTIL_COMPONENT_PATH.'/Request.php');
/**
* Generates a list of links, like in an Index
* <code>
* Usage:
* $documents = array('Message','MessageList','Redirect','Rowcolor','Singleton',);
* $indexMenuLinks = IndexMenu:links($documents);
* Or
* $file = IndexMenu::file($PACKAGES);
* </code>
* @package tab
*/
class IndexMenu {
/**
* Constructor
*/
function IndexMenu() {
}
/**
* Get the filename name for the Index source code
* The global package name is expected
* @see $PACKAGES
* <code>
* Usage:
* $file = IndexMenu::file($PACKAGES);
* </code>
* @static
* @param array $packages The array of packages
* @param String $phpFile The php filename to use
* @return String The filename to include or empty if not found
*/
function file($packages, $phpFile) {
$filename = '';
$indexSourceCode = INDEX_DEFAULT;
$tabSourceCode = TAB_INDEX;
if (defined('TAB_SHOW') && TAB_SHOW & TAB_SHOW_URL) {
$indexSourceCode = Request::get(REQUEST_INDEX, INDEX_DEFAULT);
$tabSourceCode = Request::get(REQUEST_TAB, TAB_INDEX);
}
foreach($packages as $key=>$package) {
if (defined($package)) {
$file = constant($package).DEFAULT_HTML_DOC_PATH.($indexSourceCode!=''?"$indexSourceCode":'')."/".$phpFile;
if (!file_exists($file)) {
//print "not $file<br />";
$file = constant($package).DEFAULT_HTML_DOC_PATH.$phpFile;
} else {
//
}
if (file_exists($file)) {
$text = substr(basename(constant($package)), strlen(MYPHP_PREFIX.CURRENT_VERSION));
if ( $text == $tabSourceCode ) {
$filename = $file;
//print "require $key $file<br />\r\n";
break;
} else {
// Ignore
//print "Ignore $text $key $file<br />\r\n";
}
} else {
// Ok
// print "Not exists $key $file<br />\r\n";
}
} else {
// Ok, not part of the packages
// print "Not part of package $key $package<br />\r\n";
}
}
return $filename;
}
/**
* Get the array of index menu links
* <code>
* Usage:
* $documents = array('Message','MessageList','Redirect','Rowcolor','Singleton',);
* $indexMenuLinks = IndexMenu::links($documents);
* </code>
* @static
* @param array $documents The array of index links
* @return array The rows of array links for the Index.php
*/
function links($documents) {
$indexmenuLinks = array();
$isRequest = false;
if (defined('TAB_SHOW') && TAB_SHOW & TAB_SHOW_URL) {
$isRequest = true;
}
$params = '';
$tabSourceCode = TAB_INDEX;
if ($isRequest) {
$params = Params::get(array(REQUEST_INDEX=>''));
$indexmenuLinks[] = array('text'=>LINK_TEXT_OVERVIEW,'href'=>$params,'aux'=>LINK_LAYOUT_LI,'class'=>'','title'=>LINK_TITLE_OVERVIEW,);
} else {
$indexmenuLinks[] = array('text'=>LINK_TEXT_OVERVIEW,'href'=>$GLOBALS[LINK_NAME_HREF ][LINK_SOURCE_CODE].'/'.$tabSourceCode,'aux'=>LINK_LAYOUT_LI,'class'=>'','title'=>LINK_TITLE_OVERVIEW,);
}
foreach($documents as $document) {
if ($isRequest) {
$params = Params::get(array(REQUEST_INDEX=>$document));
$indexmenuLinks[] = array('text'=>$document,'href'=>$params,'aux'=>LINK_LAYOUT_LI);
} else {
$indexmenuLinks[] = array('text'=>$document,'href'=>$GLOBALS[LINK_NAME_HREF ][LINK_SOURCE_CODE].'/'.$tabSourceCode.'/'.$document,'aux'=>LINK_LAYOUT_LI);
}
}
return $indexmenuLinks;
}
/**
* Builds the html for an Index menu, and return it
* @return String The Index menu as html
*/
function getHtml() {
$html = '';
$documents = array('Message','MessageList','Redirect','Rowcolor','Singleton',);
$indexmenuLinks = IndexMenu::links($documents);
foreach($indexmenuLinks as $no=>$links) {
$row = '';
foreach($links as $key=>$value) {
$row .= "$key=>$value ";
}
$html .= "$no) $row<br />\r\n";
}
return $html;
}
}
?>