예제 #1
0
function __compile($context, $source, $name)
{
    $sourceStr = __toString($source);
    /* Compiler initialisieren */
    static $compiler;
    if ($compiler == null) {
        include_once "compiler.php";
        $compiler = new Compiler();
    }
    /* Modul Kompilieren */
    $code = $compiler->compile($sourceStr);
    if (isset($code['Module'])) {
        /* Libarymodule bearbeiten */
        $dir = BIN_DIR . preg_replace("/\\W/", "_", $code['Module']);
        $name = $dir . ".php";
        if (is_dir($dir)) {
            foreach (__ls_r($dir . "/") as $file) {
                if (is_dir($file)) {
                    rmdir($file);
                } else {
                    unlink($file);
                }
            }
        }
        /* Ordner neu anlegen */
        mkdir($dir);
        chmod($dir, 0777);
        /* Funktionen niederschreiben */
        foreach ($code['Functions'] as $fnName => $body) {
            $fp = fopen($dir . "/" . $fnName . ".php", 'w');
            fwrite($fp, $body);
            fclose($fp);
            chmod($dir . "/" . $fnName . ".php", 0777);
        }
        /* Name von Mainmodulen anpassen */
    } else {
        $name = BIN_DIR . preg_replace("/\\W/", "_", substr($name, strrpos($name, "/") + 1)) . ".php";
    }
    /* Hauptteil niederschreiben */
    if (($fp = @fopen($name, 'w')) == false) {
        PEAR::raiseError("Die Datei '" . $name . "' kann nicht geöffnet werden!");
    }
    fwrite($fp, $code['Main']);
    fclose($fp);
    chmod($name, 0777);
    /* Leere Sequenz zurückgeben */
    return array();
}
예제 #2
0
function __ls_r($path)
{
    /* Dateien Suchen */
    $files = array();
    $dir = dir($path);
    while (false !== ($file = $dir->read())) {
        if ($file != "." and $file != ".." and $file != ".svn") {
            $files[] = $file;
        }
    }
    $dir->close();
    /* Liste erstellen */
    $list = array();
    foreach ($files as $file) {
        if (is_dir($path . $file)) {
            $list = array_merge($list, __ls_r($path . $file . "/"), array($path . $file));
        } else {
            $list[] = $path . $file;
        }
    }
    return array_merge($list, array($path));
}
예제 #3
0
<?php

/*
  Kompiliert alle Module im modules Ordner
  URL: http://localhost/urulu/trunk/compile.php
*/
/* Virtual machine laden */
require_once realpath(dirname(__FILE__)) . "/xqvm.php";
echo "Dateien einlesen ...<br />\n";
/* Jedes Dokument einlesen und kompilieren */
foreach ($GLOBALS['XQDB_SOURCE_DIRS'] as $dir) {
    foreach (__ls_r($dir) as $file) {
        if (is_file($file) and substr($file, -4) == ".xsc") {
            echo "Kompiliere: '" . $file . "' ...<br />\n";
            $fp = fopen($file, "r");
            $source = fread($fp, filesize($file));
            fclose($fp);
            /* Sequenz mit den Werten erstellen */
            __compile(array(), array($GLOBALS["XQDB_Storage"]->registerItem(new AtomicValue($source, "xs:string"))), substr($file, 0, -4));
        }
    }
}