From 850b5867e1e453f98e7994fbf1bfededd106970c Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Sat, 20 Jan 2018 14:23:36 +0200 Subject: [PATCH 1/3] Few bug fixes to the translation manager --- README.md | 4 +- admin/README.txt | 4 +- admin/models/import_language_translations.php | 64 +++++++++++++------ admin/models/joomla_component.php | 26 +++++--- admin/models/language_translation.php | 6 +- admin/models/language_translations.php | 52 ++++++++++----- componentbuilder.xml | 2 +- 7 files changed, 105 insertions(+), 53 deletions(-) diff --git a/README.md b/README.md index ced6e2e9f..970871d20 100644 --- a/README.md +++ b/README.md @@ -126,11 +126,11 @@ Component Builder is mapped as a component in itself on my local development env + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](http://joomlacomponentbuilder.com) + *First Build*: 30th April, 2015 -+ *Last Build*: 19th January, 2018 ++ *Last Build*: 20th January, 2018 + *Version*: 2.6.12 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **180465** ++ *Line count*: **180517** + *Field count*: **1573** + *File count*: **1160** + *Folder count*: **186** diff --git a/admin/README.txt b/admin/README.txt index ced6e2e9f..970871d20 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -126,11 +126,11 @@ Component Builder is mapped as a component in itself on my local development env + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](http://joomlacomponentbuilder.com) + *First Build*: 30th April, 2015 -+ *Last Build*: 19th January, 2018 ++ *Last Build*: 20th January, 2018 + *Version*: 2.6.12 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **180465** ++ *Line count*: **180517** + *Field count*: **1573** + *File count*: **1160** + *Folder count*: **186** diff --git a/admin/models/import_language_translations.php b/admin/models/import_language_translations.php index 56ea20c3d..1b01ae202 100644 --- a/admin/models/import_language_translations.php +++ b/admin/models/import_language_translations.php @@ -501,9 +501,10 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy // raw items import & update! $query = $db->getQuery(true); $query - ->select('version') + ->select($db->quoteName(array('version', 'translation'))) ->from($db->quoteName('#__componentbuilder_'.$table)) - ->where($db->quoteName('id') . ' = '. $db->quote($row[$id_key])); + ->where($db->quoteName('id') . ' = '. $db->quote($row[$id_key])) + ->where($db->quoteName('entranslation') . ' = '. $db->quote($row[$english_key])); // Reset the query using our newly populated query object. $db->setQuery($query); $db->execute(); @@ -514,14 +515,25 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy { // update item $id = $row[$id_key]; - $version = $db->loadResult(); + $item = $db->loadObject(); + // load previous translation strings + if (ComponentbuilderHelper::checkJson($item->translation)) + { + $translations = json_decode($item->translation, true); + $counter = count($translations) + 2; + $pre = true; + } + else + { + $translations = array(); + $counter = 0; + $pre = false; + } // get languages $languages = ComponentbuilderHelper::getVars('language', 1, 'published', 'langtag'); // reset all buckets $query = $db->getQuery(true); $fields = array(); - $translations = array(); - $counter = 0; // Fields to update. foreach($row as $key => $cell) { @@ -533,7 +545,7 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy // update version if ('version' == $target[$key]) { - $cell = (int) $version + 1; + $cell = (int) $item->version + 1; } // verify publish authority if ('published' == $target[$key] && !$canState) @@ -546,6 +558,20 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy // only add if it has a string if (ComponentbuilderHelper::checkString($cell)) { + // remove if was set previously + if ($pre) + { + $tag = $target[$key]; + $translations = array_filter( + $translations, + function($trans) use($tag) { + if ($trans['language'] !== $tag) + { + return true; + } + return false; + }); + } $translations['translation'.$counter] = array('language' => $target[$key], 'translation' => $cell); $counter++; } @@ -569,22 +595,18 @@ class ComponentbuilderModelImport_language_translations extends JModelLegacy if (ComponentbuilderHelper::checkArray($translations)) { $fields[] = $db->quoteName('translation') . ' = ' . $db->quote(json_encode($translations, JSON_FORCE_OBJECT)); - } - // load the defaults - $fields[] = $db->quoteName('modified_by') . ' = ' . $db->quote($user->id); - $fields[] = $db->quoteName('modified') . ' = ' . $db->quote($todayDate); - // Conditions for which records should be updated. - $conditions = array( - $db->quoteName('id') . ' = ' . $id - ); + // load the defaults + $fields[] = $db->quoteName('modified_by') . ' = ' . $db->quote($user->id); + $fields[] = $db->quoteName('modified') . ' = ' . $db->quote($todayDate); + // Conditions for which records should be updated. + $conditions = array( + $db->quoteName('id') . ' = ' . $id + ); - $query->update($db->quoteName('#__componentbuilder_'.$table))->set($fields)->where($conditions); - $db->setQuery($query); - $db->execute(); - } - else - { - return false; + $query->update($db->quoteName('#__componentbuilder_'.$table))->set($fields)->where($conditions); + $db->setQuery($query); + $db->execute(); + } } } return true; diff --git a/admin/models/joomla_component.php b/admin/models/joomla_component.php index 17e664989..5e7ac68c9 100644 --- a/admin/models/joomla_component.php +++ b/admin/models/joomla_component.php @@ -418,6 +418,8 @@ class ComponentbuilderModelJoomla_component extends JModelAdmin // prep the lang strings for export if (isset($_export) && $_export && ComponentbuilderHelper::checkArray($items)) { + // insure we have the same order in the languages + $languages = ComponentbuilderHelper::getVars('language', 1, 'published', 'langtag'); foreach ($items as $nr => &$item) { // remove some values completely @@ -432,18 +434,26 @@ class ComponentbuilderModelJoomla_component extends JModelAdmin unset($item->hits); unset($item->access); unset($item->ordering); - // now adapt the entranslation - if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation)) + // set the lang order + if ($nr != 0) { - $translations = json_decode($item->translation, true); - if (ComponentbuilderHelper::checkArray($translations)) + foreach ($languages as $lanTag) { - foreach ($translations as $language) + $item->{$lanTag} = ''; + } + // now adapt the entranslation + if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation)) + { + $translations = json_decode($item->translation, true); + if (ComponentbuilderHelper::checkArray($translations)) { - if (isset($language['translation']) && ComponentbuilderHelper::checkString($language['translation']) - && isset($language['language']) && ComponentbuilderHelper::checkString($language['language'])) + foreach ($translations as $language) { - $item->{$language['language']} = $language['translation']; + if (isset($language['translation']) && ComponentbuilderHelper::checkString($language['translation']) + && isset($language['language']) && ComponentbuilderHelper::checkString($language['language'])) + { + $item->{$language['language']} = $language['translation']; + } } } } diff --git a/admin/models/language_translation.php b/admin/models/language_translation.php index 77370ad75..40ced8708 100644 --- a/admin/models/language_translation.php +++ b/admin/models/language_translation.php @@ -107,13 +107,13 @@ class ComponentbuilderModelLanguage_translation extends JModelAdmin $translation->loadString($item->translation); $item->translation = $translation->toArray(); } - + if (!empty($item->components)) { // JSON Decode components. - $item->components = json_decode($item->components); + $item->components = json_decode($item->components, true); } - + if (empty($item->id)) { diff --git a/admin/models/language_translations.php b/admin/models/language_translations.php index c682b59e4..45c6fbf18 100644 --- a/admin/models/language_translations.php +++ b/admin/models/language_translations.php @@ -164,6 +164,8 @@ class ComponentbuilderModelLanguage_translations extends JModelList // prep the lang strings for export if (isset($_export) && $_export && ComponentbuilderHelper::checkArray($items)) { + // insure we have the same order in the languages + $languages = ComponentbuilderHelper::getVars('language', 1, 'published', 'langtag'); foreach ($items as $nr => &$item) { // remove some values completely @@ -178,18 +180,26 @@ class ComponentbuilderModelLanguage_translations extends JModelList unset($item->hits); unset($item->access); unset($item->ordering); - // now adapt the entranslation - if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation)) + // set the lang order + if ($nr != 0) { - $translations = json_decode($item->translation, true); - if (ComponentbuilderHelper::checkArray($translations)) + foreach ($languages as $lanTag) { - foreach ($translations as $language) + $item->{$lanTag} = ''; + } + // now adapt the entranslation + if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation)) + { + $translations = json_decode($item->translation, true); + if (ComponentbuilderHelper::checkArray($translations)) { - if (isset($language['translation']) && ComponentbuilderHelper::checkString($language['translation']) - && isset($language['language']) && ComponentbuilderHelper::checkString($language['language'])) + foreach ($translations as $language) { - $item->{$language['language']} = $language['translation']; + if (isset($language['translation']) && ComponentbuilderHelper::checkString($language['translation']) + && isset($language['language']) && ComponentbuilderHelper::checkString($language['language'])) + { + $item->{$language['language']} = $language['translation']; + } } } } @@ -387,6 +397,8 @@ class ComponentbuilderModelLanguage_translations extends JModelList // prep the lang strings for export if (isset($_export) && $_export && ComponentbuilderHelper::checkArray($items)) { + // insure we have the same order in the languages + $languages = ComponentbuilderHelper::getVars('language', 1, 'published', 'langtag'); foreach ($items as $nr => &$item) { // remove some values completely @@ -401,18 +413,26 @@ class ComponentbuilderModelLanguage_translations extends JModelList unset($item->hits); unset($item->access); unset($item->ordering); - // now adapt the entranslation - if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation)) + // set the lang order + if ($nr != 0) { - $translations = json_decode($item->translation, true); - if (ComponentbuilderHelper::checkArray($translations)) + foreach ($languages as $lanTag) { - foreach ($translations as $language) + $item->{$lanTag} = ''; + } + // now adapt the entranslation + if (isset($item->translation) && ComponentbuilderHelper::checkJson($item->translation)) + { + $translations = json_decode($item->translation, true); + if (ComponentbuilderHelper::checkArray($translations)) { - if (isset($language['translation']) && ComponentbuilderHelper::checkString($language['translation']) - && isset($language['language']) && ComponentbuilderHelper::checkString($language['language'])) + foreach ($translations as $language) { - $item->{$language['language']} = $language['translation']; + if (isset($language['translation']) && ComponentbuilderHelper::checkString($language['translation']) + && isset($language['language']) && ComponentbuilderHelper::checkString($language['language'])) + { + $item->{$language['language']} = $language['translation']; + } } } } diff --git a/componentbuilder.xml b/componentbuilder.xml index 3db462a41..349cb6464 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 19th January, 2018 + 20th January, 2018 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://joomlacomponentbuilder.com -- 2.40.1 From 1c20e2ef8b0cb725c104502d996fd3031810263c Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Wed, 24 Jan 2018 00:05:57 +0200 Subject: [PATCH 2/3] Added Dynamic Router Implementation to resolve gh-74 --- README.md | 12 +- admin/README.txt | 12 +- admin/compiler/joomla_3/router.php | 2 +- admin/controllers/ajax.json.php | 6 +- admin/custom/dropbox.php | 403 +++++++++++++---- admin/custom/dropboxupdater.php | 2 +- admin/helpers/compiler/a_Get.php | 2 +- admin/helpers/compiler/e_Interpretation.php | 65 +-- admin/helpers/componentbuilder.php | 113 +++-- .../en-GB/en-GB.com_componentbuilder.ini | 9 +- .../dynamic_get/custom_script_fullwidth.php | 4 +- admin/layouts/fieldtype/fields_fullwidth.php | 2 +- .../ftp/linked_components_fullwidth.php | 2 +- admin/models/ajax.php | 6 +- admin/models/dynamic_get.php | 54 ++- admin/models/dynamic_gets.php | 2 + admin/models/fieldtype.php | 12 +- admin/models/forms/admin_view.js | 22 +- admin/models/forms/custom_code.js | 88 ++-- admin/models/forms/dynamic_get.js | 173 ++++++++ admin/models/forms/dynamic_get.xml | 417 +++++++++--------- admin/models/forms/field.js | 282 ++++++------ admin/models/forms/help_document.js | 174 ++++---- admin/models/forms/library.js | 338 +++++++------- admin/models/ftp.php | 2 +- admin/sql/install.mysql.utf8.sql | 3 + admin/sql/updates/mysql/2.6.12.sql | 3 + admin/views/admin_view/tmpl/edit.php | 2 +- admin/views/custom_code/tmpl/edit.php | 170 +++---- admin/views/dynamic_get/tmpl/edit.php | 56 +++ admin/views/field/tmpl/edit.php | 108 ++--- admin/views/fieldtype/view.html.php | 2 +- admin/views/ftp/view.html.php | 2 +- admin/views/help_document/tmpl/edit.php | 60 +-- admin/views/library/tmpl/edit.php | 100 ++--- componentbuilder.xml | 6 +- componentbuilder_update_server.xml | 17 + script.php | 10 +- site/router.php | 2 +- 39 files changed, 1648 insertions(+), 1097 deletions(-) create mode 100644 admin/sql/updates/mysql/2.6.12.sql diff --git a/README.md b/README.md index 970871d20..be1bde531 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will safe you lots of time and money. A real must have! -You can install it quite easily and with no limitations. On [github](https://github.com/vdm-io/Joomla-Component-Builder/releases) is the latest release (2.6.12) with **ALL** its features and **ALL** concepts totally open-source and free! +You can install it quite easily and with no limitations. On [github](https://github.com/vdm-io/Joomla-Component-Builder/releases) is the latest release (2.6.13) with **ALL** its features and **ALL** concepts totally open-source and free! > Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45) @@ -126,13 +126,13 @@ Component Builder is mapped as a component in itself on my local development env + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](http://joomlacomponentbuilder.com) + *First Build*: 30th April, 2015 -+ *Last Build*: 20th January, 2018 -+ *Version*: 2.6.12 ++ *Last Build*: 23rd January, 2018 ++ *Version*: 2.6.13 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **180517** -+ *Field count*: **1573** -+ *File count*: **1160** ++ *Line count*: **180832** ++ *Field count*: **1577** ++ *File count*: **1161** + *Folder count*: **186** > This **component** was build with a Joomla [Automated Component Builder](http://joomlacomponentbuilder.com). diff --git a/admin/README.txt b/admin/README.txt index 970871d20..be1bde531 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will safe you lots of time and money. A real must have! -You can install it quite easily and with no limitations. On [github](https://github.com/vdm-io/Joomla-Component-Builder/releases) is the latest release (2.6.12) with **ALL** its features and **ALL** concepts totally open-source and free! +You can install it quite easily and with no limitations. On [github](https://github.com/vdm-io/Joomla-Component-Builder/releases) is the latest release (2.6.13) with **ALL** its features and **ALL** concepts totally open-source and free! > Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45) @@ -126,13 +126,13 @@ Component Builder is mapped as a component in itself on my local development env + *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com) + *Name*: [Component Builder](http://joomlacomponentbuilder.com) + *First Build*: 30th April, 2015 -+ *Last Build*: 20th January, 2018 -+ *Version*: 2.6.12 ++ *Last Build*: 23rd January, 2018 ++ *Version*: 2.6.13 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html -+ *Line count*: **180517** -+ *Field count*: **1573** -+ *File count*: **1160** ++ *Line count*: **180832** ++ *Field count*: **1577** ++ *File count*: **1161** + *Folder count*: **186** > This **component** was build with a Joomla [Automated Component Builder](http://joomlacomponentbuilder.com). diff --git a/admin/compiler/joomla_3/router.php b/admin/compiler/joomla_3/router.php index e0504bcd6..5912f24cc 100644 --- a/admin/compiler/joomla_3/router.php +++ b/admin/compiler/joomla_3/router.php @@ -222,7 +222,7 @@ function ###Component###BuildRoute(&$query) function ###Component###ParseRoute($segments) { - $router = new ContentRouter; + $router = new ###Component###Router; return $router->parse($segments); } \ No newline at end of file diff --git a/admin/controllers/ajax.json.php b/admin/controllers/ajax.json.php index c9f554f5d..a2c62bfbd 100644 --- a/admin/controllers/ajax.json.php +++ b/admin/controllers/ajax.json.php @@ -48,7 +48,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy $this->registerTask('getCronPath', 'ajax'); $this->registerTask('tableColumns', 'ajax'); $this->registerTask('fieldSelectOptions', 'ajax'); - $this->registerTask('getImportScripts', 'ajax'); + $this->registerTask('getDynamicScripts', 'ajax'); $this->registerTask('getButton', 'ajax'); $this->registerTask('getButtonID', 'ajax'); $this->registerTask('getAjaxDisplay', 'ajax'); @@ -306,14 +306,14 @@ class ComponentbuilderControllerAjax extends JControllerLegacy } } break; - case 'getImportScripts': + case 'getDynamicScripts': try { $returnRaw = $jinput->get('raw', false, 'BOOLEAN'); $typeValue = $jinput->get('type', NULL, 'WORD'); if($typeValue && $user->id != 0) { - $result = $this->getModel('ajax')->getImportScripts($typeValue); + $result = $this->getModel('ajax')->getDynamicScripts($typeValue); } else { diff --git a/admin/custom/dropbox.php b/admin/custom/dropbox.php index 8f59d5da0..66543cfe1 100644 --- a/admin/custom/dropbox.php +++ b/admin/custom/dropbox.php @@ -1,10 +1,9 @@ @@ -21,16 +20,15 @@ defined('_JEXEC') or die; */ class Dropbox { - /** * final url */ protected $url; - + /** * The array for the post url */ - protected $postUrl = array( + protected $postUrl = array( "protocol" => "https://", "suddomain" => "api.", "domain" => "dropboxapi.com", @@ -39,69 +37,75 @@ class Dropbox /** * the verious pathes we need - */ - protected $domainpath = array( + */ + protected $domainpath = array( + "list_shared_links" => "sharing/list_shared_links", "list_folder" => "files/list_folder", "list_folder_continue" => "files/list_folder/continue", - "create_shared_link" => "sharing/create_shared_link", + "create_shared_link_with_settings" => "sharing/create_shared_link_with_settings", "get_shared_link_metadata" => "sharing/get_shared_link_metadata", "revoke" => "auth/token/revoke" ); /** * the target pathe to get - */ + */ protected $targetPath = false; protected $targetPathOriginal = false; /** * oauth token - */ + */ protected $oauthToken; /** * the verious pathes we need - */ + */ protected $permissionType; /** - * The loop controller in calling Dropbox API - */ - protected $continueCalling = array(); + * The array of queries for creating shared links + */ + protected $createSharedLinks = array(); + + /** + * The array of queries for getting shared links + */ + protected $getSharedLinks = array(); /** * the success switch - */ + */ protected $succes; /** * the type call - */ + */ protected $type; /** * the query for the call - */ + */ protected $query; /** * the query for the call - */ + */ protected $model; /** * the mediaData bucket - */ + */ public $mediaData = array(); /** * the error messages - */ + */ public $error_summary = array(); - + /** - * force the update to reset - * */ + * force the update to reset + **/ public $forceReset = false; /** @@ -109,8 +113,12 @@ class Dropbox */ public function __construct(JModelLegacy $model, $buildType) { + // set the first call + $this->firstCall = 'get'; // TODO (we may what to make this dynamic) + // set the second call + $this->secondCall = 'create'; // TODO (we may what to make this dynamic) // set the url at this point for now - $this->url = $this->postUrl["protocol"] . $this->postUrl["suddomain"] . $this->postUrl["domain"] . $this->postUrl["path"]; + $this->url = $this->postUrl["protocol"].$this->postUrl["suddomain"].$this->postUrl["domain"].$this->postUrl["path"]; // set the local model $this->model = $model; // set the build type @@ -135,10 +143,10 @@ class Dropbox ini_set('max_execution_time', 500); // set the oauth toke $this->oauthToken = $token; - + // set the permission type $this->permissionType = $permissiontype; - + // set the details if ($this->checkArray($details)) { @@ -147,22 +155,125 @@ class Dropbox $this->$detail = $value; } } - + // set the curent folder path if (!$this->setFolderPath()) { return false; } - // start the main factory that calles for the folder data $this->query = array("path" => $this->targetPath, "recursive" => true, "include_media_info" => true); $this->type = 'list_folder'; if ($this->makeCall()) { + if ($this->_isCurl()) + { + // run the share link builder + return $this->makeMultiExecCalls(); + } return true; } + return false; } - + + protected function makeMultiExecCalls() + { + // make the fist call + $this->multiSharedLinks($this->firstCall); + // make the second call + $this->multiSharedLinks($this->secondCall); + // make the fist call (again for safety) + $this->multiSharedLinks($this->firstCall); + // make the second call (again for safety) + $this->multiSharedLinks($this->secondCall); + } + + protected function multiSharedLinks($type) + { + switch ($type) + { + case "create": + // great links if not made already + if (count($this->createSharedLinks) > 0) + { + $url = $this->url.$this->domainpath['create_shared_link_with_settings']; + $this->type = 'create_shared_link_with_settings'; + // build return function + $storeSharedLink = function ($data, $target) { + // check if link already made + if (isset($data->error_summary) && strpos($data->error_summary, 'shared_link_already_exists') !== false) + { + $this->getSharedLinks[] = json_encode(array("path" => $target)); + } + else + { + $this->curlCallResult($data); + } + }; + // run call + return $this->multiCall($url, $type, $storeSharedLink); + } + break; + case "get": + // now get the already made links + if (count($this->getSharedLinks) > 0) + { + $url = $this->url.$this->domainpath['list_shared_links']; + $this->type = 'list_shared_links'; + // build return function + $storeSharedLink = function ($data, $target) { + // check if link not made + if (isset($data->error_summary)) + { + $this->createSharedLinks[] = json_encode(array("path" => $target, "settings" => array("requested_visibility" => "public"))); + } + else + { + $this->curlCallResult($data); + } + }; + // run call + return $this->multiCall($url, $type, $storeSharedLink); + } + break; + } + return false; + } + + protected function multiCall(&$url, $type, &$storeSharedLink) + { + $timer = 1; + $options = array(); + // set the options array and make the calls every 250 + foreach ($this->{$type."SharedLinks"} as $query) + { + $options[] = array(CURLOPT_HTTPHEADER => array('Authorization: Bearer ' . $this->oauthToken, 'Content-Type: application/json'), CURLOPT_POST => 1, CURLOPT_POSTFIELDS => $query); $timer++; + // check timer + if ($timer >= 550) + { + // run multi curl + $this->curlMultiExec($url, $options, $storeSharedLink); + // reset + $timer = 1; + $options = array(); + } + } + // make sure all was done + if ($timer > 1 && count($options)) + { + // run multi curl + $this->curlMultiExec($url, $options, $storeSharedLink); + } + // reset the values + $this->{$type."SharedLinks"} = array(); + // only if there is no errors + if (count($this->error_summary) > 0) + { + return false; + } + return true; + } + public function revokeToken($token = null) { if ($token) @@ -179,7 +290,7 @@ class Dropbox } return false; } - + protected function setFolderPath() { if ('full' == $this->permissionType && isset($this->dropboxOption) && isset($this->dropboxTarget) && $this->checkString($this->dropboxTarget)) @@ -187,8 +298,8 @@ class Dropbox if (2 == $this->dropboxOption) { // simply set the path - $this->targetPath = '/' . trim(strtolower($this->dropboxTarget), '/'); - + $this->targetPath = '/'.trim(strtolower($this->dropboxTarget), '/'); + return true; } elseif (1 == $this->dropboxOption) @@ -205,12 +316,12 @@ class Dropbox elseif ('app' == $this->permissionType) { $this->targetPath = ""; - + return true; } return false; } - + protected function makeCall() { if ($this->_isCurl()) @@ -222,48 +333,52 @@ class Dropbox return $this->makeGetCall(); } } - + protected function makeGetCall() - { + { $options = array( 'http' => array( - 'header' => "Content-Type: application/json\r\n" . - "Authorization: Bearer " . $this->oauthToken, - 'method' => "POST" + 'header' => "Content-Type: application/json\r\n". + "Authorization: Bearer ".$this->oauthToken, + 'method' => "POST" ), ); - + if ($this->checkArray($this->query)) { $this->query = json_encode($this->query); } - $options['http']['content'] = $this->query; - + // add the query + if ($this->checkString($this->query)) + { + $options['http']['content'] = $this->query; + } $context = stream_context_create($options); - $response = file_get_contents($this->url . $this->domainpath[$this->type], false, $context); + $response = file_get_contents($this->url.$this->domainpath[$this->type], false, $context); // store the result return $this->getCallResult($response); } - + protected function getCallResult($response) { if ($response === FALSE) { - $this->error_summary[] = $this->type . '_error'; + $this->error_summary[] = $this->type.'_error'; return false; } // store the result return $this->setTheResult(json_decode($response)); } - + protected function makeCurlCall() { - $headers = array('Authorization: Bearer ' . $this->oauthToken, - 'Content-Type: application/json' - ); + // do not run creat shared link this way + $headers = array('Authorization: Bearer '. $this->oauthToken, + 'Content-Type: application/json' + ); - $ch = curl_init($this->url . $this->domainpath[$this->type]); + $ch = curl_init($this->url.$this->domainpath[$this->type]); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // check if query is set @@ -271,7 +386,11 @@ class Dropbox { $this->query = json_encode($this->query); } - curl_setopt($ch, CURLOPT_POSTFIELDS, $this->query); + // add the query + if ($this->checkString($this->query)) + { + curl_setopt($ch, CURLOPT_POSTFIELDS, $this->query); + } curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // curl_setopt($ch, CURLOPT_VERBOSE, 1); // debug @@ -283,9 +402,9 @@ class Dropbox // store the result return $this->curlCallResult($response); } - + public function curlCallResult($response) - { + { if ($this->checkJson($response)) { $response = json_decode($response); @@ -293,7 +412,7 @@ class Dropbox // store the result return $this->setTheResult($response); } - + protected function setTheResult($data) { // if there was an error stop!!! @@ -303,11 +422,11 @@ class Dropbox $this->forceReset = true; return false; } - + // deal with each type switch ($this->type) { - case "list_folder": + case "list_folder": case "list_folder_continue": if (isset($data->entries) && $this->checkArray($data->entries)) { @@ -327,15 +446,30 @@ class Dropbox return true; } } - $this->error_summary[] = $this->type . '_error'; + $this->error_summary[] = $this->type.'_error'; break; - case "create_shared_link": - if (isset($data->url) && isset($data->path) && $this->storeSharedLink($this->fixPath($data->path), str_replace('?dl=0', '?dl=1', $data->url))) + case "list_shared_links": + if (isset($data->links) && $this->checkArray($data->links)) + { + foreach ($data->links as $link) + { + if (!$this->storeSharedLink($link)) + { + // we could not stored the link + return false; + } + } + return true; + } + $this->error_summary[] = $this->type.'_error'; + break; + case "create_shared_link_with_settings": + if ($this->storeSharedLink($data)) { // we stored the link return true; } - $this->error_summary[] = $this->type . '_error'; + $this->error_summary[] = $this->type.'_error'; break; case "get_shared_link_metadata": if (isset($data->path_lower)) @@ -343,37 +477,36 @@ class Dropbox $this->targetPath = $data->path_lower; return true; } - $this->error_summary[] = $this->type . '_error'; + $this->error_summary[] = $this->type.'_error'; break; case "revoke": if (is_null($data)) { return true; } - $this->error_summary[] = $this->type . '_error'; + $this->error_summary[] = $this->type.'_error'; break; } $this->forceReset = true; return false; } - - protected function storeSharedLink($path, $url) + + protected function storeSharedLink($data) { // we need to store the url to DB - if (isset($this->mediaData[$path])) + if (isset($data->url) && isset($data->name) && isset($data->size) && (isset($data->path) || isset($data->path_lower))) { - $localListing = array(); - $localListing['id'] = 0; - $localListing['name'] = $this->mediaData[$path]['name']; - $localListing['size'] = $this->mediaData[$path]['size']; - $localListing['key'] = $path; - $localListing['url'] = $url; - $localListing['build'] = $this->build; - $localListing['external_source'] = (int) $this->sourceID; - // free some memory - unset($this->mediaData[$path]); + $path = (isset($data->path)) ? $data->path : $data->path_lower; + $localListing = array(); + $localListing['id'] = 0; + $localListing['name'] = $data->name; + $localListing['size'] = $data->size; + $localListing['key'] = $this->fixPath($path); + $localListing['url'] = str_replace('?dl=0','?dl=1',$data->url); + $localListing['build'] = $this->build; + $localListing['external_source'] = (int) $this->sourceID; // check if item already set - if ($id = $this->model->searchForId($path)) + if ($id = $this->model->searchForId($localListing['key'])) { // update item $localListing['id'] = $id; @@ -384,9 +517,9 @@ class Dropbox } protected function storeFiles($entries) - { + { foreach ($entries as $item) - { + { if (isset($item->{'.tag'}) && 'file' == $item->{'.tag'} && isset($item->name)) { $addLink = false; @@ -395,7 +528,7 @@ class Dropbox { foreach ($this->addTypes as $add) { - if (strpos($item->name, $add) !== false) + if (strpos($item->name,$add) !== false) { $addLink = true; } @@ -403,12 +536,28 @@ class Dropbox } if ($addLink && isset($item->path_lower)) { - // store media info - $this->mediaData[$this->fixPath($item->path_lower)] = array('name' => $item->name, 'size' => $item->size); - // get the shared link - $this->query = array("path" => $item->path_lower); - $this->type = 'create_shared_link'; - if (!$this->makeCall()) + // set based on first call + if ('get' === $this->firstCall) + { + // first check if shared link exist + $this->query = array("path" => $item->path_lower); + // set the type of call + $this->type = 'list_shared_links'; + } + else + { + // first check if shared link exist + $this->query = array("path" => $item->path_lower, "settings" => array("requested_visibility" => "public")); + // set the type of call + $this->type = 'create_shared_link_with_settings'; + } + // if we have curl the use multi curl execution + if ($this->_isCurl()) + { + // set query to worker + $this->{$this->firstCall."SharedLinks"}[] = json_encode($this->query); + } + elseif (!$this->makeCall()) { return false; } @@ -417,7 +566,7 @@ class Dropbox } return true; } - + protected function fixPath($path) { if ($this->checkString($this->targetPath)) @@ -426,7 +575,7 @@ class Dropbox } else { - $path = 'VDM_pLeK_h0uEr' . $path; + $path = 'VDM_pLeK_h0uEr'.$path; } return $path; } @@ -448,7 +597,7 @@ class Dropbox } return false; } - + protected function checkJson($string) { if ($this->checkString($string)) @@ -467,9 +616,85 @@ class Dropbox } return false; } - + protected function _isCurl() { return function_exists('curl_version'); } + + protected function curlMultiExec(&$url, &$_options, $callback = null) + { + if ($this->checkString($url)) + { + // make sure the thread size isn't greater than the # of _options + $threadSize = 20; + $threadSize = (sizeof($_options) < $threadSize) ? sizeof($_options) : $threadSize; + // set the options + $options = array(); + $options[CURLOPT_URL] = $url; + $options[CURLOPT_USERAGENT] = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12'; + $options[CURLOPT_RETURNTRANSFER] = TRUE; + $options[CURLOPT_SSL_VERIFYPEER] = FALSE; + // start multi threading :) + $handle = curl_multi_init(); + // start the first batch of requests + for ($i = 0; $i < $threadSize; $i++) + { + if (isset($_options[$i])) + { + $ch = curl_init(); + foreach ($_options[$i] as $curlopt => $string) + { + $options[$curlopt] = $string; + } + curl_setopt_array($ch, $options); + curl_multi_add_handle($handle, $ch); + } + } + // we wait for all the calls to finish (should not take long) + do { + while(($execrun = curl_multi_exec($handle, $working)) == CURLM_CALL_MULTI_PERFORM); + if($execrun != CURLM_OK) + break; + // a request was just completed -- find out which one + while($done = curl_multi_info_read($handle)) + { + if (is_callable($callback)) + { + // $info = curl_getinfo($done['handle']); + // request successful. process output using the callback function. + $output = curl_multi_getcontent($done['handle']); + $callback(json_decode($output), json_decode(end($_options[$i]))->path); + } + $key = $i + 1; + if(isset($_options[$key])) + { + // start a new request (it's important to do this before removing the old one) + $ch = curl_init(); $i++; + // add options + foreach ($_options[$key] as $curlopt => $string) + { + $options[$curlopt] = $string; + } + curl_setopt_array($ch, $options); + curl_multi_add_handle($handle, $ch); + // remove options again + foreach ($_options[$key] as $curlopt => $string) + { + unset($options[$curlopt]); + } + } + // remove the curl handle that just completed + curl_multi_remove_handle($handle, $done['handle']); + } + // stop wasting CPU cycles and rest for a couple ms + usleep(10000); + } while ($working); + // close the curl multi thread + curl_multi_close($handle); + // okay done + return true; + } + return false; + } } diff --git a/admin/custom/dropboxupdater.php b/admin/custom/dropboxupdater.php index 919b4897b..44bff92d3 100644 --- a/admin/custom/dropboxupdater.php +++ b/admin/custom/dropboxupdater.php @@ -405,7 +405,7 @@ class Dropboxupdater { $this->setErrors($this->dropbox->error_summary); return false; - } + } // if this is a manual update, then revoke the token if ($this->forceUpdate) { diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index d00c53680..9e2b2020a 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -1545,7 +1545,7 @@ class Get else { // load the default - $this->customScriptBuilder[$importScripter]['import_' . $name_list] = ComponentbuilderHelper::getImportScripts($importScripter, true); + $this->customScriptBuilder[$importScripter]['import_' . $name_list] = ComponentbuilderHelper::getDynamicScripts($importScripter, true); } } } diff --git a/admin/helpers/compiler/e_Interpretation.php b/admin/helpers/compiler/e_Interpretation.php index d85b00c5e..ee510982e 100644 --- a/admin/helpers/compiler/e_Interpretation.php +++ b/admin/helpers/compiler/e_Interpretation.php @@ -2242,7 +2242,11 @@ class Interpretation extends Fields $getItem .= PHP_EOL . "\t" . $tab . "\t\$this->_item[\$pk] = \$data;"; } // check if the dispather should be added - return str_replace(array_keys($this->JEventDispatcher), array_values($this->JEventDispatcher), $getItem); + if (isset($this->JEventDispatcher) && ComponentbuilderHelper::checkArray($this->JEventDispatcher)) + { + $getItem = str_replace(array_keys($this->JEventDispatcher), array_values($this->JEventDispatcher), $getItem); + } + return $getItem; } return PHP_EOL . "\t" . $tab . "\t//" . $this->setLine(__LINE__) . "add your custom code here."; } @@ -2693,7 +2697,11 @@ class Interpretation extends Fields } } // check if the dispatcher must be set - return str_replace(array_keys($this->JEventDispatcher), array_values($this->JEventDispatcher), $methods) . PHP_EOL; + if (isset($this->JEventDispatcher) && ComponentbuilderHelper::checkArray($this->JEventDispatcher)) + { + $methods = str_replace(array_keys($this->JEventDispatcher), array_values($this->JEventDispatcher), $methods); + } + return $methods . PHP_EOL; } public function setCustomViewMethodDefaults($get, $code) @@ -2842,7 +2850,10 @@ class Interpretation extends Fields } } // check if we should load the dispatcher - $getItem = str_replace(array_keys($this->JEventDispatcher), array_values($this->JEventDispatcher), $getItem); + if (isset($this->JEventDispatcher) && ComponentbuilderHelper::checkArray($this->JEventDispatcher)) + { + $getItem = str_replace(array_keys($this->JEventDispatcher), array_values($this->JEventDispatcher), $getItem); + } // setup Globals $getItem .= $this->setCustomViewGlobals($get->global, '$item', $asBucket, "\t\t"); // setup the custom gets that returns multipal values @@ -4816,19 +4827,29 @@ class Interpretation extends Fields public function routerParseSwitch(&$view, $viewArray = null, $aliasView = true, $idView = true) { + // reset buckets + $routerSwitch = array(); $isCategory = ''; $viewTable = false; - if ($viewArray && ComponentbuilderHelper::checkArray($viewArray)) + if ($viewArray && ComponentbuilderHelper::checkArray($viewArray) && isset($viewArray['settings']) && isset($viewArray['settings']->main_get)) { - if (isset($viewArray['settings']->main_get->db_table_main) && $viewArray['settings']->main_get->db_table_main === 'categories') + // check if we have custom script for this router parse switch case + if (isset($viewArray['settings']->main_get->add_php_router_parse) && $viewArray['settings']->main_get->add_php_router_parse == 1 + && isset($viewArray['settings']->main_get->php_router_parse) && ComponentbuilderHelper::checkString($viewArray['settings']->main_get->php_router_parse)) + { + // load the custom script for the switch based on dynamic get + $routerSwitch[] = PHP_EOL . "\t\t\tcase '" . $view . "':"; + $routerSwitch[] = $this->setPlaceholders($this->setDynamicValues(base64_decode($viewArray['settings']->main_get->php_router_parse)), $this->placeholders); + $routerSwitch[] = "\t\t\t\tbreak;"; + + return implode(PHP_EOL, $routerSwitch); + } + // is this a catogory + elseif (isset($viewArray['settings']->main_get->db_table_main) && $viewArray['settings']->main_get->db_table_main === 'categories') { $isCategory = ', true'; // TODO we will keep an eye on this.... } -// elseif (isset($viewArray['settings']->main_get->gettype) && $viewArray['settings']->main_get->gettype == 2) -// { -// $idView = false; // TODO we will keep an eye on this.... -// $aliasView = false; -// } + // get the main table name elseif (isset($viewArray['settings']->main_get->main_get) && ComponentbuilderHelper::checkArray($viewArray['settings']->main_get->main_get)) { foreach ($viewArray['settings']->main_get->main_get as $get) @@ -4842,6 +4863,7 @@ class Interpretation extends Fields $viewTable = str_replace('#__' . $this->fileContentStatic['###component###'] . '_', '', $get['selection']['table']); } } + break; } } } @@ -4849,9 +4871,6 @@ class Interpretation extends Fields // add if tags is added, also for all front item views if ($aliasView) { - // build view route switch - $routerSwitch = array(); - $routerSwitch[] = PHP_EOL . "\t\t\tcase '" . $view . "':"; $routerSwitch[] = "\t\t\t\t\$vars['view'] = '" . $view . "';"; $routerSwitch[] = "\t\t\t\tif (is_numeric(\$segments[\$count-1]))"; @@ -4875,14 +4894,9 @@ class Interpretation extends Fields $routerSwitch[] = "\t\t\t\t\t}"; $routerSwitch[] = "\t\t\t\t}"; $routerSwitch[] = "\t\t\t\tbreak;"; - - return implode(PHP_EOL, $routerSwitch); } elseif ($idView) { - // build view route switch - $routerSwitch = array(); - $routerSwitch[] = PHP_EOL . "\t\t\tcase '" . $view . "':"; $routerSwitch[] = "\t\t\t\t\$vars['view'] = '" . $view . "';"; $routerSwitch[] = "\t\t\t\tif (is_numeric(\$segments[\$count-1]))"; @@ -4890,21 +4904,15 @@ class Interpretation extends Fields $routerSwitch[] = "\t\t\t\t\t\$vars['id'] = (int) \$segments[\$count-1];"; $routerSwitch[] = "\t\t\t\t}"; $routerSwitch[] = "\t\t\t\tbreak;"; - - return implode(PHP_EOL, $routerSwitch); } else { - // build view route switch - $routerSwitch = array(); - $routerSwitch[] = PHP_EOL . "\t\t\tcase '" . $view . "':"; $routerSwitch[] = "\t\t\t\t\$vars['view'] = '" . $view . "';"; $routerSwitch[] = "\t\t\t\tbreak;"; - - return implode(PHP_EOL, $routerSwitch); } - return ''; + + return implode(PHP_EOL, $routerSwitch); } public function routerBuildViews(&$view) @@ -8102,11 +8110,14 @@ class Interpretation extends Fields $query .= PHP_EOL . "\t\t}"; $query .= PHP_EOL . "\t\treturn false;"; $query .= PHP_EOL . "\t}"; + + // get the header script + $header = ComponentbuilderHelper::getDynamicScripts('headers'); // add getExImPortHeaders $query .= $this->getCustomScriptBuilder('php_import_headers', 'import_' . $viewName_list, PHP_EOL . PHP_EOL, null, true, // set a default script for those with no custom script - PHP_EOL . PHP_EOL . $this->setPlaceholders(ComponentbuilderHelper::getImportScripts('headers'), $this->placeholders)); + PHP_EOL . PHP_EOL . $this->setPlaceholders($header, $this->placeholders)); } return $query; } diff --git a/admin/helpers/componentbuilder.php b/admin/helpers/componentbuilder.php index 16bdd3081..570f04164 100644 --- a/admin/helpers/componentbuilder.php +++ b/admin/helpers/componentbuilder.php @@ -158,7 +158,7 @@ abstract class ComponentbuilderHelper return $object; } - public static function getImportScripts($type, $fieldName = false) + public static function getDynamicScripts($type, $fieldName = false) { // if field name is passed the convert to type if ($fieldName) @@ -196,7 +196,7 @@ abstract class ComponentbuilderHelper $script['display'][] = "\t\tif (\$this->getLayout() !== 'modal')"; $script['display'][] = "\t\t{"; $script['display'][] = "\t\t\t// Include helper submenu"; - $script['display'][] = "\t\t\t###-#-#-Component###Helper::addSubmenu('import');"; + $script['display'][] = "\t\t\t[[[-#-#-Component]]]Helper::addSubmenu('import');"; $script['display'][] = "\t\t}"; $script['display'][] = "\n\t\t\$paths = new stdClass;"; $script['display'][] = "\t\t\$paths->first = '';"; @@ -204,7 +204,7 @@ abstract class ComponentbuilderHelper $script['display'][] = "\n\t\t\$this->paths = &\$paths;"; $script['display'][] = "\t\t\$this->state = &\$state;"; $script['display'][] = "\t\t// get global action permissions"; - $script['display'][] = "\t\t\$this->canDo = ###-#-#-Component###Helper::getActions('import');"; + $script['display'][] = "\t\t\$this->canDo = [[[-#-#-Component]]]Helper::getActions('import');"; $script['display'][] = "\n\t\t// We don't need toolbar in the modal window."; $script['display'][] = "\t\tif (\$this->getLayout() !== 'modal')"; $script['display'][] = "\t\t{"; @@ -219,7 +219,7 @@ abstract class ComponentbuilderHelper $script['display'][] = "\t\tif(\$this->hasPackage && \$this->dataType)"; $script['display'][] = "\t\t{"; $script['display'][] = "\t\t\t\$this->headerList \t= json_decode(\$session->get(\$this->dataType.'_VDM_IMPORTHEADERS', false),true);"; - $script['display'][] = "\t\t\t\$this->headers \t\t= ###-#-#-Component###Helper::getFileHeaders(\$this->dataType);"; + $script['display'][] = "\t\t\t\$this->headers \t\t= [[[-#-#-Component]]]Helper::getFileHeaders(\$this->dataType);"; $script['display'][] = "\t\t\t// clear the data type"; $script['display'][] = "\t\t\t\$session->clear('dataType');"; $script['display'][] = "\t\t}"; @@ -245,7 +245,7 @@ abstract class ComponentbuilderHelper $script['setdata'][] = "\t**/"; $script['setdata'][] = "\tprotected function setData(\$package,\$table,\$target_headers)"; $script['setdata'][] = "\t{"; - $script['setdata'][] = "\t\tif (###-#-#-Component###Helper::checkArray(\$target_headers))"; + $script['setdata'][] = "\t\tif ([[[-#-#-Component]]]Helper::checkArray(\$target_headers))"; $script['setdata'][] = "\t\t{"; $script['setdata'][] = "\t\t\t// make sure the file is loaded\t\t"; $script['setdata'][] = "\t\t\tJLoader::import('PHPExcel', JPATH_COMPONENT_ADMINISTRATOR . '/helpers');"; @@ -283,8 +283,8 @@ abstract class ComponentbuilderHelper $script['headers'][] = "\t\t// Get a db connection."; $script['headers'][] = "\t\t\$db = JFactory::getDbo();"; $script['headers'][] = "\t\t// get the columns"; - $script['headers'][] = "\t\t\$columns = \$db->getTableColumns(\"#__###-#-#-component###_###-#-#-view###\");"; - $script['headers'][] = "\t\tif (###-#-#-Component###Helper::checkArray(\$columns))"; + $script['headers'][] = "\t\t\$columns = \$db->getTableColumns(\"#__[[[-#-#-component]]]_[[[-#-#-view]]]\");"; + $script['headers'][] = "\t\tif ([[[-#-#-Component]]]Helper::checkArray(\$columns))"; $script['headers'][] = "\t\t{"; $script['headers'][] = "\t\t\t// remove the headers you don't import/export."; $script['headers'][] = "\t\t\tunset(\$columns['asset_id']);"; @@ -314,7 +314,7 @@ abstract class ComponentbuilderHelper $script['save'][] = "\tprotected function save(\$data,\$table)"; $script['save'][] = "\t{"; $script['save'][] = "\t\t// import the data if there is any"; - $script['save'][] = "\t\tif(###-#-#-Component###Helper::checkArray(\$data['array']))"; + $script['save'][] = "\t\tif([[[-#-#-Component]]]Helper::checkArray(\$data['array']))"; $script['save'][] = "\t\t{"; $script['save'][] = "\t\t\t// get user object"; $script['save'][] = "\t\t\t\$user \t\t= JFactory::getUser();"; @@ -332,7 +332,7 @@ abstract class ComponentbuilderHelper $script['save'][] = "\t\t\t}"; $script['save'][] = "\t\t\t"; $script['save'][] = "\t\t\t// make sure there is still values in array and that it was not only headers"; - $script['save'][] = "\t\t\tif(###-#-#-Component###Helper::checkArray(\$data['array']) && \$user->authorise(\$table.'.import', 'com_###-#-#-component###') && \$user->authorise('core.import', 'com_###-#-#-component###'))"; + $script['save'][] = "\t\t\tif([[[-#-#-Component]]]Helper::checkArray(\$data['array']) && \$user->authorise(\$table.'.import', 'com_[[[-#-#-component]]]') && \$user->authorise('core.import', 'com_[[[-#-#-component]]]'))"; $script['save'][] = "\t\t\t{"; $script['save'][] = "\t\t\t\t// set target."; $script['save'][] = "\t\t\t\t\$target\t= array_flip(\$data['target_headers']);"; @@ -341,7 +341,7 @@ abstract class ComponentbuilderHelper $script['save'][] = "\t\t\t\t// set some defaults"; $script['save'][] = "\t\t\t\t\$todayDate\t\t= JFactory::getDate()->toSql();"; $script['save'][] = "\t\t\t\t// get global action permissions"; - $script['save'][] = "\t\t\t\t\$canDo\t\t\t= ###-#-#-Component###Helper::getActions(\$table);"; + $script['save'][] = "\t\t\t\t\$canDo\t\t\t= [[[-#-#-Component]]]Helper::getActions(\$table);"; $script['save'][] = "\t\t\t\t\$canEdit\t\t= \$canDo->get('core.edit');"; $script['save'][] = "\t\t\t\t\$canState\t\t= \$canDo->get('core.edit.state');"; $script['save'][] = "\t\t\t\t\$canCreate\t\t= \$canDo->get('core.create');"; @@ -356,7 +356,7 @@ abstract class ComponentbuilderHelper $script['save'][] = "\t\t\t\t\t\t\$query = \$db->getQuery(true);"; $script['save'][] = "\t\t\t\t\t\t\$query"; $script['save'][] = "\t\t\t\t\t\t\t->select('version')"; - $script['save'][] = "\t\t\t\t\t\t\t->from(\$db->quoteName('#__###-#-#-component###_'.\$table))"; + $script['save'][] = "\t\t\t\t\t\t\t->from(\$db->quoteName('#__[[[-#-#-component]]]_'.\$table))"; $script['save'][] = "\t\t\t\t\t\t\t->where(\$db->quoteName('id') . ' = '. \$db->quote(\$row[\$id_key]));"; $script['save'][] = "\t\t\t\t\t\t// Reset the query using our newly populated query object."; $script['save'][] = "\t\t\t\t\t\t\$db->setQuery(\$query);"; @@ -423,7 +423,7 @@ abstract class ComponentbuilderHelper $script['save'][] = "\t\t\t\t\t\t\t\$db->quoteName('id') . ' = ' . \$id"; $script['save'][] = "\t\t\t\t\t\t);"; $script['save'][] = "\t\t\t\t\t\t"; - $script['save'][] = "\t\t\t\t\t\t\$query->update(\$db->quoteName('#__###-#-#-component###_'.\$table))->set(\$fields)->where(\$conditions);"; + $script['save'][] = "\t\t\t\t\t\t\$query->update(\$db->quoteName('#__[[[-#-#-component]]]_'.\$table))->set(\$fields)->where(\$conditions);"; $script['save'][] = "\t\t\t\t\t\t\$db->setQuery(\$query);"; $script['save'][] = "\t\t\t\t\t\t\$db->execute();"; $script['save'][] = "\t\t\t\t\t}"; @@ -499,7 +499,7 @@ abstract class ComponentbuilderHelper $script['save'][] = "\t\t\t\t\t\t}"; $script['save'][] = "\t\t\t\t\t\t// Prepare the insert query."; $script['save'][] = "\t\t\t\t\t\t\$query"; - $script['save'][] = "\t\t\t\t\t\t\t->insert(\$db->quoteName('#__###-#-#-component###_'.\$table))"; + $script['save'][] = "\t\t\t\t\t\t\t->insert(\$db->quoteName('#__[[[-#-#-component]]]_'.\$table))"; $script['save'][] = "\t\t\t\t\t\t\t->columns(\$db->quoteName(\$columns))"; $script['save'][] = "\t\t\t\t\t\t\t->values(implode(',', \$values));"; $script['save'][] = "\t\t\t\t\t\t// Set the query using our newly populated query object and execute it."; @@ -509,7 +509,7 @@ abstract class ComponentbuilderHelper $script['save'][] = "\t\t\t\t\t\t{"; $script['save'][] = "\t\t\t\t\t\t\t\$aId = \$db->insertid();"; $script['save'][] = "\t\t\t\t\t\t\t// make sure the access of asset is set"; - $script['save'][] = "\t\t\t\t\t\t\t###-#-#-Component###Helper::setAsset(\$aId,\$table);"; + $script['save'][] = "\t\t\t\t\t\t\t[[[-#-#-Component]]]Helper::setAsset(\$aId,\$table);"; $script['save'][] = "\t\t\t\t\t\t}"; $script['save'][] = "\t\t\t\t\t}"; $script['save'][] = "\t\t\t\t\telse"; @@ -527,7 +527,7 @@ abstract class ComponentbuilderHelper { $script['view'] = array(); $script['view'][] = ""; $script['view'][] = ""; $script['view'][] = "\n
"; - $script['view'][] = "
\" method=\"post\" name=\"adminForm\" id=\"adminForm\" class=\"form-horizontal form-validate\">"; + $script['view'][] = "\" method=\"post\" name=\"adminForm\" id=\"adminForm\" class=\"form-horizontal form-validate\">"; $script['view'][] = ""; $script['view'][] = "\n\tsidebar)) : ?>"; $script['view'][] = "\t\t
"; @@ -641,13 +641,13 @@ abstract class ComponentbuilderHelper $script['view'][] = "\t\t
"; $script['view'][] = "\t"; $script['view'][] = ""; - $script['view'][] = "\n\thasPackage && ###-#-#-Component###Helper::checkArray(\$this->headerList) && ###-#-#-Component###Helper::checkArray(\$this->headers)) : ?>"; + $script['view'][] = "\n\thasPackage && [[[-#-#-Component]]]Helper::checkArray(\$this->headerList) && [[[-#-#-Component]]]Helper::checkArray(\$this->headers)) : ?>"; $script['view'][] = "\t\t
"; - $script['view'][] = "\t\t\t"; + $script['view'][] = "\t\t\t"; $script['view'][] = "\t\t\t
"; - $script['view'][] = "\t\t\t\t"; + $script['view'][] = "\t\t\t\t"; $script['view'][] = "\t\t\t\t
"; - $script['view'][] = "\t\t\t\t\t"; + $script['view'][] = "\t\t\t\t\t"; $script['view'][] = "\t\t\t\t
"; $script['view'][] = "\t\t\t
"; $script['view'][] = "\t\t\theaderList as \$name => \$title): ?>"; @@ -655,72 +655,72 @@ abstract class ComponentbuilderHelper $script['view'][] = "\t\t\t\t\t"; $script['view'][] = "\t\t\t\t\t
"; $script['view'][] = "\t\t\t\t\t\t"; $script['view'][] = "\t\t\t\t\t
"; $script['view'][] = "\t\t\t\t
"; $script['view'][] = "\t\t\t"; $script['view'][] = "\t\t\t
"; - $script['view'][] = "\t\t\t\t\" onclick=\"Joomla.continueImport()\" />"; + $script['view'][] = "\t\t\t\t\" onclick=\"Joomla.continueImport()\" />"; $script['view'][] = "\t\t\t
"; $script['view'][] = "\t\t"; $script['view'][] = "\t\t"; $script['view'][] = "\t"; $script['view'][] = "\t\t 'upload')); ?>"; $script['view'][] = "\t\t"; - $script['view'][] = "\t\t"; + $script['view'][] = "\t\t"; $script['view'][] = "\t\t\t
"; - $script['view'][] = "\t\t\t\t"; + $script['view'][] = "\t\t\t\t"; $script['view'][] = "\t\t\t\t
"; - $script['view'][] = "\t\t\t\t\t"; + $script['view'][] = "\t\t\t\t\t"; $script['view'][] = "\t\t\t\t\t
"; $script['view'][] = "\t\t\t\t\t\t"; $script['view'][] = "\t\t\t\t\t
"; $script['view'][] = "\t\t\t\t
"; $script['view'][] = "\t\t\t\t
"; - $script['view'][] = "\t\t\t\t\t\" onclick=\"Joomla.submitbutton()\" />    (.csv .xls .ods)"; + $script['view'][] = "\t\t\t\t\t\" onclick=\"Joomla.submitbutton()\" />    (.csv .xls .ods)"; $script['view'][] = "\t\t\t\t
"; $script['view'][] = "\t\t\t
"; $script['view'][] = "\t\t"; $script['view'][] = "\t\t"; - $script['view'][] = "\t\t"; + $script['view'][] = "\t\t"; $script['view'][] = "\t\t\t
"; - $script['view'][] = "\t\t\t\t"; + $script['view'][] = "\t\t\t\t"; $script['view'][] = "\t\t\t\t
"; - $script['view'][] = "\t\t\t\t\t"; + $script['view'][] = "\t\t\t\t\t"; $script['view'][] = "\t\t\t\t\t
"; $script['view'][] = "\t\t\t\t\t\tstate->get('import.directory'); ?>\" />"; $script['view'][] = "\t\t\t\t\t
"; $script['view'][] = "\t\t\t\t
"; $script['view'][] = "\t\t\t\t
"; - $script['view'][] = "\t\t\t\t\t\" onclick=\"Joomla.submitbutton3()\" />    (.csv .xls .ods)"; + $script['view'][] = "\t\t\t\t\t\" onclick=\"Joomla.submitbutton3()\" />    (.csv .xls .ods)"; $script['view'][] = "\t\t\t\t
"; $script['view'][] = "\t\t\t\t
"; $script['view'][] = "\t\t"; $script['view'][] = ""; - $script['view'][] = "\n\t\t"; + $script['view'][] = "\n\t\t"; $script['view'][] = "\t\t\t
"; - $script['view'][] = "\t\t\t\t"; + $script['view'][] = "\t\t\t\t"; $script['view'][] = "\t\t\t\t
"; - $script['view'][] = "\t\t\t\t\t"; + $script['view'][] = "\t\t\t\t\t"; $script['view'][] = "\t\t\t\t\t
"; $script['view'][] = "\t\t\t\t\t\t"; $script['view'][] = "\t\t\t\t\t
"; $script['view'][] = "\t\t\t\t
"; $script['view'][] = "\t\t\t\t
"; - $script['view'][] = "\t\t\t\t\t\" onclick=\"Joomla.submitbutton4()\" />    (.csv .xls .ods)"; + $script['view'][] = "\t\t\t\t\t\" onclick=\"Joomla.submitbutton4()\" />    (.csv .xls .ods)"; $script['view'][] = "\t\t\t\t
"; $script['view'][] = "\t\t\t
"; $script['view'][] = "\t\t"; $script['view'][] = "\t\t"; $script['view'][] = "\t\t"; $script['view'][] = "\t"; - $script['view'][] = "\t"; + $script['view'][] = "\t"; $script['view'][] = "\t"; $script['view'][] = ""; $script['view'][] = "
"; @@ -770,7 +770,7 @@ abstract class ComponentbuilderHelper $script['import'][] = "\t\t\t\t\t\$session->clear('hasPackage');"; $script['import'][] = "\t\t\t\t\tbreak;"; $script['import'][] = "\n\t\t\t\tdefault:"; - $script['import'][] = "\t\t\t\t\t\$app->setUserState('com_###-#-#-component###.message', JTe-#-#-xt::_('COM_###-#-#-COMPONENT###_IMPORT_NO_IMPORT_TYPE_FOUND'));"; + $script['import'][] = "\t\t\t\t\t\$app->setUserState('com_[[[-#-#-component]]].message', JTe-#-#-xt::_('COM_[[[-#-#-COMPONENT]]]_IMPORT_NO_IMPORT_TYPE_FOUND'));"; $script['import'][] = "\n\t\t\t\t\treturn false;"; $script['import'][] = "\t\t\t\t\tbreak;"; $script['import'][] = "\t\t\t}"; @@ -782,7 +782,7 @@ abstract class ComponentbuilderHelper $script['import'][] = "\t\t\t{"; $script['import'][] = "\t\t\t\t\$this->remove(\$package['packagename']);"; $script['import'][] = "\t\t\t}"; - $script['import'][] = "\n\t\t\t\$app->setUserState('com_###-#-#-component###.message', JTe-#-#-xt::_('COM_###-#-#-COMPONENT###_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE'));"; + $script['import'][] = "\n\t\t\t\$app->setUserState('com_[[[-#-#-component]]].message', JTe-#-#-xt::_('COM_[[[-#-#-COMPONENT]]]_IMPORT_UNABLE_TO_FIND_IMPORT_PACKAGE'));"; $script['import'][] = "\t\t\treturn false;"; $script['import'][] = "\t\t}"; $script['import'][] = "\t\t"; @@ -799,11 +799,11 @@ abstract class ComponentbuilderHelper $script['import'][] = "\t\tif (!\$this->setData(\$package,\$this->dataType,\$headerList))"; $script['import'][] = "\t\t{"; $script['import'][] = "\t\t\t// There was an error importing the package"; - $script['import'][] = "\t\t\t\$msg = JTe-#-#-xt::_('COM_###-#-#-COMPONENT###_IMPORT_ERROR');"; + $script['import'][] = "\t\t\t\$msg = JTe-#-#-xt::_('COM_[[[-#-#-COMPONENT]]]_IMPORT_ERROR');"; $script['import'][] = "\t\t\t\$back = \$session->get('backto_VDM_IMPORT', NULL);"; $script['import'][] = "\t\t\tif (\$back)"; $script['import'][] = "\t\t\t{"; - $script['import'][] = "\t\t\t\t\$app->setUserState('com_###-#-#-component###.redirect_url', 'index.php?option=com_###-#-#-component###&view='.\$back);"; + $script['import'][] = "\t\t\t\t\$app->setUserState('com_[[[-#-#-component]]].redirect_url', 'index.php?option=com_[[[-#-#-component]]]&view='.\$back);"; $script['import'][] = "\t\t\t\t\$session->clear('backto_VDM_IMPORT');"; $script['import'][] = "\t\t\t}"; $script['import'][] = "\t\t\t\$result = false;"; @@ -811,11 +811,11 @@ abstract class ComponentbuilderHelper $script['import'][] = "\t\telse"; $script['import'][] = "\t\t{"; $script['import'][] = "\t\t\t// Package imported sucessfully"; - $script['import'][] = "\t\t\t\$msg = JTe-#-#-xt::sprintf('COM_###-#-#-COMPONENT###_IMPORT_SUCCESS', \$package['packagename']);"; + $script['import'][] = "\t\t\t\$msg = JTe-#-#-xt::sprintf('COM_[[[-#-#-COMPONENT]]]_IMPORT_SUCCESS', \$package['packagename']);"; $script['import'][] = "\t\t\t\$back = \$session->get('backto_VDM_IMPORT', NULL);"; $script['import'][] = "\t\t\tif (\$back)"; $script['import'][] = "\t\t\t{"; - $script['import'][] = "\t\t\t \$app->setUserState('com_###-#-#-component###.redirect_url', 'index.php?option=com_###-#-#-component###&view='.\$back);"; + $script['import'][] = "\t\t\t \$app->setUserState('com_[[[-#-#-component]]].redirect_url', 'index.php?option=com_[[[-#-#-component]]]&view='.\$back);"; $script['import'][] = "\t\t\t \$session->clear('backto_VDM_IMPORT');"; $script['import'][] = "\t\t\t}"; $script['import'][] = "\t\t\t\$result = true;"; @@ -852,6 +852,23 @@ abstract class ComponentbuilderHelper $script['ext'][] = "\t\treturn false;"; $script['ext'][] = "\t}"; } + elseif ('routerparse' === $type) + { + $script['routerparse'][] = "\t\t\t\t// default script in switch for this view"; + $script['routerparse'][] = "\t\t\t\t\$vars['view'] = '[[[-#-#-sview]]]';"; + $script['routerparse'][] = "\t\t\t\tif (is_numeric(\$segments[\$count-1]))"; + $script['routerparse'][] = "\t\t\t\t{"; + $script['routerparse'][] = "\t\t\t\t\t\$vars['id'] = (int) \$segments[\$count-1];"; + $script['routerparse'][] = "\t\t\t\t}"; + $script['routerparse'][] = "\t\t\t\telseif (\$segments[\$count-1])"; + $script['routerparse'][] = "\t\t\t\t{"; + $script['routerparse'][] = "\t\t\t\t\t\$id = \$this->getVar('[[[-#-#-sview]]]', \$segments[\$count-1], 'alias', 'id');"; + $script['routerparse'][] = "\t\t\t\t\tif(\$id)"; + $script['routerparse'][] = "\t\t\t\t\t{"; + $script['routerparse'][] = "\t\t\t\t\t\t\$vars['id'] = \$id;"; + $script['routerparse'][] = "\t\t\t\t\t}"; + $script['routerparse'][] = "\t\t\t\t}"; + } // return the needed script if (isset($script[$type])) { diff --git a/admin/language/en-GB/en-GB.com_componentbuilder.ini b/admin/language/en-GB/en-GB.com_componentbuilder.ini index 43e0fdf2d..7d9c3a6c3 100644 --- a/admin/language/en-GB/en-GB.com_componentbuilder.ini +++ b/admin/language/en-GB/en-GB.com_componentbuilder.ini @@ -3209,6 +3209,9 @@ COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_BEFORE_GETITEMS_LABEL="Add PHP (before COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_BEFORE_GETITEM_LABEL="Add PHP (before getting the Item)" COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_GETLISTQUERY="Add Php Getlistquery" COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_GETLISTQUERY_LABEL="Add PHP (getListQuery - JModelList)" +COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_ROUTER_PARSE="Add Php Router Parse" +COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_ROUTER_PARSE_DESCRIPTION="The option to override the default JCB implementation of the router parse method for the related view where this dynamicGet is added." +COM_COMPONENTBUILDER_DYNAMIC_GET_ADD_PHP_ROUTER_PARSE_LABEL="Add PHP (parse Method) - in Router" COM_COMPONENTBUILDER_DYNAMIC_GET_ARRAY_VALUE="Array Value" COM_COMPONENTBUILDER_DYNAMIC_GET_ASCENDING="Ascending" COM_COMPONENTBUILDER_DYNAMIC_GET_AS_LABEL="AS" @@ -3381,6 +3384,10 @@ COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_GETLISTQUERY="Php Getlistquery" COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_GETLISTQUERY_DESCRIPTION="Add your PHP here! [Do not add the php tags]" COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_GETLISTQUERY_HINT="// PHP Here that should run in the getlistquery Method (to add custom filtering)" COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_GETLISTQUERY_LABEL="PHP" +COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_ROUTER_PARSE="Php Router Parse" +COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_ROUTER_PARSE_DESCRIPTION="Add your PHP here! [Do not add the php tags]
Add the php code to override the default JCB implementation of the router parse method for the related view where this dynamicGet is added." +COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_ROUTER_PARSE_HINT="// PHP Here that should run in the parse Method -> switch | (array) $segments - the segments of the URL to parse | (array) $vars - the URL attributes to be used by the application." +COM_COMPONENTBUILDER_DYNAMIC_GET_PHP_ROUTER_PARSE_LABEL="PHP" COM_COMPONENTBUILDER_DYNAMIC_GET_PLEASE_SELECT="Please select" COM_COMPONENTBUILDER_DYNAMIC_GET_PP="pp" COM_COMPONENTBUILDER_DYNAMIC_GET_PUBLISHING="Publishing" @@ -3413,7 +3420,7 @@ COM_COMPONENTBUILDER_DYNAMIC_GET_TAGS="Tags" COM_COMPONENTBUILDER_DYNAMIC_GET_THIS="This" COM_COMPONENTBUILDER_DYNAMIC_GET_TT="tt" COM_COMPONENTBUILDER_DYNAMIC_GET_TWEAK="Tweak" -COM_COMPONENTBUILDER_DYNAMIC_GET_TYPE_LABEL="Set Type" +COM_COMPONENTBUILDER_DYNAMIC_GET_TYPE_LABEL="Type" COM_COMPONENTBUILDER_DYNAMIC_GET_U="u" COM_COMPONENTBUILDER_DYNAMIC_GET_USER="User" COM_COMPONENTBUILDER_DYNAMIC_GET_USER_GROUPS="User Groups" diff --git a/admin/layouts/dynamic_get/custom_script_fullwidth.php b/admin/layouts/dynamic_get/custom_script_fullwidth.php index 278925aea..56c07c3a3 100644 --- a/admin/layouts/dynamic_get/custom_script_fullwidth.php +++ b/admin/layouts/dynamic_get/custom_script_fullwidth.php @@ -39,7 +39,9 @@ $fields = $displayData->get('fields') ?: array( 'add_php_before_getitems', 'php_before_getitems', 'add_php_after_getitems', - 'php_after_getitems' + 'php_after_getitems', + 'add_php_router_parse', + 'php_router_parse' ); ?> diff --git a/admin/layouts/fieldtype/fields_fullwidth.php b/admin/layouts/fieldtype/fields_fullwidth.php index c9a183aba..878d60898 100644 --- a/admin/layouts/fieldtype/fields_fullwidth.php +++ b/admin/layouts/fieldtype/fields_fullwidth.php @@ -28,7 +28,7 @@ defined('_JEXEC') or die('Restricted access'); // set the defaults -$items = $displayData->wabfields; +$items = $displayData->wadfields; $user = JFactory::getUser(); $id = $displayData->item->id; $edit = "index.php?option=com_componentbuilder&view=fields&task=field.edit"; diff --git a/admin/layouts/ftp/linked_components_fullwidth.php b/admin/layouts/ftp/linked_components_fullwidth.php index dbedbd027..ad21cc25e 100644 --- a/admin/layouts/ftp/linked_components_fullwidth.php +++ b/admin/layouts/ftp/linked_components_fullwidth.php @@ -28,7 +28,7 @@ defined('_JEXEC') or die('Restricted access'); // set the defaults -$items = $displayData->waclinked_components; +$items = $displayData->waelinked_components; $user = JFactory::getUser(); $id = $displayData->item->id; $edit = "index.php?option=com_componentbuilder&view=joomla_components&task=joomla_component.edit"; diff --git a/admin/models/ajax.php b/admin/models/ajax.php index 8ad6a21a4..f17715455 100644 --- a/admin/models/ajax.php +++ b/admin/models/ajax.php @@ -333,10 +333,10 @@ class ComponentbuilderModelAjax extends JModelList return ''; } - public static function getImportScripts($type) + public static function getDynamicScripts($type) { // get from global helper - return ComponentbuilderHelper::getImportScripts($type); + return ComponentbuilderHelper::getDynamicScripts($type); } protected $functionArray = array( @@ -1881,7 +1881,7 @@ class ComponentbuilderModelAjax extends JModelList $query['c']['table'] = 'custom_admin_view'; $query['c']['view'] = 'custom_admin_views'; $query['c']['select'] = array('id', 'system_name', 'default','php_view','php_jview','php_jview_display','php_document', - 'js_document','css_document','css','php_model','php_controller'); + 'js_document','css_document','css','php_ajaxmethod','php_model','php_controller'); $query['c']['not_base64'] = array(); $query['c']['name'] = 'system_name'; diff --git a/admin/models/dynamic_get.php b/admin/models/dynamic_get.php index f68403bc9..8f12844c7 100644 --- a/admin/models/dynamic_get.php +++ b/admin/models/dynamic_get.php @@ -100,14 +100,6 @@ class ComponentbuilderModelDynamic_get extends JModelAdmin $item->metadata = $registry->toArray(); } - if (!empty($item->join_view_table)) - { - // Convert the join_view_table field to an array. - $join_view_table = new Registry; - $join_view_table->loadString($item->join_view_table); - $item->join_view_table = $join_view_table->toArray(); - } - if (!empty($item->join_db_table)) { // Convert the join_db_table field to an array. @@ -148,6 +140,14 @@ class ComponentbuilderModelDynamic_get extends JModelAdmin $item->global = $global->toArray(); } + if (!empty($item->join_view_table)) + { + // Convert the join_view_table field to an array. + $join_view_table = new Registry; + $join_view_table->loadString($item->join_view_table); + $item->join_view_table = $join_view_table->toArray(); + } + if (!empty($item->php_custom_get)) { // base64 Decode php_custom_get. @@ -184,6 +184,12 @@ class ComponentbuilderModelDynamic_get extends JModelAdmin $item->php_after_getitems = base64_decode($item->php_after_getitems); } + if (!empty($item->php_router_parse)) + { + // base64 Decode php_router_parse. + $item->php_router_parse = base64_decode($item->php_router_parse); + } + if (!empty($item->php_calculation)) { // base64 Decode php_calculation. @@ -970,19 +976,6 @@ class ComponentbuilderModelDynamic_get extends JModelAdmin $data['metadata'] = (string) $metadata; } - // Set the join_view_table items to data. - if (isset($data['join_view_table']) && is_array($data['join_view_table'])) - { - $join_view_table = new JRegistry; - $join_view_table->loadArray($data['join_view_table']); - $data['join_view_table'] = (string) $join_view_table; - } - elseif (!isset($data['join_view_table'])) - { - // Set the empty join_view_table to data - $data['join_view_table'] = ''; - } - // Set the join_db_table items to data. if (isset($data['join_db_table']) && is_array($data['join_db_table'])) { @@ -1048,6 +1041,19 @@ class ComponentbuilderModelDynamic_get extends JModelAdmin $data['global'] = ''; } + // Set the join_view_table items to data. + if (isset($data['join_view_table']) && is_array($data['join_view_table'])) + { + $join_view_table = new JRegistry; + $join_view_table->loadArray($data['join_view_table']); + $data['join_view_table'] = (string) $join_view_table; + } + elseif (!isset($data['join_view_table'])) + { + // Set the empty join_view_table to data + $data['join_view_table'] = ''; + } + // Set the php_custom_get string to base64 string. if (isset($data['php_custom_get'])) { @@ -1084,6 +1090,12 @@ class ComponentbuilderModelDynamic_get extends JModelAdmin $data['php_after_getitems'] = base64_encode($data['php_after_getitems']); } + // Set the php_router_parse string to base64 string. + if (isset($data['php_router_parse'])) + { + $data['php_router_parse'] = base64_encode($data['php_router_parse']); + } + // Set the php_calculation string to base64 string. if (isset($data['php_calculation'])) { diff --git a/admin/models/dynamic_gets.php b/admin/models/dynamic_gets.php index c1895652e..0e1547d66 100644 --- a/admin/models/dynamic_gets.php +++ b/admin/models/dynamic_gets.php @@ -333,6 +333,8 @@ class ComponentbuilderModelDynamic_gets extends JModelList $item->php_before_getitems = base64_decode($item->php_before_getitems); // decode php_after_getitems $item->php_after_getitems = base64_decode($item->php_after_getitems); + // decode php_router_parse + $item->php_router_parse = base64_decode($item->php_router_parse); // decode php_calculation $item->php_calculation = base64_decode($item->php_calculation); // unset the values we don't want exported. diff --git a/admin/models/fieldtype.php b/admin/models/fieldtype.php index ab2e5c558..7b380ef57 100644 --- a/admin/models/fieldtype.php +++ b/admin/models/fieldtype.php @@ -139,7 +139,7 @@ class ComponentbuilderModelFieldtype extends JModelAdmin * * @return mixed An array of data items on success, false on failure. */ - public function getWabfields() + public function getWadfields() { // Get the user object. $user = JFactory::getUser(); @@ -223,13 +223,13 @@ class ComponentbuilderModelFieldtype extends JModelAdmin foreach ($items as $nr => &$item) { // convert datatype - $item->datatype = $this->selectionTranslationWabfields($item->datatype, 'datatype'); + $item->datatype = $this->selectionTranslationWadfields($item->datatype, 'datatype'); // convert indexes - $item->indexes = $this->selectionTranslationWabfields($item->indexes, 'indexes'); + $item->indexes = $this->selectionTranslationWadfields($item->indexes, 'indexes'); // convert null_switch - $item->null_switch = $this->selectionTranslationWabfields($item->null_switch, 'null_switch'); + $item->null_switch = $this->selectionTranslationWadfields($item->null_switch, 'null_switch'); // convert store - $item->store = $this->selectionTranslationWabfields($item->store, 'store'); + $item->store = $this->selectionTranslationWadfields($item->store, 'store'); } } @@ -243,7 +243,7 @@ class ComponentbuilderModelFieldtype extends JModelAdmin * * @return translatable string */ - public function selectionTranslationWabfields($value,$name) + public function selectionTranslationWadfields($value,$name) { // Array of datatype language strings if ($name === 'datatype') diff --git a/admin/models/forms/admin_view.js b/admin/models/forms/admin_view.js index 3cfa2980d..990e7eb70 100644 --- a/admin/models/forms/admin_view.js +++ b/admin/models/forms/admin_view.js @@ -1203,7 +1203,7 @@ jQuery(document).ready(function() // set button addButtonID('admin_fields','create_edit_buttons', 1); // <-- first var valueSwitch = jQuery("#jform_add_custom_import input[type='radio']:checked").val(); - getImportScripts(valueSwitch); + getDynamicScripts(valueSwitch); // now load the fields getAjaxDisplay('admin_fields'); getAjaxDisplay('admin_fields_conditions'); @@ -1340,8 +1340,8 @@ function getTableColumns(fieldKey, table_, nr_){ } } -function getImportScripts_server(typpe){ - var getUrl = "index.php?option=com_componentbuilder&task=ajax.getImportScripts&format=json&vdm="+vastDevMod; +function getDynamicScripts_server(typpe){ + var getUrl = "index.php?option=com_componentbuilder&task=ajax.getDynamicScripts&format=json&vdm="+vastDevMod; if(token.length > 0 && typpe.length > 0){ var request = 'token='+token+'&type='+typpe; } @@ -1354,7 +1354,7 @@ function getImportScripts_server(typpe){ }); } -function getImportScripts(id){ +function getDynamicScripts(id){ if (1 == id) { // get the current values var current_import_display = jQuery('textarea#jform_php_import_display').val(); @@ -1366,7 +1366,7 @@ function getImportScripts(id){ var current_ext = jQuery('textarea#jform_php_import_ext').val(); // set the display method script if(current_import_display.length == 0){ - getImportScripts_server('display').done(function(result) { + getDynamicScripts_server('display').done(function(result) { if(result){ jQuery('textarea#jform_php_import_display').val(result); } @@ -1374,7 +1374,7 @@ function getImportScripts(id){ } // set the import method script if(current_import.length == 0){ - getImportScripts_server('import').done(function(result) { + getDynamicScripts_server('import').done(function(result) { if(result){ jQuery('textarea#jform_php_import').val(result); } @@ -1382,7 +1382,7 @@ function getImportScripts(id){ } // set the headers method script if(current_headers.length == 0){ - getImportScripts_server('headers').done(function(result) { + getDynamicScripts_server('headers').done(function(result) { if(result){ jQuery('textarea#jform_php_import_headers').val(result); } @@ -1390,7 +1390,7 @@ function getImportScripts(id){ } // set the setData method script if(current_setdata.length == 0){ - getImportScripts_server('setdata').done(function(result) { + getDynamicScripts_server('setdata').done(function(result) { if(result){ jQuery('textarea#jform_php_import_setdata').val(result); } @@ -1398,7 +1398,7 @@ function getImportScripts(id){ } // set the save method script if(current_save.length == 0){ - getImportScripts_server('save').done(function(result) { + getDynamicScripts_server('save').done(function(result) { if(result){ jQuery('textarea#jform_php_import_save').val(result); } @@ -1406,7 +1406,7 @@ function getImportScripts(id){ } // set the view script if(current_view.length == 0){ - getImportScripts_server('view').done(function(result) { + getDynamicScripts_server('view').done(function(result) { if(result){ jQuery('textarea#jform_html_import_view').val(result); } @@ -1414,7 +1414,7 @@ function getImportScripts(id){ } // set the import ext script if(current_ext.length == 0){ - getImportScripts_server('ext').done(function(result) { + getDynamicScripts_server('ext').done(function(result) { if(result){ jQuery('textarea#jform_php_import_ext').val(result); } diff --git a/admin/models/forms/custom_code.js b/admin/models/forms/custom_code.js index 686d68b35..42be4eb39 100644 --- a/admin/models/forms/custom_code.js +++ b/admin/models/forms/custom_code.js @@ -23,43 +23,43 @@ /-----------------------------------------------------------------------------------------------------------------------------*/ // Some Global Values -jform_vvvvvzuvzn_required = false; -jform_vvvvvzvvzo_required = false; -jform_vvvvvzvvzp_required = false; -jform_vvvvvzvvzq_required = false; +jform_vvvvvzxvzp_required = false; +jform_vvvvvzyvzq_required = false; +jform_vvvvvzyvzr_required = false; +jform_vvvvvzyvzs_required = false; // Initial Script jQuery(document).ready(function() { - var target_vvvvvzu = jQuery("#jform_target input[type='radio']:checked").val(); - vvvvvzu(target_vvvvvzu); - - var target_vvvvvzv = jQuery("#jform_target input[type='radio']:checked").val(); - vvvvvzv(target_vvvvvzv); - - var target_vvvvvzw = jQuery("#jform_target input[type='radio']:checked").val(); - var type_vvvvvzw = jQuery("#jform_type input[type='radio']:checked").val(); - vvvvvzw(target_vvvvvzw,type_vvvvvzw); - - var type_vvvvvzx = jQuery("#jform_type input[type='radio']:checked").val(); var target_vvvvvzx = jQuery("#jform_target input[type='radio']:checked").val(); - vvvvvzx(type_vvvvvzx,target_vvvvvzx); + vvvvvzx(target_vvvvvzx); + + var target_vvvvvzy = jQuery("#jform_target input[type='radio']:checked").val(); + vvvvvzy(target_vvvvvzy); + + var target_vvvvvzz = jQuery("#jform_target input[type='radio']:checked").val(); + var type_vvvvvzz = jQuery("#jform_type input[type='radio']:checked").val(); + vvvvvzz(target_vvvvvzz,type_vvvvvzz); + + var type_vvvvwaa = jQuery("#jform_type input[type='radio']:checked").val(); + var target_vvvvwaa = jQuery("#jform_target input[type='radio']:checked").val(); + vvvvwaa(type_vvvvwaa,target_vvvvwaa); }); -// the vvvvvzu function -function vvvvvzu(target_vvvvvzu) +// the vvvvvzx function +function vvvvvzx(target_vvvvvzx) { // set the function logic - if (target_vvvvvzu == 2) + if (target_vvvvvzx == 2) { jQuery('#jform_function_name').closest('.control-group').show(); - if (jform_vvvvvzuvzn_required) + if (jform_vvvvvzxvzp_required) { updateFieldRequired('function_name',0); jQuery('#jform_function_name').prop('required','required'); jQuery('#jform_function_name').attr('aria-required',true); jQuery('#jform_function_name').addClass('required'); - jform_vvvvvzuvzn_required = false; + jform_vvvvvzxvzp_required = false; } jQuery('.note_jcb_placeholder').closest('.control-group').show(); @@ -68,99 +68,99 @@ function vvvvvzu(target_vvvvvzu) else { jQuery('#jform_function_name').closest('.control-group').hide(); - if (!jform_vvvvvzuvzn_required) + if (!jform_vvvvvzxvzp_required) { updateFieldRequired('function_name',1); jQuery('#jform_function_name').removeAttr('required'); jQuery('#jform_function_name').removeAttr('aria-required'); jQuery('#jform_function_name').removeClass('required'); - jform_vvvvvzuvzn_required = true; + jform_vvvvvzxvzp_required = true; } jQuery('.note_jcb_placeholder').closest('.control-group').hide(); jQuery('#jform_system_name').closest('.control-group').hide(); } } -// the vvvvvzv function -function vvvvvzv(target_vvvvvzv) +// the vvvvvzy function +function vvvvvzy(target_vvvvvzy) { // set the function logic - if (target_vvvvvzv == 1) + if (target_vvvvvzy == 1) { jQuery('#jform_component').closest('.control-group').show(); - if (jform_vvvvvzvvzo_required) + if (jform_vvvvvzyvzq_required) { updateFieldRequired('component',0); jQuery('#jform_component').prop('required','required'); jQuery('#jform_component').attr('aria-required',true); jQuery('#jform_component').addClass('required'); - jform_vvvvvzvvzo_required = false; + jform_vvvvvzyvzq_required = false; } jQuery('#jform_path').closest('.control-group').show(); - if (jform_vvvvvzvvzp_required) + if (jform_vvvvvzyvzr_required) { updateFieldRequired('path',0); jQuery('#jform_path').prop('required','required'); jQuery('#jform_path').attr('aria-required',true); jQuery('#jform_path').addClass('required'); - jform_vvvvvzvvzp_required = false; + jform_vvvvvzyvzr_required = false; } jQuery('#jform_from_line').closest('.control-group').show(); jQuery('#jform_hashtarget').closest('.control-group').show(); jQuery('#jform_to_line').closest('.control-group').show(); jQuery('#jform_type').closest('.control-group').show(); - if (jform_vvvvvzvvzq_required) + if (jform_vvvvvzyvzs_required) { updateFieldRequired('type',0); jQuery('#jform_type').prop('required','required'); jQuery('#jform_type').attr('aria-required',true); jQuery('#jform_type').addClass('required'); - jform_vvvvvzvvzq_required = false; + jform_vvvvvzyvzs_required = false; } } else { jQuery('#jform_component').closest('.control-group').hide(); - if (!jform_vvvvvzvvzo_required) + if (!jform_vvvvvzyvzq_required) { updateFieldRequired('component',1); jQuery('#jform_component').removeAttr('required'); jQuery('#jform_component').removeAttr('aria-required'); jQuery('#jform_component').removeClass('required'); - jform_vvvvvzvvzo_required = true; + jform_vvvvvzyvzq_required = true; } jQuery('#jform_path').closest('.control-group').hide(); - if (!jform_vvvvvzvvzp_required) + if (!jform_vvvvvzyvzr_required) { updateFieldRequired('path',1); jQuery('#jform_path').removeAttr('required'); jQuery('#jform_path').removeAttr('aria-required'); jQuery('#jform_path').removeClass('required'); - jform_vvvvvzvvzp_required = true; + jform_vvvvvzyvzr_required = true; } jQuery('#jform_from_line').closest('.control-group').hide(); jQuery('#jform_hashtarget').closest('.control-group').hide(); jQuery('#jform_to_line').closest('.control-group').hide(); jQuery('#jform_type').closest('.control-group').hide(); - if (!jform_vvvvvzvvzq_required) + if (!jform_vvvvvzyvzs_required) { updateFieldRequired('type',1); jQuery('#jform_type').removeAttr('required'); jQuery('#jform_type').removeAttr('aria-required'); jQuery('#jform_type').removeClass('required'); - jform_vvvvvzvvzq_required = true; + jform_vvvvvzyvzs_required = true; } } } -// the vvvvvzw function -function vvvvvzw(target_vvvvvzw,type_vvvvvzw) +// the vvvvvzz function +function vvvvvzz(target_vvvvvzz,type_vvvvvzz) { // set the function logic - if (target_vvvvvzw == 1 && type_vvvvvzw == 1) + if (target_vvvvvzz == 1 && type_vvvvvzz == 1) { jQuery('#jform_hashendtarget').closest('.control-group').show(); jQuery('#jform_to_line').closest('.control-group').show(); @@ -172,11 +172,11 @@ function vvvvvzw(target_vvvvvzw,type_vvvvvzw) } } -// the vvvvvzx function -function vvvvvzx(type_vvvvvzx,target_vvvvvzx) +// the vvvvwaa function +function vvvvwaa(type_vvvvwaa,target_vvvvwaa) { // set the function logic - if (type_vvvvvzx == 1 && target_vvvvvzx == 1) + if (type_vvvvwaa == 1 && target_vvvvwaa == 1) { jQuery('#jform_hashendtarget').closest('.control-group').show(); jQuery('#jform_to_line').closest('.control-group').show(); diff --git a/admin/models/forms/dynamic_get.js b/admin/models/forms/dynamic_get.js index aba9288bd..2307b8232 100644 --- a/admin/models/forms/dynamic_get.js +++ b/admin/models/forms/dynamic_get.js @@ -41,6 +41,8 @@ jform_vvvvvzsvzj_required = false; jform_vvvvvzsvzk_required = false; jform_vvvvvzsvzl_required = false; jform_vvvvvztvzm_required = false; +jform_vvvvvzuvzn_required = false; +jform_vvvvvzvvzo_required = false; // Initial Script jQuery(document).ready(function() @@ -105,6 +107,13 @@ jQuery(document).ready(function() var gettype_vvvvvzt = jQuery("#jform_gettype").val(); vvvvvzt(gettype_vvvvvzt); + + var gettype_vvvvvzu = jQuery("#jform_gettype").val(); + vvvvvzu(gettype_vvvvvzu); + + var gettype_vvvvvzv = jQuery("#jform_gettype").val(); + var add_php_router_parse_vvvvvzv = jQuery("#jform_add_php_router_parse input[type='radio']:checked").val(); + vvvvvzv(gettype_vvvvvzv,add_php_router_parse_vvvvvzv); }); // the vvvvvyy function @@ -1250,6 +1259,139 @@ function gettype_vvvvvzt_SomeFunc(gettype_vvvvvzt) return false; } +// the vvvvvzu function +function vvvvvzu(gettype_vvvvvzu) +{ + if (isSet(gettype_vvvvvzu) && gettype_vvvvvzu.constructor !== Array) + { + var temp_vvvvvzu = gettype_vvvvvzu; + var gettype_vvvvvzu = []; + gettype_vvvvvzu.push(temp_vvvvvzu); + } + else if (!isSet(gettype_vvvvvzu)) + { + var gettype_vvvvvzu = []; + } + var gettype = gettype_vvvvvzu.some(gettype_vvvvvzu_SomeFunc); + + + // set this function logic + if (gettype) + { + jQuery('#jform_add_php_router_parse').closest('.control-group').show(); + if (jform_vvvvvzuvzn_required) + { + updateFieldRequired('add_php_router_parse',0); + jQuery('#jform_add_php_router_parse').prop('required','required'); + jQuery('#jform_add_php_router_parse').attr('aria-required',true); + jQuery('#jform_add_php_router_parse').addClass('required'); + jform_vvvvvzuvzn_required = false; + } + + } + else + { + jQuery('#jform_add_php_router_parse').closest('.control-group').hide(); + if (!jform_vvvvvzuvzn_required) + { + updateFieldRequired('add_php_router_parse',1); + jQuery('#jform_add_php_router_parse').removeAttr('required'); + jQuery('#jform_add_php_router_parse').removeAttr('aria-required'); + jQuery('#jform_add_php_router_parse').removeClass('required'); + jform_vvvvvzuvzn_required = true; + } + } +} + +// the vvvvvzu Some function +function gettype_vvvvvzu_SomeFunc(gettype_vvvvvzu) +{ + // set the function logic + if (gettype_vvvvvzu == 1 || gettype_vvvvvzu == 2) + { + return true; + } + return false; +} + +// the vvvvvzv function +function vvvvvzv(gettype_vvvvvzv,add_php_router_parse_vvvvvzv) +{ + if (isSet(gettype_vvvvvzv) && gettype_vvvvvzv.constructor !== Array) + { + var temp_vvvvvzv = gettype_vvvvvzv; + var gettype_vvvvvzv = []; + gettype_vvvvvzv.push(temp_vvvvvzv); + } + else if (!isSet(gettype_vvvvvzv)) + { + var gettype_vvvvvzv = []; + } + var gettype = gettype_vvvvvzv.some(gettype_vvvvvzv_SomeFunc); + + if (isSet(add_php_router_parse_vvvvvzv) && add_php_router_parse_vvvvvzv.constructor !== Array) + { + var temp_vvvvvzv = add_php_router_parse_vvvvvzv; + var add_php_router_parse_vvvvvzv = []; + add_php_router_parse_vvvvvzv.push(temp_vvvvvzv); + } + else if (!isSet(add_php_router_parse_vvvvvzv)) + { + var add_php_router_parse_vvvvvzv = []; + } + var add_php_router_parse = add_php_router_parse_vvvvvzv.some(add_php_router_parse_vvvvvzv_SomeFunc); + + + // set this function logic + if (gettype && add_php_router_parse) + { + jQuery('#jform_php_router_parse').closest('.control-group').show(); + if (jform_vvvvvzvvzo_required) + { + updateFieldRequired('php_router_parse',0); + jQuery('#jform_php_router_parse').prop('required','required'); + jQuery('#jform_php_router_parse').attr('aria-required',true); + jQuery('#jform_php_router_parse').addClass('required'); + jform_vvvvvzvvzo_required = false; + } + + } + else + { + jQuery('#jform_php_router_parse').closest('.control-group').hide(); + if (!jform_vvvvvzvvzo_required) + { + updateFieldRequired('php_router_parse',1); + jQuery('#jform_php_router_parse').removeAttr('required'); + jQuery('#jform_php_router_parse').removeAttr('aria-required'); + jQuery('#jform_php_router_parse').removeClass('required'); + jform_vvvvvzvvzo_required = true; + } + } +} + +// the vvvvvzv Some function +function gettype_vvvvvzv_SomeFunc(gettype_vvvvvzv) +{ + // set the function logic + if (gettype_vvvvvzv == 1 || gettype_vvvvvzv == 2) + { + return true; + } + return false; +} + +// the vvvvvzv Some function +function add_php_router_parse_vvvvvzv_SomeFunc(add_php_router_parse_vvvvvzv) +{ + // set the function logic + if (add_php_router_parse_vvvvvzv == 1) + { + return true; + } + return false; +} + // update required fields function updateFieldRequired(name,status) { @@ -1290,6 +1432,8 @@ jQuery(document).ready(function() { // get the linked details getLinked(); + var valueSwitch = jQuery("#jform_add_php_router_parse input[type='radio']:checked").val(); + getDynamicScripts(valueSwitch); }); function getLinked_server(type){ @@ -1433,4 +1577,33 @@ function updateSubItems(fieldName, fieldNr, table_, nr_){ } }); } +} + +function getDynamicScripts_server(typpe){ + var getUrl = "index.php?option=com_componentbuilder&task=ajax.getDynamicScripts&format=json&vdm="+vastDevMod; + if(token.length > 0 && typpe.length > 0){ + var request = 'token='+token+'&type='+typpe; + } + return jQuery.ajax({ + type: 'GET', + url: getUrl, + dataType: 'jsonp', + data: request, + jsonp: 'callback' + }); +} + +function getDynamicScripts(id){ + if (1 == id) { + // get the current values + var current_router_parse = jQuery('textarea#jform_php_router_parse').val(); + // set the router parse method script + if(current_router_parse.length == 0){ + getDynamicScripts_server('routerparse').done(function(result) { + if(result){ + jQuery('textarea#jform_php_router_parse').val(result); + } + }); + } + } } diff --git a/admin/models/forms/dynamic_get.xml b/admin/models/forms/dynamic_get.xml index eeafb8024..3e80e8f1b 100644 --- a/admin/models/forms/dynamic_get.xml +++ b/admin/models/forms/dynamic_get.xml @@ -143,11 +143,18 @@ filter="HTML" hint="COM_COMPONENTBUILDER_DYNAMIC_GET_DB_SELECTION_HINT" required="true" /> - - + + + + + + - - -