Exemplo n.º 1
0
function action_edit()
{
    global $page, $pagestore, $ParseEngine, $version;
    $pg = $pagestore->page($page);
    $pg->read();
    if (!$pg->mutable) {
        die(ACTION_ErrorPageLocked);
    }
    $archive = 0;
    if ($version != '') {
        $pg->version = $version;
        $pg->read();
        $archive = 1;
    }
    template_edit(array('page' => $page, 'text' => $pg->text, 'timestamp' => $pg->time, 'nextver' => $pg->version + 1, 'archive' => $archive));
}
Exemplo n.º 2
0
if (isset($_GET['action'])) {
    $action = $_GET['action'];
}
if (isset($_POST['action'])) {
    $action = $_POST['action'];
}
debug_msg("Action: " . $action, 5);
// Determine what action to take
switch ($action) {
    case 'add':
        template_add();
        break;
    case 'edit':
        if (isset($_GET['id'])) {
            $id = $_GET['id'];
            template_edit($id);
        }
        break;
    case 'delete':
        if (isset($_GET['id'])) {
            $id = $_GET['id'];
            template_delete($id);
        }
        break;
    case 'deleterecord':
        if (isset($_POST['id'])) {
            $id = $_POST['id'];
            template_deleterecord($id);
        }
        break;
    case 'insert':
Exemplo n.º 3
0
    case 'actions':
        form_actions();
        break;
    case 'rrd_add':
        template_rrd_add();
        break;
    case 'rrd_remove':
        template_rrd_remove();
        break;
    case 'template_remove':
        template_remove();
        header("Location: data_templates.php");
        break;
    case 'template_edit':
        include_once "./include/top_header.php";
        template_edit();
        include_once "./include/bottom_footer.php";
        break;
    default:
        include_once "./include/top_header.php";
        template();
        include_once "./include/bottom_footer.php";
        break;
}
/* --------------------------
    The Save Function
   -------------------------- */
function form_save()
{
    global $cnn_id;
    if (isset($_POST["save_component_template"])) {
Exemplo n.º 4
0
function action_edit()
{
    global $ErrorPageLocked, $page, $pagefrom, $pagestore, $ParseEngine;
    global $section, $use_template, $UserName, $version;
    $pg = $pagestore->page($page);
    $pg->read();
    if (!$UserName || !$pg->mutable) {
        die($ErrorPageLocked);
    }
    $archive = 0;
    if ($version != '') {
        $pg->version = $version;
        $pg->read();
        $archive = 1;
    }
    $page_text = $pg->text;
    // page template
    if ($use_template) {
        $tmpl_pg = $pagestore->page($use_template);
        if ($tmpl_pg->exists()) {
            $tmpl_pg->read();
            $page_text = $tmpl_pg->text;
            $archive = 0;
        } else {
            $use_template = '';
        }
    }
    // section editing
    $text_before = '';
    $text_after = '';
    if ($section) {
        $lines = explode("\n", $page_text);
        $lines_before = array();
        $lines_after = array();
        $lines_section = array();
        $section_count = 0;
        $found_level = 0;
        foreach ($lines as $line) {
            if (($result = parse_heading_line_match(strip_tags($line))) !== false && (!$found_level || strlen($result[2]) <= $found_level)) {
                $section_count++;
            }
            if ($section_count < $section) {
                $lines_before[] = $line;
            } else {
                if ($section_count > $section) {
                    $lines_after[] = $line;
                } else {
                    if (!$found_level) {
                        $found_level = strlen($result[2]);
                    }
                    $lines_section[] = $line;
                }
            }
        }
        $text_before = implode("\n", $lines_before);
        $text_after = implode("\n", $lines_after);
        $page_text = implode("\n", $lines_section);
    }
    if (trim($page_text) == '') {
        $page_text = "Describe {$page} here...\n\nPlease provide content before " . "saving.\n\n-- [{$UserName}]";
    }
    template_edit(array('page' => $page, 'pagefrom' => $pagefrom, 'text' => $page_text, 'section' => $section, 'text_before' => $text_before, 'text_after' => $text_after, 'timestamp' => $pg->time, 'nextver' => $pg->version + 1, 'archive' => $archive, 'template' => $pg->template, 'templates' => $pagestore->getTemplatePages(), 'use_template' => $use_template, 'edituser' => $pg->username, 'editver' => $UserName && $pg->mutable ? $version == '' ? 0 : $version : -1));
}