}
// Generate stylesheet links
- $count = count($this->_styleSheets);
- for($intCounter=0; $intCounter < $count; $intCounter++) {
- $strStyleSheet = $this->_styleSheets[$intCounter];
+ foreach ($this->_styleSheets as $strStyleSheet) {
$strHtml .= $tab . "<link rel=\"stylesheet\" href=\"$strStyleSheet\" type=\"text/css\" />" . $lnEnd;
}
}
// Generate script file links
- $count = count($this->_scripts);
- for($intCounter=0; $intCounter < $count; $intCounter++) {
- $strType = $this->_scripts[$intCounter]["type"];
- $strSrc = $this->_scripts[$intCounter]["src"];
+ foreach ($this->_scripts as $strSrc => $strType) {
$strHtml .= $tab . "<script type=\"$strType\" src=\"$strSrc\"></script>" . $lnEnd;
}
function addBodyContent($content)
{
$this->_body[] =& $content;
+ if (is_object($content)) {
+ if (method_exists($content, "toStyleSheet")) {
+ $this->addStyleSheet($content->toStyleSheet());
+ }
+ if (method_exists($content, "toScript")) {
+ $script = $content->toScript();
+ if (is_array($script)) {
+ $this->addScript($script[0], $script[1]);
+ } else {
+ $this->addScript($script);
+ }
+ }
+ } elseif (is_array($content)) {
+ foreach ($content as $element) {
+ if (is_object($content)) {
+ if (method_exists($element, "toStyleSheet")) {
+ $this->addStyleSheet($element->toStyleSheet());
+ }
+ if (method_exists($element, "toScript")) {
+ $script = $element->toScript();
+ if (is_array($script)) {
+ $this->addScript($script[0], $script[1]);
+ } else {
+ $this->addScript($script);
+ }
+ }
+ }
+ }
+ }
} // end addBodyContent
/**
*/
function addScript($url, $type="text/javascript")
{
- $this->_scripts["$type$url"] = array("type"=>$type, "src"=>$url);
+ $this->_scripts[$url] = $type;
} // end func addScript
/**
function setBody($content)
{
$this->unsetBody();
- $this->_body[] =& $content;
+ $this->addBodyContent($content);
} // end setBody
/**