Error in ChronoForms-MooTools 1.2 guide

quenda 08 Apr, 2011
Hallo!
Since I need to use the ShowPlus image slideshow module (http://hunyadi.info.hu/en/projects/showplus) in this website:

http://www.nastribrizzolari.com

...I need to activate the System - Mootools Upgrade in the joomla backend.

The Mootools Upgrade plug-in is the cause of some validation errors in my two forms (Italian and English) in the website that you can find here:

http://www.nastribrizzolari.com/en/catalogues-request.html

FYI: I don't use the ChronoForms Language Plugin.

So I've downloaded the files and the ChronoForms and MooTools 1.2 PDF guide from:

http://greyhead.net/how-to-docs/chronoforms-and-mootools-12

I've followed the guide but in the end my whole site disappeared with this message:

Parse error: syntax error, unexpected $end, expecting T_FUNCTION in /var/www/nastribrizzolari/plugins/system/mtupgrade.php on line 52

Since I'm not a programmer I've asked for help to my web hosting provider and we have discovered a very small error in the code indicated on page 4 of the ChronoForms and MooTools 1.2 PDF guide: a small bracket in the wrong place! (see image).

[attachment=0]error.jpg[/attachment]

I've deleted the bracket and now everything looks good except for this alert on form submission:

Notice: Undefined variable: script in /var/www/nastribrizzolari/components/com_chronocontact/libraries/includes/JSvalidation.php on line 5

I hope that you can correct the PDF guide and maybe give me an help about the error in the JSvalidation.php file.

Thank-you!!

ettore
GreyHead 08 Apr, 2011
Hi quenda,

I'll look at this in detail later but my initial reaction is that removing that bracket will break your site. So something else must be happening here to make it OK.

Later: as far as I can see removing that bracket only makes sense if you have accidentally deleted the final } at the end of the mtupgrade.php file. The correct code looks like this (from line 19 on):
class plgSystemMTUpgrade extends JPlugin
{
	/**
	 * Constructor
	 *
	 * For php4 compatability we must not use the __constructor as a constructor for plugins
	 * because func_get_args ( void ) returns a copy of all passed arguments NOT references.
	 * This causes problems with cross-referencing necessary for the observer design pattern.
	 *
	 * @access	protected
	 * @param	object	$subject The object to observe
	 * @param 	array   $config  An array that holds the plugin configuration
	 * @since	1.0
	 */
	function plgSystemMTUpgrade(& $subject, $config)
	{
		parent::__construct($subject, $config);
	}

	/**
	 * onAfterInitialise handler
	 *
	 * Adds the mtupgrade folder to the list of directories to search for JHTML helpers.
	 *
	 * @access	public
	 * @return null
	 */
	function onAfterInitialise()
	{
		global $mainframe;
		if ( $mainframe->isSite() ) {
			JHTML::addIncludePath(JPATH_PLUGINS.DS.'system'.DS.'mtupgrade');
		}
	}
}


Bob
GreyHead 08 Apr, 2011
Hi quenda,

Which version of ChronoForms are you using? I don't see any mention of a 'script' variable in the JSvalidation.php files that I have?

PHP undefined variable Notices will be hidden if you set your site Error Reporting to System Default or None in the site Global Configuration.

Bob
quenda 08 Apr, 2011
Hallo Bob!
First of all a very big thank you for your ultra-fast answer and great support.

Your observation on the final } at the end of the mtupgrade.php file in absolutely right.

In my case I have done a mistake with the copy & paste step from the PDF Guide to the mtupgrade.php file. Now I know that is very important to have THREE } at the end of the mtupgrade.php file.

---------------

Now, in my .htaccess file if I set the errors messages to off:

php_flag display_errors off


...the

Notice: Undefined variable: script in /var/www/nastribrizzolari/components/com_chronocontact/libraries/includes/JSvalidation.php on line 5

message is hidden.

But of course if I set (in the .htaccess file):

php_flag display_errors on


The message will show again.

Do you think that everything is OK and I don't need to worry about the "Undefined variable" message??

Thank you again and sorry for my English!

ettore

P.S.: I'm using:

COMPONENT: Chrono Contact V3.2

MODULE (inactive): mod_chronocontact 1.3/ V3.1 RC5.2

PLUGIN (active): chronocontact V3.1 RC5.2
GreyHead 08 Apr, 2011
Hi quenda,

You don't need to worry about it. PHP gives all sorts of Notices, Warnings and Deprecated messages about code that *might* be a problem. Most of the time they are not problems.

Production sites should typically be run with these messages hidden - if you are coding though it's better to have them shown so that they can be fixed.

Bob
This topic is locked and no more replies can be posted.