Advertisement
Guest User

plgSystemLanguageroot

a guest
Aug 15th, 2012
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1. <?php
  2.  
  3. defined('_JEXEC') or die;
  4.  
  5.  
  6. class plgSystemLanguageroot extends JPlugin
  7. {
  8.    
  9.     public function __construct( $subject, $config )
  10.     {
  11.         parent::__construct( $subject, $config );
  12.     }
  13.  
  14.     public function onContentPrepareForm($form, $data)
  15.     {
  16.        
  17.         if (!($form instanceof JForm))
  18.         {
  19.             $this->_subject->setError('JERROR_NOT_A_FORM');
  20.             return false;
  21.         }
  22.        
  23.         if( $form->getName() != 'com_menus.item' )
  24.         {
  25.             return true;
  26.         }
  27.        
  28.        
  29.         $path = JPATH_PLUGINS.DS.'system'.DS.'languageroot'.DS.'form';
  30.         JForm::addFormPath( $path );
  31.         $form->loadFile( 'form', false );
  32.  
  33.        
  34.         return true;
  35.  
  36.     }
  37.    
  38.     public function onContentPrepareData( $context, $data )
  39.     {
  40.         JForm::addFormPath( $this->getFormPath() );
  41.         $data->languageroot = array( 'test' => 'test' );
  42.         return true;
  43.     }
  44.    
  45.    
  46.     private function getFormPath()
  47.     {
  48.         return JPATH_PLUGINS.DS.'system'.DS.'languageroot'.DS.'form';
  49.     }
  50. }
  51. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement