Example #1
0
/**
 * 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) > 4 && substr(strtolower($file), strlen($file) - 4) === '.php' && !is_dir($file) && $file != "class.database.php" && $file != "configuration.php" && $file != "setup.php" && $file != "class.pog_base.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)) {
            eval('include_once("../../objects/class.' . strtolower($className) . '.php");');
            $instance = new $className();
            if (!TestIsMapping($instance)) {
                $objectNameList[] = $className;
                $linkParts1 = split("\\*\\/", $contentParts[1]);
                $linkParts2 = split("\\@link", $linkParts1[0]);
                $link = $linkParts2[1];
                $options = false;
                if ($GLOBALS['configuration']['proxy_host'] != false && $GLOBALS['configuration']['proxy_port'] != false && $GLOBALS['configuration']['proxy_username'] != false && $GLOBALS['configuration']['proxy_password'] != false) {
                    $options = array('proxy_host' => $GLOBALS['configuration']['proxy_host'], 'proxy_port' => $GLOBALS['configuration']['proxy_port'], 'proxy_login' => $GLOBALS['configuration']['proxy_username'], 'proxy_password' => $GLOBALS['configuration']['proxy_password']);
                }
                $client = new SoapClient($GLOBALS['configuration']['soap'], $options);
                if ($i == 0) {
                    $package = unserialize($client->GeneratePackageFromLink($link));
                } else {
                    $objectString = $client->GenerateObjectFromLink($link);
                    $package["objects"]["class." . strtolower($className) . ".php"] = $objectString;
                }
            }
        }
        $i++;
    }
    //upgrade mapping classes if any
    foreach ($objectNameList as $objectName) {
        $instance = new $objectName();
        foreach ($instance->pog_attribute_type as $key => $attribute_type) {
            if ($attribute_type['db_attributes'][1] == "JOIN") {
                $mappingString = $client->GenerateMapping($objectName, $key, isset($GLOBALS['configuration']['pdoDriver']) ? 'php5.1' : 'php5', isset($GLOBALS['configuration']['pdoDriver']) ? 'pdo' : 'pog', isset($GLOBALS['configuration']['pdoDriver']) ? 'mysql' : '');
                $package["objects"]['class.' . strtolower(MappingName($objectName, $key)) . '.php'] = $mappingString;
            }
        }
    }
    $zipfile = new createZip();
    $zipfile->addPOGPackage($package);
    $zipfile->forceDownload("pog." . time() . ".zip");
}
Example #2
0
        if (isset($_GET['objectName'])) {
            $_SESSION['objectName'] = $_GET['objectName'];
        }
        $objectName = isset($_SESSION['objectName']) ? $_SESSION['objectName'] : $objectNameList[0];
        ?>
	<div id="header">
  	<ul>
  	<li id='inactive'>My Objects:</li>
	<?php 
        if (!isset($_SESSION['objectName'])) {
            $_SESSION['objectName'] = $objectNameList[0];
        }
        for ($i = 0; $i < count($objectNameList); $i++) {
            $name = $objectNameList[$i];
            eval('$instance = new ' . $name . '();');
            if (!TestIsMapping($instance)) {
                echo "<li " . ($_SESSION['objectName'] == $objectNameList[$i] ? "id='current'" : '') . "><a href='./index.php?objectName=" . $objectNameList[$i] . "'>" . $objectNameList[$i] . "</a></li>";
                //echo "<a href='./index.php?objectName=".$objectNameList[$i]."'".(isset($_SESSION['objectName']) && $_SESSION['objectName']==$objectNameList[$i]?"class='activetab'":(!isset($_SESSION['objectName'])&&$i==0?"class='activetab'":"inactivetab")).">".$objectNameList[$i]."</a> ";
            }
        }
        $connection = Database::Connect();
        $count = 0;
        $sql = 'show index from `' . strtolower($_SESSION['objectName']) . '` where Key_name = "searching"';
        $cursor = Database::Reader($sql, $connection);
        while ($row = Database::Read($cursor)) {
            $count++;
        }
        ?>
	</ul>
	</div><!--header-->
	</div><!--subtabs-->
/**
 * Enter description here...
 *
 * @param unknown_type $instance
 * @return unknown
 */
function TestRelationsPreRequisites($instance, $allObjectsList, $thisObjectName, $ignoreObjects)
{
    if (TestIsMapping($instance)) {
        AddTrace("\tIs Mapping (OK)");
        return true;
    }
    if (TestIsSingle($instance)) {
        AddTrace("\tIs single (OK)");
        return true;
    } else {
        if (!TestParentChildLink($instance, $allObjectsList, $thisObjectName, $ignoreObjects) || !TestAssociationLink($instance, $allObjectsList, $thisObjectName, $ignoreObjects)) {
            return false;
        } else {
            AddTrace("\tIs properly connected (OK)");
            return true;
        }
    }
}