Login   Register  
PHP Classes
elePHPant
Icontem

File: setup_factory/upgrade.php4.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of joel  >  POG - PHP Code Generator  >  setup_factory/upgrade.php4.php  >  Download  
File: setup_factory/upgrade.php4.php
Role: Application script
Content type: text/plain
Description: upgrade file for php4 objects
Class: POG - PHP Code Generator
Generate object-relational mapping classes
Author: By
Last change:
Date: 8 years ago
Size: 2,786 bytes
 

Contents

Class file image Download
<?php
/**
* @author  Joel Wan & Mark Slemko.  Designs by Jonathan Easton
* @link  http://www.phpobjectgenerator.com
* @copyright  Offered under the  BSD license
*
* This upgrade file does the following:
* 1. Checks if there is a new version of POG
* 2. If there is, it reads generates newer versions of all objects in the object directory,
* zip then and present them to the user to 'download'
*/
include "../../configuration.php";
include 
"class.zipfile.php";
include 
"nusoap.php";

    
/**
     * Connects to POG SOAP server defined in configuration.php and
     * generates new versions of all objects detected in /objects/ dir.
     * All upgraded objects are then zipped and presented to user.
     *
     * @param string $path
     */
    
function UpdateAllObjects($path)
    {
        
$dir opendir($path);
        
$objects = array();
        while((
$file readdir($dir)) !== false)
        {
            if(
strlen($file) > && substr(strtolower($file), strlen($file) - 4) === '.php' && !is_dir($file) && $file != "class.database.php" && $file != "configuration.php" && $file != "setup.php")
            {
                
$objects[] = $file;
            }
        }
        
closedir($dir);
        
$i 0;
        foreach(
$objects as $object)
        {
            
$content file_get_contents($path."/".$object);
            
$contentParts split("<b>",$content);
            if (isset(
$contentParts[1]))
            {
                
$contentParts2 split("</b>",$contentParts[1]);
            }
            if (isset(
$contentParts2[0]))
            {
                
$className trim($contentParts2[0]);
            }
            if (isset(
$className))
            {
                
$objectNameList[] = $className;

                
$linkParts1 split("\*\/"$contentParts[1]);
                
$linkParts2 split("\@link"$linkParts1[0]);
                
$link $linkParts2[1];

                
$client = new soapclient($GLOBALS['configuration']['soap'], true);
                
$params = array('link'     => $link);
                if (
$i == 0)
                {
                    
$package unserialize($client->call('GeneratePackageFromLink'$params));
                }
                else
                {
                    
$objectString $client->call('GenerateObjectFromLink'$params);
                    
$package["objects"]["class.".strtolower($className).".php"] = $objectString;
                }
            }
            
$i++;
        }
        
$zipfile = new createZip();
        
$zipfile -> addPOGPackage($package);
        
$zipfile -> forceDownload("pog.".time().".zip");
    }

    
/**
     * Checks if POG generator has been updated
     *
     * @return unknown
     */
    
function UpdateAvailable()
    {
        
$client = new soapclient($GLOBALS['configuration']['soap'], true);
        
$params = array();
        
$generatorVersion base64_decode($client->call('GetGeneratorVersion'));
        if (
$generatorVersion != $GLOBALS['configuration']['versionNumber'].$GLOBALS['configuration']['revisionNumber'])
        {
            return 
true;
        }
        else
        {
            return  
false;
        }
    }

    if (
UpdateAvailable())
    {
        
UpdateAllObjects("../../objects/");
    }
    else
    {
        echo 
"<script>
            alert('All POG objects are already up to date');
            window.close();
        </script>"
;
    }
?>