I'm having trouble identifying this error that appears on one of the pages of a website:
Uncaught SyntaxError: Unexpected identifier jquery.php? version = 1.3.2 & gzip = 0 & farfuture = 0: 1
I did some research and it looks like it's related to Fututre Expire header
, but I also think it might be the JQuery version being outdated. The site was created through Joomla. If anyone can help me identify the problem, I am very grateful.
Here is the jquery.php where the error came from:
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
/**
* jQuery loading plugin
*
* @version 1.0
*/
//TODO: Create translation ini files
class plgSystemJquery extends JPlugin {
function plgSystemJquery(& $subject, $config) {
parent::__construct($subject, $config);
}
function _getPath() {
$mainframe =& JFactory::getApplication();
$gzip = $this->params->get('gzip', 0);
$farfuture = $this->params->get('farfuture', 0);
$version = $this->params->get('version','1.3.2');
$path = 'plugins/system/jquery/';
// if (!$gzip && !$farfuture) {
// $file = 'jquery-'.$version.'.min.js';
// } else {
$file = 'jquery.php?version='.$version.'&gzip='.$gzip.'&farfuture='.$farfuture;
// }
// Prepend ../ if we're in the backend
if($mainframe->isAdmin()) {
$path = '../'.$path;
}
return $path.$file;
}
function onAfterDispatch() {
$doc =& JFactory::getDocument();
if ($doc->getType() == 'html' && $this->params->get('bottomscript', 0) == 1) {
$version = $this->params->get('version','1.3.2');
$js = '<script type="text/javascript">if (typeof(jQuery) == "undefined" || (typeof(jQuery) != "undefined" && jQuery.fn.jquery != "'.$version.'") )
document.write(unescape("%3Cscript src=\''.self::_getPath().' \' type=\'text/javascript\'%3E%3C/script%3E"));</script>';
JResponse::appendBody($js);
$js = '<script type="text/javascript">$jquery = jQuery.noConflict();</script>';
JResponse::appendBody($js);
}
if ($doc->getType() == 'html' && $this->params->get('bottomscript', 0) == 0) {
// Add jquery to the scripts
$doc->addScript(self::_getPath());
// Get head data
$headdata = $doc->getHeadData();
// Take the scripts part
$scripts = $headdata['scripts'];
// Reverse the array so we can pick jquery easily
$revscripts = array_reverse($scripts,true);
// Take the jquery field
$keys = array_keys($revscripts);
$key = $keys[0];
$jqueryscript = $revscripts[$key];
// Reconstruct the scripts array with jquery as first
$newscripts[$key] = $jqueryscript;
foreach ($scripts as $path=>$type) {
$newscripts[$path] = $type;
}
// Set the new head data
$doc->setHeadData (array('scripts'=>$newscripts));
}
}
}
Code modifications:
class plgSystemJquery extends JPlugin {
function plgSystemJquery(&$subject, $config) {
parent::__construct($subject, $config);
}
function _getPath() {
$mainframe =& JFactory::getApplication();
if(!JFactory::getApplication()->get('jquery')){
JFactory::getApplication()->set('jquery',true);
$mainframe = JFactory::getDocument();
$mainframe->addScript(JURI::root() . "templates/movimentoeleclerc/scripts/jquery.js");
}