本文整理汇总了PHP中JResponse::setBody方法的典型用法代码示例。如果您正苦于以下问题:PHP JResponse::setBody方法的具体用法?PHP JResponse::setBody怎么用?PHP JResponse::setBody使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JResponse
的用法示例。
在下文中一共展示了JResponse::setBody方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showPopup
function showPopup()
{
global $mainframe;
jimport('joomla.application.helper');
$client = JApplicationHelper::getClientInfo($mainframe->getClientID());
// settings from config.xml
$dumpConfig =& JComponentHelper::getParams('com_dump');
$w = $dumpConfig->get('popupwidth', 500);
$h = $dumpConfig->get('popupheight', 500);
// build the url
$url = JURI::base(true) . '/index.php?option=com_dump&view=tree&tmpl=component';
/* @TODO remove this and implement this in a later version using JRoute
// only add Itemid in Site
if ( $mainframe->isSite() ) {
$url .= '&Itemid=' . DumpHelper::getComponentItemid( 'com_dump' );
}
*/
// create the javascript
// We can't use $document, because it's already rendered
$nl = "\n";
$script = $nl . '<!-- J!Dump -->' . $nl . '<script type="text/javascript">' . $nl . '// <!--' . $nl . 'window.open( "' . $url . '", "dump_' . $client->name . '", "height=' . $h . ',width=' . $w . ',toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1");' . $nl . '// -->' . $nl . '</script>' . $nl . '<!-- / J!Dump -->';
// add the code to the header (thanks jenscski)
// JResponse::appendBody( $script );
$body = JResponse::getBody();
$body = str_replace('</head>', $script . '</head>', $body);
JResponse::setBody($body);
}
示例2: onAfterInitialise
/**
* Converting the site URL to fit to the HTTP request
*
*/
function onAfterInitialise()
{
global $_PROFILER;
$app =& JFactory::getApplication();
$user =& JFactory::getUser();
if ($app->isAdmin() || JDEBUG) {
return;
}
if (!$user->get('guest') && $_SERVER['REQUEST_METHOD'] == 'GET') {
$this->_cache->setCaching(true);
}
$data = $this->_cache->get();
if ($data !== false) {
// the following code searches for a token in the cached page and replaces it with the
// proper token.
$token = JUtility::getToken();
$search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#';
$replacement = '<input type="hidden" name="' . $token . '" value="1" />';
$data = preg_replace($search, $replacement, $data);
JResponse::setBody($data);
echo JResponse::toString($app->getCfg('gzip'));
if (JDEBUG) {
$_PROFILER->mark('afterCache');
echo implode('', $_PROFILER->getBuffer());
}
$app->close();
}
}
示例3: setStyle
function setStyle()
{
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
if ($doc->getType() != 'html') {
return;
}
//include_once AK_LIB_PATH.DS.'dom'.DS.'simple_html_dom.php';
$body = JResponse::getBody();
$body = explode('</head>', $body);
$base = JURI::root();
$style = "\n";
if ($app->isSite()) {
if (JVERSION < 3.0) {
$style .= '<link rel="stylesheet" href="' . AK_ADMIN_CSS_URL . '/system.css" type="text/css" />' . "\n";
}
$style .= '<link rel="stylesheet" href="' . AK_CSS_URL . '/custom-typo.css" type="text/css" />' . "\n";
$style .= '<link rel="stylesheet" href="' . AK_CSS_URL . '/custom.css" type="text/css" />' . "\n";
} else {
if (JVERSION < 3.0) {
$style .= '<link rel="stylesheet" href="' . AK_ADMIN_CSS_URL . '/system.css" type="text/css" />' . "\n";
}
$style .= '<link rel="stylesheet" href="' . AK_CSS_URL . '/custom-admin.css" type="text/css" />' . "\n";
}
$body[0] .= $style;
//Fold content
$replace['{fold}'] = '<div class="ak-fold-warp"><div class="ak-fold-outter"><div class="ak-fold-inner">';
$replace['{/fold}'] = '</div></div><div class="ak-fold-button"></div></div><div class="clearfix"></div>';
if ($app->isSite()) {
$body[1] = strtr($body[1], $replace);
}
$body = implode('</head>', $body);
JResponse::setBody($body);
}
示例4: onAfterRender
function onAfterRender()
{
$app = JFactory::getApplication();
if ($app->isAdmin()) {
return;
}
// Initialise variables
$id = $this->params->get('id', '');
$webvisor = $this->params->get('webvisor', '');
$clickMap = $this->params->get('clickMap', '');
$linksOut = $this->params->get('linksOut', '');
$accurateTrackBounce = $this->params->get('accurateTrackBounce', '');
$noIndex = $this->params->get('noIndex', '');
$noIndexWrapper = $this->params->get('noindexWrapper', '1');
//getting body code and storing as buffer
$buffer = JResponse::getBody();
//embed Yandex Metrika code
$webvisor = $webvisor ? 'true' : 'false';
$clickMap = $clickMap ? 'true' : 'false';
$linksOut = $linksOut ? 'true' : 'false';
$accurateTrackBounce = $accurateTrackBounce ? 'true' : 'false';
$noIndex = $noIndex ? 'ut:"noindex",' : '';
$javascript = '<!-- Yandex.Metrika counter --><script type="text/javascript">(function (d, w, c) { (w[c] = w[c] || []).push(function() { try { w.yaCounter' . $id . ' = new Ya.Metrika({id:' . $id . ', clickmap:' . $clickMap . ', trackLinks:' . $linksOut . ', accurateTrackBounce:' . $accurateTrackBounce . ',' . $noIndex . ' webvisor:' . $webvisor . '}); } catch(e) {} }); var n = d.getElementsByTagName("script")[0], s = d.createElement("script"), f = function () { n.parentNode.insertBefore(s, n); }; s.type = "text/javascript"; s.async = true; s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js"; if (w.opera == "[object Opera]") { d.addEventListener("DOMContentLoaded", f); } else { f(); } })(document, window, "yandex_metrika_callbacks");</script><noscript><div><img src="//mc.yandex.ru/watch/' . $id . '" style="position:absolute; left:-9999px;" alt="" /></div></noscript><!-- /Yandex.Metrika counter -->';
if ($noIndexWrapper) {
$javascript = '<!--noindex-->' . $javascript . '<!--/noindex-->';
}
$buffer = preg_replace("/<\\/body>/", $javascript . "\n\n</body>", $buffer);
//output the buffer
JResponse::setBody($buffer);
return true;
}
示例5: onAfterRender
public function onAfterRender()
{
if ($this->app->isAdmin()) {
return;
}
$app = JFactory::getApplication();
$option = $app->input->get('option');
$view = $app->input->get('view');
$tmpl = $app->input->get('tmpl');
$body = JResponse::GetBody();
if ($app->isSite() && $tmpl != 'component') {
$_cls = explode(',', $this->_params->get('item_class'));
if (empty($_cls)) {
return;
}
$cls = array();
for ($i = 0; $i < count($_cls); $i++) {
$cls[] = trim($_cls[$i]);
}
$cls_str = implode(', ', $cls);
$body = str_replace('</body>', $this->_addScriptQV($cls_str) . '</body>', $body);
JResponse::setBody($body);
return true;
}
$is_ajax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest';
$is_ajax_qv = (int) JRequest::getVar('isajax_qv', 0);
if ($is_ajax && $is_ajax_qv) {
$body = JResponse::GetBody();
preg_match("~<body.*?>(.*?)<\\/body>~is", $body, $match);
echo '<div id="sj_quickview">' . $match[1] . '</div>';
die;
//die(json_encode('<div id="sj_quickview">'.$match[1].'</div>'));
}
}
示例6: onAfterRender
function onAfterRender()
{
$fbml = '<html xmlns:fb="http://www.facebook.com/2008/fbml"';
$html = JResponse::getBody();
$html = JString::str_ireplace('<html', $fbml, $html);
JResponse::setBody($html);
}
示例7: onAfterRender
/**
* Converting the site URL to fit to the HTTP request
*/
function onAfterRender()
{
$app =& JFactory::getApplication();
if ($app->getName() != 'site') {
return true;
}
//Replace src links
$base = JURI::base(true) . '/';
$buffer = JResponse::getBody();
$regex = '#href="index.php\\?([^"]*)#m';
$buffer = preg_replace_callback($regex, array('plgSystemSEF', 'route'), $buffer);
$protocols = '[a-zA-Z0-9]+:';
//To check for all unknown protocals (a protocol must contain at least one alpahnumeric fillowed by :
$regex = '#(src|href)="(?!/|' . $protocols . '|\\#|\')([^"]*)"#m';
$buffer = preg_replace($regex, "\$1=\"{$base}\$2\"", $buffer);
$regex = '#(onclick="window.open\\(\')(?!/|' . $protocols . '|\\#)([^/]+[^\']*?\')#m';
$buffer = preg_replace($regex, '$1' . $base . '$2', $buffer);
// ONMOUSEOVER / ONMOUSEOUT
$regex = '#(onmouseover|onmouseout)="this.src=([\']+)(?!/|' . $protocols . '|\\#|\')([^"]+)"#m';
$buffer = preg_replace($regex, '$1="this.src=$2' . $base . '$3$4"', $buffer);
// Background image
$regex = '#style\\s*=\\s*[\'\\"](.*):\\s*url\\s*\\([\'\\"]?(?!/|' . $protocols . '|\\#)([^\\)\'\\"]+)[\'\\"]?\\)#m';
$buffer = preg_replace($regex, 'style="$1: url(\'' . $base . '$2$3\')', $buffer);
// OBJECT <param name="xx", value="yy"> -- fix it only inside the <param> tag
$regex = '#(<param\\s+)name\\s*=\\s*"(movie|src|url)"[^>]\\s*value\\s*=\\s*"(?!/|' . $protocols . '|\\#|\')([^"]*)"#m';
$buffer = preg_replace($regex, '$1name="$2" value="' . $base . '$3"', $buffer);
// OBJECT <param value="xx", name="yy"> -- fix it only inside the <param> tag
$regex = '#(<param\\s+[^>]*)value\\s*=\\s*"(?!/|' . $protocols . '|\\#|\')([^"]*)"\\s*name\\s*=\\s*"(movie|src|url)"#m';
$buffer = preg_replace($regex, '<param value="' . $base . '$2" name="$3"', $buffer);
// OBJECT data="xx" attribute -- fix it only in the object tag
$regex = '#(<object\\s+[^>]*)data\\s*=\\s*"(?!/|' . $protocols . '|\\#|\')([^"]*)"#m';
$buffer = preg_replace($regex, '$1data="' . $base . '$2"$3', $buffer);
JResponse::setBody($buffer);
return true;
}
示例8: onAfterRender
function onAfterRender()
{
if (class_exists('JEventDispatcher', false)) {
$dispatcher = JEventDispatcher::getInstance();
} else {
$dispatcher = JDispatcher::getInstance();
}
$dispatcher->trigger('onNextendBeforeCompileHead');
ob_start();
if (class_exists('N2AssetsManager')) {
echo N2AssetsManager::getCSS();
echo N2AssetsManager::getJs();
}
$head = ob_get_clean();
if ($head != '') {
$application = JFactory::getApplication();
if (class_exists('JApplicationWeb') && method_exists($application, 'getBody')) {
$body = $application->getBody();
$mode = 'JApplicationWeb';
} else {
$body = JResponse::getBody();
$mode = 'JResponse';
}
$body = preg_replace('/<\\/head>/', $head . '</head>', $body, 1);
switch ($mode) {
case 'JResponse':
JResponse::setBody($body);
break;
default:
$application->setBody($body);
}
}
}
示例9: onAfterRender
public function onAfterRender()
{
$fbml = '<html xmlns:fb="http://ogp.me/ns/fb#" ';
$html = JResponse::getBody();
$html = JString::str_ireplace('<html', $fbml, $html);
JResponse::setBody($html);
}
示例10: onAfterRender
function onAfterRender()
{
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
// we don't care about /administrator or pages that aren't html
if ($app->isAdmin() || JRequest::getVar('format') == 'raw' || $app->isSite() && $doc->getType() != 'html') {
return true;
}
// default favicon and individual menu-item assignments
$default = (int) $this->params->get('default', 0);
$assignmentsobject = (array) $this->params->get('assignments');
$assignments = array();
foreach ($assignmentsobject as $key => $assignment) {
$assignments[$key] = (array) $assignment;
}
// no default and no assignments = no point
if (!$default && !count($assignments)) {
return true;
}
$favicon = $this->getFavicon($default, $assignments);
// no favicon found and no valid default
if (!$favicon) {
return true;
}
$buffer = JResponse::getBody();
$link = '<link href="' . $favicon . '" rel="shortcut icon" type="image/vnd.microsoft.icon" />';
preg_match('/<link href=.* rel="shortcut icon" type=.*\\/>/', $buffer, $position, PREG_OFFSET_CAPTURE);
if (isset($position[0]) && isset($position[0][0]) && strlen($position[0][0])) {
$buffer = str_replace($position[0][0], $link, $buffer);
} else {
$buffer = str_replace("</head>", "\t{$link}\n</head>", $buffer);
}
JResponse::setBody($buffer);
}
示例11: _renderStatus
public function _renderStatus()
{
$date = JFactory::getDate();
$jparam = new JConfig();
if (!JFile::exists(JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_community' . DS . 'community.xml')) {
return false;
}
if (JFile::exists($jparam->tmp_path . DS . 'jomsocialupdate.ini')) {
$lastcheckdate = JFile::read($jparam->tmp_path . DS . 'jomsocialupdate.ini');
} else {
$lastcheckdate = $date->toFormat();
}
JFile::write($jparam->tmp_path . DS . 'jomsocialupdate.ini', $lastcheckdate);
$dayInterval = 1;
// days
$currentdate = $date->toFormat();
$checkVersion = strtotime($currentdate) > strtotime($lastcheckdate) + $dayInterval * 60 * 60 * 24;
// Load language
$lang = JFactory::getLanguage();
$lang->load('com_community', JPATH_ROOT . DS . 'administrator');
$button = $this->_getButton($checkVersion);
$html = JResponse::getBody();
$html = str_replace('<div id="module-status">', '<div id="module-status">' . $button, $html);
// Load AJAX library for the back end.
$jax = new JAX(rtrim(JURI::root(), '/') . '/plugins/system/pc_includes');
$jax->setReqURI(rtrim(JURI::root(), '/') . '/administrator/index.php');
$jaxScript = $jax->getScript();
JResponse::setBody($html . $jaxScript);
}
示例12: onAfterRender
function onAfterRender()
{
$app =& JFactory::getApplication();
if ($app->getName() != 'site') {
return true;
}
$buffer = JResponse::getBody();
if (strripos($buffer, '_svg.png') !== false) {
include 'plugins/system/svg_helper/Modernizr/modernizr-server.php';
if (isset($_COOKIE['svg-check']) && strripos($_COOKIE['svg-check'], 'svg:1') !== false) {
$buffer = str_replace('_svg.png', '_png.svg', $buffer);
}
}
/* Older versions compatibility start */
$extension = $this->params->get('extension');
if (strripos($buffer, $extension) !== false) {
include 'plugins/system/svg_helper/Modernizr/modernizr-server.php';
if ($this->params->get('enable_replacement') == 1) {
if (isset($_COOKIE['svg-check']) && strripos($_COOKIE['svg-check'], 'svg:1') !== false) {
$buffer = str_replace($extension, 'svg', $buffer);
} else {
$buffer = str_replace($extension, 'png', $buffer);
}
}
}
/* Older versions compatibility end */
if ($buffer != '') {
JResponse::setBody($buffer);
}
return true;
}
示例13: plgSh404sefofflinecode
/**
* Output a correct response code when site is offline
* to let know search engines that site data
* should not be discarded or discounted
*/
function plgSh404sefofflinecode()
{
$app = JFactory::getApplication();
// are we in the backend, or not offline ?
if (!defined('SH404SEF_IS_RUNNING') || $app->isAdmin() || !$app->getCfg('offline')) {
return;
}
// get plugin params
$plugin =& JPluginHelper::getPlugin('sh404sefcore', 'sh404sefofflinecode');
$pluginParams = new JRegistry();
$pluginParams->loadString($plugin->params);
$disallowAdminAccess = $pluginParams->get('disallowAdminAccess', 0);
if (!$disallowAdminAccess) {
// admins are allowed, lets check if current user
// is an admin, or if user is trying to log in
$user =& JFactory::getUser();
$option = JRequest::getCmd('option');
$task = JRequest::getCmd('task');
if ($option == 'com_users' && $task == 'user.login') {
// Check for request forgeries
JRequest::checkToken() or jexit('Invalid Token');
$loggingIn = true;
} else {
$loggingIn = false;
}
// if already logged inadmin, or admin logging in, let it go
if ($user->authorize('core.manage', 'com_sh404sef') || $loggingIn) {
return;
}
}
// need to render offline screen
if ($disallowAdminAccess) {
// admins not allowed, use our own
// simplified template. Most likely being hacked so
// close doors as much as possible
$template = '';
$file = 'sh404sef_offline_template.php';
$directory = JPATH_ROOT . DS . 'plugins' . DS . 'sh404sefcore';
} else {
// admin can access, use Joomla! offline template,
// that includes a login form
$template = $app->getTemplate();
$file = 'offline.php';
$directory = JPATH_THEMES;
}
$params = array('template' => $template, 'file' => $file, 'directory' => $directory);
$document =& JFactory::getDocument();
$data = $document->render($app->getCfg('caching'), $params);
// header : service unavailable
JResponse::setHeader('HTTP/1.0 503', true);
// give it some time
$retryAfter = $pluginParams->get('retry_after_delay', 7400);
// set header
Jresponse::setheader('Retry-After', gmdate('D, d M Y H:i:s', time() + $retryAfter) . ' GMT');
// echo document
JResponse::setBody($data);
echo JResponse::toString($app->getCfg('gzip'));
// and terminate
$app->close();
}
示例14: onAfterInitialise
/**
* Converting the site URL to fit to the HTTP request
*
*/
function onAfterInitialise()
{
global $_PROFILER;
$app = JFactory::getApplication();
$user = JFactory::getUser();
if ($app->isAdmin()) {
return;
}
if (count($app->getMessageQueue())) {
return;
}
if ($user->get('guest') && $app->input->getMethod() == 'GET') {
$this->_cache->setCaching(true);
}
$data = $this->_cache->get($this->_cache_key);
if ($data !== false) {
// Set cached body
JResponse::setBody($data);
echo JResponse::toString($app->getCfg('gzip'));
if (JDEBUG) {
$_PROFILER->mark('afterCache');
}
$app->close();
}
}
示例15: render
/**
* Render the error page based on an exception.
*
* @param Exception $error The exception for which to render the error page.
*
* @return void
*
* @since 3.0
*/
public static function render(Exception $error)
{
try {
$app = JFactory::getApplication();
$document = JDocument::getInstance('error');
if (!$document) {
// We're probably in an CLI environment
exit($error->getMessage());
$app->close(0);
}
$config = JFactory::getConfig();
// Get the current template from the application
$template = $app->getTemplate();
// Push the error object into the document
$document->setError($error);
if (ob_get_contents()) {
ob_end_clean();
}
$document->setTitle(JText::_('Error') . ': ' . $error->getCode());
$data = $document->render(false, array('template' => $template, 'directory' => JPATH_THEMES, 'debug' => $config->get('debug')));
// Failsafe to get the error displayed.
if (empty($data)) {
exit($error->getMessage());
} else {
// Do not allow cache
JResponse::allowCache(false);
JResponse::setBody($data);
echo JResponse::toString();
}
} catch (Exception $e) {
exit('Error displaying the error page: ' . $e->getMessage());
}
}