Esempio n. 1
0
function handleInstanceReq($rootDoc, $req, $name)
{
    $xPath = new DOMXPath($rootDoc);
    $items = $xPath->query("item[settings/name = '{$name}']");
    $item = $items->length > 0 ? $items->item(0) : false;
    if ($item !== false) {
        // if(isset($_REQUEST['ajax']))
        // {
        //   echo "ajax!";
        //   die(); // we probably don't want to do this... but it works for now.
        // }
        // else
        // {
        $config = parseItem($item);
        $module = initModule($config);
        switch ($req) {
            case 'ajax':
                $module->setMode("ajax");
                break;
            case 'page':
                $module->setMode("default");
                break;
            default:
                die;
                break;
        }
        $moduleXML = '<?xml version="1.0" encoding="utf-8" ?>' . "\n" . $module->getXML();
        // echo "---1---\n";
        // var_dump($config);
        // echo "---2---\n";
        // var_dump($module);
        // echo "---3---\n";
        // var_dump($moduleXML);
        // echo "---END---\n";
        $moduleDoc = new DOMDocument();
        $moduleDoc->loadXML($moduleXML);
        $moduleElem = $moduleDoc->documentElement;
        $outDoc = new DOMDocument();
        $outDoc->loadXML('<?xml version="1.0" encoding="utf-8"?><root />');
        $title = $xPath->query("/root/title")->item(0);
        $titleNode = $outDoc->importNode($title, true);
        $outDoc->documentElement->appendChild($titleNode);
        $moduleNode = $outDoc->importNode($moduleElem, true);
        $outDoc->documentElement->appendChild($moduleNode);
        // echo "---outDoc XML---\n";
        // echo $outDoc->saveXML()."\n";
        $rootStylesheet = new DOMDocument();
        $rootStylesheet->load(CONFIG_DIR . 'root.xsl');
        $transformer = new XSLTProcessor();
        $transformer->importStylesheet($rootStylesheet);
        echo $transformer->transformToXML($outDoc);
        ob_end_flush();
        flush();
        die;
        // }
    } else {
        // FIXME: Do something to handle that there was no module with that name
    }
}
Esempio n. 2
0
} else {
    $get_action = '';
}
if (isset($_GET['d'])) {
    $get_data = cleanInputFromCode($_GET['d']);
} else {
    $get_data = '';
}
// Modul initialisieren
if (file_exists(__PATH__ . '/modules/' . $get_module . '/module-index.php')) {
    define('MODULE_URL', __URL__ . '/modules/' . $get_module);
    require_once __PATH__ . '/modules/' . $get_module . '/module-index.php';
    // Prüfen ob das Modul Javascript enthält
    if (file_exists(__PATH__ . '/modules/' . $get_module . '/module-javascript.js')) {
        $smarty->assign('module_javascript', '<script src="' . __URL__ . '/modules/' . $get_module . '/module-javascript.js"></script>');
    } else {
        $smarty->assign('module_javascript', '');
    }
    initModule($get_action, $get_data);
} else {
    logToFile('callsToNonExistingModules', $get_module);
    $smarty->assign('title', '404: Nicht gefunden');
    $theme_template = 'tpl-404.html';
}
// Ausgabe über Template
$smarty->display($theme_template);
// Fehler ausgeben
if (isset($_SESSION['errors'])) {
    // foreach($_SESSION['errors'] as $error) { echo $error['message'] . '<br>'; }
    unset($_SESSION['errors']);
}
Esempio n. 3
0
if ($rootItems) {
    // We have to do this in an ugly way since DOMNodeLists that are returned
    // from DOMDocument::getElementsByTagName() seem to differ from those
    // returned from DOMNode->childNodes. Magic.
    $itemCount = $rootItems->length;
    $i = 0;
    while ($i < $itemCount) {
        // This SHOULDN'T work, but it seems that item(0) moves some internal
        // pointer one step forward. This issue has 1-3 Crazy Hours
        $rootItem = $rootItems->item(0);
        $i++;
        // echo "inspecting $rootItem->nodeName: $rootItem->nodeValue\n";
        // The node is a text node, skip it.
        // Do The Right Thing™ with the node.
        $itemConfig = parseItem($rootItem);
        $module = initModule($itemConfig);
        $moduleXML = '<?xml version="1.0" encoding="utf-8"?>' . "\n" . $module->getXML();
        // echo "---module XML---\n";
        // echo "$moduleXML\n";
        $moduleDoc = new DOMDocument();
        $moduleDoc->loadXML($moduleXML);
        // echo "---moduleDoc XML---\n";
        // echo $moduleDoc->saveXML()."\n";
        $moduleElem = $moduleDoc->documentElement;
        $moduleNode = $rootDoc->importNode($moduleElem, true);
        $parent = $rootItem->parentNode;
        $parent->removeChild($rootItem);
        $parent->appendChild($moduleNode);
    }
    // echo "---altered rootDoc xml---\n";
    // echo $rootDoc->saveXML();