[geeklog-cvs] geeklog: Fixed Staticpage plugin to work with PHP-4.x (Bug: #000...

geeklog-cvs at lists.geeklog.net geeklog-cvs at lists.geeklog.net
Tue Jan 4 10:06:40 EST 2011


changeset 8038:edb8d1e2eaee
url:  http://project.geeklog.net/cgi-bin/hgwebdir.cgi/geeklog/rev/edb8d1e2eaee
user: Tom <websitemaster at cogeco.net>
date: Tue Jan 04 10:05:41 2011 -0500
description:
Fixed Staticpage plugin to work with PHP-4.x (Bug: #0001239)

diffstat:

 plugins/staticpages/services.inc.php |  48 +++++++++++++++++++++++++++---------
 1 files changed, 36 insertions(+), 12 deletions(-)

diffs (59 lines):

diff -r 8d1c260d9873 -r edb8d1e2eaee plugins/staticpages/services.inc.php
--- a/plugins/staticpages/services.inc.php	Sun Jan 02 11:01:30 2011 +0100
+++ b/plugins/staticpages/services.inc.php	Tue Jan 04 10:05:41 2011 -0500
@@ -671,19 +671,43 @@
                 $retval = '';
                 $mode = '';
                 
-                $xmlObject = simplexml_load_string($output['sp_content']);
+                if (PHP_VERSION >= 5) {
+                    $xmlObject = simplexml_load_string($output['sp_content']);
+                    
+                    // create array of XML data
+                    $tag = array();    
+                    foreach($xmlObject->variable as $variable) {
+                        $key = $variable["name"] . '';
+                        $value = $variable->data;
+                        $tag[$key] = $value;
+                    }    
                 
-                // create array of XML data
-                $tag = array();    
-                foreach($xmlObject->variable as $variable) {
-                    $key = $variable["name"] . '';
-                    $value = $variable->data;
-                    $tag[$key] = $value;
-                }    
-            
-                // Loop through variables to replace any autotags first
-                foreach ($tag as &$value) {
-                    $value = PLG_replaceTags($value);
+                    // Loop through variables to replace any autotags first
+                    foreach ($tag as &$value) {
+                        $value = PLG_replaceTags($value);
+                    }
+                } else {
+                    // For PHP 4
+                    $xmlObject = new DOMDocument;
+                    $xmlObject->loadXML($output['sp_content']);
+                    
+                    $tag = array();    
+                    // Loop through each <variable> tag in the dom and add it to the array 
+                    foreach($xmlObject->getElementsByTagName('variable') as $variable) {
+                        $key = $variable->getAttribute('name');
+                        if(!empty($key)) {
+                            $data = $variable->childNodes;
+                            foreach($data as $value) {
+                                if($value->nodeName == 'data') {
+                                    $tag[$key] = $value->nodeValue;
+                                }
+                            }
+                        }
+                    }                     
+                    // Loop through variables to replace any autotags first
+                    foreach ($tag as $key => $value) {
+                        $tag[$key] = PLG_replaceTags($tag[$key]);
+                    }                    
                 }
                 
                 $args = array(



More information about the geeklog-cvs mailing list