From c8af1befe4ccd350c8acacaa8a6f16beeb59261c Mon Sep 17 00:00:00 2001 From: Llewellyn van der Merwe Date: Sat, 3 Feb 2018 02:13:48 +0200 Subject: [PATCH] Changed from onlinecode to externalcode --- README.md | 2 +- admin/README.txt | 2 +- admin/helpers/compiler/a_Get.php | 81 ++++++++++++++---------------- admin/sql/install.mysql.utf8.sql | 6 +-- admin/sql/updates/mysql/2.6.13.sql | 6 +-- componentbuilder.xml | 2 +- 6 files changed, 48 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index d0c4df17b..e3e2aa42e 100644 --- a/README.md +++ b/README.md @@ -126,7 +126,7 @@ 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*: 2nd February, 2018 ++ *Last Build*: 3rd February, 2018 + *Version*: 2.6.14 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html diff --git a/admin/README.txt b/admin/README.txt index d0c4df17b..e3e2aa42e 100644 --- a/admin/README.txt +++ b/admin/README.txt @@ -126,7 +126,7 @@ 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*: 2nd February, 2018 ++ *Last Build*: 3rd February, 2018 + *Version*: 2.6.14 + *Copyright*: Copyright (C) 2015. All Rights Reserved + *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html diff --git a/admin/helpers/compiler/a_Get.php b/admin/helpers/compiler/a_Get.php index 7aaf6eef4..13984a2a1 100644 --- a/admin/helpers/compiler/a_Get.php +++ b/admin/helpers/compiler/a_Get.php @@ -165,11 +165,11 @@ class Get protected $codeAreadyDone = array(); /** - * The online code to be added + * The external code/string to be added * * @var array */ - protected $onlineCodeData = array(); + protected $externalCodeString = array(); /* * The line numbers Switch @@ -3658,48 +3658,47 @@ class Get { if (ComponentbuilderHelper::checkString($string)) { - return $this->setLangStrings($this->setCustomCodeData($this->setOnlineCodeString($string))); + return $this->setLangStrings($this->setCustomCodeData($this->setExternalCodeString($string))); } return $string; } /** - * We start set the online code string & can load it in to string + * Set the external code string & load it in to string * * @param string $string The content to check * * @return string * */ - public function setOnlineCodeString($string) + public function setExternalCodeString($string) { // check if content has custom code place holder - if (strpos($string, '[ONLIN' . 'ECODE=') !== false) + if (strpos($string, '[EXTERNA'.'LCODE=') !== false) { - // urls content + // target content $bucket = array(); - $found = ComponentbuilderHelper::getAllBetween($string, '[ONLIN' . 'ECODE=', ']'); + $found = ComponentbuilderHelper::getAllBetween($string, '[EXTERNA'.'LCODE=', ']'); if (ComponentbuilderHelper::checkArray($found)) { // build local bucket - foreach ($found as $url) + foreach ($found as $target) { - // check if the URL is valid - if (!filter_var($url, FILTER_VALIDATE_URL) === false && ComponentbuilderHelper::urlExists($url)) + // check if the target is valid URL or path + if ((!filter_var($target, FILTER_VALIDATE_URL) === false && ComponentbuilderHelper::urlExists($target)) + || (JPath::clean($target) === $target && JFile::exists($target))) { - $this->getOnlineCodeString($url, $bucket); + $this->getExternalCodeString($target, $bucket); } - // check if this is a path - elseif (JPath::clean($url) === $url && JFile::exists($url)) - { - $this->getOnlineCodeString($url, $bucket); - } - // give notice that url/path is not valid + // give notice that target is not a valid url/path else { - $this->app->enqueueMessage(JText::sprintf('The %s is not a valid url/path!', '[ONLIN'.'ECODE='.$url.']'), 'warning'); + // set key + $key = '[EXTERNA'.'LCODE='.$target.']'; + // set the notice + $this->app->enqueueMessage(JText::sprintf('The %s is not a valid url/path!', $key), 'warning'); // remove the placeholder - $bucket['[ONLIN'.'ECODE='.$url.']'] = ''; + $bucket[$key] = ''; } } // now update local string if bucket has values @@ -3713,7 +3712,7 @@ class Get } /** - * Get the Online Code/String + * Get the External Code/String * * @param string $string The content to check * @param array $bucket The Placeholders bucket @@ -3721,32 +3720,32 @@ class Get * @return void * */ - protected function getOnlineCodeString($url, &$bucket) + protected function getExternalCodeString($target, &$bucket) { // set key - $key = '[ONLIN' . 'ECODE=' . $url . ']'; + $key = '[EXTERNA'.'LCODE=' . $target . ']'; // set URL key - $urlKey = trim($url); - // check if we already fethced this - if (!isset($this->onlineCodeData[$urlKey])) + $targetKey = trim($target); + // check if we already fetched this + if (!isset($this->externalCodeString[$targetKey])) { // get the data string (code) - $this->onlineCodeData[$urlKey] = ComponentbuilderHelper::getFileContents($urlKey); + $this->externalCodeString[$targetKey] = ComponentbuilderHelper::getFileContents($targetKey); // did we get any value - if (ComponentbuilderHelper::checkString($this->onlineCodeData[$urlKey])) + if (ComponentbuilderHelper::checkString($this->externalCodeString[$targetKey])) { // check for changes - $liveHash = md5($this->onlineCodeData[$urlKey]); + $liveHash = md5($this->externalCodeString[$targetKey]); // check if it exist local - if ($hash = ComponentbuilderHelper::getVar('online_code', $urlKey, 'url', 'hash')) + if ($hash = ComponentbuilderHelper::getVar('external_code', $targetKey, 'target', 'hash')) { if ($hash !== $liveHash) { $object = new stdClass(); - $object->url = $urlKey; + $object->target = $targetKey; $object->hash = $liveHash; // update local hash - $this->db->updateObject('#__componentbuilder_online_code', $object, 'url'); + $this->db->updateObject('#__componentbuilder_external_code', $object, 'target'); // give notice of the change $this->app->enqueueMessage(JText::sprintf('The code/string from %s has been changed since the last compilation, please investigate!', $key), 'warning'); } @@ -3755,24 +3754,22 @@ class Get { // add the hash to track changes $object = new stdClass(); - $object->url = $urlKey; + $object->target = $targetKey; $object->hash = $liveHash; // insert local hash - $this->db->insertObject('#__componentbuilder_online_code', $object); + $this->db->insertObject('#__componentbuilder_external_code', $object); } } else { - // set notice that we could not get the code from the url - $this->app->enqueueMessage(JText::sprintf('The %s returned an empty string!', $key), 'warning'); - // remove the tag - $this->onlineCodeData[$urlKey] = ''; + // set notice that we could not get a valid string from the target + $this->app->enqueueMessage(JText::sprintf('The %s returned an invalid string!', $key), 'warning'); } } // add to local bucket - if (ComponentbuilderHelper::checkString($this->onlineCodeData[$urlKey])) + if (isset($this->externalCodeString[$targetKey])) { - $bucket[$key] = $this->onlineCodeData[$urlKey]; + $bucket[$key] = $this->externalCodeString[$targetKey]; } } @@ -4400,8 +4397,8 @@ class Get foreach ($bucket as $nr => &$customCode) { $customCode['code'] = base64_decode($customCode['code']); - // always insure that the online code is loaded - $customCode['code'] = $this->setOnlineCodeString($customCode['code']); + // always insure that the external code is loaded + $customCode['code'] = $this->setExternalCodeString($customCode['code']); // set the lang only if needed if ($setLang) { diff --git a/admin/sql/install.mysql.utf8.sql b/admin/sql/install.mysql.utf8.sql index 17a03fec5..7d5b57cb3 100644 --- a/admin/sql/install.mysql.utf8.sql +++ b/admin/sql/install.mysql.utf8.sql @@ -1634,10 +1634,10 @@ INSERT INTO `#__componentbuilder_library_files_folders_urls` (`id`, `addfiles`, (2, '', '', '{\"addurls0\":{\"url\":\"https:\\/\\/maxcdn.bootstrapcdn.com\\/bootstrap\\/4.0.0-alpha.6\\/js\\/bootstrap.min.js\",\"type\":\"2\"},\"addurls1\":{\"url\":\"https:\\/\\/maxcdn.bootstrapcdn.com\\/bootstrap\\/4.0.0-alpha.6\\/css\\/bootstrap.min.css\",\"type\":\"2\"}}', 2, '', 1, '2017-11-25 16:17:36', '2017-12-25 12:40:16', 10, '', 2), (3, '', '', '{\"addurls0\":{\"url\":\"https:\\/\\/cdnjs.cloudflare.com\\/ajax\\/libs\\/uikit\\/3.0.0-beta.35\\/js\\/uikit.min.js\",\"type\":\"2\"},\"addurls1\":{\"url\":\"https:\\/\\/cdnjs.cloudflare.com\\/ajax\\/libs\\/uikit\\/3.0.0-beta.35\\/js\\/uikit-icons.min.js\",\"type\":\"2\"},\"addurls2\":{\"url\":\"https:\\/\\/cdnjs.cloudflare.com\\/ajax\\/libs\\/uikit\\/3.0.0-beta.35\\/css\\/uikit.min.css\",\"type\":\"2\"}}', 3, '', 1, '2017-11-25 21:47:40', '2017-12-25 12:38:24', 8, '', 3); -CREATE TABLE IF NOT EXISTS `#__componentbuilder_online_code` ( - `url` VARCHAR(255) NOT NULL DEFAULT '', +CREATE TABLE IF NOT EXISTS `#__componentbuilder_external_code` ( + `target` VARCHAR(255) NOT NULL DEFAULT '', `hash` VARCHAR(64) NOT NULL DEFAULT '', - PRIMARY KEY (`url`) + PRIMARY KEY (`target`) ) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; diff --git a/admin/sql/updates/mysql/2.6.13.sql b/admin/sql/updates/mysql/2.6.13.sql index d9cca7fb6..59abeab59 100644 --- a/admin/sql/updates/mysql/2.6.13.sql +++ b/admin/sql/updates/mysql/2.6.13.sql @@ -1,5 +1,5 @@ -CREATE TABLE IF NOT EXISTS `#__componentbuilder_online_code` ( - `url` VARCHAR(255) NOT NULL DEFAULT '', +CREATE TABLE IF NOT EXISTS `#__componentbuilder_external_code` ( + `target` VARCHAR(255) NOT NULL DEFAULT '', `hash` VARCHAR(64) NOT NULL DEFAULT '', - PRIMARY KEY (`url`) + PRIMARY KEY (`target`) ) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8; diff --git a/componentbuilder.xml b/componentbuilder.xml index 363b61362..f888c9aff 100644 --- a/componentbuilder.xml +++ b/componentbuilder.xml @@ -1,7 +1,7 @@ COM_COMPONENTBUILDER - 2nd February, 2018 + 3rd February, 2018 Llewellyn van der Merwe llewellyn@joomlacomponentbuilder.com http://joomlacomponentbuilder.com