Resolved gh-436 so that the new Joomla plugin builder/feature is fully active, and part of the import and export of JCB packages.
This commit is contained in:
@ -60,7 +60,7 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin
|
||||
// include component compiler
|
||||
require_once JPATH_ADMINISTRATOR.'/components/com_componentbuilder/helpers/compiler.php';
|
||||
$model = $this->getModel('compiler');
|
||||
if ($model->builder($version,$componentId,$addBackup,$addRepo,$addPlaceholders,$debugLinenr, $minify))
|
||||
if ($model->builder($version, $componentId, $addBackup, $addRepo, $addPlaceholders, $debugLinenr, $minify))
|
||||
{
|
||||
$cache = JFactory::getCache('mod_menu');
|
||||
$cache->clean();
|
||||
@ -81,10 +81,32 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin
|
||||
{
|
||||
$url = JURI::root() . substr($model->compiler->filepath['component'], $pos + 1);
|
||||
}
|
||||
// Message of successful build
|
||||
$message = '<h1>The ('.$model->compiler->componentFolderName.') Was Successfully Compiled!</h1>';
|
||||
$message .= '<p><button class="btn btn-small btn-success" onclick="Joomla.submitbutton(\'compiler.installExtention\')">';
|
||||
$message .= 'Install '.$model->compiler->componentFolderName.' on this <span class="icon-joomla icon-white"></span>Joomla website.</button></p>';
|
||||
// check if we have plugins
|
||||
if (ComponentbuilderHelper::checkArray($model->compiler->filepath['plugins']))
|
||||
{
|
||||
// Message of successful build
|
||||
$message = '<h1>The Extensions were Successfully Compiled!</h1>';
|
||||
$message .= '<h4>You can install any one of the following extensions!</h4>';
|
||||
}
|
||||
else
|
||||
{
|
||||
// Message of successful build
|
||||
$message = '<h1>The (' . $model->compiler->filepath['component-folder'] . ') was Successfully Compiled!</h1>';
|
||||
}
|
||||
$message .= '<p><button class="btn btn-small btn-success" onclick="Joomla.submitbutton(\'compiler.installCompiledComponent\')">';
|
||||
$message .= 'Install ' . $model->compiler->filepath['component-folder'] . ' on this <span class="icon-joomla icon-white"></span>Joomla website. (component)</button></p>';
|
||||
// check if we have plugins
|
||||
if (ComponentbuilderHelper::checkArray($model->compiler->filepath['plugins']))
|
||||
{
|
||||
foreach ($model->compiler->filepath['plugins-folder'] as $plugin_id => $plugin_folder)
|
||||
{
|
||||
$message .= '<p><button class="btn btn-small btn-success" onclick="Joomla.submitbutton(\'compiler.installCompiledPlugin\', ' . (int) $plugin_id . ')">';
|
||||
$message .= 'Install ' . $plugin_folder . ' on this <span class="icon-joomla icon-white"></span>Joomla website. (plugin)</button></p>';
|
||||
}
|
||||
$message .= '<h4>You can install all compiled extensions!</h4>';
|
||||
$message .= '<p><button class="btn btn-small btn-success" onclick="Joomla.submitbutton(\'compiler.installCompiledExtensions\')">';
|
||||
$message .= 'Install all above extensions on this <span class="icon-joomla icon-white"></span>Joomla website.</button></p>';
|
||||
}
|
||||
$message .= '<h2>Total time saved</h2>';
|
||||
$message .= '<ul>';
|
||||
$message .= '<li>Total folders created: <b>'.$model->compiler->folderCount.'</b></li>';
|
||||
@ -100,15 +122,53 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin
|
||||
$message .= '<p><b>'.$model->compiler->actualTotalHours.' Hours</b> or <b>'.$model->compiler->actualTotalDays.' Eight Hour Days</b> <em>(a total of the realistic time frame for this project)</em><br />';
|
||||
$message .= '<small>(if creating a folder and file took <b>5 seconds</b> and writing one line of code took <b>10 seconds</b>, with the normal everyday realities at the office, that includes the component planning, mapping & debugging.)</small></p>';
|
||||
$message .= '<p>Project duration: <b>'.$model->compiler->projectWeekTime. ' weeks</b> or <b>'.$model->compiler->projectMonthTime.' months</b></p>';
|
||||
$message .= '<h2>Path to Zip File</h2>';
|
||||
$message .= '<p><b>Path:</b> <code>'.$model->compiler->filepath['component'].'</code><br />';
|
||||
$message .= '<b>URL:</b> <code>'.$url.'</code><br /><br />';
|
||||
$message .= '<small>Hey! you can also download the file right now!</small><br /><a class="btn btn-success" href="'.$url.'" ><span class="icon-download icon-white"></span>Download</a></p>';
|
||||
$message .= '<p><small><b>Remember!</b> This file is in your tmp folder and therefore publicly accessible untill you click [Clear tmp]!</small> </p>';
|
||||
// check if we have plugins
|
||||
if (ComponentbuilderHelper::checkArray($model->compiler->filepath['plugins']))
|
||||
{
|
||||
$plugin_url = array();
|
||||
$message .= '<h2>Path to Zip Files</h2>';
|
||||
$message .= '<p><b>Component Path:</b> <code>' . $model->compiler->filepath['component'] . '</code><br />';
|
||||
$message .= '<b>Component URL:</b> <code>' . $url . '</code><br /><br />';
|
||||
// load the plugins path/url
|
||||
foreach ($model->compiler->filepath['plugins'] as $plugin_id => $plugin_path)
|
||||
{
|
||||
// set plugin path
|
||||
$message .= '<b>Plugin Path:</b> <code>' . $plugin_path . '</code><br />';
|
||||
if (($pos = strpos($plugin_path, "/tmp/")) !== FALSE)
|
||||
{
|
||||
$plugin_urls[$plugin_id] = JURI::root() . substr($plugin_path, $pos + 1);
|
||||
$message .= '<b>Plugin URL:</b> <code>' . $plugin_urls[$plugin_id] . '</code><br />';
|
||||
}
|
||||
}
|
||||
$message .= '<br /><small>Hey! you can also download these zip files right now!</small><br />';
|
||||
$message .= '<a class="btn btn-success" href="' . $url . '" ><span class="icon-download icon-white"></span>Download Component</a> ';
|
||||
// load the plugin download URL's
|
||||
foreach ($plugin_urls as $plugin_id => $plugin_url)
|
||||
{
|
||||
$message .= ' <a class="btn btn-success" href="' . $plugin_url . '" >';
|
||||
$message .= '<span class="icon-download icon-white"></span>Download ' . $model->compiler->filepath['plugins-folder'][$plugin_id] . '</a> ';
|
||||
}
|
||||
$message .= '</p>';
|
||||
$message .= '<p><small><b>Remember!</b> These zip files are in your tmp folder and therefore publicly accessible until you click [Clear tmp]!</small></p>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$message .= '<h2>Path to Zip File</h2>';
|
||||
$message .= '<p><b>Path:</b> <code>' . $model->compiler->filepath['component'] . '</code><br />';
|
||||
$message .= '<b>URL:</b> <code>' . $url . '</code><br /><br />';
|
||||
$message .= '<small>Hey! you can also download the zip file right now!</small><br />';
|
||||
$message .= '<a class="btn btn-success" href="' . $url . '" ><span class="icon-download icon-white"></span>Download</a></p>';
|
||||
$message .= '<p><small><b>Remember!</b> This zip file is in your tmp folder and therefore publicly accessible until you click [Clear tmp]!</small> </p>';
|
||||
}
|
||||
$message .= '<p><small>Compilation took <b>'.$model->compiler->secondsCompiled.'</b> seconds to complete.</small> </p>';
|
||||
// set redirect
|
||||
$this->setRedirect($redirect_url,$message,'message');
|
||||
$app->setUserState('com_componentbuilder.extension_name', $model->compiler->componentFolderName);
|
||||
$this->setRedirect($redirect_url, $message, 'message');
|
||||
$app->setUserState('com_componentbuilder.component_folder_name', $model->compiler->filepath['component-folder']);
|
||||
// check if we have plugins
|
||||
if (ComponentbuilderHelper::checkArray($model->compiler->filepath['plugins']))
|
||||
{
|
||||
$app->setUserState('com_componentbuilder.plugins_folder_name', $model->compiler->filepath['plugins-folder']);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -116,9 +176,10 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin
|
||||
$app->setUserState('com_componentbuilder.redirect_url', '');
|
||||
$app->setUserState('com_componentbuilder.message', '');
|
||||
$app->setUserState('com_componentbuilder.extension_message', '');
|
||||
$app->setUserState('com_componentbuilder.extension_name', '');
|
||||
$app->setUserState('com_componentbuilder.component_folder_name', '');
|
||||
$app->setUserState('com_componentbuilder.plugins_folder_name', '');
|
||||
// set redirect
|
||||
$this->setRedirect($redirect_url,$message);
|
||||
$this->setRedirect($redirect_url, $message);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -126,11 +187,11 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin
|
||||
}
|
||||
|
||||
/**
|
||||
* Install Compiled Extension
|
||||
* Install All Compiled Extensions
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
public function installExtention()
|
||||
public function installCompiledExtensions()
|
||||
{
|
||||
// Check for request forgeries
|
||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
||||
@ -138,27 +199,133 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin
|
||||
$user = JFactory::getUser();
|
||||
// set page redirect
|
||||
$redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=compiler', false);
|
||||
$message = 'Could not install component!';
|
||||
$message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_INSTALL_THESE_EXTENSIONS');
|
||||
if($user->authorise('core.admin'))
|
||||
{
|
||||
// get the model
|
||||
$model = $this->getModel('compiler');
|
||||
$message = JText::_('COM_COMPONENTBUILDER_COULD_NOT_INSTALL_EXTENTIONS');
|
||||
$_message = array('success' => array(), 'error' => array());
|
||||
$app = JFactory::getApplication();
|
||||
$fileName = $app->getUserState('com_componentbuilder.extension_name');
|
||||
if (ComponentbuilderHelper::checkString($fileName))
|
||||
$fileNames = $app->getUserState('com_componentbuilder.plugins_folder_name', array());
|
||||
$fileNames[] = $app->getUserState('com_componentbuilder.component_folder_name', null);
|
||||
foreach ($fileNames as $fileName)
|
||||
{
|
||||
$lang = JFactory::getLanguage();
|
||||
$extension = 'com_installer';
|
||||
$base_dir = JPATH_ADMINISTRATOR;
|
||||
$language_tag = 'en-GB';
|
||||
$reload = true;
|
||||
$lang->load($extension, $base_dir, $language_tag, $reload);
|
||||
$message = '('.$fileName.'.zip) file was also removed from tmp!';
|
||||
$this->setRedirect($redirect_url,$message,'message');
|
||||
return $model->install($fileName.'.zip');
|
||||
if ($this->installExtension($fileName))
|
||||
{
|
||||
$_message['success'][] = JText::sprintf('COM_COMPONENTBUILDER_SZIP_WAS_REMOVED_THE_FROM_TMP_FOLDER_DURING_INSTALLATION', $fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
$_message['error'][] = JText::sprintf('COM_COMPONENTBUILDER_SZIP_COULD_NOT_BE_INSTALLED', $fileName);
|
||||
}
|
||||
}
|
||||
// catch errors
|
||||
if (ComponentbuilderHelper::checkArray($_message['error']))
|
||||
{
|
||||
$app->enqueueMessage(implode('<br />', $_message['error']), 'Error');
|
||||
}
|
||||
// build success message
|
||||
if (ComponentbuilderHelper::checkArray($_message['success']))
|
||||
{
|
||||
$this->setRedirect($redirect_url, implode('<br />', $_message['success']), 'message');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$this->setRedirect($redirect_url,$message,'error');
|
||||
$this->setRedirect($redirect_url, $message, 'error');
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install Compiled Component
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
public function installCompiledComponent()
|
||||
{
|
||||
// Check for request forgeries
|
||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
||||
// check if user has the right
|
||||
$user = JFactory::getUser();
|
||||
// set page redirect
|
||||
$redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=compiler', false);
|
||||
$message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_INSTALL_THE_COMPONENT');
|
||||
if($user->authorise('core.admin'))
|
||||
{
|
||||
$message = JText::_('COM_COMPONENTBUILDER_COULD_NOT_INSTALL_COMPONENT');
|
||||
$fileName = JFactory::getApplication()->getUserState('com_componentbuilder.component_folder_name');
|
||||
if ($this->installExtension($fileName))
|
||||
{
|
||||
$message = JText::sprintf('COM_COMPONENTBUILDER_ONLY_SZIP_FILE_WAS_REMOVED_THE_FROM_TMP_FOLDER_DURING_INSTALLATION', $fileName);
|
||||
$this->setRedirect($redirect_url, $message, 'message');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
$this->setRedirect($redirect_url, $message, 'error');
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install Compiled Plugin
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
public function installCompiledPlugin()
|
||||
{
|
||||
// Check for request forgeries
|
||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
||||
// check if user has the right
|
||||
$user = JFactory::getUser();
|
||||
// set page redirect
|
||||
$redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=compiler', false);
|
||||
$message = JText::_('COM_COMPONENTBUILDER_YOU_DO_NOT_HAVE_PERMISSION_TO_INSTALL_THE_PLUGIN');
|
||||
if($user->authorise('core.admin'))
|
||||
{
|
||||
$message = JText::_('COM_COMPONENTBUILDER_COULD_NOT_INSTALL_PLUGIN');
|
||||
$app = JFactory::getApplication();
|
||||
$fileNames = $app->getUserState('com_componentbuilder.plugins_folder_name');
|
||||
if (ComponentbuilderHelper::checkArray($fileNames))
|
||||
{
|
||||
$jinput = JFactory::getApplication()->input;
|
||||
$pluginId = $jinput->post->get('install_item_id', 0, 'INT');
|
||||
if ($pluginId > 0 && isset($fileNames[$pluginId]) && $this->installExtension($fileNames[$pluginId]))
|
||||
{
|
||||
$message = JText::sprintf('COM_COMPONENTBUILDER_ONLY_SZIP_FILE_WAS_REMOVED_THE_FROM_TMP_FOLDER_DURING_INSTALLATION', $fileName);
|
||||
$this->setRedirect($redirect_url, $message, 'message');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->setRedirect($redirect_url, $message, 'error');
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Install Extension
|
||||
*
|
||||
* @return true on success
|
||||
*/
|
||||
protected function installExtension($fileName)
|
||||
{
|
||||
// check that the model is set
|
||||
if (!isset($this->_compiler_model))
|
||||
{
|
||||
// get the compiler model
|
||||
$this->_compiler_model = $this->getModel('compiler');
|
||||
}
|
||||
// set the language if not set
|
||||
if (!isset($this->_installer_lang))
|
||||
{
|
||||
$this->_installer_lang = JFactory::getLanguage();
|
||||
$extension = 'com_installer';
|
||||
$base_dir = JPATH_ADMINISTRATOR;
|
||||
$language_tag = 'en-GB';
|
||||
$reload = true;
|
||||
$this->_installer_lang->load($extension, $base_dir, $language_tag, $reload);
|
||||
}
|
||||
// make sure we have a string
|
||||
if (ComponentbuilderHelper::checkString($fileName))
|
||||
{
|
||||
return $this->_compiler_model->install($fileName.'.zip');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user