Exemple #1
0
$objView = AROView::finder()->byPK($_REQUEST['id']);
$szViewFile = PROJECT_VIEWS . '/' . $objView->id . '.php';
if (!empty($_GET['deleteme'])) {
    $objView->delete();
    unlink($szViewFile);
    header('Location: ../');
    exit;
} else {
    if (isset($_POST['title'], $_POST['content'], $_POST['type'])) {
        require_once PROJECT_INCLUDE . '/Dwoo-1.1.1/Dwoo/dwooAutoload.php';
        $template_source = $_POST['content'];
        $template = new Dwoo_Template_String($template_source);
        $dwoo = new Dwoo();
        $compiler = new Dwoo_Compiler();
        $compiler->setDelimiters('<?', '?>');
        $dwoo->setCompiler($compiler);
        try {
            $compiled_template_source = $dwoo->testTemplate($template);
            //	echo '<pre>'.htmlspecialchars($template_source).'</pre>';
            //	echo '<p>is a valid template:</p>';
            //	exit('<pre>'.htmlspecialchars(file_get_contents($compiled_template_source)).'</pre>');
        } catch (Dwoo_Exception $exc) {
            echo '<pre style="background-color:pink;">' . htmlspecialchars($template_source) . '</pre>';
            echo '<p>is NOT a valid template:</p>';
            exit('<pre style="background-color:pink;">' . $exc->getMessage() . '</pre>');
        }
        $objView->title = $_POST['title'];
        $objView->type = implode(',', $_POST['type']);
        $objView->save();
        file_put_contents($szViewFile, $_POST['content']);
        header('Location: ' . $_SERVER['HTTP_REFERER']);