Thread: [Picfinity-commit] SF.net SVN: picfinity: [9] index.php
Status: Beta
Brought to you by:
espadav8
From: <esp...@us...> - 2007-07-19 00:52:19
|
Revision: 9 http://picfinity.svn.sourceforge.net/picfinity/?rev=9&view=rev Author: espadav8 Date: 2007-07-18 17:52:19 -0700 (Wed, 18 Jul 2007) Log Message: ----------- Little clean up and add the doctype to the XML Modified Paths: -------------- index.php Modified: index.php =================================================================== --- index.php 2007-07-19 00:51:22 UTC (rev 8) +++ index.php 2007-07-19 00:52:19 UTC (rev 9) @@ -1,7 +1,7 @@ <?php // site options - $site_name = "Andrew's Gallery"; + $site_name = "Picfinity"; $theme = ($_GET['theme'] != '') ? $_GET['theme'] : "ajax" ; // not implemented yet @@ -33,7 +33,7 @@ echo $html; - // echo "<div style=\"display:none;\">$xml</div>"; + echo "<div style=\"display:none;\">$xml</div>"; function create_folder_layout($folder) @@ -44,8 +44,7 @@ // 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); + $layout = array('name' => $name, 'id' => uniqid('id')); // for each entry while (list(,$folder_entry) = each($folder_contents)) @@ -59,7 +58,6 @@ { // 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 @@ -169,14 +167,18 @@ // 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 - + '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 @@ -189,8 +191,6 @@ if (PEAR::isError($status)) { die($status->getMessage()); } - - // print_r($Serializer->options); // return the XML document return $Serializer->getSerializedData(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esp...@us...> - 2007-07-29 10:56:41
|
Revision: 15 http://picfinity.svn.sourceforge.net/picfinity/?rev=15&view=rev Author: espadav8 Date: 2007-07-29 03:54:19 -0700 (Sun, 29 Jul 2007) Log Message: ----------- Add lots of comments to the file Add the option of using the XML_Seralizer PEAR module or not Make thumbnail_width, _height set with the other options Modified Paths: -------------- index.php Modified: index.php =================================================================== --- index.php 2007-07-29 10:50:51 UTC (rev 14) +++ index.php 2007-07-29 10:54:19 UTC (rev 15) @@ -2,14 +2,28 @@ // site options $site_name = "Picfinity"; + + // use the default theme or get the one passed in $theme = ($_GET['theme'] != '') ? $_GET['theme'] : "ajax" ; // not implemented yet $max_folders = 0; // 0 = unlimited - + + // create thumbnails for images that don't have one already $create_thumbnails = true; + + // create a flat HTML version of the page $create_html = true; + + // create the gallery.xml file (for use by themes $create_xml = true; + + // use the PEAR module to create the XML + $use_pear = false; + + // thumbnail sizes + $thumbnail_width = 100; + $thumbnail_height = 100; // valid images to be shown $valid_image_formats = array('png', 'gif', 'jpg', 'jpeg', 'bmp'); @@ -17,99 +31,154 @@ // get the layout of the current dir $site_layout = create_folder_layout('.'); - $xml = array_to_xml($site_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) - { file_put_contents("gallery.xml", $xml); - } + // pass the XML to the theme and get the HTML back $html = xml_to_xhtml($xml, ".themes/$theme/$theme.xsl", array('title' => $site_name)); - if ($create_html) - { - file_put_contents("index.html", $html); - } + // create the flat version if we need to + if ($create_html) file_put_contents("index.html", $html); + // echo the HTML to the screen echo $html; - echo "<div style=\"display:none;\">$xml</div>"; - - + // 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; + // get the name of the folder or '' if it's the root + $name = substr($folder, strrpos($folder, '/') + 1); + + // create a folder ID + $folder_id = uniqid('id'); + + // 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 $folder_contents = scandir($folder); - $name = substr($folder, strrpos($folder, '/') + 1); - $layout = array('name' => $name, 'id' => uniqid('id')); // 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")) { - $layout['themes'] = create_themes_layout(); + 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) { - // this is a hidden file/folder, ignore continue; } - // if it's a directory and doesn't start with a . + + // 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) - $sub_layout = create_folder_layout($folder . '/' . $folder_entry); - $layout['folder'][] = $sub_layout; + 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 { - // 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)) { + // create a thumbnail if we've been told to if ($create_thumbnails) { - // create a thumbnail create_thumbnail($folder, $folder_entry, $ext); } - $layout['image'][] = array('id' => uniqid('id'), 'file' => $folder_entry); + $image_id = uniqid('id'); + $layout['image'][] = array('id' => $image_id, 'file' => $folder_entry); + $folder_layout_xml .= "\t<image id=\"$image_id\" file=\"$folder_entry\" />\n"; } } } - return $layout; + // 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 = uniqid('id'); + + // create the themes node + $theme_xml = "<themes id=\"$themes_id\" name=\".themes\">\n"; + $layout = array('name' => '.themes', 'id' => $themes_id); + + // get the themes $folder_contents = scandir(".themes"); - $layout = array('name' => '.themes', 'id' => uniqid('id')); // 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)) { - $layout['theme'][] = array('name' => $folder_entry, 'id' => uniqid('id')); + $theme_id = uniqid('id'); + $layout['theme'][] = array('name' => $folder_entry, 'id' => $theme_id); + $theme_xml .= "\t<theme id=\"$theme_id\" name=\"$folder_entry\" />\n"; } } - return $layout; + $theme_xml .= "</themes>\n"; + echo $theme_xml; + + 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)) { mkdir('.thumbs/'.$folder, 0777, TRUE); @@ -138,25 +207,25 @@ case 'bmp': $src_img = imagecreatefrombmp($folder.'/'.$image); break; + default: + return; + 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); + $thumb_w = $thumbnail_width; + $thumb_h = $old_y * ($thumbnail_height/$old_x); } else if ($old_x < $old_y) { - $thumb_w = $old_x * ($new_w/$old_y); - $thumb_h = $new_h; + $thumb_w = $old_x * ($thumbnail_width/$old_y); + $thumb_h = $thumbnail_height; } else if ($old_x == $old_y) { - $thumb_w = $new_w; - $thumb_h = $new_h; + $thumb_w = $thumbnail_width; + $thumb_h = $thumbnail_height; } $dst_img = ImageCreateTrueColor($thumb_w, $thumb_h); @@ -235,8 +304,7 @@ $xsl->setParameter('', $params); - $html = $xsl->transformToXML($doc); + return $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-08 14:34:50
|
Revision: 16 http://picfinity.svn.sourceforge.net/picfinity/?rev=16&view=rev Author: espadav8 Date: 2007-08-08 07:34:48 -0700 (Wed, 08 Aug 2007) Log Message: ----------- Add the ability to store the selected theme in a cookie Can disable the .themes folder being scanned and thus removing the option to change the theme Allow an ID to be sent and passed to the XML, should allow 'link to image' in themes IDs for items are now the md5 of the path to the item, this way the ID will always be the same for a given file path Changed the scandir() to a PHP4 friendly version Changed mkdir() to the PHP4 version which doesn't allow recursive creation Get the ext of a file in lowercase since JPG and jpg are the same, they would've been missed before Modified Paths: -------------- index.php Modified: index.php =================================================================== --- index.php 2007-07-29 10:54:19 UTC (rev 15) +++ index.php 2007-08-08 14:34:48 UTC (rev 16) @@ -3,9 +3,33 @@ // site options $site_name = "Picfinity"; - // use the default theme or get the one passed in - $theme = ($_GET['theme'] != '') ? $_GET['theme'] : "ajax" ; + // 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; + } + // not implemented yet $max_folders = 0; // 0 = unlimited @@ -21,6 +45,10 @@ // 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; @@ -39,11 +67,10 @@ $xml = $site_layout; // create the XML file if we've been told to - if ($create_xml) - file_put_contents("gallery.xml", $xml); + if ($create_xml) file_put_contents("gallery.xml", $xml); // pass the XML to the theme and get the HTML back - $html = xml_to_xhtml($xml, ".themes/$theme/$theme.xsl", array('title' => $site_name)); + $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) file_put_contents("index.html", $html); @@ -57,12 +84,13 @@ 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 = uniqid('id'); + $folder_id = md5($folder); // add the folder to the Array (for use by the PEAR route) $layout = array('name' => $name, 'id' => $folder_id); @@ -78,14 +106,20 @@ $folder_layout_xml = "<folder id=\"$folder_id\" name=\"$name\">\n"; // get a listing of the files/folder - $folder_contents = scandir($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")) + (($folder . '/' . $folder_entry) == "./.themes") && + $enable_themes) { if ($use_pear) $layout['themes'] = create_themes_layout(); @@ -112,7 +146,7 @@ // otherwise check to see if it's an image else { - $ext = substr($folder_entry, strrpos($folder_entry, '.') + 1); + $ext = strtolower(substr($folder_entry, strrpos($folder_entry, '.') + 1)); if (in_array($ext, $valid_image_formats)) { @@ -121,7 +155,7 @@ { create_thumbnail($folder, $folder_entry, $ext); } - $image_id = uniqid('id'); + $image_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"; } @@ -141,15 +175,20 @@ { global $use_pear; - $themes_id = uniqid('id'); + $themes_id = md5(".themes"); // create the themes node + $layout = array('name' => '.themes', 'id' => $themes_id); $theme_xml = "<themes id=\"$themes_id\" name=\".themes\">\n"; - $layout = array('name' => '.themes', 'id' => $themes_id); // get the themes - $folder_contents = scandir(".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)) { @@ -161,14 +200,13 @@ // 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 = uniqid('id'); + $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"; - echo $theme_xml; if ($use_pear) return $layout; else return $theme_xml; @@ -181,7 +219,7 @@ if (!is_dir('.thumbs/'.$folder)) { - mkdir('.thumbs/'.$folder, 0777, TRUE); + MakeDirectory('.thumbs/'.$folder, 0777); chmod('.thumbs/'.$folder, 0777); } if (file_exists('.thumbs/'.$folder.'/'.$image)) @@ -306,5 +344,12 @@ 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-09 11:13:16
|
Revision: 20 http://picfinity.svn.sourceforge.net/picfinity/?rev=20&view=rev Author: espadav8 Date: 2007-08-09 04:13:16 -0700 (Thu, 09 Aug 2007) Log Message: ----------- All ids in XHTML should start with a letter, to ensure this prepend 'id' to the md5 Modified Paths: -------------- index.php Modified: index.php =================================================================== --- index.php 2007-08-08 23:54:15 UTC (rev 19) +++ index.php 2007-08-09 11:13:16 UTC (rev 20) @@ -1,5 +1,4 @@ <?php - // site options $site_name = "Picfinity"; @@ -37,7 +36,7 @@ $create_thumbnails = true; // create a flat HTML version of the page - $create_html = true; + $create_html = false; // create the gallery.xml file (for use by themes $create_xml = true; @@ -90,7 +89,7 @@ $name = substr($folder, strrpos($folder, '/') + 1); // create a folder ID - $folder_id = md5($folder); + $folder_id = "id" . md5($folder); // add the folder to the Array (for use by the PEAR route) $layout = array('name' => $name, 'id' => $folder_id); @@ -155,7 +154,7 @@ { create_thumbnail($folder, $folder_entry, $ext); } - $image_id = md5($folder . '/' . $folder_entry); + $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"; } @@ -175,7 +174,7 @@ { global $use_pear; - $themes_id = md5(".themes"); + $themes_id = "id" . md5(".themes"); // create the themes node $layout = array('name' => '.themes', 'id' => $themes_id); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esp...@us...> - 2007-08-09 12:45:41
|
Revision: 23 http://picfinity.svn.sourceforge.net/picfinity/?rev=23&view=rev Author: espadav8 Date: 2007-08-09 05:44:59 -0700 (Thu, 09 Aug 2007) Log Message: ----------- Remove the use of put_file_contents Modified Paths: -------------- index.php Modified: index.php =================================================================== --- index.php 2007-08-09 11:18:11 UTC (rev 22) +++ index.php 2007-08-09 12:44:59 UTC (rev 23) @@ -66,13 +66,23 @@ $xml = $site_layout; // create the XML file if we've been told to - if ($create_xml) file_put_contents("gallery.xml", $xml); + 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) file_put_contents("index.html", $html); + if ($create_html) + { + $fh = fopen("index.html", "w"); + fwrite($fh, $html); + fclose($fh); + } // echo the HTML to the screen echo $html; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esp...@us...> - 2007-08-09 18:24:08
|
Revision: 24 http://picfinity.svn.sourceforge.net/picfinity/?rev=24&view=rev Author: espadav8 Date: 2007-08-09 11:24:11 -0700 (Thu, 09 Aug 2007) Log Message: ----------- Change the checking order for thumbnails (check for the file first, then check/create the folder) Modified Paths: -------------- index.php Modified: index.php =================================================================== --- index.php 2007-08-09 12:44:59 UTC (rev 23) +++ index.php 2007-08-09 18:24:11 UTC (rev 24) @@ -29,9 +29,6 @@ $post_id = 0; } - // not implemented yet - $max_folders = 0; // 0 = unlimited - // create thumbnails for images that don't have one already $create_thumbnails = true; @@ -226,78 +223,78 @@ 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); } - if (file_exists('.thumbs/'.$folder.'/'.$image)) + + $src_img; + switch ($ext) { - // if it already exists, do nothing - return; + 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; } - else + + $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) { - $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); + 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) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <esp...@us...> - 2007-08-12 04:02:30
|
Revision: 27 http://picfinity.svn.sourceforge.net/picfinity/?rev=27&view=rev Author: espadav8 Date: 2007-08-11 21:02:00 -0700 (Sat, 11 Aug 2007) Log Message: ----------- Add a check for PHP version so we use the correct xsl code Modified Paths: -------------- index.php Modified: index.php =================================================================== --- index.php 2007-08-10 14:17:49 UTC (rev 26) +++ index.php 2007-08-12 04:02:00 UTC (rev 27) @@ -338,17 +338,34 @@ function xml_to_xhtml($xml, $xsl_file, $params = array()) { - $doc = new DOMDocument(); - $xsl = new XSLTProcessor(); + $ver = explode( '.', PHP_VERSION ); + $ver_num = $ver[0] . $ver[1] . $ver[2]; - $doc->load($xsl_file); - $xsl->importStyleSheet($doc); + if ( $ver_num < 500 ) + { + $arguments = array('/_xml' => $xml); + $xsltproc = xslt_create(); + $html = xslt_process($xsltproc, 'arg:/_xml', $xsl_file, NULL, $arguments); - $doc->loadXML($xml); + if (empty($html)) { + die('XSLT processing error: '. xslt_error($xsltproc)); + } + xslt_free($xsltproc); + return $html; + } + else + { + $doc = new DOMDocument(); + $xsl = new XSLTProcessor(); - $xsl->setParameter('', $params); + $doc->load($xsl_file); + $xsl->importStyleSheet($doc); - return $xsl->transformToXML($doc); + $doc->loadXML($xml); + $xsl->setParameter('', $params); + + return $xsl->transformToXML($doc); + } } function MakeDirectory($dir, $mode = 0755) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |