Esempio n. 1
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();
     }
 }