Skip to content

Commit

Permalink
Add prepend functionality as per feature request Bug #814
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.php.net/repository/pear/packages/HTML_Page/trunk@152348 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information
Klaus Guenther committed Feb 25, 2004
1 parent a7c2f07 commit c60b44b
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions Page.php
Expand Up @@ -700,13 +700,36 @@ function _parseDoctypeString($string)
* Objects must have a toString method.
*
* @param mixed $content New <body> tag content (may be passed as a reference)
* @param int $flag Determines whether to prepend, append or replace the content
* @access public
*/
function addBodyContent($content)
function addBodyContent($content, $flag = 0)
{
$this->_body[] =& $content;
if ($flag == 2) {
$this->setBody($content);
} elseif ($flag == 1) {
array_unshift($this->_body, $content);
} else {
$this->_body[] =& $content;
}
} // end addBodyContent

/**
* Prepends content to the content of the <body> tag. Wrapper for {@link addBodyContent}
* If you wish to overwrite whatever is in the body, use {@link setBody};
* {@link addBodyContent} provides full functionality including appending;
* {@link unsetBody} completely empties the body without inserting new content.
* It is possible to add objects, strings or an array of strings and/or objects
* Objects must have a toString method.
*
* @param mixed $content New <body> tag content (may be passed as a reference)
* @access public
*/
function prependBodyContent($content)
{
$this->addBodyContent($content, 1);
} // end func addScript

/**
* Adds a linked script to the page
*
Expand Down

0 comments on commit c60b44b

Please sign in to comment.