What is causing this error? jquery.php? version=1.3.2&gzip=0&farfuture=0:1

Asked

Viewed 80 times

1

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’ve done some research and it seems to be related to Fututre Expire header, but I also think it may be that the Jquery version is outdated. The site was created through Joomla. If anyone can help me identify the problem, I’d be most grateful.

Here follows the jquery.php from which the error arose:

<?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.'&amp;gzip='.$gzip.'&amp;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");

}

  • @Daniel Omine Thanks for the answer, I added the code, I thought it was an easier mistake to identify. I’m still quite inexperienced in php, I just know the basics, I’m sorry if I wasn’t as clear as I should have been. Do you have any suggestions on how to debug? I think it is not punctuation flaws because this php has already been functional, I am more inclined to file corruption. The site has undergone a joomla migration and some problems have arisen, and with that changes in code may be causing conflicts

  • @Daniel Omine the error appears in all, but only in the console when I "inspect element", the pages work well in principle. I’m the one in charge of trying to fix the errors that appear on the console. The plugin that the code is trying to access is the system - jquery that I have also checked and is in version 1.3.2.

  • Checks the order you call the plugins

  • @msm.oliveira Can you give me some hint on how to do this?

  • It’s the first time I’ve heard of joomla and I’ve never used php. One of the things that may be causing the error may be the order you call plugins: http://prntscr.com/7ablt7 . This has an order, because plugins need other classes that also have to be imported

  • Now that you mention it, there’s another error that pops up in the plugin calls: <<script type="text/javascript" src="<? php echo $this->baseurl; ? >/templates/<? php echo $this->template? >/scripts/layout.js"></script> Says $ is not a function. This could be it?

  • see the appropriate way to add the javascript file: https://docs.joomla.org/Adding_JavaScript

  • @angelfmf if it says $ is not function then it is because you should not be making the import of jquery as it should be

  • @Daniel Omine No, I already checked and joomla is not using Smarty. but, the templates have all script, css and php folders. I don’t know much about templates but in this website everything is divided like this. And thanks for the document, it will be very +useful

  • then which template system is using ?

  • @Daniel Omine Hathor admin template

  • @msm.oliveira I tried to change import via this link[http://stackoverflow.com/questions/12471067/importing-jquery-into-joomla] but to no avail. the code I modified is last in question.

  • @Daniel Omine I said "Hathor admin template" here is a video that talks about the template if you are interested in seeing it. [https://www.youtube.com/watch?v=ZXOjzpx22r4]

  • sorry, I do not participate in chat, even more to solve other people’s work..

Show 10 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.