@my wife Roline van der Merwe
@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 Compiler View
*/
class ComponentbuilderViewCompiler extends JViewLegacy
{
/**
* Componentbuilder view display method
* @return void
*/
function display($tpl = null)
{
// Check for errors.
if (count($errors = $this->get('Errors'))){
JError::raiseError(500, implode(' ', $errors));
return false;
};
$this->Components = $this->get('Components');
$this->form = $this->setForm();
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')
{
// Include helper submenu
ComponentbuilderHelper::addSubmenu('compiler');
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
}
// Display the template
parent::display($tpl);
// Set the document
$this->setDocument();
}
/**
* Setting the toolbar
*/
protected function addToolBar()
{
$canDo = ComponentbuilderHelper::getActions('compiler');
JToolBarHelper::title(JText::_('Compiler'), 'cogs');
if($canDo->get('core.admin') || $canDo->get('core.options'))
{
JToolBarHelper::custom('compiler.clearTmp', 'purge', '', 'Clear tmp', false);
JToolBarHelper::divider();
JToolBarHelper::preferences('com_componentbuilder');
}
// set help url for this view if found
$help_url = ComponentbuilderHelper::getHelpUrl('compiler');
if (ComponentbuilderHelper::checkString($help_url))
{
JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $help_url);
}
}
public function setForm()
{
if(ComponentbuilderHelper::checkArray($this->Components)){
jimport('joomla.form.form');
$radio1 = JFormHelper::loadFieldType('radio',true);
// start building add to sales folder xml field
$xml = '';
$xml .= ' ';
$xml .= "";
// prepare the xml
$sales = new SimpleXMLElement($xml);
// set components to form
$radio1->setup($sales,0);
$radio2 = JFormHelper::loadFieldType('radio',true);
// start building add to git folder xml field
$xml = '';
$xml .= ' ';
$xml .= "";
// prepare the xml
$git = new SimpleXMLElement($xml);
// set components to form
$radio2->setup($git,1);
$list = JFormHelper::loadFieldType('list',true);
// start building componet xml field
$xml = '';
$xml .= '';
foreach($this->Components as $componet){
$xml .= '';
}
$xml .= "";
// prepare the xml
$componets = new SimpleXMLElement($xml);
// set components to form
$list->setup($componets,0);
return array($radio1,$radio2,$list);
}
return false;
}
/**
* Method to set up the document properties
*
*
* @return void
*/
protected function setDocument()
{
$document = JFactory::getDocument();
$document->setTitle(JText::_('The Compiler'));
}
}