Beispiel #1
0
function generateClass($package, $class, $language = 'PHP')
{
    $languageClass = 'PHOS_' . $language;
    $language = new $languageClass();
    //make sure class exists
    $classDir = fileName(PACKAGEDIR, $package, CLASSDIR, $class);
    if (!file_exists($classDir)) {
        throw new Exception("{$classDir} does not appear to exist");
    }
    $definition = array('extend' => false, 'implement' => false, 'mixin' => false);
    foreach ($definition as $dname => $val) {
        $dfile = fileName($classDir, $dname);
        if (file_exists($dfile)) {
            $definition[$dname] = array_map('trim', explode(',', trim(file_get_contents($dfile))));
        }
    }
    //get the properties, based on type build constructor
    $properties = loadProperties($classDir);
    //get the methods
    $methods = loadMethods($classDir);
    //start the file
    $file = $language->startClass($class, $definition);
    if ($definition['mixin']) {
        //load mixin methods and properties
        foreach ($definition['mixin'] as $module) {
            $moduleDir = fileName(PACKAGEDIR, $package, MODULEDIR, $module);
            $properties = array_merge($properties, loadProperties($moduleDir));
            $methods = array_merge($methods, loadMethods($moduleDir));
        }
    }
    //build the construct method based on the private propeties
    $constructor = '';
    foreach ($properties as $property) {
        $file .= $language->addProperty($property);
        $constructor .= $language->selfAssign($property, $language->newObject($property->type, $property->default));
    }
    $file .= "\n";
    $methods[$language->constructorName] = (object) array('name' => $language->constructorName, 'scope' => 'public', 'args' => '()', 'body' => $constructor);
    foreach ($methods as $method) {
        $file .= $language->method($method);
    }
    //write file
    file_put_contents(fileName(GENERATEDIR, "class.{$class}.php"), $file . '}');
}
$store = mapi_openmsgstore($session, $storeEntryid);
$root = mapi_msgstore_openentry($store, null);
$rootProps = mapi_getprops($root, array(PR_IPM_CONTACT_ENTRYID));
$folder = mapi_msgstore_openentry($store, $rootProps[PR_IPM_CONTACT_ENTRYID]);
isUnicodeStore($store);
// open the csv file and start reading
$fh = fopen($csv_file, "r");
if (!$fh) {
    trigger_error("Can't open CSV file \"" . $csv_file . "\"", E_USER_ERROR);
}
// empty folder if needed
if (EMPTY_FOLDER) {
    mapi_folder_emptyfolder($folder, DEL_ASSOCIATED);
}
$properties = array();
loadProperties($properties);
$properties = getPropIdsFromStrings($store, $properties);
//composed properties which require more work
$special_properties = array("email_address_1", "email_address_2", "email_address_3");
$i = 1;
while (!feof($fh)) {
    $line = fgetcsv($fh, CSV_MAX_LENGTH, CSV_DELIMITER, CSV_ENCLOSURE);
    if (!$line) {
        continue;
    }
    if ($i == 1 && defined('FIELD_NAMES') && FIELD_NAMES) {
        $i++;
        continue;
    }
    $props = array();
    //set "simple" properties
    } else {
        $suffix = 0;
    }
    $start = strpos($buffer, $start);
    if ($strrpos) {
        $_end = strrpos($buffer, $end);
    } else {
        $_end = strpos($buffer, $end, $start);
    }
    if ($start !== FALSE) {
        return substr($buffer, $start + $prefix, $_end - ($start + $prefix) + $suffix);
    } else {
        return '';
    }
}
function loadProperties($buildPropertiesFilename)
{
    $return = array();
    $buildProperties = parse_ini_file($buildPropertiesFilename);
    $return['longName'] = $buildProperties['docbook.longName'];
    $editions = explode(',', $buildProperties['docbook.editions']);
    foreach ($editions as $edition) {
        $parts = explode('-', $edition);
        $version = $parts[0];
        $lang = $parts[1];
        $return['editions'][$lang][] = $version;
    }
    return $return;
}
$properties = loadProperties($argv[1]);
webifyDirectory($properties, $argv[2], $argv[3]);
<?php

require 'bc-fourstore-php/FourStore/FourStore_StorePlus.php';
require 'bc-fourstore-php/FourStore/Namespace.php';
require 'shakespeare_utilities.php';
$userID = getUserID();
$propertyList = loadProperties();
FourStore_Namespace::addW3CNamespace();
FourStore_Namespace::add('omb', 'http://purl.org/ontomedia/ext/common/being#');
FourStore_Namespace::add('omt', 'http://purl.org/ontomedia/ext/common/trait#');
FourStore_Namespace::add('ome', 'http://purl.org/ontomedia/core/expression#');
FourStore_Namespace::add('foaf', 'http://xmlns.com/foaf/0.1/');
$query = FourStore_Namespace::to_sparql();
$graphAuto = 'http://contextus.net/resource/midsum_night_dream/auto/';
$graphUser = '******' . $userID . '/';
$graphMeta = 'http://contextus.net/resource/meta/';
$queryAuto = $query . "\nSELECT ?s ?p ?o\nFROM <" . $graphAuto . ">\n" . 'WHERE { ?s a omb:Character ; ?p ?o . FILTER (?p = foaf:name || ?p = ome:is-shadow-of || ?p = rdf:type || ?p = ome:is) }' . "\n";
$queryUser = $query . "\nSELECT ?s ?p ?o\nFROM <" . $graphUser . ">\n" . 'WHERE { ?s a omb:Character ; ?p ?o . FILTER (?p = foaf:name || ?p = ome:is-shadow-of || ?p = rdf:type || ?p = ome:is) }' . "\n";
//$stateQuery = $query . "\nSELECT DISTINCT ?s ?label\nFROM <" .  $graphMeta . ">\n" . 'WHERE { ?s a omt:; rdfs:label ?label }' . "\n";
$stateQuery = $query . "\n" . 'SELECT DISTINCT ?id WHERE { { GRAPH ?g {?id a omt:State-Of-Being}} {GRAPH <' . $graphMeta . '> { ?id ?p ?o } } } ORDER BY ?id' . "\n";
//print($stateQuery);
$s = new FourStore_StorePlus('http://contextus.net:7000/sparql/');
$graph = array();
$autoCharsToBeIgnored = array();
$rUser = $s->query($queryUser);
foreach ($rUser['result']['rows'] as $result) {
    addTripleToGraph($graph, makeTriple($result['s'], $result['p'], $result['o']));
    if ($result['p'] == 'http://purl.org/ontomedia/core/expression#is-shadow-of') {
        $autoCharsToBeIgnored[] = $result['o'];
    }
}