/**
 * Prints the parameters that identify a particular wiki and could be used in view.php etc.
 * @param string $page Name of page (null for startpage)
 * @param object $subwiki Current subwiki object
 * @param object $cm Course-module object
 * @param int $type OUWIKI_PARAMS_xx constant
 */
function ouwiki_display_wiki_parameters($page, $subwiki, $cm, $type = OUWIKI_PARAMS_LINK)
{
    $output = ouwiki_get_parameter('id', $cm->id, $type);
    if (!$subwiki->defaultwiki) {
        if ($subwiki->groupid) {
            $output .= ouwiki_get_parameter('group', $subwiki->groupid, $type);
        }
        if ($subwiki->userid) {
            $output .= ouwiki_get_parameter('user', $subwiki->userid, $type);
        }
    }
    if (!is_null($page) && $page !== '') {
        $output .= ouwiki_get_parameter('page', $page, $type);
    }
    return $output;
}
示例#2
0
/**
 * Prints the parameters that identify a particular wiki and could be used in view.php etc.
 *
 * @param string $page Name of page (empty string for startpage)
 * @param object $subwiki Current subwiki object
 * @param object $cm Course-module object
 * @param int $type OUWIKI_PARAMS_xx constant
 * @return mixed Either array or string depending on type
 */
function ouwiki_display_wiki_parameters($page, $subwiki, $cm, $type = OUWIKI_PARAMS_LINK)
{
    if ($type == OUWIKI_PARAMS_ARRAY) {
        $output = array();
        $output['id'] = $cm->id;
    } else {
        $output = ouwiki_get_parameter('id', $cm->id, $type);
    }
    if (!$subwiki->defaultwiki) {
        if ($subwiki->groupid) {
            if ($type == OUWIKI_PARAMS_ARRAY) {
                $output['group'] = $subwiki->groupid;
            } else {
                $output .= ouwiki_get_parameter('group', $subwiki->groupid, $type);
            }
        }
        if ($subwiki->userid) {
            if ($type == OUWIKI_PARAMS_ARRAY) {
                $output['user'] = $subwiki->userid;
            } else {
                $output .= ouwiki_get_parameter('user', $subwiki->userid, $type);
            }
        }
    }
    if ($page !== '') {
        if ($type == OUWIKI_PARAMS_ARRAY) {
            $output['page'] = $page;
        } else {
            $output .= ouwiki_get_parameter('page', $page, $type);
        }
    }
    return $output;
}
if ($createnewpage) {
    if (trim($pagename) !== '') {
        if (get_field('ouwiki_pages', 'id', 'title', addslashes($pagename), 'subwikiid', $subwiki->id)) {
            print_error('duplicatepagetitle', 'ouwiki', 'view.php?' . ouwiki_display_wiki_parameters($originalpagename, $subwiki, $cm, OUWIKI_PARAMS_URL));
        }
    } else {
        // blank page title
        print_error('emptypagetitle', 'ouwiki', 'view.php?' . ouwiki_display_wiki_parameters($originalpagename, $subwiki, $cm, OUWIKI_PARAMS_URL));
    }
    $wikiformfields .= ouwiki_get_parameter('originalpagename', $originalpagename, OUWIKI_PARAMS_FORM);
    // Get the current page version, creating page if needed
    $pageversion = ouwiki_get_current_page($subwiki, $originalpagename, OUWIKI_GETPAGE_CREATE);
    $pageversion->xhtml = '';
} else {
    if ($addnewsection) {
        $wikiformfields .= ouwiki_get_parameter('newsectionname', $newsectionname, OUWIKI_PARAMS_FORM);
    } else {
        // Get the current page version, creating page if needed
        $pageversion = ouwiki_get_current_page($subwiki, $pagename, OUWIKI_GETPAGE_CREATE);
    }
    // endif
}
// endif
// is the page locked
if ($pageversion->locked === '1') {
    print_error('thispageislocked', 'ouwiki', 'view.php?id=' . $cm->id);
}
// Need list of known sections on current version
$knownsections = ouwiki_find_sections($pageversion->xhtml);
// Get section, make sure the name is valid
$section = optional_param('section', '', PARAM_RAW);