Skip to content

Instantly share code, notes, and snippets.

@nielsnuebel
Created May 4, 2016 09:24
Show Gist options
  • Save nielsnuebel/0818bac639e7165f199ebfd42a1fbc35 to your computer and use it in GitHub Desktop.
Save nielsnuebel/0818bac639e7165f199ebfd42a1fbc35 to your computer and use it in GitHub Desktop.
<?php
/**
* Joomla! System plugin - KickLangDefault
*
* @author KickTemp <[email protected]>
* @copyright Copyright 2016 KickTemp
* @license GNU Public License
* @link http://www.kicktemp.com
*/
// Check to ensure this file is included in Joomla!
defined('_JEXEC') or die('Restricted access');
/**
* A plugin to change the Language Default Value from langauge.xml metadata
*
* @since 1.0
*/
class PlgSystemKicklangdefault extends JPlugin
{
/**
* The language object
*
* @var null
* @since 1.0
*/
protected $lang = null;
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* constructor, used to inject the language class for testing purposes
*
* @param object &$subject The object to observe
* @param array $config An optional associative array of configuration settings.
* Recognized key values include 'name', 'group', 'params', 'language'
* (this list is not meant to be comprehensive).
*
* @since 1.0
*/
public function __construct(&$subject, $config = array())
{
parent::__construct($subject, $config);
$this->lang = JFactory::getLanguage();
}
/**
* Plugin that loads module positions within content
*
* @param string $context The context of the content being passed to the plugin.
* @param object &$article The article object. Note $article->text is also available
*
* @return mixed true if there is an error. Void otherwise.
*
* @since 1.6
*/
public function onAfterInitialise()
{
$language = JFactory::getLanguage();
$default = $language->get('default', false);
if($default)
{
$language->setDefault($default);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment