• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wfResetOutputBuffers函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wfResetOutputBuffers函数的典型用法代码示例。如果您正苦于以下问题:PHP wfResetOutputBuffers函数的具体用法?PHP wfResetOutputBuffers怎么用?PHP wfResetOutputBuffers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wfResetOutputBuffers函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: wfStreamFile

/** */
function wfStreamFile($fname)
{
    $stat = @stat($fname);
    if (!$stat) {
        header('HTTP/1.0 404 Not Found');
        header('Cache-Control: no-cache');
        header('Content-Type: text/html; charset=utf-8');
        $encFile = htmlspecialchars($fname);
        $encScript = htmlspecialchars($_SERVER['SCRIPT_NAME']);
        echo "<html><body>\n<h1>File not found</h1>\n<p>Although this PHP script ({$encScript}) exists, the file requested for output \n({$encFile}) does not.</p>\n</body></html>\n";
        return;
    }
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $stat['mtime']) . ' GMT');
    // Cancel output buffering and gzipping if set
    wfResetOutputBuffers();
    $type = wfGetType($fname);
    if ($type and $type != "unknown/unknown") {
        header("Content-type: {$type}");
    } else {
        header('Content-type: application/x-wiki');
    }
    if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
        $modsince = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']);
        $sinceTime = strtotime($modsince);
        if ($stat['mtime'] <= $sinceTime) {
            header("HTTP/1.0 304 Not Modified");
            return;
        }
    }
    header('Content-Length: ' . $stat['size']);
    readfile($fname);
}
开发者ID:negabaro,项目名称:alfresco,代码行数:33,代码来源:StreamFile.php


示例2: csvOutput

 function csvOutput($res)
 {
     global $wgOut, $wgRequest;
     $ts = wfTimestampNow();
     $filename = "community_applications_{$ts}.csv";
     $wgOut->disable();
     wfResetOutputBuffers();
     $wgRequest->response()->header("Content-disposition: attachment;filename={$filename}");
     $wgRequest->response()->header("Content-type: text/csv; charset=utf-8");
     $fh = fopen('php://output', 'w');
     $fields = null;
     foreach ($res as $row) {
         $data = FormatJson::decode($row->ch_data, true);
         $data = array('id' => $row->ch_id) + $data;
         if (!is_array($fields)) {
             $fields = array_keys($data);
             fputcsv($fh, $fields);
         }
         $outData = array();
         foreach ($fields as $k) {
             $outData[] = isset($data[$k]) ? $data[$k] : null;
             unset($data[$k]);
         }
         foreach ($data as $k => $v) {
             $outData[] = "{$k}: {$v}";
         }
         fputcsv($fh, $outData);
     }
     fclose($fh);
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:30,代码来源:SpecialCommunityApplications.php


示例3: streamAppleTouch

function streamAppleTouch()
{
    global $wgAppleTouchIcon;
    wfResetOutputBuffers();
    if ($wgAppleTouchIcon === false) {
        # That's not very helpful, that's where we are already
        header('HTTP/1.1 404 Not Found');
        faviconShowError('$wgAppleTouchIcon is configured incorrectly, ' . 'it must be set to something other than false \\n');
        return;
    }
    $req = RequestContext::getMain()->getRequest();
    if ($req->getHeader('X-Favicon-Loop') !== false) {
        header('HTTP/1.1 500 Internal Server Error');
        faviconShowError('Proxy forwarding loop detected');
        return;
    }
    $url = wfExpandUrl($wgAppleTouchIcon, PROTO_CANONICAL);
    $client = MWHttpRequest::factory($url);
    $client->setHeader('X-Favicon-Loop', '1');
    $status = $client->execute();
    if (!$status->isOK()) {
        header('HTTP/1.1 500 Internal Server Error');
        faviconShowError("Failed to fetch URL \"{$url}\"");
        return;
    }
    $content = $client->getContent();
    header('Content-Length: ' . strlen($content));
    header('Content-Type: ' . $client->getResponseHeader('Content-Type'));
    header('Cache-Control: public');
    header('Expires: ' . gmdate('r', time() + 86400));
    echo $content;
}
开发者ID:nomoa,项目名称:operations-mediawiki-config,代码行数:32,代码来源:touch.php


示例4: execute

 function execute($par)
 {
     global $wgMemc;
     $tempToken = $this->getRequest()->getVal('token');
     $logout = $this->getRequest()->getBool('logout');
     # Don't cache error messages
     $this->getOutput()->enableClientCache(false);
     if (strlen($tempToken) == 0) {
         $this->setHeaders();
         $this->getOutput()->addWikiMsg('centralauth-autologin-desc');
         return;
     }
     $key = CentralAuthUser::memcKey('login-token', $tempToken);
     $data = $wgMemc->get($key);
     $wgMemc->delete($key);
     if (!$data) {
         $msg = 'Token is invalid or has expired';
         wfDebug(__METHOD__ . ": {$msg}\n");
         $this->setHeaders();
         $this->getOutput()->addWikiText($msg);
         return;
     }
     $userName = $data['userName'];
     $token = $data['token'];
     $remember = $data['remember'];
     if ($data['wiki'] != wfWikiID()) {
         $msg = 'Bad token (wrong wiki)';
         wfDebug(__METHOD__ . ": {$msg}\n");
         $this->setHeaders();
         $this->getOutput()->addWikiText($msg);
         return;
     }
     $centralUser = new CentralAuthUser($userName);
     $loginResult = $centralUser->authenticateWithToken($token);
     if ($loginResult != 'ok') {
         $msg = "Bad token: {$loginResult}";
         wfDebug(__METHOD__ . ": {$msg}\n");
         $this->setHeaders();
         $this->getOutput()->addWikiText($msg);
         return;
     }
     // Auth OK.
     if ($logout) {
         $centralUser->deleteGlobalCookies();
     } else {
         $centralUser->setGlobalCookies($remember);
     }
     $this->getOutput()->disable();
     wfResetOutputBuffers();
     header('Cache-Control: no-cache');
     header('Content-Type: image/png');
     global $wgCentralAuthLoginIcon;
     if ($wgCentralAuthLoginIcon) {
         readfile($wgCentralAuthLoginIcon);
     } else {
         readfile(dirname(__FILE__) . '/1x1.png');
     }
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:58,代码来源:SpecialAutoLogin.php


示例5: execute

 function execute($par)
 {
     global $wgOut;
     $this->setHideCookie();
     $wgOut->disable();
     wfResetOutputBuffers();
     header('Content-Type: image/png');
     header('Cache-Control: no-cache');
     readfile(dirname(__FILE__) . '/../1x1.png');
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:10,代码来源:SpecialHideBanners.php


示例6: getImage

 /**
  * getImage method
  *
  */
 public function getImage()
 {
     wfProfileIn(__METHOD__);
     if ($this->wg->User->isLoggedIn()) {
         # make proper thumb path: c/central/images/thumb/....
         $path = sprintf("%s/%s/images", substr($this->wg->DBname, 0, 1), $this->wg->DBname);
         # take thumb request from request
         $img = $this->getVal('image');
         if (preg_match('/^(\\/?)thumb\\//', $img)) {
             # build proper thumb url for thumbnailer
             $thumb_url = sprintf("%s/%s/%s", $this->wg->ThumbnailerService, $path, $img);
             # call thumbnailer
             $options = array('method' => 'GET', 'timeout' => 'default', 'noProxy' => 1);
             $thumb_request = MWHttpRequest::factory($thumb_url, $options);
             $status = $thumb_request->execute();
             $headers = $thumb_request->getResponseHeaders();
             if ($status->isOK()) {
                 if (!empty($headers)) {
                     foreach ($headers as $header_name => $header_value) {
                         if (is_array($header_value)) {
                             list($value) = $header_value;
                         } else {
                             $value = $header_value;
                         }
                         header(sprintf("%s: %s", $header_name, $value));
                     }
                 }
                 echo $thumb_request->getContent();
             } else {
                 wfdebug("Cannot generate auth thumb");
                 $this->_access_forbidden('img-auth-accessdenied', 'img-auth-nofile', $img);
             }
         } else {
             # serve original image
             $filename = realpath(sprintf("%s/%s", $this->wg->UploadDirectory, $img));
             $stat = @stat($filename);
             if ($stat) {
                 wfResetOutputBuffers();
                 $fileinfo = finfo_open(FILEINFO_MIME_TYPE);
                 $imageType = finfo_file($fileinfo, $filename);
                 header(sprintf("Content-Disposition: inline;filename*=utf-8'%s'%s", $this->wg->ContLanguageCode, urlencode(basename($filename))));
                 header(sprintf("Content-Type: %s", $imageType));
                 header(sprintf("Content-Length: %d" . $stat['size']));
                 readfile($filename);
             } else {
                 $this->_access_forbidden('img-auth-accessdenied', 'img-auth-nopathinfo', $img);
             }
         }
     } else {
         $this->_access_forbidden('img-auth-accessdenied', 'img-auth-public', '');
     }
     wfProfileOut(__METHOD__);
     exit;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:58,代码来源:AuthImageSpecialPageController.class.php


示例7: prepareForStream

 /**
  * Call this function used in preparation before streaming a file.
  * This function does the following:
  * (a) sends Last-Modified, Content-type, and Content-Disposition headers
  * (b) cancels any PHP output buffering and automatic gzipping of output
  * (c) sends Content-Length header based on HTTP_IF_MODIFIED_SINCE check
  *
  * @param $path string Storage path or file system path
  * @param $info Array|false File stat info with 'mtime' and 'size' fields
  * @param $headers Array Additional headers to send
  * @param $sendErrors bool Send error messages if errors occur (like 404)
  * @return int|false READY_STREAM, NOT_MODIFIED, or false on failure
  */
 public static function prepareForStream($path, $info, $headers = array(), $sendErrors = true)
 {
     global $wgLanguageCode;
     if (!is_array($info)) {
         if ($sendErrors) {
             header('HTTP/1.0 404 Not Found');
             header('Cache-Control: no-cache');
             header('Content-Type: text/html; charset=utf-8');
             $encFile = htmlspecialchars($path);
             $encScript = htmlspecialchars($_SERVER['SCRIPT_NAME']);
             echo "<html><body>\n\t\t\t\t\t<h1>File not found</h1>\n\t\t\t\t\t<p>Although this PHP script ({$encScript}) exists, the file requested for output\n\t\t\t\t\t({$encFile}) does not.</p>\n\t\t\t\t\t</body></html>\n\t\t\t\t\t";
         }
         return false;
     }
     // Sent Last-Modified HTTP header for client-side caching
     header('Last-Modified: ' . wfTimestamp(TS_RFC2822, $info['mtime']));
     // Cancel output buffering and gzipping if set
     wfResetOutputBuffers();
     $type = self::contentTypeFromPath($path);
     if ($type && $type != 'unknown/unknown') {
         header("Content-type: {$type}");
     } else {
         // Send a content type which is not known to Internet Explorer, to
         // avoid triggering IE's content type detection. Sending a standard
         // unknown content type here essentially gives IE license to apply
         // whatever content type it likes.
         header('Content-type: application/x-wiki');
     }
     // Don't stream it out as text/html if there was a PHP error
     if (headers_sent()) {
         echo "Headers already sent, terminating.\n";
         return false;
     }
     header("Content-Disposition: inline;filename*=utf-8'{$wgLanguageCode}'" . urlencode(basename($path)));
     // Send additional headers
     foreach ($headers as $header) {
         header($header);
     }
     // Don't send if client has up to date cache
     if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
         $modsince = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']);
         if (wfTimestamp(TS_UNIX, $info['mtime']) <= strtotime($modsince)) {
             ini_set('zlib.output_compression', 0);
             header("HTTP/1.0 304 Not Modified");
             return self::NOT_MODIFIED;
             // ok
         }
     }
     header('Content-Length: ' . $info['size']);
     return self::READY_STREAM;
     // ok
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:65,代码来源:StreamFile.php


示例8: wfProtectAdminNamespace

function wfProtectAdminNamespace(Parser $parser)
{
    global $wgTitle, $wgUser, $wgOut, $mediaWiki;
    if (is_object($wgTitle) && $wgTitle->getNamespace() == NS_ADMIN && !in_array('bureaucrat', $wgUser->getEffectiveGroups())) {
        if (is_object($mediaWiki)) {
            $mediaWiki->restInPeace();
        }
        $wgOut->disable();
        wfResetOutputBuffers();
        header("Location: http://wiki.ligmincha.org/");
    }
    return true;
}
开发者ID:uinerd,项目名称:Code,代码行数:13,代码来源:LigminchaInternationalSettings.php


示例9: setup

 public function setup()
 {
     global $wgOut, $wgResourceModules, $wgAutoloadClasses, $wgExtensionAssetsPath, $IP, $wgUser, $wgAjaxCommentsPollServer, $wgAjaxCommentsLikeDislike, $wgAjaxCommentsCopyTalkpages, $wgAjaxCommentsAdmins;
     // Determine if the current user is an admin for comments
     self::$admin = count(array_intersect($wgAjaxCommentsAdmins, $wgUser->getEffectiveGroups())) > 0;
     // If options set, hook into the new revisions to change talk page additions to ajaxcomments
     if ($wgAjaxCommentsCopyTalkpages) {
         Hooks::register('PageContentSave', $this);
     }
     // Create a hook to allow external condition for whether there should be comments shown
     $title = array_key_exists('title', $_GET) ? Title::newFromText($_GET['title']) : false;
     if (!array_key_exists('action', $_REQUEST) && self::checkTitle($title)) {
         Hooks::register('BeforePageDisplay', $this);
     } else {
         $wgAjaxCommentsPollServer = -1;
     }
     // Create a hook to allow external condition for whether comments can be added or replied to (default is just user logged in)
     $this->canComment = $wgUser->isLoggedIn();
     Hooks::run('AjaxCommentsCheckWritable', array($title, &$this->canComment));
     // Redirect talk pages with AjaxComments to the comments
     if (is_object($title) && $title->getNamespace() > 0 && $title->getNamespace() & 1) {
         $ret = true;
         Hooks::run('AjaxCommentsCheckTitle', array($userpage, &$ret));
         if ($ret) {
             $userpage = Title::newFromText($title->getText(), $title->getNamespace() - 1);
             global $mediaWiki;
             if (is_object($mediaWiki)) {
                 $mediaWiki->restInPeace();
             }
             $wgOut->disable();
             wfResetOutputBuffers();
             $url = $userpage->getLocalUrl();
             header("Location: {$url}#ajaxcomments");
             wfDebugLog(__CLASS__, "Redirecting to {$url}");
             exit;
         }
     }
     // This gets the remote path even if it's a symlink (MW1.25+)
     $path = $wgExtensionAssetsPath . str_replace("{$IP}/extensions", '', dirname($wgAutoloadClasses[__CLASS__]));
     $wgResourceModules['ext.ajaxcomments']['remoteExtPath'] = $path;
     $wgOut->addModules('ext.ajaxcomments');
     $wgOut->addStyle("{$path}/styles/ajaxcomments.css");
     // Add config vars to client side
     $wgOut->addJsConfigVars('ajaxCommentsPollServer', $wgAjaxCommentsPollServer);
     $wgOut->addJsConfigVars('ajaxCommentsCanComment', $this->canComment);
     $wgOut->addJsConfigVars('ajaxCommentsLikeDislike', $wgAjaxCommentsLikeDislike);
     $wgOut->addJsConfigVars('ajaxCommentsAdmin', self::$admin);
 }
开发者ID:saper,项目名称:organic-extensions,代码行数:48,代码来源:AjaxComments.class.php


示例10: wfStreamFile

/**
 * @param $fname string
 * @param $headers array
 */
function wfStreamFile($fname, $headers = array())
{
    wfSuppressWarnings();
    $stat = stat($fname);
    wfRestoreWarnings();
    if (!$stat) {
        header('HTTP/1.0 404 Not Found');
        header('Cache-Control: no-cache');
        header('Content-Type: text/html; charset=utf-8');
        $encFile = htmlspecialchars($fname);
        $encScript = htmlspecialchars($_SERVER['SCRIPT_NAME']);
        echo "<html><body>\n<h1>File not found</h1>\n<p>Although this PHP script ({$encScript}) exists, the file requested for output\n({$encFile}) does not.</p>\n</body></html>\n";
        return;
    }
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $stat['mtime']) . ' GMT');
    // Cancel output buffering and gzipping if set
    wfResetOutputBuffers();
    $type = wfGetType($fname);
    if ($type and $type != "unknown/unknown") {
        header("Content-type: {$type}");
    } else {
        header('Content-type: application/x-wiki');
    }
    // Don't stream it out as text/html if there was a PHP error
    if (headers_sent()) {
        echo "Headers already sent, terminating.\n";
        return;
    }
    global $wgLanguageCode;
    header("Content-Disposition: inline;filename*=utf-8'{$wgLanguageCode}'" . urlencode(basename($fname)));
    foreach ($headers as $header) {
        header($header);
    }
    if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
        $modsince = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']);
        $sinceTime = strtotime($modsince);
        if ($stat['mtime'] <= $sinceTime) {
            ini_set('zlib.output_compression', 0);
            header("HTTP/1.0 304 Not Modified");
            return;
        }
    }
    header('Content-Length: ' . $stat['size']);
    readfile($fname);
}
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:49,代码来源:StreamFile.php


示例11: wfStreamFile

/** */
function wfStreamFile($fname, $headers = array())
{
    $stat = @stat($fname);
    if (!$stat) {
        header('HTTP/1.0 404 Not Found');
        header('Cache-Control: no-cache');
        header('Content-Type: text/html; charset=utf-8');
        $encFile = htmlspecialchars($fname);
        $encScript = htmlspecialchars($_SERVER['SCRIPT_NAME']);
        echo "<html><body>\n<h1>File not found</h1>\n<p>Although this PHP script ({$encScript}) exists, the file requested for output \n({$encFile}) does not.</p>\n</body></html>\n";
        return;
    }
    header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $stat['mtime']) . ' GMT');
    // Cancel output buffering and gzipping if set
    wfResetOutputBuffers();
    $type = wfGetType($fname);
    if ($type and $type != "unknown/unknown") {
        header("Content-type: {$type}");
    } else {
        header('Content-type: application/x-wiki');
    }
    global $wgContLanguageCode;
    header("Content-Disposition: inline;filename*=utf-8'{$wgContLanguageCode}'" . urlencode(basename($fname)));
    foreach ($headers as $header) {
        header($header);
    }
    if (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
        $modsince = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']);
        $sinceTime = strtotime($modsince);
        if ($stat['mtime'] <= $sinceTime) {
            header("HTTP/1.0 304 Not Modified");
            return;
        }
    }
    $h = "";
    foreach ($stat as $k => $v) {
        $h .= "{$k}={$v},";
    }
    header('Content-Length: ' . $stat['size']);
    header('X-stat-results: ' . $h);
    header('X-Serving-host: ' . wfHostname());
    header('Content-Length-true: ' . $stat['size']);
    readfile($fname);
}
开发者ID:ErdemA,项目名称:wikihow,代码行数:45,代码来源:StreamFile.php


示例12: wfSpecialExport

/**
 *
 */
function wfSpecialExport($page = '')
{
    global $wgOut, $wgRequest, $wgSitename, $wgExportAllowListContributors;
    global $wgExportAllowHistory, $wgExportMaxHistory;
    $curonly = true;
    $doexport = false;
    if ($wgRequest->getCheck('addcat')) {
        $page = $wgRequest->getText('pages');
        $catname = $wgRequest->getText('catname');
        if ($catname !== '' && $catname !== NULL && $catname !== false) {
            $t = Title::makeTitleSafe(NS_MAIN, $catname);
            if ($t) {
                /**
                 * @fixme This can lead to hitting memory limit for very large
                 * categories. Ideally we would do the lookup synchronously
                 * during the export in a single query.
                 */
                $catpages = wfExportGetPagesFromCategory($t);
                if ($catpages) {
                    $page .= "\n" . implode("\n", $catpages);
                }
            }
        }
    } else {
        if ($wgRequest->wasPosted() && $page == '') {
            $page = $wgRequest->getText('pages');
            $curonly = $wgRequest->getCheck('curonly');
            $rawOffset = $wgRequest->getVal('offset');
            if ($rawOffset) {
                $offset = wfTimestamp(TS_MW, $rawOffset);
            } else {
                $offset = null;
            }
            $limit = $wgRequest->getInt('limit');
            $dir = $wgRequest->getVal('dir');
            $history = array('dir' => 'asc', 'offset' => false, 'limit' => $wgExportMaxHistory);
            $historyCheck = $wgRequest->getCheck('history');
            if ($curonly) {
                $history = WikiExporter::CURRENT;
            } elseif (!$historyCheck) {
                if ($limit > 0 && $limit < $wgExportMaxHistory) {
                    $history['limit'] = $limit;
                }
                if (!is_null($offset)) {
                    $history['offset'] = $offset;
                }
                if (strtolower($dir) == 'desc') {
                    $history['dir'] = 'desc';
                }
            }
            if ($page != '') {
                $doexport = true;
            }
        } else {
            // Default to current-only for GET requests
            $page = $wgRequest->getText('pages', $page);
            $historyCheck = $wgRequest->getCheck('history');
            if ($historyCheck) {
                $history = WikiExporter::FULL;
            } else {
                $history = WikiExporter::CURRENT;
            }
            if ($page != '') {
                $doexport = true;
            }
        }
    }
    if (!$wgExportAllowHistory) {
        // Override
        $history = WikiExporter::CURRENT;
    }
    $list_authors = $wgRequest->getCheck('listauthors');
    if (!$curonly || !$wgExportAllowListContributors) {
        $list_authors = false;
    }
    if ($doexport) {
        $wgOut->disable();
        // Cancel output buffering and gzipping if set
        // This should provide safer streaming for pages with history
        wfResetOutputBuffers();
        header("Content-type: application/xml; charset=utf-8");
        if ($wgRequest->getCheck('wpDownload')) {
            // Provide a sane filename suggestion
            $filename = urlencode($wgSitename . '-' . wfTimestampNow() . '.xml');
            $wgRequest->response()->header("Content-disposition: attachment;filename={$filename}");
        }
        /* Split up the input and look up linked pages */
        $inputPages = array_filter(explode("\n", $page), 'wfFilterPage');
        $pageSet = array_flip($inputPages);
        if ($wgRequest->getCheck('templates')) {
            $pageSet = wfExportGetTemplates($inputPages, $pageSet);
        }
        /*
        // Enable this when we can do something useful exporting/importing image information. :)
        if( $wgRequest->getCheck( 'images' ) ) {
        	$pageSet = wfExportGetImages( $inputPages, $pageSet );
        }
//.........这里部分代码省略.........
开发者ID:amjadtbssm,项目名称:website,代码行数:101,代码来源:SpecialExport.php


示例13: execute


//.........这里部分代码省略.........
     } elseif ($request->getCheck('exportall') && $wgExportAllowAll) {
         $this->doExport = true;
         $exportall = true;
     } elseif ($request->wasPosted() && $par == '') {
         $page = $request->getText('pages');
         $this->curonly = $request->getCheck('curonly');
         $rawOffset = $request->getVal('offset');
         if ($rawOffset) {
             $offset = wfTimestamp(TS_MW, $rawOffset);
         } else {
             $offset = null;
         }
         $limit = $request->getInt('limit');
         $dir = $request->getVal('dir');
         $history = array('dir' => 'asc', 'offset' => false, 'limit' => $wgExportMaxHistory);
         $historyCheck = $request->getCheck('history');
         if ($this->curonly) {
             $history = WikiExporter::CURRENT;
         } elseif (!$historyCheck) {
             if ($limit > 0 && ($wgExportMaxHistory == 0 || $limit < $wgExportMaxHistory)) {
                 $history['limit'] = $limit;
             }
             if (!is_null($offset)) {
                 $history['offset'] = $offset;
             }
             if (strtolower($dir) == 'desc') {
                 $history['dir'] = 'desc';
             }
         }
         if ($page != '') {
             $this->doExport = true;
         }
     } else {
         // Default to current-only for GET requests.
         $page = $request->getText('pages', $par);
         $historyCheck = $request->getCheck('history');
         if ($historyCheck) {
             $history = WikiExporter::FULL;
         } else {
             $history = WikiExporter::CURRENT;
         }
         if ($page != '') {
             $this->doExport = true;
         }
     }
     if (!$wgExportAllowHistory) {
         // Override
         $history = WikiExporter::CURRENT;
     }
     $list_authors = $request->getCheck('listauthors');
     if (!$this->curonly || !$wgExportAllowListContributors) {
         $list_authors = false;
     }
     if ($this->doExport) {
         $this->getOutput()->disable();
         // Cancel output buffering and gzipping if set
         // This should provide safer streaming for pages with history
         wfResetOutputBuffers();
         $request->response()->header("Content-type: application/xml; charset=utf-8");
         if ($request->getCheck('wpDownload')) {
             // Provide a sane filename suggestion
             $filename = urlencode($wgSitename . '-' . wfTimestampNow() . '.xml');
             $request->response()->header("Content-disposition: attachment;filename={$filename}");
         }
         $this->doExport($page, $history, $list_authors, $exportall);
         return;
     }
     $out = $this->getOutput();
     $out->addWikiMsg('exporttext');
     $form = Xml::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getLocalUrl('action=submit')));
     $form .= Xml::inputLabel(wfMsg('export-addcattext'), 'catname', 'catname', 40) . '&#160;';
     $form .= Xml::submitButton(wfMsg('export-addcat'), array('name' => 'addcat')) . '<br />';
     if ($wgExportFromNamespaces) {
         $form .= Xml::namespaceSelector($nsindex, null, 'nsindex', wfMsg('export-addnstext')) . '&#160;';
         $form .= Xml::submitButton(wfMsg('export-addns'), array('name' => 'addns')) . '<br />';
     }
     if ($wgExportAllowAll) {
         $form .= Xml::checkLabel(wfMsg('exportall'), 'exportall', 'exportall', $request->wasPosted() ? $request->getCheck('exportall') : false) . '<br />';
     }
     $form .= Xml::element('textarea', array('name' => 'pages', 'cols' => 40, 'rows' => 10), $page, false);
     $form .= '<br />';
     if ($wgExportAllowHistory) {
         $form .= Xml::checkLabel(wfMsg('exportcuronly'), 'curonly', 'curonly', $request->wasPosted() ? $request->getCheck('curonly') : true) . '<br />';
     } else {
         $out->addHTML(wfMsgExt('exportnohistory', 'parse'));
     }
     $form .= Xml::checkLabel(wfMsg('export-templates'), 'templates', 'wpExportTemplates', $request->wasPosted() ? $request->getCheck('templates') : false) . '<br />';
     if ($wgExportMaxLinkDepth || $this->userCanOverrideExportDepth()) {
         $form .= Xml::inputLabel(wfMsg('export-pagelinks'), 'pagelink-depth', 'pagelink-depth', 20, 0) . '<br />';
     }
     // Enable this when we can do something useful exporting/importing image information. :)
     //$form .= Xml::checkLabel( wfMsg( 'export-images' ), 'images', 'wpExportImages', false ) . '<br />';
     $form .= Xml::checkLabel(wfMsg('export-download'), 'wpDownload', 'wpDownload', $request->wasPosted() ? $request->getCheck('wpDownload') : true) . '<br />';
     if ($wgExportAllowListContributors) {
         $form .= Xml::checkLabel(wfMsg('exportlistauthors'), 'listauthors', 'listauthors', $request->wasPosted() ? $request->getCheck('listauthors') : false) . '<br />';
     }
     $form .= Xml::submitButton(wfMsg('export-submit'), Linker::tooltipAndAccesskeyAttribs('export'));
     $form .= Xml::closeElement('form');
     $out->addHTML($form);
 }
开发者ID:yusufchang,项目名称:app,代码行数:101,代码来源:SpecialExport.php


示例14: doSpecialViewXML

    static function doSpecialViewXML()
    {
        global $wgOut, $wgRequest, $wgUser, $wgContLang;
        $skin = $wgUser->getSkin();
        $namespace_labels = $wgContLang->getNamespaces();
        $category_label = $namespace_labels[NS_CATEGORY];
        $template_label = $namespace_labels[NS_TEMPLATE];
        $name_str = str_replace(' ', '_', wfMsgForContent('dt_xml_name'));
        $namespace_str = str_replace(' ', '_', wfMsg('dt_xml_namespace'));
        $pages_str = str_replace(' ', '_', wfMsgForContent('dt_xml_pages'));
        $form_submitted = false;
        $page_titles = array();
        $cats = $wgRequest->getArray('categories');
        $nses = $wgRequest->getArray('namespaces');
        if (count($cats) > 0 || count($nses) > 0) {
            $form_submitted = true;
        }
        if ($form_submitted) {
            $wgOut->disable();
            // Cancel output buffering and gzipping if set
            // This should provide safer streaming for pages with history
            wfResetOutputBuffers();
            header("Content-type: application/xml; charset=utf-8");
            $groupings = self::getGroupings();
            $simplified_format = $wgRequest->getVal('simplified_format');
            $text = "<{$pages_str}>";
            if ($cats) {
                foreach ($cats as $cat => $val) {
                    if ($simplified_format) {
                        $text .= '<' . str_replace(' ', '_', $cat) . ">\n";
                    } else {
                        $text .= "<{$category_label} {$name_str}=\"{$cat}\">\n";
                    }
                    $titles = self::getPagesForCategory($cat, 10);
                    foreach ($titles as $title) {
                        $text .= self::getXMLForPage($title, $simplified_format, $groupings);
                    }
                    if ($simplified_format) {
                        $text .= '</' . str_replace(' ', '_', $cat) . ">\n";
                    } else {
                        $text .= "</{$category_label}>\n";
                    }
                }
            }
            if ($nses) {
                foreach ($nses as $ns => $val) {
                    if ($ns == 0) {
                        $ns_name = "Main";
                    } else {
                        $ns_name = MWNamespace::getCanonicalName($ns);
                    }
                    if ($simplified_format) {
                        $text .= '<' . str_replace(' ', '_', $ns_name) . ">\n";
                    } else {
                        $text .= "<{$namespace_str} {$name_str}=\"{$ns_name}\">\n";
                    }
                    $titles = self::getPagesForNamespace($ns);
                    foreach ($titles as $title) {
                        $text .= self::getXMLForPage($title, $simplified_format, $groupings);
                    }
                    if ($simplified_format) {
                        $text .= '</' . str_replace(' ', '_', $ns_name) . ">\n";
                    } else {
                        $text .= "</{$namespace_str}>\n";
                    }
                }
            }
            $text .= "</{$pages_str}>";
            print $text;
        } else {
            // set 'title' as hidden field, in case there's no URL niceness
            global $wgContLang;
            $mw_namespace_labels = $wgContLang->getNamespaces();
            $special_namespace = $mw_namespace_labels[NS_SPECIAL];
            $text = <<<END
\t<form action="" method="get">
\t<input type="hidden" name="title" value="{$special_namespace}:ViewXML">

END;
            $text .= "<p>" . wfMsg('dt_viewxml_docu') . "</p>\n";
            $text .= "<h2>" . wfMsg('dt_viewxml_categories') . "</h2>\n";
            $categories = self::getCategoriesList();
            foreach ($categories as $category) {
                $title = Title::makeTitle(NS_CATEGORY, $category);
                $link = $skin->makeLinkObj($title, $title->getText());
                $text .= "<input type=\"checkbox\" name=\"categories[{$category}]\" /> {$link} <br />\n";
            }
            $text .= "<h2>" . wfMsg('dt_viewxml_namespaces') . "</h2>\n";
            $namespaces = self::getNamespacesList();
            foreach ($namespaces as $namespace) {
                if ($namespace == 0) {
                    $ns_name = wfMsgHtml('blanknamespace');
                } else {
                    $ns_name = htmlspecialchars($wgContLang->getFormattedNsText($namespace));
                }
                $ns_name = str_replace('_', ' ', $ns_name);
                $text .= "<input type=\"checkbox\" name=\"namespaces[{$namespace}]\" /> {$ns_name} <br />\n";
            }
            $text .= "<br /><p><input type=\"checkbox\" name=\"simplified_format\" /> " . wfMsg('dt_viewxml_simplifiedformat') . "</p>\n";
            $text .= "<input type=\"submit\" value=\"" . wfMsg('viewxml') . "\">\n";
//.........这里部分代码省略.........
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:101,代码来源:DT_ViewXML.php


示例15: execute

	function execute( $param ) {
		global $wgOut, $wgRequest, $wgRecordAdmin, $wgSecurityProtectRecords;
		if ( !isset( $wgSecurityProtectRecords ) ) $wgSecurityProtectRecords = false;

		$this->setHeaders();
		$type     = $wgRequest->getText( 'wpType' ) or $type = $param;
		$newtype  = $wgRequest->getText( 'wpNewType' );
		$invert   = $wgRequest->getText( 'wpInvert' );
		$record   = $wgRecordAdmin->record = $wgRequest->getText( 'wpRecord' );
		$title    = $this->title = SpecialPage::getTitleFor( 'RecordAdmin' );
		$action   = $title->getLocalURL( 'action=submit' );
		$wpTitle  = trim( $wgRequest->getText( 'wpTitle' ) );
		$this->template = Title::makeTitle( NS_TEMPLATE, $type );

		$wgOut->addHTML(
			'<div class="recordadmin-menubar"><a href="' . $title->getLocalURL() . "/$type\">" . wfMsg( 'recordadmin-newsearch', $type ) . '</a>'
			. '&#160;'
			. '<a href="' . $title->getLocalURL() . '">' . wfMsg( 'recordadmin-newrecord' ) . '</a></div>'."\n"
		);

		# Get posted form values if any
		$posted = array();
		foreach ( $_REQUEST as $k => $v ) if ( preg_match( "|^ra_(\\w+)|", $k, $m ) ) $posted[$m[1]] = is_array( $v ) ? join( "\n", $v ) : $v;

		# Read in and prepare the form for this record type if one has been selected
		if ( $type ) $wgRecordAdmin->preProcessForm( $type );

		# Extract the input names and types used in the form
		$wgRecordAdmin->examineForm();

		# Process Create New Type form if submitted and user permitted
		if ( $newtype ) {
			$wgRecordAdmin->createRecordType( $newtype );
			$type = '';
		}

		# If no type selected, render form for record types and create record-type
		if ( empty( $type ) ) {
			$wgOut->addHTML( Xml::element( 'form', array( 'class' => 'recordadmin', 'action' => $action, 'method' => 'post' ), null ) );
			$wgOut->addWikiText( "<div class='visualClear'></div>\n==" . wfMsg( 'recordadmin-select' ) . "==\n" );

			# Render type select list
			$options = "";
			foreach( $wgRecordAdmin->getRecordTypes() as $option ) $options .= "<option>$option</option>";
			if ( $options ) $wgOut->addHTML(
				"<select name='wpType'>$options</select>&#160;"
				. Xml::element( 'input', array( 'type' => 'submit', 'value' => wfMsg( 'recordadmin-submit' ) ) )
			); else $wgOut->AddWikiText( wfMsg( 'recordadmin-noforms' ) );

			# Render type create
			$wgOut->addWikiText( "<br />\n==" . wfMsg( 'recordadmin-createtype' ) . "==\n" );
			$wgOut->addHTML( Xml::element( 'input', array( 'name' => 'wpNewType', 'type' => 'text' ) )
				. '&#160;'
				. Xml::element( 'input', array( 'type' => 'submit', 'value' => wfMsg( 'recordadmin-buttoncreate' ) ) )
				. '</form>'
			);

		}

		# Record type known, render form for searching or creating
		else {

			# Process Create submission
			if ( count( $posted ) && $wgRequest->getText( 'wpCreate' ) ) {
				if ( empty( $wpTitle ) ) $wpTitle = $wgRecordAdmin->guid;
				$t = Title::newFromText( $wpTitle );
				if ( is_object( $t ) ) {
					if ( $t->exists() ) $wgOut->addHTML( "<div class='errorbox'>" . wfMsg( 'recordadmin-alreadyexist' , $wpTitle ) . "</div>\n" );
					else {

						# Attempt to create the article
						$article = new Article( $t );
						$summary = "[[Special:RecordAdmin/$type|" . wfMsgForContent( 'recordadmin' ) . "]]: " . wfMsg( 'recordadmin-summary-typecreated', $type );
						$success = $article->doEdit( $wgRecordAdmin->valuesToText( $type, $posted ), $summary, EDIT_NEW );

						# Redirect to view the record if successfully updated
						if ( $success ) {
							$wgOut->disable();
							wfResetOutputBuffers();
							header( "Location: " . $t->getFullUrl() );
						}

						# Or stay in edit view and report error
						else $wgOut->addHTML( "<div class='errorbox'>" . wfMsg( 'recordadmin-createerror', $type ) . "</div>\n" );
					}
				} else $wgOut->addHTML( "<div class='errorbox'>" . wfMsg( 'recordadmin-badtitle' ) . "</div>\n" );
				$wgOut->addHTML( "<br /><br /><br /><br />\n" );
			}

			# Populate the search form with any posted values
			$wgRecordAdmin->populateForm( $posted );

			# Process Find submission (select and render records)
			if ( count( $posted ) && $wgRequest->getText( 'wpFind' ) ) {
				$wgOut->addWikiText( "== " . wfMsg( 'recordadmin-searchresult' ) . " ==\n" );
				$records = $wgRecordAdmin->getRecords( $type, $posted, '=', $wpTitle, $invert );
				$wgOut->addHTML( $wgRecordAdmin->renderRecords( $records ) );
			}

			# Render the form
//.........这里部分代码省略.........
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:101,代码来源:SpecialRecordAdmin.php


示例16: onUserGetRights

 /**
  * Permissions: For non-sysops lock all but a few specials down - return a 404 if not allowed to read
  */
 function onUserGetRights($user, &$rights)
 {
     global $wgTitle, $wgOut, $wgContLang;
     $specials = $wgContLang->getSpecialPageAliases();
     $title = explode('/', $wgTitle->getText());
     $title = $title[0];
     if (is_object($wgTitle) && $wgTitle->getNamespace() == NS_SPECIAL && !self::sysop() && $title != $specials['Userlogin'][0] && $title != $specials['Userlogout'][0] && $title != $specials['ChangePassword'][0] && $title != $specials['PasswordReset'][0] && $title != $specials['Confirmemail'][0]) {
         $wgOut->disable();
         wfResetOutputBuffers();
         $code = 404;
         include dirname(__FILE__) . "/error.php";
         die;
     }
     return true;
 }
开发者ID:saper,项目名称:organic-extensions,代码行数:18,代码来源:UserProfiles.class.php


示例17: prepareCreatingDownloadableFile

 /**
  * Do preparations for getting outputted data as a downloadable file
  * rather than written to the current page
  */
 function prepareCreatingDownloadableFile()
 {
     global $wgOut;
     // Disable MediaWikis theming
     $wgOut->disable();
     // Enables downloading as a stream, which is important for large dumps
     wfResetOutputBuffers();
     // Send headers telling that this is a special content type
     // and potentially is to be downloaded as a file
     $this->sendHeadersForOutputType($this->requestdata->outputtype);
 }
开发者ID:rdfio,项目名称:RDFIO,

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wfRestoreWarnings函数代码示例发布时间:2022-05-23
下一篇:
PHP wfReportTime函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap