'.$model->compiler->actualTotalHours.' Hours or '.$model->compiler->actualTotalDays.' Eight Hour Days (a total of the realistic time frame for this project)
';
$message .= '(if creating a folder and file took 5 seconds and writing one line of code took 10 seconds, with the normal everyday realities at the office, that includes the component planning, mapping & debugging.)
Project duration: '.$model->compiler->projectWeekTime. ' weeks or '.$model->compiler->projectMonthTime.' months
'; - // check if we have plugins - if (ComponentbuilderHelper::checkArray($model->compiler->filepath['plugins'])) + // check if we have modules or plugins + if (ComponentbuilderHelper::checkArray($model->compiler->filepath['plugins']) || ComponentbuilderHelper::checkArray($model->compiler->filepath['modules'])) { - $plugin_url = array(); $message .= 'Component Path: ' . $model->compiler->filepath['component'] . '
';
$message .= 'Component URL: ' . $url . '
';
- // load the plugins path/url
- foreach ($model->compiler->filepath['plugins'] as $plugin_id => $plugin_path)
+ // load plugins if found
+ if (ComponentbuilderHelper::checkArray($model->compiler->filepath['plugins']))
{
- // set plugin path
- $message .= 'Plugin Path: ' . $plugin_path . '
';
- if (($pos = strpos($plugin_path, "/tmp/")) !== FALSE)
+ $plugin_urls = array();
+ // load the plugins path/url
+ foreach ($model->compiler->filepath['plugins'] as $plugin_id => $plugin_path)
{
- $plugin_urls[$plugin_id] = JURI::root() . substr($plugin_path, $pos + 1);
- $message .= 'Plugin URL: ' . $plugin_urls[$plugin_id] . '
';
+ // set plugin path
+ $message .= 'Plugin Path: ' . $plugin_path . '
';
+ if (($pos = strpos($plugin_path, "/tmp/")) !== FALSE)
+ {
+ $plugin_urls[$plugin_id] = JURI::root() . substr($plugin_path, $pos + 1);
+ $message .= 'Plugin URL: ' . $plugin_urls[$plugin_id] . '
';
+ }
+ }
+ }
+ // load modules if found
+ if (ComponentbuilderHelper::checkArray($model->compiler->filepath['modules']))
+ {
+ $module_urls = array();
+ // load the modules path/url
+ foreach ($model->compiler->filepath['modules'] as $module_id => $module_path)
+ {
+ // set module path
+ $message .= 'Module Path: ' . $module_path . '
';
+ if (($pos = strpos($module_path, "/tmp/")) !== FALSE)
+ {
+ $module_urls[$module_id] = JURI::root() . substr($module_path, $pos + 1);
+ $message .= 'Module URL: ' . $module_urls[$module_id] . '
';
+ }
}
}
$message .= '
Hey! you can also download these zip files right now!
';
$message .= 'Download Component ';
- // load the plugin download URL's
- foreach ($plugin_urls as $plugin_id => $plugin_url)
+ // load the module download URL's
+ if (isset($module_urls) && ComponentbuilderHelper::checkArray($module_urls))
{
- $message .= ' ';
- $message .= 'Download ' . $model->compiler->filepath['plugins-folder'][$plugin_id] . ' ';
+ foreach ($module_urls as $module_id => $module_url)
+ {
+ $message .= ' ';
+ $message .= 'Download ' . $model->compiler->filepath['modules-folder'][$module_id] . ' ';
+ }
+ }
+ // load the plugin download URL's
+ if (isset($plugin_urls) && ComponentbuilderHelper::checkArray($plugin_urls))
+ {
+ foreach ($plugin_urls as $plugin_id => $plugin_url)
+ {
+ $message .= ' ';
+ $message .= 'Download ' . $model->compiler->filepath['plugins-folder'][$plugin_id] . ' ';
+ }
}
$message .= '
Remember! These zip files are in your tmp folder and therefore publicly accessible until you click [Clear tmp]!
'; @@ -164,6 +212,11 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin // set redirect $this->setRedirect($redirect_url, $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'])) + { + $app->setUserState('com_componentbuilder.modules_folder_name', $model->compiler->filepath['modules-folder']); + } // check if we have plugins if (ComponentbuilderHelper::checkArray($model->compiler->filepath['plugins'])) { @@ -177,6 +230,7 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin $app->setUserState('com_componentbuilder.message', ''); $app->setUserState('com_componentbuilder.extension_message', ''); $app->setUserState('com_componentbuilder.component_folder_name', ''); + $app->setUserState('com_componentbuilder.modules_folder_name', ''); $app->setUserState('com_componentbuilder.plugins_folder_name', ''); // set redirect $this->setRedirect($redirect_url, $message); @@ -205,8 +259,20 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin $message = JText::_('COM_COMPONENTBUILDER_COULD_NOT_INSTALL_EXTENTIONS'); $_message = array('success' => array(), 'error' => array()); $app = JFactory::getApplication(); - $fileNames = $app->getUserState('com_componentbuilder.plugins_folder_name', array()); + // start file name array + $fileNames = array(); $fileNames[] = $app->getUserState('com_componentbuilder.component_folder_name', null); + // check if we have modules + $fileNames = ComponentbuilderHelper::mergeArrays(array($fileNames, $app->getUserState('com_componentbuilder.modules_folder_name', array()) )); + // check if we have plugins + $fileNames = ComponentbuilderHelper::mergeArrays(array($fileNames, $app->getUserState('com_componentbuilder.plugins_folder_name', array()) )); + + // wipe out the user c-m-p since we are done with them all + $app->setUserState('com_componentbuilder.component_folder_name', ''); + $app->setUserState('com_componentbuilder.modules_folder_name', ''); + $app->setUserState('com_componentbuilder.plugins_folder_name', ''); + + // loop and install all extensions found foreach ($fileNames as $fileName) { if ($this->installExtension($fileName)) @@ -251,7 +317,14 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin if($user->authorise('core.admin')) { $message = JText::_('COM_COMPONENTBUILDER_COULD_NOT_INSTALL_COMPONENT'); - $fileName = JFactory::getApplication()->getUserState('com_componentbuilder.component_folder_name'); + $app = JFactory::getApplication(); + $fileName = $app->getUserState('com_componentbuilder.component_folder_name'); + + // wipe out the user c-m-p since we are done with them all + $app->setUserState('com_componentbuilder.component_folder_name', ''); + $app->setUserState('com_componentbuilder.modules_folder_name', ''); + $app->setUserState('com_componentbuilder.plugins_folder_name', ''); + if ($this->installExtension($fileName)) { $message = JText::sprintf('COM_COMPONENTBUILDER_ONLY_SZIP_FILE_WAS_REMOVED_THE_FROM_TMP_FOLDER_DURING_INSTALLATION', $fileName); @@ -263,6 +336,47 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin return false; } + /** + * Install Compiled Module + * + * @return true on success + */ + public function installCompiledModule() + { + // 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_MODULE'); + if($user->authorise('core.admin')) + { + $message = JText::_('COM_COMPONENTBUILDER_COULD_NOT_INSTALL_MODULE'); + $app = JFactory::getApplication(); + $fileNames = $app->getUserState('com_componentbuilder.modules_folder_name'); + + // wipe out the user c-m-p since we are done with them all + $app->setUserState('com_componentbuilder.component_folder_name', ''); + $app->setUserState('com_componentbuilder.modules_folder_name', ''); + $app->setUserState('com_componentbuilder.plugins_folder_name', ''); + + if (ComponentbuilderHelper::checkArray($fileNames)) + { + $jinput = JFactory::getApplication()->input; + $moduleId = $jinput->post->get('install_item_id', 0, 'INT'); + if ($moduleId > 0 && isset($fileNames[$moduleId]) && $this->installExtension($fileNames[$moduleId])) + { + $message = JText::sprintf('COM_COMPONENTBUILDER_ONLY_SZIP_FILE_WAS_REMOVED_THE_FROM_TMP_FOLDER_DURING_INSTALLATION', $fileNames[$moduleId]); + $this->setRedirect($redirect_url, $message, 'message'); + return true; + } + } + } + $this->setRedirect($redirect_url, $message, 'error'); + return false; + } + /** * Install Compiled Plugin * @@ -282,6 +396,12 @@ class ComponentbuilderControllerCompiler extends JControllerAdmin $message = JText::_('COM_COMPONENTBUILDER_COULD_NOT_INSTALL_PLUGIN'); $app = JFactory::getApplication(); $fileNames = $app->getUserState('com_componentbuilder.plugins_folder_name'); + + // wipe out the user c-m-p since we are done with them all + $app->setUserState('com_componentbuilder.component_folder_name', ''); + $app->setUserState('com_componentbuilder.modules_folder_name', ''); + $app->setUserState('com_componentbuilder.plugins_folder_name', ''); + if (ComponentbuilderHelper::checkArray($fileNames)) { $jinput = JFactory::getApplication()->input; diff --git a/admin/controllers/component_modules.php b/admin/controllers/component_modules.php new file mode 100644 index 000000000..1dfea9f78 --- /dev/null +++ b/admin/controllers/component_modules.php @@ -0,0 +1,321 @@ + + * @github Joomla Component Builder' . $module->description . '
'; + } + $module->xml_description = "Created by " . trim(JFilterOutput::cleanText($component->author)) . "
Development started " . JFactory::getDate($module->created)->format("jS F, Y") . "