Location: PHPKode > projects > LayManSys > laymansys-0.4.0/lib/taglib.php
<?php
/* $Id: taglib.php,v 1.2 2005/09/28 21:14:25 robertbienert Exp $
 *
 * simple tag library
 *
 * Copyright (C) 2005 Robert Bienert
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 */

/* starts the given tag
 *
 * $t	the tag (may include attributes, node values, ...)
 */
function tagStart($t) { echo '<' . $t; }

/* ends the given tag
 *
 * $t	the tag
 */
function tagEnd($t) { echo '</' . $t . '>'; }

/* prints a XML/HTML node
 *
 * $t	the tag name
 * $s	the node value
 */
function tag($t, & $s) { tagStart($t); echo '>' . $s; tagEnd($t); }

/* prints a XML/HTML key-value pair
 */
function echoKeyValue($val, $key) {
	echo ' ' . $key . '="' . $val . '"';
}

/* prints an associative array as XML/HTML attributes
 *
 * $a	the array
 */
function htmlAttrs(& $a) {
	array_walk($a, 'echoKeyValue');
}

/* prints a XML/HTML tag including attributes and node value
 *
 * $tag		the tag name
 * $text	the node value
 * $attr	XML/HTML attributes as associative array
 */
function tagA($tag, $text, $attr) {
	tagStart($tag);
	htmlAttrs($attr);
	echo '>' . $text;
	tagEnd($tag);
}

/* prints a standalone XML/HTML tag including attributes
 *
 * $tag		the tag name
 * $attr	XML/HTML attributes as associative array
 */
function sTagA($tag, $attr) {
	tagStart($tag);
	htmlAttrs($attr);
	echo ' />';
}
?>
Return current item: LayManSys