If the page existed before, returns its data. If not, initializes %Page for this now-being-created page.
Keeps value of $OpenPageName in synch with id passed as $id.
Commented version below
sub OpenPage { my ($id) = @_; my ($fname, $data);
# If page being asked to open is already the page we're on, # then do nothing. ($OpenPageName = "currently open page") if ($OpenPageName eq $id) { return; }
%Section = (); %Text = ();
# Get the database file name for the page $fname = &GetPageFile($id);
# If the database file for the page exists, then return a global hash called
# %Page, which stores the page's data (in the internal wiki data format)
if (-f $fname) {
$data = &ReadFileOrDie($fname);
%Page = split(/$FS1/, $data, -1); # -1 keeps trailing null fields ($FS1 and
# $FS2 are 'field seperator' characters)
# Otherwise, there _is_ no file by that name, so we just want
# to start one--so, initialize values for %Page right now
} else {
&OpenNewPage($id);
}
# Raise an error if the internal data file format is
# not in synch with that this script is expecting
if ($Page{'version'} != 3) {
&UpdatePageVersion();
}
# Set the global for current open page name to # the parameter that was passed to this function $OpenPageName = $id; }