<?php
header( "Content-type: text/xml" );
echo '<?xml version="1.0" encoding="utf-8" ?>';

$this_file = str_replace( '\\', '/', __FILE__ );
$this_file = explode( 'wp-content', $this_file );
$this_file = $this_file[ 0 ];

// required for making tables easier
require_once( $this_file . 'wp-config.php' );

// alternative
//require_once( '../../../wp-config.php' );

// get options
$aOptions   = SofaShoppr::initOptions( false );
$slidespage = $aOptions[ 'slidespage' ];
$segments = $aOptions[ 'segments' ]; 
$tweentime = $aOptions[ 'tween_time' ]; 
$tweendelay = $aOptions[ 'tween_delay' ];  
$tweentype = $aOptions[ 'tween_type' ]; 
$zdistance = $aOptions[ 'z_distance' ]; 
$expand = $aOptions[ 'expand' ];
$innercolor = $aOptions[ 'inner_color' ];
$textbackground = $aOptions[ 'text_background' ];  
$textdistance = $aOptions[ 'text_distance' ];  
$shadow = $aOptions[ 'shadow_darkness' ]; 
$autoplay = $aOptions[ 'autoplay' ];
?>

<?php
echo '<Piecemaker>';

echo '<Settings>';
echo '<imageWidth>920</imageWidth>';
echo '<imageHeight>280</imageHeight>';
echo '<segments>'. $segments . '</segments>';
echo '<tweenTime>'. $tweentime . '</tweenTime>';
echo '<tweenDelay>'. $tweendelay . '</tweenDelay>';
echo '<tweenType>'. $tweentype . '</tweenType>';
echo '<zDistance>'. $zdistance . '</zDistance>';
echo '<expand>'. $expand . '</expand>';
echo '<innerColor>'. $innercolor . '</innerColor>';
echo '<textBackground>'. $textbackground . '</textBackground>';
echo '<textDistance>'. $textdistance . '</textDistance>';
echo '<shadowDarkness>' . $shadow . '</shadowDarkness>';
echo '<autoplay>' . $autoplay .  '</autoplay>';
echo '</Settings>';
// dynamic
$array_irp_imgs = array(); // image path
$array_irp_iurl = array(); // image links to
$attFiles =& get_children( 'post_type=attachment&post_mime_type=image&orderby=menu_order&order=ASC&post_parent=' . $slidespage );
$arrK = array_keys( $attFiles );
if( $arrK[ 0 ] ) {
	$cnt_imagez = 0;
	$imagez_len = count( $arrK );
	while( $cnt_imagez < $imagez_len ) {
		$gpm_image_linkto = get_post_meta( $arrK[ $cnt_imagez ], '_url', true );
		if( $gpm_image_linkto != '' && $gpm_image_linkto != NULL ) {
			array_push( $array_irp_iurl, $gpm_image_linkto );
		} else array_push( $array_irp_iurl, '' );
		array_push( $array_irp_imgs, wp_get_attachment_url( $arrK[ $cnt_imagez ] ) );
		$cnt_imagez ++;
	}
}

if( count( $array_irp_imgs ) > 0 ) {		
	$iterate = 0;
	$irp_imgs_len = count( $array_irp_imgs );
	while( $iterate < $irp_imgs_len ) {

		echo '<Image Filename="' . $array_irp_imgs[ $iterate ] . '">';
		echo '<Text>';
		echo '<headline>';
		if( $array_irp_iurl[ $iterate ] != '' ) echo '<a href="' . $array_irp_iurl[ $iterate ] . '" target="_self">' . __( "READ MORE", "sofa_shoppr" ) . '</a>';
		echo '</headline>';
		echo '<paragraph></paragraph>';
		echo '<break></break>';
		echo '<inline></inline>';
		echo '</Text>';
		echo '</Image>';
		
		$iterate ++;
	}	
}
// end dynamic

echo '</Piecemaker>';
?>