diff --git a/README.md b/README.md index 256f8941b..c6024ed39 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will safe you lots of time and money. A real must have! -You can install it quite easily and with no limitations. On [github](https://github.com/vdm-io/Joomla-Component-Builder/releases) is the latest release (2.6.5) with **ALL** its features and **ALL** concepts totally open-source and free! +You can install it quite easily and with no limitations. On [github](https://github.com/vdm-io/Joomla-Component-Builder/releases) is the latest release (2.6.6) with **ALL** its features and **ALL** concepts totally open-source and free! > Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45) @@ -111,13 +111,13 @@ Component Builder is mapped as a component in itself on my local development env + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Component Builder](http://vdm.bz/component-builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 21st November, 2017 -+ *Version*: 2.6.5 ++ *Last Build*: 26th November, 2017 ++ *Version*: 2.6.6 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **168387** -+ *File count*: **1073** -+ *Folder count*: **176** ++ *Line count*: **178893** ++ *File count*: **1139** ++ *Folder count*: **184** > This **component** was build with a Joomla [Automated Component Builder](http://vdm.bz/component-builder). > Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io) diff --git a/admin/README.txt b/admin/README.txt index 256f8941b..c6024ed39 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -10,7 +10,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will safe you lots of time and money. A real must have! -You can install it quite easily and with no limitations. On [github](https://github.com/vdm-io/Joomla-Component-Builder/releases) is the latest release (2.6.5) with **ALL** its features and **ALL** concepts totally open-source and free! +You can install it quite easily and with no limitations. On [github](https://github.com/vdm-io/Joomla-Component-Builder/releases) is the latest release (2.6.6) with **ALL** its features and **ALL** concepts totally open-source and free! > Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45) @@ -111,13 +111,13 @@ Component Builder is mapped as a component in itself on my local development env + *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io) + *Name*: [Component Builder](http://vdm.bz/component-builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 21st November, 2017 -+ *Version*: 2.6.5 ++ *Last Build*: 26th November, 2017 ++ *Version*: 2.6.6 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **168387** -+ *File count*: **1073** -+ *Folder count*: **176** ++ *Line count*: **178893** ++ *File count*: **1139** ++ *Folder count*: **184** > This **component** was build with a Joomla [Automated Component Builder](http://vdm.bz/component-builder). > Developed by [Llewellyn van der Merwe](mailto:joomla@vdm.io) diff --git a/admin/access.xml b/admin/access.xml index 7f2d7b47f..09ade1bd2 100644 --- a/admin/access.xml +++ b/admin/access.xml @@ -297,12 +297,34 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -418,6 +440,15 @@ +
+ + + + + + + +
@@ -619,14 +650,27 @@
-
- - - - - - - +
+ + + + + + + + + +
+
+ + + + + + + + +
diff --git a/admin/assets/css/custom_admin_view.css b/admin/assets/css/custom_admin_view.css index 97693c0d7..a6129ddb4 100644 --- a/admin/assets/css/custom_admin_view.css +++ b/admin/assets/css/custom_admin_view.css @@ -24,4 +24,22 @@ /* CSS Document */ - + +#jform_snippet_chzn { +width: 100% !important; +} +.jform_snippet_input_width { +width: 90% !important; +} +#jform_main_get_chzn { +width: 100% !important; +} +.jform_main_get_input_width { +width: 90% !important; +} +#jform_dynamic_get_chzn { +width: 100% !important; +} +.jform_dynamic_get_input_width { +width: 90% !important; +} diff --git a/admin/assets/css/layout.css b/admin/assets/css/layout.css index cdce5a733..62e6a7ebe 100644 --- a/admin/assets/css/layout.css +++ b/admin/assets/css/layout.css @@ -24,4 +24,16 @@ /* CSS Document */ - + +#jform_snippet_chzn { +width: 100% !important; +} +.jform_snippet_input_width { +width: 90% !important; +} +#jform_dynamic_get_chzn { +width: 100% !important; +} +.jform_dynamic_get_input_width { +width: 90% !important; +} diff --git a/admin/assets/css/libraries_config.css b/admin/assets/css/libraries_config.css new file mode 100644 index 000000000..7252bea7e --- /dev/null +++ b/admin/assets/css/libraries_config.css @@ -0,0 +1,27 @@ +/*--------------------------------------------------------------------------------------------------------| www.vdm.io |------/ + __ __ _ _____ _ _ __ __ _ _ _ + \ \ / / | | | __ \ | | | | | \/ | | | | | | | + \ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| | + \ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` | + \ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| | + \/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_| + | | + |_| +/-------------------------------------------------------------------------------------------------------------------------------/ + + @version 2.6.x + @created 30th April, 2015 + @package Component Builder + @subpackage libraries_config.css + @author Llewellyn van der Merwe + @github Joomla Component Builder + @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/admin/assets/css/libraries_files_folders_urls.css b/admin/assets/css/libraries_files_folders_urls.css new file mode 100644 index 000000000..e352c49b1 --- /dev/null +++ b/admin/assets/css/libraries_files_folders_urls.css @@ -0,0 +1,27 @@ +/*--------------------------------------------------------------------------------------------------------| www.vdm.io |------/ + __ __ _ _____ _ _ __ __ _ _ _ + \ \ / / | | | __ \ | | | | | \/ | | | | | | | + \ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| | + \ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` | + \ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| | + \/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_| + | | + |_| +/-------------------------------------------------------------------------------------------------------------------------------/ + + @version 2.6.x + @created 30th April, 2015 + @package Component Builder + @subpackage libraries_files_folders_urls.css + @author Llewellyn van der Merwe + @github Joomla Component Builder + @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/admin/assets/css/library_config.css b/admin/assets/css/library_config.css new file mode 100644 index 000000000..80a4b875b --- /dev/null +++ b/admin/assets/css/library_config.css @@ -0,0 +1,27 @@ +/*--------------------------------------------------------------------------------------------------------| www.vdm.io |------/ + __ __ _ _____ _ _ __ __ _ _ _ + \ \ / / | | | __ \ | | | | | \/ | | | | | | | + \ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| | + \ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` | + \ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| | + \/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_| + | | + |_| +/-------------------------------------------------------------------------------------------------------------------------------/ + + @version 2.6.x + @created 30th April, 2015 + @package Component Builder + @subpackage library_config.css + @author Llewellyn van der Merwe + @github Joomla Component Builder + @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/admin/assets/css/library_files_folders_urls.css b/admin/assets/css/library_files_folders_urls.css new file mode 100644 index 000000000..21e162fa2 --- /dev/null +++ b/admin/assets/css/library_files_folders_urls.css @@ -0,0 +1,30 @@ +/*--------------------------------------------------------------------------------------------------------| www.vdm.io |------/ + __ __ _ _____ _ _ __ __ _ _ _ + \ \ / / | | | __ \ | | | | | \/ | | | | | | | + \ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| | + \ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` | + \ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| | + \/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_| + | | + |_| +/-------------------------------------------------------------------------------------------------------------------------------/ + + @version 2.6.x + @created 30th April, 2015 + @package Component Builder + @subpackage library_files_folders_urls.css + @author Llewellyn van der Merwe + @github Joomla Component Builder + @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 */ + + +.control-group, .controls, .controls input[type="url"], .controls input[type="text"], .controls input[type="number"], .controls input[type="email"], .controls select, .controls textarea { + max-width: 100%; +} diff --git a/admin/assets/css/site_view.css b/admin/assets/css/site_view.css index ace4683bf..715277974 100644 --- a/admin/assets/css/site_view.css +++ b/admin/assets/css/site_view.css @@ -24,4 +24,22 @@ /* CSS Document */ - + +#jform_snippet_chzn { +width: 100% !important; +} +.jform_snippet_input_width { +width: 90% !important; +} +#jform_main_get_chzn { +width: 100% !important; +} +.jform_main_get_input_width { +width: 90% !important; +} +#jform_dynamic_get_chzn { +width: 100% !important; +} +.jform_dynamic_get_input_width { +width: 90% !important; +} diff --git a/admin/assets/css/template.css b/admin/assets/css/template.css index 553aabec9..f0d90485b 100644 --- a/admin/assets/css/template.css +++ b/admin/assets/css/template.css @@ -24,4 +24,16 @@ /* CSS Document */ - + +#jform_snippet_chzn { +width: 100% !important; +} +.jform_snippet_input_width { +width: 90% !important; +} +#jform_dynamic_get_chzn { +width: 100% !important; +} +.jform_dynamic_get_input_width { +width: 90% !important; +} diff --git a/admin/assets/images/icons/libraries.png b/admin/assets/images/icons/libraries.png new file mode 100644 index 000000000..3ad91662f Binary files /dev/null and b/admin/assets/images/icons/libraries.png differ diff --git a/admin/compiler/joomla_3/JModelAdmin_site.php b/admin/compiler/joomla_3/JModelAdmin_site.php index 47374e011..4ac9a3908 100644 --- a/admin/compiler/joomla_3/JModelAdmin_site.php +++ b/admin/compiler/joomla_3/JModelAdmin_site.php @@ -82,7 +82,7 @@ class ###Component###Model###View### extends JModelAdmin {###LICENSE_LOCKED_CHECK### if ($item = parent::getItem($pk)) { - if (!empty($item->params)) + if (!empty($item->params) && !is_array($item->params)) { // Convert the params field to an array. $registry = new Registry; diff --git a/admin/controller.php b/admin/controller.php index 869c27073..9a52d777f 100644 --- a/admin/controller.php +++ b/admin/controller.php @@ -96,6 +96,7 @@ class ComponentbuilderController extends JControllerLegacy 'layout' => 'layouts', 'dynamic_get' => 'dynamic_gets', 'custom_code' => 'custom_codes', + 'library' => 'libraries', 'snippet' => 'snippets', 'field' => 'fields', 'fieldtype' => 'fieldtypes', @@ -115,7 +116,8 @@ class ComponentbuilderController extends JControllerLegacy 'component_dashboard' => 'components_dashboard', 'component_files_folders' => 'components_files_folders', 'snippet_type' => 'snippet_types', - 'library' => 'libraries' + 'library_config' => 'libraries_config', + 'library_files_folders_urls' => 'libraries_files_folders_urls' ); // check if this is a list view if (in_array($view,$views)) diff --git a/admin/controllers/ajax.json.php b/admin/controllers/ajax.json.php index fccde7093..f845eb1fc 100644 --- a/admin/controllers/ajax.json.php +++ b/admin/controllers/ajax.json.php @@ -52,6 +52,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy $this->registerTask('getButton', 'ajax'); $this->registerTask('getButtonID', 'ajax'); $this->registerTask('getAjaxDisplay', 'ajax'); + $this->registerTask('getSnippets', 'ajax'); $this->registerTask('templateDetails', 'ajax'); $this->registerTask('getLayoutDetails', 'ajax'); $this->registerTask('dbTableColumns', 'ajax'); @@ -457,6 +458,44 @@ class ComponentbuilderControllerAjax extends JControllerLegacy } } break; + case 'getSnippets': + try + { + $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); + $librariesValue = $jinput->get('libraries', NULL, 'STRING'); + if($librariesValue && $user->id != 0) + { + $result = $this->getModel('ajax')->getSnippets($librariesValue); + } + else + { + $result = false; + } + if($callback = $jinput->get('callback', null, 'CMD')) + { + echo $callback . "(".json_encode($result).");"; + } + elseif($returnRaw) + { + echo json_encode($result); + } + else + { + echo "(".json_encode($result).");"; + } + } + catch(Exception $e) + { + if($callback = $jinput->get('callback', null, 'CMD')) + { + echo $callback."(".json_encode($e).");"; + } + else + { + echo "(".json_encode($e).");"; + } + } + break; case 'templateDetails': try { diff --git a/admin/controllers/libraries_config.php b/admin/controllers/libraries_config.php new file mode 100644 index 000000000..31fc0d49b --- /dev/null +++ b/admin/controllers/libraries_config.php @@ -0,0 +1,48 @@ + + @github Joomla Component Builder + @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 controlleradmin library +jimport('joomla.application.component.controlleradmin'); + +/** + * Libraries_config Controller + */ +class ComponentbuilderControllerLibraries_config extends JControllerAdmin +{ + protected $text_prefix = 'COM_COMPONENTBUILDER_LIBRARIES_CONFIG'; + /** + * Proxy for getModel. + * @since 2.5 + */ + public function getModel($name = 'Library_config', $prefix = 'ComponentbuilderModel', $config = array()) + { + $model = parent::getModel($name, $prefix, array('ignore_request' => true)); + + return $model; + } +} diff --git a/admin/controllers/libraries_files_folders_urls.php b/admin/controllers/libraries_files_folders_urls.php new file mode 100644 index 000000000..61fc5d345 --- /dev/null +++ b/admin/controllers/libraries_files_folders_urls.php @@ -0,0 +1,48 @@ + + @github Joomla Component Builder + @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 controlleradmin library +jimport('joomla.application.component.controlleradmin'); + +/** + * Libraries_files_folders_urls Controller + */ +class ComponentbuilderControllerLibraries_files_folders_urls extends JControllerAdmin +{ + protected $text_prefix = 'COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS'; + /** + * Proxy for getModel. + * @since 2.5 + */ + public function getModel($name = 'Library_files_folders_urls', $prefix = 'ComponentbuilderModel', $config = array()) + { + $model = parent::getModel($name, $prefix, array('ignore_request' => true)); + + return $model; + } +} diff --git a/admin/controllers/library.php b/admin/controllers/library.php index 025576ac8..e45db5475 100644 --- a/admin/controllers/library.php +++ b/admin/controllers/library.php @@ -320,6 +320,31 @@ class ComponentbuilderControllerLibrary extends JControllerForm */ protected function postSaveHook(JModelLegacy $model, $validData = array()) { + // get the state object (Joomla\CMS\Object\CMSObject) + $state = $model->get('state'); + // if we save2copy we need to also copy linked tables found! + if ($state->task === 'save2copy' && $state->{'library.new'}) + { + // get new ID + $newID = $state->{'library.id'}; + // get old ID + $oldID = $this->input->get('id', 0, 'INT'); + // linked tables to update + $_tablesArray = array( + 'library_config', + 'library_files_folders_urls' + ); + foreach($_tablesArray as $_updateTable) + { + // get the linked ID + if ($_value = ComponentbuilderHelper::getVar($_updateTable, $oldID, 'library', 'id')) + { + // copy fields to new linked table + ComponentbuilderHelper::copyItem(/*id->*/ $_value, /*table->*/ $_updateTable, /*change->*/ array('library' => $newID)); + } + } + } + return; } diff --git a/admin/controllers/library_config.php b/admin/controllers/library_config.php new file mode 100644 index 000000000..2edb5eec0 --- /dev/null +++ b/admin/controllers/library_config.php @@ -0,0 +1,326 @@ + + @github Joomla Component Builder + @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.controllerform'); + +/** + * Library_config Controller + */ +class ComponentbuilderControllerLibrary_config 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 = 'Libraries_config'; // safeguard for setting the return view listing to the main view. + parent::__construct($config); + } + + /** + * 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()) + { + // Access check. + $access = JFactory::getUser()->authorise('library_config.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + // In the absense of better information, revert to the component permissions. + return JFactory::getUser()->authorise('library_config.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // get user object. + $user = JFactory::getUser(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('library_config.access', 'com_componentbuilder.library_config.' . (int) $recordId) && $user->authorise('library_config.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('library_config.edit', 'com_componentbuilder.library_config.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('library_config.edit.own', 'com_componentbuilder.library_config.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('library_config.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('library_config.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 12.2 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + $tmpl = $this->input->get('tmpl'); + $layout = $this->input->get('layout', 'edit', 'string'); + + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // Setup redirect info. + + $append = ''; + + if ($refid) + { + $append .= '&ref='.(string)$ref.'&refid='.(int)$refid; + } + elseif ($ref) + { + $append .= '&ref='.(string)$ref; + } + + if ($tmpl) + { + $append .= '&tmpl=' . $tmpl; + } + + if ($layout) + { + $append .= '&layout=' . $layout; + } + + if ($recordId) + { + $append .= '&' . $urlVar . '=' . $recordId; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Library_config', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=libraries_config' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referal details + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + $cancel = parent::cancel($key); + + if ($cancel) + { + if ($this->refid) + { + $redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + } + else + { + // Redirect to the items screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . '&view=' . $this->view_list, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referal details + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + if ($this->ref || $this->refid) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + if ($this->refid && $saved) + { + $redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref && $saved) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/admin/controllers/library_files_folders_urls.php b/admin/controllers/library_files_folders_urls.php new file mode 100644 index 000000000..b6061cfce --- /dev/null +++ b/admin/controllers/library_files_folders_urls.php @@ -0,0 +1,326 @@ + + @github Joomla Component Builder + @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.controllerform'); + +/** + * Library_files_folders_urls Controller + */ +class ComponentbuilderControllerLibrary_files_folders_urls 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 = 'Libraries_files_folders_urls'; // safeguard for setting the return view listing to the main view. + parent::__construct($config); + } + + /** + * 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()) + { + // Access check. + $access = JFactory::getUser()->authorise('library_files_folders_urls.access', 'com_componentbuilder'); + if (!$access) + { + return false; + } + // In the absense of better information, revert to the component permissions. + return JFactory::getUser()->authorise('library_files_folders_urls.create', $this->option); + } + + /** + * Method override to check if you can edit an existing record. + * + * @param array $data An array of input data. + * @param string $key The name of the key for the primary key. + * + * @return boolean + * + * @since 1.6 + */ + protected function allowEdit($data = array(), $key = 'id') + { + // get user object. + $user = JFactory::getUser(); + // get record id. + $recordId = (int) isset($data[$key]) ? $data[$key] : 0; + + + // Access check. + $access = ($user->authorise('library_files_folders_urls.access', 'com_componentbuilder.library_files_folders_urls.' . (int) $recordId) && $user->authorise('library_files_folders_urls.access', 'com_componentbuilder')); + if (!$access) + { + return false; + } + + if ($recordId) + { + // The record has been set. Check the record permissions. + $permission = $user->authorise('library_files_folders_urls.edit', 'com_componentbuilder.library_files_folders_urls.' . (int) $recordId); + if (!$permission) + { + if ($user->authorise('library_files_folders_urls.edit.own', 'com_componentbuilder.library_files_folders_urls.' . $recordId)) + { + // Now test the owner is the user. + $ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0; + if (empty($ownerId)) + { + // Need to do a lookup from the model. + $record = $this->getModel()->getItem($recordId); + + if (empty($record)) + { + return false; + } + $ownerId = $record->created_by; + } + + // If the owner matches 'me' then allow. + if ($ownerId == $user->id) + { + if ($user->authorise('library_files_folders_urls.edit.own', 'com_componentbuilder')) + { + return true; + } + } + } + return false; + } + } + // Since there is no permission, revert to the component permissions. + return $user->authorise('library_files_folders_urls.edit', $this->option); + } + + /** + * Gets the URL arguments to append to an item redirect. + * + * @param integer $recordId The primary key id for the item. + * @param string $urlVar The name of the URL variable for the id. + * + * @return string The arguments to append to the redirect URL. + * + * @since 12.2 + */ + protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') + { + $tmpl = $this->input->get('tmpl'); + $layout = $this->input->get('layout', 'edit', 'string'); + + $ref = $this->input->get('ref', 0, 'string'); + $refid = $this->input->get('refid', 0, 'int'); + + // Setup redirect info. + + $append = ''; + + if ($refid) + { + $append .= '&ref='.(string)$ref.'&refid='.(int)$refid; + } + elseif ($ref) + { + $append .= '&ref='.(string)$ref; + } + + if ($tmpl) + { + $append .= '&tmpl=' . $tmpl; + } + + if ($layout) + { + $append .= '&layout=' . $layout; + } + + if ($recordId) + { + $append .= '&' . $urlVar . '=' . $recordId; + } + + return $append; + } + + /** + * Method to run batch operations. + * + * @param object $model The model. + * + * @return boolean True if successful, false otherwise and internal error is set. + * + * @since 2.5 + */ + public function batch($model = null) + { + JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN')); + + // Set the model + $model = $this->getModel('Library_files_folders_urls', '', array()); + + // Preset the redirect + $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=libraries_files_folders_urls' . $this->getRedirectToListAppend(), false)); + + return parent::batch($model); + } + + /** + * Method to cancel an edit. + * + * @param string $key The name of the primary key of the URL variable. + * + * @return boolean True if access level checks pass, false otherwise. + * + * @since 12.2 + */ + public function cancel($key = null) + { + // get the referal details + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + $cancel = parent::cancel($key); + + if ($cancel) + { + if ($this->refid) + { + $redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + } + else + { + // Redirect to the items screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . '&view=' . $this->view_list, false + ) + ); + } + return $cancel; + } + + /** + * Method to save a record. + * + * @param string $key The name of the primary key of the URL variable. + * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). + * + * @return boolean True if successful, false otherwise. + * + * @since 12.2 + */ + public function save($key = null, $urlVar = null) + { + // get the referal details + $this->ref = $this->input->get('ref', 0, 'word'); + $this->refid = $this->input->get('refid', 0, 'int'); + + if ($this->ref || $this->refid) + { + // to make sure the item is checkedin on redirect + $this->task = 'save'; + } + + $saved = parent::save($key, $urlVar); + + if ($this->refid && $saved) + { + $redirect = '&view='.(string)$this->ref.'&layout=edit&id='.(int)$this->refid; + + // Redirect to the item screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + elseif ($this->ref && $saved) + { + $redirect = '&view='.(string)$this->ref; + + // Redirect to the list screen. + $this->setRedirect( + JRoute::_( + 'index.php?option=' . $this->option . $redirect, false + ) + ); + } + return $saved; + } + + /** + * Function that allows child controller access to model data + * after the data has been saved. + * + * @param JModel &$model The data model object. + * @param array $validData The validated data. + * + * @return void + * + * @since 11.1 + */ + protected function postSaveHook(JModelLegacy $model, $validData = array()) + { + return; + } + +} diff --git a/admin/helpers/componentbuilder.php b/admin/helpers/componentbuilder.php index 5e9f2d360..c098bc194 100644 --- a/admin/helpers/componentbuilder.php +++ b/admin/helpers/componentbuilder.php @@ -245,6 +245,11 @@ abstract class ComponentbuilderHelper return false; } + /** + * Locked Libraries (we can not have these change) + **/ + public static $libraryNames = array(1 => 'No Library', 2 => 'Bootstrap v4', 3 => 'Uikit v3', 4 => 'Uikit v2', 5 => 'FooTable v2', 6 => 'FooTable v3'); + /** * The global params **/ @@ -319,6 +324,104 @@ abstract class ComponentbuilderHelper return array('contributor_company' => self::$localCompany['company'] ,'contributor_name' => self::$localCompany['owner'], 'contributor_email' => self::$localCompany['email'], 'contributor_website' => self::$localCompany['website'], 'origin' => 'global'); } + /** + * Get the library files + * + * @param int $id The library id to target + * + * @return array On success the contributor details + * + */ + public static function getLibraryFiles($id) + { + // get the library files, folders, and urls + $files = array(); + // Get a db connection. + $db = JFactory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName(array('addurls','addfolders','addfiles'))); + $query->from($db->quoteName('#__componentbuilder_library_files_folders_urls')); + $query->where($db->quoteName('library') . ' = ' . (int) $id); + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + // prepare the files + $result = $db->loadObject(); + // first we load the URLs + if (self::checkJson($result->addurls)) + { + // convert to array + $result->addurls = json_decode($result->addurls, true); + // set urls + if (self::checkArray($result->addurls)) + { + foreach($result->addurls as $url) + { + if (isset($url['url']) && isset($url['type'])) + { + switch ($url['type']) + { + case 1: + // link only + $files['1'.$url['url']] = '(' . JText::_('COM_COMPONENTBUILDER_URL') . ') ' . basename($url['url']) . ' - ' . JText::_('COM_COMPONENTBUILDER_LINK'); + break; + case 2: + // local + $files['2'.$url['url']] = '(' . JText::_('COM_COMPONENTBUILDER_URL') . ') ' . basename($url['url']) . ' - ' . JText::_('COM_COMPONENTBUILDER_LOCAL'); + break; + case 3: + // link and local + $files['1'.$url['url']] = '(' . JText::_('COM_COMPONENTBUILDER_URL') . ') ' . basename($url['url']) . ' - ' . JText::_('COM_COMPONENTBUILDER_LINK'); + $files['2'.$url['url']] = '(' . JText::_('COM_COMPONENTBUILDER_URL') . ') ' . basename($url['url']) . ' - ' . JText::_('COM_COMPONENTBUILDER_LOCAL'); + break; + } + } + } + } + } + // load the local files + if (self::checkJson($result->addfiles)) + { + // convert to array + $result->addfiles = json_decode($result->addfiles, true); + // set files + if (self::checkArray($result->addfiles)) + { + foreach($result->addfiles as $file) + { + if (isset($file['file']) && isset($file['path'])) + { + $files['3'.$file['path'].$file['file']] = '(' . JText::_('COM_COMPONENTBUILDER_FILE') . ') ' . $file['file']; + } + } + } + } + // load the files in the folder + if (self::checkJson($result->addfolders)) + { + // convert to array + $result->addfolders = json_decode($result->addfolders, true); + // set folder + if (self::checkArray($result->addfolders)) + { + foreach($result->addfolders as $folder) + { + // not yet set + } + $files['4folders'] = '(' . JText::_('COM_COMPONENTBUILDER_FOLDERS') . ') not yet able to deal with folders'; + } + } + // return files if found + if (self::checkArray($files)) + { + return $files; + } + } + return false; + } + /** * get all component IDs */ @@ -1802,6 +1905,10 @@ abstract class ComponentbuilderHelper { JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_CUSTOM_CODES'), 'index.php?option=com_componentbuilder&view=custom_codes', $submenu === 'custom_codes'); } + if ($user->authorise('library.access', 'com_componentbuilder') && $user->authorise('library.submenu', 'com_componentbuilder')) + { + JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_LIBRARIES'), 'index.php?option=com_componentbuilder&view=libraries', $submenu === 'libraries'); + } if ($user->authorise('snippet.access', 'com_componentbuilder') && $user->authorise('snippet.submenu', 'com_componentbuilder')) { JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_SNIPPETS'), 'index.php?option=com_componentbuilder&view=snippets', $submenu === 'snippets'); diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.ini b/admin/language/en-GB/en-GB.com_componentbuilder.ini index b2e960a7f..d2f945560 100644 --- a/admin/language/en-GB/en-GB.com_componentbuilder.ini +++ b/admin/language/en-GB/en-GB.com_componentbuilder.ini @@ -1561,7 +1561,7 @@ COM_COMPONENTBUILDER_COMPONENT_CONFIG_CREATED_BY_DESC="The user that created thi COM_COMPONENTBUILDER_COMPONENT_CONFIG_CREATED_BY_LABEL="Created By" COM_COMPONENTBUILDER_COMPONENT_CONFIG_CREATED_DATE_DESC="The date this Component Config was created." COM_COMPONENTBUILDER_COMPONENT_CONFIG_CREATED_DATE_LABEL="Created Date" -COM_COMPONENTBUILDER_COMPONENT_CONFIG_CUSTOM_VALUE_DESCRIPTION="Enter custom value in needed" +COM_COMPONENTBUILDER_COMPONENT_CONFIG_CUSTOM_VALUE_DESCRIPTION="Enter custom value if needed" COM_COMPONENTBUILDER_COMPONENT_CONFIG_CUSTOM_VALUE_HINT="Custom Value Here" COM_COMPONENTBUILDER_COMPONENT_CONFIG_CUSTOM_VALUE_LABEL="Custom Value" COM_COMPONENTBUILDER_COMPONENT_CONFIG_EDIT="Editing the Component Config" @@ -1584,7 +1584,7 @@ COM_COMPONENTBUILDER_COMPONENT_CONFIG_PUBLISHING="Publishing" COM_COMPONENTBUILDER_COMPONENT_CONFIG_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Component Config to customise the alias." COM_COMPONENTBUILDER_COMPONENT_CONFIG_STATUS="Status" COM_COMPONENTBUILDER_COMPONENT_CONFIG_TABNAME_DESCRIPTION="The name of the tab this field belongs to." -COM_COMPONENTBUILDER_COMPONENT_CONFIG_TABNAME_HINT="Global" +COM_COMPONENTBUILDER_COMPONENT_CONFIG_TABNAME_HINT="Library" COM_COMPONENTBUILDER_COMPONENT_CONFIG_TABNAME_LABEL="Tab Name" COM_COMPONENTBUILDER_COMPONENT_CONFIG_TABNAME_MESSAGE="Error! Please add tab name here." COM_COMPONENTBUILDER_COMPONENT_CONFIG_TWEAKS="Tweaks" @@ -1973,7 +1973,7 @@ COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_NOTE_ADD_FOLDERS_LABEL="Adding Cust COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_NOTNEW_DESCRIPTION="Should file be updated." COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_NOTNEW_LABEL="Update" COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_ORDERING_LABEL="Ordering" -COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_PATH_DESCRIPTION="Path in relation to the folder structure in the install package, unzip the compiled file to see the structure. " +COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_PATH_DESCRIPTION="Path in relation to the folder structure in the install package, unzip the compiled zip file to see the structure. " COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_PATH_HINT="Target Path Here" COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_PATH_LABEL="Target Path" COM_COMPONENTBUILDER_COMPONENT_FILES_FOLDERS_PATH_MESSAGE="Error! Please add target path." @@ -2392,6 +2392,7 @@ COM_COMPONENTBUILDER_CONTRIBUTORS="Contributors" COM_COMPONENTBUILDER_COPYRIGHT="Copyright" COM_COMPONENTBUILDER_COPYRIGHT_S="Copyright: %s" COM_COMPONENTBUILDER_CREATE="Create" +COM_COMPONENTBUILDER_CREATE_A_SNIPPET="create a snippet" COM_COMPONENTBUILDER_CREATE_NEW_S="Create New %s" COM_COMPONENTBUILDER_CREATE_S_FOR_THIS_S="Create %s for this %s" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW="Custom Admin View" @@ -2620,6 +2621,9 @@ COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_JS_DOCUMENT_LABEL="Custom Script (Documen COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_KEY="Key" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_LAMP="Lamp" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_LAST="Last" +COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_LIBRARIES="Libraries" +COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_LIBRARIES_DESCRIPTION="Select the libraries you want to use here." +COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_LIBRARIES_LABEL="Libraries" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_LINK="Link" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_LIST="List" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_LIST_TWO="List 2" @@ -2657,6 +2661,8 @@ COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NEXT="Next" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NO="No" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NOTE_ADD_LANGUAGE_STRING_DESCRIPTION="<?php echo JText::_('Text'); ?>" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NOTE_ADD_LANGUAGE_STRING_LABEL="Add Language String" +COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NOTE_LIBRARIES_SELECTION_DESCRIPTION="All libraries you select will dynamically be added to the header of the page according to the settings of the selected library. Each library will also get its respective buttons added to the component global options if it has any set. Please take a look at the libraries for more details." +COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NOTE_LIBRARIES_SELECTION_LABEL="Select libraries you would like to use in your code" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NOTE_SNIPPET_USAGE_LABEL="Snippet Usage" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NOTE_UIKIT_SNIPPET_LABEL="Snippet Details" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NOTIFICATION="Notification" @@ -2740,6 +2746,7 @@ COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_SMILEY_SAD="Smiley Sad" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_SMILEY_SAD_TWO="Smiley Sad 2" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_SMILEY_TWO="Smiley 2" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_SNIPPET="Snippet" +COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_SNIPPET_DESCRIPTION="Select a snippet you would like to use or review." COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_SNIPPET_LABEL="Select a Snippet" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_SQUARE="Square" COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_STACK="Stack" @@ -3045,6 +3052,7 @@ COM_COMPONENTBUILDER_DASHBOARD_JOOMLA_COMPONENT_ADD="Add Joomla ComponentgetForm(); $fields = $displayData->get('fields') ?: array( - 'note_add_language_string', 'default' ); diff --git a/admin/layouts/custom_admin_view/details_left.php b/admin/layouts/custom_admin_view/details_left.php index ff3c7fd86..67dfa2a56 100644 --- a/admin/layouts/custom_admin_view/details_left.php +++ b/admin/layouts/custom_admin_view/details_left.php @@ -33,8 +33,9 @@ $fields = $displayData->get('fields') ?: array( 'name', 'codename', 'description', - 'snippet', - 'note_snippet_usage' + 'note_libraries_selection', + 'libraries', + 'note_add_language_string' ); $hiddenFields = $displayData->get('hidden_fields') ?: array(); diff --git a/admin/layouts/custom_admin_view/details_right.php b/admin/layouts/custom_admin_view/details_right.php index 32cf0e554..6eec871a4 100644 --- a/admin/layouts/custom_admin_view/details_right.php +++ b/admin/layouts/custom_admin_view/details_right.php @@ -31,7 +31,9 @@ $form = $displayData->getForm(); $fields = $displayData->get('fields') ?: array( 'icon', - 'note_uikit_snippet' + 'snippet', + 'note_uikit_snippet', + 'note_snippet_usage' ); $hiddenFields = $displayData->get('hidden_fields') ?: array(); diff --git a/admin/layouts/fieldtype/fields_fullwidth.php b/admin/layouts/fieldtype/fields_fullwidth.php index fdfa5539b..b57918936 100644 --- a/admin/layouts/fieldtype/fields_fullwidth.php +++ b/admin/layouts/fieldtype/fields_fullwidth.php @@ -28,7 +28,7 @@ defined('_JEXEC') or die('Restricted access'); // set the defaults -$items = $displayData->vzufields; +$items = $displayData->vzwfields; $user = JFactory::getUser(); $id = $displayData->item->id; $edit = "index.php?option=com_componentbuilder&view=fields&task=field.edit"; diff --git a/admin/layouts/ftp/linked_components_fullwidth.php b/admin/layouts/ftp/linked_components_fullwidth.php index f2557f52e..a437256a6 100644 --- a/admin/layouts/ftp/linked_components_fullwidth.php +++ b/admin/layouts/ftp/linked_components_fullwidth.php @@ -28,7 +28,7 @@ defined('_JEXEC') or die('Restricted access'); // set the defaults -$items = $displayData->vzvlinked_components; +$items = $displayData->vzxlinked_components; $user = JFactory::getUser(); $id = $displayData->item->id; $edit = "index.php?option=com_componentbuilder&view=joomla_components&task=joomla_component.edit"; diff --git a/admin/layouts/layout/details_fullwidth.php b/admin/layouts/layout/details_fullwidth.php index a2258aef9..649984a09 100644 --- a/admin/layouts/layout/details_fullwidth.php +++ b/admin/layouts/layout/details_fullwidth.php @@ -30,7 +30,6 @@ defined('_JEXEC') or die('Restricted access'); $form = $displayData->getForm(); $fields = $displayData->get('fields') ?: array( - 'note_add_language_string', 'layout' ); diff --git a/admin/layouts/layout/details_left.php b/admin/layouts/layout/details_left.php index 35ea371dc..352879ab6 100644 --- a/admin/layouts/layout/details_left.php +++ b/admin/layouts/layout/details_left.php @@ -33,8 +33,9 @@ $fields = $displayData->get('fields') ?: array( 'name', 'alias', 'description', - 'snippet', - 'note_snippet_usage' + 'note_libraries_selection', + 'libraries', + 'note_add_language_string' ); $hiddenFields = $displayData->get('hidden_fields') ?: array(); diff --git a/admin/layouts/layout/details_right.php b/admin/layouts/layout/details_right.php index 4665583e1..d5039e115 100644 --- a/admin/layouts/layout/details_right.php +++ b/admin/layouts/layout/details_right.php @@ -30,7 +30,9 @@ defined('_JEXEC') or die('Restricted access'); $form = $displayData->getForm(); $fields = $displayData->get('fields') ?: array( - 'note_uikit_snippet' + 'snippet', + 'note_uikit_snippet', + 'note_snippet_usage' ); $hiddenFields = $displayData->get('hidden_fields') ?: array(); diff --git a/admin/layouts/library/behaviour_above.php b/admin/layouts/library/behaviour_above.php new file mode 100644 index 000000000..55d0e6df3 --- /dev/null +++ b/admin/layouts/library/behaviour_above.php @@ -0,0 +1,42 @@ + + @github Joomla Component Builder + @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'); + +$form = $displayData->getForm(); + +$fields = array( + 'name', + 'how' +); + +?> +
+ renderField($field); + } ?> +
diff --git a/admin/layouts/library/behaviour_fullwidth.php b/admin/layouts/library/behaviour_fullwidth.php new file mode 100644 index 000000000..0530f76ae --- /dev/null +++ b/admin/layouts/library/behaviour_fullwidth.php @@ -0,0 +1,52 @@ + + @github Joomla Component Builder + @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'); + +$form = $displayData->getForm(); + +$fields = $displayData->get('fields') ?: array( + 'note_no_behaviour_one', + 'note_yes_behaviour_one', + 'addconditions', + 'php_setdocument', + 'php_preparedocument' +); + +?> +
+ +
+
+ getLabel($field); ?> +
+
+ getInput($field); ?> +
+
+ +
diff --git a/admin/layouts/library/details_right.php b/admin/layouts/library/behaviour_right.php similarity index 96% rename from admin/layouts/library/details_right.php rename to admin/layouts/library/behaviour_right.php index 92112f79b..9371a467f 100644 --- a/admin/layouts/library/details_right.php +++ b/admin/layouts/library/behaviour_right.php @@ -13,7 +13,7 @@ @version 2.6.x @created 30th April, 2015 @package Component Builder - @subpackage details_right.php + @subpackage behaviour_right.php @author Llewellyn van der Merwe @github Joomla Component Builder @copyright Copyright (C) 2015. All Rights Reserved diff --git a/admin/layouts/library/behaviour_under.php b/admin/layouts/library/behaviour_under.php new file mode 100644 index 000000000..bb1c12abc --- /dev/null +++ b/admin/layouts/library/behaviour_under.php @@ -0,0 +1,41 @@ + + @github Joomla Component Builder + @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'); + +$form = $displayData->getForm(); + +$fields = array( + 'not_required' +); + +?> +
+ renderField($field); + } ?> +
diff --git a/admin/layouts/library/config_fullwidth.php b/admin/layouts/library/config_fullwidth.php new file mode 100644 index 000000000..f78b33db2 --- /dev/null +++ b/admin/layouts/library/config_fullwidth.php @@ -0,0 +1,50 @@ + + @github Joomla Component Builder + @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'); + +$form = $displayData->getForm(); + +$fields = $displayData->get('fields') ?: array( + 'note_no_behaviour_two', + 'note_yes_behaviour_two', + 'note_display_library_config' +); + +?> +
+ +
+
+ getLabel($field); ?> +
+
+ getInput($field); ?> +
+
+ +
diff --git a/admin/layouts/library/files_folders_urls_fullwidth.php b/admin/layouts/library/files_folders_urls_fullwidth.php new file mode 100644 index 000000000..9b00b61e2 --- /dev/null +++ b/admin/layouts/library/files_folders_urls_fullwidth.php @@ -0,0 +1,49 @@ + + @github Joomla Component Builder + @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'); + +$form = $displayData->getForm(); + +$fields = $displayData->get('fields') ?: array( + 'note_no_behaviour_three', + 'note_display_library_files_folders_urls' +); + +?> +
+ +
+
+ getLabel($field); ?> +
+
+ getInput($field); ?> +
+
+ +
diff --git a/admin/layouts/library_config/index.html b/admin/layouts/library_config/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/layouts/library_config/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/layouts/library/details_left.php b/admin/layouts/library_config/publishing.php similarity index 93% rename from admin/layouts/library/details_left.php rename to admin/layouts/library_config/publishing.php index 892f7233e..13d13ed74 100644 --- a/admin/layouts/library/details_left.php +++ b/admin/layouts/library_config/publishing.php @@ -13,7 +13,7 @@ @version 2.6.x @created 30th April, 2015 @package Component Builder - @subpackage details_left.php + @subpackage publishing.php @author Llewellyn van der Merwe @github Joomla Component Builder @copyright Copyright (C) 2015. All Rights Reserved @@ -27,10 +27,14 @@ defined('_JEXEC') or die('Restricted access'); +$app = JFactory::getApplication(); $form = $displayData->getForm(); $fields = $displayData->get('fields') ?: array( - 'name' + 'created', + 'created_by', + 'modified', + 'modified_by' ); $hiddenFields = $displayData->get('hidden_fields') ?: array(); diff --git a/admin/layouts/library_config/publlshing.php b/admin/layouts/library_config/publlshing.php new file mode 100644 index 000000000..c982db556 --- /dev/null +++ b/admin/layouts/library_config/publlshing.php @@ -0,0 +1,60 @@ + + @github Joomla Component Builder + @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'); + +$app = JFactory::getApplication(); +$form = $displayData->getForm(); + +$fields = $displayData->get('fields') ?: array( + 'published', + 'ordering', + 'access', + 'version', + 'hits', + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +foreach ($fields as $field) +{ + $field = is_array($field) ? $field : array($field); + foreach ($field as $f) + { + if ($form->getField($f)) + { + if (in_array($f, $hiddenFields)) + { + $form->setFieldAttribute($f, 'type', 'hidden'); + } + + echo $form->renderField($f); + break; + } + } +} diff --git a/admin/layouts/library_config/tweaks_above.php b/admin/layouts/library_config/tweaks_above.php new file mode 100644 index 000000000..4c71d79d6 --- /dev/null +++ b/admin/layouts/library_config/tweaks_above.php @@ -0,0 +1,41 @@ + + @github Joomla Component Builder + @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'); + +$form = $displayData->getForm(); + +$fields = array( + 'library' +); + +?> +
+ renderField($field); + } ?> +
diff --git a/admin/layouts/library_config/tweaks_fullwidth.php b/admin/layouts/library_config/tweaks_fullwidth.php new file mode 100644 index 000000000..e832119f3 --- /dev/null +++ b/admin/layouts/library_config/tweaks_fullwidth.php @@ -0,0 +1,48 @@ + + @github Joomla Component Builder + @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'); + +$form = $displayData->getForm(); + +$fields = $displayData->get('fields') ?: array( + 'addconfig' +); + +?> +
+ +
+
+ getLabel($field); ?> +
+
+ getInput($field); ?> +
+
+ +
diff --git a/admin/layouts/library_files_folders_urls/index.html b/admin/layouts/library_files_folders_urls/index.html new file mode 100644 index 000000000..fa6d84e80 --- /dev/null +++ b/admin/layouts/library_files_folders_urls/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/admin/layouts/library_files_folders_urls/publishing.php b/admin/layouts/library_files_folders_urls/publishing.php new file mode 100644 index 000000000..13d13ed74 --- /dev/null +++ b/admin/layouts/library_files_folders_urls/publishing.php @@ -0,0 +1,58 @@ + + @github Joomla Component Builder + @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'); + +$app = JFactory::getApplication(); +$form = $displayData->getForm(); + +$fields = $displayData->get('fields') ?: array( + 'created', + 'created_by', + 'modified', + 'modified_by' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +foreach ($fields as $field) +{ + $field = is_array($field) ? $field : array($field); + foreach ($field as $f) + { + if ($form->getField($f)) + { + if (in_array($f, $hiddenFields)) + { + $form->setFieldAttribute($f, 'type', 'hidden'); + } + + echo $form->renderField($f); + break; + } + } +} diff --git a/admin/layouts/library_files_folders_urls/publlshing.php b/admin/layouts/library_files_folders_urls/publlshing.php new file mode 100644 index 000000000..c982db556 --- /dev/null +++ b/admin/layouts/library_files_folders_urls/publlshing.php @@ -0,0 +1,60 @@ + + @github Joomla Component Builder + @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'); + +$app = JFactory::getApplication(); +$form = $displayData->getForm(); + +$fields = $displayData->get('fields') ?: array( + 'published', + 'ordering', + 'access', + 'version', + 'hits', + 'id' +); + +$hiddenFields = $displayData->get('hidden_fields') ?: array(); + +foreach ($fields as $field) +{ + $field = is_array($field) ? $field : array($field); + foreach ($field as $f) + { + if ($form->getField($f)) + { + if (in_array($f, $hiddenFields)) + { + $form->setFieldAttribute($f, 'type', 'hidden'); + } + + echo $form->renderField($f); + break; + } + } +} diff --git a/admin/layouts/library_files_folders_urls/settings_above.php b/admin/layouts/library_files_folders_urls/settings_above.php new file mode 100644 index 000000000..dbfce2d87 --- /dev/null +++ b/admin/layouts/library_files_folders_urls/settings_above.php @@ -0,0 +1,41 @@ + + @github Joomla Component Builder + @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'); + +$form = $displayData->getForm(); + +$fields = array( + 'library' +); + +?> +
+ renderField($field); + } ?> +
diff --git a/admin/layouts/library_files_folders_urls/settings_fullwidth.php b/admin/layouts/library_files_folders_urls/settings_fullwidth.php new file mode 100644 index 000000000..db6dbca1c --- /dev/null +++ b/admin/layouts/library_files_folders_urls/settings_fullwidth.php @@ -0,0 +1,53 @@ + + @github Joomla Component Builder + @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'); + +$form = $displayData->getForm(); + +$fields = $displayData->get('fields') ?: array( + 'note_add_urls', + 'addurls', + 'note_add_files', + 'addfiles', + 'note_add_folders', + 'addfolders' +); + +?> +
+ +
+
+ getLabel($field); ?> +
+
+ getInput($field); ?> +
+
+ +
diff --git a/admin/layouts/site_view/details_fullwidth.php b/admin/layouts/site_view/details_fullwidth.php index 6c422bc54..1a572bf4e 100644 --- a/admin/layouts/site_view/details_fullwidth.php +++ b/admin/layouts/site_view/details_fullwidth.php @@ -30,7 +30,6 @@ defined('_JEXEC') or die('Restricted access'); $form = $displayData->getForm(); $fields = $displayData->get('fields') ?: array( - 'note_add_language_string', 'default' ); diff --git a/admin/layouts/site_view/details_left.php b/admin/layouts/site_view/details_left.php index ff3c7fd86..67dfa2a56 100644 --- a/admin/layouts/site_view/details_left.php +++ b/admin/layouts/site_view/details_left.php @@ -33,8 +33,9 @@ $fields = $displayData->get('fields') ?: array( 'name', 'codename', 'description', - 'snippet', - 'note_snippet_usage' + 'note_libraries_selection', + 'libraries', + 'note_add_language_string' ); $hiddenFields = $displayData->get('hidden_fields') ?: array(); diff --git a/admin/layouts/site_view/details_right.php b/admin/layouts/site_view/details_right.php index 4665583e1..d5039e115 100644 --- a/admin/layouts/site_view/details_right.php +++ b/admin/layouts/site_view/details_right.php @@ -30,7 +30,9 @@ defined('_JEXEC') or die('Restricted access'); $form = $displayData->getForm(); $fields = $displayData->get('fields') ?: array( - 'note_uikit_snippet' + 'snippet', + 'note_uikit_snippet', + 'note_snippet_usage' ); $hiddenFields = $displayData->get('hidden_fields') ?: array(); diff --git a/admin/layouts/template/details_fullwidth.php b/admin/layouts/template/details_fullwidth.php index 682164c24..f8b5ac35b 100644 --- a/admin/layouts/template/details_fullwidth.php +++ b/admin/layouts/template/details_fullwidth.php @@ -30,7 +30,6 @@ defined('_JEXEC') or die('Restricted access'); $form = $displayData->getForm(); $fields = $displayData->get('fields') ?: array( - 'note_add_language_string', 'template' ); diff --git a/admin/layouts/template/details_left.php b/admin/layouts/template/details_left.php index 35ea371dc..352879ab6 100644 --- a/admin/layouts/template/details_left.php +++ b/admin/layouts/template/details_left.php @@ -33,8 +33,9 @@ $fields = $displayData->get('fields') ?: array( 'name', 'alias', 'description', - 'snippet', - 'note_snippet_usage' + 'note_libraries_selection', + 'libraries', + 'note_add_language_string' ); $hiddenFields = $displayData->get('hidden_fields') ?: array(); diff --git a/admin/layouts/template/details_right.php b/admin/layouts/template/details_right.php index 4665583e1..d5039e115 100644 --- a/admin/layouts/template/details_right.php +++ b/admin/layouts/template/details_right.php @@ -30,7 +30,9 @@ defined('_JEXEC') or die('Restricted access'); $form = $displayData->getForm(); $fields = $displayData->get('fields') ?: array( - 'note_uikit_snippet' + 'snippet', + 'note_uikit_snippet', + 'note_snippet_usage' ); $hiddenFields = $displayData->get('hidden_fields') ?: array(); diff --git a/admin/models/admin_fields.php b/admin/models/admin_fields.php index e12ddf256..1027be741 100644 --- a/admin/models/admin_fields.php +++ b/admin/models/admin_fields.php @@ -79,7 +79,7 @@ class ComponentbuilderModelAdmin_fields extends JModelAdmin { if ($item = parent::getItem($pk)) { - if (!empty($item->params)) + if (!empty($item->params) && !is_array($item->params)) { // Convert the params field to an array. $registry = new Registry; diff --git a/admin/models/admin_fields_conditions.php b/admin/models/admin_fields_conditions.php index 51ba6843c..147f91bd9 100644 --- a/admin/models/admin_fields_conditions.php +++ b/admin/models/admin_fields_conditions.php @@ -79,7 +79,7 @@ class ComponentbuilderModelAdmin_fields_conditions extends JModelAdmin { if ($item = parent::getItem($pk)) { - if (!empty($item->params)) + if (!empty($item->params) && !is_array($item->params)) { // Convert the params field to an array. $registry = new Registry; diff --git a/admin/models/admin_view.php b/admin/models/admin_view.php index 1e3eb3c26..395766bba 100644 --- a/admin/models/admin_view.php +++ b/admin/models/admin_view.php @@ -84,7 +84,7 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin { if ($item = parent::getItem($pk)) { - if (!empty($item->params)) + if (!empty($item->params) && !is_array($item->params)) { // Convert the params field to an array. $registry = new Registry; diff --git a/admin/models/ajax.php b/admin/models/ajax.php index c474abcd9..f5736e200 100644 --- a/admin/models/ajax.php +++ b/admin/models/ajax.php @@ -211,6 +211,8 @@ class ComponentbuilderModelAjax extends JModelList } protected $buttonArray = array( + 'library_config' => 'libraries_config', + 'library_files_folders_urls' => 'libraries_files_folders_urls', 'admin_fields' => 'admins_fields', 'admin_fields_conditions' => 'admins_fields_conditions', 'field' => 'fields', @@ -338,6 +340,10 @@ class ComponentbuilderModelAjax extends JModelList } protected $functionArray = array( + // Library + 'rename' => 'setYesNo', + 'update' => 'setYesNo', + 'type' => 'setURLType', // Admin View 'field' => 'setItemNames', 'list' => 'setYesNo', @@ -379,6 +385,10 @@ class ComponentbuilderModelAjax extends JModelList protected function getLanguage($key) { $language = array( + // Library (folder file url) + 'rename' => JText::_('COM_COMPONENTBUILDER_RENAME'), + 'path' => JText::_('COM_COMPONENTBUILDER_TARGET_PATH'), + 'update' => JText::_('COM_COMPONENTBUILDER_UPDATE'), // Admin View (fields) 'field' => JText::_('COM_COMPONENTBUILDER_FIELD'), 'list' => JText::_('COM_COMPONENTBUILDER_ADMIN_LIST'), @@ -546,11 +556,17 @@ class ComponentbuilderModelAjax extends JModelList protected $ref; protected $fieldsArray = array( + 'library_config' => 'addconfig', + 'library_files_folders_urls' => array('addurls','addfiles','addfolders'), 'admin_fields' => 'addfields', 'admin_fields_conditions' => 'addconditions', 'component_admin_views' => 'addadmin_views', 'component_site_views' => 'addsite_views', 'component_custom_admin_views' => 'addcustom_admin_views'); + protected $allowedViewsArray = array( + 'admin_view', + 'joomla_component', + 'library'); public function getAjaxDisplay($type) { @@ -561,28 +577,39 @@ class ComponentbuilderModelAjax extends JModelList // get the view name & id $values = $this->getViewID(); // check if we are in the correct view. - if (!is_null($values['a_id']) && $values['a_id'] > 0 && strlen($values['a_view']) && ($values['a_view'] === 'admin_view' || $values['a_view'] === 'joomla_component')) + if (!is_null($values['a_id']) && $values['a_id'] > 0 && strlen($values['a_view']) && in_array($values['a_view'], $this->allowedViewsArray)) { $this->ref = '&ref=' . $values['a_view'] . '&refid=' . $values['a_id']; - // get the field data - if ($fieldsData = ComponentbuilderHelper::getVar($type, (int) $values['a_id'], $values['a_view'], $this->fieldsArray[$type])) + // load the results + $result = array(); + // return field table + if (ComponentbuilderHelper::checkArray($this->fieldsArray[$type])) { - // check repeatable conversion - $this->checkRepeatableConversion($fieldsData, $type, $values['a_id'], $values['a_view']); - // get the table - $table = $this->getSubformTable($type, $fieldsData); - // set notice of bad practice - $notice = ''; - if ($values['a_view'] === 'admin_view' && isset($this->rowNumber) && $this->rowNumber > 50) + foreach ($this->fieldsArray[$type] as $fieldName) { - $notice = '
' . JText::sprintf('COM_COMPONENTBUILDER_YOU_HAVE_S_S_ADDING_MORE_THEN_FIFTY_S_IS_CONSIDERED_BAD_PRACTICE_YOUR_S_PAGE_LOAD_IN_JCB_WILL_SLOWDOWN_YOU_SHOULD_CONSIDER_DECOUPLING_SOME_OF_THESE_S', $this->rowNumber, $typeName, $typeName, $typeName, $typeName) . '
'; + if ($table = $this->getFieldTable($type, $values['a_id'], $values['a_view'], $fieldName, $typeName)) + { + $result[] = $table; + } } - elseif ($values['a_view'] === 'admin_view' && isset($this->rowNumber)) + } + elseif (ComponentbuilderHelper::checkString($this->fieldsArray[$type])) + { + if ($table = $this->getFieldTable($type, $values['a_id'], $values['a_view'], $this->fieldsArray[$type], $typeName)) { - $notice = '
' . JText::sprintf('COM_COMPONENTBUILDER_YOU_HAVE_S_S_ADDING_MORE_THEN_FIFTY_S_IS_CONSIDERED_BAD_PRACTICE', $this->rowNumber, $typeName, $typeName) . '
'; + $result[] = $table; } - // return table - return $notice.$table; + } + // check if we have results + if (ComponentbuilderHelper::checkArray($result) && count($result) == 1) + { + // return the display + return implode('', $result); + } + elseif (ComponentbuilderHelper::checkArray($result)) + { + // return the display + return '
' . implode('
', $result) . '
'; } } return '
' . JText::sprintf('COM_COMPONENTBUILDER_NO_S_HAVE_BEEN_LINKED_TO_THIS_VIEW_SOON_AS_THIS_IS_DONE_IT_WILL_BE_DISPLAYED_HERE', $typeName) . '
'; @@ -590,6 +617,31 @@ class ComponentbuilderModelAjax extends JModelList return '

' . JText::_('COM_COMPONENTBUILDER_TYPE_ERROR') . '

' . JText::_('COM_COMPONENTBUILDER_THERE_HAS_BEEN_AN_ERROR_IF_THIS_CONTINUES_PLEASE_INFORM_YOUR_SYSTEM_ADMINISTRATOR_OF_A_TYPE_ERROR_IN_THE_FIELDS_DISPLAY_REQUEST') . '

'; } + protected function getFieldTable($type, $id, $idName, $fieldName, $typeName) + { + // get the field data + if ($fieldsData = ComponentbuilderHelper::getVar($type, (int) $id, $idName, $fieldName)) + { + // check repeatable conversion + $this->checkRepeatableConversion($fieldsData, $fieldName, $id, $idName); + // get the table + $table = $this->getSubformTable($type, $fieldsData); + // set notice of bad practice + $notice = ''; + if ($idName === 'admin_view' && isset($this->rowNumber) && $this->rowNumber > 50) + { + $notice = '
' . JText::sprintf('COM_COMPONENTBUILDER_YOU_HAVE_S_S_ADDING_MORE_THEN_FIFTY_S_IS_CONSIDERED_BAD_PRACTICE_YOUR_S_PAGE_LOAD_IN_JCB_WILL_SLOWDOWN_YOU_SHOULD_CONSIDER_DECOUPLING_SOME_OF_THESE_S', $this->rowNumber, $typeName, $typeName, $typeName, $typeName) . '
'; + } + elseif ($idName === 'admin_view' && isset($this->rowNumber)) + { + $notice = '
' . JText::sprintf('COM_COMPONENTBUILDER_YOU_HAVE_S_S_ADDING_MORE_THEN_FIFTY_S_IS_CONSIDERED_BAD_PRACTICE', $this->rowNumber, $typeName, $typeName) . '
'; + } + // return table + return $notice.$table; + } + return false; + } + protected $conversionCheck = array( 'addfields' => 'field', 'addconditions' => 'target_field', @@ -601,26 +653,26 @@ class ComponentbuilderModelAjax extends JModelList 'sql_tweak' => 'adminview', 'version_update' => 'version'); - protected function checkRepeatableConversion(&$fieldsData, $type, $id, $linked_id_name) + protected function checkRepeatableConversion(&$fieldsData, $fieldsArrayType, $id, $linked_id_name) { - if (ComponentbuilderHelper::checkJson($fieldsData)) + if (ComponentbuilderHelper::checkJson($fieldsData) && isset($this->conversionCheck[$fieldsArrayType])) { $fieldsData = json_decode($fieldsData, true); - if (isset($fieldsData[$this->conversionCheck[$this->fieldsArray[$type]]])) + if (isset($fieldsData[$this->conversionCheck[$fieldsArrayType]])) { $bucket = array(); foreach($fieldsData as $option => $values) { foreach($values as $nr => $value) { - $bucket[$this->fieldsArray[$type].$nr][$option] = $value; + $bucket[$fieldsArrayType.$nr][$option] = $value; } } $fieldsData = json_encode($bucket); // update the fields $objectUpdate = new stdClass(); $objectUpdate->{$linked_id_name} = (int) $id; - $objectUpdate->{$this->fieldsArray[$type]} = $fieldsData; + $objectUpdate->{$fieldsArrayType} = $fieldsData; JFactory::getDbo()->updateObject('#__componentbuilder_'.$type, $objectUpdate, 'admin_view'); } } @@ -715,6 +767,23 @@ class ComponentbuilderModelAjax extends JModelList return JText::_('COM_COMPONENTBUILDER_NO_ITEM_FOUND'); } + protected function setURLType($header, $value) + { + switch ($value) + { + case 1: + return JText::_('COM_COMPONENTBUILDER_DEFAULT_LINK'); + break; + case 2: + return JText::_('COM_COMPONENTBUILDER_LOCAL_GET'); + break; + case 3: + return JText::_('COM_COMPONENTBUILDER_LINK_LOCAL_DYNAMIC'); + break; + } + return JText::_('COM_COMPONENTBUILDER_NOT_SET'); + } + protected function setIcoMoon($header, $value) { if (ComponentbuilderHelper::checkString($value)) @@ -1003,6 +1072,39 @@ class ComponentbuilderModelAjax extends JModelList return false; } + // Used in site_view + + public function getSnippets($libraries) + { + if (ComponentbuilderHelper::checkJson($libraries)) + { + $libraries = json_decode($libraries, true); + } + // check if we have an array + if (ComponentbuilderHelper::checkArray($libraries)) + { + // insure we only have int values + $libraries = array_map( function($id){ return (int) $id; }, $libraries); + // Get a db connection. + $db = JFactory::getDbo(); + // Create a new query object. + $query = $db->getQuery(true); + $query->select($db->quoteName( array('a.id') )); + $query->from($db->quoteName('#__componentbuilder_snippet', 'a')); + $query->where($db->quoteName('a.published') . ' = 1'); + // check for country and region + $query->where($db->quoteName('a.library') . ' IN ('. implode(',',$libraries) .')'); + $db->setQuery($query); + $db->execute(); + if ($db->getNumRows()) + { + return $db->loadColumn(); + } + } + return false; + } + + // Used in template public function getTemplateDetails($id) { diff --git a/admin/models/component_admin_views.php b/admin/models/component_admin_views.php index d0a7acf18..2ca81fed2 100644 --- a/admin/models/component_admin_views.php +++ b/admin/models/component_admin_views.php @@ -79,7 +79,7 @@ class ComponentbuilderModelComponent_admin_views extends JModelAdmin { if ($item = parent::getItem($pk)) { - if (!empty($item->params)) + if (!empty($item->params) && !is_array($item->params)) { // Convert the params field to an array. $registry = new Registry; diff --git a/admin/models/component_config.php b/admin/models/component_config.php index 4fa5e7b26..5c2fd0bb4 100644 --- a/admin/models/component_config.php +++ b/admin/models/component_config.php @@ -79,7 +79,7 @@ class ComponentbuilderModelComponent_config extends JModelAdmin { if ($item = parent::getItem($pk)) { - if (!empty($item->params)) + if (!empty($item->params) && !is_array($item->params)) { // Convert the params field to an array. $registry = new Registry; diff --git a/admin/models/component_custom_admin_menus.php b/admin/models/component_custom_admin_menus.php index e7932e9e1..8c5900497 100644 --- a/admin/models/component_custom_admin_menus.php +++ b/admin/models/component_custom_admin_menus.php @@ -79,7 +79,7 @@ class ComponentbuilderModelComponent_custom_admin_menus extends JModelAdmin { if ($item = parent::getItem($pk)) { - if (!empty($item->params)) + if (!empty($item->params) && !is_array($item->params)) { // Convert the params field to an array. $registry = new Registry; diff --git a/admin/models/component_custom_admin_views.php b/admin/models/component_custom_admin_views.php index b8f91cbac..7046d87c5 100644 --- a/admin/models/component_custom_admin_views.php +++ b/admin/models/component_custom_admin_views.php @@ -79,7 +79,7 @@ class ComponentbuilderModelComponent_custom_admin_views extends JModelAdmin { if ($item = parent::getItem($pk)) { - if (!empty($item->params)) + if (!empty($item->params) && !is_array($item->params)) { // Convert the params field to an array. $registry = new Registry; diff --git a/admin/models/component_dashboard.php b/admin/models/component_dashboard.php index f25db9e09..a23ff3456 100644 --- a/admin/models/component_dashboard.php +++ b/admin/models/component_dashboard.php @@ -79,7 +79,7 @@ class ComponentbuilderModelComponent_dashboard extends JModelAdmin { if ($item = parent::getItem($pk)) { - if (!empty($item->params)) + if (!empty($item->params) && !is_array($item->params)) { // Convert the params field to an array. $registry = new Registry; diff --git a/admin/models/component_files_folders.php b/admin/models/component_files_folders.php index b6d2db167..a01e64894 100644 --- a/admin/models/component_files_folders.php +++ b/admin/models/component_files_folders.php @@ -79,7 +79,7 @@ class ComponentbuilderModelComponent_files_folders extends JModelAdmin { if ($item = parent::getItem($pk)) { - if (!empty($item->params)) + if (!empty($item->params) && !is_array($item->params)) { // Convert the params field to an array. $registry = new Registry; diff --git a/admin/models/component_mysql_tweaks.php b/admin/models/component_mysql_tweaks.php index 3d7148880..dbf351d42 100644 --- a/admin/models/component_mysql_tweaks.php +++ b/admin/models/component_mysql_tweaks.php @@ -79,7 +79,7 @@ class ComponentbuilderModelComponent_mysql_tweaks extends JModelAdmin { if ($item = parent::getItem($pk)) { - if (!empty($item->params)) + if (!empty($item->params) && !is_array($item->params)) { // Convert the params field to an array. $registry = new Registry; diff --git a/admin/models/component_site_views.php b/admin/models/component_site_views.php index 25170119f..3ac82dcb3 100644 --- a/admin/models/component_site_views.php +++ b/admin/models/component_site_views.php @@ -79,7 +79,7 @@ class ComponentbuilderModelComponent_site_views extends JModelAdmin { if ($item = parent::getItem($pk)) { - if (!empty($item->params)) + if (!empty($item->params) && !is_array($item->params)) { // Convert the params field to an array. $registry = new Registry; diff --git a/admin/models/component_updates.php b/admin/models/component_updates.php index 36e30aaeb..a3b4df547 100644 --- a/admin/models/component_updates.php +++ b/admin/models/component_updates.php @@ -79,7 +79,7 @@ class ComponentbuilderModelComponent_updates extends JModelAdmin { if ($item = parent::getItem($pk)) { - if (!empty($item->params)) + if (!empty($item->params) && !is_array($item->params)) { // Convert the params field to an array. $registry = new Registry; diff --git a/admin/models/componentbuilder.php b/admin/models/componentbuilder.php index 03f328d15..1f40523fe 100644 --- a/admin/models/componentbuilder.php +++ b/admin/models/componentbuilder.php @@ -43,7 +43,7 @@ class ComponentbuilderModelComponentbuilder extends JModelList $icons = array(); // view groups array $viewGroups = array( - 'main' => array('png.compiler', 'png.joomla_component.add', 'png.joomla_components', 'png.admin_view.add', 'png.admin_views', 'png.custom_admin_view.add', 'png.custom_admin_views', 'png.site_view.add', 'png.site_views', 'png.template.add', 'png.templates', 'png.layout.add', 'png.layouts', 'png.dynamic_get.add', 'png.dynamic_gets', 'png.custom_codes', 'png.snippet.add', 'png.snippets', 'png.field.add', 'png.fields', 'png.fields.catid', 'png.fieldtype.add', 'png.fieldtypes', 'png.fieldtypes.catid', 'png.language_translations', 'png.ftps', 'png.help_document.add', 'png.help_documents') + 'main' => array('png.compiler', 'png.joomla_component.add', 'png.joomla_components', 'png.admin_view.add', 'png.admin_views', 'png.custom_admin_view.add', 'png.custom_admin_views', 'png.site_view.add', 'png.site_views', 'png.template.add', 'png.templates', 'png.layout.add', 'png.layouts', 'png.dynamic_get.add', 'png.dynamic_gets', 'png.custom_codes', 'png.libraries', 'png.snippet.add', 'png.snippets', 'png.field.add', 'png.fields', 'png.fields.catid', 'png.fieldtype.add', 'png.fieldtypes', 'png.fieldtypes.catid', 'png.language_translations', 'png.ftps', 'png.help_document.add', 'png.help_documents') ); // view access array $viewAccess = array( @@ -92,6 +92,11 @@ class ComponentbuilderModelComponentbuilder extends JModelList 'custom_code.access' => 'custom_code.access', 'custom_codes.submenu' => 'custom_code.submenu', 'custom_codes.dashboard_list' => 'custom_code.dashboard_list', + 'library.create' => 'library.create', + 'libraries.access' => 'library.access', + 'library.access' => 'library.access', + 'libraries.submenu' => 'library.submenu', + 'libraries.dashboard_list' => 'library.dashboard_list', 'snippets.access' => 'snippet.access', 'snippet.access' => 'snippet.access', 'snippets.submenu' => 'snippet.submenu', @@ -165,9 +170,12 @@ class ComponentbuilderModelComponentbuilder extends JModelList 'snippet_type.create' => 'snippet_type.create', 'snippet_types.access' => 'snippet_type.access', 'snippet_type.access' => 'snippet_type.access', - 'library.create' => 'library.create', - 'libraries.access' => 'library.access', - 'library.access' => 'library.access'); + 'library_config.create' => 'library_config.create', + 'libraries_config.access' => 'library_config.access', + 'library_config.access' => 'library_config.access', + 'library_files_folders_urls.create' => 'library_files_folders_urls.create', + 'libraries_files_folders_urls.access' => 'library_files_folders_urls.access', + 'library_files_folders_urls.access' => 'library_files_folders_urls.access'); foreach($viewGroups as $group => $views) { $i = 0; diff --git a/admin/models/custom_admin_view.php b/admin/models/custom_admin_view.php index 18cbbf214..138b84f24 100644 --- a/admin/models/custom_admin_view.php +++ b/admin/models/custom_admin_view.php @@ -79,7 +79,7 @@ class ComponentbuilderModelCustom_admin_view extends JModelAdmin { if ($item = parent::getItem($pk)) { - if (!empty($item->params)) + if (!empty($item->params) && !is_array($item->params)) { // Convert the params field to an array. $registry = new Registry; @@ -95,12 +95,12 @@ class ComponentbuilderModelCustom_admin_view extends JModelAdmin $item->metadata = $registry->toArray(); } - if (!empty($item->custom_get)) + if (!empty($item->libraries)) { - // Convert the custom_get field to an array. - $custom_get = new Registry; - $custom_get->loadString($item->custom_get); - $item->custom_get = $custom_get->toArray(); + // Convert the libraries field to an array. + $libraries = new Registry; + $libraries->loadString($item->libraries); + $item->libraries = $libraries->toArray(); } if (!empty($item->custom_button)) @@ -111,6 +111,14 @@ class ComponentbuilderModelCustom_admin_view extends JModelAdmin $item->custom_button = $custom_button->toArray(); } + if (!empty($item->custom_get)) + { + // Convert the custom_get field to an array. + $custom_get = new Registry; + $custom_get->loadString($item->custom_get); + $item->custom_get = $custom_get->toArray(); + } + if (!empty($item->php_controller)) { // base64 Decode php_controller. @@ -915,17 +923,17 @@ class ComponentbuilderModelCustom_admin_view extends JModelAdmin $data['metadata'] = (string) $metadata; } - // Set the custom_get items to data. - if (isset($data['custom_get']) && is_array($data['custom_get'])) + // Set the libraries items to data. + if (isset($data['libraries']) && is_array($data['libraries'])) { - $custom_get = new JRegistry; - $custom_get->loadArray($data['custom_get']); - $data['custom_get'] = (string) $custom_get; + $libraries = new JRegistry; + $libraries->loadArray($data['libraries']); + $data['libraries'] = (string) $libraries; } - elseif (!isset($data['custom_get'])) + elseif (!isset($data['libraries'])) { - // Set the empty custom_get to data - $data['custom_get'] = ''; + // Set the empty libraries to data + $data['libraries'] = ''; } // Set the custom_button items to data. @@ -941,6 +949,19 @@ class ComponentbuilderModelCustom_admin_view extends JModelAdmin $data['custom_button'] = ''; } + // Set the custom_get items to data. + if (isset($data['custom_get']) && is_array($data['custom_get'])) + { + $custom_get = new JRegistry; + $custom_get->loadArray($data['custom_get']); + $data['custom_get'] = (string) $custom_get; + } + elseif (!isset($data['custom_get'])) + { + // Set the empty custom_get to data + $data['custom_get'] = ''; + } + // Set the php_controller string to base64 string. if (isset($data['php_controller'])) { diff --git a/admin/models/custom_code.php b/admin/models/custom_code.php index 74ee3fe32..074986b1a 100644 --- a/admin/models/custom_code.php +++ b/admin/models/custom_code.php @@ -79,7 +79,7 @@ class ComponentbuilderModelCustom_code extends JModelAdmin { if ($item = parent::getItem($pk)) { - if (!empty($item->params)) + if (!empty($item->params) && !is_array($item->params)) { // Convert the params field to an array. $registry = new Registry; diff --git a/admin/models/dynamic_get.php b/admin/models/dynamic_get.php index bb8b6bb43..17483f157 100644 --- a/admin/models/dynamic_get.php +++ b/admin/models/dynamic_get.php @@ -79,7 +79,7 @@ class ComponentbuilderModelDynamic_get extends JModelAdmin { if ($item = parent::getItem($pk)) { - if (!empty($item->params)) + if (!empty($item->params) && !is_array($item->params)) { // Convert the params field to an array. $registry = new Registry; diff --git a/admin/models/field.php b/admin/models/field.php index c8b932bbb..a057ede2a 100644 --- a/admin/models/field.php +++ b/admin/models/field.php @@ -79,7 +79,7 @@ class ComponentbuilderModelField extends JModelAdmin { if ($item = parent::getItem($pk)) { - if (!empty($item->params)) + if (!empty($item->params) && !is_array($item->params)) { // Convert the params field to an array. $registry = new Registry; diff --git a/admin/models/fields/adminviewsreadonly.php b/admin/models/fields/adminviewsreadonly.php new file mode 100644 index 000000000..ff5e67b1c --- /dev/null +++ b/admin/models/fields/adminviewsreadonly.php @@ -0,0 +1,170 @@ + + @github Joomla Component Builder + @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 the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Adminviewsreadonly Form Field class for the Componentbuilder component + */ +class JFormFieldAdminviewsreadonly extends JFormFieldList +{ + /** + * The adminviewsreadonly field type. + * + * @var string + */ + public $type = 'adminviewsreadonly'; + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $setButton = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($setButton === 'true') + { + $button = array(); + $script = array(); + $buttonName = $this->getAttribute('name'); + // get the input from url + $app = JFactory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referal if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + } + $user = JFactory::getUser(); + // only add if user allowed to create admin_view + if ($user->authorise('admin_view.create', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area. + { + // build Create button + $buttonNamee = trim($buttonName); + $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee); + $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee); + $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee); + $buttonNamee = ucfirst(strtolower($buttonNamee)); + $button[] = ' + '; + } + // only add if user allowed to edit admin_view + if (($buttonName === 'admin_view' || $buttonName === 'admin_views') && $user->authorise('admin_view.edit', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area. + { + // build edit button + $buttonNamee = trim($buttonName); + $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee); + $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee); + $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee); + $buttonNamee = ucfirst(strtolower($buttonNamee)); + $button[] = ''; + // build script + $script[] = " + jQuery(document).ready(function() { + jQuery('#adminForm').on('change', '#jform_".$buttonName."',function (e) { + e.preventDefault(); + var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val(); + ".$buttonName."Button(".$buttonName."Value); + }); + var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val(); + ".$buttonName."Button(".$buttonName."Value); + }); + function ".$buttonName."Button(value) { + if (value > 0) { + // hide the create button + jQuery('#".$buttonName."Create').hide(); + // show edit button + jQuery('#".$buttonName."Edit').show(); + var url = 'index.php?option=com_componentbuilder&view=admin_views&task=admin_view.edit&id='+value+'".$refJ."'; + jQuery('#".$buttonName."Edit').attr('href', url); + } else { + // show the create button + jQuery('#".$buttonName."Create').show(); + // hide edit button + jQuery('#".$buttonName."Edit').hide(); + } + }"; + } + // check if button was created for admin_view field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = JFactory::getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
' .$html . implode('',$button).'
'; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + public function getOptions() + { + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.system_name'),array('id','admin_view_system_name'))); + $query->from($db->quoteName('#__componentbuilder_admin_view', 'a')); + $query->order('a.system_name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = JHtml::_('select.option', '', 'Select an option'); + foreach($items as $item) + { + $options[] = JHtml::_('select.option', $item->id, $item->admin_view_system_name); + } + } + return $options; + } +} diff --git a/admin/models/fields/joomlacomponents.php b/admin/models/fields/joomlacomponents.php index 2401e1bc8..76db53a39 100644 --- a/admin/models/fields/joomlacomponents.php +++ b/admin/models/fields/joomlacomponents.php @@ -153,7 +153,6 @@ class JFormFieldJoomlacomponents extends JFormFieldList $query = $db->getQuery(true); $query->select($db->quoteName(array('a.id','a.system_name'),array('id','joomla_component_system_name'))); $query->from($db->quoteName('#__componentbuilder_joomla_component', 'a')); - $query->where($db->quoteName('a.published') . ' >= 1'); $query->order('a.system_name ASC'); $db->setQuery((string)$query); $items = $db->loadObjectList(); diff --git a/admin/models/fields/libconfigfield.php b/admin/models/fields/libconfigfield.php new file mode 100644 index 000000000..61674254b --- /dev/null +++ b/admin/models/fields/libconfigfield.php @@ -0,0 +1,206 @@ + + @github Joomla Component Builder + @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 the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Libconfigfield Form Field class for the Componentbuilder component + */ +class JFormFieldLibconfigfield extends JFormFieldList +{ + /** + * The libconfigfield field type. + * + * @var string + */ + public $type = 'libconfigfield'; + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $setButton = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($setButton === 'true') + { + $button = array(); + $script = array(); + $buttonName = $this->getAttribute('name'); + // get the input from url + $app = JFactory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referal if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + } + $user = JFactory::getUser(); + // only add if user allowed to create field + if ($user->authorise('field.create', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area. + { + // build Create button + $buttonNamee = trim($buttonName); + $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee); + $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee); + $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee); + $buttonNamee = ucfirst(strtolower($buttonNamee)); + $button[] = ' + '; + } + // only add if user allowed to edit field + if (($buttonName === 'field' || $buttonName === 'fields') && $user->authorise('field.edit', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area. + { + // build edit button + $buttonNamee = trim($buttonName); + $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee); + $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee); + $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee); + $buttonNamee = ucfirst(strtolower($buttonNamee)); + $button[] = ''; + // build script + $script[] = " + jQuery(document).ready(function() { + jQuery('#adminForm').on('change', '#jform_".$buttonName."',function (e) { + e.preventDefault(); + var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val(); + ".$buttonName."Button(".$buttonName."Value); + }); + var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val(); + ".$buttonName."Button(".$buttonName."Value); + }); + function ".$buttonName."Button(value) { + if (value > 0) { + // hide the create button + jQuery('#".$buttonName."Create').hide(); + // show edit button + jQuery('#".$buttonName."Edit').show(); + var url = 'index.php?option=com_componentbuilder&view=fields&task=field.edit&id='+value+'".$refJ."'; + jQuery('#".$buttonName."Edit').attr('href', url); + } else { + // show the create button + jQuery('#".$buttonName."Create').show(); + // hide edit button + jQuery('#".$buttonName."Edit').hide(); + } + }"; + } + // check if button was created for field field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = JFactory::getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
' .$html . implode('',$button).'
'; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + public function getOptions() + { + // load the db opbject + $db = JFactory::getDBO(); + // get the input from url + $jinput = JFactory::getApplication()->input; + // get the id + $ID = $jinput->getInt('id', 0); + // rest the fields ids + $fieldIds = array(); + if (is_numeric($ID) && $ID >= 1) + { + // get all the fields linked to the library config + if ($addconfig = ComponentbuilderHelper::getVar('library_config', (int) $ID, 'library', 'addconfig')) + { + if (ComponentbuilderHelper::checkJson($addconfig)) + { + $addconfig = json_decode($addconfig, true); + if (ComponentbuilderHelper::checkArray($addconfig)) + { + foreach($addconfig as $field) + { + if (isset($field['field'])) + { + $fieldIds[] = (int) $field['field']; + } + } + } + } + } + } + // check if we have ids, since we should not show any fields that are not part of this config + if (ComponentbuilderHelper::checkArray($fieldIds)) + { + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name'),array('id','name'))); + $query->from($db->quoteName('#__componentbuilder_field', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + // only load these fields + $query->where($db->quoteName('a.id') . ' IN (' . implode(',', $fieldIds) . ')'); + $query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = JHtml::_('select.option', '', 'Select an option'); + foreach($items as $item) + { + $options[] = JHtml::_('select.option', $item->id, $item->name); + } + return $options; + } + } + return array(JHtml::_('select.option', '', 'No config fields linked')); + } +} diff --git a/admin/models/fields/libraries.php b/admin/models/fields/libraries.php new file mode 100644 index 000000000..9eda09545 --- /dev/null +++ b/admin/models/fields/libraries.php @@ -0,0 +1,170 @@ + + @github Joomla Component Builder + @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 the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Libraries Form Field class for the Componentbuilder component + */ +class JFormFieldLibraries extends JFormFieldList +{ + /** + * The libraries field type. + * + * @var string + */ + public $type = 'libraries'; + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $setButton = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($setButton === 'true') + { + $button = array(); + $script = array(); + $buttonName = $this->getAttribute('name'); + // get the input from url + $app = JFactory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referal if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + } + $user = JFactory::getUser(); + // only add if user allowed to create library + if ($user->authorise('library.create', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area. + { + // build Create button + $buttonNamee = trim($buttonName); + $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee); + $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee); + $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee); + $buttonNamee = ucfirst(strtolower($buttonNamee)); + $button[] = ' + '; + } + // only add if user allowed to edit library + if (($buttonName === 'library' || $buttonName === 'libraries') && $user->authorise('library.edit', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area. + { + // build edit button + $buttonNamee = trim($buttonName); + $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee); + $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee); + $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee); + $buttonNamee = ucfirst(strtolower($buttonNamee)); + $button[] = ''; + // build script + $script[] = " + jQuery(document).ready(function() { + jQuery('#adminForm').on('change', '#jform_".$buttonName."',function (e) { + e.preventDefault(); + var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val(); + ".$buttonName."Button(".$buttonName."Value); + }); + var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val(); + ".$buttonName."Button(".$buttonName."Value); + }); + function ".$buttonName."Button(value) { + if (value > 0) { + // hide the create button + jQuery('#".$buttonName."Create').hide(); + // show edit button + jQuery('#".$buttonName."Edit').show(); + var url = 'index.php?option=com_componentbuilder&view=libraries&task=library.edit&id='+value+'".$refJ."'; + jQuery('#".$buttonName."Edit').attr('href', url); + } else { + // show the create button + jQuery('#".$buttonName."Create').show(); + // hide edit button + jQuery('#".$buttonName."Edit').hide(); + } + }"; + } + // check if button was created for library field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = JFactory::getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
' .$html . implode('',$button).'
'; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + public function getOptions() + { + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name'),array('id','libraries_name'))); + $query->from($db->quoteName('#__componentbuilder_library', 'a')); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + foreach($items as $item) + { + $options[] = JHtml::_('select.option', $item->id, $item->libraries_name); + } + } + return $options; + } +} diff --git a/admin/models/fields/libraryfiles.php b/admin/models/fields/libraryfiles.php new file mode 100644 index 000000000..747d71611 --- /dev/null +++ b/admin/models/fields/libraryfiles.php @@ -0,0 +1,171 @@ + + @github Joomla Component Builder + @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 the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Libraryfiles Form Field class for the Componentbuilder component + */ +class JFormFieldLibraryfiles extends JFormFieldList +{ + /** + * The libraryfiles field type. + * + * @var string + */ + public $type = 'libraryfiles'; + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $setButton = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($setButton === 'true') + { + $button = array(); + $script = array(); + $buttonName = $this->getAttribute('name'); + // get the input from url + $app = JFactory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referal if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + } + $user = JFactory::getUser(); + // only add if user allowed to create + if ($user->authorise('core.create', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area. + { + // build Create button + $buttonNamee = trim($buttonName); + $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee); + $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee); + $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee); + $buttonNamee = ucfirst(strtolower($buttonNamee)); + $button[] = ' + '; + } + // only add if user allowed to edit + if (($buttonName === '' || $buttonName === '') && $user->authorise('core.edit', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area. + { + // build edit button + $buttonNamee = trim($buttonName); + $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee); + $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee); + $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee); + $buttonNamee = ucfirst(strtolower($buttonNamee)); + $button[] = ''; + // build script + $script[] = " + jQuery(document).ready(function() { + jQuery('#adminForm').on('change', '#jform_".$buttonName."',function (e) { + e.preventDefault(); + var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val(); + ".$buttonName."Button(".$buttonName."Value); + }); + var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val(); + ".$buttonName."Button(".$buttonName."Value); + }); + function ".$buttonName."Button(value) { + if (value > 0) { + // hide the create button + jQuery('#".$buttonName."Create').hide(); + // show edit button + jQuery('#".$buttonName."Edit').show(); + var url = 'index.php?option=com_componentbuilder&view=&task=.edit&id='+value+'".$refJ."'; + jQuery('#".$buttonName."Edit').attr('href', url); + } else { + // show the create button + jQuery('#".$buttonName."Create').show(); + // hide edit button + jQuery('#".$buttonName."Edit').hide(); + } + }"; + } + // check if button was created for field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = JFactory::getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
' .$html . implode('',$button).'
'; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + public function getOptions() + { + // get the input from url + $jinput = JFactory::getApplication()->input; + // get the library id + $id = $jinput->getInt('id', 0); + // get custom the files + $files = ComponentbuilderHelper::getLibraryFiles($id); + // set the default + $options[] = JHtml::_('select.option', '', JText::_('COM_COMPONENTBUILDER_NO_FILES_LINKED')); + // now check if there are files in the folder + if (ComponentbuilderHelper::checkArray($files)) + { + $options = array(); + foreach ($files as $file => $name) + { + $options[] = JHtml::_('select.option', $file, $name); + } + } + return $options; + } +} diff --git a/admin/models/fields/libraryreadonly.php b/admin/models/fields/libraryreadonly.php new file mode 100644 index 000000000..71c7099b6 --- /dev/null +++ b/admin/models/fields/libraryreadonly.php @@ -0,0 +1,170 @@ + + @github Joomla Component Builder + @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 the list field type +jimport('joomla.form.helper'); +JFormHelper::loadFieldClass('list'); + +/** + * Libraryreadonly Form Field class for the Componentbuilder component + */ +class JFormFieldLibraryreadonly extends JFormFieldList +{ + /** + * The libraryreadonly field type. + * + * @var string + */ + public $type = 'libraryreadonly'; + /** + * Override to add new button + * + * @return string The field input markup. + * + * @since 3.2 + */ + protected function getInput() + { + // see if we should add buttons + $setButton = $this->getAttribute('button'); + // get html + $html = parent::getInput(); + // if true set button + if ($setButton === 'true') + { + $button = array(); + $script = array(); + $buttonName = $this->getAttribute('name'); + // get the input from url + $app = JFactory::getApplication(); + $jinput = $app->input; + // get the view name & id + $values = $jinput->getArray(array( + 'id' => 'int', + 'view' => 'word' + )); + // check if new item + $ref = ''; + $refJ = ''; + if (!is_null($values['id']) && strlen($values['view'])) + { + // only load referal if not new item. + $ref = '&ref=' . $values['view'] . '&refid=' . $values['id']; + $refJ = '&ref=' . $values['view'] . '&refid=' . $values['id']; + } + $user = JFactory::getUser(); + // only add if user allowed to create library + if ($user->authorise('library.create', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area. + { + // build Create button + $buttonNamee = trim($buttonName); + $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee); + $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee); + $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee); + $buttonNamee = ucfirst(strtolower($buttonNamee)); + $button[] = ' + '; + } + // only add if user allowed to edit library + if (($buttonName === 'library' || $buttonName === 'libraries') && $user->authorise('library.edit', 'com_componentbuilder') && $app->isAdmin()) // TODO for now only in admin area. + { + // build edit button + $buttonNamee = trim($buttonName); + $buttonNamee = preg_replace('/_+/', ' ', $buttonNamee); + $buttonNamee = preg_replace('/\s+/', ' ', $buttonNamee); + $buttonNamee = preg_replace("/[^A-Za-z ]/", '', $buttonNamee); + $buttonNamee = ucfirst(strtolower($buttonNamee)); + $button[] = ''; + // build script + $script[] = " + jQuery(document).ready(function() { + jQuery('#adminForm').on('change', '#jform_".$buttonName."',function (e) { + e.preventDefault(); + var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val(); + ".$buttonName."Button(".$buttonName."Value); + }); + var ".$buttonName."Value = jQuery('#jform_".$buttonName."').val(); + ".$buttonName."Button(".$buttonName."Value); + }); + function ".$buttonName."Button(value) { + if (value > 0) { + // hide the create button + jQuery('#".$buttonName."Create').hide(); + // show edit button + jQuery('#".$buttonName."Edit').show(); + var url = 'index.php?option=com_componentbuilder&view=libraries&task=library.edit&id='+value+'".$refJ."'; + jQuery('#".$buttonName."Edit').attr('href', url); + } else { + // show the create button + jQuery('#".$buttonName."Create').show(); + // hide edit button + jQuery('#".$buttonName."Edit').hide(); + } + }"; + } + // check if button was created for library field. + if (is_array($button) && count($button) > 0) + { + // Load the needed script. + $document = JFactory::getDocument(); + $document->addScriptDeclaration(implode(' ',$script)); + // return the button attached to input field. + return '
' .$html . implode('',$button).'
'; + } + } + return $html; + } + + /** + * Method to get a list of options for a list input. + * + * @return array An array of JHtml options. + */ + public function getOptions() + { + $db = JFactory::getDBO(); + $query = $db->getQuery(true); + $query->select($db->quoteName(array('a.id','a.name'),array('id','library_name'))); + $query->from($db->quoteName('#__componentbuilder_library', 'a')); + $query->order('a.name ASC'); + $db->setQuery((string)$query); + $items = $db->loadObjectList(); + $options = array(); + if ($items) + { + $options[] = JHtml::_('select.option', '', 'Select an option'); + foreach($items as $item) + { + $options[] = JHtml::_('select.option', $item->id, $item->library_name); + } + } + return $options; + } +} diff --git a/admin/models/fields/snippets.php b/admin/models/fields/snippets.php index e0495c20d..86f27c189 100644 --- a/admin/models/fields/snippets.php +++ b/admin/models/fields/snippets.php @@ -165,11 +165,11 @@ class JFormFieldSnippets extends JFormFieldList $options = array(); if ($items) { - $options[] = JHtml::_('select.option', '', 'Select an option'); foreach($items as $item) { - $lib = (ComponentbuilderHelper::checkString($item->library)) ? ' (' . $item->library . ')' :''; - $options[] = JHtml::_('select.option', $item->id, $item->type . ' - ' . $item->snippet_name . $lib ); + $lib = (isset($item->library) && ComponentbuilderHelper::checkString($item->library)) ? ' (' . $item->library . ')' :''; + $type = (isset($item->type) && ComponentbuilderHelper::checkString($item->type)) ? $item->type :JText::_('COM_COMPONENTBUILDER_NO_TYPE'); + $options[] = JHtml::_('select.option', $item->id, $type . ' - ' . $item->snippet_name . $lib ); } } return $options; diff --git a/admin/models/fieldtype.php b/admin/models/fieldtype.php index 592749075..b7a7378e4 100644 --- a/admin/models/fieldtype.php +++ b/admin/models/fieldtype.php @@ -79,7 +79,7 @@ class ComponentbuilderModelFieldtype extends JModelAdmin { if ($item = parent::getItem($pk)) { - if (!empty($item->params)) + if (!empty($item->params) && !is_array($item->params)) { // Convert the params field to an array. $registry = new Registry; @@ -139,7 +139,7 @@ class ComponentbuilderModelFieldtype extends JModelAdmin * * @return mixed An array of data items on success, false on failure. */ - public function getVzufields() + public function getVzwfields() { // Get the user object. $user = JFactory::getUser(); @@ -223,13 +223,13 @@ class ComponentbuilderModelFieldtype extends JModelAdmin foreach ($items as $nr => &$item) { // convert datatype - $item->datatype = $this->selectionTranslationVzufields($item->datatype, 'datatype'); + $item->datatype = $this->selectionTranslationVzwfields($item->datatype, 'datatype'); // convert indexes - $item->indexes = $this->selectionTranslationVzufields($item->indexes, 'indexes'); + $item->indexes = $this->selectionTranslationVzwfields($item->indexes, 'indexes'); // convert null_switch - $item->null_switch = $this->selectionTranslationVzufields($item->null_switch, 'null_switch'); + $item->null_switch = $this->selectionTranslationVzwfields($item->null_switch, 'null_switch'); // convert store - $item->store = $this->selectionTranslationVzufields($item->store, 'store'); + $item->store = $this->selectionTranslationVzwfields($item->store, 'store'); } } @@ -243,7 +243,7 @@ class ComponentbuilderModelFieldtype extends JModelAdmin * * @return translatable string */ - public function selectionTranslationVzufields($value,$name) + public function selectionTranslationVzwfields($value,$name) { // Array of datatype language strings if ($name === 'datatype') diff --git a/admin/models/forms/admin_fields.xml b/admin/models/forms/admin_fields.xml index 032492169..248a5bd94 100644 --- a/admin/models/forms/admin_fields.xml +++ b/admin/models/forms/admin_fields.xml @@ -90,9 +90,9 @@ filter="unset" /> - + - + - + - + 0 && libraries.length > 0){ + var request = 'token='+token+'&libraries='+JSON.stringify(libraries); + } + return jQuery.ajax({ + type: 'GET', + url: getUrl, + dataType: 'jsonp', + data: request, + jsonp: 'callback' + }); +} +function getSnippets(){ + jQuery("#loading").show(); + // clear the selection + jQuery('#jform_snippet').find('option').remove().end(); + jQuery('#jform_snippet').trigger('liszt:updated'); + // get country value if set + var libraries = jQuery("#jform_libraries").val(); + if (libraries) { + getSnippets_server(libraries).done(function(result) { + setSnippets(result); + jQuery("#loading").hide(); + if (typeof snippetButton !== 'undefined') { + // ensure button is correct + var snippet = jQuery('#jform_snippet').val(); + snippetButton(snippet); + } + }); + } + else + { + // load all snippets in none is selected + setSnippets(snippetIds); + jQuery("#loading").hide(); + } +} +function setSnippets(array){ + if (array) { + jQuery('#jform_snippet').append(''); + jQuery.each( array, function( i, id ) { + if (id in snippets) { + jQuery('#jform_snippet').append(''); + } + if (id == snippet) { + jQuery('#jform_snippet').val(id); + } + }); + } else { + jQuery('#jform_snippet').append(''); + } + jQuery('#jform_snippet').trigger('liszt:updated'); } diff --git a/admin/models/forms/custom_admin_view.xml b/admin/models/forms/custom_admin_view.xml index 65d36a555..10fbf7d69 100644 --- a/admin/models/forms/custom_admin_view.xml +++ b/admin/models/forms/custom_admin_view.xml @@ -153,11 +153,24 @@ type="snippets" name="snippet" label="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_SNIPPET_LABEL" + description="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_SNIPPET_DESCRIPTION" class="list_class" multiple="false" required="false" button="true" /> + + + + + + COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NO - - - - - - COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NO - - - - - - - + @@ -226,13 +213,23 @@ - - - + + + @@ -255,6 +252,22 @@ hint="COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_PHP_CONTROLLER_HINT" required="false" /> + + + + + + + + COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEW_NO - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 && libraries.length > 0){ + var request = 'token='+token+'&libraries='+JSON.stringify(libraries); + } + return jQuery.ajax({ + type: 'GET', + url: getUrl, + dataType: 'jsonp', + data: request, + jsonp: 'callback' + }); +} +function getSnippets(){ + jQuery("#loading").show(); + // clear the selection + jQuery('#jform_snippet').find('option').remove().end(); + jQuery('#jform_snippet').trigger('liszt:updated'); + // get country value if set + var libraries = jQuery("#jform_libraries").val(); + if (libraries) { + getSnippets_server(libraries).done(function(result) { + setSnippets(result); + jQuery("#loading").hide(); + if (typeof snippetButton !== 'undefined') { + // ensure button is correct + var snippet = jQuery('#jform_snippet').val(); + snippetButton(snippet); + } + }); + } + else + { + // load all snippets in none is selected + setSnippets(snippetIds); + jQuery("#loading").hide(); + } +} +function setSnippets(array){ + if (array) { + jQuery('#jform_snippet').append(''); + jQuery.each( array, function( i, id ) { + if (id in snippets) { + jQuery('#jform_snippet').append(''); + } + if (id == snippet) { + jQuery('#jform_snippet').val(id); + } + }); + } else { + jQuery('#jform_snippet').append(''); + } + jQuery('#jform_snippet').trigger('liszt:updated'); } diff --git a/admin/models/forms/layout.xml b/admin/models/forms/layout.xml index 420513859..0b3baebec 100644 --- a/admin/models/forms/layout.xml +++ b/admin/models/forms/layout.xml @@ -150,11 +150,26 @@ type="snippets" name="snippet" label="COM_COMPONENTBUILDER_LAYOUT_SNIPPET_LABEL" + description="COM_COMPONENTBUILDER_LAYOUT_SNIPPET_DESCRIPTION" class="list_class" multiple="false" required="false" button="true" /> + + + + COM_COMPONENTBUILDER_LAYOUT_NO - + + + - - - - + + - - + + 0 && type.length > 0 && size > 0){ + var request = 'token='+token+'&type='+type+'&size='+size; + } + return jQuery.ajax({ + type: 'GET', + url: getUrl, + dataType: 'jsonp', + data: request, + jsonp: 'callback' + }); +} +function addButtonID(type, where, size){ + addButtonID_server(type, size).done(function(result) { + if(result){ + if (2 == size) { + jQuery('#'+where).html(result); + } else { + addData(result, '#jform_'+where); + } + } + }); +} + +function addButton_server(type){ + var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.getButton&format=json&vdm="+vastDevMod); + if(token.length > 0 && type.length > 0){ + var request = 'token='+token+'&type='+type; + } + return jQuery.ajax({ + type: 'GET', + url: getUrl, + dataType: 'jsonp', + data: request, + jsonp: 'callback' + }); +} +function addButton(type,where){ + addButton_server(type).done(function(result) { + if(result){ + addData(result,'#jform_'+where); + } + }) +} + +function getAjaxDisplay(type){ + getAjaxDisplay_server(type).done(function(result) { + if(result){ + jQuery('#display_'+type).html(result); + } + // set button + addButtonID(type,'header_'+type+'_buttons', 2); // <-- little edit button + }); +} + +function getAjaxDisplay_server(type){ + var getUrl = "index.php?option=com_componentbuilder&task=ajax.getAjaxDisplay&format=json&vdm="+vastDevMod; + if(token.length > 0 && type.length > 0){ + var request = 'token='+token+'&type=' + type; + } + return jQuery.ajax({ + type: 'GET', + url: getUrl, + dataType: 'jsonp', + data: request, + jsonp: 'callback' + }); +} + +function getFieldSelectOptions_server(fieldId){ + var getUrl = "index.php?option=com_componentbuilder&task=ajax.fieldSelectOptions&format=json"; + if(token.length > 0 && fieldId > 0){ + var request = 'token='+token+'&id='+fieldId; + } + return jQuery.ajax({ + type: 'GET', + url: getUrl, + dataType: 'jsonp', + data: request, + jsonp: 'callback' + }); +} + +function getFieldSelectOptions(fieldKey){ + // first check if the field is set + if(jQuery("#jform_addconditions__addconditions"+fieldKey+"__option_field").length) { + var fieldId = jQuery("#jform_addconditions__addconditions"+fieldKey+"__option_field option:selected").val(); + getFieldSelectOptions_server(fieldId).done(function(result) { + if(result){ + jQuery('textarea#jform_addconditions__addconditions'+fieldKey+'__field_options').val(result); + } + else + { + jQuery('textarea#jform_addconditions__addconditions'+fieldKey+'__field_options').val(''); + } + }); + } +} diff --git a/admin/models/forms/library.xml b/admin/models/forms/library.xml index 36633167e..7ea100d37 100644 --- a/admin/models/forms/library.xml +++ b/admin/models/forms/library.xml @@ -122,6 +122,189 @@ message="COM_COMPONENTBUILDER_LIBRARY_DESCRIPTION_MESSAGE" hint="COM_COMPONENTBUILDER_LIBRARY_DESCRIPTION_HINT" /> + + + + + + + + + + + + + + +