Permalink
Browse files

Add prepend functionality as per feature request Bug #814

git-svn-id: http://svn.php.net/repository/pear/packages/HTML_Page/trunk@152348 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent a7c2f07 commit c60b44be1cc270fc7560d51d5e8b2d389cbb60c1 Klaus Guenther committed Feb 25, 2004
Showing with 25 additions and 2 deletions.
  1. +25 −2 Page.php
View
@@ -700,14 +700,37 @@ 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
*
* @param string $url URL to the linked script

0 comments on commit c60b44b

Please sign in to comment.