<?php
/*
This file is part of POOF.
POOF is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
POOF is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with POOF; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
require_once(dirname(__FILE__) . "/Queue.class.php");
/**
* A list of formatted Hyperlinks.
* @package poof
* @author Brian Takita <hide@address.com>
* @version 0.4
* @since Version 0.3.1
*/
class Hyperlinks {
/**
* @var string The delimiter between the hyperlinks.
*/
var $delimiter = "<br />";
/**
* @var string The html before the hyperlinks.
*/
var $header;
/**
* @var string The html after the hyperlinks.
*/
var $footer;
/**
* @var Queue The hyperlinks.
* @access private
*/
var $_links;
/**
* The Hyperlinks constructor. It initialises the link queue.
*/
function Hyperlinks() {
$this->_links = & new Queue;
}
/**
* Add a link to the list of hyperlinks.
*
* @param string $title The displayed title name of the hyperlink.
* @param string $url The url of the displayed hyperlink.
*/
function add($title, $url) {
$bc = array('title'=>&$title, 'url'=>&$url);
$this->_links->push(&$bc);
}
/**
* Parse the hyperlink list into html.
* @return string The html of the formatted list of hyperlinks.
*/
function parse() {
$items = $this->_links->get_length();
$string = $this->header;
for ($i=0; $i < $items; $i++) {
$content = &$this->_links->shift();
$string .= '<a href="' . $content['url'] . '">' . $content['title'] . '</a>';
if ($i < $items-1)
$string .= $this->delimiter;
}
return $string . $this->footer;
}
}
?>