Thread: [Picfinity-commit] SF.net SVN: picfinity: [1] trunk
Status: Beta
Brought to you by:
espadav8
From: <esp...@us...> - 2007-07-17 21:24:04
|
Revision: 1 http://picfinity.svn.sourceforge.net/picfinity/?rev=1&view=rev Author: espadav8 Date: 2007-07-17 14:24:05 -0700 (Tue, 17 Jul 2007) Log Message: ----------- - Initial import Added Paths: ----------- trunk Added: trunk =================================================================== --- trunk (rev 0) +++ trunk 2007-07-17 21:24:05 UTC (rev 1) @@ -0,0 +1,215 @@ +<?php + + // site options + $site_name = "Andrew's Gallery"; + $theme = ($_GET['theme'] != '') ? $_GET['theme'] : "ajax" ; + + // not implemented yet + $max_folders = 0; // 0 = unlimited + + $create_thumbnails = true; + $create_html = true; + $create_xml = true; + + // valid images to be shown + $valid_image_formats = array('png', 'gif', 'jpg', 'jpeg', 'bmp'); + + // get the layout of the current dir + $site_layout = create_folder_layout('.'); + + $xml = array_to_xml($site_layout); + + if ($create_xml) + { + file_put_contents("gallery.xml", $xml); + } + + $html = xml_to_xhtml($xml, ".themes/$theme/$theme.xsl", array('title' => $site_name)); + + if ($create_html) + { + file_put_contents("index.html", $html); + } + + echo $html; + + // echo "<div style=\"display:none;\">$xml</div>"; + + + function create_folder_layout($folder) + { + global $valid_image_formats; + global $create_thumbnails; + + // get a listing of the files/folder + $folder_contents = scandir($folder); + $name = substr($folder, strrpos($folder, '/') + 1); + $id = uniqid('id'); + $layout = array('name' => $name, 'id' => $id); + + // for each entry + while (list(,$folder_entry) = each($folder_contents)) + { + if (strpos($folder_entry, '.') === 0) + { + // this is a hidden file/folder, ignore + } + // if it's a directory and doesn't start with a . + else if (is_dir($folder . '/' . $folder_entry)) + { + // get a list of it's files and check/create thumbnail(s) + $sub_layout = create_folder_layout($folder . '/' . $folder_entry); + //$layout[] = array($folder_entry => $sub_layout); + $layout['folder'][] = $sub_layout; + } + else + { + // otherwise, check if it's an image to process + $ext = substr($folder_entry, strrpos($folder_entry, '.') + 1); + + // check if it's a valid image format + if (in_array($ext, $valid_image_formats)) + { + if ($create_thumbnails) + { + // create a thumbnail + create_thumbnail($folder, $folder_entry, $ext); + } + $layout['image'][] = array('id' => uniqid('id'), 'file' => $folder_entry); + } + } + } + + return $layout; + } + + function create_thumbnail($folder, $image, $ext) + { + if (!is_dir('.thumbs/'.$folder)) + { + mkdir('.thumbs/'.$folder, 0777, TRUE); + chmod('.thumbs/'.$folder, 0777); + } + if (file_exists('.thumbs/'.$folder.'/'.$image)) + { + // if it already exists, do nothing + return; + } + else + { + $src_img; + switch ($ext) + { + case 'png': + $src_img = imagecreatefrompng($folder.'/'.$image); + break; + case 'jpg': + case 'jpeg': + $src_img = imagecreatefromjpeg($folder.'/'.$image); + break; + case 'gif': + $src_img = imagecreatefromgif($folder.'/'.$image); + break; + case 'bmp': + $src_img = imagecreatefrombmp($folder.'/'.$image); + break; + } + + $new_w = 100; + $new_h = 100; + + $old_x = imageSX($src_img); + $old_y = imageSY($src_img); + + if ($old_x > $old_y) { + $thumb_w = $new_w; + $thumb_h = $old_y * ($new_h/$old_x); + } + else if ($old_x < $old_y) { + $thumb_w = $old_x * ($new_w/$old_y); + $thumb_h = $new_h; + } + else if ($old_x == $old_y) { + $thumb_w = $new_w; + $thumb_h = $new_h; + } + + $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h); + imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y); + + switch ($ext) + { + case 'png': + imagepg($dst_img, '.thumbs/'.$folder.'/'.$image); + break; + case 'jpg': + case 'jpeg': + imagejpeg($dst_img, '.thumbs/'.$folder.'/'.$image); + break; + case 'gif': + imagegif($dst_img, '.thumbs/'.$folder.'/'.$image); + break; + case 'bmp': + imagebmp($dst_img, '.thumbs/'.$folder.'/'.$image); + break; + } + + imagedestroy($dst_img); + imagedestroy($src_img); + } + } + + function array_to_xml(&$array, $tag_name = 'image', $headless = false) + { + error_reporting(E_ALL ^ E_NOTICE); + + // Include XML_Serializer + require_once 'XML/Serializer.php'; + + // An array of serializer options + $serializer_options = array ( + 'addDecl' => !$headless, + 'encoding' => 'ISO-8859-1', + 'indent' => ' ', + 'indentAttributes' => '_auto', + 'rootName' => 'layout', + 'defaultTagName' => $tag_name, + 'mode' => 'simplexml', + 'scalarAsAttributes' => true + + ); + + // Instantiate the serializer with the options + $Serializer = &new XML_Serializer($serializer_options); + + // Serialize the data structure + $status = $Serializer->serialize($array); + + // Check whether serialization worked + if (PEAR::isError($status)) { + die($status->getMessage()); + } + + // print_r($Serializer->options); + + // return the XML document + return $Serializer->getSerializedData(); + } + + function xml_to_xhtml($xml, $xsl_file, $params = array()) + { + $doc = new DOMDocument(); + $xsl = new XSLTProcessor(); + + $doc->load($xsl_file); + $xsl->importStyleSheet($doc); + + $doc->loadXML($xml); + + $xsl->setParameter('', $params); + + $html = $xsl->transformToXML($doc); + + return $html; + } +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esp...@us...> - 2007-07-17 21:24:44
|
Revision: 2 http://picfinity.svn.sourceforge.net/picfinity/?rev=2&view=rev Author: espadav8 Date: 2007-07-17 14:24:47 -0700 (Tue, 17 Jul 2007) Log Message: ----------- - Mistake Removed Paths: ------------- trunk Deleted: trunk =================================================================== --- trunk 2007-07-17 21:24:05 UTC (rev 1) +++ trunk 2007-07-17 21:24:47 UTC (rev 2) @@ -1,215 +0,0 @@ -<?php - - // site options - $site_name = "Andrew's Gallery"; - $theme = ($_GET['theme'] != '') ? $_GET['theme'] : "ajax" ; - - // not implemented yet - $max_folders = 0; // 0 = unlimited - - $create_thumbnails = true; - $create_html = true; - $create_xml = true; - - // valid images to be shown - $valid_image_formats = array('png', 'gif', 'jpg', 'jpeg', 'bmp'); - - // get the layout of the current dir - $site_layout = create_folder_layout('.'); - - $xml = array_to_xml($site_layout); - - if ($create_xml) - { - file_put_contents("gallery.xml", $xml); - } - - $html = xml_to_xhtml($xml, ".themes/$theme/$theme.xsl", array('title' => $site_name)); - - if ($create_html) - { - file_put_contents("index.html", $html); - } - - echo $html; - - // echo "<div style=\"display:none;\">$xml</div>"; - - - function create_folder_layout($folder) - { - global $valid_image_formats; - global $create_thumbnails; - - // get a listing of the files/folder - $folder_contents = scandir($folder); - $name = substr($folder, strrpos($folder, '/') + 1); - $id = uniqid('id'); - $layout = array('name' => $name, 'id' => $id); - - // for each entry - while (list(,$folder_entry) = each($folder_contents)) - { - if (strpos($folder_entry, '.') === 0) - { - // this is a hidden file/folder, ignore - } - // if it's a directory and doesn't start with a . - else if (is_dir($folder . '/' . $folder_entry)) - { - // get a list of it's files and check/create thumbnail(s) - $sub_layout = create_folder_layout($folder . '/' . $folder_entry); - //$layout[] = array($folder_entry => $sub_layout); - $layout['folder'][] = $sub_layout; - } - else - { - // otherwise, check if it's an image to process - $ext = substr($folder_entry, strrpos($folder_entry, '.') + 1); - - // check if it's a valid image format - if (in_array($ext, $valid_image_formats)) - { - if ($create_thumbnails) - { - // create a thumbnail - create_thumbnail($folder, $folder_entry, $ext); - } - $layout['image'][] = array('id' => uniqid('id'), 'file' => $folder_entry); - } - } - } - - return $layout; - } - - function create_thumbnail($folder, $image, $ext) - { - if (!is_dir('.thumbs/'.$folder)) - { - mkdir('.thumbs/'.$folder, 0777, TRUE); - chmod('.thumbs/'.$folder, 0777); - } - if (file_exists('.thumbs/'.$folder.'/'.$image)) - { - // if it already exists, do nothing - return; - } - else - { - $src_img; - switch ($ext) - { - case 'png': - $src_img = imagecreatefrompng($folder.'/'.$image); - break; - case 'jpg': - case 'jpeg': - $src_img = imagecreatefromjpeg($folder.'/'.$image); - break; - case 'gif': - $src_img = imagecreatefromgif($folder.'/'.$image); - break; - case 'bmp': - $src_img = imagecreatefrombmp($folder.'/'.$image); - break; - } - - $new_w = 100; - $new_h = 100; - - $old_x = imageSX($src_img); - $old_y = imageSY($src_img); - - if ($old_x > $old_y) { - $thumb_w = $new_w; - $thumb_h = $old_y * ($new_h/$old_x); - } - else if ($old_x < $old_y) { - $thumb_w = $old_x * ($new_w/$old_y); - $thumb_h = $new_h; - } - else if ($old_x == $old_y) { - $thumb_w = $new_w; - $thumb_h = $new_h; - } - - $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h); - imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y); - - switch ($ext) - { - case 'png': - imagepg($dst_img, '.thumbs/'.$folder.'/'.$image); - break; - case 'jpg': - case 'jpeg': - imagejpeg($dst_img, '.thumbs/'.$folder.'/'.$image); - break; - case 'gif': - imagegif($dst_img, '.thumbs/'.$folder.'/'.$image); - break; - case 'bmp': - imagebmp($dst_img, '.thumbs/'.$folder.'/'.$image); - break; - } - - imagedestroy($dst_img); - imagedestroy($src_img); - } - } - - function array_to_xml(&$array, $tag_name = 'image', $headless = false) - { - error_reporting(E_ALL ^ E_NOTICE); - - // Include XML_Serializer - require_once 'XML/Serializer.php'; - - // An array of serializer options - $serializer_options = array ( - 'addDecl' => !$headless, - 'encoding' => 'ISO-8859-1', - 'indent' => ' ', - 'indentAttributes' => '_auto', - 'rootName' => 'layout', - 'defaultTagName' => $tag_name, - 'mode' => 'simplexml', - 'scalarAsAttributes' => true - - ); - - // Instantiate the serializer with the options - $Serializer = &new XML_Serializer($serializer_options); - - // Serialize the data structure - $status = $Serializer->serialize($array); - - // Check whether serialization worked - if (PEAR::isError($status)) { - die($status->getMessage()); - } - - // print_r($Serializer->options); - - // return the XML document - return $Serializer->getSerializedData(); - } - - function xml_to_xhtml($xml, $xsl_file, $params = array()) - { - $doc = new DOMDocument(); - $xsl = new XSLTProcessor(); - - $doc->load($xsl_file); - $xsl->importStyleSheet($doc); - - $doc->loadXML($xml); - - $xsl->setParameter('', $params); - - $html = $xsl->transformToXML($doc); - - return $html; - } -?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esp...@us...> - 2007-08-12 20:06:29
|
Revision: 29 http://picfinity.svn.sourceforge.net/picfinity/?rev=29&view=rev Author: espadav8 Date: 2007-08-12 13:06:30 -0700 (Sun, 12 Aug 2007) Log Message: ----------- Hopefully create the folders in the correct places so it can be tagged and branched Added Paths: ----------- branches/ tags/ trunk/ trunk/.themes/ trunk/.themes/ajax/ trunk/.themes/gallery/ trunk/gallery.dtd trunk/index.php Removed Paths: ------------- .themes/ gallery.dtd index.php trunk/.themes/ajax/ trunk/.themes/gallery/ Deleted: gallery.dtd =================================================================== --- gallery.dtd 2007-08-12 19:43:08 UTC (rev 28) +++ gallery.dtd 2007-08-12 20:06:30 UTC (rev 29) @@ -1,20 +0,0 @@ -<!ELEMENT layout (themes,folder*)> -<!ELEMENT folder (folder*,image*)> -<!ELEMENT themes (theme*)> -<!ELEMENT image EMPTY> -<!ELEMENT theme EMPTY> - -<!ATTLIST layout id ID #IMPLIED> -<!ATTLIST layout name CDATA #REQUIRED> - -<!ATTLIST folder id ID #IMPLIED> -<!ATTLIST folder name CDATA #REQUIRED> - -<!ATTLIST themes id ID #IMPLIED> -<!ATTLIST themes name CDATA #REQUIRED> - -<!ATTLIST theme id ID #IMPLIED> -<!ATTLIST theme name CDATA #REQUIRED> - -<!ATTLIST image id ID #IMPLIED> -<!ATTLIST image file CDATA #REQUIRED> \ No newline at end of file Deleted: index.php =================================================================== --- index.php 2007-08-12 19:43:08 UTC (rev 28) +++ index.php 2007-08-12 20:06:30 UTC (rev 29) @@ -1,378 +0,0 @@ -<?php - // site options - $site_name = "Picfinity"; - - // here we either get the theme posted in - // or if there's one stored in the cookie use that one - // otherwise use the default one - if ($_POST['theme']) - { - setcookie("theme", $_POST['theme']); - $theme = $_POST['theme']; - } - else if ($_COOKIE['theme']) - { - $theme = $_COOKIE['theme']; - } - else - { - // set the name of the default theme here - $theme = "ajax" ; - } - - if ($_GET['id']) - { - $post_id = $_GET['id']; - } - else - { - $post_id = 0; - } - - // create thumbnails for images that don't have one already - $create_thumbnails = true; - - // create a flat HTML version of the page - $create_html = false; - - // create the gallery.xml file (for use by themes - $create_xml = true; - - // use the PEAR module to create the XML - $use_pear = false; - - // Allow the users to change the theme - // this needs the PHP version of the page - $enable_themes = true; - - // thumbnail sizes - $thumbnail_width = 100; - $thumbnail_height = 100; - - // valid images to be shown - $valid_image_formats = array('png', 'gif', 'jpg', 'jpeg', 'bmp'); - - // get the layout of the current dir - $site_layout = create_folder_layout('.'); - - // create the XML of the layout - // if we're not using the PEAR module then the XML will have already been returned - if ($use_pear) - $xml = array_to_xml($site_layout); - else - $xml = $site_layout; - - // create the XML file if we've been told to - if ($create_xml) - { - $fh = fopen("gallery.xml", "w"); - fwrite($fh, $xml); - fclose($fh); - } - - // pass the XML to the theme and get the HTML back - $html = xml_to_xhtml($xml, ".themes/$theme/$theme.xsl", array('title' => $site_name, 'post_id' => $post_id)); - - // create the flat version if we need to - if ($create_html) - { - $fh = fopen("index.html", "w"); - fwrite($fh, $html); - fclose($fh); - } - - // echo the HTML to the screen - echo $html; - - // this function takes a folder path and creates a layout of the folder and sub folders - function create_folder_layout($folder) - { - global $valid_image_formats; - global $create_thumbnails; - global $use_pear; - global $enable_themes; - - // get the name of the folder or '' if it's the root - $name = substr($folder, strrpos($folder, '/') + 1); - - // create a folder ID - $folder_id = "id" . md5($folder); - - // add the folder to the Array (for use by the PEAR route) - $layout = array('name' => $name, 'id' => $folder_id); - - // create the non-PEAR XML - if ($name == "") - $folder_layout_xml = "<?xml version=\"1.0\"?>" - . "\n" - . "<!DOCTYPE layout PUBLIC \"-//picfinity//Gallery Layout//EN\" \"http://www.sunset-cigarette.co.uk/gallery/gallery.dtd\">" - . "\n" - . "<layout id=\"$folder_id\" name=\"\">\n"; - else - $folder_layout_xml = "<folder id=\"$folder_id\" name=\"$name\">\n"; - - // get a listing of the files/folder - $dh = opendir($folder); - while (false !== ($filename = readdir($dh))) { - $folder_contents[] = $filename; - } - - sort($folder_contents); - - // for each entry - while (list(,$folder_entry) = each($folder_contents)) - { - // if it's a folder and the path of it is ./.themes then create the list of themes - if ((is_dir($folder . '/' . $folder_entry)) && - (($folder . '/' . $folder_entry) == "./.themes") && - $enable_themes) - { - if ($use_pear) - $layout['themes'] = create_themes_layout(); - else - $folder_layout_xml .= create_themes_layout(); - } - - // else if it starts with a . ignore it - else if (strpos($folder_entry, '.') === 0) - { - continue; - } - - // if it's a directory and doesn't start with a . then create a folder layout for it - else if (is_dir($folder . '/' . $folder_entry)) - { - // get a list of it's files and check/create thumbnail(s) - if ($use_pear) - $layout['folder'][] = create_folder_layout($folder . '/' . $folder_entry); - else - $folder_layout_xml .= create_folder_layout($folder . '/' . $folder_entry); - } - - // otherwise check to see if it's an image - else - { - $ext = strtolower(substr($folder_entry, strrpos($folder_entry, '.') + 1)); - - if (in_array($ext, $valid_image_formats)) - { - // create a thumbnail if we've been told to - if ($create_thumbnails) - { - create_thumbnail($folder, $folder_entry, $ext); - } - $image_id = "id" . md5($folder . '/' . $folder_entry); - $layout['image'][] = array('id' => $image_id, 'file' => $folder_entry); - $folder_layout_xml .= "\t<image id=\"$image_id\" file=\"$folder_entry\" />\n"; - } - } - } - - // close up the hand-coded XML - if ($name == "") $folder_layout_xml .= "</layout>\n"; - else $folder_layout_xml .= "</folder>\n"; - - // return the correct layout (XML or Array) - if ($use_pear) return $layout; - else return $folder_layout_xml; - } - - function create_themes_layout() - { - global $use_pear; - - $themes_id = "id" . md5(".themes"); - - // create the themes node - $layout = array('name' => '.themes', 'id' => $themes_id); - $theme_xml = "<themes id=\"$themes_id\" name=\".themes\">\n"; - - // get the themes - $dh = opendir(".themes"); - while (false !== ($filename = readdir($dh))) { - $folder_contents[] = $filename; - } - - sort($folder_contents); - - // for each entry - while (list(,$folder_entry) = each($folder_contents)) - { - // if it's hidden ignore it - if (strpos($folder_entry, '.') === 0) - { - continue; - } - // otherwise if it's a dir assume it's a theme and add it to the list - else if (is_dir(".themes/" . $folder_entry)) - { - $theme_id = md5(".themes/" . $folder_entry); - $layout['theme'][] = array('name' => $folder_entry, 'id' => $theme_id); - $theme_xml .= "\t<theme id=\"$theme_id\" name=\"$folder_entry\" />\n"; - } - } - - $theme_xml .= "</themes>\n"; - - if ($use_pear) return $layout; - else return $theme_xml; - } - - function create_thumbnail($folder, $image, $ext) - { - global $thumbnail_width; - global $thumbnail_height; - - if (file_exists('.thumbs/'.$folder.'/'.$image)) - { - // if it already exists, do nothing - return; - } - if (!is_dir('.thumbs/'.$folder)) - { - MakeDirectory('.thumbs/'.$folder, 0777); - chmod('.thumbs/'.$folder, 0777); - } - - $src_img; - switch ($ext) - { - case 'png': - $src_img = imagecreatefrompng($folder.'/'.$image); - break; - case 'jpg': - case 'jpeg': - $src_img = imagecreatefromjpeg($folder.'/'.$image); - break; - case 'gif': - $src_img = imagecreatefromgif($folder.'/'.$image); - break; - case 'bmp': - $src_img = imagecreatefrombmp($folder.'/'.$image); - break; - default: - return; - break; - } - - $old_x = imageSX($src_img); - $old_y = imageSY($src_img); - - if ($old_x > $old_y) { - $thumb_w = $thumbnail_width; - $thumb_h = $old_y * ($thumbnail_height/$old_x); - } - else if ($old_x < $old_y) { - $thumb_w = $old_x * ($thumbnail_width/$old_y); - $thumb_h = $thumbnail_height; - } - else if ($old_x == $old_y) { - $thumb_w = $thumbnail_width; - $thumb_h = $thumbnail_height; - } - - $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h); - imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y); - - switch ($ext) - { - case 'png': - imagepg($dst_img, '.thumbs/'.$folder.'/'.$image); - break; - case 'jpg': - case 'jpeg': - imagejpeg($dst_img, '.thumbs/'.$folder.'/'.$image); - break; - case 'gif': - imagegif($dst_img, '.thumbs/'.$folder.'/'.$image); - break; - case 'bmp': - imagebmp($dst_img, '.thumbs/'.$folder.'/'.$image); - break; - } - - imagedestroy($dst_img); - imagedestroy($src_img); - - return; - } - - function array_to_xml(&$array, $tag_name = 'image', $headless = false) - { - error_reporting(E_ALL ^ E_NOTICE); - - // Include XML_Serializer - require_once 'XML/Serializer.php'; - - // An array of serializer options - $serializer_options = array ( - 'addDecl' => !$headless, - 'addDoctype' => true, - 'encoding' => 'ISO-8859-1', - 'indent' => ' ', - 'indentAttributes' => '_auto', - 'rootName' => 'layout', - 'defaultTagName' => $tag_name, - 'mode' => 'simplexml', - 'scalarAsAttributes' => true, - 'doctype' => array ( - 'id' => '-//picfinity//Gallery Layout//EN', - 'uri' => 'http://www.sunset-cigarette.co.uk/gallery/gallery.dtd' - ) - ); - - // Instantiate the serializer with the options - $Serializer = &new XML_Serializer($serializer_options); - - // Serialize the data structure - $status = $Serializer->serialize($array); - - // Check whether serialization worked - if (PEAR::isError($status)) { - die($status->getMessage()); - } - - // return the XML document - return $Serializer->getSerializedData(); - } - - function xml_to_xhtml($xml, $xsl_file, $params = array()) - { - $ver = explode( '.', PHP_VERSION ); - $ver_num = $ver[0] . $ver[1] . $ver[2]; - - if ( $ver_num < 500 ) - { - $arguments = array('/_xml' => $xml); - $xsltproc = xslt_create(); - $html = xslt_process($xsltproc, 'arg:/_xml', $xsl_file, NULL, $arguments); - - if (empty($html)) { - die('XSLT processing error: '. xslt_error($xsltproc)); - } - xslt_free($xsltproc); - return $html; - } - else - { - $doc = new DOMDocument(); - $xsl = new XSLTProcessor(); - - $doc->load($xsl_file); - $xsl->importStyleSheet($doc); - - $doc->loadXML($xml); - $xsl->setParameter('', $params); - - return $xsl->transformToXML($doc); - } - } - - function MakeDirectory($dir, $mode = 0755) - { - if (is_dir($dir) || @mkdir($dir,$mode)) return TRUE; - if (!MakeDirectory(dirname($dir),$mode)) return FALSE; - return @mkdir($dir,$mode); - } -?> - Copied: trunk/.themes (from rev 27, .themes) Copied: trunk/.themes/ajax (from rev 28, .themes/ajax) Copied: trunk/.themes/gallery (from rev 28, .themes/gallery) Copied: trunk/gallery.dtd (from rev 27, gallery.dtd) =================================================================== --- trunk/gallery.dtd (rev 0) +++ trunk/gallery.dtd 2007-08-12 20:06:30 UTC (rev 29) @@ -0,0 +1,20 @@ +<!ELEMENT layout (themes,folder*)> +<!ELEMENT folder (folder*,image*)> +<!ELEMENT themes (theme*)> +<!ELEMENT image EMPTY> +<!ELEMENT theme EMPTY> + +<!ATTLIST layout id ID #IMPLIED> +<!ATTLIST layout name CDATA #REQUIRED> + +<!ATTLIST folder id ID #IMPLIED> +<!ATTLIST folder name CDATA #REQUIRED> + +<!ATTLIST themes id ID #IMPLIED> +<!ATTLIST themes name CDATA #REQUIRED> + +<!ATTLIST theme id ID #IMPLIED> +<!ATTLIST theme name CDATA #REQUIRED> + +<!ATTLIST image id ID #IMPLIED> +<!ATTLIST image file CDATA #REQUIRED> \ No newline at end of file Copied: trunk/index.php (from rev 27, index.php) =================================================================== --- trunk/index.php (rev 0) +++ trunk/index.php 2007-08-12 20:06:30 UTC (rev 29) @@ -0,0 +1,378 @@ +<?php + // site options + $site_name = "Picfinity"; + + // here we either get the theme posted in + // or if there's one stored in the cookie use that one + // otherwise use the default one + if ($_POST['theme']) + { + setcookie("theme", $_POST['theme']); + $theme = $_POST['theme']; + } + else if ($_COOKIE['theme']) + { + $theme = $_COOKIE['theme']; + } + else + { + // set the name of the default theme here + $theme = "ajax" ; + } + + if ($_GET['id']) + { + $post_id = $_GET['id']; + } + else + { + $post_id = 0; + } + + // create thumbnails for images that don't have one already + $create_thumbnails = true; + + // create a flat HTML version of the page + $create_html = false; + + // create the gallery.xml file (for use by themes + $create_xml = true; + + // use the PEAR module to create the XML + $use_pear = false; + + // Allow the users to change the theme + // this needs the PHP version of the page + $enable_themes = true; + + // thumbnail sizes + $thumbnail_width = 100; + $thumbnail_height = 100; + + // valid images to be shown + $valid_image_formats = array('png', 'gif', 'jpg', 'jpeg', 'bmp'); + + // get the layout of the current dir + $site_layout = create_folder_layout('.'); + + // create the XML of the layout + // if we're not using the PEAR module then the XML will have already been returned + if ($use_pear) + $xml = array_to_xml($site_layout); + else + $xml = $site_layout; + + // create the XML file if we've been told to + if ($create_xml) + { + $fh = fopen("gallery.xml", "w"); + fwrite($fh, $xml); + fclose($fh); + } + + // pass the XML to the theme and get the HTML back + $html = xml_to_xhtml($xml, ".themes/$theme/$theme.xsl", array('title' => $site_name, 'post_id' => $post_id)); + + // create the flat version if we need to + if ($create_html) + { + $fh = fopen("index.html", "w"); + fwrite($fh, $html); + fclose($fh); + } + + // echo the HTML to the screen + echo $html; + + // this function takes a folder path and creates a layout of the folder and sub folders + function create_folder_layout($folder) + { + global $valid_image_formats; + global $create_thumbnails; + global $use_pear; + global $enable_themes; + + // get the name of the folder or '' if it's the root + $name = substr($folder, strrpos($folder, '/') + 1); + + // create a folder ID + $folder_id = "id" . md5($folder); + + // add the folder to the Array (for use by the PEAR route) + $layout = array('name' => $name, 'id' => $folder_id); + + // create the non-PEAR XML + if ($name == "") + $folder_layout_xml = "<?xml version=\"1.0\"?>" + . "\n" + . "<!DOCTYPE layout PUBLIC \"-//picfinity//Gallery Layout//EN\" \"http://www.sunset-cigarette.co.uk/gallery/gallery.dtd\">" + . "\n" + . "<layout id=\"$folder_id\" name=\"\">\n"; + else + $folder_layout_xml = "<folder id=\"$folder_id\" name=\"$name\">\n"; + + // get a listing of the files/folder + $dh = opendir($folder); + while (false !== ($filename = readdir($dh))) { + $folder_contents[] = $filename; + } + + sort($folder_contents); + + // for each entry + while (list(,$folder_entry) = each($folder_contents)) + { + // if it's a folder and the path of it is ./.themes then create the list of themes + if ((is_dir($folder . '/' . $folder_entry)) && + (($folder . '/' . $folder_entry) == "./.themes") && + $enable_themes) + { + if ($use_pear) + $layout['themes'] = create_themes_layout(); + else + $folder_layout_xml .= create_themes_layout(); + } + + // else if it starts with a . ignore it + else if (strpos($folder_entry, '.') === 0) + { + continue; + } + + // if it's a directory and doesn't start with a . then create a folder layout for it + else if (is_dir($folder . '/' . $folder_entry)) + { + // get a list of it's files and check/create thumbnail(s) + if ($use_pear) + $layout['folder'][] = create_folder_layout($folder . '/' . $folder_entry); + else + $folder_layout_xml .= create_folder_layout($folder . '/' . $folder_entry); + } + + // otherwise check to see if it's an image + else + { + $ext = strtolower(substr($folder_entry, strrpos($folder_entry, '.') + 1)); + + if (in_array($ext, $valid_image_formats)) + { + // create a thumbnail if we've been told to + if ($create_thumbnails) + { + create_thumbnail($folder, $folder_entry, $ext); + } + $image_id = "id" . md5($folder . '/' . $folder_entry); + $layout['image'][] = array('id' => $image_id, 'file' => $folder_entry); + $folder_layout_xml .= "\t<image id=\"$image_id\" file=\"$folder_entry\" />\n"; + } + } + } + + // close up the hand-coded XML + if ($name == "") $folder_layout_xml .= "</layout>\n"; + else $folder_layout_xml .= "</folder>\n"; + + // return the correct layout (XML or Array) + if ($use_pear) return $layout; + else return $folder_layout_xml; + } + + function create_themes_layout() + { + global $use_pear; + + $themes_id = "id" . md5(".themes"); + + // create the themes node + $layout = array('name' => '.themes', 'id' => $themes_id); + $theme_xml = "<themes id=\"$themes_id\" name=\".themes\">\n"; + + // get the themes + $dh = opendir(".themes"); + while (false !== ($filename = readdir($dh))) { + $folder_contents[] = $filename; + } + + sort($folder_contents); + + // for each entry + while (list(,$folder_entry) = each($folder_contents)) + { + // if it's hidden ignore it + if (strpos($folder_entry, '.') === 0) + { + continue; + } + // otherwise if it's a dir assume it's a theme and add it to the list + else if (is_dir(".themes/" . $folder_entry)) + { + $theme_id = md5(".themes/" . $folder_entry); + $layout['theme'][] = array('name' => $folder_entry, 'id' => $theme_id); + $theme_xml .= "\t<theme id=\"$theme_id\" name=\"$folder_entry\" />\n"; + } + } + + $theme_xml .= "</themes>\n"; + + if ($use_pear) return $layout; + else return $theme_xml; + } + + function create_thumbnail($folder, $image, $ext) + { + global $thumbnail_width; + global $thumbnail_height; + + if (file_exists('.thumbs/'.$folder.'/'.$image)) + { + // if it already exists, do nothing + return; + } + if (!is_dir('.thumbs/'.$folder)) + { + MakeDirectory('.thumbs/'.$folder, 0777); + chmod('.thumbs/'.$folder, 0777); + } + + $src_img; + switch ($ext) + { + case 'png': + $src_img = imagecreatefrompng($folder.'/'.$image); + break; + case 'jpg': + case 'jpeg': + $src_img = imagecreatefromjpeg($folder.'/'.$image); + break; + case 'gif': + $src_img = imagecreatefromgif($folder.'/'.$image); + break; + case 'bmp': + $src_img = imagecreatefrombmp($folder.'/'.$image); + break; + default: + return; + break; + } + + $old_x = imageSX($src_img); + $old_y = imageSY($src_img); + + if ($old_x > $old_y) { + $thumb_w = $thumbnail_width; + $thumb_h = $old_y * ($thumbnail_height/$old_x); + } + else if ($old_x < $old_y) { + $thumb_w = $old_x * ($thumbnail_width/$old_y); + $thumb_h = $thumbnail_height; + } + else if ($old_x == $old_y) { + $thumb_w = $thumbnail_width; + $thumb_h = $thumbnail_height; + } + + $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h); + imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y); + + switch ($ext) + { + case 'png': + imagepg($dst_img, '.thumbs/'.$folder.'/'.$image); + break; + case 'jpg': + case 'jpeg': + imagejpeg($dst_img, '.thumbs/'.$folder.'/'.$image); + break; + case 'gif': + imagegif($dst_img, '.thumbs/'.$folder.'/'.$image); + break; + case 'bmp': + imagebmp($dst_img, '.thumbs/'.$folder.'/'.$image); + break; + } + + imagedestroy($dst_img); + imagedestroy($src_img); + + return; + } + + function array_to_xml(&$array, $tag_name = 'image', $headless = false) + { + error_reporting(E_ALL ^ E_NOTICE); + + // Include XML_Serializer + require_once 'XML/Serializer.php'; + + // An array of serializer options + $serializer_options = array ( + 'addDecl' => !$headless, + 'addDoctype' => true, + 'encoding' => 'ISO-8859-1', + 'indent' => ' ', + 'indentAttributes' => '_auto', + 'rootName' => 'layout', + 'defaultTagName' => $tag_name, + 'mode' => 'simplexml', + 'scalarAsAttributes' => true, + 'doctype' => array ( + 'id' => '-//picfinity//Gallery Layout//EN', + 'uri' => 'http://www.sunset-cigarette.co.uk/gallery/gallery.dtd' + ) + ); + + // Instantiate the serializer with the options + $Serializer = &new XML_Serializer($serializer_options); + + // Serialize the data structure + $status = $Serializer->serialize($array); + + // Check whether serialization worked + if (PEAR::isError($status)) { + die($status->getMessage()); + } + + // return the XML document + return $Serializer->getSerializedData(); + } + + function xml_to_xhtml($xml, $xsl_file, $params = array()) + { + $ver = explode( '.', PHP_VERSION ); + $ver_num = $ver[0] . $ver[1] . $ver[2]; + + if ( $ver_num < 500 ) + { + $arguments = array('/_xml' => $xml); + $xsltproc = xslt_create(); + $html = xslt_process($xsltproc, 'arg:/_xml', $xsl_file, NULL, $arguments); + + if (empty($html)) { + die('XSLT processing error: '. xslt_error($xsltproc)); + } + xslt_free($xsltproc); + return $html; + } + else + { + $doc = new DOMDocument(); + $xsl = new XSLTProcessor(); + + $doc->load($xsl_file); + $xsl->importStyleSheet($doc); + + $doc->loadXML($xml); + $xsl->setParameter('', $params); + + return $xsl->transformToXML($doc); + } + } + + function MakeDirectory($dir, $mode = 0755) + { + if (is_dir($dir) || @mkdir($dir,$mode)) return TRUE; + if (!MakeDirectory(dirname($dir),$mode)) return FALSE; + return @mkdir($dir,$mode); + } +?> + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esp...@us...> - 2007-08-18 18:55:14
|
Revision: 45 http://picfinity.svn.sourceforge.net/picfinity/?rev=45&view=rev Author: espadav8 Date: 2007-08-18 11:55:16 -0700 (Sat, 18 Aug 2007) Log Message: ----------- Copy the ajax theme to db (and remove the background image from it) Import an empty gallery.xml file Added Paths: ----------- trunk/.themes/db/ trunk/gallery.xml Removed Paths: ------------- trunk/.themes/db/background.gif Copied: trunk/.themes/db (from rev 43, trunk/.themes/ajax) Deleted: trunk/.themes/db/background.gif =================================================================== (Binary files differ) Added: trunk/gallery.xml =================================================================== --- trunk/gallery.xml (rev 0) +++ trunk/gallery.xml 2007-08-18 18:55:16 UTC (rev 45) @@ -0,0 +1,4 @@ +<?xml version="1.0"?> +<!DOCTYPE layout PUBLIC "-//picfinity//Gallery Layout//EN" "http://www.espadav8.co.uk/gallery/gallery.dtd"> +<layout id="id5058f1af8388633f609cadb75a75dc9d" name=""> +</layout> Property changes on: trunk/gallery.xml ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esp...@us...> - 2007-08-18 20:36:08
|
Revision: 48 http://picfinity.svn.sourceforge.net/picfinity/?rev=48&view=rev Author: espadav8 Date: 2007-08-18 13:35:54 -0700 (Sat, 18 Aug 2007) Log Message: ----------- Add the first parts of the DB backend in (likely to change a fair bit) Modified Paths: -------------- trunk/index.php Added Paths: ----------- trunk/db.inc Added: trunk/db.inc =================================================================== --- trunk/db.inc (rev 0) +++ trunk/db.inc 2007-08-18 20:35:54 UTC (rev 48) @@ -0,0 +1,23 @@ +<?php + $db_host = "www.espadav8.co.uk"; + $db_user = "espadav8_picfin"; + $db_pass = "picfin_pass"; + $db_name = "espadav8_picfinity"; + + $db_connection = mysql_pconnect($db_host, $db_user, $db_pass); + + if (!$db_connection) + { + echo "Couldn't connect to the DB, disabling"; + die(); + } + else + { + $selected_table = mysql_select_db($db_name); + if (!$selected_table) + { + echo "Couldn't select table"; + die(); + } + } +?> Modified: trunk/index.php =================================================================== --- trunk/index.php 2007-08-18 20:34:19 UTC (rev 47) +++ trunk/index.php 2007-08-18 20:35:54 UTC (rev 48) @@ -1,14 +1,14 @@ <?php // site options $site_name = "Picfinity"; - + // here we either get the theme posted in // or if there's one stored in the cookie use that one // otherwise use the default one if ($_POST['theme']) { setcookie("theme", $_POST['theme']); - $theme = $_POST['theme']; + $theme = $_POST['theme']; } else if ($_COOKIE['theme']) { @@ -17,9 +17,9 @@ else { // set the name of the default theme here - $theme = "ajax" ; + $theme = "db" ; } - + if ($_GET['id']) { $post_id = $_GET['id']; @@ -28,40 +28,78 @@ { $post_id = 0; } - + // create thumbnails for images that don't have one already $create_thumbnails = true; - + // create a flat HTML version of the page $create_html = false; - + // create the gallery.xml file (for use by themes $create_xml = true; - + // use the PEAR module to create the XML $use_pear = false; - + // Allow the users to change the theme - // this needs the PHP version of the page + // this needs the PHP version of the page $enable_themes = true; - + // thumbnail sizes $thumbnail_width = 100; $thumbnail_height = 100; + // use the database + $use_db = true; + + if ($use_db) + { + require_once ('db.inc'); + if (!$db_connection) + { + $use_db = false; + } + else + { + if ($selected_table) + { + $result = mysql_query("SELECT image_md5 FROM images"); + if (!$result) + { + echo 'Invalid query: ' . mysql_error() . "\n"; + echo 'Whole query: ' . $query; + $use_db = false; + } + else + { + $current_images = array(); + while ($row = mysql_fetch_row($result)) + { + $current_images[] = $row[0]; + } + mysql_free_result($result); + } + } + else + { + $use_db = false; + } + } + } + // valid images to be shown $valid_image_formats = array('png', 'gif', 'jpg', 'jpeg', 'bmp'); - + // get the layout of the current dir $site_layout = create_folder_layout('.'); - + // create the XML of the layout // if we're not using the PEAR module then the XML will have already been returned if ($use_pear) $xml = array_to_xml($site_layout); else $xml = $site_layout; - + // create the XML file if we've been told to if ($create_xml) { @@ -69,10 +107,10 @@ fwrite($fh, $xml); fclose($fh); } - + // pass the XML to the theme and get the HTML back $html = xml_to_xhtml($xml, ".themes/$theme/$theme.xsl", array('title' => $site_name, 'post_id' => $post_id)); - + // create the flat version if we need to if ($create_html) { @@ -80,27 +118,29 @@ fwrite($fh, $html); fclose($fh); } - + + if ($use_db) + { + mysql_close($db_connection); + } + // echo the HTML to the screen echo $html; - + // this function takes a folder path and creates a layout of the folder and sub folders function create_folder_layout($folder) { - global $valid_image_formats; - global $create_thumbnails; - global $use_pear; - global $enable_themes; - + global $valid_image_formats, $create_thumbnails, $use_pear, $enable_themes, $use_db, $current_images; + // get the name of the folder or '' if it's the root $name = substr($folder, strrpos($folder, '/') + 1); - + // create a folder ID $folder_id = "id" . md5($folder); - + // add the folder to the Array (for use by the PEAR route) $layout = array('name' => $name, 'id' => $folder_id); - + // create the non-PEAR XML if ($name == "") $folder_layout_xml = "<?xml version=\"1.0\"?>" @@ -110,15 +150,15 @@ . "<layout id=\"$folder_id\" name=\"\">\n"; else $folder_layout_xml = "<folder id=\"$folder_id\" name=\"$name\">\n"; - + // get a listing of the files/folder $dh = opendir($folder); while (false !== ($filename = readdir($dh))) { $folder_contents[] = $filename; } - + sort($folder_contents); - + // for each entry while (list(,$folder_entry) = each($folder_contents)) { @@ -132,13 +172,13 @@ else $folder_layout_xml .= create_themes_layout(); } - + // else if it starts with a . ignore it else if (strpos($folder_entry, '.') === 0) { continue; } - + // if it's a directory and doesn't start with a . then create a folder layout for it else if (is_dir($folder . '/' . $folder_entry)) { @@ -148,12 +188,12 @@ else $folder_layout_xml .= create_folder_layout($folder . '/' . $folder_entry); } - + // otherwise check to see if it's an image else { $ext = strtolower(substr($folder_entry, strrpos($folder_entry, '.') + 1)); - + if (in_array($ext, $valid_image_formats)) { // create a thumbnail if we've been told to @@ -164,37 +204,47 @@ $image_id = "id" . md5($folder . '/' . $folder_entry); $layout['image'][] = array('id' => $image_id, 'file' => $folder_entry); $folder_layout_xml .= "\t<image id=\"$image_id\" file=\"$folder_entry\" />\n"; + + if (($use_db) && (!in_array($image_id, $current_images))) + { + $query = "INSERT INTO images (image_md5) VALUES ('$image_id')"; + $result = mysql_query($query); + if (!$result) + { + die (mysql_error()); + } + } } } } - + // close up the hand-coded XML if ($name == "") $folder_layout_xml .= "</layout>\n"; else $folder_layout_xml .= "</folder>\n"; - + // return the correct layout (XML or Array) if ($use_pear) return $layout; else return $folder_layout_xml; } - + function create_themes_layout() { global $use_pear; - + $themes_id = "id" . md5(".themes"); - + // create the themes node $layout = array('name' => '.themes', 'id' => $themes_id); $theme_xml = "<themes id=\"$themes_id\" name=\".themes\">\n"; - + // get the themes $dh = opendir(".themes"); while (false !== ($filename = readdir($dh))) { $folder_contents[] = $filename; } - + sort($folder_contents); - + // for each entry while (list(,$folder_entry) = each($folder_contents)) { @@ -203,7 +253,7 @@ { continue; } - // otherwise if it's a dir assume it's a theme and add it to the list + // otherwise if it's a dir assume it's a theme and add it to the list else if (is_dir(".themes/" . $folder_entry)) { $theme_id = md5(".themes/" . $folder_entry); @@ -211,24 +261,24 @@ $theme_xml .= "\t<theme id=\"$theme_id\" name=\"$folder_entry\" />\n"; } } - + $theme_xml .= "</themes>\n"; - + if ($use_pear) return $layout; else return $theme_xml; } - + function create_thumbnail($folder, $image, $ext) { global $thumbnail_width; global $thumbnail_height; - + if (!is_dir('.thumbs/'.$folder)) { MakeDirectory('.thumbs/'.$folder, 0777); chmod('.thumbs/'.$folder, 0777); } - + $src_img; switch ($ext) { @@ -249,10 +299,10 @@ return; break; } - + $old_x = imageSX($src_img); $old_y = imageSY($src_img); - + if ($old_x > $old_y) { $thumb_w = $thumbnail_width; $thumb_h = $old_y * ($thumbnail_height/$old_x); @@ -265,10 +315,10 @@ $thumb_w = $thumbnail_width; $thumb_h = $thumbnail_height; } - + $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h); imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $old_x, $old_y); - + switch ($ext) { case 'png': @@ -285,13 +335,13 @@ imagebmp($dst_img, '.thumbs/'.$folder.'/'.$image); break; } - + imagedestroy($dst_img); imagedestroy($src_img); - + return; } - + function array_to_xml(&$array, $tag_name = 'image', $headless = false) { error_reporting(E_ALL ^ E_NOTICE); @@ -330,7 +380,7 @@ // return the XML document return $Serializer->getSerializedData(); } - + function xml_to_xhtml($xml, $xsl_file, $params = array()) { $ver = explode( '.', PHP_VERSION ); @@ -362,7 +412,7 @@ return $xsl->transformToXML($doc); } } - + function MakeDirectory($dir, $mode = 0755) { if (is_dir($dir) || @mkdir($dir,$mode)) return TRUE; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esp...@us...> - 2007-08-26 11:13:34
|
Revision: 54 http://picfinity.svn.sourceforge.net/picfinity/?rev=54&view=rev Author: espadav8 Date: 2007-08-25 03:04:59 -0700 (Sat, 25 Aug 2007) Log Message: ----------- Remove the use of a PEAR module to create the XML, it complicated things more than needed Add any comments to the image xml if an id was passed in Update the dtd to show this (and correct an error with the themes entry) Modified Paths: -------------- trunk/gallery.dtd trunk/index.php Modified: trunk/gallery.dtd =================================================================== --- trunk/gallery.dtd 2007-08-19 11:55:45 UTC (rev 53) +++ trunk/gallery.dtd 2007-08-25 10:04:59 UTC (rev 54) @@ -1,9 +1,17 @@ -<!ELEMENT layout (themes,folder*)> +<!ELEMENT layout (themes?,folder*)> <!ELEMENT folder (folder*,image*)> <!ELEMENT themes (theme*)> -<!ELEMENT image EMPTY> +<!ELEMENT image (comment*)> <!ELEMENT theme EMPTY> +<!ELEMENT comment (name,www,email,comment_text,rating,added)> +<!ELEMENT name (#CDATA)> +<!ELEMENT www (#CDATA)> +<!ELEMENT email (#CDATA)> +<!ELEMENT comment_text (#CDATA)> +<!ELEMENT rating (#CDATA)> +<!ELEMENT added (#CDATA)> + <!ATTLIST layout id ID #IMPLIED> <!ATTLIST layout name CDATA #REQUIRED> @@ -17,4 +25,4 @@ <!ATTLIST theme name CDATA #REQUIRED> <!ATTLIST image id ID #IMPLIED> -<!ATTLIST image file CDATA #REQUIRED> \ No newline at end of file +<!ATTLIST image file CDATA #REQUIRED> Modified: trunk/index.php =================================================================== --- trunk/index.php 2007-08-19 11:55:45 UTC (rev 53) +++ trunk/index.php 2007-08-25 10:04:59 UTC (rev 54) @@ -38,9 +38,6 @@ // create the gallery.xml file (for use by themes $create_xml = true; - // use the PEAR module to create the XML - $use_pear = false; - // Allow the users to change the theme // this needs the PHP version of the page $enable_themes = true; @@ -91,25 +88,18 @@ $valid_image_formats = array('png', 'gif', 'jpg', 'jpeg', 'bmp'); // get the layout of the current dir - $site_layout = create_folder_layout('.'); + $site_layout_xml = create_folder_layout('.'); - // create the XML of the layout - // if we're not using the PEAR module then the XML will have already been returned - if ($use_pear) - $xml = array_to_xml($site_layout); - else - $xml = $site_layout; - // create the XML file if we've been told to if ($create_xml) { $fh = fopen("gallery.xml", "w"); - fwrite($fh, $xml); + fwrite($fh, $site_layout_xml); fclose($fh); } // pass the XML to the theme and get the HTML back - $html = xml_to_xhtml($xml, ".themes/$theme/$theme.xsl", array('title' => $site_name, 'post_id' => $post_id)); + $html = xml_to_xhtml($site_layout_xml, ".themes/$theme/$theme.xsl", array('title' => $site_name, 'post_id' => $post_id)); // create the flat version if we need to if ($create_html) @@ -127,10 +117,11 @@ // echo the HTML to the screen echo $html; + // this function takes a folder path and creates a layout of the folder and sub folders function create_folder_layout($folder) { - global $valid_image_formats, $create_thumbnails, $use_pear, $enable_themes, $use_db, $current_images; + global $valid_image_formats, $create_thumbnails, $enable_themes, $use_db, $current_images, $post_id; // get the name of the folder or '' if it's the root $name = substr($folder, strrpos($folder, '/') + 1); @@ -138,15 +129,10 @@ // create a folder ID $folder_id = "id" . md5($folder); - // add the folder to the Array (for use by the PEAR route) - $layout = array('name' => $name, 'id' => $folder_id); - - // create the non-PEAR XML + // create the XML if ($name == "") - $folder_layout_xml = "<?xml version=\"1.0\"?>" - . "\n" - . "<!DOCTYPE layout PUBLIC \"-//picfinity//Gallery Layout//EN\" \"http://www.espadav8.co.uk/gallery/gallery.dtd\">" - . "\n" + $folder_layout_xml = "<?xml version=\"1.0\"?>\n" + . "<!DOCTYPE layout PUBLIC \"-//picfinity//Gallery Layout//EN\" \"http://www.espadav8.co.uk/gallery/gallery.dtd\">\n" . "<layout id=\"$folder_id\" name=\"\">\n"; else $folder_layout_xml = "<folder id=\"$folder_id\" name=\"$name\">\n"; @@ -162,15 +148,12 @@ // for each entry while (list(,$folder_entry) = each($folder_contents)) { - // if it's a folder and the path of it is ./.themes then create the list of themes + // if it's a folder and the path of it is ./.themes then create the list of themes if ((($folder . '/' . $folder_entry) == "./.themes") && (is_dir('./themes')) && $enable_themes) { - if ($use_pear) - $layout['themes'] = create_themes_layout(); - else - $folder_layout_xml .= create_themes_layout(); + $folder_layout_xml .= create_themes_layout(); } // else if it starts with a . ignore it @@ -183,10 +166,7 @@ else if (is_dir($folder . '/' . $folder_entry)) { // get a list of it's files and check/create thumbnail(s) - if ($use_pear) - $layout['folder'][] = create_folder_layout($folder . '/' . $folder_entry); - else - $folder_layout_xml .= create_folder_layout($folder . '/' . $folder_entry); + $folder_layout_xml .= create_folder_layout($folder . '/' . $folder_entry); } // otherwise check to see if it's an image @@ -201,45 +181,96 @@ { create_thumbnail($folder, $folder_entry, $ext); } + $image_id = "id" . md5($folder . '/' . $folder_entry); - $layout['image'][] = array('id' => $image_id, 'file' => $folder_entry); - $folder_layout_xml .= "\t<image id=\"$image_id\" file=\"$folder_entry\" />\n"; - if (($use_db) && (!in_array($image_id, $current_images))) + if (!in_array($image_id, $current_images)) { - $query = "INSERT INTO images (image_md5) VALUES ('$image_id')"; - $result = mysql_query($query); - if (!$result) - { - die (mysql_error()); - } + add_image_to_db($image_id); } + + if (($use_db) && ($image_id == $post_id)) + { + $folder_layout_xml .= "\t<image id=\"$image_id\" file=\"$folder_entry\">\n" + . get_comments($image_id) + . "\t</image>\n"; + } + else + { + $folder_layout_xml .= "\t<image id=\"$image_id\" file=\"$folder_entry\" />\n"; + } } } } - // close up the hand-coded XML + // close up the XML if ($name == "") $folder_layout_xml .= "</layout>\n"; else $folder_layout_xml .= "</folder>\n"; - // return the correct layout (XML or Array) - if ($use_pear) return $layout; - else return $folder_layout_xml; + // return the XML + return $folder_layout_xml; } - function create_themes_layout() + function add_image_to_db($image_id) { - global $use_pear; + $query = "INSERT INTO images (image_md5) VALUES ('$image_id')"; + $result = mysql_query($query); + if (!$result) + { + // die (mysql_error()); + } + } + function get_comments($image_id) + { + $query = " + SELECT user_name + , user_www + , user_email + , user_comment + , comment_rating + , date_added + FROM comments + INNER JOIN images + WHERE images.image_id = comments.image_id + AND images.image_md5 = '$image_id' + ORDER BY date_added DESC"; + + $result = mysql_query($query); + + if (mysql_num_rows($result) > 0) + { + while ($row = mysql_fetch_assoc($result)) + { + $comments_xml .= "<comment>" + . "<name>$row[user_name]</name>" + . "<www>$row[user_www]</www>" + . "<email>$row[user_email]</email>" + . "<comment_text>$row[user_comment]</comment_text>" + . "<rating>$row[comment_rating]</rating>" + . "<added>$row[date_added]</added>" + . "</comment>"; + } + + return $comments_xml; + } + else + { + return ""; + } + } + + function create_themes_layout() + { $themes_id = "id" . md5(".themes"); // create the themes node - $layout = array('name' => '.themes', 'id' => $themes_id); $theme_xml = "<themes id=\"$themes_id\" name=\".themes\">\n"; // get the themes $dh = opendir(".themes"); - while (false !== ($filename = readdir($dh))) { + while (false !== ($filename = readdir($dh))) + { $folder_contents[] = $filename; } @@ -257,15 +288,13 @@ else if (is_dir(".themes/" . $folder_entry)) { $theme_id = md5(".themes/" . $folder_entry); - $layout['theme'][] = array('name' => $folder_entry, 'id' => $theme_id); $theme_xml .= "\t<theme id=\"$theme_id\" name=\"$folder_entry\" />\n"; } } $theme_xml .= "</themes>\n"; - if ($use_pear) return $layout; - else return $theme_xml; + return $theme_xml; } function create_thumbnail($folder, $image, $ext) @@ -303,15 +332,18 @@ $old_x = imageSX($src_img); $old_y = imageSY($src_img); - if ($old_x > $old_y) { + if ($old_x > $old_y) + { $thumb_w = $thumbnail_width; $thumb_h = $old_y * ($thumbnail_height/$old_x); } - else if ($old_x < $old_y) { + else if ($old_x < $old_y) + { $thumb_w = $old_x * ($thumbnail_width/$old_y); $thumb_h = $thumbnail_height; } - else if ($old_x == $old_y) { + else if ($old_x == $old_y) + { $thumb_w = $thumbnail_width; $thumb_h = $thumbnail_height; } @@ -342,45 +374,6 @@ return; } - function array_to_xml(&$array, $tag_name = 'image', $headless = false) - { - error_reporting(E_ALL ^ E_NOTICE); - - // Include XML_Serializer - require_once 'XML/Serializer.php'; - - // An array of serializer options - $serializer_options = array ( - 'addDecl' => !$headless, - 'addDoctype' => true, - 'encoding' => 'ISO-8859-1', - 'indent' => ' ', - 'indentAttributes' => '_auto', - 'rootName' => 'layout', - 'defaultTagName' => $tag_name, - 'mode' => 'simplexml', - 'scalarAsAttributes' => true, - 'doctype' => array ( - 'id' => '-//picfinity//Gallery Layout//EN', - 'uri' => 'http://www.espadav8.co.uk/gallery/gallery.dtd' - ) - ); - - // Instantiate the serializer with the options - $Serializer = &new XML_Serializer($serializer_options); - - // Serialize the data structure - $status = $Serializer->serialize($array); - - // Check whether serialization worked - if (PEAR::isError($status)) { - die($status->getMessage()); - } - - // return the XML document - return $Serializer->getSerializedData(); - } - function xml_to_xhtml($xml, $xsl_file, $params = array()) { $ver = explode( '.', PHP_VERSION ); @@ -390,7 +383,7 @@ { $arguments = array('/_xml' => $xml); $xsltproc = xslt_create(); - $html = xslt_process($xsltproc, 'arg:/_xml', $xsl_file, NULL, $arguments); + $html = xslt_process($xsltproc, 'arg:/_xml', $xsl_file, NULL, $arguments); if (empty($html)) { die('XSLT processing error: '. xslt_error($xsltproc)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esp...@us...> - 2007-08-12 20:07:39
|
Revision: 30 http://picfinity.svn.sourceforge.net/picfinity/?rev=30&view=rev Author: espadav8 Date: 2007-08-12 13:07:42 -0700 (Sun, 12 Aug 2007) Log Message: ----------- Missed these 2 files Added Paths: ----------- trunk/.project trunk/.projectOptions Removed Paths: ------------- .project .projectOptions Deleted: .project =================================================================== --- .project 2007-08-12 20:06:30 UTC (rev 29) +++ .project 2007-08-12 20:07:42 UTC (rev 30) @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<projectDescription> - <name>picfinity</name> - <comment></comment> - <projects> - </projects> - <buildSpec> - <buildCommand> - <name>org.eclipse.php.core.PhpIncrementalProjectBuilder</name> - <arguments> - </arguments> - </buildCommand> - <buildCommand> - <name>org.eclipse.wst.validation.validationbuilder</name> - <arguments> - </arguments> - </buildCommand> - </buildSpec> - <natures> - <nature>org.eclipse.php.core.PHPNature</nature> - </natures> -</projectDescription> Deleted: .projectOptions =================================================================== --- .projectOptions 2007-08-12 20:06:30 UTC (rev 29) +++ .projectOptions 2007-08-12 20:07:42 UTC (rev 30) @@ -1,9 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<phpProjectOptions> - <projectOption name="org.eclipse.php.core.contextRoot"> - </projectOption> - <projectOption name="org.eclipse.php.core.defaultEncoding"> - </projectOption> - <includepath> - </includepath> -</phpProjectOptions> Copied: trunk/.project (from rev 28, .project) =================================================================== --- trunk/.project (rev 0) +++ trunk/.project 2007-08-12 20:07:42 UTC (rev 30) @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>picfinity</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.php.core.PhpIncrementalProjectBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.wst.validation.validationbuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.php.core.PHPNature</nature> + </natures> +</projectDescription> Copied: trunk/.projectOptions (from rev 28, .projectOptions) =================================================================== --- trunk/.projectOptions (rev 0) +++ trunk/.projectOptions 2007-08-12 20:07:42 UTC (rev 30) @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8"?> +<phpProjectOptions> + <projectOption name="org.eclipse.php.core.contextRoot"> + </projectOption> + <projectOption name="org.eclipse.php.core.defaultEncoding"> + </projectOption> + <includepath> + </includepath> +</phpProjectOptions> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |