The Joomla! Forum ™



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.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Editor-xtd button plugin
PostPosted: Thu Oct 28, 2010 11:21 am 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun May 17, 2009 12:57 pm
Posts: 34
Location: The Netherlands
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:
<?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:
<?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>support@packtpub.com</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:
( ! ) 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 !


Top
 Profile  
 
PostPosted: Mon Dec 06, 2010 3:07 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Nov 02, 2010 8:14 pm
Posts: 23
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


Top
 Profile  
 
PostPosted: Mon Dec 06, 2010 4:38 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun May 17, 2009 12:57 pm
Posts: 34
Location: The Netherlands
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 !


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 



Who is online

Users browsing this forum: No registered users and 24 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group