Exemple #1
0
 function _ensure_loaded($pagename)
 {
     global $request;
     $dbi = $request->getDbh();
     if (!$dbi->isWikiPage($pagename)) {
         require_once 'lib/loadsave.php';
         $request->setArg('source', FindFile('pgsrc/' . urlencode($pagename)));
         $request->setArg('overwrite', 1);
         LoadAny($request, $request->getArg('source'));
         $request->setArg('source', false);
     }
 }
Exemple #2
0
 function testSetupWiki()
 {
     global $request;
     purge_testbox();
     $dbi = $request->getDbh();
     $dbi->purgePage('HomePage');
     // possibly in cache
     $this->assertFalse($dbi->isWikiPage('HomePage'));
     $request->setArg('source', FindFile('pgsrc'));
     $request->setArg('overwrite', 1);
     LoadAny($request, $request->getArg('source'));
     $request->setArg('source', false);
     $request->setArg('overwrite', false);
     $this->assertTrue($dbi->isWikiPage('HomePage'));
 }
Exemple #3
0
/**
 * HomePage was not found so first-time install is supposed to run.
 * - import all pgsrc pages.
 * - Todo: installer interface to edit config/config.ini settings
 * - Todo: ask for existing old index.php to convert to config/config.ini
 * - Todo: theme-specific pages: 
 *   blog - HomePage, ADMIN_USER/Blogs
 */
function SetupWiki(&$request)
{
    global $GenericPages, $LANG;
    //FIXME: This is a hack (err, "interim solution")
    // This is a bogo-bogo-login:  Login without
    // saving login information in session state.
    // This avoids logging in the unsuspecting
    // visitor as "The PhpWiki programming team".
    //
    // This really needs to be cleaned up...
    // (I'm working on it.)
    $real_user = $request->_user;
    if (ENABLE_USER_NEW) {
        $request->_user = new _BogoUser(_("The PhpWiki programming team"));
    } else {
        $request->_user = new WikiUser($request, _("The PhpWiki programming team"), WIKIAUTH_BOGO);
    }
    StartLoadDump($request, _("Loading up virgin wiki"));
    echo "<dl>\n";
    $pgsrc = FindLocalizedFile(WIKI_PGSRC);
    $default_pgsrc = FindFile(DEFAULT_WIKI_PGSRC);
    $request->setArg('overwrite', true);
    if ($default_pgsrc != $pgsrc) {
        LoadAny($request, $default_pgsrc, $GenericPages);
    }
    $request->setArg('overwrite', false);
    LoadAny($request, $pgsrc);
    $dbi =& $request->_dbi;
    // Ensure that all mandatory pages are loaded
    $finder = new FileFinder();
    foreach (array_merge(explode(':', 'OldTextFormattingRules:TextFormattingRules:PhpWikiAdministration'), $GLOBALS['AllActionPages'], array(constant('HOME_PAGE'))) as $f) {
        $page = gettext($f);
        $epage = urlencode($page);
        if (!$dbi->isWikiPage($page)) {
            // translated version provided?
            if ($lf = FindLocalizedFile($pgsrc . $finder->_pathsep . $epage, 1)) {
                LoadAny($request, $lf);
            } else {
                // load english version of required action page
                LoadAny($request, FindFile(DEFAULT_WIKI_PGSRC . $finder->_pathsep . urlencode($f)));
                $page = $f;
            }
        }
        if (!$dbi->isWikiPage($page)) {
            trigger_error(sprintf("Mandatory file %s couldn't be loaded!", $page), E_USER_WARNING);
        }
    }
    echo "</dl>\n";
    EndLoadDump($request);
}
Exemple #4
0
/**
 * HomePage was not found so first-time install is supposed to run.
 * - import all pgsrc pages.
 * - Todo: installer interface to edit config/config.ini settings
 * - Todo: ask for existing old index.php to convert to config/config.ini
 * - Todo: theme-specific pages:
 *   blog - HomePage, ADMIN_USER/Blogs
 */
function SetupWiki(&$request)
{
    global $GenericPages, $LANG;
    //FIXME: This is a hack (err, "interim solution")
    // This is a bogo-bogo-login:  Login without
    // saving login information in session state.
    // This avoids logging in the unsuspecting
    // visitor as ADMIN_USER
    //
    // This really needs to be cleaned up...
    // (I'm working on it.)
    $real_user = $request->_user;
    if (ENABLE_USER_NEW) {
        $request->_user = new _BogoUser(ADMIN_USER);
    } else {
        $request->_user = new WikiUser($request, ADMIN_USER, WIKIAUTH_BOGO);
    }
    StartLoadDump($request, _("Loading up virgin wiki"));
    $pgsrc = FindLocalizedFile(WIKI_PGSRC);
    $default_pgsrc = FindFile(DEFAULT_WIKI_PGSRC);
    $request->setArg('overwrite', true);
    if ($default_pgsrc != $pgsrc) {
        LoadAny($request, $default_pgsrc, $GenericPages);
    }
    $request->setArg('overwrite', false);
    LoadAny($request, $pgsrc);
    $dbi =& $request->_dbi;
    // Ensure that all mandatory pages are loaded
    $finder = new FileFinder();
    if (!FUSIONFORGE) {
        $mandatory = explode(':', 'SandBox:Template/Category:Template/Talk:SpecialPages:CategoryCategory:CategoryActionPage:Help/OldTextFormattingRules:Help/TextFormattingRules:PhpWikiAdministration');
    } else {
        if (WIKI_NAME == "help") {
            $mandatory = explode(':', 'SandBox:Template/Category:Template/Talk:SpecialPages:CategoryCategory:CategoryActionPage:Help/TextFormattingRules:PhpWikiAdministration');
        } else {
            $mandatory = explode(':', 'SandBox:Template/UserPage:Template/Category:Template/Talk:SpecialPages:CategoryCategory:CategoryActionPage:TextFormattingRules:PhpWikiAdministration');
        }
    }
    foreach (array_merge($mandatory, $GLOBALS['AllActionPages'], array(constant('HOME_PAGE'))) as $f) {
        $page = gettext($f);
        $epage = urlencode($page);
        if (!$dbi->isWikiPage($page)) {
            // translated version provided?
            if ($lf = FindLocalizedFile($pgsrc . $finder->_pathsep . $epage, 1)) {
                LoadAny($request, $lf);
            } else {
                // load english version of required action page
                LoadAny($request, FindFile(DEFAULT_WIKI_PGSRC . $finder->_pathsep . urlencode($f)));
                $page = $f;
            }
        }
        if (!$dbi->isWikiPage($page)) {
            trigger_error(sprintf("Mandatory file %s couldn't be loaded!", $page), E_USER_WARNING);
        }
    }
    $pagename = _("InterWikiMap");
    $map = $dbi->getPage($pagename);
    $map->set('locked', true);
    PrintXML(HTML::p(HTML::em(WikiLink($pagename)), HTML::strong(" locked")));
    EndLoadDump($request);
}
Exemple #5
0
/**
 * TODO: check for the pgsrc_version number, not the revision mtime only
 */
function doPgsrcUpdate(&$request, $pagename, $path, $filename, $checkonly = false)
{
    $dbi = $request->getDbh();
    $page = $dbi->getPage($pagename);
    if ($page->exists()) {
        // check mtime: update automatically if pgsrc is newer
        $rev = $page->getCurrentRevision();
        $page_mtime = $rev->get('mtime');
        $data = implode("", file($path . "/" . $filename));
        if ($parts = ParseMimeifiedPages($data)) {
            usort($parts, 'SortByPageVersion');
            reset($parts);
            $pageinfo = $parts[0];
            $stat = stat($path . "/" . $filename);
            $new_mtime = @$pageinfo['versiondata']['mtime'];
            if (!$new_mtime) {
                $new_mtime = @$pageinfo['versiondata']['lastmodified'];
            }
            if (!$new_mtime) {
                $new_mtime = @$pageinfo['pagedata']['date'];
            }
            if (!$new_mtime) {
                $new_mtime = $stat[9];
            }
            if ($new_mtime > $page_mtime) {
                echo "{$path}/{$pagename}: ", _("newer than the existing page."), _(" replace "), "({$new_mtime} &gt; {$page_mtime})", "<br />\n";
                if (!$checkonly) {
                    LoadAny($request, $path . "/" . $filename);
                }
                echo "<br />\n";
            } else {
                /*echo "$path/$pagename: ",_("older than the existing page."),
                  _(" skipped"),".<br />\n";*/
            }
        } else {
            echo "{$path}/{$pagename}: ", "unknown format.", _(" skipped"), ".<br />\n";
        }
    } else {
        echo sprintf(_("%s does not exist"), $pagename), "<br />\n";
        if (!$checkonly) {
            LoadAny($request, $path . "/" . $filename);
        }
        echo "<br />\n";
    }
}
Exemple #6
0
 /**
  * TODO: check for the pgsrc_version number, not the revision mtime only
  */
 function doPgsrcUpdate($pagename, $path, $filename)
 {
     // don't ever update the HomePage
     if (defined(HOME_PAGE) and $pagename == HOME_PAGE or $pagename == _("HomePage") or $pagename == "HomePage") {
         echo "{$path}/{$pagename}: ", _("always skip the HomePage."), _(" Skipped"), ".<br />\n";
         return;
     }
     $page = $this->dbi->getPage($pagename);
     if ($page->exists()) {
         // check mtime: update automatically if pgsrc is newer
         $rev = $page->getCurrentRevision();
         $page_mtime = $rev->get('mtime');
         $data = implode("", file($path . "/" . $filename));
         if ($parts = ParseMimeifiedPages($data)) {
             usort($parts, 'SortByPageVersion');
             reset($parts);
             $pageinfo = $parts[0];
             $stat = stat($path . "/" . $filename);
             $new_mtime = 0;
             if (isset($pageinfo['versiondata']['mtime'])) {
                 $new_mtime = $pageinfo['versiondata']['mtime'];
             }
             if (!$new_mtime and isset($pageinfo['versiondata']['lastmodified'])) {
                 $new_mtime = $pageinfo['versiondata']['lastmodified'];
             }
             if (!$new_mtime and isset($pageinfo['pagedata']['date'])) {
                 $new_mtime = $pageinfo['pagedata']['date'];
             }
             if (!$new_mtime) {
                 $new_mtime = $stat[9];
             }
             if ($new_mtime > $page_mtime) {
                 echo "{$path}/{$pagename}: ", _("newer than the existing page."), _(" replace "), "({$new_mtime} &gt; {$page_mtime})", "<br />\n";
                 LoadAny($this->request, $path . "/" . $filename);
                 echo "<br />\n";
             } else {
                 echo "{$path}/{$pagename}: ", _("older than the existing page."), _(" Skipped"), ".<br />\n";
             }
         } else {
             echo "{$path}/{$pagename}: ", "unknown format.", _(" Skipped"), ".<br />\n";
         }
     } else {
         echo sprintf(_("%s does not exist"), $pagename), "<br />\n";
         LoadAny($this->request, $path . "/" . $filename);
         echo "<br />\n";
     }
 }
Exemple #7
0
/**
 * HomePage was not found so first-time install is supposed to run.
 * - import all pgsrc pages.
 * - Todo: installer interface to edit config/config.ini settings
 * - Todo: ask for existing old index.php to convert to config/config.ini
 * - Todo: theme-specific pages: 
 *   blog - HomePage, ADMIN_USER/Blogs
 */
function SetupWiki(&$request)
{
    global $GenericPages, $LANG;
    //FIXME: This is a hack (err, "interim solution")
    // This is a bogo-bogo-login:  Login without
    // saving login information in session state.
    // This avoids logging in the unsuspecting
    // visitor as "The PhpWiki programming team".
    //
    // This really needs to be cleaned up...
    // (I'm working on it.)
    $real_user = $request->_user;
    if (ENABLE_USER_NEW) {
        $request->_user = new _BogoUser(_("The PhpWiki programming team"));
    } else {
        $request->_user = new WikiUser($request, _("The PhpWiki programming team"), WIKIAUTH_BOGO);
    }
    // Get the localised wiki loading message
    $message = _("Loading up virgin wiki. Please wait until the end of the process, this will take few minutes.");
    StartLoadDump($request, $message);
    echo "<dl>\n";
    $pgsrc = FindLocalizedFile(WIKI_PGSRC);
    $default_pgsrc = FindFile(DEFAULT_WIKI_PGSRC);
    $request->setArg('overwrite', true);
    if ($default_pgsrc != $pgsrc) {
        LoadAny($request, $default_pgsrc, $GenericPages);
    }
    // Codendi - Commented-out the following line to make sure that wiki pages are properly instanciated
    // If the line is not commented, we randomly run into error messages like this at wiki init:
    // "...pagename has edit conflicts - skipped  (Merge Edit ) (Restore Anyway)"
    //$request->setArg('overwrite', false);
    LoadAny($request, $pgsrc);
    $dbi =& $request->_dbi;
    // Ensure that all mandatory pages are loaded
    $finder = new FileFinder();
    foreach (array_merge(explode(':', 'OldTextFormattingRules:TextFormattingRules:PhpWikiAdministration'), $GLOBALS['AllActionPages'], array(constant('HOME_PAGE'))) as $f) {
        $page = gettext($f);
        $epage = urlencode($page);
        if (!$dbi->isWikiPage($page)) {
            // translated version provided?
            if ($lf = FindLocalizedFile($pgsrc . $finder->_pathsep . $epage, 1)) {
                LoadAny($request, $lf);
            } else {
                // load english version of required action page
                LoadAny($request, FindFile(DEFAULT_WIKI_PGSRC . $finder->_pathsep . urlencode($f)));
                $page = $f;
            }
        }
        if (!$dbi->isWikiPage($page)) {
            trigger_error(sprintf("Mandatory file %s couldn't be loaded!", $page), E_USER_WARNING);
        }
        //WARNING  CODENDI CODE : give permissions to the administration pages of the wiki
        $pages = array("AdministrationDePhpWiki", "AdministrationDePhpWiki/Supprimer", "AdministrationDePhpWiki/Remplacer", "AdministrationDePhpWiki/Renommer", "PhpWikiAdministration", "PhpWikiAdministration/Replace", "PhpWikiAdministration/Remove", "PhpWikiAdministration/Rename");
        if (in_array($page, $pages)) {
            $group_id = $request->getArg('group_id');
            $wikiPage = new WikiPage($group_id, $page);
            $id = $wikiPage->getId();
            $pm = PermissionsManager::instance();
            $pm->addPermission('WIKIPAGE_READ', $id, $GLOBALS['UGROUP_PROJECT_ADMIN']);
            $pm->addPermission('WIKIPAGE_READ', $id, $GLOBALS['UGROUP_WIKI_ADMIN']);
        }
        //END WARNING
    }
    echo "</dl>\n";
    EndLoadDump($request);
}