ebc_project = JRequest::getVar('ebc_project', '');
if( $this->ebc_project )
{
JLoader::import('helpers.project', JPATH_COMPONENT);
if( ! $this->easyProject = new easyProject($this->ebc_project))
{
JError::raiseWarning(100, JText::sprintf('Unable to load the project %s', $this->ebc_project));
ecrHTML::easyFormEnd();
//--Something went wrong..
return;
}
$this->project = $this->easyProject->getProject();
}
$task = JRequest::getVar('task');
$tmpl = JRequest::getCmd('tmpl');
if( $task != 'display_snip'
&& $task != 'aj_reflection'
&& $tmpl != 'component' )
{
//--Draw h1 header
ecrHTML::header(JText::_('Configure'), $this->project);
//--Draw the submenu if task is not for a raw view
echo $this->displayBar($task);
}
if( in_array($task, get_class_methods($this)) )
{
//--Execute the task
$this->$task();
if( $task == 'display_snip')
{
//--Raw view
parent::display($tpl);
return;
}
}
else
{
if($task) echo 'UNDEFINED..'.$task.'
';
$this->setLayout('stuffer');
}
$this->assignRef( 'task', $task );
$this->assignRef( 'tmpl', $tmpl );
parent::display($tpl);
ecrHTML::easyFormEnd();
}//function
/**
* Displays the submenu
*
* @param $task the actual task
* @return string html
*/
private function displayBar($task)
{
/*
* testing descriptions with mootools
*/
?>
get('ecr_help');
$imgBase = JURI::root().'administrator/components/'.com_EASY_APP_ELKUKU_1.'/assets/images/ico/';
$separator = ' •• ';
$subtasks = array(
array('title'=> JText::_('Files')
, 'description' => JText::_('DESC PROJECT FILES')
, 'icon' => 'module'
, 'task' => 'stuffer'
)
, array('title' => JText::_('Building')
, 'description' => JText::_('DESC PROJECT BUILDING')
, 'icon' => 'config'
, 'task' => 'buildfile'
)
, array('title' => JText::_('Parameters')
, 'description' => JText::_('DESC PROJECT PARAMETERS')
, 'icon' => 'article'
, 'task' => 'projectparams'
)
, array('title' => JText::_('Project Info')
, 'description' => JText::_('DESC PROJECT INFO')
, 'icon' =>'info'
, 'task' => 'projectinfo'
)
, array('title' => JText::_('REMOVE Project')
, 'description' => JText::_('DESC PROJECT DELETE')
, 'icon' => 'logout'
, 'task' => 'projectdelete'
)
);
$htmlDescriptionDivs = '';
$jsVars = '';
$jsMorphs = '';
$jsEvents = '';
$html = '';
$html .= '
';
foreach( $subtasks as $sTask )
{
$selected =( $sTask['task'] == $task ) ? '_selected' : '';
$html .= NL.'| ';
$html .= ' ';
$html .= $sTask['title'].' | ';
if( $ecr_help == 'all'
|| $ecr_help == 'some')
{
$htmlDescriptionDivs .= ''.$sTask['description'].'
';
$jsVars .= "var desc_".$sTask['task']." = $('desc_".$sTask['task']."');\n";
# $jsMorphs = "desc_".$sTask['task']." = new Fx.Morph(desc_".$sTask['task'].", {\n"
# ."link: 'cancel'\n"
# ."});";
$jsEvents .= "$('btn_".$sTask['task']."').addEvents({\n"
. "'mouseenter': showTaskDesc.bind(desc_".$sTask['task']."),\n"
. "'mouseleave': hideTaskDesc.bind(desc_".$sTask['task'].")\n"
. "});\n";
}
}//foreach
$html .= ' | ';
switch( $task )
{
case 'buildfile':
$t = JText::_('Save');
$html .= '';
$html .= '
'.JText::_('Save').'
';
$html .= ' | ';
break;
}//switch
$html .= '
';
$html .= $htmlDescriptionDivs;
if( $ecr_help == 'all'
|| $ecr_help == 'some')
{
$html .= "";
}
return $html;
}//function
private function buildfile()
{
$buildvars = array(
JText::_('Name') => 'com_name'
, JText::_('com_Name') => 'com_com_name'
, JText::_('Version') => 'com_version'
, JText::_('Description') => 'description'
, JText::_('Author') => 'author'
, JText::_('Author e-mail') => 'authoremail'
, JText::_('Author URL') => 'authorurl'
, JText::_('License') => 'license'
, JText::_('Copyright') => 'copyright'
);
$this->assignRef( 'buildvars', $buildvars );
$this->assignRef( 'task', $task );
$this->setLayout('buildfile');
}// function
private function buildfilefile()
{
JLoader::import('helpers.file', JPATH_COMPONENT);
$easyFile = new EasyFile();
$this->assignRef('easyFile', $easyFile);
$conf_path = JPATH_COMPONENT.DS.'builds'.DS.'scripts';
if( file_exists($conf_path.DS.$this->ebc_project.'.ebc') === false )
{
ecrHTML::displayMessage(array(JText::_('File not found'), $this->ebc_project.'.ebc'), 'error');
}
else
{
$file = $this->ebc_project.'.ebc';
$this->assignRef( 'path', $conf_path );
$this->assignRef( 'file', $file );
$this->assignRef( 'model_file', $model_file );
$this->assignRef( 'task', $task );
$this->setLayout('buildfile');
}
}// function
private function stuffer()
{
JLoader::import('helpers.file', JPATH_COMPONENT);
$easyFile = new EasyFile();
$this->assignRef('easyFile', $easyFile);
JHTML::script('addelement.js', 'administrator/components/'.com_EASY_APP_ELKUKU_1.'/assets/js/', false);
$this->setLayout('stuffer');
}//function
private function projectinfo()
{
//--TODO still need dirinfo class ?? - line counter...
JLoader::import('helpers.dirinfo', JPATH_COMPONENT);
$dirinfo = new EasyDirInfo();
$this->assignRef( 'dirinfo', $dirinfo );
$this->setLayout('projectinfo');
}//function
private function reflect()
{
$this->setLayout('projectinfo');
}//function
private function aj_reflect()
{
$this->setLayout('projectinfo');
}//function
private function aj_reflection()
{
$el_num = JRequest::getInt('el_num', '');
$this->assignRef('el_num', $el_num);
$this->setLayout('aj_reflection');
}//function
private function projectdelete()
{
$this->setLayout('deleteconfirm');
}//function
private function projectparams()
{
$selected_xml = JRequest::getVar('selected_xml', '');
$params = array();
$xmlFiles = array();
foreach ($this->project->copys as $copy)
{
$path = JPATH_ROOT.DS.$copy['source'];
if( JFolder::exists($path))
{
$files = JFolder::files($path,'\.xml', true, true);
if( count($files))
{
foreach ($files as $file)
{
$xmlFiles[] = substr($file, strlen(JPATH_ROOT) + 1);
}//foreach
}
}
else if( JFile::getExt($path) == 'xml')
{
$xmlFiles[] = $path;
}
}//foreach
if( in_array($selected_xml, $xmlFiles ))
{
//--Get the project params
$params = $this->easyProject->getProjectParams(JPATH_ROOT.DS.$selected_xml);
}
$this->assignRef( 'params', $params );
$options = array();
$options[] = JHTML::_('select.option', '',JText::_('Select'));
for ($i=1; $i < sizeof($xmlFiles) + 1; $i++)
{
$options[$i] = JHTML::_('select.option', $xmlFiles[$i-1]);
}
$xmlSelector = JHTML::_('select.genericlist', $options, 'selected_xml', 'style="font-size: 1.3em;" onchange="submitbutton(\''.JRequest::getVar('task').'\');"', 'value', 'text', $selected_xml );
$this->assignRef( 'xmlSelector', $xmlSelector );
$this->assignRef( 'selected_xml', $selected_xml );
$this->setLayout('projectparams');
}//function
private function display_snip()
{
jimport('joomla.filesystem.file');
$path = JRequest::getVar('file_path', '');
$start = JRequest::getVar('start', '');
$end = JRequest::getVar('end', '');
if( ! JFile::exists($path) )
{
echo ''.JText::_('File not found').'
';
echo $path;
//--EXIT
jexit();
}
else
{
$fileContents = JFile::read($path);
}
if( $fileContents )
{
$fileContents = explode("\n", $fileContents);
$this->assignRef( 'fileContents', $fileContents );
$this->assignRef( 'startAtLine', $start );
$this->assignRef( 'endAtLine', $end );
$this->assignRef( 'path', $path );
}
$this->setLayout('snippet');
}//function
}// class