Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Remove the command scheduler JavaScript from the "fe_page" template
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Apr 16, 2014
1 parent 16f5c7e commit a90a355
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 33 deletions.
2 changes: 1 addition & 1 deletion system/modules/core/classes/Frontend.php
Expand Up @@ -623,7 +623,7 @@ protected function prepareMetaDescription($strText)
* Return the cron timeout in seconds
* @return integer
*/
protected function getCronTimeout()
public static function getCronTimeout()
{
if (!empty($GLOBALS['TL_CRON']['minutely']))
{
Expand Down
26 changes: 26 additions & 0 deletions system/modules/core/library/Contao/Controller.php
Expand Up @@ -1838,6 +1838,32 @@ public static function replaceDynamicScriptTags($strBuffer)
}
}

$strSearchCron = '';

// Add to search index
if (\Config::get('enableSearch'))
{
$strSearchCron .= 'setTimeout(function(){try{var e=new XMLHttpRequest}catch(t){return}e.open("GET",window.location.href,!0),e.setRequestHeader("Index-Page",!0),e.setRequestHeader("X-Requested-With","XMLHttpRequest"),e.send()},1e4);';
}

// Command scheduler
if (!\Config::get('disableCron'))
{
$strSearchCron .= 'setTimeout(function(){var e=function(e,t){try{var n=new XMLHttpRequest}catch(r){return}n.open("GET",e,!0),n.onreadystatechange=function(){this.readyState==4&&this.status==200&&typeof t=="function"&&t(this.responseText)},n.send()},t="system/cron/cron.";e(t+"txt",function(n){parseInt(n||0)<Math.round(+(new Date)/1e3)-' . \Frontend::getCronTimeout() . '&&e(t+"php")})},5e3);';
}

if ($strSearchCron != '')
{
if ($blnXhtml)
{
$strScripts .= "\n" . '<script type="text/javascript">' . "\n/* <![CDATA[ */\n" . $strSearchCron . "\n/* ]]> */\n" . '</script>' . "\n";
}
else
{
$strScripts .= "\n" . '<script>' . $strSearchCron . '</script>' . "\n";
}
}

$arrReplace['[[TL_BODY]]'] = $strScripts;
$strScripts = '';

Expand Down
19 changes: 1 addition & 18 deletions system/modules/core/pages/PageRegular.php
Expand Up @@ -444,22 +444,6 @@ protected function createTemplate($objPage, $objLayout)
$GLOBALS['TL_JAVASCRIPT'] = array_merge($GLOBALS['TL_JAVASCRIPT'], $arrAppendJs);
}

$strJsBottom = '';

// Add to search index
if (\Config::get('enableSearch'))
{
$strJsBottom .= 'setTimeout(function(){try{var e=new XMLHttpRequest}catch(t){return}e.open("GET",window.location.href,!0),e.setRequestHeader("Index-Page",!0),e.setRequestHeader("X-Requested-With","XMLHttpRequest"),e.send()},1e4);';
}

$intTimeout = $this->getCronTimeout();

// Command scheduler
if (!\Config::get('disableCron'))
{
$strJsBottom .= 'setTimeout(function(){var e=function(e,t){try{var n=new XMLHttpRequest}catch(r){return}n.open("GET",e,!0),n.onreadystatechange=function(){this.readyState==4&&this.status==200&&typeof t=="function"&&t(this.responseText)},n.send()},t="system/cron/cron.";e(t+"txt",function(n){parseInt(n||0)<Math.round(+(new Date)/1e3)-' . $intTimeout . '&&e(t+"php")})},5e3);';
}

// Initialize the sections
$this->Template->header = '';
$this->Template->left = '';
Expand All @@ -477,8 +461,7 @@ protected function createTemplate($objPage, $objLayout)
$this->Template->charset = \Config::get('characterSet');
$this->Template->base = \Environment::get('base');
$this->Template->disableCron = \Config::get('disableCron');
$this->Template->cronTimeout = $intTimeout;
$this->Template->jsBottom = $strJsBottom;
$this->Template->cronTimeout = $this->getCronTimeout();

This comment has been minimized.

Copy link
@Toflar

Toflar Apr 16, 2014

Member

This should be called statically? :)

}


Expand Down
6 changes: 0 additions & 6 deletions system/modules/core/templates/frontend/fe_page.html5
Expand Up @@ -76,11 +76,5 @@

<?php echo $this->mootools; ?>

<?php if ($this->jsBottom): ?>
<script>
<?php echo $this->jsBottom; ?>
</script>
<?php endif; ?>

</body>
</html>
8 changes: 0 additions & 8 deletions system/modules/core/templates/frontend/fe_page.xhtml
Expand Up @@ -77,13 +77,5 @@

<?php echo $this->mootools; ?>

<?php if ($this->jsBottom): ?>
<script type="text/javascript">
/* <![CDATA[ */
<?php echo $this->jsBottom; ?>
/* ]]> */
</script>
<?php endif; ?>

</body>
</html>

0 comments on commit a90a355

Please sign in to comment.