tags to enable formatting * using CSS. * * @author Pascal Van Hecke * @since 1.7 */ class HtmlCreator extends FeedCreator { public $contentType = "text/html"; /** * Contains HTML to be output at the start of the feed's html representation. */ public $header; /** * Contains HTML to be output at the end of the feed's html representation. */ public $footer; /** * Contains HTML to be output between entries. A separator is only used in * case of multiple entries. */ public $separator; /** * Used to prefix the stylenames to make sure they are unique * and do not clash with stylenames on the users' page. */ public $stylePrefix; /** * Determines whether the links open in a new window or not. */ public $openInNewWindow = true; public $imageAlign = "right"; /** * In case of very simple output you may want to get rid of the style tags, * hence this variable. There's no equivalent on item level, but of course you can * add strings to it while iterating over the items ($this->stylelessOutput .= ...) * and when it is non-empty, ONLY the styleless output is printed, the rest is ignored * in the function createFeed(). */ public $stylelessOutput = ""; /** * Writes the HTML. * @return string the scripts's complete text */ public function createFeed() { // if there is styleless output, use the content of this variable and ignore the rest if ($this->stylelessOutput != "") { return $this->stylelessOutput; } //if no stylePrefix is set, generate it yourself depending on the script name if ($this->stylePrefix == "") { $this->stylePrefix = str_replace( ".", "_", $this->_generateFilename() ) . "_"; } //set an openInNewWindow_token_to be inserted or not if ($this->openInNewWindow) { $targetInsert = " target='_blank'"; } // use this array to put the lines in and implode later with "document.write" javascript $feedArray = []; if ($this->image != null) { $imageStr = "" . "" .
				FeedCreator::iTrunc( htmlspecialchars( $this->image->title ), 100 ) .
				"image->width) { $imageStr .= " width='" . $this->image->width . "' "; } if ($this->image->height) { $imageStr .= " height='" . $this->image->height . "' "; } $imageStr .= "/>"; $feedArray[] = $imageStr; } if ($this->title) { $feedArray[] = "
" . FeedCreator::iTrunc( htmlspecialchars( $this->title ), 100 ) . "
"; } if ($this->getDescription()) { $feedArray[] = "
" . str_replace( "]]>", "", str_replace( "getDescription() ) ) . "
"; } if ($this->header) { $feedArray[] = "
" . $this->header . "
"; } for ( $i = 0; $i < count( $this->items ); $i++ ) { if ($this->separator and $i > 0) { $feedArray[] = "
" . $this->separator . "
"; } if ($this->items[$i]->title) { $feedArray[] = ( $this->items[$i]->link ) ? "
" . FeedCreator::iTrunc( htmlspecialchars( strip_tags( $this->items[$i]->title ) ), 100 ) . "
" : "
" . FeedCreator::iTrunc( htmlspecialchars( strip_tags( $this->items[$i]->title ) ), 100 ) . "
"; } if ($this->items[$i]->getDescription()) { $feedArray[] = "
". str_replace("]]>", "", str_replace("items[$i]->getDescription())). "
"; } } if ($this->footer) { $feedArray[] = "
".$this->footer."
"; } $feed= "".join($feedArray, "\r\n"); return $feed; } /** * Overrrides parent to produce .html extensions * * @return string the feed cache filename * @since 1.4 */ public function _generateFilename() { $fileInfo = pathinfo($_SERVER["PHP_SELF"]); return substr($fileInfo["basename"],0,-(strlen($fileInfo["extension"])+1)).".html"; } }