Example #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;
}
Example #2
0
 function doMove()
 {
     if (!Current_User::authorized('wiki', 'edit_page') && !(PHPWS_Settings::get('wiki', 'allow_page_edit') && Current_User::isLogged()) || !$this->allow_edit) {
         Current_User::disallow(dgettext('wiki', 'User attempted to execute a wiki page move.'));
         return;
     }
     if (strlen($_POST['newpage']) == 0) {
         WikiManager::sendMessage(dgettext('wiki', 'Please supply a new page title'), array('page_op' => 'move', 'page' => $this->getTitle(FALSE)));
     }
     $db = new PHPWS_DB('wiki_pages');
     $db->addWhere('title', $_POST['newpage']);
     $result = $db->select();
     if ($result != NULL) {
         WikiManager::sendMessage(dgettext('wiki', 'Page with that name already exists!'), array('page_op' => 'move', 'page' => $this->getTitle(FALSE)));
     }
     $this->setTitle($_POST['newpage']);
     $db->reset();
     $db->saveObject($this);
     $db2 = new PHPWS_DB('wiki_pages_version');
     $db2->addWhere('title', $_POST['page']);
     $db2->addValue('title', $this->getTitle(FALSE));
     $db2->update();
     $db3 = new PHPWS_DB('phpws_key');
     $db3->addWhere('item_id', $this->getId());
     $db3->addWhere('module', 'wiki');
     $db3->addValue('title', $this->getTitle());
     $db3->addValue('url', (MOD_REWRITE_ENABLED ? 'wiki/' : 'index.php?module=wiki&page=') . $this->getTitle(FALSE));
     $db3->update();
     // Create redirect page
     $redirect = new WikiPage($_POST['page']);
     $redirect->setPagetext(sprintf(dgettext('wiki', 'This page has moved to %s.  Please modify links to point to the new location.'), $this->getTitle(FALSE)));
     $redirect->setOwnerId(Current_User::getId());
     $redirect->setEditorId(Current_User::getId());
     $redirect->setCreated(mktime());
     $redirect->setUpdated(mktime());
     $redirect->setComment(sprintf(dgettext('wiki', 'Moved page to %s.'), $this->getTitle(FALSE)));
     $redirect->save();
     PHPWS_Core::initModClass('version', 'Version.php');
     $version = new Version('wiki_pages');
     $version->setSource($redirect);
     $version->setApproved(1);
     $version->save();
     WikiManager::sendMessage(dgettext('wiki', 'Wiki Page Moved!'), array('page' => $this->getTitle(FALSE)), FALSE);
 }
Example #3
0
function convertPage($page)
{
    PHPWS_Core::initModClass('wiki', 'WikiManager.php');
    PHPWS_Core::initModClass('wiki', 'WikiPage.php');
    PHPWS_Core::initModClass('version', 'Version.php');
    PHPWS_Core::initModClass('search', 'Search.php');
    $newpage = new WikiPage($page['label']);
    $newpage->setPagetext($page['pagetext']);
    $newpage->setOwnerId(Current_User::getId());
    $newpage->setEditorId(Current_User::getId());
    $newpage->setCreated($page['created']);
    $newpage->setUpdated(mktime());
    $newpage->setComment(dgettext('wiki', 'Converted from previous wiki install'));
    $newpage->allow_edit = $page['allow_edit'];
    $result = $newpage->save();
    if (PEAR::isError($result)) {
        PHPWS_Error::log($result);
        return FALSE;
    }
    $version = new Version('wiki_pages');
    $version->setSource($newpage);
    $version->setApproved(1);
    $version->save();
    return TRUE;
}