Beispiel #1
0
/**
 * Wiki for phpWebSite
 *
 * See docs/CREDITS for copyright information
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * @package Wiki
 * @author Greg Meiste <*****@*****.**>
 */
function wiki_install(&$content)
{
    PHPWS_Core::initModClass('wiki', 'WikiManager.php');
    PHPWS_Core::initModClass('wiki', 'WikiPage.php');
    PHPWS_Core::initModClass('version', 'Version.php');
    // Adding pages that ship with the module
    if (file_exists(PHPWS_SOURCE_DIR . 'mod/wiki/boost/frontpage.txt')) {
        $frontpage = new WikiPage('FrontPage');
        $frontpage->setPagetext(implode('', file(PHPWS_SOURCE_DIR . 'mod/wiki/boost/frontpage.txt')));
        $frontpage->setOwnerId(Current_User::getId());
        $frontpage->setEditorId(Current_User::getId());
        $frontpage->setCreated(mktime());
        $frontpage->setUpdated(mktime());
        $frontpage->setComment('Provided by Wiki install');
        $frontpage->save();
        $version1 = new Version('wiki_pages');
        $version1->setSource($frontpage);
        $version1->setApproved(1);
        $version1->save();
    }
    if (file_exists(PHPWS_SOURCE_DIR . 'mod/wiki/boost/samplepage.txt')) {
        $samplepage = new WikiPage('SamplePage');
        $samplepage->setPagetext(implode('', file(PHPWS_SOURCE_DIR . 'mod/wiki/boost/samplepage.txt')));
        $samplepage->setOwnerId(Current_User::getId());
        $samplepage->setEditorId(Current_User::getId());
        $samplepage->setCreated(mktime());
        $samplepage->setUpdated(mktime());
        $samplepage->setComment('Provided by Wiki install');
        $samplepage->allow_edit = 0;
        $samplepage->save();
        $version2 = new Version('wiki_pages');
        $version2->setSource($samplepage);
        $version2->setApproved(1);
        $version2->save();
    }
    if (file_exists(PHPWS_SOURCE_DIR . 'mod/wiki/boost/sandbox.txt')) {
        $sandbox = new WikiPage('WikiSandBox');
        $sandbox->setPagetext(implode('', file(PHPWS_SOURCE_DIR . 'mod/wiki/boost/sandbox.txt')));
        $sandbox->setOwnerId(Current_User::getId());
        $sandbox->setEditorId(Current_User::getId());
        $sandbox->setCreated(mktime());
        $sandbox->setUpdated(mktime());
        $sandbox->setComment('Provided by Wiki install');
        $sandbox->save();
        $version3 = new Version('wiki_pages');
        $version3->setSource($sandbox);
        $version3->setApproved(1);
        $version3->save();
    }
    // Adding first interwiki link
    PHPWS_Core::initModClass('wiki', 'InterWiki.php');
    $interwiki = new InterWiki();
    $interwiki->setLabel('Wikipedia');
    $interwiki->setUrl('http://en.wikipedia.org/wiki/%s');
    $interwiki->save(FALSE);
    return TRUE;
}
Beispiel #2
0
 /**
  * Action
  *
  * @author Greg Meiste <*****@*****.**>
  */
 function action()
 {
     Layout::addStyle('wiki');
     if (!PHPWS_Settings::get('wiki', 'allow_anon_view') && !Current_User::isLogged()) {
         Current_User::requireLogin();
         return;
     }
     if (isset($_REQUEST['page_id']) && is_numeric($_REQUEST['page_id'])) {
         PHPWS_Core::initModClass('wiki', 'WikiPage.php');
         $wikipage = new WikiPage($_REQUEST['page_id']);
     } else {
         if (isset($_REQUEST['page']) && is_string($_REQUEST['page'])) {
             PHPWS_Core::initModClass('wiki', 'WikiPage.php');
             $wikipage = new WikiPage($_REQUEST['page']);
         }
     }
     if (!isset($_REQUEST['op']) && !isset($_REQUEST['page_op'])) {
         // phpWebSite 1.5.0 and later mod_rewrite method
         if (isset($_GET['var1'])) {
             $_REQUEST['id'] = $_GET['id'] = $_GET['var1'];
         }
         if (isset($_REQUEST['id']) && is_string($_REQUEST['id'])) {
             PHPWS_Core::initModClass('wiki', 'WikiPage.php');
             $wikipage = new WikiPage($_REQUEST['id']);
         }
         $_REQUEST['page_op'] = 'view';
     }
     WikiManager::addToMiniAdmin();
     if (isset($_REQUEST['page_op']) && isset($wikipage)) {
         $wikipage->action();
         return;
     }
     switch (@$_REQUEST['op']) {
         case 'admin':
         case 'savesettings':
             PHPWS_Core::initModClass('wiki', 'WikiSettings.php');
             WikiSettings::admin();
             break;
         case 'doimagedelete':
         case 'doimageupload':
         case 'imageupload':
             WikiManager::imageUpload();
             break;
         case 'imagedelete':
             PHPWS_Core::initModClass('wiki', 'WikiImage.php');
             $delImage = new WikiImage($_REQUEST['id']);
             $template['TITLE'] = dgettext('wiki', 'Wiki Images');
             $template['CONTENT'] = $delImage->delete();
             Layout::add(PHPWS_Template::process($template, 'wiki', 'box.tpl'), 'wiki', 'wiki_mod', TRUE);
             break;
         case 'imagecopy':
             PHPWS_Core::initModClass('wiki', 'WikiImage.php');
             $image = new WikiImage($_REQUEST['id']);
             Clipboard::copy($image->getFilename(), $image->getTag());
             PHPWS_Core::goBack();
             break;
         case 'recentchanges':
             $template['TITLE'] = dgettext('wiki', 'Recent changes');
             $template['CONTENT'] = WikiManager::recentChanges();
             Layout::add(PHPWS_Template::process($template, 'wiki', 'box.tpl'), 'wiki', 'wiki_mod', TRUE);
             break;
         case 'random':
             WikiManager::random();
             break;
         case 'interwikisetup':
         case 'addinterwiki':
             PHPWS_Core::initModClass('wiki', 'InterWiki.php');
             $interwiki = new InterWiki();
             $interwiki->setup();
             break;
         case 'editinterwiki':
         case 'saveinterwiki':
         case 'deleteinterwiki':
         case 'dodeleteinterwiki':
             PHPWS_Core::initModClass('wiki', 'InterWiki.php');
             $interwiki = new InterWiki($_REQUEST['id']);
             $interwiki->setup();
             break;
         case 'copyinterwiki':
             PHPWS_Core::initModClass('wiki', 'InterWiki.php');
             $interwiki = new InterWiki($_REQUEST['id']);
             Clipboard::copy($interwiki->getLabel(), $interwiki->getLabel() . ':PageName');
             PHPWS_Core::goBack();
             break;
         default:
             $_REQUEST['page'] = PHPWS_Settings::get('wiki', 'default_page');
             WikiManager::action();
     }
 }
Beispiel #3
0
function convertInterwiki($interwiki)
{
    PHPWS_Core::initModClass('wiki', 'WikiManager.php');
    PHPWS_Core::initModClass('wiki', 'InterWiki.php');
    $newinterwiki = new InterWiki();
    $newinterwiki->setLabel($interwiki['label']);
    $newinterwiki->setUrl($interwiki['url']);
    $newinterwiki->save(FALSE);
    return TRUE;
}