<?php

/**
 * This file contains miscellaneous functions
 * used by the phpHtmllibs that don't seem to
 * fit in the other files.
 *
 * $Id: misc_utils.inc,v 1.6.2.1 2005/05/12 01:24:03 hemna Exp $
 *
 * @author Walter A. Boring IV <waboring@newsblob.com>
 * @package phpHtmlLib
 * 
 */

/**
 * This builds an IMG tag object that is used
 * to show a spacer image.
 * <img src="spacer.gif" width="$width" height="$height">
 *
 * @param   int $width - the width of the img
 *                       ( DEFAULT : 1)
 * @param   int $height - the height of the img
 *                       ( DEFAULT : 1)
 * @param   string  $img_path - The dir that holds the spacer.gif file.
 *                              ( DEFAULT = "/images" )
 * @return  IMGtag object.
 */
function build_spacergif_imgtag( $width=1, $height=1, $img_path="/images" ) {
    $attributes = array( "src" => $img_path."/spacer.gif",
                         "width" => $width,
                         "height" => $height);
    return html_img( $img_path."/spacer.gif", $width, $height );
}

/**
 * This function pushes an array of keys
 * into an HTMLTagObject
 *
 * @param object - the HTMLTagClass object.
 * @param array - the array of data to push
 *                array("blah", "foo", "bar");
 * @return HTMLTagClass object.
 */
function push_args( $tag_object, $args ) {
    foreach ($args as $content) {
        $tag_object->push( $content );
    }
    return $tag_object;
}



/**
 * This function creates a new container widget
 * and stuffs all the args into it.
 *
 * @param mixed - variable # of args
 * @return ContainerWidget object
 */
function container() {
    $container = new ContainerWidget;

    $num_args = func_num_args();
    for ($i=0;$i<$num_args;$i++) {
        $container->push(func_get_arg($i));
    }
    return $container;
}


/**
 * This function is used to wrap 
 * a string in the standard 
 * CDATA section wrapper for a 
 * tag content
 *
 * <![CDATA[ CONTENT ]]>
 *
 * @param string the content to wrap
 */
function cdata_wrapper( $content ) {
	$tag = new CDATAtag;

	$num_args = func_num_args();
    for ($i=0;$i<$num_args;$i++) {
        $tag->push(func_get_arg($i));
    }
	return $tag;
}
?>
