/**
* The required files
*/
require_once(HTML_BASE_UTIL_PATH.'/Link.php');
require_once(HTML_BASIC_UTIL_PATH.'/Message.php');
require_once(HTML_UTIL_COMPONENT_PATH.'/Request.php');
require_once(HTML_UTIL_COMPONENT_PATH.'/Params.php');
if (defined('HTML_LOG_UTIL_PATH')) {
require_once(HTML_LOG_UTIL_PATH.'/Log.php');
}
/**
* Returns a complete predefined Link as HTML.
* The link is found by the $name
* <code>
* Usage:
* $name = LINK_CLOSE; // Or one of the following
* // LINK_DENMARK, LINK_CLOSE, LINK_START, LINK_RETURNX, LINK_BACK, LINK_FIND,
* // LINK_UPDATE, LINK_CMS_HEAD, LINK_CMS_CONTENT, LINK_MAIL, LINK_LOGIN,
* // LINK_LOGOFF, LINK_RETURN, LINK_PRINT
* $html = new Links($name,$text,$class,$title,$aux,$target);
* print $html->getHtml();
* Or
* Links::display($name,$text,$class,$title,$aux,$target);
* </code>
* @package base
*/
class Links extends Link {
/**
* Constructor
* @param String $name The name of an image i.e. 'logo'
* @param String $text The text for the link
* @param String $class The css class of the link
* @param String $title The tool tip of the link
* @param String $aux Add 'br' or 'li' html tags, if required
* @param String $target The target for the link I.e. _BLANK
*/
function Links($name='',$text='',$class='',$title='',$aux='',$target='') {
$href = ''; // TODO overrule ?
$theHref = $this->getUrl($href,$name); // Update href
$theText = $this->getText($text,$name);
$theClass = $this->getClass($class,$name);
$theTitle = $this->getTitle($title,$name);
$this->Link($theText,$theHref,$theClass,$theTitle,$aux,$target);
}
/**
* Get the complete url for a Link icluding the request parameters
* @param String $name The name of a link i.e. LINK_PRINT
* @param String $href The name of an external link i.e. 'design/'
* @return String the html
*/
function getUrl($href,$name) {
$url = $this->getHref($href,$name);
switch ($name) {
case LINK_DENMARK:
case LINK_GERMANY:
case LINK_ENGLAND:
case LINK_FRANCE:
case LINK_ITALY:
case LINK_NORWAY:
case LINK_SWEDEN:
case LINK_USA:
$url .= $this->nextLanguage($href,$name);
break;
case LINK_START:
$params = Params::get(array(@REQUEST_CMS_USERNAME=>''));
$url .= $params;
break;
case LINK_FIND:
$params = Params::get();
$url = @LINK_HREF_SEARCH.$params;
break;
case LINK_UPDATE:
$params = Params::get();
$url .= $params;
break;
case LINK_CMS_HEAD:
if (defined('VIEW_CMS_HEAD_LANGUAGE')) {
$params = Params::get(array(REQUEST_COMMAND=>VIEW_CMS_HEAD_LANGUAGE));
$url .= $params;
}
break;
case LINK_CMS_CONTENT:
if (defined('VIEW_CMS_CONTENT_LANGUAGE')) {
$params = Params::get(array(REQUEST_COMMAND=>VIEW_CMS_CONTENT_LANGUAGE));
$url .= $params;
}
break;
case LINK_MAIL:
$params = Params::get();
$url .= LINK_HREF_EMAIL.$params;
break;
case LINK_LOGIN:
if (defined('VIEW_LOGIN_FORM')) {
$params = Params::get(array(REQUEST_COMMAND=>VIEW_LOGIN_FORM));
$url .= LINK_HREF_LOGIN.$params;
}
break;
case LINK_LOGOFF:
if (defined('VIEW_LOGOFF_FORM')) {
$params = Params::get(array(REQUEST_COMMAND=>VIEW_LOGOFF_FORM));
$url .= LINK_HREF_LOGIN.$params;
}
break;
case LINK_RETURN:
$params = Params::get();
$url .= '/'.$params;
break;
case LINK_BACK:
// Ignore, because of javascript::back();
break;
case LINK_PRINT:
$params = $this->getPrinterParams();
$url .= Params::get($params);
break;
default:
$params = Params::get();
$url .= $params;
break;
}
return $url;
}
/**
* Get the parameters for the print link for the supported packages
* @return array The array of supported packages
*/
function getPrinterParams() {
$params = array();
if (defined('REQUEST_COMMAND') && defined('VIEW_PRINTER')) {
$params[REQUEST_COMMAND] = VIEW_PRINTER;
}
if (defined('REQUEST_COMPONENT_SHOW') && defined('COMPONENT_SHOW_PRINTER')) {
$params[REQUEST_COMPONENT_SHOW] = COMPONENT_SHOW_PRINTER;
}
if (defined('REQUEST_LAYOUT_SHOW') && defined('LAYOUT_SHOW_PRINTER')) {
$params[REQUEST_LAYOUT_SHOW] = LAYOUT_SHOW_PRINTER;
}
if (defined('REQUEST_LINK_SHOW') && defined('LINK_SHOW_PRINTER')) {
$params[REQUEST_LINK_SHOW] = LINK_SHOW_PRINTER;
}
if (defined('REQUEST_TAB_SHOW') && defined('TAB_SHOW_PRINTER')) {
$params[REQUEST_TAB_SHOW] = TAB_SHOW_PRINTER;
}
if (defined('REQUEST_CMS_SHOW') && defined('CMS_SHOW_PRINTER')) {
$params[REQUEST_CMS_SHOW] = CMS_SHOW_PRINTER;
}
if (defined('REQUEST_SKELETON_SHOW') && defined('SKELETON_SHOW_PRINTER')) {
$params[REQUEST_SKELETON_SHOW] = SKELETON_SHOW_PRINTER;
}
if (defined('REQUEST_GOOGLE_ADS_SHOW') && defined('GOOGLE_ADS_SHOW_PRINTER')) {
$params[REQUEST_GOOGLE_ADS_SHOW] = GOOGLE_ADS_SHOW_PRINTER;
}
if (defined('REQUEST_GOOGLE_MAPS_SHOW') && defined('GOOGLE_MAPS_SHOW_PRINTER')) {
$params[REQUEST_GOOGLE_MAPS_SHOW] = GOOGLE_MAPS_SHOW_PRINTER;
}
if (defined('REQUEST_GOOGLE_TRANSLATE_SHOW') && defined('GOOGLE_TRANSLATE_SHOW_PRINTER')) {
$params[REQUEST_GOOGLE_TRANSLATE_SHOW] = GOOGLE_TRANSLATE_SHOW_PRINTER;
}
if (defined('REQUEST_MENU_FISHEYE_SHOW') && defined('MENU_FISHEYE_SHOW_PRINTER')) {
$params[REQUEST_MENU_FISHEYE_SHOW] = MENU_FISHEYE_SHOW_PRINTER;
}
return $params;
}
/**
* Get the link attribute or use the default
* <code>
* Usage:
* $attribute = '';
* $text = $this->getLinkName($attribute,LINK_PRINT,LINK_NAME_TEXT);
* </code>
* @param String $attribute The attribute to use, if supplied
* @param String $linkId The link ID to use
* @param String $linkname The link name to use
* @return String The value of the link attribute
*/
function getLinkName($attribute, $linkId, $name) {
$value = $attribute;
if ($value == '') {
$linkname = $GLOBALS[$name];
if (is_array($linkname)) {
if (array_key_exists($linkId,$linkname)) {
$value = $GLOBALS[$name][$linkId];
} else {
// TODO what
}
} else {
// TODO what
}
} else {
// TODO what
}
return $value;
}
/**
* Get the link attribute for the href or use the link ID
* @param String $href The href to use, if supplied
* @param String $linkId The link ID to use
* @return String The value of the link href attribute
*/
function getHref($href, $linkId) {
return $this->getLinkName($href,$linkId,LINK_NAME_HREF);
}
/**
* Get the link attribute for the text or use the link ID
* @param String $text The text to use, if supplied
* @param String $linkId The link ID to use
* @return String The value of the link text attribute
*/
function getText($text, $linkId) {
return $this->getLinkName($text,$linkId,LINK_NAME_TEXT);
}
/**
* Get the link attribute for the class or use the link ID
* @param String $class The class to use, if supplied
* @param String $linkId The link ID to use
* @return String The value of the link class attribute
*/
function getClass($class, $linkId) {
return $this->getLinkName($class,$linkId,LINK_NAME_CLASS);
}
/**
* Get the link attribute for the title or use the link ID
* @param String $title The title to use, if supplied
* @param String $linkId The link ID to use
* @return String The value of the link title attribute
*/
function getTitle($title, $linkId) {
return $this->getLinkName($title,$linkId,LINK_NAME_TITLE);
}
/**
* Get the new language from the Link name
* @param String $name The name of the link
* @return String $language The next language to use
*/
function getLanguage($name) {
$language = LANGUAGE;
switch ($name) {
case LINK_DENMARK:
$language = LANGUAGE_DA;
break;
case LINK_GERMANY:
$language = LANGUAGE_DE;
break;
case LINK_ENGLAND:
$language = LANGUAGE_EN;
break;
case LINK_FRANCE:
$language = LANGUAGE_FR;
break;
case LINK_ITALY:
$language = LANGUAGE_IT;
break;
case LINK_NORWAY:
$language = LANGUAGE_NO;
break;
case LINK_SWEDEN:
$language = LANGUAGE_SE;
break;
case LINK_USA:
$language = LANGUAGE_US;
break;
default:
break;
}
return $language;
}
/**
* Change to the next language
* @param String $href The href of the link
* @param String $name The name of the link
* @return String The href to use
*/
function nextLanguage($href,$name) {
$param = array();
$language = $this->getLanguage($name);
if (defined('REQUEST_LANGUAGE')) {
$param[REQUEST_LANGUAGE] = $language;
}
if (defined('REQUEST_TAB')) {
$tab = Request::get(REQUEST_TAB);
if ($tab != '') {
$param[REQUEST_TAB] = $tab;
}
}
$params = Params::get($param);
// Substitute the original language with the new language in question
if (LANGUAGE!='' && LANGUAGE!==$language && array_key_exists($language,$GLOBALS[DEFINE_LANGUAGE])) {
$params = str_replace(REQUEST_LANGUAGE.'='.LANGUAGE,REQUEST_LANGUAGE.'='.$GLOBALS[DEFINE_LANGUAGE][$language],$params);
}
return $href.$params;
}
/**
* Get a new Links object from the specified Link name
* <code>
* Usage:
* $link = Links::newLink($name,$text,$class,$title,$aux,$target);
* </code>
* @static
* @param String $name The name of a link i.e. 'logo'
* @param String $text The text for the link
* @param String $class The css class of the link
* @param String $title The tool tip of the link
* @param String $aux Add 'br' or 'li' html tags, if required
* @param String $target The target for the link. I.e. _BLANK
* @return Links Return a new instance of the Links object
*/
function newLink($name='',$text='',$class='',$title='',$aux='',$target='') {
return new Links($name,$text,$class,$title,$aux,$target);
}
/**
* Display a predefined link, when the LINK_name is supplied
* <code>
* Usage:
* Links::display($name,$text,$class,$title,$aux,$target);
* </code>
* @static
* @param String $name The name of an image i.e. 'logo'
* @param String $text The text for the link
* @param String $class The css class of the link
* @param String $title The tool tip of the link
* @param String $aux Add 'br' or 'li' html tags, if required
* @param String $target The target for the link. I.e. _BLANK
*/
function display($name='',$text='',$class='',$title='',$aux='',$target='') {
$html = new Links($name,$text,$class,$title,$aux,$target);
$html->addHtml();
}
}
?>
HTML source code
Den fulde HTML kildekode for Links klassen
<?
<!-- Copyright @ 1999-2008
Web Expert Finn Rasmussen --><a id="Links60" class="baseLinkColor" href="http://www.hvepseeksperten.dk/finnrasmussen/copyright/#copyright" title="Læs om Copyright (c) fra
Web Expert Finn Rasmussen">Copyright @ 1999-2008
Web Expert Finn Rasmussen</a>
?>
Class methods
Her er 'klasse metoderne' for Links klassen:
link
getparams
gethtml
display
object
getclassname
getmsg
addhtml
tostring
getcachefilename
save
content
html
setobject
set
get
getattribute
gettag
add
getsizeof
getelement
getelements
gettoogle
getmaximize
getminimize
newtriangle
showsource
element
getvalue
setid
setonfocus
setonblur
id
links
geturl
getprinterparams
getlinkname
gethref
gettext
getclass
gettitle
getlanguage
nextlanguage
newlink
Object vars
Her er 'objekt variable' for Links klassen:
text => Copyright @ 1999-2008
Web Expert Finn Rasmussen