XML,PHP,CMS - Flash gallery content managment system, can anyone help?

I have a meeting with a potential client this upcoming Wed. If I am hired, I will be redesigning his website, the major components he wants are galleries of his sculpture art and a way to update the images himself.

My idea: develop a custom CMS so he or his secretary can easily update what images are in the online flash galleries. My idea right now is an HTML/PHP form where they would enter what gallery the image goes to and maybe an upload button for the image, they hit submit and the PHP form edits an XML document which is where the gallery gets its image info from. Can anyone help me figure out how to do this? Or if there is an easier way to develop a CMS for them to update the images in the gallery themselves? Being able to remove images via a custom CMS would be ideal.

I just graduated with an AA degree a couple months ago but I focused on the front-end design aspect of web design, so I am not that backend savvy, but I learn fast. I appreciate any help and insight anyone can offer me.

What you could do is have PHP read all the existing images in the folder (this can be easily done), and have it output the proper XML so that Flash can read it. Then, in your admin panel, you’d have an upload script that uploads the image to that folder (very easy too). After the image has been uploaded, PHP will then read it because it reads all the images in the folder, and thus output the new XMl file with the new image added to it, and thus it’s been updated.

Hmm, that is a really good idea. Thanks for the advice!

But, how could I remove images as well from the xml? Would the php form simply have an option to delete the image from the folder, THEN, output a new xml based on what images are NOW in the folder? or what?

If anyone can help me figure out the best way to do this, and/or show an example of what the code would look like. I mean I know the basics but I have no idea how to do this or where to start, I need a stepping stone, thanks to anyone who can spare some time, I appreciate it.

I cant find anything about how to create an xml file from php, can you help me or point me to something i have missed when googling?

To remove an image, just remove it from the folder then. When PHP reads the folder, it won’t be there anymore and thus no longer in the XML file, and thus no longer in Flash. To output XML with PHP, use this excellent tutorial by Jubba/Vash. It’s originally used with MySQL, but you can apply it to your situation too: http://www.kirupa.com/web/mysql_xml_php.htm


<?php
function getTabs($level){
	$tabs = "";
	for($i=0;$i<$level;$i++){
		$tabs .= "	";
	}
	return $tabs;
}
function getImage($dir, $file, $level){
	$fullPath=$dir."/".$file;
	$file = substr($file, 0, -4);
	list($width, $height, $type, $attr) = getimagesize($fullPath);
	if($type == 2){
		//echo $attr;
		echo getTabs($level)."<image name=\"$file\" $attr path=\"$fullPath\"/> 
";
	}
}

function readdirRecursive($dir, $level){ 
	$dh=opendir($dir);
	while ($file=readdir($dh)){ 
		if($file!="." && $file!=".."){ 
			$fullpath=$dir."/".$file;
			if(!is_dir($fullpath)){ 
				getImage($dir, $file, $level);
			}else{
				echo getTabs($level)."<dir name=\"$file\" >
";
				readdirRecursive($fullpath, $level + 1);
				echo getTabs($level)."</dir>
";
				
			}
		}
	}
	closedir($dh);
}
echo "<?xml version='1.0' ?>
";
echo "<data>
";
readdirRecursive(".", 1);
echo "</data>
";
?>

results
http://www.rvgate.nl/fotos/xmllist.php
(takes kinda long to load coz of the 1000+ images in there. hehe)
(this includes subfolders)

then just use flash to read the xml, (just load the xmllist.php into an xml object)

I guess I dont understand how to make that work, can you elaborate?

just copy paste it in a php file, and put that file in the dir with all your photo’s

then, when you open the file in internet explorer or firefox, you will see an xml formatted data (in the source, if screen is ****ed up)

and use the xml load function, to load the php file into the xml object, flash can read it as xml then.