Component Builder (v.2.4.10)
+ Component Builder (v.2.5.0)
The Component Builder for [Joomla](http://www.joomla.org/) that is highly advanced, truly able to build extremely complex components in a fraction of the time.
@@ -50,9 +50,23 @@ Whether you're a seasoned [Joomla](http://www.joomla.org/) developer, or have ju
-
+
+ controller.php
+ index.html
+ router.php
+ componentbuilder.php
+ assets
+ helpers
+ controllers
+ models
+ views
+ layouts
+
-
+
+ language/en-GB/en-GB.com_componentbuilder.ini
+ language/en-GB/en-GB.com_componentbuilder.sys.ini
+
COM_COMPONENTBUILDER_MENU
diff --git a/componentbuilder_update_server.xml b/componentbuilder_update_server.xml
index eecd739d1..0b0bad436 100644
--- a/componentbuilder_update_server.xml
+++ b/componentbuilder_update_server.xml
@@ -373,4 +373,21 @@
http://vdm.bz/component-builder
+
+ Component Builder
+ Builds Complex Joomla Components
+ com_componentbuilder
+ component
+ 2.5.0
+ http://vdm.bz/component-builder
+
+ https://github.com/vdm-io/Joomla-Component-Builder/releases/download/v2.5.0/JCB_v2.5.0.zip
+
+
+ stable
+
+ Llewellyn van der Merwe
+ http://vdm.bz/component-builder
+
+
\ No newline at end of file
diff --git a/script.php b/script.php
index b48586792..1dd14d5aa 100644
--- a/script.php
+++ b/script.php
@@ -10,8 +10,8 @@
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
- @version 2.4.10
- @build 12th August, 2017
+ @version 2.5.0
+ @build 21st August, 2017
@created 30th April, 2015
@package Component Builder
@subpackage script.php
@@ -1714,7 +1714,7 @@ class com_componentbuilderInstallerScript
// Field to update.
$fields = array(
- $db->quoteName('params') . ' = ' . $db->quote('{"autorName":"Llewellyn van der Merwe","autorEmail":"joomla@vdm.io","minify":"0","percentagelanguageadd":"50","export_license":"GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html","export_copyright":"Copyright (C) 2015. All Rights Reserved","check_in":"-1 day","save_history":"1","history_limit":"10","uikit_load":"1","uikit_min":"","uikit_style":""}'),
+ $db->quoteName('params') . ' = ' . $db->quote('{"autorName":"Llewellyn van der Merwe","autorEmail":"joomla@vdm.io","minify":"0","percentagelanguageadd":"50","backup_package_name":"JCB_Backup_[YEAR]_[MONTH]_[DAY]","export_license":"GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html","export_copyright":"Copyright (C) 2015. All Rights Reserved","check_in":"-1 day","save_history":"1","history_limit":"10","uikit_load":"1","uikit_min":"","uikit_style":""}'),
);
// Condition.
@@ -1726,7 +1726,7 @@ class com_componentbuilderInstallerScript
$db->setQuery($query);
$allDone = $db->execute();
echo '
-
+
';
}
// do any updates needed
@@ -2202,9 +2202,9 @@ class com_componentbuilderInstallerScript
echo '
-
+
- Upgrade to Version 2.4.10 Was Successful! Let us know if anything is not working as expected. ';
+ Upgrade to Version 2.5.0 Was Successful! Let us know if anything is not working as expected. ';
}
}
}
diff --git a/site/assets/css/api.css b/site/assets/css/api.css
new file mode 100644
index 000000000..dd4585a78
--- /dev/null
+++ b/site/assets/css/api.css
@@ -0,0 +1,27 @@
+/*--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
+ __ __ _ _____ _ _ __ __ _ _ _
+ \ \ / / | | | __ \ | | | | | \/ | | | | | | |
+ \ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| |
+ \ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` |
+ \ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| |
+ \/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_|
+ | |
+ |_|
+/-------------------------------------------------------------------------------------------------------------------------------/
+
+ @version @update number 7 of this MVC
+ @build 19th August, 2017
+ @created 19th August, 2017
+ @package Component Builder
+ @subpackage api.css
+ @author Llewellyn 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
+
+/-----------------------------------------------------------------------------------------------------------------------------*/
+
+/* CSS Document */
+
+
diff --git a/site/assets/css/index.html b/site/assets/css/index.html
new file mode 100644
index 000000000..fa6d84e80
--- /dev/null
+++ b/site/assets/css/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/site/assets/css/site.css b/site/assets/css/site.css
new file mode 100644
index 000000000..f4881bcfd
--- /dev/null
+++ b/site/assets/css/site.css
@@ -0,0 +1,31 @@
+/*--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
+ __ __ _ _____ _ _ __ __ _ _ _
+ \ \ / / | | | __ \ | | | | | \/ | | | | | | |
+ \ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| |
+ \ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` |
+ \ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| |
+ \/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_|
+ | |
+ |_|
+/-------------------------------------------------------------------------------------------------------------------------------/
+
+ @version 2.5.0
+ @build 21st August, 2017
+ @created 30th April, 2015
+ @package Component Builder
+ @subpackage site.css
+ @author Llewellyn 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
+
+/-----------------------------------------------------------------------------------------------------------------------------*/
+
+/* CSS Document */
+.no-click {
+ pointer-events: none;
+}
+.fieldMedium { width: 130px; }
+.fieldSmall { width: 60px; }
+code { display: inline-block; margin: 3px;}
diff --git a/site/assets/images/index.html b/site/assets/images/index.html
new file mode 100644
index 000000000..fa6d84e80
--- /dev/null
+++ b/site/assets/images/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/site/assets/index.html b/site/assets/index.html
new file mode 100644
index 000000000..fa6d84e80
--- /dev/null
+++ b/site/assets/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/site/assets/js/index.html b/site/assets/js/index.html
new file mode 100644
index 000000000..fa6d84e80
--- /dev/null
+++ b/site/assets/js/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/site/assets/js/site.js b/site/assets/js/site.js
new file mode 100644
index 000000000..e69de29bb
diff --git a/site/componentbuilder.php b/site/componentbuilder.php
new file mode 100644
index 000000000..624d0b6a1
--- /dev/null
+++ b/site/componentbuilder.php
@@ -0,0 +1,50 @@
+
+ @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');
+
+// Set the component css/js
+$document = JFactory::getDocument();
+$document->addStyleSheet('components/com_componentbuilder/assets/css/site.css');
+$document->addScript('components/com_componentbuilder/assets/js/site.js');
+
+// Require helper files
+JLoader::register('ComponentbuilderHelper', dirname(__FILE__) . '/helpers/componentbuilder.php');
+JLoader::register('ComponentbuilderEmail', JPATH_COMPONENT_ADMINISTRATOR . '/helpers/componentbuilderemail.php');
+JLoader::register('ComponentbuilderHelperRoute', dirname(__FILE__) . '/helpers/route.php');
+
+// import joomla controller library
+jimport('joomla.application.component.controller');
+
+// Get an instance of the controller prefixed by Componentbuilder
+$controller = JControllerLegacy::getInstance('Componentbuilder');
+
+// Perform the request task
+$jinput = JFactory::getApplication()->input;
+$controller->execute($jinput->get('task', null, 'CMD'));
+
+// Redirect if set by the controller
+$controller->redirect();
diff --git a/site/controller.php b/site/controller.php
new file mode 100644
index 000000000..2c09b3248
--- /dev/null
+++ b/site/controller.php
@@ -0,0 +1,101 @@
+
+ @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 controller library
+jimport('joomla.application.component.controller');
+
+/**
+ * Componentbuilder Component Controller
+ */
+class ComponentbuilderController extends JControllerLegacy
+{
+ /**
+ * display task
+ *
+ * @return void
+ */
+ function display($cachable = false, $urlparams = false)
+ {
+ // set default view if not set
+ $view = $this->input->getCmd('view', '');
+ $isEdit = $this->checkEditView($view);
+ $layout = $this->input->get('layout', null, 'WORD');
+ $id = $this->input->getInt('id');
+ $cachable = true;
+
+ // Check for edit form.
+ if($isEdit)
+ {
+ if ($layout == 'edit' && !$this->checkEditId('com_componentbuilder.edit.'.$view, $id))
+ {
+ // Somehow the person just went to the form - we don't allow that.
+ $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
+ $this->setMessage($this->getError(), 'error');
+ // check if item was opend from other then its own list view
+ $ref = $this->input->getCmd('ref', 0);
+ $refid = $this->input->getInt('refid', 0);
+ // set redirect
+ if ($refid > 0 && ComponentbuilderHelper::checkString($ref))
+ {
+ // redirect to item of ref
+ $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view='.(string)$ref.'&layout=edit&id='.(int)$refid, false));
+ }
+ elseif (ComponentbuilderHelper::checkString($ref))
+ {
+
+ // redirect to ref
+ $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view='.(string)$ref, false));
+ }
+ else
+ {
+ // normal redirect back to the list default site view
+ $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=', false));
+ }
+ return false;
+ }
+ }
+
+ return parent::display($cachable, $urlparams);
+ }
+
+ protected function checkEditView($view)
+ {
+ if (ComponentbuilderHelper::checkString($view))
+ {
+ $views = array(
+
+ );
+ // check if this is a edit view
+ if (in_array($view,$views))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/site/controllers/api.php b/site/controllers/api.php
new file mode 100644
index 000000000..b738fbbb1
--- /dev/null
+++ b/site/controllers/api.php
@@ -0,0 +1,268 @@
+
+ @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 controllerform library
+jimport('joomla.application.component.controller');
+
+/**
+ * Componentbuilder Api Controller
+ */
+class ComponentbuilderControllerApi extends JControllerForm
+{
+ /**
+ * Current or most recently performed task.
+ *
+ * @var string
+ * @since 12.2
+ * @note Replaces _task.
+ */
+ protected $task;
+
+ public function __construct($config = array())
+ {
+ $this->view_list = ''; // safeguard for setting the return view listing to the default site view.
+ parent::__construct($config);
+ }
+
+
+ public function backup()
+ {
+ // get params
+ if (!isset($this->params) || !ComponentbuilderHelper::checkObject($this->params))
+ {
+ $this->params = JComponentHelper::getParams('com_componentbuilder');
+ }
+ // get all component IDs to backup
+ $pks = componentbuilderHelper::getComponentIDs();
+ // Get the model
+ $model = componentbuilderHelper::getModel('joomla_components', JPATH_ADMINISTRATOR . '/components/com_componentbuilder');
+ // set user
+ $model->user = $this->getApiUser();
+ // make sure to set active type to backup
+ $model->activeType = 'backup';
+ // set auto loader
+ ComponentbuilderHelper::autoLoader('smart');
+ // manual backup message
+ $backupNotice = array();
+ // get the data to export
+ if (ComponentbuilderHelper::checkArray($pks) && $model->getSmartExport($pks))
+ {
+ $backupNotice[] = JText::_('COM_COMPONENTBUILDER_BACKUP_WAS_DONE_SUCCESSFULLY');
+ $backupNoticeStatus = 'Success';
+ // set the key string
+ if (componentbuilderHelper::checkString($model->key) && strlen($model->key) == 32)
+ {
+ $textNotice = array();
+ $keyNotice = '' . JText::sprintf('COM_COMPONENTBUILDER_THE_PACKAGE_KEY_IS_CODESCODE', $model->key) . ' ';
+ $textNotice[] = JText::sprintf('COM_COMPONENTBUILDER_THE_PACKAGE_KEY_IS_S', $model->key);
+ $keyNotice .= JText::_('COM_COMPONENTBUILDER_YOUR_DATA_IS_ENCRYPTED_WITH_A_AES_ONE_HUNDRED_AND_TWENTY_EIGHT_BIT_ENCRYPTION_USING_THE_ABOVE_THIRTY_TWO_CHARACTER_KEY_WITHOUT_THIS_KEY_IT_WILL_TAKE_THE_CURRENT_TECHNOLOGY_WITH_A_BRUTE_FORCE_ATTACK_METHOD_MORE_THEN_A_HREFHTTPRANDOMIZECOMHOWLONGTOHACKPASS_TARGET_BLANK_TITLEHOW_LONG_TO_HACK_PASSSEVEN_HUNDRED_ZERO_ZERO_ZERO_ZERO_ZERO_ZERO_ZERO_ZERO_ZERO_ZEROA_YEARS_TO_CRACK_THEORETICALLY_UNLESS_THEY_HAVE_THIS_KEY_ABOVE_SO_DO_KEEP_IT_SAFE') . ' ';
+ // set the package owner info
+ if ((isset($model->info['getKeyFrom']['company']) && componentbuilderHelper::checkString($model->info['getKeyFrom']['company'])) || (isset($model->info['getKeyFrom']['owner']) && componentbuilderHelper::checkString($model->info['getKeyFrom']['owner'])))
+ {
+ $ownerDetails = '' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS') . ' ';
+ $textNotice[] = '# ' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS');
+ $ownerDetails .= '';
+ if (isset($model->info['getKeyFrom']['company']) && componentbuilderHelper::checkString($model->info['getKeyFrom']['company']))
+ {
+ $ownerDetails .= '' . JText::sprintf('COM_COMPONENTBUILDER_EMCOMPANYEM_BSB', $model->info['getKeyFrom']['company']) . ' ';
+ $textNotice[] = '- ' . JText::sprintf('COM_COMPONENTBUILDER_COMPANY_S', $model->info['getKeyFrom']['company']);
+ }
+ // add value only if set
+ if (isset($model->info['getKeyFrom']['owner']) && componentbuilderHelper::checkString($model->info['getKeyFrom']['owner']))
+ {
+ $ownerDetails .= '' . JText::sprintf('COM_COMPONENTBUILDER_EMOWNEREM_BSB', $model->info['getKeyFrom']['owner']) . ' ';
+ $textNotice[] = '- ' . JText::sprintf('COM_COMPONENTBUILDER_OWNER_S', $model->info['getKeyFrom']['owner']);
+ }
+ // add value only if set
+ if (isset($model->info['getKeyFrom']['website']) && componentbuilderHelper::checkString($model->info['getKeyFrom']['website']))
+ {
+ $ownerDetails .= '' . JText::sprintf('COM_COMPONENTBUILDER_EMWEBSITEEM_BSB', $model->info['getKeyFrom']['website']) . ' ';
+ $textNotice[] = '- ' . JText::sprintf('COM_COMPONENTBUILDER_WEBSITE_S', $model->info['getKeyFrom']['website']);
+ }
+ // add value only if set
+ if (isset($model->info['getKeyFrom']['email']) && componentbuilderHelper::checkString($model->info['getKeyFrom']['email']))
+ {
+ $ownerDetails .= '' . JText::sprintf('COM_COMPONENTBUILDER_EMEMAILEM_BSB', $model->info['getKeyFrom']['email']) . ' ';
+ $textNotice[] = '- ' . JText::sprintf('COM_COMPONENTBUILDER_EMAIL_S', $model->info['getKeyFrom']['email']);
+ }
+ // add value only if set
+ if (isset($model->info['getKeyFrom']['license']) && componentbuilderHelper::checkString($model->info['getKeyFrom']['license']))
+ {
+ $ownerDetails .= '' . JText::sprintf('COM_COMPONENTBUILDER_EMLICENSEEM_BSB', $model->info['getKeyFrom']['license']) . ' ';
+ $textNotice[] = '- ' . JText::sprintf('COM_COMPONENTBUILDER_LICENSE_S', $model->info['getKeyFrom']['license']);
+ }
+ // add value only if set
+ if (isset($model->info['getKeyFrom']['copyright']) && componentbuilderHelper::checkString($model->info['getKeyFrom']['copyright']))
+ {
+ $ownerDetails .= '' . JText::sprintf('COM_COMPONENTBUILDER_EMCOPYRIGHTEM_BSB', $model->info['getKeyFrom']['copyright']) . ' ';
+ $textNotice[] = '- ' . JText::sprintf('COM_COMPONENTBUILDER_COPYRIGHT_S', $model->info['getKeyFrom']['copyright']);
+ }
+ $ownerDetails .= ' ';
+ $backupNotice[] = JText::_('COM_COMPONENTBUILDER_OWNER_DETAILS_WAS_SET');
+ }
+ else
+ {
+ $ownerDetails = '' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_NOT_SET') . ' ';
+ $textNotice[] = '# ' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS');
+ $ownerDetails .= JText::_('COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_BJCB_GLOBAL_OPTIONSB_GO_TO_THE_BCOMPANYB_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE') . ' ';
+ $textNotice[] = JText::_('COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_JCB_GLOBAL_OPTIONS_GO_TO_THE_COMPANY_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE');
+ $ownerDetails .= '' . JText::_('COM_COMPONENTBUILDER_YOU_SHOULD_ADD_THE_CORRECT_OWNER_DETAILS') . ' ';
+ $textNotice[] = '## ' . JText::_('COM_COMPONENTBUILDER_YOU_SHOULD_ADD_THE_CORRECT_OWNER_DETAILS');
+ $ownerDetails .= JText::_('COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_BIMPORT_PROCESSB_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_BDOES_NOTB_HAVE_THE_KEY_THEY_CAN_SEE_BWHERE_TO_GET_ITB') . ' ';
+ $textNotice[] = JText::_('COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_IMPORT_PROCESS_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_DOES_NOT_HAVE_THE_KEY_THEY_CAN_SEE_WHERE_TO_GET_IT');
+ $backupNotice[] = JText::_('COM_COMPONENTBUILDER_CHECK_YOUR_OWNER_DETAILS_IT_HAS_NOT_BEEN_SET_OPEN_THE_JCB_GLOBAL_OPTIONS_GO_TO_THE_COMPANY_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE');
+ }
+ }
+ else
+ {
+ $keyNotice = '' . JText::_('COM_COMPONENTBUILDER_THIS_PACKAGE_HAS_NO_KEY') . ' ';
+ $textNotice[] = '# ' . JText::_('COM_COMPONENTBUILDER_THIS_PACKAGE_HAS_NO_KEY');
+ $ownerDetails = JText::_('COM_COMPONENTBUILDER_THAT_MEANS_ANYONE_WHO_HAS_THIS_PACKAGE_CAN_INSTALL_IT_INTO_JCB_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_BSETTINGSB_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_BEXPORT_KEYB') . ' ';
+ $textNotice[] = JText::_('COM_COMPONENTBUILDER_THAT_MEANS_ANYONE_WHO_HAS_THIS_PACKAGE_CAN_INSTALL_IT_INTO_JCB_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_SETTINGS_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_EXPORT_KEY');
+ $backupNotice[] = JText::_('COM_COMPONENTBUILDER_NO_KEYS_WERE_FOUND_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COMPONENT_GO_TO_THE_TAB_CALLED_SETTINGS_BOTTOM_RIGHT_THERE_IS_A_FIELD_CALLED_EXPORT_KEY');
+ }
+ // get email
+ if ($email = $this->params->get('backup_email', null))
+ {
+ // plain text
+ $plainText = implode("\n", $textNotice);
+ // set hash to track changes
+ $hashTracker = md5($plainText);
+ if (ComponentbuilderHelper::newHash($hashTracker))
+ {
+ // Build final massage.
+ $message = $keyNotice . $ownerDetails . 'HASH: ' . $hashTracker . ' ';
+ // set the subject
+ $subject = JText::_('COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BUILDER_BACKUP_KEY');
+ // email the message
+ componentbuilderEmail::send($email, $subject, componentbuilderEmail::setTableBody($message, $subject), $plainText, 1);
+ $backupNotice[] = JText::_('COM_COMPONENTBUILDER_EMAIL_WITH_THE_NEW_KEY_WAS_SEND');
+ }
+ else
+ {
+ $backupNotice[] = JText::_('COM_COMPONENTBUILDER_KEY_HAS_NOT_CHANGED');
+ }
+ }
+ }
+ else
+ {
+ $backupNotice[] = JText::_('COM_COMPONENTBUILDER_BACKUP_FAILED_PLEASE_TRY_AGAIN_IF_THE_ERROR_CONTINUE_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR');
+ $backupNoticeStatus = 'Error';
+ if (componentbuilderHelper::checkString($model->packagePath))
+ {
+ // clear all if not successful
+ ComponentbuilderHelper::removeFolder($model->packagePath);
+ }
+ if (componentbuilderHelper::checkString($model->zipPath))
+ {
+ // clear all if not successful
+ JFile::delete($model->zipPath);
+ }
+ }
+ // quite only if auto backup (adding this script from custom code :)
+ if ('backup' === 'backup')
+ {
+ echo "# " . $backupNoticeStatus . "\n" .implode("\n", $backupNotice);
+ jexit();
+ }
+ $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=joomla_components', false), implode(" ", $backupNotice), $backupNoticeStatus);
+ return;
+ }
+
+ protected function getApiUser()
+ {
+ // return user object
+ return JFactory::getUser($this->params->get('api', 0, 'INT'));
+ }
+
+ /**
+ * Method to check if you can edit an existing record.
+ *
+ * Extended classes can override this if necessary.
+ *
+ * @param array $data An array of input data.
+ * @param string $key The name of the key for the primary key; default is id.
+ *
+ * @return boolean
+ *
+ * @since 12.2
+ */
+ protected function allowEdit($data = array(), $key = 'id')
+ {
+ // to insure no other tampering
+ return false;
+ }
+
+ /**
+ * Method override to check if you can add a new record.
+ *
+ * @param array $data An array of input data.
+ *
+ * @return boolean
+ *
+ * @since 1.6
+ */
+ protected function allowAdd($data = array())
+ {
+ // to insure no other tampering
+ return false;
+ }
+
+ /**
+ * Method to check if you can save a new or existing record.
+ *
+ * Extended classes can override this if necessary.
+ *
+ * @param array $data An array of input data.
+ * @param string $key The name of the key for the primary key.
+ *
+ * @return boolean
+ *
+ * @since 12.2
+ */
+ protected function allowSave($data, $key = 'id')
+ {
+ // to insure no other tampering
+ return false;
+ }
+
+ /**
+ * Function that allows child controller access to model data
+ * after the data has been saved.
+ *
+ * @param JModelLegacy $model The data model object.
+ * @param array $validData The validated data.
+ *
+ * @return void
+ *
+ * @since 12.2
+ */
+ protected function postSaveHook(JModelLegacy $model, $validData = array())
+ {
+ }
+}
diff --git a/site/controllers/help.php b/site/controllers/help.php
new file mode 100644
index 000000000..cb8961942
--- /dev/null
+++ b/site/controllers/help.php
@@ -0,0 +1,130 @@
+
+ @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 controllerform library
+jimport('joomla.application.component.controller');
+
+/**
+ * Componentbuilder Help Controller
+ */
+class ComponentbuilderControllerHelp extends JControllerLegacy
+{
+ public function __construct($config)
+ {
+ parent::__construct($config);
+ // load the tasks
+ $this->registerTask('getText', 'help');
+ }
+
+ public function help()
+ {
+ $user = JFactory::getUser();
+ $jinput = JFactory::getApplication()->input;
+ // Check Token!
+ $token = JSession::getFormToken();
+ $call_token = $jinput->get('token', 0, 'ALNUM');
+ if($token == $call_token){
+ $task = $this->getTask();
+ switch($task){
+ case 'getText':
+ try
+ {
+ $idValue = $jinput->get('id', 0, 'INT');
+ if($idValue)
+ {
+ $result = $this->getHelpDocumentText($idValue);
+ }
+ else
+ {
+ $result = '';
+ }
+ echo $result;
+ // stop execution gracefully
+ jexit();
+ }
+ catch(Exception $e)
+ {
+ // stop execution gracefully
+ jexit();
+ }
+ break;
+ }
+ }
+ else
+ {
+ // stop execution gracefully
+ jexit();
+ }
+ }
+
+ protected function getHelpDocumentText($id)
+ {
+ $db = JFactory::getDbo();
+ $query = $db->getQuery(true);
+ $query->select(array('a.title','a.content'));
+ $query->from('#__componentbuilder_help_document AS a');
+ $query->where('a.id = '.(int) $id);
+ $query->where('a.published = 1');
+ $query->where('a.location = 2');
+ $db->setQuery($query);
+ $db->execute();
+ if($db->getNumRows())
+ {
+ $text = array();
+ $document = $db->loadObject();
+ // fix image issue
+ $images['src="images'] = 'src="'.JURI::root().'images';
+ $images["src='images"] = "src='".JURI::root()."images";
+ $images['src="/images'] = 'src="'.JURI::root().'images';
+ $images["src='/images"] = "src='".JURI::root()."images";
+ // set document template
+ $text[] = "";
+ $text[] = '';
+ $text[] = "";
+ $text[] = ' ';
+ $text[] = "".$document->title." ";
+ $text[] = ' ';
+ $text[] = '';
+ $text[] = "";
+ $text[] = ' ';
+ $text[] = '';
+ $text[] = '
';
+ // build the help text
+ $text[] = '
'.$document->title." ";
+ $text[] = str_replace(array_keys($images),array_values($images),$document->content);
+ // end template
+ $text[] = '';
+ $text[] = '
';
+ $text[] = "";
+ $text[] = "";
+
+ return implode("\n",$text);
+ }
+ return false;
+ }
+}
diff --git a/site/controllers/index.html b/site/controllers/index.html
new file mode 100644
index 000000000..fa6d84e80
--- /dev/null
+++ b/site/controllers/index.html
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/site/helpers/category.php b/site/helpers/category.php
new file mode 100644
index 000000000..94f0d56ff
--- /dev/null
+++ b/site/helpers/category.php
@@ -0,0 +1,52 @@
+
+ @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');
+
+/**
+ * Componentbuilder Component Category Tree
+ */
+
+//Insure this view category file is loaded.
+$classname = 'componentbuilderFieldsCategories';
+if (!class_exists($classname))
+{
+ $path = JPATH_SITE . '/components/com_componentbuilder/helpers/categoryfields.php';
+ if (is_file($path))
+ {
+ include_once $path;
+ }
+}
+//Insure this view category file is loaded.
+$classname = 'componentbuilderFieldtypesCategories';
+if (!class_exists($classname))
+{
+ $path = JPATH_SITE . '/components/com_componentbuilder/helpers/categoryfieldtypes.php';
+ if (is_file($path))
+ {
+ include_once $path;
+ }
+}
diff --git a/site/helpers/categoryfields.php b/site/helpers/categoryfields.php
new file mode 100644
index 000000000..a5d0019f8
--- /dev/null
+++ b/site/helpers/categoryfields.php
@@ -0,0 +1,47 @@
+
+ @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');
+
+/**
+ * Componentbuilder Field Component Category Tree
+ */
+class ComponentbuilderFieldsCategories extends JCategories
+{
+ /**
+ * Class constructor
+ *
+ * @param array $options Array of options
+ *
+ */
+ public function __construct($options = array())
+ {
+ $options['table'] = '#__componentbuilder_field';
+ $options['extension'] = 'com_componentbuilder.fields';
+
+ parent::__construct($options);
+ }
+}
diff --git a/site/helpers/categoryfieldtypes.php b/site/helpers/categoryfieldtypes.php
new file mode 100644
index 000000000..b3195e426
--- /dev/null
+++ b/site/helpers/categoryfieldtypes.php
@@ -0,0 +1,47 @@
+
+ @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');
+
+/**
+ * Componentbuilder Fieldtype Component Category Tree
+ */
+class ComponentbuilderFieldtypesCategories extends JCategories
+{
+ /**
+ * Class constructor
+ *
+ * @param array $options Array of options
+ *
+ */
+ public function __construct($options = array())
+ {
+ $options['table'] = '#__componentbuilder_fieldtype';
+ $options['extension'] = 'com_componentbuilder.fieldtypes';
+
+ parent::__construct($options);
+ }
+}
diff --git a/site/helpers/componentbuilder.php b/site/helpers/componentbuilder.php
new file mode 100644
index 000000000..5bc54d70c
--- /dev/null
+++ b/site/helpers/componentbuilder.php
@@ -0,0 +1,2269 @@
+
+ @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');
+
+/**
+ * Componentbuilder component helper
+ */
+abstract class ComponentbuilderHelper
+{
+
+ /*
+ * get all component IDs
+ */
+ public static function getComponentIDs()
+ {
+ // Get a db connection.
+ $db = JFactory::getDbo();
+ // Create a new query object.
+ $query = $db->getQuery(true);
+ $query->select($db->quoteName(array('id')));
+ $query->from($db->quoteName('#__componentbuilder_joomla_component'));
+ $query->where($db->quoteName('published') . ' >= 1'); // do not backup trash
+ $db->setQuery($query);
+ $db->execute();
+ if ($db->getNumRows())
+ {
+ return $db->loadColumn();
+ }
+ return false;
+ }
+
+ /*
+ * Autoloader
+ */
+ public static function autoLoader($type = 'compiler')
+ {
+ // load the type classes
+ if ('smart' !== $type)
+ {
+ foreach (glob(JPATH_ADMINISTRATOR."/components/com_componentbuilder/helpers/".$type."/*.php") as $autoFile)
+ {
+ require_once $autoFile;
+ }
+ }
+ // load only if compiler
+ if ('compiler' === $type)
+ {
+ // import the Joomla librarys
+ jimport('joomla.filesystem.file');
+ jimport('joomla.filesystem.folder');
+ jimport('joomla.filesystem.archive');
+ jimport('joomla.application.component.modellist');
+ // include class to minify js
+ require_once JPATH_ADMINISTRATOR.'/components/com_componentbuilder/helpers/js.php';
+ }
+ // load only if smart
+ if ('smart' === $type)
+ {
+ // import the Joomla libraries
+ jimport('joomla.filesystem.file');
+ jimport('joomla.filesystem.folder');
+ jimport('joomla.filesystem.archive');
+ jimport('joomla.application.component.modellist');
+ }
+ // load this for all
+ jimport('joomla.application');
+ }
+
+ /**
+ * Remove folders with files
+ *
+ * @param string $dir The path to folder to remove
+ * @param boolean $git if there is a git folder in that must not be removed
+ *
+ * @return boolean True in all is removed
+ *
+ */
+ public static function removeFolder($dir, $git = false)
+ {
+ if (JFolder::exists($dir))
+ {
+ $it = new RecursiveDirectoryIterator($dir);
+ $it = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
+ foreach ($it as $file)
+ {
+ if ('.' === $file->getBasename() || '..' === $file->getBasename()) continue;
+ if ($file->isDir())
+ {
+ if ($git && strpos($file->getPathname(), $dir.'/.git') !== false) continue;
+ JFolder::delete($file->getPathname());
+ }
+ else
+ {
+ if ($git && strpos($file->getPathname(), $dir.'/.git') !== false) continue;
+ JFile::delete($file->getPathname());
+ }
+ }
+ if (!$git && JFolder::delete($dir))
+ {
+ return true;
+ }
+ }
+ return false;
+ } /**
+ * The dynamic builder of views, tables and fields
+ **/
+ public static function dynamicBuilder(&$data, $type)
+ {
+ self::autoLoader('extrusion');
+ $extruder = new Extrusion($data);
+ }
+
+ /**
+ * The zipper method
+ **/
+ public static function zip($workingDIR, &$filepath)
+ {
+ // store the current joomla working directory
+ $joomla = getcwd();
+
+ // we are changing the working directory to the component temp folder
+ chdir($workingDIR);
+
+ // the full file path of the zip file
+ $filepath = JPath::clean($filepath);
+
+ // delete an existing zip file (or use an exclusion parameter in JFolder::files()
+ JFile::delete($filepath);
+
+ // get a list of files in the current directory tree
+ $files = JFolder::files('.', '', true, true);
+ $zipArray = array();
+ // setup the zip array
+ foreach ($files as $file)
+ {
+ $tmp = array();
+ $tmp['name'] = str_replace('./', '', $file);
+ $tmp['data'] = JFile::read($file);
+ $tmp['time'] = filemtime($file);
+ $zipArray[] = $tmp;
+ }
+
+ // change back to joomla working directory
+ chdir($joomla);
+
+ // get the zip adapter
+ $zip = JArchive::getAdapter('zip');
+
+ //create the zip file
+ if ($zip->create($filepath, $zipArray))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Create file and write data to the file
+ **/
+ public static function writeFile($path, $data)
+ {
+ $klaar = false;
+ // open the file
+ $fh = fopen($path, "w");
+ if (!is_resource($fh))
+ {
+ return $klaar;
+ }
+ // write to the file
+ if (fwrite($fh, $data))
+ {
+ // has been done
+ $klaar = true;
+ }
+ // close file.
+ fclose($fh);
+ return $klaar;
+ }
+
+ /**
+ * The user notice info File Name
+ **/
+ protected static $usernotice = false;
+
+ /**
+ * The backup hash file name
+ **/
+ protected static $backuphash = false;
+
+ public static function getFilePath($type, $name = 'listing', $key = '', $fileType = '.json', $PATH = JPATH_COMPONENT_SITE)
+ {
+ if (!self::checkString(self::${$type.$name}))
+ {
+ // Get local key
+ $localkey = self::getLocalKey();
+ // set the name
+ $fileName = md5($type.$name.$localkey.$key);
+ // set file path
+ self::${$type.$name} = $PATH.'/helpers/'.$fileName.$fileType;
+ }
+ // return the path
+ return self::${$type.$name};
+ }
+
+ public static function getFieldOptions($value, $type, $settings = array())
+ {
+ // Get a db connection.
+ $db = JFactory::getDbo();
+
+ // Create a new query object.
+ $query = $db->getQuery(true);
+ $query->select($db->quoteName(array('properties', 'short_description', 'description')));
+ $query->from($db->quoteName('#__componentbuilder_fieldtype'));
+ $query->where($db->quoteName('published') . ' = 1');
+ $query->where($db->quoteName($type) . ' = '. $value);
+
+ // Reset the query using our newly populated query object.
+ $db->setQuery($query);
+ $db->execute();
+ if ($db->getNumRows())
+ {
+ $result = $db->loadObject();
+ $properties = json_decode($result->properties,true);
+ $pointer = 0;
+ $field = array('values' => " '', 'short_description' => $result->short_description, 'description' => $result->description);
+ foreach ($properties['name'] as $line)
+ {
+ $field['values_description'] .= ''.$properties['name'][$pointer].' '.$properties['description'][$pointer].' ';
+ if(isset($settings[$properties['name'][$pointer]]))
+ {
+ $field['values'] .= "\n\t".$properties['name'][$pointer].'="'.$settings[$properties['name'][$pointer]].'" ';
+ }
+ else
+ {
+ $field['values'] .= "\n\t".$properties['name'][$pointer].'="'.$properties['example'][$pointer].'" ';
+ }
+ $pointer++;
+ }
+ $field['values'] .= "\n/>";
+ $field['values_description'] .= ' ';
+ // return found field options
+ return $field;
+ }
+ return false;
+ }
+
+ /**
+ * get the localkey
+ **/
+ protected static $localkey = false;
+
+ public static function getLocalKey()
+ {
+ if (!self::$localkey)
+ {
+ // get the main key
+ self::$localkey = md5(JComponentHelper::getParams('com_componentbuilder')->get('basic_key', 'localKey34fdWEkl'));
+ }
+ return self::$localkey;
+ }
+
+ /**
+ * indent HTML
+ */
+ public static function indent($html)
+ {
+ // load the class
+ require_once JPATH_ADMINISTRATOR.'/components/com_componentbuilder/helpers/indenter.php';
+ // set new indenter
+ $indenter = new Indenter();
+ // return indented html
+ return $indenter->indent($html);
+ }
+
+ public static function checkFileType($file, $sufix) {
+ // now check if the file ends with the sufix
+ return $sufix === "" || ($sufix == substr(strrchr($file, "."), -strlen($sufix)));
+ }
+
+ public static function imageInfo($path,$request = 'type')
+ {
+ // set image
+ $image = JPATH_SITE.'/'.$path;
+ // check if exists
+ if (file_exists($image) && $result = @getimagesize($image))
+ {
+ // return type request
+ switch ($request)
+ {
+ case 'width':
+ return $result[0];
+ break;
+ case 'height':
+ return $result[1];
+ break;
+ case 'type':
+ $extensions = array(
+ IMAGETYPE_GIF => "gif",
+ IMAGETYPE_JPEG => "jpg",
+ IMAGETYPE_PNG => "png",
+ IMAGETYPE_SWF => "swf",
+ IMAGETYPE_PSD => "psd",
+ IMAGETYPE_BMP => "bmp",
+ IMAGETYPE_TIFF_II => "tiff",
+ IMAGETYPE_TIFF_MM => "tiff",
+ IMAGETYPE_JPC => "jpc",
+ IMAGETYPE_JP2 => "jp2",
+ IMAGETYPE_JPX => "jpx",
+ IMAGETYPE_JB2 => "jb2",
+ IMAGETYPE_SWC => "swc",
+ IMAGETYPE_IFF => "iff",
+ IMAGETYPE_WBMP => "wbmp",
+ IMAGETYPE_XBM => "xbm",
+ IMAGETYPE_ICO => "ico"
+ );
+ return $extensions[$result[2]];
+ break;
+ case 'attr':
+ return $result[3];
+ break;
+ case 'all':
+ default:
+ return $result;
+ break;
+ }
+ }
+ return false;
+ }
+
+ public static function getBetween($content,$start,$end)
+ {
+ $r = explode($start, $content);
+ if (isset($r[1]))
+ {
+ $r = explode($end, $r[1]);
+ return $r[0];
+ }
+ return '';
+ }
+
+ public static function getAllBetween($content,$start,$end)
+ {
+ $buket = array();
+ for ($i = 0; ; $i++)
+ {
+ $found = self::getBetween($content,$start,$end);
+ if (self::checkString($found))
+ {
+ $buket[] = $found;
+ $remove = $start.$found.$end;
+ $content = str_replace($remove,'',$content);
+ }
+ else
+ {
+ break;
+ }
+ // safety catch
+ if ($i == 500)
+ {
+ break;
+ }
+ }
+ return array_unique($buket);
+ }
+
+ public static function typeField($type,$option = 'default')
+ {
+ // list of default fields
+ // https://docs.joomla.org/Form_field
+ $fields = array(
+ 'default' => array(
+ 'accesslevel','cachehandler','calendar','captcha','category','checkbox',
+ 'checkboxes','color','combo','componentlayout','contentlanguage','editor',
+ 'chromestyle','contenttype','databaseconnection','editors','email','file',
+ 'filelist','folderlist','groupedlist','hidden','file','headertag','helpsite',
+ 'imagelist','integer','language','list','media','menu','note','password',
+ 'plugins','range','radio','repeatable','rules','sessionhandler','spacer','sql','tag',
+ 'tel','menuitem','modulelayout','meter','moduleorder','moduleposition','moduletag',
+ 'templatestyle','text','textarea','timezone','url','user','usergroup'
+ ),
+ 'text' => array(
+ 'calendar','color','editor','email','password','tel','text','textarea','url','number','range'
+ ),
+ 'list' => array(
+ 'checkboxes','checkbox','list','radio'
+ ),
+ 'dynamic' => array(
+ 'category','headertag','tag','rules','user','file','filelist','folderlist','imagelist','integer','timezone','media','meter'
+ )
+ );
+
+ if (in_array($type,$fields[$option]))
+ {
+ return true;
+ }
+ return false;
+ }
+
+ public static function getImportScripts($type, $fieldName = false)
+ {
+ // if field name is pased the convert to type
+ if ($fieldName)
+ {
+ $fieldNames = array(
+ 'php_import_display' => 'display',
+ 'php_import_setdata' => 'setdata',
+ 'php_import_save' => 'save',
+ 'html_import_view' => 'view',
+ 'php_import' => 'import',
+ 'php_import_ext' => 'ext'
+ );
+ // first check if the field name is found
+ if (isset($fieldNames[$type]))
+ {
+ $type = $fieldNames[$type];
+ }
+ else
+ {
+ return '';
+ }
+ }
+ $script = array();
+ if ('display' === $type)
+ {
+ // set the display script
+ $script['display'][] = "\tprotected \$headerList;";
+ $script['display'][] = "\tprotected \$hasPackage = false;";
+ $script['display'][] = "\tprotected \$headers;";
+ $script['display'][] = "\tprotected \$hasHeader = 0;";
+ $script['display'][] = "\tprotected \$dataType;";
+ $script['display'][] = "\n\tpublic function display(\$tpl = null)";
+ $script['display'][] = "\t{";
+ $script['display'][] = "\t\tif (\$this->getLayout() !== 'modal')";
+ $script['display'][] = "\t\t{";
+ $script['display'][] = "\t\t\t// Include helper submenu";
+ $script['display'][] = "\t\t\t###-#-#-Component###Helper::addSubmenu('import');";
+ $script['display'][] = "\t\t}";
+ $script['display'][] = "\n\t\t// Check for errors.";
+ $script['display'][] = "\t\tif (count(\$errors = \$this->get('Errors'))){";
+ $script['display'][] = "\t\t\tJError::raiseError(500, implode(' ', \$errors));";
+ $script['display'][] = "\t\t\treturn false;";
+ $script['display'][] = "\t\t}";
+ $script['display'][] = "\n\t\t\$paths = new stdClass;";
+ $script['display'][] = "\t\t\$paths->first = '';";
+ $script['display'][] = "\t\t\$state = \$this->get('state');";
+ $script['display'][] = "\n\t\t\$this->paths = &\$paths;";
+ $script['display'][] = "\t\t\$this->state = &\$state;";
+ $script['display'][] = "\t\t// get global action permissions";
+ $script['display'][] = "\t\t\$this->canDo = ###-#-#-Component###Helper::getActions('import');";
+ $script['display'][] = "\n\t\t// We don't need toolbar in the modal window.";
+ $script['display'][] = "\t\tif (\$this->getLayout() !== 'modal')";
+ $script['display'][] = "\t\t{";
+ $script['display'][] = "\t\t\t\$this->addToolbar();";
+ $script['display'][] = "\t\t\t\$this->sidebar = JHtmlSidebar::render();";
+ $script['display'][] = "\t\t}";
+ $script['display'][] = "\n\t\t// get the session object";
+ $script['display'][] = "\t\t\$session = JFactory::getSession();";
+ $script['display'][] = "\t\t// check if it has package";
+ $script['display'][] = "\t\t\$this->hasPackage \t= \$session->get('hasPackage', false);";
+ $script['display'][] = "\t\t\$this->dataType \t= \$session->get('dataType', false);";
+ $script['display'][] = "\t\tif(\$this->hasPackage && \$this->dataType)";
+ $script['display'][] = "\t\t{";
+ $script['display'][] = "\t\t\t\$this->headerList \t= json_decode(\$session->get(\$this->dataType.'_VDM_IMPORTHEADERS', false),true);";
+ $script['display'][] = "\t\t\t\$this->headers \t\t= ###-#-#-Component###Helper::getFileHeaders(\$this->dataType);";
+ $script['display'][] = "\t\t\t// clear the data type";
+ $script['display'][] = "\t\t\t\$session->clear('dataType');";
+ $script['display'][] = "\t\t}";
+ $script['display'][] = "\n\t\t// Display the template";
+ $script['display'][] = "\t\tparent::display(\$tpl);";
+ $script['display'][] = "\t}";
+ }
+ elseif ('setdata' === $type)
+ {
+ // set the setdata script
+ $script['setdata'] = array();
+ $script['setdata'][] = "\t/**";
+ $script['setdata'][] = "\t* Set the data from the spreadsheet to the database";
+ $script['setdata'][] = "\t*";
+ $script['setdata'][] = "\t* @param string \$package Paths to the uploaded package file";
+ $script['setdata'][] = "\t*";
+ $script['setdata'][] = "\t* @return boolean false on failure";
+ $script['setdata'][] = "\t*";
+ $script['setdata'][] = "\t**/";
+ $script['setdata'][] = "\tprotected function setData(\$package,\$table,\$target_headers)";
+ $script['setdata'][] = "\t{";
+ $script['setdata'][] = "\t\tif (###-#-#-Component###Helper::checkArray(\$target_headers))";
+ $script['setdata'][] = "\t\t{";
+ $script['setdata'][] = "\t\t\t// make sure the file is loaded\t\t";
+ $script['setdata'][] = "\t\t\tJLoader::import('PHPExcel', JPATH_COMPONENT_ADMINISTRATOR . '/helpers');";
+ $script['setdata'][] = "\t\t\t\$jinput = JFactory::getApplication()->input;";
+ $script['setdata'][] = "\t\t\tforeach(\$target_headers as \$header)";
+ $script['setdata'][] = "\t\t\t{";
+ $script['setdata'][] = "\t\t\t\t\$data['target_headers'][\$header] = \$jinput->getString(\$header, null);";
+ $script['setdata'][] = "\t\t\t}";
+ $script['setdata'][] = "\t\t\t// set the data";
+ $script['setdata'][] = "\t\t\tif(isset(\$package['dir']))";
+ $script['setdata'][] = "\t\t\t{";
+ $script['setdata'][] = "\t\t\t\t\$inputFileType = PHPExcel_IOFactory::identify(\$package['dir']);";
+ $script['setdata'][] = "\t\t\t\t\$excelReader = PHPExcel_IOFactory::createReader(\$inputFileType);";
+ $script['setdata'][] = "\t\t\t\t\$excelReader->setReadDataOnly(true);";
+ $script['setdata'][] = "\t\t\t\t\$excelObj = \$excelReader->load(\$package['dir']);";
+ $script['setdata'][] = "\t\t\t\t\$data['array'] = \$excelObj->getActiveSheet()->toArray(null, true,true,true);";
+ $script['setdata'][] = "\t\t\t\t\$excelObj->disconnectWorksheets();";
+ $script['setdata'][] = "\t\t\t\tunset(\$excelObj);";
+ $script['setdata'][] = "\t\t\t\treturn \$this->save(\$data,\$table);";
+ $script['setdata'][] = "\t\t\t}";
+ $script['setdata'][] = "\t\t}";
+ $script['setdata'][] = "\t\treturn false;";
+ $script['setdata'][] = "\t}";
+ }
+ elseif ('save' === $type)
+ {
+ $script['save'] = array();
+ $script['save'][] = "\t/**";
+ $script['save'][] = "\t* Save the data from the file to the database";
+ $script['save'][] = "\t*";
+ $script['save'][] = "\t* @param string \$package Paths to the uploaded package file";
+ $script['save'][] = "\t*";
+ $script['save'][] = "\t* @return boolean false on failure";
+ $script['save'][] = "\t*";
+ $script['save'][] = "\t**/";
+ $script['save'][] = "\tprotected function save(\$data,\$table)";
+ $script['save'][] = "\t{";
+ $script['save'][] = "\t\t// import the data if there is any";
+ $script['save'][] = "\t\tif(###-#-#-Component###Helper::checkArray(\$data['array']))";
+ $script['save'][] = "\t\t{";
+ $script['save'][] = "\t\t\t// get user object";
+ $script['save'][] = "\t\t\t\$user \t\t= JFactory::getUser();";
+ $script['save'][] = "\t\t\t// remove header if it has headers";
+ $script['save'][] = "\t\t\t\$id_key \t= \$data['target_headers']['id'];";
+ $script['save'][] = "\t\t\t\$published_key \t= \$data['target_headers']['published'];";
+ $script['save'][] = "\t\t\t\$ordering_key \t= \$data['target_headers']['ordering'];";
+ $script['save'][] = "\t\t\t// get the first array set";
+ $script['save'][] = "\t\t\t\$firstSet = reset(\$data['array']);";
+ $script['save'][] = "";
+ $script['save'][] = "\t\t\t// check if first array is a header array and remove if true";
+ $script['save'][] = "\t\t\tif(\$firstSet[\$id_key] == 'id' || \$firstSet[\$published_key] == 'published' || \$firstSet[\$ordering_key] == 'ordering')";
+ $script['save'][] = "\t\t\t{";
+ $script['save'][] = "\t\t\t\tarray_shift(\$data['array']);";
+ $script['save'][] = "\t\t\t}";
+ $script['save'][] = "\t\t\t";
+ $script['save'][] = "\t\t\t// make sure there is still values in array and that it was not only headers";
+ $script['save'][] = "\t\t\tif(###-#-#-Component###Helper::checkArray(\$data['array']) && \$user->authorise(\$table.'.import', 'com_###-#-#-component###') && \$user->authorise('core.import', 'com_###-#-#-component###'))";
+ $script['save'][] = "\t\t\t{";
+ $script['save'][] = "\t\t\t\t// set target.";
+ $script['save'][] = "\t\t\t\t\$target\t= array_flip(\$data['target_headers']);";
+ $script['save'][] = "\t\t\t\t// Get a db connection.";
+ $script['save'][] = "\t\t\t\t\$db = JFactory::getDbo();";
+ $script['save'][] = "\t\t\t\t// set some defaults";
+ $script['save'][] = "\t\t\t\t\$todayDate\t\t= JFactory::getDate()->toSql();";
+ $script['save'][] = "\t\t\t\t// get global action permissions";
+ $script['save'][] = "\t\t\t\t\$canDo\t\t\t= ###-#-#-Component###Helper::getActions(\$table);";
+ $script['save'][] = "\t\t\t\t\$canEdit\t\t= \$canDo->get('core.edit');";
+ $script['save'][] = "\t\t\t\t\$canState\t\t= \$canDo->get('core.edit.state');";
+ $script['save'][] = "\t\t\t\t\$canCreate\t\t= \$canDo->get('core.create');";
+ $script['save'][] = "\t\t\t\t\$hasAlias\t\t= \$this->getAliasesUsed(\$table);";
+ $script['save'][] = "\t\t\t\t// prosses the data";
+ $script['save'][] = "\t\t\t\tforeach(\$data['array'] as \$row)";
+ $script['save'][] = "\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\$found = false;";
+ $script['save'][] = "\t\t\t\t\tif (isset(\$row[\$id_key]) && is_numeric(\$row[\$id_key]) && \$row[\$id_key] > 0)";
+ $script['save'][] = "\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t// raw items import & update!";
+ $script['save'][] = "\t\t\t\t\t\t\$query = \$db->getQuery(true);";
+ $script['save'][] = "\t\t\t\t\t\t\$query";
+ $script['save'][] = "\t\t\t\t\t\t\t->select('version')";
+ $script['save'][] = "\t\t\t\t\t\t\t->from(\$db->quoteName('#__###-#-#-component###_'.\$table))";
+ $script['save'][] = "\t\t\t\t\t\t\t->where(\$db->quoteName('id') . ' = '. \$db->quote(\$row[\$id_key]));";
+ $script['save'][] = "\t\t\t\t\t\t// Reset the query using our newly populated query object.";
+ $script['save'][] = "\t\t\t\t\t\t\$db->setQuery(\$query);";
+ $script['save'][] = "\t\t\t\t\t\t\$db->execute();";
+ $script['save'][] = "\t\t\t\t\t\t\$found = \$db->getNumRows();";
+ $script['save'][] = "\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t";
+ $script['save'][] = "\t\t\t\t\tif(\$found && \$canEdit)";
+ $script['save'][] = "\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t// update item";
+ $script['save'][] = "\t\t\t\t\t\t\$id \t\t= \$row[\$id_key];";
+ $script['save'][] = "\t\t\t\t\t\t\$version\t= \$db->loadResult();";
+ $script['save'][] = "\t\t\t\t\t\t// reset all buckets";
+ $script['save'][] = "\t\t\t\t\t\t\$query \t\t= \$db->getQuery(true);";
+ $script['save'][] = "\t\t\t\t\t\t\$fields \t= array();";
+ $script['save'][] = "\t\t\t\t\t\t// Fields to update.";
+ $script['save'][] = "\t\t\t\t\t\tforeach(\$row as \$key => \$cell)";
+ $script['save'][] = "\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t// ignore column";
+ $script['save'][] = "\t\t\t\t\t\t\tif ('IGNORE' == \$target[\$key])";
+ $script['save'][] = "\t\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t\tcontinue;";
+ $script['save'][] = "\t\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t\t// update modified";
+ $script['save'][] = "\t\t\t\t\t\t\tif ('modified_by' == \$target[\$key])";
+ $script['save'][] = "\t\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t\tcontinue;";
+ $script['save'][] = "\t\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t\t// update modified";
+ $script['save'][] = "\t\t\t\t\t\t\tif ('modified' == \$target[\$key])";
+ $script['save'][] = "\t\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t\tcontinue;";
+ $script['save'][] = "\t\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t\t// update version";
+ $script['save'][] = "\t\t\t\t\t\t\tif ('version' == \$target[\$key])";
+ $script['save'][] = "\t\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t\t\$cell = (int) \$version + 1;";
+ $script['save'][] = "\t\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t\t// verify publish authority";
+ $script['save'][] = "\t\t\t\t\t\t\tif ('published' == \$target[\$key] && !\$canState)";
+ $script['save'][] = "\t\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t\tcontinue;";
+ $script['save'][] = "\t\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t\t// set to update array";
+ $script['save'][] = "\t\t\t\t\t\t\tif(in_array(\$key, \$data['target_headers']) && is_numeric(\$cell))";
+ $script['save'][] = "\t\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t\t\$fields[] = \$db->quoteName(\$target[\$key]) . ' = ' . \$cell;";
+ $script['save'][] = "\t\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t\telseif(in_array(\$key, \$data['target_headers']) && is_string(\$cell))";
+ $script['save'][] = "\t\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t\t\$fields[] = \$db->quoteName(\$target[\$key]) . ' = ' . \$db->quote(\$cell);";
+ $script['save'][] = "\t\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t\telseif(in_array(\$key, \$data['target_headers']) && is_null(\$cell))";
+ $script['save'][] = "\t\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t\t// if import data is null then set empty";
+ $script['save'][] = "\t\t\t\t\t\t\t\t\$fields[] = \$db->quoteName(\$target[\$key]) . \" = ''\";";
+ $script['save'][] = "\t\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t// load the defaults";
+ $script['save'][] = "\t\t\t\t\t\t\$fields[]\t= \$db->quoteName('modified_by') . ' = ' . \$db->quote(\$user->id);";
+ $script['save'][] = "\t\t\t\t\t\t\$fields[]\t= \$db->quoteName('modified') . ' = ' . \$db->quote(\$todayDate);";
+ $script['save'][] = "\t\t\t\t\t\t// Conditions for which records should be updated.";
+ $script['save'][] = "\t\t\t\t\t\t\$conditions = array(";
+ $script['save'][] = "\t\t\t\t\t\t\t\$db->quoteName('id') . ' = ' . \$id";
+ $script['save'][] = "\t\t\t\t\t\t);";
+ $script['save'][] = "\t\t\t\t\t\t";
+ $script['save'][] = "\t\t\t\t\t\t\$query->update(\$db->quoteName('#__###-#-#-component###_'.\$table))->set(\$fields)->where(\$conditions);";
+ $script['save'][] = "\t\t\t\t\t\t\$db->setQuery(\$query);";
+ $script['save'][] = "\t\t\t\t\t\t\$db->execute();";
+ $script['save'][] = "\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\telseif (\$canCreate)";
+ $script['save'][] = "\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t// insert item";
+ $script['save'][] = "\t\t\t\t\t\t\$query = \$db->getQuery(true);";
+ $script['save'][] = "\t\t\t\t\t\t// reset all buckets";
+ $script['save'][] = "\t\t\t\t\t\t\$columns \t= array();";
+ $script['save'][] = "\t\t\t\t\t\t\$values \t= array();";
+ $script['save'][] = "\t\t\t\t\t\t\$version\t= false;";
+ $script['save'][] = "\t\t\t\t\t\t// Insert columns. Insert values.";
+ $script['save'][] = "\t\t\t\t\t\tforeach(\$row as \$key => \$cell)";
+ $script['save'][] = "\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t// ignore column";
+ $script['save'][] = "\t\t\t\t\t\t\tif ('IGNORE' == \$target[\$key])";
+ $script['save'][] = "\t\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t\tcontinue;";
+ $script['save'][] = "\t\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t\t// remove id";
+ $script['save'][] = "\t\t\t\t\t\t\tif ('id' == \$target[\$key])";
+ $script['save'][] = "\t\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t\tcontinue;";
+ $script['save'][] = "\t\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t\t// update created";
+ $script['save'][] = "\t\t\t\t\t\t\tif ('created_by' == \$target[\$key])";
+ $script['save'][] = "\t\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t\tcontinue;";
+ $script['save'][] = "\t\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t\t// update created";
+ $script['save'][] = "\t\t\t\t\t\t\tif ('created' == \$target[\$key])";
+ $script['save'][] = "\t\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t\tcontinue;";
+ $script['save'][] = "\t\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t\t// Make sure the alias is incremented";
+ $script['save'][] = "\t\t\t\t\t\t\tif ('alias' == \$target[\$key])";
+ $script['save'][] = "\t\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t\t\$cell = \$this->getAlias(\$cell,\$table);";
+ $script['save'][] = "\t\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t\t// update version";
+ $script['save'][] = "\t\t\t\t\t\t\tif ('version' == \$target[\$key])";
+ $script['save'][] = "\t\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t\t\$cell = 1;";
+ $script['save'][] = "\t\t\t\t\t\t\t\t\$version = true;";
+ $script['save'][] = "\t\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t\t// set to insert array";
+ $script['save'][] = "\t\t\t\t\t\t\tif(in_array(\$key, \$data['target_headers']) && is_numeric(\$cell))";
+ $script['save'][] = "\t\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t\t\$columns[] \t= \$target[\$key];";
+ $script['save'][] = "\t\t\t\t\t\t\t\t\$values[] \t= \$cell;";
+ $script['save'][] = "\t\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t\telseif(in_array(\$key, \$data['target_headers']) && is_string(\$cell))";
+ $script['save'][] = "\t\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t\t\$columns[] \t= \$target[\$key];";
+ $script['save'][] = "\t\t\t\t\t\t\t\t\$values[] \t= \$db->quote(\$cell);";
+ $script['save'][] = "\t\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t\telseif(in_array(\$key, \$data['target_headers']) && is_null(\$cell))";
+ $script['save'][] = "\t\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t\t// if import data is null then set empty";
+ $script['save'][] = "\t\t\t\t\t\t\t\t\$columns[] \t= \$target[\$key];";
+ $script['save'][] = "\t\t\t\t\t\t\t\t\$values[] \t= \"''\";";
+ $script['save'][] = "\t\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t// load the defaults";
+ $script['save'][] = "\t\t\t\t\t\t\$columns[] \t= 'created_by';";
+ $script['save'][] = "\t\t\t\t\t\t\$values[] \t= \$db->quote(\$user->id);";
+ $script['save'][] = "\t\t\t\t\t\t\$columns[] \t= 'created';";
+ $script['save'][] = "\t\t\t\t\t\t\$values[] \t= \$db->quote(\$todayDate);";
+ $script['save'][] = "\t\t\t\t\t\tif (!\$version)";
+ $script['save'][] = "\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t\$columns[] \t= 'version';";
+ $script['save'][] = "\t\t\t\t\t\t\t\$values[] \t= 1;";
+ $script['save'][] = "\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t\t// Prepare the insert query.";
+ $script['save'][] = "\t\t\t\t\t\t\$query";
+ $script['save'][] = "\t\t\t\t\t\t\t->insert(\$db->quoteName('#__###-#-#-component###_'.\$table))";
+ $script['save'][] = "\t\t\t\t\t\t\t->columns(\$db->quoteName(\$columns))";
+ $script['save'][] = "\t\t\t\t\t\t\t->values(implode(',', \$values));";
+ $script['save'][] = "\t\t\t\t\t\t// Set the query using our newly populated query object and execute it.";
+ $script['save'][] = "\t\t\t\t\t\t\$db->setQuery(\$query);";
+ $script['save'][] = "\t\t\t\t\t\t\$done = \$db->execute();";
+ $script['save'][] = "\t\t\t\t\t\tif (\$done)";
+ $script['save'][] = "\t\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\t\t\$aId = \$db->insertid();";
+ $script['save'][] = "\t\t\t\t\t\t\t// make sure the access of asset is set";
+ $script['save'][] = "\t\t\t\t\t\t\t###-#-#-Component###Helper::setAsset(\$aId,\$table);";
+ $script['save'][] = "\t\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t\telse";
+ $script['save'][] = "\t\t\t\t\t{";
+ $script['save'][] = "\t\t\t\t\t\treturn false;";
+ $script['save'][] = "\t\t\t\t\t}";
+ $script['save'][] = "\t\t\t\t}";
+ $script['save'][] = "\t\t\t\treturn true;";
+ $script['save'][] = "\t\t\t}";
+ $script['save'][] = "\t\t}";
+ $script['save'][] = "\t\treturn false;";
+ $script['save'][] = "\t}";
+ }
+ elseif ('view' === $type)
+ {
+ $script['view'] = array();
+ $script['view'][] = "";
+ $script['view'][] = "";
+ $script['view'][] = "\n";
+ $script['view'][] = "