2 // vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4:
3 // +--------------------------------------------------------------------+
4 // | BIFE - Buil It FastEr |
5 // +--------------------------------------------------------------------+
6 // | This file is part of BIFE. |
8 // | BIFE is free software; you can redistribute it and/or modify it |
9 // | under the terms of the GNU General Public License as published by |
10 // | the Free Software Foundation; either version 2 of the License, or |
11 // | (at your option) any later version. |
13 // | BIFE is distributed in the hope that it will be useful, but |
14 // | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 // | General Public License for more details. |
18 // | You should have received a copy of the GNU General Public License |
19 // | along with Hooks; if not, write to the Free Software Foundation, |
20 // | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 // +--------------------------------------------------------------------+
22 // | Created: Sun Jun 1 20:00:20 2003 |
23 // | Authors: Leandro Lucarella <luca@lugmen.org.ar> |
24 // +--------------------------------------------------------------------+
30 require_once 'BIFE/Container.php';
33 // +X2C Class 110 :Link
35 * Link to another page.
40 class BIFE_Link extends BIFE_Container {
47 * @param array $attrs Attributes.
52 function BIFE_Link($attrs) // ~X2C
54 $this->__construct($attrs);
62 * @param array $attrs Attributes.
67 function __construct($attrs) // ~X2C
69 $link_attrs['URL'] = $this->getURL($attrs);
70 $link_attrs['DESC'] = @$attrs['DESC'];
71 $link_attrs['TARGET'] = @$attrs['TARGET'];
72 parent::__construct($link_attrs);
78 * Gets a URL string based on Link attributes.
80 * @param array $attrs Link attributes.
85 function getURL($attrs) // ~X2C
87 $url = @$attrs['URL'];
88 if (substr($url, strlen($url)-1) == '/') {
89 $url .= 'index.xbf'; // TODO - add a configuration option for this.
93 foreach($attrs as $name => $value) {
94 if (substr($name, 0, 5) === 'DATA-') {
95 if ($name = substr($name, 5)) {
96 $query[] = urlencode($name) . '=' . urlencode($value);
101 $url .= '?' . join('&', $query);
107 // +X2C Operation 160
109 * Gets the relative path of the current BIFE file for web (URL) usage.
114 function getWebPath() // ~X2C
116 return (@$_SERVER['PATH_INFO']) ? '../' : './';
120 // +X2C Operation 161
122 * Gets the relative path of the current BIFE file for filesystem usage.
127 function getFsPath() // ~X2C
129 return dirname('.' . @$_SERVER['PATH_INFO']) . '/';
133 // +X2C Operation 157
135 * Renders the widget.
137 * @param HTML_Template_HIT &$template Template to use to render the widget.
142 function render(&$template) // ~X2C
144 $this->attrs['CONTENTS'] = $this->renderContents($template);
145 return $template->parse('bife_link', $this->attrs, '', '');
149 } // -X2C Class :Link