3 * @version $Id: plugin.php 4955 2012-06-09 10:11:23Z fishbone $
4 * @package Joomla.Framework
6 * @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
7 * @license GNU/GPL, see LICENSE.php
8 * Joomla! is free software. This version may have been modified pursuant
9 * to the GNU General Public License, and as distributed it includes or
10 * is derivative of works licensed under the GNU General Public License or
11 * other free or open source software licenses.
12 * See COPYRIGHT.php for copyright notices and details.
15 // Check to ensure this file is within the rest of the framework
16 //defined('JPATH_BASE') or die();
18 //jimport( 'joomla.event.event' );
24 * @package Joomla.Framework
28 //class JPlugin extends JEvent
32 * A JParameter object holding the parameters for the plugin
34 * @var A JParameter object
41 * The name of the plugin
59 * For php4 compatability we must not use the __constructor as a constructor for plugins
60 * because func_get_args ( void ) returns a copy of all passed arguments NOT references.
61 * This causes problems with cross-referencing necessary for the observer design pattern.
63 * @param object $subject The object to observe
64 * @param array $config An optional associative array of configuration settings.
65 * Recognized key values include 'name', 'group', 'params'
66 * (this list is not meant to be comprehensive).
69 /* function JPlugin(& $subject, $config = array()) {
70 parent::__construct($subject);
76 function __construct(& $subject, $config = array())
79 if ( isset( $config['params'] ) ) {
81 if(is_a($config['params'], 'JParameter')) {
82 $this->params = $config['params'];
84 $this->params = new JParameter($config['params']);
88 if ( isset( $config['name'] ) ) {
89 $this->_name = $config['name'];
92 if ( isset( $config['type'] ) ) {
93 $this->_type = $config['type'];
96 parent::__construct($subject);
100 * Loads the plugin language file
103 * @param string $extension The extension for which a language file should be loaded
104 * @param string $basePath The basepath to use
105 * @return boolean True, if the file has successfully loaded.
108 public static function loadLanguage($extension = '', $basePath = JPATH_BASE)
111 if(empty($extension)) {
112 $extension = 'plg_'.$this->_type.'_'.$this->_name;
115 $lang =& JFactory::getLanguage();
116 return $lang->load( strtolower($extension), $basePath);