class Locator extends TableDataReader {
/**
* Constructor
* @param DataReader $datareader The Data Reader object
* @param String $text The text header for the table
* @param String $width The width of the table, default 100%
* @param String $class The css class to use
* @param String $border The table border
* @param String $cellPadding
* @param String $cellSpacing
*/
function Locator($datareader='',$text='',$width='',$class='',$border='',$cellPadding='',$cellSpacing='') {
$theText = $text!=''?$text:'';
$theWidth = $width!=''?$width:LOCATOR_VIEW_WIDTH;
$theClass = $class!=''?$class:LOCATOR_VIEW_CLASS;
$theBorder = $border!=''?$border:LOCATOR_VIEW_BORDER;
$theCellPadding = $cellPadding!=''?$cellPadding:LOCATOR_VIEW_CELLPADDING;
$theCellSpacing = $cellSpacing!=''?$cellSpacing:LOCATOR_VIEW_CELLSPACING;
$theDatareader = $datareader;
if ($theDatareader == '') {
$theDatareader = $this->getDirs();
}
$this->layout = LINK_LAYOUT_TRIANGLE;
$this->TableDataReader($theDatareader,$theText,$theWidth,$theClass,$theBorder,$theCellPadding,$theCellSpacing);
}
/**
* Get a dirview of the Disk
* <code>
* The path info looks like i.e. /dir1/dir2/dir3/file.php
* $url[0] is empty,
* $url[1]..$url[3] is the dir path
* $url[4] is the filename
* </code>
* @return array The array of dir links
*/
function getDirs() {
$dirs = array();
$url = explode('/', LINK_TEXT_HOME.$_SERVER['PHP_SELF']);
$count = count($url)-1; // Skip filename
$root = '';
for ($i = 0; $i < $count; $i++) {
if ($i==0) {
$dash = TEXT_LOCATOR.": / ";
} else {
$root .= '/'.$url[$i]; // Next dir
$dash = " / "; // »
}
if (defined('HTML_LANGUAGE_UTIL_PATH')) {
$text = ucfirst(Translate::get($url[$i]));
} else {
$text = ucfirst($url[$i]);
}
//$text = str_replace('-',"»",$text); // In order to avoid line breaks
$dash = str_replace(' '," ",$dash); // In order to avoid line breaks
$href = $root.'/';
$title = LINK_TITLE_VISIT_US.$text;
$dirs[] = array(KEY_PLAIN=>$dash,'class'=>CSS_LOCATOR);
$dirs[] = array('text'=>$text,'href'=>$href,'class'=>CSS_LOCATOR,'title'=>$title);
}
$dirs[] = array(KEY_PLAIN=>' ','class'=>CSS_LOCATOR.' '.CSS_FILL_OUT);
$dirs[] = $this->getLoginImage();
$dirs[] = array(KEY_PLAIN=>' ','class'=>CSS_LOCATOR);
$dirs[] = $this->getLoginLink();
return $dirs;
}
/**
* Get the Login Image if supplied
* @return String The login name
*/
function getLoginImage() {
$dirs = array();
if (defined('LOGIN_REQUIRED') && LOGIN_REQUIRED) {
// Login/Logoff required
if (defined('LOGIN_USERNAME')) {
$image = new Images(IMAGE_LOGIN,'','','',CSS_LOCATOR);
$link = new Links (LINK_LOGIN,'',CSS_LOCATOR);
if (defined('LOGIN_USERNAME') && LOGIN_USERNAME!=DEFAULT_LOGIN_USERNAME) {
$image = new Images(IMAGE_LOGOFF,'','','',CSS_LOCATOR);
$link = new Links (LINK_LOGOFF,'',CSS_LOCATOR);
} else {
// Not logged in
}
$dirs = array('href'=>$link->get('href'),'class'=>$link->get('class'),'title'=>$link->get('title'),
'src'=>$image->getSrcName(),'width'=>$image->get('width'),'height'=>$image->get('height'),'alt'=>$image->get('alt'));
}
} else {
// Login not required
}
return $dirs;
}
/**
* Get the Login Link if supplied
* @return String The login name
*/
function getLoginLink() {
$dirs = array();
if (defined('LOGIN_REQUIRED') && LOGIN_REQUIRED) {
// Login/Logoff required
if (defined('LOGIN_USERNAME')) {
$link = new Links(LINK_LOGIN,'',CSS_LOCATOR);
if (defined('LOGIN_USERNAME') && LOGIN_USERNAME!=DEFAULT_LOGIN_USERNAME) {
$link = new Links(LINK_LOGOFF,'',CSS_LOCATOR);
} else {
// Not logged in
}
$dirs = array('text'=>$link->get('text'),'href'=>$link->get('href'),'class'=>$link->get('class'),'title'=>$link->get('title'));
}
} else {
// Login not required
}
return $dirs;
}
/**
* Get the CSS class Name for this component
* @return String The CSS class name
*/
function getCssClass() {
return CSS_LOCATOR;
}
/**
* Toogle the request parameters which will minimize or maximize this component
* @return array The array of key=>value pair
*/
function getMinimize() {
return $this->getToogle(REQUEST_LAYOUT_SHOW, LAYOUT_SHOW, LAYOUT_SHOW_LOCATOR);
}
/**
* Get the html, and return it for a location
* @return String The html
*/
function getHtml() {
$html = $this->html;
if (LAYOUT_SHOW & LAYOUT_SHOW_LOCATOR && HTTP_USER_AGENT!=HTTP_USER_AGENT_P900) {
if (defined('CREATE_RUNTIME_KERNEL') && CREATE_RUNTIME_KERNEL) {
$html .= '<?'.ucfirst($this->getClassName()).'::display()?>';
} else {
if (defined('LOGIN_USERNAME') && LOGIN_USERNAME==='' && CACHE_LAYOUT && $this->getCacheFileName(CACHE_LAYOUT_PATH)!='' && file_exists($this->getCacheFileName(CACHE_LAYOUT_PATH))) {
$html .= $this->content($this->getCacheFileName(CACHE_LAYOUT_PATH));
} else {
$html .= $this->getColumns();
if (CACHE_LAYOUT && defined('LOGIN_USERNAME') && LOGIN_USERNAME==='') {
$this->save($html, CACHE_LAYOUT_PATH);
}
}
}
} else {
$html .= $this->getMaximize();
}
return $html;
}
/**
* Display html
* <code>
* Usage:
* Locator::display($width,$class);
* </code>
* @static
* @param String $width The width of the table
* @param String $class The css class of the table
*/
function display($width='',$class='') {
$html = new Locator($width,$class);
$html->addHtml();
}
}
?>