Thứ Năm, 23 tháng 5, 2013

Adding access keys

Here's a quick way to add access keys to Joomla! 1.5.
Firstly edit the component.xml parameter definiton file in \administrator\components\com_menus\models\metadata and add to it an accesskey parameter:
<param name="accesskey" type="text" size="1" default="" label="Accessibility Access Key"
description="Accessibility Access Key for the page which this Menu item points to" />
Your file should now look something like:
    <?xml version="1.0" encoding="utf-8"?>
<metadata>
<state>
<name>Component</name>
<description>Component Parameters</description>
<params>
<param name="page_title" type="text" size="30" default="" label="Page Title"
description="PARAMPAGETITLE" />
<param name="show_page_title" type="radio" default="1" label="Show Page Title"
description="SHOW/HIDE THE PAGES TITLE">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param name="pageclass_sfx" type="text" size="20" default="" label="Page Class Suffix"
description="PARAMPAGECLASSSFX" />
<param name="@spacer" type="spacer" default="" label="" description="" />
<param name="menu_image" type="imagelist" directory="/images/stories" hide_default="1"
default="" label="Menu Image" description="PARAMMENUIMAGE" />
<param name="@spacer" type="spacer" default="" label="" description="" />
<param name="secure" type="radio" default="0" label="SSL Enabled" description="PARAMSECURE">
<option value="-1">Off</option>
<option value="0">Ignore</option>
<option value="1">On</option>
</param>
<param name="@spacer" type="spacer" default="" label="" description="" />
<param name="accesskey" type="text" size="1" default="" label="Accessibility Access Key"
description="Accessibility Access Key for the page which this Menu item points to" />
</params>
<advanced />
</state>
</metadata>
Now edit the frontend file \modules\mod_mainmenu\helper.php:
    // ACCESS KEY HACK - Part 1
$accessKey = $iParams->get('accesskey');
$tmp->accessKey = $accessKey;
and
    // ACCESS KEY HACK - Part 2
if ($tmp->accessKey)
$data = '<a href="'.$tmp->url.'" accesskey="'.$tmp->accessKey.'">'.$image.$tmp->name.'</a>';
else
$data = '<a href="'.$tmp->url.'" >'.$image.$tmp->name.'</a>';
into the _getItemData($item) function so that it looks like this
    function _getItemData($item)
{
$data = null;
 
// Menu Link is a special type that is a link to another item
if ($item->type == 'menulink')
{
$menu = &JSite::getMenu();
if ($tmp = clone($menu->getItem($item->query['Itemid']))) {
$tmp->name = '<span><![CDATA['.$item->name.']]></span>';
$tmp->mid = $item->id;
$tmp->parent = $item->parent;
} else {
return false;
}
} else {
$tmp = clone($item);
$tmp->name = '<span><![CDATA['.$item->name.']]></span>';
}
 
$iParams = new JParameter($tmp->params);
if ($iParams->get('menu_image') && $iParams->get('menu_image') != -1) {
$image = '<img src="'.JURI::base(true).'/images/stories/'.$iParams->get('menu_image').'" alt="" />';
} else {
$image = null;
}
 
 
// ACCESS KEY HACK - Part 1
$accessKey = $iParams->get('accesskey');
$tmp->accessKey = $accessKey;
 
switch ($tmp->type)
{
case 'separator' :
return '<span class="separator">'.$image.$tmp->name.'</span>';
break;
 
case 'url' :
if ((strpos($tmp->link, 'index.php?') !== false) && (strpos($tmp->link, 'Itemid=') === false)) {
$tmp->url = $tmp->link.'&amp;Itemid='.$tmp->id;
} else {
$tmp->url = $tmp->link;
}
break;
 
default :
$router = JSite::getRouter();
$tmp->url = $router->getMode() == JROUTER_MODE_SEF ?
'index.php?Itemid='.$tmp->id : $tmp->link.'&Itemid='.$tmp->id;
break;
}
 
// Print a link if it exists
if ($tmp->url != null)
{
// Handle SSL links
$iSecure = $iParams->def('secure', 0);
if ($tmp->home == 1) {
$tmp->url = JURI::base();
} elseif (strcasecmp(substr($tmp->url, 0, 4), 'http') && (strpos($tmp->link, 'index.php?') !== false)) {
$tmp->url = JRoute::_($tmp->url, true, $iSecure);
} else {
$tmp->url = str_replace('&', '&amp;', $tmp->url);
}
 
switch ($tmp->browserNav)
{
default:
case 0:
// _top
// ACCESS KEY HACK - Part 2 ###############################
if ($tmp->accessKey)
$data = '<a href="'.$tmp->url.'" accesskey="'.$tmp->accessKey.'">'.$image.$tmp->name.'</a>';
else
$data = '<a href="'.$tmp->url.'" >'.$image.$tmp->name.'</a>';
break;
case 1:
// _blank
$data = '<a href="'.$tmp->url.'" target="_blank">'.$image.$tmp->name.'</a>';
break;
case 2:
// window.open
$attribs = 'toolbar=no,location=no,status=no,menubar=no,
scrollbars=yes,resizable=yes,'
.$this->_params->get('window_open');
 
// hrm...this is a bit dickey
$link = str_replace('index.php', 'index2.php', $tmp->url);
$data = '<a href="'.$link.'" onclick="window.open(this.href,\'targetWindow\',\''.$attribs.'\');
return false;">'
.$image.$tmp->name.'</a>';
break;
}
} else {
$data = '<a>'.$image.$tmp->name.'</a>';
}
 
return $data;
 
}
Login to your admin site and edit a menu item. Now open the "Parameters - System" accordion item on the right and you will see your accesskey parameter. Set a value, save the menu item and voila.

Thứ Tư, 22 tháng 5, 2013

Plugin Developer Overview


Joomla! 1.5 introduced the JPlugin class. In the effort to move Joomla! toward a more efficient object-oriented framework, a new plugin system has been developed which follows the Observer pattern. Plugins are observer classes that attach to a global event dispatcher object in the Joomla! core. What does this mean in English? It means that either the Joomla! core or a third party component or module can trigger an event which causes one or more plugins to execute some code.

Implementation

The implementation of the plugin system is that of an observer pattern. It has two parts, an observer class, JPlugin, and an observable class, JEventDispatcher.
/**
* JPlugin Class
*
* @package Joomla.Framework
* @subpackage Application
* @since 1.5
*/

class JPlugin extends JObserver
{
/**
* 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.
*
* @param object $subject The object to observe
* @since 1.5
*/

function JPlugin(& $subject)
{
parent::__construct($subject);
}
 
/**
* Method to map events to handler methods
*
* @access public
* @param array Arguments
* @return mixed Routine return value
* @since 1.1
*/

function update( &$args )
{
/*
* First lets get the event from the argument array. Next we will unset the
* event argument as it has no bearing on the method to handle the event.
*/

$event = $args['event'];
unset($args['event']);
 
/*
* If the method to handle an event exists, call it and return its return
* value. If it does not exist, return a boolean true.
*/

if (method_exists($this, $event)) {
return call_user_func_array(array($this, $event), $args);
} else {
return true;
}
}
}
There are two important things that makes this class work.
One is the constructor which actually gets executed by the parent class of this class JObserver. The following is what happens in the constructor:
// Register the observer ($this) so we can be notified
$subject->attach($this);
 
// Set the subject to observe
$this->_subject = &$subject;
This attaches the JPlugin to an observable object. In the case of plugins, they observe the JEventDispatcher object.
The second important thing to note is the update method. The update method is passed an array from its trigger. The array contains two elements - the event and the arguments. Once the update method receives this array it extracts the event and removes it from the arguments. It then calls a method of name ‘event’ (passing the arguments array) and returns its response.

Third Party Usage

<?php
/**
* @version $Id: $
* @package
* @subpackage
* @copyright
* @license
*/

 
jimport('joomla.plugin');
 
 
/**
* Example Plugin
*
* @author
* @package
* @subpackage
* @since
*/

class ExamplePlugin extends JPlugin
{
/**
* Constructor
*
* @param object $subject The object to observe
* @since 1.1
*/

function ExamplePlugin( &$subject ) {
parent::__construct( $subject );
}
 
/**
* This method handles the onIncrement event. It takes an integer input and
* increments its value.
*
* @access public
* @param int $input An integer to increment
* @return int Incremented integer
* @since 1.1
*/

function onIncrement($input)
{
return $input++;
}
}
?>
As you can see, it is quite simple to create a JPlugin. It is truly as simple as creating a class that extends JPlugin and writing a method for each event you want the plugin to handle.

Plugin


A plugin is a kind of Joomla! extension. Plugins provide functions which are associated with trigger events. Joomla provides a set of core plugin events, but any extension can fire (custom) events. When a particular event occurs, all plugin functions of the type associated with the event are executed in sequence. This is a powerful way of extending the functionality of the Joomla! Framework. It also offers extension developers a way to allow other extensions to respond to their actions, making extensions extensible.
The Joomla! plugin architecture follows the Observer design pattern. The JPlugin class is derived from JObserver and provides the means to register custom plugin code with core or custom events. The JEventDispatcher class, derived from JObservable, is an event handler which calls all plugins registered for a particular event, when that event is triggered.
See alsoComponentModuleTemplate

Accessing the database using JDatabase


Supported Storage Connectors

The table below outlines the database and storage connectors available for Joomla! as well as which version of Joomla they became available in.
To make a connector available in Joomla's installer or global configuration manager, you will need to ensure the PHP library is installed (E.g. for PHP5 and MySQL the php5-mysql library would need to be installed).
DatabaseJoomla Versions
MySQLJoomla 1.5Joomla 2.5Joomla 3.0
PostgresqlJoomla 3.0
Microsoft SQL ServerJoomla 2.5Joomla 3.0
Microsoft SQL AzureJoomla 2.5Joomla 3.0
Oracle DBJoomla 3.0
SQL LiteJoomla 3.0
PHP Data Objects (PDO)*Joomla 3.0
  • PHP Data Objects is a database abstraction layer and is shipped with PHP 5.1+.

Joomla 3 FAQ


What are the major differences between Joomla! 2.5 and 3?

The most noticeable difference is the totally revamped administrator, which is updated to a modern design with many simpler and more friendly user-interfaces. Also, starting with Joomla! 3.0, Joomla! is now device responsive. Simply, Joomla! is mobile friendly and can be used with any modern device.
In addition, there are dozens of improvements to the details of all of the Joomla core. Some highlights are:
Star icon.png A new installer which you will notice when creating a new Joomla 3.x install.
Star icon.png Joomla 3 is packed with goodies for extension developers, such as Bootstrap support and jQuery support.
Star icon.png Joomla 3.1 adds Tagging capability.

How long is each Joomla! version supported?

Each major release of Joomla is supported for over 4 years and includes one-click upgrades. For example, the 2.x series (which included 1.6 and 1.7 due to naming conflicts) has a support life of over 4 years (January 2011 until December 31st, 2014). 1.6 to 1.7 was a one-click upgrade. 1.7 to 2.5 was a one click upgrade. 2.5 will be supported until December 31st of 2014. So the 2.x series has over four years of support and, overall, it was a smooth experience for users and extension developers.
The 3.x series will have over 4 years of support as well. This of course is taking into account all the STS versions, 3.0 to 3.1 then 3.2 which will only have 7 months of support each, followed by last version, 3.5. The final version of the 3.x series will be Joomla! 3.5, an LTS version, planned for release in March of 2014 with support until the end of 2016. All of the Joomla! 3.x versions will be one-click upgrades and should, overall, be smooth transitions for users and developers as the 2.x series was.
Because Joomla's new timed-release cycle makes moving from major version to major version (e.g. 2.x to 3.x) relatively simple (see the below FAQ's for more information), users get the added benefit of compounded support, where they can move from major version to major version to get continued and uninterrupted support.

I'm building a brand new site. Should I launch a Joomla! 2.5 site or a 3.x site?

For most new sites, the Joomla! 3 series is the preferred series and starting on it avoids a mini-migration from Joomla 2.5 later down the road. Starting on the Joomla 3 series for a new site, also provides you with longer backward compatible support (with one-click upgrades) than starting a new site on 2.5 right now, because support for 3.x ends in 2016.
When starting a new site, please plan ahead and check to make sure that any extensions (including templates) that you plan to use are Joomla 3 compatible. If not, then Joomla 2.5 still provides you a well supported option in the meantime.
Sites that are currently on Joomla 2.5 are encouraged to stay on 2.5, until Joomla 3.5’s release, unless they need to be moved over sooner to take advantage of Joomla 3’s new features. We’ve provided a one-click upgrade from Joomla 2.5 to any Joomla 3 version and you just have to make sure that all your extensions are compatible before upgrading. (See the “How do I find Joomla 3.x compatible extensions?” FAQ below for more information)

If I launch a Joomla! 3 site, will I be able to install extensions?

Yes, you will be able to install extensions compatible with Joomla 3.x. The Joomla Extension Directory (JED) will have a Joomla 3.x compatible icon to know which extensions are Joomla 3.x compatible; however, the best place to check is the developer’s site.

How do I get a Joomla! 3.x template?

Some template companies will be offering Joomla 3 templates either right away or shortly after release, but you will need to ask each one. Some have already announced that their templates will be ready for Joomla 3 when it is released, but others have not. Also, please note that some Joomla 2.5 templates will work in Joomla 3 without any issues or any changes needed. It's best to consult with the developers on this.

How do I find Joomla! 3.x compatible extensions?

Visit Joomla Extension Directory (JED), which will have Joomla 3.0 compatible icons to let you know which extensions are Joomla 3.x compatible; however, the best place to check is your extension developer’s site.

Will my Joomla! 2.5 extensions work with Joomla! 3.x?

Extensions that are native to Joomla 2.5 should work on Joomla 3.0 with very little change, if any. Components and templates will need the most work, while modules and plugins should work without issue (assuming they do not use deprecated methods). Extensions that support Joomla 2.5 and 1.5 in the same package will likely not work right away, until the developers update them for Joomla 3 compatibility.
In short, it depends on the extension. The Joomla Project has made the process relatively easy for most extensions, however for some extensions it’s going to take some work. To be certain, let the developers of the extensions know that you want to use their extension on Joomla 3 and consult with their documentation.

What happens if I launch a Joomla! 3.x site, but the extension I want is for a 2.5 site?

You need to speak with the extension developer to see if they have plans to release that extension for Joomla 3 in the immediate future. Developers do have to make some changes but how extensive they are depends on the extension.

Should I update from Joomla! 2.5 to 3.x?

In most cases, probably not. Joomla 2.5 will continue be supported until December 31st of 2014 and you can update directly to Joomla 3 once it’s tried-and-tested thoroughly by other users. You can even wait until Joomla 3.5 which will be released in a year from now and still get a direct upgrade. The only reason you should update is if you need Joomla 3’s features or want to be on the leading edge.

I have a 2.5 site and I see a that the Joomla! update manager lets me upgrade to 3.x; should I do it since it’s letting me?

Not unless you’re 1000% sure. By default, Joomla will not let you update to 3.x unless you activate the option within the Joomla! Update component (administrator >> Component >> Joomla! Update >> Options >> Update server >> Short Term Support). If for some reason you’ve changed this, and you’d like the updater to stop letting you upgrade, change the setting to Long Term Support. After making this change, you’ll only receive updates for Joomla 2.5.
Notice: You should not upgrade from Joomla 2.5 to Joomla 3.x unless you are certain that all of your additionally installed extensions (from third party developers), especially templates, are Joomla 3.x ready or have a Joomla 3.x version that you can upgrade to.

What’s next after Joomla 3.0?

Joomla 3.1 will be released around April 15th, 2013. Don't worry though, because it's a one-click upgrade and will be backward compatible. If you’re on Joomla 3.0, you will need to upgrade to 3.1 at that time using the one-click upgrader. If you’re still on Joomla 2.5, you can continue to wait until Joomla 3.5 and still get a direct upgrade.

Okay, I’m ready and want to upgrade. How do I do the upgrade?

  • First, review the system requirements for Joomla 3.x and make sure that your server environment meets those requirements.
  • Second, make sure that all your extensions (especially, your templates) are Joomla 3.x compatible.
  • Third, create a test site and test the upgrade on the test site first.
  • Fourth, consult a trusted developer if you’re not 100% certain about anything.
  • Fifth, make a full backup of your site (files and database).
Once ready, go to the Joomla! Update component. Click on options and change the setting to Short Term Support. Save. You should be notified of the availability of Joomla 3.x. Click the button to install. Clear your browser’s cache to make sure you see the latest changes. That’s it!
Finally, double check and make sure that everything is working properly.
Note: On some hosts you may need to use alternative update methods such as using the extensions installer.

But what if I’m on Joomla 1.5. Will my site break? Do I migrate to 2.5 or the current version of 3?

Support for Joomla 1.5 has officially ended. Does that mean your 1.5 site will stop working? No, your site will continue to work as it always has. However, Joomla’s developers will not be releasing new versions for Joomla 1.5, so you won’t be getting bug fixes or security fixes. For this reason, it’s recommended to migrate from 1.5.
Moving from 2.5 to any Joomla 3 version is relatively simple, since Joomla has made the process easy for newer versions. Unfortunately, moving from 1.5 is not a trivial task. Fortunately, there are two good extensions that make the process easier: jUpgrade and SP Upgrade.
You have a choice of going straight to Joomla 3.0 or going to 2.5 first. Both SP Upgrade and jUpgrade have versions ready for both versions. Please consult with their documentation on how to migrate from Joomla 1.5 to 3.0/2.5.
Migrate to Joomla 3.0 if all the extensions that you plan to use are Joomla 3.0 compatible. Only some template providers or the extension vendors will be ready for Joomla 3.0 at launch, however most will not be ready until days, weeks or months after. (See the “How do I find Joomla 3.0 compatible extensions?” FAQ for more information)
Migrate to Joomla 2.5 if you want the most stable that Joomla has to offer and/or if you plan on using many extensions.

OK, final question. Where can I get more information about Joomla 3?

You can get more information at http://www.joomla.org/3.

We hope you enjoy Joomla 3 as much as we do! Thanks for reading this FAQ.
FAQ Contributors:
Gary Jay Brooks, Nick Savov, Elin Waring, Jon Neubauer, Guillermo Bravo
FAQ Reviewers:
Sully Sullivan, Michael Babker, Andrea Tarr, Mark Dexter, Brian Teeman

Thứ Ba, 21 tháng 5, 2013

JDOC:Joomla! Doc Camp


Welcome to the first world-wide Joomla! Doc Camp. Following on from the huge success of the Joomla! 1.5 bug squashing event, please join us for a weekend of authoring at locations around the planet. We have tasks for everyone; coders and non-coders alike. Our aim is to dramatically increase the volume of documentation available for Joomla! 1.5.
This wiki will be used as the central resource for coordinating efforts and accumulating results from this event. After the event it will become a new central hub for the official Joomla! documentation.

Locations

North America

Vancouver, Canada 9AM to 6PM PST (GMT -8) on 19 January 2008. <countdown time="01/19/2008 9:00 AM UTC-0800"> Thanks to everyone in Vancouver for your efforts.</countdown>

Europe

Brussels, Belgium 10AM to 7PM CET (GMT +1) on 21 January 2008. <countdown time="01/21/2008 10:00 AM UTC+0100"> Thanks to everyone in Brussels for your efforts.</countdown>

Cyberspace

Internet Relay Chat (IRC)
Freenode channel #joomladocs from 19 to 21 January 2008, all times, all timezones.
This channel is available now and throughout the event.

Registration

for write access to this wiki

To get write access to this wiki you will need to register here first. Please be aware that the registration process requires a valid email address. If you are travelling to one of the physical locations you are advised to ensure that you have registered on this wiki and have a valid login before you travel. You don't need access to your email account after registration.

at a physical location

If you wish to be present at one of the physical locations listed above then you must register in advance as space is limited. Registrations are the responsibility of the individual location organisers and you should click on the appropriate link above for more information.

Requirements

  • All contributions must be made available under the Joomla! Electronic Documentation License. Further information on the JEDL is available in the JEDL Frequently Asked Questions
  • No advertising or self-promotion will be allowed. This includes backlinks to your website or anyone else's. The one exception is that if you have made a contribution then feel free to add your name and an optional link to your website to the Doc Camp Contributors List
  • All contributions must be in English. Note that the official language of the Joomla! project is British/Australian English.

Where to go next

Doc Campers Start Here
Once you have read the above then please click the link below to begin:

License

License
The contents of this wiki are subject to copyright law and are made available under the Joomla! Electronic Documentation License (JEDL) unless otherwise stated. You may find the JEDL Frequently Asked Questions useful in determining if your proposed use of this material is allowed. If you have any questions regarding licensing of this material please contactlegal@opensourcematters.org. If you wish to report a possible violation of the license terms for the material on this site then please contact legal@opensourcematters.org.

Contributors