Editor-xtd button plugin

This forum is for general questions about extensions for Joomla! version 1.5.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
User avatar
gubagy
Joomla! Apprentice
Joomla! Apprentice
Posts: 34
Joined: Sun May 17, 2009 12:57 pm
Location: The Netherlands

Editor-xtd button plugin

Postby gubagy » Thu Oct 28, 2010 11:21 am

Hi guys,

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 :D . 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 !!! :eek: 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;
}

?>


Here the xml file:

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>


and that is the error:

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

How you can guess in is not about the plugin itself but it really bugs me why it breaks. According to the author that is legitimate way for writing an editor-xtd plugins -> Obviously not :)


Any help highly appreciated

Thanks in advance

Cheers,
Guby
Learning is not mandatory...
Surviving also not !

stushev
Joomla! Apprentice
Joomla! Apprentice
Posts: 23
Joined: Tue Nov 02, 2010 8:14 pm
Contact:

Re: Editor-xtd button plugin

Postby stushev » Mon Dec 06, 2010 3:07 pm

http://tushev.org , go to Articles->Programming
Visit my site: http://tushev.org
(NEW: Tutorial: how to create editor button (editors-xtd) plugin )

Follow me on Twitter: http://twitter.com/tushevorg

User avatar
gubagy
Joomla! Apprentice
Joomla! Apprentice
Posts: 34
Joined: Sun May 17, 2009 12:57 pm
Location: The Netherlands

Re: Editor-xtd button plugin

Postby gubagy » Mon Dec 06, 2010 4:38 pm

stushev wrote:http://tushev.org, go to Articles->Programming


I looked at your article and realized I will need more than 2 min.Thanks Man or should I say Болшое Спасибо ;)
Learning is not mandatory...
Surviving also not !


Return to “Extensions for Joomla! 1.5”

Who is online

Users browsing this forum: No registered users and 17 guests