From 19d4d77305692d55702d81b8bed266b00bbeef53 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Sun, 3 Dec 2017 20:09:04 +0200 Subject: [PATCH] Improved the get snippets area to load one library at a time. started on the adaptation of the compiler that is needed for the new libraries --- README.md | 10 +- admin/README.txt | 10 +- admin/access.xml | 2 + admin/controllers/get_snippets.php | 19 +- admin/controllers/libraries.php | 11 +- admin/helpers/compiler/a_Get.php | 247 +++++++++- admin/helpers/compiler/c_Fields.php | 129 +++--- .../en-GB/en-GB.com_componentbuilder.ini | 30 +- .../en-GB/en-GB.com_componentbuilder.sys.ini | 4 + admin/layouts/fieldtype/fields_fullwidth.php | 2 +- .../ftp/linked_components_fullwidth.php | 2 +- admin/layouts/library/behaviour_above.php | 3 +- admin/layouts/library/behaviour_left.php | 54 +++ admin/models/ajax.php | 83 +++- admin/models/custom_admin_view.php | 3 + admin/models/fields/librariesx.php | 178 ++++++++ admin/models/fields/library.php | 3 +- admin/models/fieldtype.php | 12 +- admin/models/forms/component_config.xml | 6 +- admin/models/forms/field.js | 430 +++++++++--------- admin/models/forms/help_document.js | 238 +++++----- admin/models/forms/library.js | 227 ++++++++- admin/models/forms/library.xml | 85 ++-- admin/models/forms/library_config.xml | 6 +- admin/models/ftp.php | 2 +- admin/models/layout.php | 3 + admin/models/libraries.php | 41 +- admin/models/library.php | 32 +- admin/models/site_view.php | 3 + admin/models/template.php | 3 + admin/sql/install.mysql.utf8.sql | 24 +- admin/sql/updates/mysql/2.6.5.sql | 22 +- admin/views/field/tmpl/edit.php | 132 +++--- admin/views/fieldtype/view.html.php | 2 +- admin/views/ftp/view.html.php | 2 +- admin/views/get_snippets/tmpl/default.php | 30 +- admin/views/get_snippets/view.html.php | 219 +++++++-- admin/views/help_document/tmpl/edit.php | 54 +-- admin/views/libraries/tmpl/default_body.php | 3 + admin/views/libraries/tmpl/default_foot.php | 2 +- admin/views/libraries/tmpl/default_head.php | 3 + admin/views/libraries/view.html.php | 128 +++++- admin/views/library/tmpl/edit.php | 44 +- componentbuilder.xml | 2 +- script.php | 8 +- 45 files changed, 1841 insertions(+), 712 deletions(-) create mode 100644 admin/layouts/library/behaviour_left.php create mode 100644 admin/models/fields/librariesx.php diff --git a/README.md b/README.md index c6024ed39..8f9d9de8e 100644 --- a/README.md +++ b/README.md @@ -111,12 +111,12 @@ 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*: 26th November, 2017 ++ *Last Build*: 3rd December, 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*: **178893** -+ *File count*: **1139** ++ *Line count*: **179770** ++ *File count*: **1141** + *Folder count*: **184** > This **component** was build with a Joomla [Automated Component Builder](http://vdm.bz/component-builder). @@ -126,5 +126,5 @@ Component Builder is mapped as a component in itself on my local development env Come on buy me a coffee :) * PayPal: [paypal.me/payvdm](https://www.paypal.me/payvdm) - * Bitcoin: 1FLxiT6wyxgZ3boeviLkYJ1DRpp41uzpxa - * Ethereum: 0x243392daa3c9c8bc841fcacf7c7f72541cb16823 \ No newline at end of file + * Bitcoin: 18vURxYpPFjvNk8BnUy1ovCAyQmY3MzkSf + * Ethereum: 0x9548144662b47327c954f3e214edb96662d51218 \ No newline at end of file diff --git a/admin/README.txt b/admin/README.txt index c6024ed39..8f9d9de8e 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -111,12 +111,12 @@ 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*: 26th November, 2017 ++ *Last Build*: 3rd December, 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*: **178893** -+ *File count*: **1139** ++ *Line count*: **179770** ++ *File count*: **1141** + *Folder count*: **184** > This **component** was build with a Joomla [Automated Component Builder](http://vdm.bz/component-builder). @@ -126,5 +126,5 @@ Component Builder is mapped as a component in itself on my local development env Come on buy me a coffee :) * PayPal: [paypal.me/payvdm](https://www.paypal.me/payvdm) - * Bitcoin: 1FLxiT6wyxgZ3boeviLkYJ1DRpp41uzpxa - * Ethereum: 0x243392daa3c9c8bc841fcacf7c7f72541cb16823 \ No newline at end of file + * Bitcoin: 18vURxYpPFjvNk8BnUy1ovCAyQmY3MzkSf + * Ethereum: 0x9548144662b47327c954f3e214edb96662d51218 \ No newline at end of file diff --git a/admin/access.xml b/admin/access.xml index 09ade1bd2..9224fdb5d 100644 --- a/admin/access.xml +++ b/admin/access.xml @@ -229,6 +229,7 @@ + @@ -325,6 +326,7 @@ + diff --git a/admin/controllers/get_snippets.php b/admin/controllers/get_snippets.php index 1d65b8189..57d4df20a 100644 --- a/admin/controllers/get_snippets.php +++ b/admin/controllers/get_snippets.php @@ -52,11 +52,20 @@ class ComponentbuilderControllerGet_snippets extends JControllerAdmin return; } + public function openLibraries() + { + // Check for request forgeries + JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); + // redirect to the libraries + $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=libraries', false)); + return; + } + public function openSnippets() { // Check for request forgeries JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the snippets admin view + // redirect to the snippets $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=snippets', false)); return; } @@ -65,7 +74,7 @@ class ComponentbuilderControllerGet_snippets extends JControllerAdmin { // Check for request forgeries JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the snippets admin view + // redirect to the site views $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=site_views', false)); return; } @@ -74,7 +83,7 @@ class ComponentbuilderControllerGet_snippets extends JControllerAdmin { // Check for request forgeries JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the snippets admin view + // redirect to the custom admin views $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=custom_admin_views', false)); return; } @@ -83,7 +92,7 @@ class ComponentbuilderControllerGet_snippets extends JControllerAdmin { // Check for request forgeries JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the snippets admin view + // redirect to the templates $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=templates', false)); return; } @@ -92,7 +101,7 @@ class ComponentbuilderControllerGet_snippets extends JControllerAdmin { // Check for request forgeries JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); - // redirect to the snippets admin view + // redirect to the layouts $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=layouts', false)); return; } diff --git a/admin/controllers/libraries.php b/admin/controllers/libraries.php index 0e89c427e..6cb108050 100644 --- a/admin/controllers/libraries.php +++ b/admin/controllers/libraries.php @@ -44,5 +44,14 @@ class ComponentbuilderControllerLibraries extends JControllerAdmin $model = parent::getModel($name, $prefix, array('ignore_request' => true)); return $model; - } + } + + public function getSnippets() + { + // Check for request forgeries + JSession::checkToken() or die(JText::_('JINVALID_TOKEN')); + // redirect to the import snippets custom admin view + $this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=get_snippets', false)); + return; + } } diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index 881a9bf6c..f70e3d972 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -497,6 +497,20 @@ class Get * @var array */ public $updateSQL = array(); + + /** + * The Library Manager + * + * @var array + */ + public $libManager = array(); + + /** + * The Libraries + * + * @var array + */ + public $libraries = array(); /*** * Constructor @@ -855,7 +869,7 @@ class Get unset($component->addcustom_admin_views); } - // ser the config data + // set the config data $component->addconfig = (isset($component->addconfig) && ComponentbuilderHelper::checkJson($component->addconfig)) ? json_decode($component->addconfig,true):null; if (ComponentbuilderHelper::checkArray($component->addconfig)) { @@ -1717,6 +1731,45 @@ class Get // } } } + // load the library + if (!isset($this->libManager[$this->target]) || !isset($this->libManager[$this->target][$view->code])) + { + // prep array + if (!isset($this->libManager[$this->target])) + { + $this->libManager[$this->target] = array(); + } + if (!isset($this->libManager[$this->target][$view->code])) + { + $this->libManager[$this->target][$view->code] = array(); + } + // make sure json become array + if (ComponentbuilderHelper::checkJson($view->libraries)) + { + $view->libraries = json_decode($view->libraries, true); + } + // if we have an array add it + if (ComponentbuilderHelper::checkArray($view->libraries)) + { + foreach ($view->libraries as $library) + { + if (!isset($this->libManager[$this->target][$view->code][$library])) + { + if ($this->getLibrary($library)) + { + $this->libManager[$this->target][$view->code][$library] = true; + } + } + } + } + elseif (is_numeric($view->libraries) && !isset($this->libManager[$this->target][$view->code][(int) $view->libraries])) + { + if ($this->getLibrary((int) $view->libraries)) + { + $this->libManager[$this->target][$view->code][(int) $view->libraries] = true; + } + } + } // add_Ajax for this view if (isset($view->add_php_ajax) && $view->add_php_ajax == 1) { @@ -2726,7 +2779,7 @@ class Get * @return array The data found with the alias * */ - public function getDataWithAlias($n_ame,$table,$view) + public function getDataWithAlias($n_ame, $table, $view) { // Create a new query object. $query = $this->db->getQuery(true); @@ -2789,12 +2842,200 @@ class Get $this->getModule[$this->target][$view] = true; } } + // load the library + if (!isset($this->libManager[$this->target]) || !isset($this->libManager[$this->target][$view])) + { + // prep array + if (!isset($this->libManager[$this->target])) + { + $this->libManager[$this->target] = array(); + } + if (!isset($this->libManager[$this->target][$view])) + { + $this->libManager[$this->target][$view] = array(); + } + // make sure json become array + if (ComponentbuilderHelper::checkJson($row->libraries)) + { + $row->libraries = json_decode($row->libraries, true); + } + // if we have an array add it + if (ComponentbuilderHelper::checkArray($row->libraries)) + { + foreach ($row->libraries as $library) + { + if (!isset($this->libManager[$this->target][$view][$library])) + { + if ($this->getLibrary($library)) + { + $this->libManager[$this->target][$view][$library] = true; + } + } + } + } + elseif (is_numeric($row->libraries) && !isset($this->libManager[$this->target][$view][(int) $row->libraries])) + { + if ($this->getLibrary((int) $row->libraries)) + { + $this->libManager[$this->target][$view][(int) $row->libraries] = true; + } + } + } return array('id' => $row->id, 'html' => $contnent, 'php_view' => $php_view); } } return false; } + /** + * Get Library Data and store globaly + * + * @param string $id the library id + * + * @return bool true on success + * + */ + protected function getLibrary($id) + { + // check if the lib has already been set + if (!isset($this->libraries[$id])) + { + $query = $this->db->getQuery(true); + + $query->select('a.*'); + $query->select( + $this->db->quoteName( + array( + 'a.id', + 'a.name', + 'a.how', + 'a.type', + 'a.addconditions', + 'b.addconfig', + 'c.addfiles', + 'c.addfolders', + 'c.addurls', + 'a.php_preparedocument', + 'a.php_setdocument' + ), + array( + 'id', + 'name', + 'how', + 'type', + 'addconditions', + 'addconfig', + 'addfiles', + 'addfolders', + 'addurls', + 'php_preparedocument', + 'php_setdocument' + ) + ) + ); + // from these tables + $query->from('#__componentbuilder_library AS a'); + $query->join('LEFT', $this->db->quoteName('#__componentbuilder_library_config', 'b') . ' ON (' . $this->db->quoteName('a.id') . ' = ' . $this->db->quoteName('b.library') . ')'); + $query->join('LEFT', $this->db->quoteName('#__componentbuilder_library_files_folders_urls', 'c') . ' ON (' . $this->db->quoteName('a.id') . ' = ' . $this->db->quoteName('c.library') . ')'); + $query->where($this->db->quoteName('a.id') . ' = '. (int) $id); + + // Reset the query using our newly populated query object. + $this->db->setQuery($query); + + // Load the results as a list of stdClass objects + $library = $this->db->loadObject(); + + // check if this lib has dynamic behaviour + if ($library->how > 0) + { + // unset original value + unset($library->addconfig); + + // set the addfolders data + $library->addfolders = (isset($library->addfolders) && ComponentbuilderHelper::checkJson($library->addfolders)) ? json_decode($library->addfolders,true):null; + if (ComponentbuilderHelper::checkArray($library->addfolders)) + { + $library->folders = array_values($library->addfolders); + } + unset($library->addfolders); + + // set the addfiles data + $library->addfiles = (isset($library->addfiles) && ComponentbuilderHelper::checkJson($library->addfiles)) ? json_decode($library->addfiles,true):null; + if (ComponentbuilderHelper::checkArray($library->addfiles)) + { + $library->files = array_values($library->addfiles); + } + unset($library->addfiles); + + // set the addurls data + $library->addurls = (isset($library->addurls) && ComponentbuilderHelper::checkJson($library->addurls)) ? json_decode($library->addurls,true):null; + if (ComponentbuilderHelper::checkArray($library->addurls)) + { + $library->urls = array_values($library->addurls); + } + unset($library->addurls); + + // add config fields only if needed + if ($library->how > 1) + { + // set the config data + $library->addconfig = (isset($library->addconfig) && ComponentbuilderHelper::checkJson($library->addconfig)) ? json_decode($library->addconfig,true):null; + if (ComponentbuilderHelper::checkArray($library->addconfig)) + { + $library->config = array_map(function($array) { + $array['alias'] = 0; + $array['title'] = 0; + $array['settings'] = $this->getFieldData($array['field']); + return $array; + }, array_values($library->addconfig)); + } + } + + // if this lib is controlled by custom script + if (3 == $library->how) + { + // set Needed PHP + $phpMethods = array('preparedocument', 'setdocument'); + foreach ($phpMethods as $method) + { + if (isset($library->{'php_'.$method}) && ComponentbuilderHelper::checkString($library->{'php_'.$method})) + { + $library->{$method} = $this->setDynamicValues(base64_decode($library->{'php_'.$method})); + } + } + } + // if this lib is controlled by conditions + elseif (2 == $library->how) + { + // set the addconditions data + $library->addconditions = (isset($library->addconditions) && ComponentbuilderHelper::checkJson($library->addconditions)) ? json_decode($library->addconditions,true):null; + if (ComponentbuilderHelper::checkArray($library->addconditions)) + { + $library->conditions = array_values($library->addconditions); + } + } + // if this lib is always being added + else + { + + } + unset($library->php_preparedocument); + unset($library->php_setdocument); + unset($library->addconditions); + } + else + { + $this->libraries[$id] = false; + } + } + // if set return + if (isset($this->libraries[$id])) + { + return $this->libraries[$id]; + } + return false; + } + /** * Set Language Place Holders * @@ -3233,7 +3474,7 @@ class Get } /** - * Check for getModules script + * Check for get Google Chart script * * @param string $content The content to check * diff --git a/admin/helpers/compiler/c_Fields.php b/admin/helpers/compiler/c_Fields.php index 45e01d1bf..16a8a2efa 100644 --- a/admin/helpers/compiler/c_Fields.php +++ b/admin/helpers/compiler/c_Fields.php @@ -1048,83 +1048,92 @@ class Fields extends Structure $fieldsSet = array(); foreach ($fieldAttributes as $property => $value) { - if ($property != 'fields') + if ($property != 'fields' && $property != 'formsource') { $fieldSet .= PHP_EOL."\t\t\t" . $property . '="' . $value . '"'; } } - $fieldSet .= ">"; - $fieldSet .= PHP_EOL."\t\t\t" . '"; + $fieldSet .= PHP_EOL."\t\t"; } - $fieldSet .= PHP_EOL."\t\t\t"; - $fieldSet .= PHP_EOL."\t\t"; } } elseif ($setType === 'custom') @@ -1419,7 +1428,7 @@ class Fields extends Structure $name = $this->setPlaceholders($xmlValue, $placeholders); } } - elseif ($property['name'] === 'extension' || $property['name'] === 'directory') + elseif ($property['name'] === 'extension' || $property['name'] === 'directory' || $property['name'] === 'formsource') { $xmlValue = ComponentbuilderHelper::getBetween($field['settings']->xml, $property['name'] . '="', '"'); // replace the placeholders diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.ini b/admin/language/en-GB/en-GB.com_componentbuilder.ini index d2f945560..b96d3898f 100644 --- a/admin/language/en-GB/en-GB.com_componentbuilder.ini +++ b/admin/language/en-GB/en-GB.com_componentbuilder.ini @@ -186,7 +186,7 @@ COM_COMPONENTBUILDER_ADMIN_FIELDS_MODIFIED_DATE_DESC="The date this Admin Fields COM_COMPONENTBUILDER_ADMIN_FIELDS_MODIFIED_DATE_LABEL="Modified Date" COM_COMPONENTBUILDER_ADMIN_FIELDS_NEW="A New Admin Fields" COM_COMPONENTBUILDER_ADMIN_FIELDS_NONE="None" -COM_COMPONENTBUILDER_ADMIN_FIELDS_NOTE_ON_VIEWS_DESCRIPTION="id, asset_id, state, access, ordering, created_by, date_created, modified_by, date_modified, checked_out, checked_out_time, version, hits, metakey, metadesc, metadata (you don't need to add them again)
For more help please watch this tutorial." +COM_COMPONENTBUILDER_ADMIN_FIELDS_NOTE_ON_VIEWS_DESCRIPTION="id, asset_id, state, access, ordering, created_by, created, modified_by, modified, checked_out, checked_out_time, version, hits, metakey, metadesc, metadata (you don't need to add them again)
For more help please watch this tutorial." COM_COMPONENTBUILDER_ADMIN_FIELDS_NOTE_ON_VIEWS_LABEL="The following fields are added by default to all views." COM_COMPONENTBUILDER_ADMIN_FIELDS_ORDERING_LABEL="Ordering" COM_COMPONENTBUILDER_ADMIN_FIELDS_ORDER_EDIT_DESCRIPTION="Order in relation to tab & alignment of admin and site." @@ -878,6 +878,7 @@ COM_COMPONENTBUILDER_AUTHOR_EMAIL="Author Email" COM_COMPONENTBUILDER_AUTHOR_NAME="Author Name" COM_COMPONENTBUILDER_AUTHOR_WEBSITE="Author Website" COM_COMPONENTBUILDER_AUTO_CHECKIN="Auto Check-in" +COM_COMPONENTBUILDER_AVAILABLE_LIBRARIES="Available Libraries" COM_COMPONENTBUILDER_A_FEW_CLOSED_ISSUES_FROM_GITHUB_IS_LOADING="A few closed issues from Github is loading" COM_COMPONENTBUILDER_A_FEW_OPEN_ISSUES_FROM_GITHUB_IS_LOADING="A few open issues from Github is loading" COM_COMPONENTBUILDER_BACK="Back" @@ -885,6 +886,7 @@ COM_COMPONENTBUILDER_BACKUP="Backup" COM_COMPONENTBUILDER_BACKUP_FAILED_PLEASE_TRY_AGAIN_IF_THE_ERROR_CONTINUE_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR="Backup failed, please try again. If the error continue, please contact your system administrator." COM_COMPONENTBUILDER_BACKUP_LOCAL_DATA_FIRST="Backup Local Data First" COM_COMPONENTBUILDER_BACKUP_WAS_DONE_SUCCESSFULLY="Backup was done successfully" +COM_COMPONENTBUILDER_BACK_TO_LIBRARIES="Back to Libraries" COM_COMPONENTBUILDER_BASIC_METHOD="Basic Method" COM_COMPONENTBUILDER_BASIC_TUTORIAL_ON_GIT_BSB="Basic Tutorial on git: %s" COM_COMPONENTBUILDER_BCUSTOM_FILESB_NOT_MOVE_TO_CORRECT_LOCATION="Custom files not move to correct location!" @@ -1584,7 +1586,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="Library" +COM_COMPONENTBUILDER_COMPONENT_CONFIG_TABNAME_HINT="Global" 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" @@ -3803,6 +3805,7 @@ COM_COMPONENTBUILDER_FTP_VERSION_DESC="A count of the number of times this FTP h COM_COMPONENTBUILDER_FTP_VERSION_LABEL="Revision" COM_COMPONENTBUILDER_FULL_WIDTH_IN_TAB="Full Width in Tab" COM_COMPONENTBUILDER_GENERAL_OVERVIEW_OF_HOW_THINGS_WORK_BSB="General overview of how things work: %s" +COM_COMPONENTBUILDER_GETTING_AVAILABLE_LIBRARIES="Getting available libraries" COM_COMPONENTBUILDER_GET_ALL_NEW_SNIPPETS="Get All New Snippets" COM_COMPONENTBUILDER_GET_AN_ACCOUNT_WITH_GITHUB_BSB="Get an Account with gitHub: %s" COM_COMPONENTBUILDER_GET_SNIPPET="Get snippet" @@ -3814,6 +3817,8 @@ COM_COMPONENTBUILDER_GET_SNIPPETS_CUSTOM_ADMIN_VIEWS_BUTTON_ACCESS_DESC=" Allows COM_COMPONENTBUILDER_GET_SNIPPETS_DESC="The compiler" COM_COMPONENTBUILDER_GET_SNIPPETS_LAYOUTS_BUTTON_ACCESS="Get Snippets Layouts Button Access" COM_COMPONENTBUILDER_GET_SNIPPETS_LAYOUTS_BUTTON_ACCESS_DESC=" Allows the users in this group to access the layouts button." +COM_COMPONENTBUILDER_GET_SNIPPETS_LIBRARIES_BUTTON_ACCESS="Get Snippets Libraries Button Access" +COM_COMPONENTBUILDER_GET_SNIPPETS_LIBRARIES_BUTTON_ACCESS_DESC=" Allows the users in this group to access the libraries button." COM_COMPONENTBUILDER_GET_SNIPPETS_SITE_VIEWS_BUTTON_ACCESS="Get Snippets Site Views Button Access" COM_COMPONENTBUILDER_GET_SNIPPETS_SITE_VIEWS_BUTTON_ACCESS_DESC=" Allows the users in this group to access the site views button." COM_COMPONENTBUILDER_GET_SNIPPETS_SNIPPETS_BUTTON_ACCESS="Get Snippets Snippets Button Access" @@ -4312,8 +4317,8 @@ Project duration: **###projectWeekTime### weeks** or **###projectMonthTime### mo
If you want to support this project, please consider donating:
* PayPal: [paypal.me/payvdm](https://www.paypal.me/payvdm)
- * Bitcoin: 1FLxiT6wyxgZ3boeviLkYJ1DRpp41uzpxa
- * Ethereum: 0x243392daa3c9c8bc841fcacf7c7f72541cb16823 + * Bitcoin: 18vURxYpPFjvNk8BnUy1ovCAyQmY3MzkSf
+ * Ethereum: 0x9548144662b47327c954f3e214edb96662d51218 " COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NOTE_README_LABEL="Demo README (with all place-holders)" COM_COMPONENTBUILDER_JOOMLA_COMPONENT_NOTE_UPDATE_SERVER_NOTE_FTP_DESCRIPTION="During compilation the file will be moved to the FTP folder. You still need to point the above update server url to the xml file on your FTP server for it to work correctly." @@ -4857,8 +4862,8 @@ COM_COMPONENTBUILDER_LIBRARY_ADDCONDITIONS_DESCRIPTION="Conditional setup for th COM_COMPONENTBUILDER_LIBRARY_ADDCONDITIONS_LABEL="Conditions" COM_COMPONENTBUILDER_LIBRARY_ALWAYS_ADD="Always Add" COM_COMPONENTBUILDER_LIBRARY_ANY_SELECTION_ONLY_FOUR_LISTRADIOCHECKBOXESDYNAMIC_LIST="Any Selection (only 4 list/radio/checkboxes/dynamic_list)" -COM_COMPONENTBUILDER_LIBRARY_ASC="Library (Asc)" COM_COMPONENTBUILDER_LIBRARY_BEHAVIOUR="Behaviour" +COM_COMPONENTBUILDER_LIBRARY_BUNDLE="Bundle" COM_COMPONENTBUILDER_LIBRARY_CHAIN="Chain" COM_COMPONENTBUILDER_LIBRARY_CONDITIONS="Conditions" COM_COMPONENTBUILDER_LIBRARY_CONFIG="Library Config" @@ -4892,7 +4897,7 @@ COM_COMPONENTBUILDER_LIBRARY_CONFIG_PUBLISHING="Publishing" COM_COMPONENTBUILDER_LIBRARY_CONFIG_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Library Config to customise the alias." COM_COMPONENTBUILDER_LIBRARY_CONFIG_STATUS="Status" COM_COMPONENTBUILDER_LIBRARY_CONFIG_TABNAME_DESCRIPTION="The name of the tab this field belongs to." -COM_COMPONENTBUILDER_LIBRARY_CONFIG_TABNAME_HINT="Library" +COM_COMPONENTBUILDER_LIBRARY_CONFIG_TABNAME_HINT="Global" COM_COMPONENTBUILDER_LIBRARY_CONFIG_TABNAME_LABEL="Tab Name" COM_COMPONENTBUILDER_LIBRARY_CONFIG_TABNAME_MESSAGE="Error! Please add tab name here." COM_COMPONENTBUILDER_LIBRARY_CONFIG_TWEAKS="Tweaks" @@ -4903,7 +4908,6 @@ COM_COMPONENTBUILDER_LIBRARY_CREATED_BY_LABEL="Created By" COM_COMPONENTBUILDER_LIBRARY_CREATED_DATE_DESC="The date this Library was created." COM_COMPONENTBUILDER_LIBRARY_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_LIBRARY_CUSTOM_SCRIPT="Custom Script" -COM_COMPONENTBUILDER_LIBRARY_DESC="Library (Desc)" COM_COMPONENTBUILDER_LIBRARY_DESCRIPTION="Description" COM_COMPONENTBUILDER_LIBRARY_DESCRIPTION_DESCRIPTION="Enter some description" COM_COMPONENTBUILDER_LIBRARY_DESCRIPTION_HINT="Description Here" @@ -4980,6 +4984,8 @@ COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_VERSION_DESC="A count of the num COM_COMPONENTBUILDER_LIBRARY_FILES_FOLDERS_URLS_VERSION_LABEL="Revision" COM_COMPONENTBUILDER_LIBRARY_FILE_DESCRIPTION="to library" COM_COMPONENTBUILDER_LIBRARY_FILE_LABEL="Target File Linked" +COM_COMPONENTBUILDER_LIBRARY_GET_SNIPPETS_BUTTON_ACCESS="Library Get Snippets Button Access" +COM_COMPONENTBUILDER_LIBRARY_GET_SNIPPETS_BUTTON_ACCESS_DESC=" Allows the users in this group to access the get snippets button." COM_COMPONENTBUILDER_LIBRARY_HOW="How" COM_COMPONENTBUILDER_LIBRARY_HOW_DESCRIPTION="Select how you want to control the behaviour of the library file inclusion." COM_COMPONENTBUILDER_LIBRARY_HOW_LABEL="File Behaviour" @@ -4992,6 +4998,10 @@ COM_COMPONENTBUILDER_LIBRARY_KEY_WORD_ALL_CASEINSENSITIVE_ONLY_FOUR_TEXT_FIELD=" COM_COMPONENTBUILDER_LIBRARY_KEY_WORD_ALL_CASESENSITIVE_ONLY_FOUR_TEXT_FIELD="Key Word All case-sensitive (only 4 text_field)" COM_COMPONENTBUILDER_LIBRARY_KEY_WORD_ANY_CASEINSENSITIVE_ONLY_FOUR_TEXT_FIELD="Key Word Any case-insensitive (only 4 text_field)" COM_COMPONENTBUILDER_LIBRARY_KEY_WORD_ANY_CASESENSITIVE_ONLY_FOUR_TEXT_FIELD="Key Word Any case-sensitive (only 4 text_field)" +COM_COMPONENTBUILDER_LIBRARY_LIBRARIES="Libraries" +COM_COMPONENTBUILDER_LIBRARY_LIBRARIES_DESCRIPTION="Select the libraries you want to bundle here." +COM_COMPONENTBUILDER_LIBRARY_LIBRARIES_LABEL="Libraries" +COM_COMPONENTBUILDER_LIBRARY_MAIN="Main" COM_COMPONENTBUILDER_LIBRARY_MAX_LENGTH_ONLY_FOUR_TEXT_FIELD="Max Length (only 4 text_field)" COM_COMPONENTBUILDER_LIBRARY_MIN_LENGTH_ONLY_FOUR_TEXT_FIELD="Min Length (only 4 text_field)" COM_COMPONENTBUILDER_LIBRARY_MODIFIED_BY_DESC="The last user that modified this Library." @@ -5039,6 +5049,9 @@ COM_COMPONENTBUILDER_LIBRARY_TARGET_BEHAVIOR_DESCRIPTION="Select the target beha COM_COMPONENTBUILDER_LIBRARY_TARGET_BEHAVIOR_LABEL="Target Behavior" COM_COMPONENTBUILDER_LIBRARY_TARGET_RELATION_DESCRIPTION="Select the target file/s relation to other of the same target file/s." COM_COMPONENTBUILDER_LIBRARY_TARGET_RELATION_LABEL="Target Relation" +COM_COMPONENTBUILDER_LIBRARY_TYPE="Type" +COM_COMPONENTBUILDER_LIBRARY_TYPE_DESCRIPTION="Select what type of library this should be." +COM_COMPONENTBUILDER_LIBRARY_TYPE_LABEL="Type" COM_COMPONENTBUILDER_LIBRARY_UNACTIVE_ONLY_FOUR_TEXT_FIELD="Unactive (only 4 text_field)" COM_COMPONENTBUILDER_LIBRARY_VERSION_DESC="A count of the number of times this Library has been revised." COM_COMPONENTBUILDER_LIBRARY_VERSION_LABEL="Revision" @@ -5085,6 +5098,7 @@ COM_COMPONENTBUILDER_ON_GITHUB="on Github" COM_COMPONENTBUILDER_OPEN="Open" COM_COMPONENTBUILDER_OPENED="opened" COM_COMPONENTBUILDER_OPENED_THIS="opened this" +COM_COMPONENTBUILDER_OPEN_LIBRARY_SNIPPETS="Open Library Snippets" COM_COMPONENTBUILDER_OPEN_ON_GITHUB="Open on Github" COM_COMPONENTBUILDER_OPTIONS="Options" COM_COMPONENTBUILDER_ORDER_BEFORE="Order Before" @@ -5105,6 +5119,7 @@ COM_COMPONENTBUILDER_PLEASE_CHECK_AGAIN_LATTER="Please check again latter." COM_COMPONENTBUILDER_PLEASE_SELECT_A_COMPONENT_THAT_YOU_WOULD_LIKE_TO_COMPILE="Please select a component that you would like to compile." COM_COMPONENTBUILDER_PLEASE_TRY_AGAIN_LATER="Please try again later" COM_COMPONENTBUILDER_PLEASE_WAIT_CLEARING_THE_TMP_FOLDER="Please wait! Clearing the tmp folder" +COM_COMPONENTBUILDER_PLEASE_WAIT_LOADING="Please wait, loading" COM_COMPONENTBUILDER_PUBLIC_ACCESS="Public Access" COM_COMPONENTBUILDER_PUBLISHED="Published" COM_COMPONENTBUILDER_PUBLISHING="Publishing" @@ -5945,7 +5960,6 @@ COM_COMPONENTBUILDER_THE_PACKAGE_KEY_IS_CODESCODE="The package key is: %s< COM_COMPONENTBUILDER_THE_PACKAGE_KEY_IS_S="The package key is: %s" COM_COMPONENTBUILDER_THE_README_IS_LOADING="The readme is loading" COM_COMPONENTBUILDER_THE_SEARCH_FOR_THE_SNIPPETS_ARE_CASE_SENSITIVE_SO_IF_YOU_CHANGED_THE_LOCAL_BNAMESB_OF_EITHER_OR_THE_BSNIPPET_LIBRARY_OR_SNIPPET_TYPESB_IN_ANY_SMALL_WAY_THE_SYSTEM_WILL_NOT_BE_ABLE_TO_CONNECT_YOUR_LOCAL_SNIPPETS_WITH_THOSE_IN_THE_COMMUNITY_REPOSITORY_SO_WE_STRONGLY_ADVICE_TO_BKEEP_TO_THE_COMMUNITY_NAMINGB_TO_AVOID_MISMATCHING_THAT_WILL_IN_TURN_CAUSE_DUPLICATION_SO_IF_YOU_CHANGED_ANY_NAMES_JUST_CHANGE_THEM_BACK_AND_ALL_WILL_AGAIN_WORK_AS_EXPECTED="The search for the snippets are case sensitive so if you changed the local names of either or the snippet, library or snippet types in any small way, the system will not be able to connect your local snippets with those in the community repository. So we strongly advice to keep to the community naming to avoid mismatching, that will in turn cause duplication. So if you changed any names, just change them back and all will again work as expected." -COM_COMPONENTBUILDER_THE_SNIPPETS_ARE="The snippets are" COM_COMPONENTBUILDER_THE_SNIPPETS_WERE_SUCCESSFULLY_EXPORTED="The Snippets Were Successfully Exported!" COM_COMPONENTBUILDER_THE_SNIPPET_WAS_SUCCESSFULLY_EXPORTED="The Snippet Was Successfully Exported!" COM_COMPONENTBUILDER_THE_WIKI_IS_LOADING="The wiki is loading" diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.sys.ini b/admin/language/en-GB/en-GB.com_componentbuilder.sys.ini index 08124678f..34db21cf3 100644 --- a/admin/language/en-GB/en-GB.com_componentbuilder.sys.ini +++ b/admin/language/en-GB/en-GB.com_componentbuilder.sys.ini @@ -446,6 +446,8 @@ COM_COMPONENTBUILDER_GET_SNIPPETS_CUSTOM_ADMIN_VIEWS_BUTTON_ACCESS="Get Snippets COM_COMPONENTBUILDER_GET_SNIPPETS_CUSTOM_ADMIN_VIEWS_BUTTON_ACCESS_DESC=" Allows the users in this group to access the custom admin views button." COM_COMPONENTBUILDER_GET_SNIPPETS_LAYOUTS_BUTTON_ACCESS="Get Snippets Layouts Button Access" COM_COMPONENTBUILDER_GET_SNIPPETS_LAYOUTS_BUTTON_ACCESS_DESC=" Allows the users in this group to access the layouts button." +COM_COMPONENTBUILDER_GET_SNIPPETS_LIBRARIES_BUTTON_ACCESS="Get Snippets Libraries Button Access" +COM_COMPONENTBUILDER_GET_SNIPPETS_LIBRARIES_BUTTON_ACCESS_DESC=" Allows the users in this group to access the libraries button." COM_COMPONENTBUILDER_GET_SNIPPETS_SITE_VIEWS_BUTTON_ACCESS="Get Snippets Site Views Button Access" COM_COMPONENTBUILDER_GET_SNIPPETS_SITE_VIEWS_BUTTON_ACCESS_DESC=" Allows the users in this group to access the site views button." COM_COMPONENTBUILDER_GET_SNIPPETS_SNIPPETS_BUTTON_ACCESS="Get Snippets Snippets Button Access" @@ -650,6 +652,8 @@ COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS_EDIT_VERSION="Libraries Files COM_COMPONENTBUILDER_LIBRARIES_FILES_FOLDERS_URLS_EDIT_VERSION_DESC="Allows users in this group to edit versions of version libraries files folders urls" COM_COMPONENTBUILDER_LIBRARIES_SUBMENU="Libraries Submenu" COM_COMPONENTBUILDER_LIBRARIES_SUBMENU_DESC="Allows the users in this group to update the submenu of the library" +COM_COMPONENTBUILDER_LIBRARY_GET_SNIPPETS_BUTTON_ACCESS="Library Get Snippets Button Access" +COM_COMPONENTBUILDER_LIBRARY_GET_SNIPPETS_BUTTON_ACCESS_DESC=" Allows the users in this group to access the get snippets button." COM_COMPONENTBUILDER_MENU="» Component Builder" COM_COMPONENTBUILDER_MENU_ADMIN_VIEWS="Admin Views" COM_COMPONENTBUILDER_MENU_COMPILER="Compiler" diff --git a/admin/layouts/fieldtype/fields_fullwidth.php b/admin/layouts/fieldtype/fields_fullwidth.php index b57918936..e107a5bfe 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->vzwfields; +$items = $displayData->vzxfields; $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 a437256a6..a6afd46b0 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->vzxlinked_components; +$items = $displayData->vzylinked_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/library/behaviour_above.php b/admin/layouts/library/behaviour_above.php index 55d0e6df3..31b448755 100644 --- a/admin/layouts/library/behaviour_above.php +++ b/admin/layouts/library/behaviour_above.php @@ -31,7 +31,8 @@ $form = $displayData->getForm(); $fields = array( 'name', - 'how' + 'how', + 'type' ); ?> diff --git a/admin/layouts/library/behaviour_left.php b/admin/layouts/library/behaviour_left.php new file mode 100644 index 000000000..c34288a0d --- /dev/null +++ b/admin/layouts/library/behaviour_left.php @@ -0,0 +1,54 @@ + + @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( + 'libraries' +); + +$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/models/ajax.php b/admin/models/ajax.php index f5736e200..6d06cd9a3 100644 --- a/admin/models/ajax.php +++ b/admin/models/ajax.php @@ -1084,26 +1084,79 @@ class ComponentbuilderModelAjax extends JModelList 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()) + if ($libraries = $this->checkLibraries($libraries)) { - return $db->loadColumn(); + // 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; } - + + protected function checkLibraries($libraries) + { + $bucket = array(); + $libraries = array_map( function($id) use (&$bucket) { + // now get bundled libraries + $type = ComponentbuilderHelper::getVar('library', (int) $id, 'id', 'type'); + if (2 == $type && $bundled = ComponentbuilderHelper::getVar('library', (int) $id, 'id', 'libraries')) + { + // make sure we have an array if it was json + if (ComponentbuilderHelper::checkJson($bundled)) + { + $bundled = json_decode($bundled, true); + } + // load in the values if we have an array + if (ComponentbuilderHelper::checkArray($bundled)) + { + foreach ($bundled as $lib) + { + $bucket[$lib] = $lib; + } + } + elseif (is_numeric($bundled)) + { + $bucket[(int) $bundled] = (int) $bundled; + } + } + else + { + return (int) $id; + } + }, $libraries); + // check if we have any bundled libraries + if (ComponentbuilderHelper::checkArray($bucket)) + { + foreach ($bucket as $lib) + { + $libraries[] = (int) $lib; + } + } + // check that we have libraries + if (ComponentbuilderHelper::checkArray($libraries)) + { + $libraries = array_values(array_unique(array_filter($libraries, function($id){return is_int($id);}))); + // check if we have any libraries remaining + if (ComponentbuilderHelper::checkArray($libraries)) + { + return $libraries; + } + } + return false; + } // Used in template public function getTemplateDetails($id) diff --git a/admin/models/custom_admin_view.php b/admin/models/custom_admin_view.php index 138b84f24..7c91fe535 100644 --- a/admin/models/custom_admin_view.php +++ b/admin/models/custom_admin_view.php @@ -923,6 +923,9 @@ class ComponentbuilderModelCustom_admin_view extends JModelAdmin $data['metadata'] = (string) $metadata; } + // always reset the snippets + $data['snippet'] = 0; + // Set the libraries items to data. if (isset($data['libraries']) && is_array($data['libraries'])) { diff --git a/admin/models/fields/librariesx.php b/admin/models/fields/librariesx.php new file mode 100644 index 000000000..e46f771ed --- /dev/null +++ b/admin/models/fields/librariesx.php @@ -0,0 +1,178 @@ + + @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'); + +/** + * Librariesx Form Field class for the Componentbuilder component + */ +class JFormFieldLibrariesx extends JFormFieldList +{ + /** + * The librariesx field type. + * + * @var string + */ + public $type = 'librariesx'; + /** + * 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() + { + // get the input from url + $jinput = JFactory::getApplication()->input; + // get the library id + $libID = $jinput->getInt('id', 0); + $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'); + if ($libID > 0) + { + $query->where($db->quoteName('a.id') . ' != ' . (int) $libID); + } + $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/library.php b/admin/models/fields/library.php index 2c2d744cf..feaa47928 100644 --- a/admin/models/fields/library.php +++ b/admin/models/fields/library.php @@ -153,7 +153,8 @@ class JFormFieldLibrary extends JFormFieldList $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->where($db->quoteName('a.published') . ' >= 1'); + $query->where($db->quoteName('a.published') . ' >= 1'); + $query->where($db->quoteName('a.type') . ' = 1'); $query->order('a.name ASC'); $db->setQuery((string)$query); $items = $db->loadObjectList(); diff --git a/admin/models/fieldtype.php b/admin/models/fieldtype.php index b7a7378e4..9168d46f8 100644 --- a/admin/models/fieldtype.php +++ b/admin/models/fieldtype.php @@ -139,7 +139,7 @@ class ComponentbuilderModelFieldtype extends JModelAdmin * * @return mixed An array of data items on success, false on failure. */ - public function getVzwfields() + public function getVzxfields() { // 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->selectionTranslationVzwfields($item->datatype, 'datatype'); + $item->datatype = $this->selectionTranslationVzxfields($item->datatype, 'datatype'); // convert indexes - $item->indexes = $this->selectionTranslationVzwfields($item->indexes, 'indexes'); + $item->indexes = $this->selectionTranslationVzxfields($item->indexes, 'indexes'); // convert null_switch - $item->null_switch = $this->selectionTranslationVzwfields($item->null_switch, 'null_switch'); + $item->null_switch = $this->selectionTranslationVzxfields($item->null_switch, 'null_switch'); // convert store - $item->store = $this->selectionTranslationVzwfields($item->store, 'store'); + $item->store = $this->selectionTranslationVzxfields($item->store, 'store'); } } @@ -243,7 +243,7 @@ class ComponentbuilderModelFieldtype extends JModelAdmin * * @return translatable string */ - public function selectionTranslationVzwfields($value,$name) + public function selectionTranslationVzxfields($value,$name) { // Array of datatype language strings if ($name === 'datatype') diff --git a/admin/models/forms/component_config.xml b/admin/models/forms/component_config.xml index c6498e705..9a5a7a14a 100644 --- a/admin/models/forms/component_config.xml +++ b/admin/models/forms/component_config.xml @@ -107,12 +107,10 @@ type="subform" name="addconfig" label="COM_COMPONENTBUILDER_COMPONENT_CONFIG_ADDCONFIG_LABEL" - layout="joomla.form.field.subform.repeatable-table" multiple="true" description="COM_COMPONENTBUILDER_COMPONENT_CONFIG_ADDCONFIG_DESCRIPTION" icon="list" - maximum="500" - filter="ARRAY"> + maximum="500">