UseModWiki | RecentChanges | Preferences

Sets global data hash %Page to correspond to the page id passed as $id.

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

-- ChrisBurbridge

 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) {

   %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 {

   # Raise an error if the internal data file format is
   # not in synch with that this script is expecting
   if ($Page{'version'} != 3) {

   # Set the global for current open page name to 
   # the parameter that was passed to this function
   $OpenPageName = $id;

Called by

UseModWiki | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited January 4, 2009 1:52 am by ppp-70-129-167-206.dsl.hstntx.swbell.net (diff)