当前位置: 首页>>代码示例>>PHP>>正文


PHP JResponse类代码示例

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


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

示例1: _modifyResponsiveTemplate

function _modifyResponsiveTemplate()
{
    // Get the current HTML body.
    $body = trim(JResponse::getBody());
    // Correct doctype declaration.
    $doctype = '<!doctype html>';
    // Modified flag.
    $modified = false;
    // Found doctype declaration.
    if (preg_match('#<\\!doctype(.*?)>#is', $body, $match)) {
        // Make sure it's the correct type.
        if (strtolower($match[0]) != $doctype) {
            $body = str_replace($match[0], $doctype, $body);
            $modified = true;
        }
    } else {
        // No doctype declaration, just add it.
        $body = $doctype . "\n" . $body;
        $modified = true;
    }
    // Set the new body only if we've modified it.
    if ($modified) {
        JResponse::setBody($body);
    }
}
开发者ID:knigherrant,项目名称:decopatio,代码行数:25,代码来源:rsform.php

示例2: display

 public function display()
 {
     // Get model data.
     $state = $this->get('State');
     $item = $this->get('Item');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     $doc = JFactory::getDocument();
     $doc->setMetaData('Content-Type', 'text/directory', true);
     // Initialise variables.
     $app = JFactory::getApplication();
     $params = $app->getParams();
     $user = JFactory::getUser();
     $dispatcher = JEventDispatcher::getInstance();
     // Compute lastname, firstname and middlename
     $item->name = trim($item->name);
     // "Lastname, Firstname Midlename" format support
     // e.g. "de Gaulle, Charles"
     $namearray = explode(',', $item->name);
     if (count($namearray) > 1) {
         $lastname = $namearray[0];
         $card_name = $lastname;
         $name_and_midname = trim($namearray[1]);
         $firstname = '';
         if (!empty($name_and_midname)) {
             $namearray = explode(' ', $name_and_midname);
             $firstname = $namearray[0];
             $middlename = count($namearray) > 1 ? $namearray[1] : '';
             $card_name = $firstname . ' ' . ($middlename ? $middlename . ' ' : '') . $card_name;
         }
     } else {
         $namearray = explode(' ', $item->name);
         $middlename = count($namearray) > 2 ? $namearray[1] : '';
         $firstname = array_shift($namearray);
         $lastname = count($namearray) ? end($namearray) : '';
         $card_name = $firstname . ($middlename ? ' ' . $middlename : '') . ($lastname ? ' ' . $lastname : '');
     }
     $rev = date('c', strtotime($item->modified));
     JResponse::setHeader('Content-disposition', 'attachment; filename="' . $card_name . '.vcf"', true);
     $vcard = array();
     $vcard[] .= 'BEGIN:VCARD';
     $vcard[] .= 'VERSION:3.0';
     $vcard[] = 'N:' . $lastname . ';' . $firstname . ';' . $middlename;
     $vcard[] = 'FN:' . $item->name;
     $vcard[] = 'TITLE:' . $item->con_position;
     $vcard[] = 'TEL;TYPE=WORK,VOICE:' . $item->telephone;
     $vcard[] = 'TEL;TYPE=WORK,FAX:' . $item->fax;
     $vcard[] = 'TEL;TYPE=WORK,MOBILE:' . $item->mobile;
     $vcard[] = 'ADR;TYPE=WORK:;;' . $item->address . ';' . $item->suburb . ';' . $item->state . ';' . $item->postcode . ';' . $item->country;
     $vcard[] = 'LABEL;TYPE=WORK:' . $item->address . "\n" . $item->suburb . "\n" . $item->state . "\n" . $item->postcode . "\n" . $item->country;
     $vcard[] = 'EMAIL;TYPE=PREF,INTERNET:' . $item->email_to;
     $vcard[] = 'URL:' . $item->webpage;
     $vcard[] = 'REV:' . $rev . 'Z';
     $vcard[] = 'END:VCARD';
     echo implode("\n", $vcard);
     return true;
 }
开发者ID:exntu,项目名称:joomla-cms,代码行数:60,代码来源:view.vcf.php

示例3: onAfterRender

 public function onAfterRender()
 {
     // only in html and feeds
     if (JFactory::getDocument()->getType() !== 'html' && JFactory::getDocument()->getType() !== 'feed') {
         return;
     }
     $html = JResponse::getBody();
     if ($html == '') {
         return;
     }
     if (JFactory::getDocument()->getType() != 'html') {
         $this->helpers->get('replace')->replaceTags($html, 'body');
         $this->helpers->get('clean')->cleanLeftoverJunk($html);
         JResponse::setBody($html);
         return;
     }
     // only do stuff in body
     list($pre, $body, $post) = nnText::getBody($html);
     $this->helpers->get('replace')->replaceTags($body, 'body');
     $html = $pre . $body . $post;
     $this->helpers->get('clean')->cleanLeftoverJunk($html);
     // replace head with newly generated head
     // this is necessary because the plugins might have added scripts/styles to the head
     $this->helpers->get('head')->updateHead($html);
     JResponse::setBody($html);
 }
开发者ID:naka211,项目名称:studiekorrektur,代码行数:26,代码来源:helper.php

示例4: display

 function display($tpl = null)
 {
     // Do not allow cache
     JResponse::allowCache(false);
     $app = JFactory::getApplication();
     $style = $app->getUserStateFromRequest('media.list.layout', 'layout', 'thumbs', 'word');
     $lang = JFactory::getLanguage();
     JHtml::_('behavior.framework', true);
     $document = JFactory::getDocument();
     $document->addStyleSheet('../media/media/css/medialist-' . $style . '.css');
     if ($lang->isRTL()) {
         $document->addStyleSheet('../media/media/css/medialist-' . $style . '_rtl.css');
     }
     $document->addScriptDeclaration("\n\t\twindow.addEvent('domready', function() {\n\t\t\twindow.parent.document.updateUploader();\n\t\t\t\$\$('a.img-preview').each(function(el) {\n\t\t\t\tel.addEvent('click', function(e) {\n\t\t\t\t\tnew Event(e).stop();\n\t\t\t\t\twindow.top.document.preview.fromElement(el);\n\t\t\t\t});\n\t\t\t});\n\t\t});");
     $images = $this->get('images');
     $documents = $this->get('documents');
     $folders = $this->get('folders');
     $state = $this->get('state');
     $this->baseURL = JURI::root();
     $this->assignRef('images', $images);
     $this->assignRef('documents', $documents);
     $this->assignRef('folders', $folders);
     $this->assignRef('state', $state);
     parent::display($tpl);
 }
开发者ID:christianesperar,项目名称:joomla-example,代码行数:25,代码来源:view.html.php

示例5: 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 (count($app->getMessageQueue())) {
         return;
     }
     if ($user->get('guest') && $_SERVER['REQUEST_METHOD'] == 'GET') {
         $this->_cache->setCaching(true);
     }
     $data = $this->_cache->get();
     if ($data !== false) {
         JResponse::setBody($data);
         echo JResponse::toString($app->getCfg('gzip'));
         if (JDEBUG) {
             $_PROFILER->mark('afterCache');
             echo implode('', $_PROFILER->getBuffer());
         }
         $app->close();
     }
 }
开发者ID:jimyb3,项目名称:mathematicalteachingsite,代码行数:29,代码来源:cache.php

示例6: render

 /**
  * Render the document.
  *
  * @param   boolean  $cache   If true, cache the output
  * @param   array    $params  Associative array of attributes
  *
  * @return  The rendered data
  *
  * @since  11.1
  */
 public function render($cache = false, $params = array())
 {
     JResponse::allowCache(false);
     JResponse::setHeader('Content-disposition', 'attachment; filename="' . $this->getName() . '.json"', true);
     parent::render();
     return $this->getBuffer();
 }
开发者ID:NavaINT1876,项目名称:ccustoms,代码行数:17,代码来源:json.php

示例7: onAfterRender

 function onAfterRender()
 {
     $buffer = JResponse::getBody();
     $buffer = preg_replace('#<head>([\\s\\S]+?)<\\/head>#', '<head>$1' . $this->loadStyles() . '</head>', $buffer);
     JResponse::setBody($buffer);
     return true;
 }
开发者ID:omarmm,项目名称:MangLuoiBDS,代码行数:7,代码来源:system.php

示例8: display

 public function display($tpl = null)
 {
     JResponse::allowCache(true);
     $app = JFactory::getApplication();
     if ($app->input->get('callback', '', 'cmd')) {
         $document = JFactory::getDocument();
         $document->setMimeEncoding('application/javascript');
     }
     $this->categories = $this->get('Categories');
     $this->extensions = $this->get('Extensions');
     $this->breadcrumbs = $this->get('Breadcrumbs');
     $this->orderby = $this->get('OrderBy');
     $this->params = new JRegistry();
     // Temporary params @DELETE
     $this->params->set('extensions_perrow', 4);
     $response = array();
     $response['body'] = array('html' => iconv("UTF-8", "UTF-8//IGNORE", $this->loadTemplate($tpl)), 'pluginuptodate' => $this->get('PluginUpToDate'));
     $response['error'] = false;
     $response['message'] = '';
     $json = new JResponseJson($response['body'], $response['message'], $response['error']);
     if ($app->input->get('callback', '', 'cmd')) {
         echo str_replace(array('\\n', '\\t'), '', $app->input->get('callback') . '(' . $json . ')');
     } else {
         echo str_replace(array('\\n', '\\t'), '', $json);
     }
 }
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:26,代码来源:view.json.php

示例9: 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;
 }
开发者ID:joebushi,项目名称:joomla,代码行数:38,代码来源:sef.php

示例10: 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);
 }
开发者ID:Simarpreet05,项目名称:joomla,代码行数:7,代码来源:jomsocialconnect.php

示例11: onAfterRender

 function onAfterRender()
 {
     if ((defined('JCOMMENTS_CSS') || defined('JCOMMENTS_JS')) && !defined('JCOMMENTS_SHOW')) {
         $app =& JFactory::getApplication();
         if ($app->getName() != 'site') {
             return true;
         }
         $buffer = JResponse::getBody();
         $regexpJS = '#(\\<script(\\stype=\\"text\\/javascript\\")? src="[^\\"]*\\/com_jcomments\\/[^\\>]*\\>\\<\\/script\\>[\\s\\r\\n]*?)#ismU';
         $regexpCSS = '#(\\<link rel="stylesheet" href="[^\\"]*\\/com_jcomments\\/[^>]*>[\\s\\r\\n]*?)#ismU';
         $jcommentsTestJS = '#(JCommentsEditor|new JComments)#ismU';
         $jcommentsTestCSS = '#(comment-link|jcomments-links)#ismU';
         $jsFound = preg_match($jcommentsTestJS, $buffer);
         $cssFound = preg_match($jcommentsTestCSS, $buffer);
         if (!$jsFound) {
             // remove JavaScript if JComments isn't loaded
             $buffer = preg_replace($regexpJS, '', $buffer);
         }
         if (!$cssFound && !$jsFound) {
             // remove CSS if JComments isn't loaded
             $buffer = preg_replace($regexpCSS, '', $buffer);
         }
         if ($buffer != '') {
             JResponse::setBody($buffer);
         }
     }
     return true;
 }
开发者ID:omarmm,项目名称:MangLuoiBDS,代码行数:28,代码来源:jcomments.php

示例12: init

 function init()
 {
     $mainframe =& JFactory::getApplication();
     $file = JRequest::getVar('file');
     $folder = JRequest::getVar('folder');
     jimport('joomla.filesystem.file');
     // only allow files that have .inc.php in the file name
     if (!$file || strpos($file, '.inc.php') === false) {
         echo JText::_('Access Denied');
         exit;
     }
     if (!$mainframe->isAdmin() && !JRequest::getCmd('usetemplate')) {
         $mainframe->setTemplate('system');
     }
     $_REQUEST['tmpl'] = 'component';
     $mainframe->_messageQueue = array();
     $html = '';
     $path = JPATH_SITE;
     if ($folder) {
         $path .= DS . implode(DS, explode('.', $folder));
     }
     $file = $path . DS . $file;
     if (JFile::exists($file)) {
         ob_start();
         include $file;
         $html = ob_get_contents();
         ob_end_clean();
     }
     $document =& JFactory::getDocument();
     $document->setBuffer($html, 'component');
     $document->addStyleSheet(JURI::root(true) . '/plugins/system/nonumberelements/css/default.css');
     $mainframe->render();
     echo JResponse::toString($mainframe->getCfg('gzip'));
     exit;
 }
开发者ID:omarmm,项目名称:MangLuoiBDS,代码行数:35,代码来源:helper.php

示例13: registerOnAfterRenderBodyFilter

 /**
  * Registers a handler to filter the final output
  *
  * @param  callable  $handler  A function( $body ) { return $bodyChanged; }
  * @return self                To allow chaining.
  */
 public function registerOnAfterRenderBodyFilter($handler)
 {
     $this->registerEvent('onAfterRender', function () use($handler) {
         \JResponse::setBody($handler(\JResponse::getBody()));
     });
     return $this;
 }
开发者ID:Raul-mz,项目名称:web-erpcya,代码行数:13,代码来源:Joomla2.php

示例14: 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());
     }
 }
开发者ID:interfaceslivres,项目名称:ccmd-ufpb,代码行数:42,代码来源:page.php

示例15: render

 /**
  * Display the application.
  */
 public function render()
 {
     $user = JFactory::getUser();
     $conf = JFactory::getConfig();
     if ($user->guest || !JFactory::getUser()->authorise('core.admin', 'com_cache')) {
         //TODO change this to the the proper access acl
         echo JText::_('Unauthorized');
         exit;
     }
     $logfile = $this->input->getPath('logfile', null);
     if (is_null($logfile)) {
         echo JText::_('Log not found.');
         exit;
     }
     $logfile_path = JPATH_ROOT . '/logs/' . $logfile;
     if (!is_file($logfile_path)) {
         echo JText::_('Log not found.');
         exit;
     }
     JResponse::clearHeaders();
     header('Content-type: application/octet-stream');
     header('Content-Disposition: attachment; filename=' . pathinfo($logfile, PATHINFO_FILENAME) . '.log');
     header('Content-Length: ' . filesize($logfile_path) . ';');
     header('Content-Transfer-Encoding: binary');
     readfile($logfile_path);
     exit;
 }
开发者ID:interfaceslivres,项目名称:ccmd-ufpb,代码行数:30,代码来源:application.php


注:本文中的JResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。