Updated the copyright date for the new year 2021. Improved the compiler message area.
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
* @created 30th April, 2015
|
||||
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||
* @copyright Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved.
|
||||
* @copyright Copyright (C) 2015 - 2021 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
@ -48,6 +48,7 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin
|
||||
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
||||
// check if user has the right
|
||||
$user = JFactory::getUser();
|
||||
// currently only administrators can compile a component
|
||||
if($user->authorise('core.admin', 'com_componentbuilder'))
|
||||
{
|
||||
// get the post values
|
||||
@ -73,120 +74,133 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin
|
||||
return false;
|
||||
}
|
||||
|
||||
// switch to set multi install button
|
||||
$add_multi_install = false;
|
||||
$add_plugin_install = false;
|
||||
$add_module_install = false;
|
||||
// get application
|
||||
$app = JFactory::getApplication();
|
||||
// set redirection URL
|
||||
$redirect_url = $app->getUserState('com_componentbuilder.redirect_url');
|
||||
// get system messages
|
||||
$message = $app->getUserState('com_componentbuilder.message');
|
||||
if (empty($redirect_url) && $componentId > 0)
|
||||
{
|
||||
// start new message
|
||||
$message = array();
|
||||
// update the redirection URL
|
||||
$redirect_url = JRoute::_('index.php?option=com_componentbuilder&view=compiler', false);
|
||||
if (($pos = strpos($model->compiler->filepath['component'], "/tmp/")) !== FALSE)
|
||||
{
|
||||
$url = JURI::root() . substr($model->compiler->filepath['component'], $pos + 1);
|
||||
}
|
||||
// check if we have plugins
|
||||
if (ComponentbuilderHelper::checkArray($model->compiler->filepath['plugins']))
|
||||
$add_plugin_install = ComponentbuilderHelper::checkArray($model->compiler->filepath['plugins'], true);
|
||||
// check if we have modules
|
||||
$add_module_install = ComponentbuilderHelper::checkArray($model->compiler->filepath['modules'], true);
|
||||
// if a multi install we set another kind of header
|
||||
if ($add_plugin_install || $add_module_install)
|
||||
{
|
||||
// Message of successful build
|
||||
$message = '<h1>The Extensions were Successfully Compiled!</h1>';
|
||||
$message .= '<h4>You can install any one of the following extensions!</h4>';
|
||||
// Message of successful builds
|
||||
$message[] = '<h1>The Extensions were Successfully Compiled!</h1>';
|
||||
$message[] = '<h4>You can install any one of the following extensions!</h4>';
|
||||
// set multi install
|
||||
$add_multi_install = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Message of successful build
|
||||
$message = '<h1>The (' . $model->compiler->filepath['component-folder'] . ') was Successfully Compiled!</h1>';
|
||||
$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>';
|
||||
// switch to set multi install button
|
||||
$add_multi_install = true;
|
||||
$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 modules
|
||||
if (ComponentbuilderHelper::checkArray($model->compiler->filepath['modules']))
|
||||
if ($add_module_install)
|
||||
{
|
||||
foreach ($model->compiler->filepath['modules-folder'] as $module_id => $module_folder)
|
||||
{
|
||||
$message .= '<p><button class="btn btn-small btn-success" onclick="Joomla.submitbutton(\'compiler.installCompiledModule\', ' . (int) $module_id . ')">';
|
||||
$message .= 'Install ' . $module_folder . ' on this <span class="icon-joomla icon-white"></span>Joomla website. (module)</button></p>';
|
||||
$message[] = '<p><button class="btn btn-small btn-success" onclick="Joomla.submitbutton(\'compiler.installCompiledModule\', ' . (int) $module_id . ')">';
|
||||
$message[] = 'Install ' . $module_folder . ' on this <span class="icon-joomla icon-white"></span>Joomla website. (module)</button></p>';
|
||||
}
|
||||
}
|
||||
// check if we have plugins
|
||||
if (ComponentbuilderHelper::checkArray($model->compiler->filepath['plugins']))
|
||||
if ($add_plugin_install)
|
||||
{
|
||||
$add_multi_install = true;
|
||||
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[] = '<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>';
|
||||
}
|
||||
}
|
||||
// set multi install button
|
||||
if ($add_multi_install)
|
||||
{
|
||||
$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[] = '<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>';
|
||||
$message .= '<li>Total files created: <b>'.$model->compiler->fileCount.'</b></li>';
|
||||
$message .= '<li>Total fields created: <b>'.$model->compiler->fieldCount.'</b></li>';
|
||||
$message .= '<li>Total lines written: <b>'.$model->compiler->lineCount.'</b></li>';
|
||||
$message .= '<li>A4 Book of: <b>'.$model->compiler->pageCount.' pages</b></li>';
|
||||
$message .= '</ul>';
|
||||
$message .= '<p><b>'.$model->compiler->totalHours.' Hours</b> or <b>'.$model->compiler->totalDays.' Eight Hour Days</b> <em>(actual time you saved)</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>, never making one mistake or taking any coffee break.)</small><br />';
|
||||
$message .= '<b>'.$model->compiler->actualHoursSpent.' Hours</b> or <b>'.$model->compiler->actualDaysSpent.' Eight Hour Days</b> <em>(the actual time you spent)</em><br />';
|
||||
$message .= '<small>(with the following break down: <b>debugging @'.$model->compiler->debuggingHours.'hours</b> = codingtime / 4; <b>planning @'.$model->compiler->planningHours.'hours</b> = codingtime / 7; <b>mapping @'.$model->compiler->mappingHours.'hours</b> = codingtime / 10; <b>office @'.$model->compiler->officeHours.'hours</b> = codingtime / 6;)</small></p>';
|
||||
$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>Total time saved</h2>';
|
||||
$message[] = '<ul>';
|
||||
$message[] = '<li>Total folders created: <b>'.$model->compiler->folderCount.'</b></li>';
|
||||
$message[] = '<li>Total files created: <b>'.$model->compiler->fileCount.'</b></li>';
|
||||
$message[] = '<li>Total fields created: <b>'.$model->compiler->fieldCount.'</b></li>';
|
||||
$message[] = '<li>Total lines written: <b>'.$model->compiler->lineCount.'</b></li>';
|
||||
$message[] = '<li>A4 Book of: <b>'.$model->compiler->pageCount.' pages</b></li>';
|
||||
$message[] = '</ul>';
|
||||
$message[] = '<p><b>'.$model->compiler->totalHours.' Hours</b> or <b>'.$model->compiler->totalDays.' Eight Hour Days</b> <em>(actual time you saved)</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>, never making one mistake or taking any coffee break.)</small><br />';
|
||||
$message[] = '<b>'.$model->compiler->actualHoursSpent.' Hours</b> or <b>'.$model->compiler->actualDaysSpent.' Eight Hour Days</b> <em>(the actual time you spent)</em><br />';
|
||||
$message[] = '<small>(with the following break down: <b>debugging @'.$model->compiler->debuggingHours.'hours</b> = codingtime / 4; <b>planning @'.$model->compiler->planningHours.'hours</b> = codingtime / 7; <b>mapping @'.$model->compiler->mappingHours.'hours</b> = codingtime / 10; <b>office @'.$model->compiler->officeHours.'hours</b> = codingtime / 6;)</small></p>';
|
||||
$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>';
|
||||
// check if we have modules or plugins
|
||||
if (ComponentbuilderHelper::checkArray($model->compiler->filepath['plugins']) || ComponentbuilderHelper::checkArray($model->compiler->filepath['modules']))
|
||||
if ($add_multi_install)
|
||||
{
|
||||
$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 plugins if found
|
||||
if (ComponentbuilderHelper::checkArray($model->compiler->filepath['plugins']))
|
||||
{
|
||||
$plugin_urls = array();
|
||||
// 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[] = '<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 modules if found
|
||||
if (ComponentbuilderHelper::checkArray($model->compiler->filepath['modules']))
|
||||
if ($add_module_install)
|
||||
{
|
||||
$module_urls = array();
|
||||
// load the modules path/url
|
||||
foreach ($model->compiler->filepath['modules'] as $module_id => $module_path)
|
||||
{
|
||||
// set module path
|
||||
$message .= '<b>Module Path:</b> <code>' . $module_path . '</code><br />';
|
||||
$message[] = '<b>Module Path:</b> <code>' . $module_path . '</code><br />';
|
||||
if (($pos = strpos($module_path, "/tmp/")) !== FALSE)
|
||||
{
|
||||
$module_urls[$module_id] = JURI::root() . substr($module_path, $pos + 1);
|
||||
$message .= '<b>Module URL:</b> <code>' . $module_urls[$module_id] . '</code><br />';
|
||||
$message[] = '<b>Module URL:</b> <code>' . $module_urls[$module_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 plugins if found
|
||||
if ($add_plugin_install)
|
||||
{
|
||||
$plugin_urls = array();
|
||||
// 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 module download URL's
|
||||
if (isset($module_urls) && ComponentbuilderHelper::checkArray($module_urls))
|
||||
{
|
||||
foreach ($module_urls as $module_id => $module_url)
|
||||
{
|
||||
$message .= ' <a class="btn btn-success" href="' . $module_url . '" >';
|
||||
$message .= '<span class="icon-download icon-white"></span>Download ' . $model->compiler->filepath['modules-folder'][$module_id] . '</a> ';
|
||||
$message[] = ' <a class="btn btn-success" href="' . $module_url . '" >';
|
||||
$message[] = '<span class="icon-download icon-white"></span>Download ' . $model->compiler->filepath['modules-folder'][$module_id] . '</a> ';
|
||||
}
|
||||
}
|
||||
// load the plugin download URL's
|
||||
@ -194,33 +208,33 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin
|
||||
{
|
||||
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[] = ' <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>';
|
||||
$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[] = '<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>';
|
||||
$message[] = '<p><small>Compilation took <b>'.$model->compiler->secondsCompiled.'</b> seconds to complete.</small> </p>';
|
||||
// set redirect
|
||||
$this->setRedirect($redirect_url, $message, 'message');
|
||||
$this->setRedirect($redirect_url, implode(PHP_EOL, $message), 'message');
|
||||
$app->setUserState('com_componentbuilder.component_folder_name', $model->compiler->filepath['component-folder']);
|
||||
// check if we have modules
|
||||
if (ComponentbuilderHelper::checkArray($model->compiler->filepath['modules']))
|
||||
if ($add_module_install)
|
||||
{
|
||||
$app->setUserState('com_componentbuilder.modules_folder_name', $model->compiler->filepath['modules-folder']);
|
||||
}
|
||||
// check if we have plugins
|
||||
if (ComponentbuilderHelper::checkArray($model->compiler->filepath['plugins']))
|
||||
if ($add_plugin_install)
|
||||
{
|
||||
$app->setUserState('com_componentbuilder.plugins_folder_name', $model->compiler->filepath['plugins-folder']);
|
||||
}
|
||||
@ -256,9 +270,10 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin
|
||||
// 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_THESE_EXTENSIONS');
|
||||
// currently only administrators can install a component via JCB
|
||||
if($user->authorise('core.admin'))
|
||||
{
|
||||
$message = JText::_('COM_COMPONENTBUILDER_COULD_NOT_INSTALL_EXTENTIONS');
|
||||
$message = JText::_('COM_COMPONENTBUILDER_COULD_NOT_INSTALL_EXTENSIONS');
|
||||
$_message = array('success' => array(), 'error' => array());
|
||||
$app = JFactory::getApplication();
|
||||
// start file name array
|
||||
@ -316,6 +331,7 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin
|
||||
// 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');
|
||||
// currently only administrators can install a component via JCB
|
||||
if($user->authorise('core.admin'))
|
||||
{
|
||||
$message = JText::_('COM_COMPONENTBUILDER_COULD_NOT_INSTALL_COMPONENT');
|
||||
@ -352,6 +368,7 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin
|
||||
// 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_MODULE');
|
||||
// currently only administrators can install a molule via JCB
|
||||
if($user->authorise('core.admin'))
|
||||
{
|
||||
$message = JText::_('COM_COMPONENTBUILDER_COULD_NOT_INSTALL_MODULE');
|
||||
@ -393,6 +410,7 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin
|
||||
// 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');
|
||||
// currently only administrators can install a plugin via JCB
|
||||
if($user->authorise('core.admin'))
|
||||
{
|
||||
$message = JText::_('COM_COMPONENTBUILDER_COULD_NOT_INSTALL_PLUGIN');
|
||||
|
Reference in New Issue
Block a user