After several years of fascination with Joomla! I took the decision to get my hand dirty in code and programming. The last time when had written something that a computer can understand was for 8 bit computers when was teenager . So i made free time and got into PHP - I loved it ! and consequently I bought a book (according to the authors) Professional guide to programming Joomla!. Everything was going fine up to the moment i decided to test the provided code. It was broken !!! a real "Professional guide" !
It is a Editor-xtd button plugin and that is the PHP code:
Code: Select all
<?php
// no direct access
defined('_JEXEC') or die('Restricted access');
$mainframe->registerEvent('onCustomEditorButton', 'plgSmileyButton');
/**
* Smiley button
*
* @name string Name of the editor
* @return array Array of three elements: JavaScript action, Button name, CSS class.
*/
function plgSmileyButton($name)
{
global $mainframe;
// get the image base URI
$doc =& JFactory::getDocument();
$url = $mainframe->isAdmin() ? $mainframe->getSiteURL() : JURI::base();
// get the JavaScript
$js = "
function insertSmiley()
{
jInsertEditorText(' :) ');
}
";
$css = " .button1-left .smiley { background: url($url/plugins/editors-xtd/smiley1.gif) 100% 0 no-repeat; }";
$css .= "\n .button2-left .smiley { background: url($url/plugins/editors-xtd/smiley2.gif) 100% 0 no-repeat; }";
$doc->addStyleDeclaration($css);
$doc->addScriptDeclaration($js);
$button = array("insertSmiley()", JText::_('Smiley'), 'smiley');
return $button;
}
?>
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<install version="1.5.0" type="plugin" group="editors-xtd" method="upgrade">
<name>Button - Smiley</name>
<author>Box Office Software</author>
<authorEmail>[email protected]</authorEmail>
<authorUrl>www.packtpub.com</authorUrl>
<copyright>Copyright (C) 2009 </copyright>
<creationDate>November 14, 2009</creationDate>
<description>This plugin adds</description>
<license>GNU/GPL</license>
<version>1.07.00</version>
<files>
<filename plugin="smiley">smiley.php</filename>
<filename>smiley1.gif</filename>
<filename>smiley2.gif</filename>
</files>
<params />
</install>
Code: Select all
( ! ) Fatal error: Call to undefined method stdClass::onDisplay() in C:\wamp\www\joomla\libraries\joomla\html\editor.php on line 268
Call Stack
# Time Memory Function Location
1 0.0004 348920 {main}( ) ..\index.php:0
2 0.1325 3984088 JAdministrator->dispatch( ) ..\index.php:67
3 0.1397 4515696 JComponentHelper->renderComponent( ) ..\application.php:136
4 0.1495 4635456 require_once( 'C:\wamp\www\joomla\administrator\components\com_content\admin.content.php' ) ..\helper.php:162
5 0.1609 5698280 ContentController->editContent( ) ..\admin.content.php:42
6 0.2866 6329320 ContentView->editContent( ) ..\controller.php:451
7 0.3506 6829640 JEditor->display( ) ..\admin.content.html.php:513
8 0.3506 6830520 JEvent->update( ) ..\editor.php:152
9 0.3506 6831200 call_user_func_array ( ) ..\event.php:67
10 0.3506 6831240 plgEditorTinymce->onDisplay( ) ..\event.php:0
11 0.3507 6832408 plgEditorTinymce->_displayButtons( ) ..\tinymce.php:627
12 0.3511 6834736 JEditor->getButtons( ) ..\tinymce.php:684
Any help highly appreciated
Thanks in advance
Cheers,
Guby