/**
* The required files
*/
require_once(HTML_TABLE_COMPONENT_PATH.'/TableDataReader.php');
/**
* Generates a Branding Top
* <code>
* +-----------------------------+
* | some text |
* +-----------------------------+
*
* Usage:
* $columns = array(
* array('class'=>CSS_COPYRIGHT,KEY_LINK=>LINK_COPYRIGHT,),
* array('class'=>CSS_COPYRIGHT,KEY_POWERED=>LINK_POWERED_BY,),
* array('class'=>CSS_COPYRIGHT,KEY_VERSION=>CURRENT_VERSION,),
* );
* $datareader = DataReaderFactory::newDataReader($columns);
* $html = new Branding($datareader,$text,$width,$class,$border,$cellPadding,$cellSpacing);
* print $html->getHtml();
* Or
* Branding::display($datareader,$text,$width,$class,$border,$cellPadding,$cellSpacing);
* </code>
* @package layout
*/
class Branding extends TableDataReader {
/**
* Constructor
* @param DataReader $datareader The Data Reader object
* @param String $text The text of the table header
* @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 Branding($datareader='',$text='',$width='',$class='',$border='',$cellPadding='',$cellSpacing='') {
$theText = $text!=''?$text:'';
$theWidth = $width!=''?$width:BRANDING_VIEW_WIDTH;
$theClass = $class!=''?$class:BRANDING_VIEW_CLASS;
$theBorder = $border!=''?$border:BRANDING_VIEW_BORDER;
$theCellPadding = $cellPadding!=''?$cellPadding:BRANDING_VIEW_CELLPADDING;
$theCellSpacing = $cellSpacing!=''?$cellSpacing:BRANDING_VIEW_CELLSPACING;
$theDatareader = $this->getDatareader($datareader);
$this->layout = LINK_LAYOUT_TRIANGLE | LINK_LAYOUT_BR;
$this->TableDataReader($theDatareader,$theText,$theWidth,$theClass,$theBorder,$theCellPadding,$theCellSpacing);
}
/**
* Get the DataReader to use for this class
* @param DataReader $datareader The DataReader object, if defined
* @return DataReader or array The DataReader object or an array of default data
*/
function getDatareader($datareader) {
$theDatareader = $datareader;
if ($theDatareader == '') {
$brandingText = '';
$length = strlen(THE_CUSTOMER_DOMAIN_NAME);
for ($i=0; $i < $length; $i++) {
$ch = substr(THE_CUSTOMER_DOMAIN_NAME, $i, 1);
switch (strtolower($ch)) {
case 'a':
case 'e':
case 'i':
case 'o':
$brandingText .= '<span class="'.CSS_VOWELS.'">'.$ch."</span>\r\n";
break;
default:
$brandingText .= '<span class="'.CSS_NON_VOWELS.'">'.$ch."</span>\r\n";
break;
}
}
$columns = array(
array(KEY_PLAIN=>$brandingText,'class'=>CSS_BRANDING.' '.CSS_ALIGN_LEFT,),
array('valign'=>'middle','text'=>LINK_TEXT_HOME,'title'=>LINK_TITLE_HOME,'href'=>LINK_HREF_HOME,'class'=>CSS_BRANDING.' '.CSS_ALIGN_RIGHT,'src'=>'/'.IMAGE_LOGO.'.gif','alt'=>LINK_TITLE_HOME),
);
$theDatareader = $columns;
}
return $theDatareader;
}
/**
* Get the CSS class Name for this component
* @return String The CSS class name
*/
function getCssClass() {
return CSS_BRANDING;
}
/**
* 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_BRANDING);
}
/**
* Builds the html for a Branding Top, and return it
* @return String The html
*/
function getHtml() {
$html = $this->html;
if (LAYOUT_SHOW & LAYOUT_SHOW_BRANDING && HTTP_USER_AGENT!=HTTP_USER_AGENT_P900) {
if (CACHE_LAYOUT && $this->getCacheFileName(CACHE_LAYOUT_PATH)!='' && file_exists($this->getCacheFileName(CACHE_LAYOUT_PATH))) {
$html .= $this->content($this->getCacheFileName(CACHE_LAYOUT_PATH));
} else {
// $html .= ' <td class="'.$class.'"><div class="'.CSS_ALIGN_CENTER.' '.$class.'">'.$montessori."</div></td>\r\n";
// $html .= ' <td class="'.$class.'"> </td>'."\r\n";
// $html .= " </tr>\r\n";
// $html .= $table->getEnd();
$html .= $this->getColumns();
if (CACHE_LAYOUT) {
$this->save($html, CACHE_LAYOUT_PATH);
}
}
} else {
$html .= $this->getMaximize();
}
return $html;
}
/**
* Display html
* <code>
* Usage:
* Branding::display($datareader,$text,$width,$class,$border,$cellPadding,$cellSpacing);
* </code>
* @static
* @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 The Cell Padding
* @param String $cellSpacing The Cell Spacing
*/
function display($datareader='',$text='',$width='',$class='',$border='',$cellPadding='',$cellSpacing='') {
$html = new Branding($datareader='',$text='',$width='',$class='',$border='',$cellPadding='',$cellSpacing='');
$html->addHtml();
}
}
?>