本文整理汇总了PHP中JResponse::allowCache方法的典型用法代码示例。如果您正苦于以下问题:PHP JResponse::allowCache方法的具体用法?PHP JResponse::allowCache怎么用?PHP JResponse::allowCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JResponse
的用法示例。
在下文中一共展示了JResponse::allowCache方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* Render the document.
*
* @param boolean $cache If true, cache the output
* @param array $params Associative array of attributes
*
* @return The rendered data
*
* @since 3.1
*/
public function render($cache = false, $params = array())
{
JResponse::allowCache($cache);
JResponse::setHeader('Content-disposition', 'attachment; filename="' . $this->getName() . '.json"', true);
// Unfortunately, the exact syntax of the Content-Type header
// is not defined, so we have to try to be a bit clever here.
$contentType = $this->_mime;
if (stripos($contentType, 'json') === false) {
$contentType .= '+' . $this->_type;
}
$this->_mime = $contentType;
parent::render();
// Get the HAL object from the buffer.
$hal = $this->getBuffer();
// If required, change relative links to absolute.
if ($this->absoluteHrefs && is_object($hal) && isset($hal->_links)) {
// Adjust hrefs in the _links object.
$this->relToAbs($hal->_links);
// Adjust hrefs in the _embedded object (if there is one).
if (isset($hal->_embedded)) {
foreach ($hal->_embedded as $rel => $resources) {
foreach ($resources as $id => $resource) {
if (isset($resource->_links)) {
$this->relToAbs($resource->_links);
}
}
}
}
}
// Return it as a JSON string.
return json_encode($hal);
}
示例2: 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);
}
}
示例3: __construct
public function __construct($config = array())
{
$name = isset($config['name']) ? $config['name'] : $this->getName();
$this->document = JFactory::getDocument();
$this->document->setBase('');
$this->profiler = KunenaProfiler::instance('Kunena');
$this->app = JFactory::getApplication();
$this->me = KunenaUserHelper::getMyself();
$this->config = KunenaFactory::getConfig();
$this->ktemplate = KunenaFactory::getTemplate();
// Set the default template search path
if ($this->app->isSite() && !isset($config['template_path'])) {
$config['template_path'] = $this->ktemplate->getTemplatePaths("html/{$name}", true);
}
if ($this->app->isAdmin()) {
$templateAdmin = KunenaFactory::getAdminTemplate();
$templateAdmin->initialize();
$config['template_path'] = $templateAdmin->getTemplatePaths($name);
}
parent::__construct($config);
if ($this->app->isSite()) {
// Add another template file lookup path specific to the current template
$fallback = JPATH_THEMES . "/{$this->app->getTemplate()}/html/com_kunena/{$this->ktemplate->name}/{$this->getName()}";
$this->addTemplatePath($fallback);
}
// Use our own browser side cache settings.
JResponse::allowCache(false);
JResponse::setHeader('Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true);
JResponse::setHeader('Last-Modified', gmdate("D, d M Y H:i:s") . ' GMT', true);
JResponse::setHeader('Cache-Control', 'no-store, must-revalidate, post-check=0, pre-check=0', true);
}
示例4: _displayModal
function _displayModal($tpl)
{
$mainframe = JFactory::getApplication();
// Do not allow cache
JResponse::allowCache(false);
$document = JFactory::getDocument();
$prjid = array();
$prjid = JRequest::getVar('prjid', array(0), 'post', 'array');
$proj_id = (int) $prjid[0];
//build the html select list for projects
$projects[] = JHTML::_('select.option', '0', JText::_('COM_JOOMLEAGUE_GLOBAL_SELECT_PROJECT'), 'id', 'name');
if ($res = JoomleagueHelper::getProjects()) {
$projects = array_merge($projects, $res);
}
$lists['projects'] = JHTMLSelect::genericlist($projects, 'prjid[]', 'class="inputbox" onChange="this.form.submit();" style="width:170px"', 'id', 'name', $proj_id);
unset($projects);
$projectteams[] = JHTMLSelect::option('0', JText::_('COM_JOOMLEAGUE_GLOBAL_SELECT_TEAM'), 'value', 'text');
// if a project is active we show the teams select list
if ($proj_id > 0) {
if ($res = JoomleagueHelper::getProjectteams($proj_id)) {
$projectteams = array_merge($projectteams, $res);
}
$lists['projectteams'] = JHTMLSelect::genericlist($projectteams, 'xtid[]', 'class="inputbox" style="width:170px"', 'value', 'text');
unset($projectteams);
}
$this->assignRef('lists', $lists);
$this->assignRef('project_id', $proj_id);
parent::display($tpl);
}
示例5: testAllowCache
/**
* Test...
*
* @return void
*/
public function testAllowCache()
{
$this->assertThat(JResponse::allowCache(), $this->equalTo(false));
JResponse::allowCache(true);
$this->assertThat(JResponse::allowCache(), $this->equalTo(true));
$this->assertThat(JResponse::allowCache(false), $this->equalTo(false));
}
示例6: testAllowCache
public function testAllowCache()
{
$this->assertThat(JResponse::allowCache(), $this->equalTo(FALSE));
JResponse::allowCache(TRUE);
$this->assertThat(JResponse::allowCache(), $this->equalTo(TRUE));
$this->assertThat(JResponse::allowCache(FALSE), $this->equalTo(FALSE));
}
示例7: display
function display($tpl = null)
{
// Do not allow cache
JResponse::allowCache(false);
$app = JFactory::getApplication();
$lang = JFactory::getLanguage();
// Nuevo Jokte 1.3.4
$clave = JRequest::getVar('clave');
JHtml::_('stylesheet', 'media/popup-imagelist.css', array(), true);
if ($lang->isRTL()) {
JHtml::_('stylesheet', 'media/popup-imagelist_rtl.css', array(), true);
}
$document = JFactory::getDocument();
$document->addScriptDeclaration("var ImageManager = window.parent.ImageManager;");
$images = $this->get('images');
$documents = $this->get('documents');
$folders = $this->get('folders');
$state = $this->get('state');
$this->baseURL = COM_MEDIA_BASEURL;
$this->assignRef('images', $images);
$this->assignRef('clave', $clave);
$this->assignRef('documents', $documents);
$this->assignRef('folders', $folders);
$this->assignRef('state', $state);
parent::display($tpl);
}
示例8: display
public function display($tpl = null)
{
// Do not allow cache
JResponse::allowCache(false);
JHtml::_('behavior.framework', true);
JFactory::getDocument()->addScriptDeclaration("\n\t\twindow.addEvent('domready', function()\n\t\t{\n\t\t\twindow.parent.document.updateUploader();\n\t\t\t\$\$('a.img-preview').each(function(el)\n\t\t\t{\n\t\t\t\tel.addEvent('click', function(e)\n\t\t\t\t{\n\t\t\t\t\twindow.top.document.preview.fromElement(el);\n\t\t\t\t\treturn false;\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');
// Check for invalid folder name
if (empty($state->folder)) {
$dirname = JRequest::getVar('folder', '', '', 'string');
if (!empty($dirname)) {
$dirname = htmlspecialchars($dirname, ENT_COMPAT, 'UTF-8');
JError::raiseWarning(100, JText::sprintf('COM_MEDIA_ERROR_UNABLE_TO_BROWSE_FOLDER_WARNDIRNAME', $dirname));
}
}
$this->baseURL = JUri::root();
$this->images =& $images;
$this->documents =& $documents;
$this->folders =& $folders;
$this->state =& $state;
parent::display($tpl);
}
示例9: display
/**
* Image selection List
*
*/
function display($tpl = null) {
$app = JFactory::getApplication();
$option = $app->input->getString('option', 'com_jem');
JHtml::_('behavior.framework');
if($this->getLayout() == 'uploadimage') {
$this->_displayuploadimage($tpl);
return;
}
//get vars
$task = $app->input->get('task', '');
$search = $app->getUserStateFromRequest($option.'.filter_search', 'filter_search', '', 'string');
$search = trim(JString::strtolower($search));
//set variables
if ($task == 'selecteventimg') {
$folder = 'events';
$task = 'eventimg';
$redi = 'selecteventimg';
} else if ($task == 'selectvenueimg') {
$folder = 'venues';
$task = 'venueimg';
$redi = 'selectvenueimg';
} else if ($task == 'selectcategoriesimg') {
$folder = 'categories';
$task = 'categoriesimg';
$redi = 'selectcategoriesimg';
}
$app->input->set('folder', $folder);
// Do not allow cache
JResponse::allowCache(false);
// Load css
JHtml::_('stylesheet', 'com_jem/backend.css', array(), true);
//get images
$images = $this->get('images');
$pagination = $this->get('Pagination');
if (count($images) > 0 || $search) {
$this->images = $images;
$this->folder = $folder;
$this->task = $redi;
$this->search = $search;
$this->state = $this->get('state');
$this->pagination = $pagination;
parent::display($tpl);
} else {
//no images in the folder, redirect to uploadscreen and raise notice
JError::raiseNotice('SOME_ERROR_CODE', JText::_('COM_JEM_NO_IMAGES_AVAILABLE'));
$this->setLayout('uploadimage');
$app->input->set('task', $task);
$this->_displayuploadimage($tpl);
return;
}
}
示例10: 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();
}
示例11: 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());
}
}
示例12: display
function display($tpl = null)
{
// Do not allow cache
JResponse::allowCache(false);
$app = JFactory::getApplication();
$lang = JFactory::getLanguage();
JHtml::_('stylesheet', 'media/popup-imagelist.css', array(), true);
if ($lang->isRTL()) {
JHtml::_('stylesheet', 'media/popup-imagelist_rtl.css', array(), true);
}
$css = '.item{position:relative; width:80px; height:80px; overflow:hidden;}
.item .titledoc{position:absolute;width:80px; bottom:0; left:0; padding:1px 0; background-color:#eee;}';
$document =& JFactory::getDocument();
//$document->addStyleSheet( JURI::base().'../plugins/system/fieldsattachment/js/style.css' );
$document->addStyleDeclaration($css);
$document = JFactory::getDocument();
$document->addScriptDeclaration("var ImageManager = window.parent.ImageManager;");
$images = $this->get('images');
$folders = $this->get('folders');
$state = $this->get('state');
$docs = $this->get('documents');
$this->assign('baseURL', COM_MEDIA_BASEURL);
$this->assignRef('images', $images);
$this->assignRef('folders', $folders);
$this->assignRef('docs', $docs);
$this->assignRef('state', $state);
parent::display($tpl);
}
示例13: 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);
}
示例14: t3_init
function t3_init()
{
t3import('core.parameter');
t3import('core.extendable');
t3import('core.template');
t3import('core.basetemplate');
t3import('core.cache');
t3import('core.head');
t3import('core.hook');
t3import('core.joomla.view');
if (!class_exists('JModuleHelper', false)) {
t3import('core.joomla.modulehelper');
}
t3import('core.joomla.pagination');
//Load template language
$this->loadLanguage('tpl_' . T3_ACTIVE_TEMPLATE, JPATH_SITE);
$params = T3Common::get_template_based_params();
//instance cache object.
$devmode = $params ? $params->get('devmode', '0') == '1' : false;
T3Cache::getInstance($devmode);
//Check if enable T3 info mode. Enable by default (if not set)
if ($params->get('infomode', 1) == 1) {
if (!JRequest::getCmd('t3info') && JRequest::getCmd('tp')) {
JRequest::setVar('t3info', JRequest::getCmd('tp'));
}
}
$key = T3Cache::getPageKey();
$data = null;
$user =& JFactory::getUser();
if (!$devmode && JRequest::getCmd('cache') != 'no') {
T3Cache::setCaching(true);
JResponse::allowCache(true);
}
$data = T3Cache::get($key);
if ($data) {
if (!preg_match('#<jdoc:include\\ type="([^"]+)" (.*)\\/>#iU', $data)) {
$mainframe = JFactory::getApplication();
$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($mainframe->getCfg('gzip'));
if (JDEBUG) {
global $_PROFILER;
$_PROFILER->mark('afterCache');
echo implode('', $_PROFILER->getBuffer());
}
$mainframe->close();
}
}
//Preload template
t3import('core.preload');
$preload = T3Preload::getInstance();
$preload->load();
$doc =& JFactory::getDocument();
$t3 = T3Template::getInstance($doc);
$t3->_html = $data;
}
示例15: send
/**
* Send response in JSON-format
* @param array $data
* @param bool $result
*/
public function send(array $data = array(), $result = true)
{
$data['result'] = $result;
JResponse::allowCache(false);
JResponse::setHeader('Last-Modified', gmdate('D, d M Y H:i:s', time()) . ' GMT', true);
JResponse::setHeader('Content-Type', 'application/json; charset=utf-8', true);
JResponse::sendHeaders();
jexit(json_encode($data));
}