<?php
// $Id: mosimage.inc,v 1.9 2004/01/13 00:57:17 eddieajau Exp $
/**
* mosimage mambot
* @package Mambo Open Source
* @Copyright (C) 2000 - 2003 Miro International Pty Ltd
* @ All rights reserved
* @ Mambo Open Source is Free Software
* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html
* @version $Revision: 1.9 $
**/

defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

function MAMBOT_mosimage( &$row, $mask ) {
	global $mosConfig_live_site, $mosConfig_absolute_path;

	$row->images = explode( "\n", $row->images );
	$images = array();

	foreach ($row->images as $img) {
		$img = trim( $img );
		if ($img) {
			$temp = explode( '|', trim( $img ) );
			if (!isset( $temp[1] )) {
				$temp[1] = "left";
			}
			if (!isset( $temp[2] )) {
				$temp[2] = "Image";
			} else {
				$temp[2] = htmlspecialchars( $temp[2] );
			}
			if (!isset( $temp[3] )) {
				$temp[3] = "0";
			}
			$size = '';
			if (function_exists( 'getimagesize' )) {
				$size = @getimagesize( "$mosConfig_absolute_path/images/stories/$temp[0]" );
				if (is_array( $size )) {
					$size = "width=\"$size[0]\" height=\"$size[1]\"";
				}
			}
			$images[] = "<img src=\"$mosConfig_live_site/images/stories/$temp[0]\" $size align=\"$temp[1]\"  hspace=\"6\" alt=\"$temp[2]\" border=\"$temp[3]\" />";
		}
	}

	$text = explode( '{mosimage}', $row->text );

	$row->text = $text[0];

	for ($i=0, $n=count( $text )-1; $i < $n; $i++) {
		if (isset( $images[$i] )) {
			$row->text .= $images[$i];
		}
		if (isset( $text[$i+1] )) {
			$row->text .= $text[$i+1];
		}
	}
	unset( $text );
}
?>
