@github Joomla Component Builder @copyright Copyright (C) 2015. All Rights Reserved @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html Builds Complex Joomla Components /-----------------------------------------------------------------------------------------------------------------------------*/ // No direct access to this file defined('_JEXEC') or die('Restricted access'); // import Joomla view library jimport('joomla.application.component.view'); /** * Componentbuilder Import_joomla_components View */ class ComponentbuilderViewImport_joomla_components extends JViewLegacy { protected $headerList; protected $hasPackage = false; protected $headers; protected $hasHeader = 0; protected $dataType; protected $packageInfo; protected $formPackage; public function display($tpl = null) { if ($this->getLayout() !== 'modal') { // Include helper submenu ComponentbuilderHelper::addSubmenu('import'); } $paths = new stdClass; $paths->first = ''; $state = $this->get('state'); $this->paths = &$paths; $this->state = &$state; // get global action permissions $this->canDo = ComponentbuilderHelper::getActions('import'); // We don't need toolbar in the modal window. if ($this->getLayout() !== 'modal') { $this->addToolbar(); $this->sidebar = JHtmlSidebar::render(); } // load the application $app = JFactory::getApplication(); // get the session object $session = JFactory::getSession(); // check if it has package $this->hasPackage = $session->get('hasPackage', false); $this->dataType = $session->get('dataType', false); if($this->hasPackage && $this->dataType && $this->dataType !== 'smart_package') { $this->headerList = json_decode($session->get($this->dataType.'_VDM_IMPORTHEADERS', false),true); $this->headers = ComponentbuilderHelper::getFileHeaders($this->dataType); // clear the data type $session->clear('dataType'); } elseif (!$this->dataType) { $this->dataType = $session->get('dataType_VDM_IMPORTINTO', null); } // set form only if smart package if ($this->dataType === 'smart_package') { $this->packageInfo = json_decode($session->get('smart_package_info', false), true); $this->formPackage = $this->getForm(); } // Check for errors. if (count($errors = $this->get('Errors'))) { throw new Exception(implode("\n", $errors), 500); } // Display the template parent::display($tpl); } public function getForm() { jimport('joomla.form.form'); $form = array(); $radio1 = JFormHelper::loadFieldType('radio',true); // Switch to force local update $xml = ''; $xml .= ' '; $xml .= ""; // prepare the xml $force = new SimpleXMLElement($xml); // set components to form $radio1->setup($force,0); // add to form $form[] = $radio1; if (!$this->packageInfo || (isset($this->packageInfo['getKeyFrom']) && ComponentbuilderHelper::checkArray($this->packageInfo['getKeyFrom']))) { // set required field $required = 'required="true"'; if (!$this->packageInfo) { $radio2 = JFormHelper::loadFieldType('radio',true); // has key $xml = ''; $xml .= ' '; $xml .= ""; // prepare the xml $license = new SimpleXMLElement($xml); // set components to form $radio2->setup($license,1); $required = ''; // change required field // add to form $form[] = $radio2; } $text1 = JFormHelper::loadFieldType('text',true); // add the key $xml = ''; // prepare the xml $sleutle = new SimpleXMLElement($xml); // set components to form $text1->setup($sleutle,''); // add to form $form[] = $text1; } return $form; } /** * Setting the toolbar */ protected function addToolBar() { JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_IMPORT_TITLE'), 'upload'); JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=import_joomla_components'); if ($this->canDo->get('core.admin') || $this->canDo->get('core.options')) { JToolBarHelper::preferences('com_componentbuilder'); } // set help url for this view if found $help_url = ComponentbuilderHelper::getHelpUrl('import_joomla_components'); if (ComponentbuilderHelper::checkString($help_url)) { JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $help_url); } } }