Exemple #1
0
function page_admin_edit($table, $field, $id)
{
    use_layout("admin");
    requires_admin();
    global $tables;
    if (!isset($tables[$table]['liveedit'])) {
        die("can't edit this table tables[{$table}]['liveedit'] not set");
    }
    if (isset($_POST['editor1'])) {
        $html = form_post("editor1");
        $html = str_replace('\\"', '"', $html);
        $html = str_replace("\\'", "'", $html);
        $html = str_replace("\\\\", "\\", $html);
        $f = "on_{$table}_{$field}_update";
        if (function_exists($f)) {
            $f($id, $html);
        }
        db_query("UPDATE %s SET %s='%s' WHERE id=%d", $table, $field, $html, $id);
        if (CLOSE_ON_SAVE) {
            die("<script> window.close();</script>");
        }
        flash("message", "Изменения сохранены");
    }
    $content = db_result(db_query("SELECT %s FROM %s WHERE id=%d", $field, $table, $id));
    $o = "";
    if (form_post("back")) {
        $back = form_post("back");
        $o .= "<a href={$back}><<Назад</a>";
    }
    $o .= template("tinymce", "content", $content);
    return $o;
}
Exemple #2
0
function page_admin_news($act = "", $id = "")
{
    requires_admin();
    use_layout("admin");
    $o = table_edit("news", "admin/news", $act, $id);
    return $o;
}
Exemple #3
0
function page_admin_menu_edit($parent_id = "", $act = "", $id = "")
{
    requires_admin();
    set_lang("other");
    use_layout("admin");
    if (!$parent_id) {
        $parent_id = 0;
    }
    $o = "";
    if ($act == "del") {
        $rec = db_object_get("menu", $id);
        if ($rec->fixed == 'Y') {
            $act = "-";
            $o .= '<script>alert("Эту запись нельзя удалить.")</script>';
        }
    }
    global $tables;
    $tables['menu']['fields'][] = "title";
    $tables['menu']['fields'][] = "link";
    $tables['menu']['weight'] = true;
    if ($parent_id) {
        $o .= menu_path($parent_id);
    }
    global $table_edit_props;
    $table_edit_props->use_rename_icon_for_edit = true;
    $o .= table_edit("menu", "admin/menu/edit/{$parent_id}", $act, $id, "parent_id", $parent_id, "", "on_menu");
    $o .= "<style> input[type='submit'] { padding: 5px 10px; width: auto;}\r\n\t  input{ width:400px; }\r\n\t</style>";
    return $o;
}
Exemple #4
0
function page_admin_images($act = "", $id = "")
{
    requires_admin();
    use_layout("admin");
    form_start("", "post", " enctype='multipart/form-data' ");
    form_file("Файл", "file");
    $caption = "Загрузить картинку";
    if ($act == "edit") {
        $caption = "Изменить картинку";
    }
    form_submit($caption, "submit");
    form_end();
    $upload = form();
    if (form_file_uploaded("file")) {
        $fname = $_FILES["file"]['name'];
        $ext = strtolower(fileext($fname));
        if (!($ext == "swf" || $ext == "jpg" || $ext == "gif" || $ext == "png" || $ext == "bmp" || $ext == "jpeg" || $ext == "pdf")) {
            $o = "Данный тип файла не является картинкой";
            return $o;
        } else {
            if ($act == "add") {
                db_query("INSERT INTO images (link) VALUES ('')");
                $id = db_last_id();
            } else {
                @unlink(db_result(db_query("SELECT link FROM images WHERE id=%d", $id)));
            }
            $fname = $id . "." . fileext($fname);
            form_file_uploaded_move("file", "img/" . $fname);
            db_query("UPDATE images SET link='img/{$fname}' WHERE id=%d", $id);
            redir("admin/images/edit/{$id}");
        }
    }
    if ($act == "add") {
        $o = $upload;
        return $o;
    }
    if ($act == "del") {
        $im = db_object_get("images", $id);
        @unlink("{$im->link}");
    }
    $o = table_edit("images", "admin/images", $act, $id, "", "", "", "image_func");
    if ($act == 'edit') {
        $im = db_object_get("images", $id);
        $o .= "<img width=100px src={$im->link}><br>{$upload}";
    }
    return $o;
}
Exemple #5
0
function page_admin_pages($act = "", $id = "")
{
    requires_admin();
    use_layout("admin");
    $o = "";
    if ($act == "del") {
        $p = db_object_get("pages", $id);
        if ($p->fixed == 'Y') {
            $act = "-";
            $o .= '<script>alert("Эту страницу нельзя удалить.")</script>';
        }
    }
    global $table_edit_props;
    $table_edit_props->col_title_show = false;
    //	$table_edit_props->new_record_show = false;
    //   $table_edit_props->del_record_show = false;
    //    $table_edit_props->edit_record_show = false;
    $table_edit_props->use_rename_icon_for_edit = true;
    global $base_url;
    $o .= table_edit("pages", "admin/pages", $act, $id, "category", "null", "weight", "admin_on_page");
    return $o;
}
Exemple #6
0
function page_admin_settings()
{
    requires_admin();
    use_layout("admin");
    global $tables;
    $o = "";
    if (form_post("save")) {
        $set = "";
        foreach ($tables['settings']['fields'] as $field) {
            if ($set) {
                $set .= ",";
            }
            $set = "{$field}='" . form_post($field) . "'";
        }
        db_query("UPDATE settings SET {$set}");
        $o .= "<font color=green>changes saved</font>";
    }
    $vals = db_fetch_object(db_query("SELECT * FROM settings LIMIT 1"));
    form_start();
    foreach ($tables['settings']['fields'] as $field) {
        form_input($field, $field, $vals->{$field});
    }
    form_submit("Save", "save");
    form_end();
    $o .= form();
    return $o;
}