Permalink
Browse files

* fix linked script and stylesheet support (thanks to Leandro Lucarella)

* fix notice in unsetBody()


git-svn-id: http://svn.php.net/repository/pear/packages/HTML_Page/trunk@136205 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent fb5c969 commit 9196b60f394cacb850cb4d80ff08bd1490abb0f3 Klaus Guenther committed Jul 29, 2003
Showing with 8 additions and 13 deletions.
  1. +8 −13 Page.php
View
@@ -432,10 +432,8 @@ function _generateHead()
}
// Generate stylesheet links
- $count = count($this->_styleSheets);
- for($intCounter=0; $intCounter < $count; $intCounter++) {
- $strStyleSheet = $this->_styleSheets[$intCounter];
- $strHtml .= $tab . "<link rel=\"stylesheet\" href=\"$strStyleSheet\" type=\"text/css\"" . $tagEnd . $lnEnd;
+ foreach ($this->_styleSheets as $strSrc => $strType ) {
+ $strHtml .= $tab . "<link rel=\"stylesheet\" href=\"$strSrc\" type=\"$strType\"" . $tagEnd . $lnEnd;
}
// Generate stylesheet declarations
@@ -481,10 +479,7 @@ function _generateHead()
}
// 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;
}
@@ -698,7 +693,7 @@ function addBodyContent($content)
*/
function addScript($url, $type="text/javascript")
{
- $this->_scripts[] = array("type"=>$type, "src"=>$url);
+ $this->_scripts[$url] = $type;
} // end func addScript
/**
@@ -723,9 +718,9 @@ function addScriptDeclaration($content, $type = 'text/javascript')
* @access public
* @return void
*/
- function addStyleSheet($url)
+ function addStyleSheet($url, $type = 'text/css')
{
- $this->_styleSheets[] = $url;
+ $this->_styleSheets[$url] = $type;
} // end func addStyleSheet
/**
@@ -832,7 +827,7 @@ function setBody($content)
*/
function unsetBody()
{
- $this->_body = '';
+ $this->_body = array();
} // end unsetBody
/**
@@ -1047,4 +1042,4 @@ function display()
} // end func display
}
-?>
+?>

0 comments on commit 9196b60

Please sign in to comment.