toHtml() which
// generates the look and feel of the original Cobalt products.
//
// applicability:
// NOTE: This implementation and style are scheduled for removal.
global $isClassicListDefined;
if($isClassicListDefined)
return;
$isClassicListDefined = true;
// description: turn the object into HTML form
// param: scrollList: the ScrollList object
// param: style: the style to show in (optional)
// returns: HTML that represents the object or
// "" if pageIndex is out of range
function toClassicListHtml($scrollList, $style = "") {
$this = $scrollList;
$widgetid = $this->widgetid;
if($style == null || $style->getPropertyNumber() == 0) {
$page = $this->getPage();
$style = $this->getDefaultStyle($page->getStylist());
}
// find out style properties
$borderColor = $style->getProperty("borderColor");
$borderThickness = $style->getProperty("borderThickness");
$controlAlign = $style->getProperty("controlAlign");
$controlStyleStr = $style->toBackgroundStyle("controlCell");
$controlLabelStyleStr = $style->toTextStyle("controlLabel");
$formFieldStyleStr = $style->toBackgroundStyle("entryCell").$style->toTextStyle("entryCell");
$labelStyleStr = $style->toBackgroundStyle("labelCell");
$sortAscendingIcon = $style->getProperty("sortAscendingIcon");
$sortDescendingIcon = $style->getProperty("sortDescendingIcon");
$sortedAscendingIcon = $style->getProperty("sortedAscendingIcon");
$sortedDescendingIcon = $style->getProperty("sortedDescendingIcon");
$titleAlign = $style->getProperty("titleAlign");
$titleStyleStr = $style->toBackgroundStyle("titleCell");
$width = $this->width;
if (!$width) {
$width = $style->getProperty("width");
}
if (!$width) {
$width = 550;
}
$entries = $this->getEntries();
$entryIds = $this->entryIds;
$entriesSelected = $this->entriesSelected;
$entryNum = count($entries);
$sortedIndex = $this->getSortedIndex();
$sortOrder = $this->getSortOrder();
// sort the entries
if($sortedIndex != -1)
$this->sortEntries($entries);
/*
// prepare a hash for sorting
$sortHash = array();
for($i = 0; $i < $entryNum; $i++) {
$entry = $entries[$i];
$sortHash[$entry[$sortedIndex]->getValue()] = $entry;
}
// sort
if($sortOrder == "ascending")
ksort($sortHash);
else
krsort($sortHash);
// save result
$entries = array_values($sortHash);
*/
$desiredLength = $this->getLength();
$length = $desiredLength;
// out of range?
$pageIndex = $this->getPageIndex();
if($pageIndex < 0 || $pageIndex > $entryNum/$length)
return "";
// find out from where to start listing
$from = $pageIndex*$length;
// find out length
if($from+$length > $entryNum)
$length = $entryNum-$from;
$id = $this->getId();
$page = $this->getPage();
$i18n = $page->getI18n();
$form = $page->getForm();
$formId = $form->getId();
$entryLabelObjs = $this->getEntryLabels();
$entryLabelNum = count($entryLabelObjs);
// find out if any entries can be selected
$hasSelectColumn = false;
for($i = 0; $i < $entryNum; $i++)
if($entryIds[$i] != "") {
$hasSelectColumn = true;
break;
}
// find out number of columns
$columnNum = $hasSelectColumn ? $entryLabelNum+1 : $entryLabelNum;
$builder = new FormFieldBuilder();
// make entry count
$messageTag = ($entryNum == 1) ? $this->entryCountTagSingular : $this->entryCountTagPlural;
$entryCount = "
".$i18n->interpolate($messageTag, array("count" => $entryNum))." | ";
// make page selection widget
if($entryNum <= $length)
$pageSelect = "";
else {
// make button for selection
$pageIndexId = "_ScrollList_pageIndex_$widgetid";
$multiButton = new MultiButton($page);
$pageIndexCount = 0;
for($i = 0; $i < $entryNum; $i += $desiredLength) {
// find the range
$fromEntry = $desiredLength*$pageIndexCount+1;
$toEntry = $desiredLength*($pageIndexCount+1);
$toEntry = ($toEntry <= $entryNum) ? $toEntry : $entryNum;
// add action
$multiButton->addAction("javascript: document.$formId.$pageIndexId.value = $pageIndexCount; document.$formId.submit()", $i18n->get("entryRange", "palette", array("from" => $fromEntry, "to" => $toEntry)));
// next page
$pageIndexCount++;
}
$multiButton->setSelectedIndex($pageIndex);
// make hidden field to store page index
$result .= $builder->makeHiddenField($pageIndexId, $pageIndex);
$pageSelect .= "".$multiButton->toHtml()." | ";
}
// make buttons
$buttons = $this->getButtons();
$allButtons = "";
if(count($buttons) > 0) {
$allButtons .= "";
for($i = 0; $i < count($buttons); $i++) {
if($i > 0)
$allButtons .= "| | ";
$allButtons .= "".$buttons[$i]->toHtml()." | ";
}
$allButtons .= "
";
}
if (!$this->entryCountHidden) {
$controlRow = "
| $allButtons | $pageSelect $entryCount
|
";
} else {
$controlRow = "";
}
$labelObj = $this->getLabel();
$label = $labelObj->toHtml($style->getSubstyle("titleLabel"));
$result .= "
";
return $result;
}