Exemplo n.º 1
0
 function display($tpl = null)
 {
     $this->canDo = JCKHelper::getActions();
     $this->app = JFactory::getApplication();
     $this->user = JFactory::getUser();
     $this->state = $this->get('State');
     $this->item = $this->get('Item');
     $this->form = $this->get('Form');
     $this->params = $this->prepareForm($this->item);
     if (!$this->canDo->get('core.edit')) {
         $this->app->redirect(JRoute::_('index.php?option=com_jckman&view=list', false), JText::_('COM_JCKMAN_PLUGIN_PERM_NO_EDIT'), 'error');
         return false;
     }
     //end if
     //language
     $lang = JCKHelper::getLanguage();
     $tag = $lang->getTag();
     JFactory::$language = $lang;
     //override Joomla default language class
     $name = $this->item->name;
     $plugin = 'plg_jck' . $name;
     $pluginOverideFile = JPATH_COMPONENT . '/language/overrides/' . $tag . '.' . $plugin . '.ini';
     $pluginLangFile = JPATH_COMPONENT . '/language/' . $tag . '/' . $tag . '.' . $plugin . '.ini';
     if (JFile::exists($pluginOverideFile)) {
         //check in language overrides to see if user has installed an override language file
         $lang->loadFile($pluginOverideFile, $plugin);
     } else {
         if (JFile::exists($pluginLangFile)) {
             //load core language file if it exists
             $lang->load($plugin, JPATH_COMPONENT);
         } else {
             //load english default languge
             if (JFile::exists(JPATH_COMPONENT . '/language/en-GB/en-GB.plg_jck' . $name . '.ini')) {
                 $lang->load($plugin, JPATH_COMPONENT, 'en-GB');
             }
         }
     }
     $this->item->description = JText::_($this->item->description);
     $this->form->bind($this->item);
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JCKHelper::error(implode("\n", $errors));
         return false;
     }
     $this->addToolbar();
     parent::display($tpl);
 }