Ejemplo n.º 1
0
function plugin_guiedit_action()
{
    // global $vars, $_title_edit, $load_template_func;
    global $vars, $load_template_func;
    global $menubar, $sidebar, $topicpath, $_string;
    // if (PKWK_READONLY) Utility::dieMessage( sprintf($_string['error_prohibit'],'PKWK_READONLY') );
    if (Auth::check_role('readonly')) {
        Utility::dieMessage(sprintf($_string['error_prohibit'], 'PKWK_READONLY'));
    }
    if (PKWK_READONLY == Auth::ROLE_AUTH && Auth::get_role_level() > Auth::ROLE_AUTH) {
        Utility::dieMessage(sprintf($_string['error_prohibit'], 'PKWK_READONLY'));
    }
    $page = isset($vars['page']) ? $vars['page'] : '';
    $wiki = Factory::Wiki($page);
    if (!$wiki->isEditable()) {
        Utility::dieMessage('You have not permission to edit this page.');
    }
    if (!is_page($page) && Auth::is_check_role(PKWK_CREATE_PAGE)) {
        Utility::dieMessage(sprintf($_string['error_prohibit'], 'PKWK_CREATE_PAGE'));
    }
    global $guiedit_use_fck;
    $guiedit_use_fck = isset($vars['text']) ? false : true;
    if ($guiedit_use_fck) {
        global $guiedit_pkwk_root;
        $guiedit_pkwk_root = get_baseuri('abs');
    }
    if (GUIEDIT_FULL_SIZE) {
        $menubar = $sidebar = '';
        $topicpath = false;
    }
    if (isset($vars['edit'])) {
        return plugin_guiedit_edit_data($page);
    } else {
        if ($load_template_func && isset($vars['template'])) {
            return plugin_guiedit_template();
        } else {
            if (isset($vars['preview'])) {
                return plugin_guiedit_preview();
            } else {
                if (isset($vars['write'])) {
                    return plugin_guiedit_write();
                } else {
                    if (isset($vars['cancel'])) {
                        return plugin_guiedit_cancel();
                    }
                }
            }
        }
    }
    $postdata = $vars['original'] = $wiki->get(true);
    if (isset($vars['text'])) {
        if (!empty($vars['id'])) {
            exist_plugin('edit');
            $postdata = plugin_edit_parts($vars['id'], $source);
            if ($postdata === FALSE) {
                unset($vars['id']);
                $postdata = $vars['original'];
            }
        }
        if ($postdata == '') {
            $postdata = $wiki->auto_template();
        }
    }
    return array('msg' => 'GUI Edit', 'body' => plugin_guiedit_edit_form($page, $postdata));
}
Ejemplo n.º 2
0
function plugin_guiedit_action()
{
    // global $vars, $_title_edit, $load_template_func;
    global $vars, $load_template_func;
    global $menubar, $sidebar, $topicpath;
    // if (PKWK_READONLY) die_message( _('PKWK_READONLY prohibits editing') );
    if (auth::check_role('readonly')) {
        die_message(_('PKWK_READONLY prohibits editing'));
    }
    if (PKWK_READONLY == ROLE_AUTH && auth::get_role_level() > ROLE_AUTH) {
        die_message(_('PKWK_READONLY prohibits editing'));
    }
    $page = isset($vars['page']) ? $vars['page'] : '';
    check_editable($page, true, true);
    if (!is_page($page) && auth::is_check_role(PKWK_CREATE_PAGE)) {
        die_message(_('PKWK_CREATE_PAGE prohibits editing'));
    }
    global $guiedit_use_fck;
    $guiedit_use_fck = isset($vars['text']) ? false : true;
    if ($guiedit_use_fck) {
        global $guiedit_pkwk_root;
        $guiedit_pkwk_root = get_baseuri('abs');
    }
    if (GUIEDIT_FULL_SIZE) {
        $menubar = $sidebar = '';
        $topicpath = false;
    }
    if (isset($vars['edit'])) {
        return plugin_guiedit_edit_data($page);
    } else {
        if ($load_template_func && isset($vars['template'])) {
            return plugin_guiedit_template();
        } else {
            if (isset($vars['preview'])) {
                return plugin_guiedit_preview();
            } else {
                if (isset($vars['write'])) {
                    return plugin_guiedit_write();
                } else {
                    if (isset($vars['cancel'])) {
                        return plugin_guiedit_cancel();
                    }
                }
            }
        }
    }
    $source = get_source($page);
    $postdata = $vars['original'] = join('', $source);
    if (isset($vars['text'])) {
        if (!empty($vars['id'])) {
            exist_plugin('edit');
            $postdata = plugin_edit_parts($vars['id'], $source);
            if ($postdata === FALSE) {
                unset($vars['id']);
                $postdata = $vars['original'];
            }
        }
        if ($postdata == '') {
            $postdata = auto_template($page);
        }
    }
    return array('msg' => $_title_edit, 'body' => plugin_guiedit_edit_form($page, $postdata));
}