From 6539862534fbfece3d3db0adc041f60fd81cf399 Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Fri, 8 Nov 2019 18:07:08 +0200 Subject: [PATCH] Improved the internal session handel of JCB. Fixed gh-487 that removed the data size when creating a new field. --- README.md | 15 +- admin/README.txt | 15 +- admin/compiler/joomla_3/Helper.php | 10 +- admin/compiler/joomla_3/Helper_site.php | 10 +- admin/compiler/joomla_3/settings.json | 11 +- admin/helpers/compiler/a_Get.php | 8 +- admin/helpers/compiler/c_Fields.php | 8 +- admin/helpers/compiler/e_Interpretation.php | 79 +- admin/helpers/componentbuilder.php | 32 +- .../en-GB/en-GB.com_componentbuilder.ini | 4 +- .../server/linked_components_fullwidth.php | 5 + admin/models/admin_fields_relations.php | 51 + admin/models/admin_view.php | 48 +- admin/models/ajax.php | 950 ++++++++++-------- admin/models/class_extends.php | 46 +- admin/models/class_method.php | 46 +- admin/models/class_property.php | 46 +- admin/models/component_dashboard.php | 51 + admin/models/custom_admin_view.php | 46 +- admin/models/custom_code.php | 46 +- admin/models/dynamic_get.php | 46 +- admin/models/field.php | 46 +- admin/models/fieldtype.php | 46 +- admin/models/forms/custom_code.js | 2 +- admin/models/forms/field.js | 19 +- admin/models/forms/placeholder.js | 2 +- admin/models/joomla_component.php | 46 +- admin/models/joomla_plugin.php | 46 +- admin/models/language_translation.php | 51 + admin/models/layout.php | 46 +- admin/models/library.php | 46 +- admin/models/placeholder.php | 46 +- admin/models/site_view.php | 46 +- admin/models/template.php | 46 +- admin/models/validation_rule.php | 46 +- .../joomla_components/tmpl/default_body.php | 5 + componentbuilder.xml | 2 +- site/helpers/componentbuilder.php | 32 +- 38 files changed, 1582 insertions(+), 564 deletions(-) diff --git a/README.md b/README.md index 312d3ed35..a1740d26b 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ # Joomla Component Builder ([JCB](http://joomlacomponentbuilder.com)) [![GitHub release](https://img.shields.io/github/release/vdm-io/Joomla-Component-Builder.svg)](https://github.com/vdm-io/Joomla-Component-Builder/releases) [![Total Downloads](https://img.shields.io/github/downloads/vdm-io/Joomla-Component-Builder/total.svg)](https://github.com/vdm-io/Joomla-Component-Builder/releases) -[![Backers on Open Collective](https://opencollective.com/Joomla-Component-Builder/backers/badge.svg)](#backers) -[![Sponsors on Open Collective](https://opencollective.com/Joomla-Component-Builder/sponsors/badge.svg)](#sponsors) +[![JCB Pro Members](https://opencollective.com/joomla-component-builder/tiers/jcb-pro/badge.svg?label=JCB Pro&color=brightgreen)](#sponsors) This is a [Joomla 3.x](https://extensions.joomla.org/extension/component-builder/) component. [__See In Action__](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45) @@ -110,8 +109,6 @@ Where can you get support and help? + [Report a Security Issue](http://joomlacomponentbuilder.com/report-security-issues) + [Community Complaint](http://joomlacomponentbuilder.com/community-complaint) + [Open Issue On Github](https://github.com/vdm-io/Joomla-Component-Builder/issues) ^^ -+ [Telegram Group](https://t.me/jcb_group) -+ [JCB IRC Channel](https://vdm.bz/jcb-irc) Since [JCB](http://joomlacomponentbuilder.com) has [become a community](https://github.com/vdm-io/Joomla-Component-Builder/blob/staging/.github/SUPPORT.md) project [VDM.io](https://www.vdm.io/) is **no longer solely responsible** for support. @@ -146,14 +143,14 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 16th October, 2019 ++ *Last Build*: 8th November, 2019 + *Version*: 2.10.4 + *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **255312** -+ *Field count*: **1353** -+ *File count*: **1620** -+ *Folder count*: **261** ++ *Line count*: **255756** ++ *Field count*: **1350** ++ *File count*: **1614** ++ *Folder count*: **256** > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com). > Developed by [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) diff --git a/admin/README.txt b/admin/README.txt index 312d3ed35..a1740d26b 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -1,8 +1,7 @@ # Joomla Component Builder ([JCB](http://joomlacomponentbuilder.com)) [![GitHub release](https://img.shields.io/github/release/vdm-io/Joomla-Component-Builder.svg)](https://github.com/vdm-io/Joomla-Component-Builder/releases) [![Total Downloads](https://img.shields.io/github/downloads/vdm-io/Joomla-Component-Builder/total.svg)](https://github.com/vdm-io/Joomla-Component-Builder/releases) -[![Backers on Open Collective](https://opencollective.com/Joomla-Component-Builder/backers/badge.svg)](#backers) -[![Sponsors on Open Collective](https://opencollective.com/Joomla-Component-Builder/sponsors/badge.svg)](#sponsors) +[![JCB Pro Members](https://opencollective.com/joomla-component-builder/tiers/jcb-pro/badge.svg?label=JCB Pro&color=brightgreen)](#sponsors) This is a [Joomla 3.x](https://extensions.joomla.org/extension/component-builder/) component. [__See In Action__](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45) @@ -110,8 +109,6 @@ Where can you get support and help? + [Report a Security Issue](http://joomlacomponentbuilder.com/report-security-issues) + [Community Complaint](http://joomlacomponentbuilder.com/community-complaint) + [Open Issue On Github](https://github.com/vdm-io/Joomla-Component-Builder/issues) ^^ -+ [Telegram Group](https://t.me/jcb_group) -+ [JCB IRC Channel](https://vdm.bz/jcb-irc) Since [JCB](http://joomlacomponentbuilder.com) has [become a community](https://github.com/vdm-io/Joomla-Component-Builder/blob/staging/.github/SUPPORT.md) project [VDM.io](https://www.vdm.io/) is **no longer solely responsible** for support. @@ -146,14 +143,14 @@ TODO + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder) + *First Build*: 30th April, 2015 -+ *Last Build*: 16th October, 2019 ++ *Last Build*: 8th November, 2019 + *Version*: 2.10.4 + *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved. + *License*: GNU General Public License version 2 or later; see LICENSE.txt -+ *Line count*: **255312** -+ *Field count*: **1353** -+ *File count*: **1620** -+ *Folder count*: **261** ++ *Line count*: **255756** ++ *Field count*: **1350** ++ *File count*: **1614** ++ *Folder count*: **256** > This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](http://joomlacomponentbuilder.com). > Developed by [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) diff --git a/admin/compiler/joomla_3/Helper.php b/admin/compiler/joomla_3/Helper.php index f5dabbcb2..69b04531f 100644 --- a/admin/compiler/joomla_3/Helper.php +++ b/admin/compiler/joomla_3/Helper.php @@ -209,7 +209,15 @@ abstract class ###Component###Helper { $query->from($db->quoteName('#_'.$main.'_'.$table)); } - $query->where($db->quoteName($whereString) . ' '.$operator.' (' . implode(',',$where) . ')'); + // add strings to array search + if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator) + { + $query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$where) . '")'); + } + else + { + $query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',',$where) . ')'); + } $db->setQuery($query); $db->execute(); if ($db->getNumRows()) diff --git a/admin/compiler/joomla_3/Helper_site.php b/admin/compiler/joomla_3/Helper_site.php index 8494df7f2..3cc0fa07d 100644 --- a/admin/compiler/joomla_3/Helper_site.php +++ b/admin/compiler/joomla_3/Helper_site.php @@ -602,7 +602,15 @@ abstract class ###Component###Helper { $query->from($db->quoteName('#_'.$main.'_'.$table)); } - $query->where($db->quoteName($whereString) . ' '.$operator.' (' . implode(',',$where) . ')'); + // add strings to array search + if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator) + { + $query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$where) . '")'); + } + else + { + $query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',',$where) . ')'); + } $db->setQuery($query); $db->execute(); if ($db->getNumRows()) diff --git a/admin/compiler/joomla_3/settings.json b/admin/compiler/joomla_3/settings.json index 619cf6b0c..a012e154e 100644 --- a/admin/compiler/joomla_3/settings.json +++ b/admin/compiler/joomla_3/settings.json @@ -212,6 +212,12 @@ "path": "c0mp0n3nt/site/helpers", "rename": false, "type": "file" + }, + "import.gif": { + "naam": "import.gif", + "path": "c0mp0n3nt/admin/assets/images", + "rename": false, + "type": "file" } }, "dynamic": { @@ -461,11 +467,6 @@ "newName": "default.php", "type": "import" }, - "import.gif": { - "path": "c0mp0n3nt/admin/assets/images", - "rename": false, - "type": "import" - }, "JControllerLegacy_import_custom.php": { "path": "c0mp0n3nt/admin/controllers", "rename": "JControllerLegacy_import_custom", diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index 66dd3ad72..d0cc2df6b 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -7001,7 +7001,7 @@ class Get (trim($lineContent) === $endHTML || strpos($lineContent, $endHTML) !== false))) { // trim the placeholder and if there is still data then load it - if ($_line = $this->addLineChecker($endReplace, 2, $lineContent)) + if (isset($endReplace) && ($_line = $this->addLineChecker($endReplace, 2, $lineContent)) !== false) { $codeBucket[$pointer[$targetKey]][] = $_line; } @@ -7360,9 +7360,9 @@ class Get /** * Check if this line should be added * - * @param strin $replaceKey The key to remove from line - * @param int $type The line type - * @param string $lineContent The line to check + * @param string $replaceKey The key to remove from line + * @param int $type The line type + * @param string $lineContent The line to check * * @return bool true on success * diff --git a/admin/helpers/compiler/c_Fields.php b/admin/helpers/compiler/c_Fields.php index 1e43e49c9..574ee821a 100644 --- a/admin/helpers/compiler/c_Fields.php +++ b/admin/helpers/compiler/c_Fields.php @@ -1829,7 +1829,7 @@ class Fields extends Structure // add to lang array $this->setLangContent($this->lang, $langValue, $option); // now add to option set - $grouped_['option'][$option] = array('value' => $valueKeyArray[0], 'text' => $langValue); + $grouped_['option'][$option] = array('value' => $option, 'text' => $langValue); $optionArray[$option] = $langValue; // set order $order_['option' . $option] = $option; @@ -2357,7 +2357,7 @@ class Fields extends Structure } else { - $this->siteFieldData['decode'][$array['site']][$code][$array['as']][$array['key']] = array('decode' => array($set), 'type' => $type); + $this->siteFieldData['decode'][$array['site']][$code][$array['as']][$array['key']] = array('decode' => array($set), 'type' => $type, 'admin_view' => $view); } } // set the uikit checker @@ -3052,8 +3052,8 @@ class Fields extends Structure $this->buildSiteFieldData($view_name_single, $name, 'json', $typeName); } - // load the json list display fix - if (($listSwitch || $listJoin) && $typeName != 'repeatable' && $typeName != 'subform') + // load the model list display fix + if (($listSwitch || $listJoin) && (($typeName != 'repeatable' && $typeName != 'subform') || $field['settings']->store == 6)) { if (ComponentbuilderHelper::checkArray($options)) { diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index b3e4144fb..dbd4816cb 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -1835,11 +1835,11 @@ class Interpretation extends Fields // base64_decode $decoder = $string . "->" . $field . " = base64_decode(" . $string . "->" . $field . ");"; } - elseif (strpos($decode, '_encryption') !== false) + elseif (strpos($decode, '_encryption') !== false || 'expert_mode' === $decode) { foreach ($this->cryptionTypes as $cryptionType) { - if ($cryptionType . '_encryption' === $decode) + if ($cryptionType . '_encryption' === $decode || $cryptionType . '_mode' === $decode) { if ('expert' !== $cryptionType) { @@ -1847,10 +1847,10 @@ class Interpretation extends Fields // set decryption $decoder = $string . "->" . $field . " = rtrim(\$" . $cryptionType . "->decryptString(" . $string . "->" . $field . "), " . '"\0"' . ");"; } - elseif (isset($this->{$cryptionType . 'FieldModeling'}[$code][$field])) + elseif (isset($this->{$cryptionType . 'FieldModeling'}[$array['admin_view']][$field])) { $_placeholder_for_field = array('[[[field]]]' => $string . "->" . $field); - $fieldDecode .= $this->setPlaceholders(PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . implode(PHP_EOL . $this->_t(1) . $tab . $this->_t(1), $this->{$cryptionType . 'FieldModeling'}[$code][$field]['get']), $_placeholder_for_field); + $fieldDecode .= $this->setPlaceholders(PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . implode(PHP_EOL . $this->_t(1) . $tab . $this->_t(1), $this->{$cryptionType . 'FieldModeling'}[$array['admin_view']][$field]['get']), $_placeholder_for_field); } // activate site decryption $this->siteDecrypt[$cryptionType][$code] = true; @@ -12955,9 +12955,7 @@ class Interpretation extends Fields break; case 6: // EXPERT_ENCRYPTION - $decode = '///////////////////////////////////////////'; $expertCrypt = true; - $suffix_decode = ''; break; default: // JSON_ARRAY_ENCODE @@ -12968,7 +12966,7 @@ class Interpretation extends Fields break; } - if ($item['type'] === 'usergroup' && !$export) + if ($item['type'] === 'usergroup' && !$export && $item['method'] != 6) { $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "//" . $this->setLine(__LINE__) . " decode " . $item['name']; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "\$" . $item['name'] . "Array = " . $decode . "(\$item->" . $item['name'] . $suffix_decode . ");"; @@ -12991,7 +12989,7 @@ class Interpretation extends Fields $fix .= PHP_EOL.$this->_t(1).$tab.$this->_t(4) . "\$item->".$item['name']." = implode('|',\$".$item['name']."Array);"; $fix .= PHP_EOL.$this->_t(1).$tab.$this->_t(3) . "}"; } */ - elseif ($item['translation'] && !$export) + elseif ($item['translation'] && !$export && $item['method'] != 6) { $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "//" . $this->setLine(__LINE__) . " decode " . $item['name']; $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "\$" . $item['name'] . "Array = " . $decode . "(\$item->" . $item['name'] . $suffix_decode . ");"; @@ -13007,40 +13005,49 @@ class Interpretation extends Fields } else { - if ($item['method'] == 2 || $item['method'] == 3 || $item['method'] == 4 || $item['method'] == 5) + if ($item['method'] == 2 || $item['method'] == 3 || $item['method'] == 4 || $item['method'] == 5 || $item['method'] == 6) { - $taber = ''; - if ($item['method'] == 3) + // expert mode (dev must do it all) + if ($item['method'] == 6) { - $taber = $this->_t(1); - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (\$basickey && !is_numeric(\$item->" . $item['name'] . ") && \$item->" . $item['name'] . " === base64_encode(base64_decode(\$item->" . $item['name'] . ", true)))"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "{"; - } - elseif ($item['method'] == 5) - { - $taber = $this->_t(1); - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (\$mediumkey && !is_numeric(\$item->" . $item['name'] . ") && \$item->" . $item['name'] . " === base64_encode(base64_decode(\$item->" . $item['name'] . ", true)))"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "{"; - } - elseif ($item['method'] == 4) - { - $taber = $this->_t(1); - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (\$whmcskey && !is_numeric(\$item->" . $item['name'] . ") && \$item->" . $item['name'] . " === base64_encode(base64_decode(\$item->" . $item['name'] . ", true)))"; - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "{"; - } - if ($item['method'] == 3 || $item['method'] == 4 || $item['method'] == 5) - { - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "//" . $this->setLine(__LINE__) . " decrypt " . $item['name']; + $_placeholder_for_field = array('[[[field]]]' => "\$item->" . $item['name']); + $fix .= $this->setPlaceholders(PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . implode(PHP_EOL . $this->_t(1) . $tab . $this->_t(3), $this->expertFieldModeling[$viewName_single][$item['name']]['get']), $_placeholder_for_field); } else { - $fix .= PHP_EOL . $this->_t(1) . $tab . $taber . $this->_t(3) . "//" . $this->setLine(__LINE__) . " decode " . $item['name']; - } - $fix .= PHP_EOL . $this->_t(1) . $tab . $taber . $this->_t(3) . "\$item->" . $item['name'] . " = " . $decode . "(\$item->" . $item['name'] . ");"; + $taber = ''; + if ($item['method'] == 3) + { + $taber = $this->_t(1); + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (\$basickey && !is_numeric(\$item->" . $item['name'] . ") && \$item->" . $item['name'] . " === base64_encode(base64_decode(\$item->" . $item['name'] . ", true)))"; + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "{"; + } + elseif ($item['method'] == 5) + { + $taber = $this->_t(1); + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (\$mediumkey && !is_numeric(\$item->" . $item['name'] . ") && \$item->" . $item['name'] . " === base64_encode(base64_decode(\$item->" . $item['name'] . ", true)))"; + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "{"; + } + elseif ($item['method'] == 4) + { + $taber = $this->_t(1); + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (\$whmcskey && !is_numeric(\$item->" . $item['name'] . ") && \$item->" . $item['name'] . " === base64_encode(base64_decode(\$item->" . $item['name'] . ", true)))"; + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "{"; + } + if ($item['method'] == 3 || $item['method'] == 4 || $item['method'] == 5) + { + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "//" . $this->setLine(__LINE__) . " decrypt " . $item['name']; + } + else + { + $fix .= PHP_EOL . $this->_t(1) . $tab . $taber . $this->_t(3) . "//" . $this->setLine(__LINE__) . " decode " . $item['name']; + } + $fix .= PHP_EOL . $this->_t(1) . $tab . $taber . $this->_t(3) . "\$item->" . $item['name'] . " = " . $decode . "(\$item->" . $item['name'] . ");"; - if ($item['method'] == 3 || $item['method'] == 4 || $item['method'] == 5) - { - $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "}"; + if ($item['method'] == 3 || $item['method'] == 4 || $item['method'] == 5) + { + $fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "}"; + } } } else diff --git a/admin/helpers/componentbuilder.php b/admin/helpers/componentbuilder.php index 7499db214..5e72cc1a4 100644 --- a/admin/helpers/componentbuilder.php +++ b/admin/helpers/componentbuilder.php @@ -834,13 +834,13 @@ abstract class ComponentbuilderHelper */ public static function getContributorDetails($filename, $type = 'snippet') { - // start loading he contributor details + // start loading the contributor details $contributor = array(); // get the path & content switch ($type) { case 'snippet': - $path = $snippetPath.$filename; + $path = self::$snippetPath.$filename; // get the file if available $content = self::getFileContents($path); if (self::checkJson($content)) @@ -2043,17 +2043,17 @@ abstract class ComponentbuilderHelper /** - * the Butler + * the Butler **/ public static $session = array(); /** - * the Butler Assistant + * the Butler Assistant **/ protected static $localSession = array(); /** - * start a session if not already set, and load with data + * start a session if not already set, and load with data **/ public static function loadSession() { @@ -2066,7 +2066,7 @@ abstract class ComponentbuilderHelper } /** - * give Session more to keep + * give Session more to keep **/ public static function set($key, $value) { @@ -2081,7 +2081,7 @@ abstract class ComponentbuilderHelper } /** - * get info from Session + * get info from Session **/ public static function get($key, $default = null) { @@ -4304,12 +4304,12 @@ abstract class ComponentbuilderHelper } /** - * Composer Switch + * Composer Switch **/ protected static $composer = array(); /** - * Load the Composer Vendors + * Load the Composer Vendors **/ public static function composerAutoload($target) { @@ -4330,7 +4330,7 @@ abstract class ComponentbuilderHelper /** - * Load the Composer Vendor phpseclib + * Load the Composer Vendor phpseclib **/ protected static function composephpseclib() { @@ -4338,6 +4338,8 @@ abstract class ComponentbuilderHelper require_once JPATH_SITE . '/libraries/phpseclib/vendor/autoload.php'; // do not load again self::$composer['phpseclib'] = true; + + return true; } @@ -6101,7 +6103,15 @@ abstract class ComponentbuilderHelper { $query->from($db->quoteName('#_'.$main.'_'.$table)); } - $query->where($db->quoteName($whereString) . ' '.$operator.' (' . implode(',',$where) . ')'); + // add strings to array search + if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator) + { + $query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$where) . '")'); + } + else + { + $query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',',$where) . ')'); + } $db->setQuery($query); $db->execute(); if ($db->getNumRows()) diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.ini b/admin/language/en-GB/en-GB.com_componentbuilder.ini index a9eca0089..23712cdfa 100644 --- a/admin/language/en-GB/en-GB.com_componentbuilder.ini +++ b/admin/language/en-GB/en-GB.com_componentbuilder.ini @@ -4953,14 +4953,14 @@ COM_COMPONENTBUILDER_FIELD_INDEXES_LABEL="Indexes Type" COM_COMPONENTBUILDER_FIELD_INITIATOR_ON_GET_MODEL="Initiator On Get Model" COM_COMPONENTBUILDER_FIELD_INITIATOR_ON_GET_MODEL_DESCRIPTION="The initiator to on get model this field. If JCB finds that there is more then one field with the same initiator code in one view it will only load it once. You could also leave this blank if you already have the on get model initiator set in another field of the same admin_view." COM_COMPONENTBUILDER_FIELD_INITIATOR_ON_GET_MODEL_HINT="// Get the medium decryption. -$mediumkey = [[[Component]]]Helper::getCryptKey('medium'); +$mediumkey = ComponentbuilderHelper::getCryptKey('medium'); // Get the encryption object. $medium = new FOFEncryptAes($mediumkey);" COM_COMPONENTBUILDER_FIELD_INITIATOR_ON_GET_MODEL_LABEL="Initiator
on get model" COM_COMPONENTBUILDER_FIELD_INITIATOR_ON_SAVE_MODEL="Initiator On Save Model" COM_COMPONENTBUILDER_FIELD_INITIATOR_ON_SAVE_MODEL_DESCRIPTION="The initiator to on save model this field. If JCB finds that there is more then one field with the same initiator code in one view it will only load it once. You could also leave this blank if you already have the on save model initiator set in another field of the same admin_view." COM_COMPONENTBUILDER_FIELD_INITIATOR_ON_SAVE_MODEL_HINT="// Get the medium encryption. -$mediumkey = [[[Component]]]Helper::getCryptKey('medium'); +$mediumkey = ComponentbuilderHelper::getCryptKey('medium'); // Get the encryption object. $medium = new FOFEncryptAes($mediumkey);" COM_COMPONENTBUILDER_FIELD_INITIATOR_ON_SAVE_MODEL_LABEL="Initiator
on save model" diff --git a/admin/layouts/server/linked_components_fullwidth.php b/admin/layouts/server/linked_components_fullwidth.php index 7195f4dab..000ce8a3a 100644 --- a/admin/layouts/server/linked_components_fullwidth.php +++ b/admin/layouts/server/linked_components_fullwidth.php @@ -84,6 +84,11 @@ else - escape($item->component_version); ?> return_here is set + if (!isset($this->return_here)) + { + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + } // setup the buttons if (!isset($_buttons) || !ComponentbuilderHelper::checkArray($_buttons)) { diff --git a/admin/models/admin_fields_relations.php b/admin/models/admin_fields_relations.php index e947914a7..ce4edc40e 100644 --- a/admin/models/admin_fields_relations.php +++ b/admin/models/admin_fields_relations.php @@ -69,10 +69,54 @@ class ComponentbuilderModelAdmin_fields_relations extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + + /** + * get VDM internal session key + * + * @return string the session key + * + */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('admin_fields_relations__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'admin_fields_relations__'.$id); + ComponentbuilderHelper::set('admin_fields_relations__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } + /** * Method to get a single record. @@ -135,6 +179,13 @@ class ComponentbuilderModelAdmin_fields_relations extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } if (!empty($item->id)) diff --git a/admin/models/admin_view.php b/admin/models/admin_view.php index c3f72c724..641dd7773 100644 --- a/admin/models/admin_view.php +++ b/admin/models/admin_view.php @@ -215,14 +215,51 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + /** - * get VDM session key + * get VDM internal session key * * @return string the session key * */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('admin_view__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'admin_view__'.$id); + ComponentbuilderHelper::set('admin_view__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } @@ -540,6 +577,7 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin $item->ajax_input = $ajax_input->toArray(); } + if (empty($item->id)) { $id = 0; @@ -563,8 +601,14 @@ class ComponentbuilderModelAdmin_view extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } - // update the fields $objectUpdate = new stdClass(); $objectUpdate->id = (int) $item->id; diff --git a/admin/models/ajax.php b/admin/models/ajax.php index 7afc33d96..cb9fefd89 100644 --- a/admin/models/ajax.php +++ b/admin/models/ajax.php @@ -279,48 +279,6 @@ class ComponentbuilderModelAjax extends JModelList // Used in admin_view - - protected $viewid = array(); - - protected function getViewID($call = 'table') - { - if (!isset($this->viewid[$call])) - { - // get the vdm key - $jinput = JFactory::getApplication()->input; - $vdm = $jinput->get('vdm', null, 'WORD'); - if ($vdm) - { - // set view and id - if ($view = ComponentbuilderHelper::get($vdm)) - { - $current = (array) explode('__', $view); - if (ComponentbuilderHelper::checkString($current[0]) && isset($current[1]) && is_numeric($current[1])) - { - // get the view name & id - $this->viewid[$call] = array( - 'a_id' => (int) $current[1], - 'a_view' => $current[0] - ); - } - } - // set return if found - if ($return = ComponentbuilderHelper::get($vdm . '__return')) - { - if (ComponentbuilderHelper::checkString($return)) - { - $this->viewid[$call]['a_return'] = $return; - } - } - } - } - if (isset($this->viewid[$call])) - { - return $this->viewid[$call]; - } - return false; - } - protected $rowNumbers = array( 'admin_fields_conditions' => 80, 'admin_fields' => 50 @@ -346,140 +304,6 @@ class ComponentbuilderModelAjax extends JModelList 'component_files_folders' => 'components_files_folders', 'custom_code' => 'custom_codes', 'language' => true); - - public function getButton($type, $size) - { - if (isset($this->buttonArray[$type])) - { - $user = JFactory::getUser(); - // only add if user allowed to create - if ($user->authorise($type.'.create', 'com_componentbuilder')) - { - // get the view name & id - $values = $this->getViewID(); - // check if new item - $ref = ''; - if (!is_null($values['a_id']) && $values['a_id'] > 0 && strlen($values['a_view'])) - { - // check if we have a return value - $return_url = 'index.php?option=com_componentbuilder&view=' . (string) $values['a_view'] . '&layout=edit&id=' . (int) $values['a_id']; - if (isset($values['a_return'])) - { - $return_url .= '&return=' . (string) $values['a_return']; - } - // only load referral if not new item. - $ref = '&ref=' . $values['a_view'] . '&refid=' . $values['a_id'] . '&return=' . urlencode(base64_encode($return_url)); - } - // build url (A tag) - $startAtag = 'onclick="UIkit2.modal.confirm(\''.JText::_('COM_COMPONENTBUILDER_ALL_UNSAVED_WORK_ON_THIS_PAGE_WILL_BE_LOST_ARE_YOU_SURE_YOU_WANT_TO_CONTINUE').'\', function(){ window.location.href = \'index.php?option=com_componentbuilder&view=' . $type . '&layout=edit' . $ref . '\' })" href="javascript:void(0)" title="'.JText::sprintf('COM_COMPONENTBUILDER_CREATE_NEW_S', ComponentbuilderHelper::safeString($type, 'W')).'">'; - // build the smallest button - if (3 == $size) - { - $button = ''; - } - // build the smaller button - elseif (2 == $size) - { - $button = ' ' . JText::_('COM_COMPONENTBUILDER_CREATE') . ''; - } - else - // build the big button - { - $button = '
-
- -
- -
'; - } - // return the button attached to input field - return $button; - } - return ''; - } - return false; - } - - public function getButtonID($type, $size) - { - if (isset($this->buttonArray[$type])) - { - $user = JFactory::getUser(); - // only add if user allowed to create - if ($user->authorise($type.'.create', 'com_componentbuilder')) - { - // get the view name & id - $values = $this->getViewID(); - // set the button ID - $css_class = 'control-group-'.ComponentbuilderHelper::safeString($type. '-' . $size, 'L', '-'); - // check if new item - $ref = ''; - if (!is_null($values['a_id']) && $values['a_id'] > 0 && strlen($values['a_view'])) - { - // set the return value - $return_url = 'index.php?option=com_componentbuilder&view=' . (string) $values['a_view'] . '&layout=edit&id=' . (int) $values['a_id']; - if (isset($values['a_return'])) - { - $return_url .= '&return=' . (string) $values['a_return']; - } - // only load referral if not new item. - $ref = '&ref=' . $values['a_view'] . '&refid=' . $values['a_id'] . '&return=' . urlencode(base64_encode($return_url)); - // get item id - if (($id = ComponentbuilderHelper::getVar($type, $values['a_id'], $values['a_view'], 'id')) !== false && $id > 0) - { - $buttonText = JText::sprintf('COM_COMPONENTBUILDER_EDIT_S_FOR_THIS_S', ComponentbuilderHelper::safeString($type, 'w'), ComponentbuilderHelper::safeString($values['a_view'], 'w')); - $buttonTextSmall = JText::_('COM_COMPONENTBUILDER_EDIT'); - $editThis = 'index.php?option=com_componentbuilder&view='.$this->buttonArray[$type].'&task='.$type.'.edit&id='.$id; - $icon = 'icon-apply'; - } - else - { - $buttonText = JText::sprintf('COM_COMPONENTBUILDER_CREATE_S_FOR_THIS_S', ComponentbuilderHelper::safeString($type, 'w'), ComponentbuilderHelper::safeString($values['a_view'], 'w')); - $buttonTextSmall = JText::_('COM_COMPONENTBUILDER_CREATE'); - $editThis = 'index.php?option=com_componentbuilder&view='.$type.'&layout=edit'; - $icon = 'icon-new'; - } - // build the button - $button = array(); - if (1 == $size) - { - $button[] = '
'; - $button[] = '
'; - $button[] = ''; - $button[] = '
'; - $button[] = ''; - $button[] = '
'; - } - elseif (2 == $size) - { - $button[] = ''; - $button[] = $buttonTextSmall; - $button[] = ''; - } - // return the button attached to input field - return implode("\n", $button); - } - // only return notice if big button - if (1 == $size) - { - return '
' . JText::sprintf('COM_COMPONENTBUILDER_BUTTON_TO_CREATE_S_WILL_SHOW_ONCE_S_IS_SAVED_FOR_THE_FIRST_TIME', ComponentbuilderHelper::safeString($type, 'w'), ComponentbuilderHelper::safeString($values['a_view'], 'w')) . '
'; - } - } - } - return ''; - } public function checkAliasField($type) { @@ -626,97 +450,19 @@ class ComponentbuilderModelAjax extends JModelList return $language[$key]; } // check a shared value is available - $keys = explode('|=VDM=|', $key); - if (isset($language[$keys[1]])) + if (strpos($key, '|=VDM=|') !== false) { - return $language[$keys[1]]; + $keys = explode('|=VDM=|', $key); + if (isset($language[$keys[1]])) + { + return $language[$keys[1]]; + } } return ComponentbuilderHelper::safeString($keys[1], 'Ww'); } - - protected function getSubformTable($idName, $data) - { - // make sure we convert the json to array - if (ComponentbuilderHelper::checkJson($data)) - { - $data = json_decode($data, true); - } - // make sure we have an array - if (ComponentbuilderHelper::checkArray($data) && ComponentbuilderHelper::checkString($idName)) - { - // Build heading - $head = array(); - foreach ($data as $headers) - { - foreach ($headers as $header => $value) - { - if (!isset($head[$header])) - { - $head[$header] = $this->getLanguage($idName . '|=VDM=|' . $header); - } - } - } - // build the rows - $rows = array(); - if (ComponentbuilderHelper::checkArray($data) && ComponentbuilderHelper::checkArray($head)) - { - foreach ($data as $nr => $values) - { - foreach ($head as $key => $_header) - { - // set the value for the row - if (isset($values[$key])) - { - $this->setSubformRows($nr, $this->setSubformValue($key, $values[$key]), $rows, $_header); - } - else - { - $this->setSubformRows($nr, $this->setSubformValue($key, ''), $rows, $_header); - } - } - } - } - // build table - if (ComponentbuilderHelper::checkArray($rows) && ComponentbuilderHelper::checkArray($head)) - { - // set the number of rows - $this->rowNumber = count($rows); - // return the table - return ComponentbuilderHelper::setSubformTable($head, $rows, $idName); - } - } - return false; - } - - protected function setSubformValue($header, $value) - { - if (array_key_exists($header, $this->functionArray) && method_exists($this, $this->functionArray[$header])) - { - $value = $this->{$this->functionArray[$header]}($header, $value); - } - // if no value are set - if (!ComponentbuilderHelper::checkString($value)) - { - $value = '-'; - } - return $value; - } - - protected function setSubformRows($nr, $value, &$rows, $_header) - { - // build rows - if (!isset($rows[$nr])) - { - $rows[$nr] = ''.$value.''; - } - else - { - $rows[$nr] .= ''.$value.''; - } - } - protected $ref; + protected $fieldsArray = array( 'library_config' => 'addconfig', 'library_files_folders_urls' => array('addurls', 'addfiles', 'addfolders', 'addfoldersfullpath', 'addfilesfullpath'), @@ -726,94 +472,12 @@ class ComponentbuilderModelAjax extends JModelList '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) - { - if (isset($this->fieldsArray[$type])) - { - // set type name - $typeName = ComponentbuilderHelper::safeString($type, 'w'); - // 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']) && in_array($values['a_view'], $this->allowedViewsArray)) - { - // set a return value - $return_url = 'index.php?option=com_componentbuilder&view=' . (string) $values['a_view'] . '&layout=edit&id=' . (int) $values['a_id']; - if (isset($values['a_return'])) - { - $return_url .= '&return=' . (string) $values['a_return']; - } - // set the ref - $this->ref = '&ref=' . $values['a_view'] . '&refid=' . $values['a_id'] . '&return=' . urlencode(base64_encode($return_url)); - // load the results - $result = array(); - // return field table - if (ComponentbuilderHelper::checkArray($this->fieldsArray[$type])) - { - foreach ($this->fieldsArray[$type] as $fieldName) - { - if ($table = $this->getFieldTable($type, $values['a_id'], $values['a_view'], $fieldName, $typeName)) - { - $result[] = $table; - } - } - } - elseif (ComponentbuilderHelper::checkString($this->fieldsArray[$type])) - { - if ($table = $this->getFieldTable($type, $values['a_id'], $values['a_view'], $this->fieldsArray[$type], $typeName)) - { - $result[] = $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) . '
'; - } - 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); - // get row number - $number = (isset($this->rowNumbers[$type]) && $this->rowNumbers[$type]) ? $this->rowNumbers[$type] : false; - // set notice of bad practice - $notice = ''; - if ($number && isset($this->rowNumber) && $this->rowNumber > $number) - { - $notice = '
' . JText::sprintf('COM_COMPONENTBUILDER_YOU_HAVE_S_S_ADDING_MORE_THEN_S_S_IS_CONSIDERED_BAD_PRACTICE_YOUR_S_PAGE_LOAD_IN_JCB_WILL_SLOWDOWN_YOU_SHOULD_CONSIDER_DECOUPLING_SOME_OF_THESE_S', $this->rowNumber, $typeName, $number, $typeName, $typeName, $typeName) . '
'; - } - elseif ($number && isset($this->rowNumber)) - { - $notice = '
' . JText::sprintf('COM_COMPONENTBUILDER_YOU_HAVE_S_S_ADDING_MORE_THEN_S_S_IS_CONSIDERED_BAD_PRACTICE', $this->rowNumber, $typeName, $number, $typeName) . '
'; - } - // return table - return $notice.$table; - } - return false; - } - protected $conversionCheck = array( 'addfields' => 'field', 'addconditions' => 'target_field', @@ -825,6 +489,28 @@ class ComponentbuilderModelAjax extends JModelList 'sql_tweak' => 'adminview', 'version_update' => 'version'); + protected $itemNames = array( + 'field' => array(), + 'admin_view' => array(), + 'site_view' => array(), + 'custom_admin_view' => array() + ); + + protected $itemKeys = array( + // admin view + 'field' => array('table' => 'field', 'tables' => 'fields', 'id' => 'id', 'name' => 'name', 'text' => 'Field', 'type' => array('table' => 'fieldtype', 'field' => 'id', 'key' => 'fieldtype', 'get' => 'name')), + 'target_field' => array('table' => 'field', 'tables' => 'fields', 'id' => 'id', 'name' => 'name', 'text' => 'Field', 'type' => array('table' => 'fieldtype', 'field' => 'id', 'key' => 'fieldtype', 'get' => 'name')), + 'match_field' => array('table' => 'field', 'tables' => 'fields', 'id' => 'id', 'name' => 'name', 'text' => 'Field', 'type' => array('table' => 'fieldtype', 'field' => 'id', 'key' => 'fieldtype', 'get' => 'name')), + 'listfield' => array('table' => 'field', 'tables' => 'fields', 'id' => 'id', 'name' => 'name', 'text' => 'Field', 'type' => array('table' => 'fieldtype', 'field' => 'id', 'key' => 'fieldtype', 'get' => 'name')), + 'joinfields' => array('table' => 'field', 'tables' => 'fields', 'id' => 'id', 'name' => 'name', 'text' => 'Field', 'type' => array('table' => 'fieldtype', 'field' => 'id', 'key' => 'fieldtype', 'get' => 'name')), + // joomla component view + 'siteview' => array('table' => 'site_view', 'tables' => 'site_views', 'id' => 'id', 'name' => 'name', 'text' => 'Site View'), + 'customadminview' => array('table' => 'custom_admin_view', 'tables' => 'custom_admin_views', 'id' => 'id', 'name' => 'system_name', 'text' => 'Custom Admin View'), + 'adminviews' => array('table' => 'admin_view', 'tables' => 'admin_views', 'id' => 'id', 'name' => 'system_name', 'text' => 'Admin View'), + 'adminview' => array('table' => 'admin_view', 'tables' => 'admin_views', 'id' => 'id', 'name' => 'system_name', 'text' => 'Admin View'), + 'before' => array('table' => 'admin_view', 'tables' => 'admin_views', 'id' => 'id', 'name' => 'system_name', 'text' => 'Admin View') + ); + protected function checkRepeatableConversion(&$fieldsData, $fieldsArrayType, $id, $linked_id_name) { if (ComponentbuilderHelper::checkJson($fieldsData) && isset($this->conversionCheck[$fieldsArrayType])) @@ -850,97 +536,6 @@ class ComponentbuilderModelAjax extends JModelList } } - protected $itemNames = array( - 'field' => array(), - 'admin_view' => array(), - 'site_view' => array(), - 'custom_admin_view' => array() - ); - - protected $itemKeys = array( - // admin view - 'field' => array('table' => 'field', 'tables' => 'fields', 'id' => 'id', 'name' => 'name', 'text' => 'Field', 'type' => array('table' => 'fieldtype', 'field' => 'id', 'key' => 'fieldtype', 'get' => 'name')), - 'target_field' => array('table' => 'field', 'tables' => 'fields', 'id' => 'id', 'name' => 'name', 'text' => 'Field', 'type' => array('table' => 'fieldtype', 'field' => 'id', 'key' => 'fieldtype', 'get' => 'name')), - 'match_field' => array('table' => 'field', 'tables' => 'fields', 'id' => 'id', 'name' => 'name', 'text' => 'Field', 'type' => array('table' => 'fieldtype', 'field' => 'id', 'key' => 'fieldtype', 'get' => 'name')), - 'listfield' => array('table' => 'field', 'tables' => 'fields', 'id' => 'id', 'name' => 'name', 'text' => 'Field', 'type' => array('table' => 'fieldtype', 'field' => 'id', 'key' => 'fieldtype', 'get' => 'name')), - 'joinfields' => array('table' => 'field', 'tables' => 'fields', 'id' => 'id', 'name' => 'name', 'text' => 'Field', 'type' => array('table' => 'fieldtype', 'field' => 'id', 'key' => 'fieldtype', 'get' => 'name')), - // joomla component view - 'siteview' => array('table' => 'site_view', 'tables' => 'site_views', 'id' => 'id', 'name' => 'name', 'text' => 'Site View'), - 'customadminview' => array('table' => 'custom_admin_view', 'tables' => 'custom_admin_views', 'id' => 'id', 'name' => 'system_name', 'text' => 'Custom Admin View'), - 'adminviews' => array('table' => 'admin_view', 'tables' => 'admin_views', 'id' => 'id', 'name' => 'system_name', 'text' => 'Admin View'), - 'adminview' => array('table' => 'admin_view', 'tables' => 'admin_views', 'id' => 'id', 'name' => 'system_name', 'text' => 'Admin View'), - 'before' => array('table' => 'admin_view', 'tables' => 'admin_views', 'id' => 'id', 'name' => 'system_name', 'text' => 'Admin View') - ); - - protected function setItemNames($header, $value) - { - if (isset($this->itemKeys[$header]) && isset($this->itemKeys[$header]['table']) && isset($this->itemNames[$this->itemKeys[$header]['table']])) - { - // reset bucket - $bucket = array(); - if (ComponentbuilderHelper::checkArray($value)) - { - foreach ($value as $item) - { - $edit = true; - if (!isset($this->itemNames[$this->itemKeys[$header]['table']][$item])) - { - if (!$this->itemNames[$this->itemKeys[$header]['table']][$item] = ComponentbuilderHelper::getVar($this->itemKeys[$header]['table'], (int) $item, $this->itemKeys[$header]['id'], $this->itemKeys[$header]['name'])) - { - $this->itemNames[$this->itemKeys[$header]['table']][$item] = JText::sprintf('COM_COMPONENTBUILDER_NO_S_FOUND', $this->itemKeys[$header]['text']); - $edit = false; - } - // check if we should load a type - if ($edit && isset($this->itemKeys[$header]['type']) && ComponentbuilderHelper::checkArray($this->itemKeys[$header]['type']) && isset($this->itemKeys[$header]['type']['table'])) - { - // get the linked value - if ($_key = ComponentbuilderHelper::getVar($this->itemKeys[$header]['table'], (int) $item, $this->itemKeys[$header]['id'], $this->itemKeys[$header]['type']['key'])) - { - $this->itemNames[$this->itemKeys[$header]['table']][$item] .= ' [' . ComponentbuilderHelper::getVar($this->itemKeys[$header]['type']['table'], (int) $_key, $this->itemKeys[$header]['type']['field'], $this->itemKeys[$header]['type']['get']) .']'; - } - } - } - // set edit link - $link = ($edit) ? ComponentbuilderHelper::getEditButton($item, $this->itemKeys[$header]['table'], $this->itemKeys[$header]['tables'], $this->ref) : ''; - // load item - $bucket[] = $this->itemNames[$this->itemKeys[$header]['table']][$item] . $link; - } - } - elseif (is_numeric($value)) - { - $edit = true; - if (!isset($this->itemNames[$this->itemKeys[$header]['table']][$value])) - { - if (!$this->itemNames[$this->itemKeys[$header]['table']][$value] = ComponentbuilderHelper::getVar($this->itemKeys[$header]['table'], (int) $value, $this->itemKeys[$header]['id'], $this->itemKeys[$header]['name'])) - { - $this->itemNames[$this->itemKeys[$header]['table']][$value] = JText::sprintf('COM_COMPONENTBUILDER_NO_S_FOUND', $this->itemKeys[$header]['text']); - $edit = false; - } - // check if we should load a type - if ($edit && isset($this->itemKeys[$header]['type']) && ComponentbuilderHelper::checkArray($this->itemKeys[$header]['type']) && isset($this->itemKeys[$header]['type']['table'])) - { - // get the linked value - if ($_key = ComponentbuilderHelper::getVar($this->itemKeys[$header]['table'], (int) $value, $this->itemKeys[$header]['id'], $this->itemKeys[$header]['type']['key'])) - { - $this->itemNames[$this->itemKeys[$header]['table']][$value] .= ' [' . ComponentbuilderHelper::getVar($this->itemKeys[$header]['type']['table'], (int) $_key, $this->itemKeys[$header]['type']['field'], $this->itemKeys[$header]['type']['get']) .']'; - } - } - } - // set edit link - $link = ($edit) ? ComponentbuilderHelper::getEditButton($value, $this->itemKeys[$header]['table'], $this->itemKeys[$header]['tables'], $this->ref) : ''; - // load item - $bucket[] = $this->itemNames[$this->itemKeys[$header]['table']][$value] . $link; - } - // return found items - if (ComponentbuilderHelper::checkArray($bucket)) - { - return implode('
', $bucket); - } - return JText::sprintf('COM_COMPONENTBUILDER_NO_S_FOUND', $this->itemKeys[$header]['text']); - } - return JText::_('COM_COMPONENTBUILDER_NO_ITEM_FOUND'); - } - protected function setPermissions($header, $values) { // check if value is array @@ -1221,7 +816,7 @@ class ComponentbuilderModelAjax extends JModelList } public function getFieldSelectOptions($id) - { + { // Create a new query object. $query = $this->_db->getQuery(true); $query->select($this->_db->quoteName(array('a.xml', 'b.name'))); @@ -1229,21 +824,21 @@ class ComponentbuilderModelAjax extends JModelList $query->join('LEFT', $this->_db->quoteName('#__componentbuilder_fieldtype', 'b') . ' ON (' . $this->_db->quoteName('a.fieldtype') . ' = ' . $this->_db->quoteName('b.id') . ')'); $query->where($this->_db->quoteName('a.published') . ' = 1'); $query->where($this->_db->quoteName('a.id') . ' = '. (int) $id); - + // Reset the query using our newly populated query object. $this->_db->setQuery($query); $this->_db->execute(); if ($this->_db->getNumRows()) { - $result = $this->_db->loadObject(); - $result->name = strtolower($result->name); + $result = $this->_db->loadObject(); + $result->name = strtolower($result->name); if (ComponentbuilderHelper::fieldCheck($result->name,'list')) { // load the values form params $xml = json_decode($result->xml); - + $xmlOptions = ComponentbuilderHelper::getBetween($xml,'option="','"'); - + $optionSet = ''; if (strpos($xmlOptions,',') !== false) { @@ -1297,18 +892,17 @@ class ComponentbuilderModelAjax extends JModelList { return 'dynamic_list'; } - } return false; } - + public function getTableColumns($tableName) { // get the columns $columns = $this->_db->getTableColumns("#__".$tableName); if (ComponentbuilderHelper::checkArray($columns)) { - // build the return string + // build the return string $tableColumns = array(); foreach ($columns as $column => $type) { @@ -1557,7 +1151,473 @@ class ComponentbuilderModelAjax extends JModelList return $linked; } return false; - } + } + + protected $viewid = array(); + + protected function getViewID($call = 'table') + { + if (!isset($this->viewid[$call])) + { + // get the vdm key + $jinput = JFactory::getApplication()->input; + $vdm = $jinput->get('vdm', null, 'WORD'); + if ($vdm) + { + // set view and id + if ($view = ComponentbuilderHelper::get($vdm)) + { + $current = (array) explode('__', $view); + if (ComponentbuilderHelper::checkString($current[0]) && isset($current[1]) && is_numeric($current[1])) + { + // get the view name & id + $this->viewid[$call] = array( + 'a_id' => (int) $current[1], + 'a_view' => $current[0] + ); + } + } + // set GUID if found + if (($guid = ComponentbuilderHelper::get($vdm . '__guid')) !== false && method_exists('ComponentbuilderHelper', 'validGUID')) + { + if (ComponentbuilderHelper::validGUID($guid)) + { + $this->viewid[$call]['a_guid'] = $guid; + } + } + // set return if found + if (($return = ComponentbuilderHelper::get($vdm . '__return')) !== false) + { + if (ComponentbuilderHelper::checkString($return)) + { + $this->viewid[$call]['a_return'] = $return; + } + } + } + } + if (isset($this->viewid[$call])) + { + return $this->viewid[$call]; + } + return false; + } + + + public function getButton($type, $size) + { + if (isset($this->buttonArray[$type])) + { + $user = JFactory::getUser(); + // only add if user allowed to create + if ($user->authorise($type.'.create', 'com_componentbuilder')) + { + // get the view name & id + $values = $this->getViewID(); + // check if new item + $ref = ''; + if (!is_null($values['a_id']) && $values['a_id'] > 0 && strlen($values['a_view'])) + { + // check if we have a return value + $return_url = 'index.php?option=com_componentbuilder&view=' . (string) $values['a_view'] . '&layout=edit&id=' . (int) $values['a_id']; + if (isset($values['a_return'])) + { + $return_url .= '&return=' . (string) $values['a_return']; + } + // only load referral if not new item. + $ref = '&ref=' . $values['a_view'] . '&refid=' . $values['a_id'] . '&return=' . urlencode(base64_encode($return_url)); + } + // build url (A tag) + $startAtag = 'onclick="UIkit2.modal.confirm(\''.JText::_('COM_COMPONENTBUILDER_ALL_UNSAVED_WORK_ON_THIS_PAGE_WILL_BE_LOST_ARE_YOU_SURE_YOU_WANT_TO_CONTINUE').'\', function(){ window.location.href = \'index.php?option=com_componentbuilder&view=' . $type . '&layout=edit' . $ref . '\' })" href="javascript:void(0)" title="'.JText::sprintf('COM_COMPONENTBUILDER_CREATE_NEW_S', ComponentbuilderHelper::safeString($type, 'W')).'">'; + // build the smallest button + if (3 == $size) + { + $button = ''; + } + // build the smaller button + elseif (2 == $size) + { + $button = ' ' . JText::_('COM_COMPONENTBUILDER_CREATE') . ''; + } + else + // build the big button + { + $button = '
+
+ +
+ +
'; + } + // return the button attached to input field + return $button; + } + return ''; + } + return false; + } + + public function getButtonID($type, $size) + { + if (isset($this->buttonArray[$type])) + { + $user = JFactory::getUser(); + // only add if user allowed to create + if ($user->authorise($type.'.create', 'com_componentbuilder')) + { + // get the view name & id + $values = $this->getViewID(); + // set the button ID + $css_class = 'control-group-'.ComponentbuilderHelper::safeString($type. '-' . $size, 'L', '-'); + // check if new item + $ref = ''; + if (!is_null($values['a_id']) && $values['a_id'] > 0 && strlen($values['a_view'])) + { + // set the return value + $return_url = 'index.php?option=com_componentbuilder&view=' . (string) $values['a_view'] . '&layout=edit&id=' . (int) $values['a_id']; + if (isset($values['a_return'])) + { + $return_url .= '&return=' . (string) $values['a_return']; + } + // only load referral if not new item. + $ref = '&ref=' . $values['a_view'] . '&refid=' . $values['a_id'] . '&return=' . urlencode(base64_encode($return_url)); + // set the key get value + $key_get_value = $values['a_id']; + // check if we have a GUID + if (isset($values['a_guid'])) + { + $ref .= '&guid=' . (string) $values['a_guid']; + $key_get_value = $values['a_guid']; + } + // get item id + if (($id = ComponentbuilderHelper::getVar($type, $key_get_value, $values['a_view'], 'id')) !== false && $id > 0) + { + $buttonText = JText::sprintf('COM_COMPONENTBUILDER_EDIT_S_FOR_THIS_S', ComponentbuilderHelper::safeString($type, 'w'), ComponentbuilderHelper::safeString($values['a_view'], 'w')); + $buttonTextSmall = JText::_('COM_COMPONENTBUILDER_EDIT'); + $editThis = 'index.php?option=com_componentbuilder&view='.$this->buttonArray[$type].'&task='.$type.'.edit&id='.$id; + $icon = 'icon-apply'; + } + else + { + $buttonText = JText::sprintf('COM_COMPONENTBUILDER_CREATE_S_FOR_THIS_S', ComponentbuilderHelper::safeString($type, 'w'), ComponentbuilderHelper::safeString($values['a_view'], 'w')); + $buttonTextSmall = JText::_('COM_COMPONENTBUILDER_CREATE'); + $editThis = 'index.php?option=com_componentbuilder&view='.$type.'&layout=edit'; + $icon = 'icon-new'; + } + // build the button + $button = array(); + if (1 == $size) + { + $button[] = '
'; + $button[] = '
'; + $button[] = ''; + $button[] = '
'; + $button[] = ''; + $button[] = '
'; + } + elseif (2 == $size) + { + $button[] = ''; + $button[] = $buttonTextSmall; + $button[] = ''; + } + // return the button attached to input field + return implode("\n", $button); + } + // only return notice if big button + if (1 == $size) + { + return '
' . JText::sprintf('COM_COMPONENTBUILDER_BUTTON_TO_CREATE_S_WILL_SHOW_ONCE_S_IS_SAVED_FOR_THE_FIRST_TIME', ComponentbuilderHelper::safeString($type, 'w'), ComponentbuilderHelper::safeString($values['a_view'], 'w')) . '
'; + } + } + } + return ''; + } + + protected function getSubformTable($idName, $data) + { + // make sure we convert the json to array + if (ComponentbuilderHelper::checkJson($data)) + { + $data = json_decode($data, true); + } + // make sure we have an array + if (ComponentbuilderHelper::checkArray($data) && ComponentbuilderHelper::checkString($idName)) + { + // Build heading + $head = array(); + foreach ($data as $headers) + { + foreach ($headers as $header => $value) + { + if (!isset($head[$header])) + { + $head[$header] = $this->getLanguage($idName . '|=VDM=|' . $header); + } + } + } + // build the rows + $rows = array(); + if (ComponentbuilderHelper::checkArray($data) && ComponentbuilderHelper::checkArray($head)) + { + foreach ($data as $nr => $values) + { + foreach ($head as $key => $_header) + { + // set the value for the row + if (isset($values[$key])) + { + $this->setSubformRows($nr, $this->setSubformValue($key, $values[$key]), $rows, $_header); + } + else + { + $this->setSubformRows($nr, $this->setSubformValue($key, ''), $rows, $_header); + } + } + } + } + // build table + if (ComponentbuilderHelper::checkArray($rows) && ComponentbuilderHelper::checkArray($head)) + { + // set the number of rows + $this->rowNumber = count($rows); + // return the table + return ComponentbuilderHelper::setSubformTable($head, $rows, $idName); + } + } + return false; + } + + protected function setSubformValue($header, $value) + { + if (array_key_exists($header, $this->functionArray) && method_exists($this, $this->functionArray[$header])) + { + $value = $this->{$this->functionArray[$header]}($header, $value); + } + // if no value are set + if (!ComponentbuilderHelper::checkString($value)) + { + $value = '-'; + } + return $value; + } + + protected function setSubformRows($nr, $value, &$rows, $_header) + { + // build rows + if (!isset($rows[$nr])) + { + $rows[$nr] = ''.$value.''; + } + else + { + $rows[$nr] .= ''.$value.''; + } + } + + public function getAjaxDisplay($type) + { + if (isset($this->fieldsArray[$type])) + { + // set type name + $typeName = ComponentbuilderHelper::safeString($type, 'w'); + // 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']) && in_array($values['a_view'], $this->allowedViewsArray)) + { + // set a return value + $return_url = 'index.php?option=com_componentbuilder&view=' . (string) $values['a_view'] . '&layout=edit&id=' . (int) $values['a_id']; + // set a global return value + if (isset($values['a_return'])) + { + $return_url .= '&return=' . (string) $values['a_return']; + } + // set the ref + $this->ref = '&ref=' . $values['a_view'] . '&refid=' . $values['a_id'] . '&return=' . urlencode(base64_encode($return_url)); + // set the key get value + $key_get_value = $values['a_id']; + // check if we have a GUID + if (isset($values['a_guid'])) + { + $this->ref .= '&guid=' . (string) $values['a_guid']; + $key_get_value = $values['a_guid']; + } + // load the results + $result = array(); + // return field table + if (ComponentbuilderHelper::checkArray($this->fieldsArray[$type])) + { + foreach ($this->fieldsArray[$type] as $fieldName) + { + if ($table = $this->getFieldTable($type, $key_get_value, $values['a_view'], $fieldName, $typeName)) + { + $result[] = $table; + } + } + } + elseif (ComponentbuilderHelper::checkString($this->fieldsArray[$type])) + { + if ($table = $this->getFieldTable($type, $key_get_value, $values['a_view'], $this->fieldsArray[$type], $typeName)) + { + $result[] = $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) . '
'; + } + 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 setItemNames($header, $value) + { + if (isset($this->itemKeys[$header]) && isset($this->itemKeys[$header]['table']) && isset($this->itemNames[$this->itemKeys[$header]['table']])) + { + // check if we have GUID setup + $validGUID = function ($guid) { + if (method_exists('ComponentbuilderHelper', 'validGUID') && ComponentbuilderHelper::validGUID($guid)) + { + return true; + } + return false; + }; + // reset bucket + $bucket = array(); + if (ComponentbuilderHelper::checkArray($value)) + { + foreach ($value as $item) + { + $edit = true; + if (!isset($this->itemNames[$this->itemKeys[$header]['table']][$item])) + { + if (($this->itemNames[$this->itemKeys[$header]['table']][$item] = ComponentbuilderHelper::getVar($this->itemKeys[$header]['table'], $item, $this->itemKeys[$header]['id'], $this->itemKeys[$header]['name'])) === false) + { + $this->itemNames[$this->itemKeys[$header]['table']][$item] = JText::sprintf('COM_COMPONENTBUILDER_NO_S_FOUND', $this->itemKeys[$header]['text']); + $edit = false; + } + // check if we should load a type + if ($edit && isset($this->itemKeys[$header]['type']) && ComponentbuilderHelper::checkArray($this->itemKeys[$header]['type']) && isset($this->itemKeys[$header]['type']['table'])) + { + // get the linked value + if (($_key = ComponentbuilderHelper::getVar($this->itemKeys[$header]['table'], $item, $this->itemKeys[$header]['id'], $this->itemKeys[$header]['type']['key'])) !== false) + { + $this->itemNames[$this->itemKeys[$header]['table']][$item] .= ' [' . ComponentbuilderHelper::getVar($this->itemKeys[$header]['type']['table'], $_key, $this->itemKeys[$header]['type']['field'], $this->itemKeys[$header]['type']['get']) .']'; + } + } + } + // check if we are working with GUID + if ($validGUID($item) && method_exists('ComponentbuilderHelper', 'getEditButtonGUID')) + { + // set edit link + $link = ($edit) ? ComponentbuilderHelper::getEditButtonGUID($item, $this->itemKeys[$header]['id'], $this->itemKeys[$header]['table'], $this->itemKeys[$header]['tables'], $this->ref) : ''; + } + else + { + // set edit link + $link = ($edit) ? ComponentbuilderHelper::getEditButton($item, $this->itemKeys[$header]['table'], $this->itemKeys[$header]['tables'], $this->ref) : ''; + } + // load item + $bucket[] = $this->itemNames[$this->itemKeys[$header]['table']][$item] . $link; + } + } + elseif (is_numeric($value) || $validGUID($value)) + { + $edit = true; + if (!isset($this->itemNames[$this->itemKeys[$header]['table']][$value])) + { + if (($this->itemNames[$this->itemKeys[$header]['table']][$value] = ComponentbuilderHelper::getVar($this->itemKeys[$header]['table'], $value, $this->itemKeys[$header]['id'], $this->itemKeys[$header]['name'])) === false) + { + $this->itemNames[$this->itemKeys[$header]['table']][$value] = JText::sprintf('COM_COMPONENTBUILDER_NO_S_FOUND', $this->itemKeys[$header]['text']); + $edit = false; + } + // check if we should load a type + if ($edit && isset($this->itemKeys[$header]['type']) && ComponentbuilderHelper::checkArray($this->itemKeys[$header]['type']) && isset($this->itemKeys[$header]['type']['table'])) + { + // get the linked value + if (($_key = ComponentbuilderHelper::getVar($this->itemKeys[$header]['table'], $value, $this->itemKeys[$header]['id'], $this->itemKeys[$header]['type']['key'])) !== false) + { + $this->itemNames[$this->itemKeys[$header]['table']][$value] .= ' [' . ComponentbuilderHelper::getVar($this->itemKeys[$header]['type']['table'], $_key, $this->itemKeys[$header]['type']['field'], $this->itemKeys[$header]['type']['get']) .']'; + } + } + } + // check if we are working with GUID + if ($validGUID($value) && method_exists('ComponentbuilderHelper', 'getEditButtonGUID')) + { + // set edit link + $link = ($edit) ? ComponentbuilderHelper::getEditButtonGUID($value, $this->itemKeys[$header]['id'], $this->itemKeys[$header]['table'], $this->itemKeys[$header]['tables'], $this->ref) : ''; + } + else + { + // set edit link + $link = ($edit) ? ComponentbuilderHelper::getEditButton($value, $this->itemKeys[$header]['table'], $this->itemKeys[$header]['tables'], $this->ref) : ''; + } + // load item + $bucket[] = $this->itemNames[$this->itemKeys[$header]['table']][$value] . $link; + } + // return found items + if (ComponentbuilderHelper::checkArray($bucket)) + { + return implode('
', $bucket); + } + return JText::sprintf('COM_COMPONENTBUILDER_NO_S_FOUND', $this->itemKeys[$header]['text']); + } + return JText::_('COM_COMPONENTBUILDER_NO_ITEM_FOUND'); + } + + + protected function getFieldTable($type, $id, $idName, $fieldName, $typeName) + { + // get the field data + if (($fieldsData = ComponentbuilderHelper::getVar($type, $id, $idName, $fieldName)) !== false) + { + // check repeatable conversion + if (method_exists(__CLASS__, 'checkRepeatableConversion')) + { + $this->checkRepeatableConversion($fieldsData, $fieldName, $id, $idName); + } + // get the table + $table = $this->getSubformTable($type, $fieldsData); + // get row number + $number = (isset($this->rowNumbers) && isset($this->rowNumbers[$type]) && $this->rowNumbers[$type]) ? $this->rowNumbers[$type] : false; + // set notice of bad practice + $notice = ''; + if ($number && isset($this->rowNumber) && $this->rowNumber > $number) + { + $notice = '
' . JText::sprintf('COM_COMPONENTBUILDER_YOU_HAVE_S_S_ADDING_MORE_THEN_S_S_IS_CONSIDERED_BAD_PRACTICE_YOUR_S_PAGE_LOAD_IN_JCB_WILL_SLOWDOWN_YOU_SHOULD_CONSIDER_DECOUPLING_SOME_OF_THESE_S', $this->rowNumber, $typeName, $number, $typeName, $typeName, $typeName) . '
'; + } + elseif ($number && isset($this->rowNumber)) + { + $notice = '
' . JText::sprintf('COM_COMPONENTBUILDER_YOU_HAVE_S_S_ADDING_MORE_THEN_S_S_IS_CONSIDERED_BAD_PRACTICE', $this->rowNumber, $typeName, $number, $typeName) . '
'; + } + // return table + return $notice . $table; + } + return false; + } + // Used in template public function getTemplateDetails($id) diff --git a/admin/models/class_extends.php b/admin/models/class_extends.php index 804cd34d8..cd3ba03ac 100644 --- a/admin/models/class_extends.php +++ b/admin/models/class_extends.php @@ -72,14 +72,51 @@ class ComponentbuilderModelClass_extends extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + /** - * get VDM session key + * get VDM internal session key * * @return string the session key * */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('class_extends__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'class_extends__'.$id); + ComponentbuilderHelper::set('class_extends__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } @@ -149,6 +186,13 @@ class ComponentbuilderModelClass_extends extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } if (!empty($item->id)) diff --git a/admin/models/class_method.php b/admin/models/class_method.php index c54a78a99..06d0fd51e 100644 --- a/admin/models/class_method.php +++ b/admin/models/class_method.php @@ -75,14 +75,51 @@ class ComponentbuilderModelClass_method extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + /** - * get VDM session key + * get VDM internal session key * * @return string the session key * */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('class_method__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'class_method__'.$id); + ComponentbuilderHelper::set('class_method__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } @@ -158,6 +195,13 @@ class ComponentbuilderModelClass_method extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } if (!empty($item->id)) diff --git a/admin/models/class_property.php b/admin/models/class_property.php index 9642f1768..b7ef158db 100644 --- a/admin/models/class_property.php +++ b/admin/models/class_property.php @@ -72,14 +72,51 @@ class ComponentbuilderModelClass_property extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + /** - * get VDM session key + * get VDM internal session key * * @return string the session key * */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('class_property__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'class_property__'.$id); + ComponentbuilderHelper::set('class_property__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } @@ -149,6 +186,13 @@ class ComponentbuilderModelClass_property extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } if (!empty($item->id)) diff --git a/admin/models/component_dashboard.php b/admin/models/component_dashboard.php index 855bba7d6..a1460f7fb 100644 --- a/admin/models/component_dashboard.php +++ b/admin/models/component_dashboard.php @@ -70,10 +70,54 @@ class ComponentbuilderModelComponent_dashboard extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + + /** + * get VDM internal session key + * + * @return string the session key + * + */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('component_dashboard__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'component_dashboard__'.$id); + ComponentbuilderHelper::set('component_dashboard__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } + /** * Method to get a single record. @@ -142,6 +186,13 @@ class ComponentbuilderModelComponent_dashboard extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } // update the fields $objectUpdate = new stdClass(); diff --git a/admin/models/custom_admin_view.php b/admin/models/custom_admin_view.php index e19b76c45..038684eb1 100644 --- a/admin/models/custom_admin_view.php +++ b/admin/models/custom_admin_view.php @@ -134,14 +134,51 @@ class ComponentbuilderModelCustom_admin_view extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + /** - * get VDM session key + * get VDM internal session key * * @return string the session key * */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('custom_admin_view__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'custom_admin_view__'.$id); + ComponentbuilderHelper::set('custom_admin_view__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } @@ -303,6 +340,13 @@ class ComponentbuilderModelCustom_admin_view extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } // check what type of custom_button array we have here (should be subform... but just incase) diff --git a/admin/models/custom_code.php b/admin/models/custom_code.php index cc36476c2..33c9aa537 100644 --- a/admin/models/custom_code.php +++ b/admin/models/custom_code.php @@ -87,14 +87,51 @@ class ComponentbuilderModelCustom_code extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + /** - * get VDM session key + * get VDM internal session key * * @return string the session key * */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('custom_code__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'custom_code__'.$id); + ComponentbuilderHelper::set('custom_code__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } @@ -158,6 +195,13 @@ class ComponentbuilderModelCustom_code extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } if (!empty($item->id)) diff --git a/admin/models/dynamic_get.php b/admin/models/dynamic_get.php index cd48b4f0d..faf71c97b 100644 --- a/admin/models/dynamic_get.php +++ b/admin/models/dynamic_get.php @@ -127,14 +127,51 @@ class ComponentbuilderModelDynamic_get extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + /** - * get VDM session key + * get VDM internal session key * * @return string the session key * */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('dynamic_get__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'dynamic_get__'.$id); + ComponentbuilderHelper::set('dynamic_get__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } @@ -302,6 +339,13 @@ class ComponentbuilderModelDynamic_get extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } // update the fields diff --git a/admin/models/field.php b/admin/models/field.php index b95612521..34225d89b 100644 --- a/admin/models/field.php +++ b/admin/models/field.php @@ -118,14 +118,51 @@ class ComponentbuilderModelField extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + /** - * get VDM session key + * get VDM internal session key * * @return string the session key * */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('field__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'field__'.$id); + ComponentbuilderHelper::set('field__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } @@ -237,6 +274,13 @@ class ComponentbuilderModelField extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } if (!empty($item->id)) diff --git a/admin/models/fieldtype.php b/admin/models/fieldtype.php index 538d4d8d3..927f9594b 100644 --- a/admin/models/fieldtype.php +++ b/admin/models/fieldtype.php @@ -93,14 +93,51 @@ class ComponentbuilderModelFieldtype extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + /** - * get VDM session key + * get VDM internal session key * * @return string the session key * */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('fieldtype__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'fieldtype__'.$id); + ComponentbuilderHelper::set('fieldtype__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } @@ -166,6 +203,13 @@ class ComponentbuilderModelFieldtype extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } // check what type of properties array we have here (should be subform... but just incase) // This could happen due to huge data sets diff --git a/admin/models/forms/custom_code.js b/admin/models/forms/custom_code.js index 81d09a518..8b4ce9868 100644 --- a/admin/models/forms/custom_code.js +++ b/admin/models/forms/custom_code.js @@ -345,7 +345,7 @@ function usedin(functioName, ide) { function usedin_server(functioName, ide, target){ var getUrl = "index.php?option=com_componentbuilder&task=ajax.usedin&format=json"; if(token.length > 0){ - var request = 'token='+token+'&functioName='+functioName+'&id='+ide+'&target='+target+'&raw=true&return_here='+return_here; + var request = token+'=1&functioName='+functioName+'&id='+ide+'&target='+target+'&raw=true&return_here='+return_here; } return jQuery.ajax({ type: 'GET', diff --git a/admin/models/forms/field.js b/admin/models/forms/field.js index e10251e1f..49334681d 100644 --- a/admin/models/forms/field.js +++ b/admin/models/forms/field.js @@ -855,33 +855,42 @@ function getFieldOptions(fieldtype, db){ jQuery('#jform_datatype').val(result.database.datatype); jQuery('#jform_datatype').trigger("liszt:updated"); jQuery('#jform_datatype').trigger("change"); + // be sure to remove from no required + updateFieldRequired('datatype', 0); // update datalenght jQuery('#jform_datalenght').val(result.database.datalenght); jQuery('#jform_datalenght').trigger("liszt:updated"); jQuery('#jform_datalenght').trigger("change"); + // be sure to remove from no required + updateFieldRequired('datalenght', 0); // load the datalenght_other if needed - if ('Other' == result.database.datalenght){ + if ('Other' === result.database.datalenght){ jQuery('#jform_datalenght_other').val(result.database.datalenght_other); + // be sure to remove from no required + updateFieldRequired('datalenght_other', 0); } // update datadefault jQuery('#jform_datadefault').val(result.database.datadefault); jQuery('#jform_datadefault').trigger("liszt:updated"); jQuery('#jform_datadefault').trigger("change"); // load the datadefault_other if needed - if ('Other' == result.database.datadefault){ + if ('Other' === result.database.datadefault){ jQuery('#jform_datadefault_other').val(result.database.datadefault_other); + // be sure to remove from no required + updateFieldRequired('datadefault_other', 0); } // update indexes jQuery('#jform_indexes').val(result.database.indexes); jQuery('#jform_indexes').trigger("liszt:updated"); jQuery('#jform_indexes').trigger("change"); + // be sure to remove from no required + updateFieldRequired('indexes', 0); // update store jQuery('#jform_store').val(result.database.store); jQuery('#jform_store').trigger("liszt:updated"); jQuery('#jform_store').trigger("change"); - // update null_switch (hmmm) - // jQuery('#jform_null_switch').val(result.database.null_switch); - // jQuery('#jform_null_switch').trigger("change"); + // be sure to remove from no required + updateFieldRequired('store', 0); } } }) diff --git a/admin/models/forms/placeholder.js b/admin/models/forms/placeholder.js index a36ec605d..df818aa19 100644 --- a/admin/models/forms/placeholder.js +++ b/admin/models/forms/placeholder.js @@ -110,7 +110,7 @@ function placedin(placeholder, ide) { function placedin_server(placeholder, ide, target){ var getUrl = "index.php?option=com_componentbuilder&task=ajax.placedin&format=json"; if(token.length > 0){ - var request = 'token='+token+'&placeholder='+placeholder+'&id='+ide+'&target='+target+'&raw=true&return_here='+return_here; + var request = token+'=1&placeholder='+placeholder+'&id='+ide+'&target='+target+'&raw=true&return_here='+return_here; } return jQuery.ajax({ type: 'GET', diff --git a/admin/models/joomla_component.php b/admin/models/joomla_component.php index 3f88112b8..717cd6477 100644 --- a/admin/models/joomla_component.php +++ b/admin/models/joomla_component.php @@ -238,14 +238,51 @@ class ComponentbuilderModelJoomla_component extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + /** - * get VDM session key + * get VDM internal session key * * @return string the session key * */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('joomla_component__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'joomla_component__'.$id); + ComponentbuilderHelper::set('joomla_component__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } @@ -448,6 +485,13 @@ class ComponentbuilderModelJoomla_component extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } // update the fields diff --git a/admin/models/joomla_plugin.php b/admin/models/joomla_plugin.php index 1d025f130..fe600562d 100644 --- a/admin/models/joomla_plugin.php +++ b/admin/models/joomla_plugin.php @@ -134,14 +134,51 @@ class ComponentbuilderModelJoomla_plugin extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + /** - * get VDM session key + * get VDM internal session key * * @return string the session key * */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('joomla_plugin__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'joomla_plugin__'.$id); + ComponentbuilderHelper::set('joomla_plugin__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } @@ -295,6 +332,13 @@ class ComponentbuilderModelJoomla_plugin extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } if (!empty($item->id)) diff --git a/admin/models/language_translation.php b/admin/models/language_translation.php index 5d71122fb..580fb9d9d 100644 --- a/admin/models/language_translation.php +++ b/admin/models/language_translation.php @@ -67,10 +67,54 @@ class ComponentbuilderModelLanguage_translation extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + + /** + * get VDM internal session key + * + * @return string the session key + * + */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('language_translation__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'language_translation__'.$id); + ComponentbuilderHelper::set('language_translation__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } + /** * Method to get a single record. @@ -139,6 +183,13 @@ class ComponentbuilderModelLanguage_translation extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } if (!empty($item->id)) diff --git a/admin/models/layout.php b/admin/models/layout.php index 2f8fb6bb6..119cea1f7 100644 --- a/admin/models/layout.php +++ b/admin/models/layout.php @@ -91,14 +91,51 @@ class ComponentbuilderModelLayout extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + /** - * get VDM session key + * get VDM internal session key * * @return string the session key * */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('layout__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'layout__'.$id); + ComponentbuilderHelper::set('layout__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } @@ -176,6 +213,13 @@ class ComponentbuilderModelLayout extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } if (!empty($item->id)) diff --git a/admin/models/library.php b/admin/models/library.php index f9ddd66b5..4878c4d0b 100644 --- a/admin/models/library.php +++ b/admin/models/library.php @@ -105,14 +105,51 @@ class ComponentbuilderModelLibrary extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + /** - * get VDM session key + * get VDM internal session key * * @return string the session key * */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('library__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'library__'.$id); + ComponentbuilderHelper::set('library__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } @@ -192,6 +229,13 @@ class ComponentbuilderModelLibrary extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } if (!empty($item->id)) diff --git a/admin/models/placeholder.php b/admin/models/placeholder.php index f2ee9f5e9..ea5e418bc 100644 --- a/admin/models/placeholder.php +++ b/admin/models/placeholder.php @@ -71,14 +71,51 @@ class ComponentbuilderModelPlaceholder extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + /** - * get VDM session key + * get VDM internal session key * * @return string the session key * */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('placeholder__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'placeholder__'.$id); + ComponentbuilderHelper::set('placeholder__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } @@ -142,6 +179,13 @@ class ComponentbuilderModelPlaceholder extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } if (!empty($item->id)) diff --git a/admin/models/site_view.php b/admin/models/site_view.php index 08853c59d..7b34d2c02 100644 --- a/admin/models/site_view.php +++ b/admin/models/site_view.php @@ -137,14 +137,51 @@ class ComponentbuilderModelSite_view extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + /** - * get VDM session key + * get VDM internal session key * * @return string the session key * */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('site_view__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'site_view__'.$id); + ComponentbuilderHelper::set('site_view__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } @@ -306,6 +343,13 @@ class ComponentbuilderModelSite_view extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } // update the fields diff --git a/admin/models/template.php b/admin/models/template.php index 4681f4d63..219622116 100644 --- a/admin/models/template.php +++ b/admin/models/template.php @@ -91,14 +91,51 @@ class ComponentbuilderModelTemplate extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + /** - * get VDM session key + * get VDM internal session key * * @return string the session key * */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('template__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'template__'.$id); + ComponentbuilderHelper::set('template__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } @@ -176,6 +213,13 @@ class ComponentbuilderModelTemplate extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } if (!empty($item->id)) diff --git a/admin/models/validation_rule.php b/admin/models/validation_rule.php index 863789bae..3fd38b852 100644 --- a/admin/models/validation_rule.php +++ b/admin/models/validation_rule.php @@ -74,14 +74,51 @@ class ComponentbuilderModelValidation_rule extends JModelAdmin return JTable::getInstance($type, $prefix, $config); } + /** - * get VDM session key + * get VDM internal session key * * @return string the session key * */ public function getVDM() { + if (!isset($this->vastDevMod)) + { + $_id = 0; // new item probably (since it was not set in the getItem method) + + if (empty($_id)) + { + $id = 0; + } + else + { + $id = $_id; + } + // set the id and view name to session + if ($vdm = ComponentbuilderHelper::get('validation_rule__'.$id)) + { + $this->vastDevMod = $vdm; + } + else + { + // set the vast development method key + $this->vastDevMod = ComponentbuilderHelper::randomkey(50); + ComponentbuilderHelper::set($this->vastDevMod, 'validation_rule__'.$id); + ComponentbuilderHelper::set('validation_rule__'.$id, $this->vastDevMod); + // set a return value if found + $jinput = JFactory::getApplication()->input; + $return = $jinput->get('return', null, 'base64'); + ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } + } + } return $this->vastDevMod; } @@ -145,6 +182,13 @@ class ComponentbuilderModelValidation_rule extends JModelAdmin $jinput = JFactory::getApplication()->input; $return = $jinput->get('return', null, 'base64'); ComponentbuilderHelper::set($this->vastDevMod . '__return', $return); + // set a GUID value if found + if (isset($item) && ComponentbuilderHelper::checkObject($item) && isset($item->guid) + && method_exists('ComponentbuilderHelper', 'validGUID') + && ComponentbuilderHelper::validGUID($item->guid)) + { + ComponentbuilderHelper::set($this->vastDevMod . '__guid', $item->guid); + } } if (!empty($item->id)) diff --git a/admin/views/joomla_components/tmpl/default_body.php b/admin/views/joomla_components/tmpl/default_body.php index c45fbf2e4..07baaa81e 100644 --- a/admin/views/joomla_components/tmpl/default_body.php +++ b/admin/views/joomla_components/tmpl/default_body.php @@ -73,6 +73,11 @@ $edit = "index.php?option=com_componentbuilder&view=joomla_components&task=jooml - escape($item->component_version); ?> return_here is set + if (!isset($this->return_here)) + { + $this->return_here = urlencode(base64_encode((string) JUri::getInstance())); + } // setup the buttons if (!isset($_buttons) || !ComponentbuilderHelper::checkArray($_buttons)) { diff --git a/componentbuilder.xml b/componentbuilder.xml index 84635c886..8fb3b9e1c 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 16th October, 2019 + 8th November, 2019 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://www.joomlacomponentbuilder.com diff --git a/site/helpers/componentbuilder.php b/site/helpers/componentbuilder.php index 62d7fd0c8..d9e9f4a86 100644 --- a/site/helpers/componentbuilder.php +++ b/site/helpers/componentbuilder.php @@ -834,13 +834,13 @@ abstract class ComponentbuilderHelper */ public static function getContributorDetails($filename, $type = 'snippet') { - // start loading he contributor details + // start loading the contributor details $contributor = array(); // get the path & content switch ($type) { case 'snippet': - $path = $snippetPath.$filename; + $path = self::$snippetPath.$filename; // get the file if available $content = self::getFileContents($path); if (self::checkJson($content)) @@ -2043,17 +2043,17 @@ abstract class ComponentbuilderHelper /** - * the Butler + * the Butler **/ public static $session = array(); /** - * the Butler Assistant + * the Butler Assistant **/ protected static $localSession = array(); /** - * start a session if not already set, and load with data + * start a session if not already set, and load with data **/ public static function loadSession() { @@ -2066,7 +2066,7 @@ abstract class ComponentbuilderHelper } /** - * give Session more to keep + * give Session more to keep **/ public static function set($key, $value) { @@ -2081,7 +2081,7 @@ abstract class ComponentbuilderHelper } /** - * get info from Session + * get info from Session **/ public static function get($key, $default = null) { @@ -4304,12 +4304,12 @@ abstract class ComponentbuilderHelper } /** - * Composer Switch + * Composer Switch **/ protected static $composer = array(); /** - * Load the Composer Vendors + * Load the Composer Vendors **/ public static function composerAutoload($target) { @@ -4330,7 +4330,7 @@ abstract class ComponentbuilderHelper /** - * Load the Composer Vendor phpseclib + * Load the Composer Vendor phpseclib **/ protected static function composephpseclib() { @@ -4338,6 +4338,8 @@ abstract class ComponentbuilderHelper require_once JPATH_SITE . '/libraries/phpseclib/vendor/autoload.php'; // do not load again self::$composer['phpseclib'] = true; + + return true; } @@ -6228,7 +6230,15 @@ abstract class ComponentbuilderHelper { $query->from($db->quoteName('#_'.$main.'_'.$table)); } - $query->where($db->quoteName($whereString) . ' '.$operator.' (' . implode(',',$where) . ')'); + // add strings to array search + if ('IN_STRINGS' === $operator || 'NOT IN_STRINGS' === $operator) + { + $query->where($db->quoteName($whereString) . ' ' . str_replace('_STRINGS', '', $operator) . ' ("' . implode('","',$where) . '")'); + } + else + { + $query->where($db->quoteName($whereString) . ' ' . $operator . ' (' . implode(',',$where) . ')'); + } $db->setQuery($query); $db->execute(); if ($db->getNumRows())