Skip to content
Permalink
Browse files

Added option to include or exclude Joomla Plugins from being compiled…

… or exported. Added the Joomla\Utilities\ArrayHelper to helper class header. Added option to only export words if required global option fields are set. Added option to use strict field access on all exports if required global option fields are set. Fixed gh-475 by adding the option to add a github token if needed under the global options global tab, also updated the error message.
  • Loading branch information...
Llewellynvdm committed Sep 10, 2019
1 parent e3f22d6 commit 2b1e0a65faf29269fc53e659ce9810e351bd0cbe
Showing with 675 additions and 279 deletions.
  1. +3 −3 README.md
  2. +3 −3 admin/README.txt
  3. +2 −0 admin/compiler/joomla_3/Helper.php
  4. +2 −0 admin/compiler/joomla_3/Helper_site.php
  5. +15 −0 admin/config.xml
  6. +20 −1 admin/helpers/compiler/a_Get.php
  7. +108 −34 admin/helpers/compiler/e_Interpretation.php
  8. +164 −34 admin/helpers/componentbuilder.php
  9. +13 −1 admin/language/en-GB/en-GB.com_componentbuilder.ini
  10. +2 −2 admin/models/admin_views.php
  11. +1 −1 admin/models/admins_custom_tabs.php
  12. +1 −1 admin/models/admins_fields.php
  13. +1 −1 admin/models/admins_fields_conditions.php
  14. +1 −1 admin/models/admins_fields_relations.php
  15. +5 −4 admin/models/ajax.php
  16. +1 −1 admin/models/class_extendings.php
  17. +2 −2 admin/models/class_methods.php
  18. +2 −2 admin/models/class_properties.php
  19. +1 −1 admin/models/components_admin_views.php
  20. +1 −1 admin/models/components_config.php
  21. +1 −1 admin/models/components_custom_admin_menus.php
  22. +1 −1 admin/models/components_custom_admin_views.php
  23. +1 −1 admin/models/components_dashboard.php
  24. +1 −1 admin/models/components_files_folders.php
  25. +1 −1 admin/models/components_mysql_tweaks.php
  26. +1 −1 admin/models/components_placeholders.php
  27. +1 −1 admin/models/components_plugins.php
  28. +1 −1 admin/models/components_site_views.php
  29. +1 −1 admin/models/components_updates.php
  30. +2 −2 admin/models/custom_admin_views.php
  31. +2 −2 admin/models/custom_codes.php
  32. +2 −2 admin/models/dynamic_gets.php
  33. +2 −2 admin/models/fields.php
  34. +1 −1 admin/models/fieldtype.php
  35. +2 −2 admin/models/fieldtypes.php
  36. +17 −0 admin/models/forms/component_plugins.xml
  37. +2 −2 admin/models/help_documents.php
  38. +2 −2 admin/models/joomla_components.php
  39. +81 −90 admin/models/joomla_plugins.php
  40. +1 −1 admin/models/joomla_plugins_files_folders_urls.php
  41. +1 −1 admin/models/joomla_plugins_updates.php
  42. +2 −2 admin/models/language_translations.php
  43. +2 −2 admin/models/languages.php
  44. +2 −2 admin/models/layouts.php
  45. +1 −1 admin/models/libraries.php
  46. +1 −1 admin/models/libraries_config.php
  47. +1 −1 admin/models/libraries_files_folders_urls.php
  48. +2 −2 admin/models/placeholders.php
  49. +1 −1 admin/models/server.php
  50. +2 −2 admin/models/servers.php
  51. +2 −2 admin/models/site_views.php
  52. +1 −1 admin/models/snippet_types.php
  53. +2 −2 admin/models/snippets.php
  54. +2 −2 admin/models/templates.php
  55. +2 −2 admin/models/validation_rules.php
  56. +7 −7 admin/views/import_joomla_components/tmpl/default.php
  57. +2 −2 admin/views/import_joomla_components/view.html.php
  58. +1 −1 componentbuilder.xml
  59. +2 −2 script.php
  60. +164 −34 site/helpers/componentbuilder.php
  61. +4 −1 site/language/en-GB/en-GB.com_componentbuilder.ini
@@ -146,12 +146,12 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 5th September, 2019
+ *Last Build*: 10th September, 2019
+ *Version*: 2.10.1
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **251450**
+ *Field count*: **1343**
+ *Line count*: **251878**
+ *Field count*: **1345**
+ *File count*: **1608**
+ *Folder count*: **253**

@@ -146,12 +146,12 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 5th September, 2019
+ *Last Build*: 10th September, 2019
+ *Version*: 2.10.1
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **251450**
+ *Field count*: **1343**
+ *Line count*: **251878**
+ *Field count*: **1345**
+ *File count*: **1608**
+ *Folder count*: **253**

@@ -17,6 +17,8 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

use Joomla\Utilities\ArrayHelper;

/**
* ###Component### component helper.
*/
@@ -17,6 +17,8 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');

use Joomla\Utilities\ArrayHelper;

/**
* ###Component### component helper
*/
@@ -67,6 +67,21 @@
folder="extension"
filter="cmd"
/>
<!-- Github_access_token Field. Type: Text. (joomla) -->
<field
type="text"
name="github_access_token"
label="COM_COMPONENTBUILDER_CONFIG_GITHUB_ACCESS_TOKEN_LABEL"
size="128"
maxlength="128"
description="COM_COMPONENTBUILDER_CONFIG_GITHUB_ACCESS_TOKEN_DESCRIPTION"
class="text_area full-width"
required="false"
filter="STRING"
message="COM_COMPONENTBUILDER_CONFIG_GITHUB_ACCESS_TOKEN_MESSAGE"
hint="COM_COMPONENTBUILDER_CONFIG_GITHUB_ACCESS_TOKEN_HINT"
autocomplete="off"
/>
<!-- Spacer_hr_one Field. Type: Spacer. A None Database Field. (joomla) -->
<field type="spacer" name="spacer_hr_one" hr="true" class="spacer_hr_one" />
<!-- Manage_jcb_package_directories Field. Type: Radio. (joomla) -->
@@ -60,6 +60,20 @@ class Get
*/
public $params;
/**
* Add strict field export permissions
*
* @var boolean
*/
public $strictFieldExportPermissions = false;
/**
* Add text only export options
*
* @var boolean
*/
public $exportTextOnly = false;
/**
* The global placeholders
*
@@ -1665,7 +1679,12 @@ public function getComponentData()
if (ComponentbuilderHelper::checkArray($component->addjoomla_plugins))
{
$joomla_plugins = array_map(function($array) use(&$component) {
return $this->setJoomlaPlugin($array['plugin'], $component);
// only load the plugins whose target association calles for it
if (!isset($array['target']) || $array['target'] != 2)
{
return $this->setJoomlaPlugin($array['plugin'], $component);
}
return null;
}, array_values($component->addjoomla_plugins));
}
unset($component->addjoomla_plugins);

Large diffs are not rendered by default.

@@ -12,6 +12,8 @@
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/**
* Componentbuilder component helper.
*/
@@ -61,24 +63,21 @@ public static function globalEvent($document)
/**
* The VDM packages paths
**/
public static $vdmGithubPackagesUrl = "https://api.github.com/repos/vdm-io/JCB-Packages/git/trees/master";
public static $vdmGithubPackageUrl = "https://github.com/vdm-io/JCB-Packages/raw/master/";
public static $vdmGithubPackagesUrl = "https://api.github.com/repos/vdm-io/JCB-Packages/git/trees/master";
/**
* The JCB packages paths
**/
public static $jcbGithubPackagesUrl = "https://api.github.com/repos/vdm-io/JCB-Community-Packages/git/trees/master";
public static $jcbGithubPackageUrl = "https://github.com/vdm-io/JCB-Community-Packages/raw/master/";
public static $jcbGithubPackagesUrl = "https://api.github.com/repos/vdm-io/JCB-Community-Packages/git/trees/master";
/**
* The bolerplate paths
**/
public static $bolerplatePath = 'https://raw.githubusercontent.com/vdm-io/boilerplate/jcb/';
public static $bolerplateAPI = 'https://api.github.com/repos/vdm-io/boilerplate/git/trees/jcb';
// not needed at this time (maybe latter)
public static $accessToken = "";
/**
* The array of constant paths
*
@@ -2413,66 +2412,163 @@ public static function removeFolder($dir, $ignore = false)
/**
* get the github repo file list
*
* @return array on success
*
*/
* The github access token
**/
protected static $gitHubAccessToken = "";
/**
* The github repo get data errors
**/
public static $githubRepoDataErrors = array();
/**
* get the github repo file list
*
* @return array on success
*
*/
public static function getGithubRepoFileList($type, $target)
{
// get the repo data
if (($repoData = self::getGithubRepoData($type, $target, 'tree')) !== false)
{
return $repoData->tree;
}
return false;
}
/**
* get the github repo file list
*
* @return array on success
*
*/
public static function getGithubRepoData($type, $url, $target = null, $return_type = 'object')
{
// always reset errors per/request
self::$githubRepoDataErrors = array();
// get the current Packages (public)
if (!$repoData = self::get($type))
if ('nomemory' === $type || !$repoData = self::get($type))
{
if (self::urlExists($target))
// add the token if not already added
$_url = self::setGithubToken($url);
// check if the url exist
if (self::urlExists($_url))
{
$repoData = self::getFileContents($target);
if (self::checkJson($repoData))
// get the data from github
if (($repoData = self::getFileContents($_url)) !== false && self::checkJson($repoData))
{
$test = json_decode($repoData);
if (self::checkObject($test) && isset($test->tree) && self::checkArray($test->tree) )
$github_returned = json_decode($repoData);
if (self::checkString($target) && self::checkObject($github_returned) &&
isset($github_returned->{$target}) && self::checkArray($github_returned->{$target}) )
{
if ('nomemory' !== $type)
{
// remember to set it
self::set($type, $repoData);
}
}
elseif (!self::checkString($target) && self::checkObject($github_returned) && !isset($github_returned->message))
{
// remember to set it
self::set($type, $repoData);
if ('nomemory' !== $type)
{
// remember to set it
self::set($type, $repoData);
}
}
// check if we have error message from github
elseif ($errorMessage = self::githubErrorHandeler(array('error' => null), $test))
elseif (($errorMessage = self::githubErrorHandeler(array('error' => null), $github_returned, $type)) !== false)
{
if (self::checkString($errorMessage['error']))
if (isset($errorMessage['error']) && self::checkString($errorMessage['error']))
{
// set the error in the application
JFactory::getApplication()->enqueueMessage($errorMessage['error'], 'Error');
// set the error also in the class encase it is and Ajax call
self::$githubRepoDataErrors[] = $errorMessage['error'];
}
$repoData = false;
return false;
}
elseif (self::checkString($target))
{
// setup error string
$error = JText::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DID_NOT_RETURN_S_DATA', $url, $target);
// set the error in the application
JFactory::getApplication()->enqueueMessage($error, 'Error');
// set the error also in the class encase it is and Ajax call
self::$githubRepoDataErrors[] = $error;
// we are done here
return false;
}
elseif ('nomemory' !== $type)
{
// setup error string
$error = JText::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DID_NOT_RETURN_S_DATA', $url, $type);
// set the error in the application
JFactory::getApplication()->enqueueMessage($error, 'Error');
// set the error also in the class encase it is and Ajax call
self::$githubRepoDataErrors[] = $error;
// we are done here
return false;
}
else
{
// setup error string
$error = JText::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DID_NOT_RETURN_VALID_DATA', $url, $type);
// set the error in the application
JFactory::getApplication()->enqueueMessage($error, 'Error');
// set the error also in the class encase it is and Ajax call
self::$githubRepoDataErrors[] = $error;
// we are done here
return false;
}
}
else
{
$repoData = false;
// setup error string
$error = JText::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_RETURN_ANY_DATA', $url);
// set the error in the application
JFactory::getApplication()->enqueueMessage($error, 'Error');
// set the error also in the class encase it is and Ajax call
self::$githubRepoDataErrors[] = $error;
// we are done here
return false;
}
}
else
{
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_EXIST', $target), 'Error');
// setup error string
$error = JText::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_EXIST', $url);
// set the error in the application
JFactory::getApplication()->enqueueMessage($error, 'Error');
// set the error also in the class encase it is and Ajax call
self::$githubRepoDataErrors[] = $error;
// we are done here
return false;
}
}
// check if we could find packages
if (isset($repoData) && self::checkJson($repoData))
{
$repoData = json_decode($repoData);
if (self::checkObject($repoData) && isset($repoData->tree) && self::checkArray($repoData->tree) )
if ('object' === $return_type)
{
return $repoData->tree;
return json_decode($repoData);
}
elseif ('array' === $return_type)
{
return json_decode($repoData, true);
}
return $repoData;
}
return false;
}
/**
* get the github error messages
*
* @return array of errors on success
*
*/
protected static function githubErrorHandeler($message, &$github)
* get the github error messages
*
* @return array of errors on success
*
*/
protected static function githubErrorHandeler($message, &$github, $type)
{
if (self::checkObject($github) && isset($github->message) && self::checkString($github->message))
{
@@ -2481,13 +2577,17 @@ protected static function githubErrorHandeler($message, &$github)
// add the documentation URL
if (isset($github->documentation_url) && self::checkString($github->documentation_url))
{
$errorMessage = $errorMessage.'<br />'.$github->documentation_url;
$errorMessage = $errorMessage . '<br />' . $github->documentation_url;
}
// check the message
if (strpos($errorMessage, 'Authenticated') !== false)
{
if ('nomemory' === $type)
{
$type = 'data';
}
// add little more help if it is an access token issue
$errorMessage = JText::sprintf('COM_COMPONENTBUILDER_SBR_YOU_CAN_ADD_AN_BACCESS_TOKENB_TO_GETBIBLE_GLOBAL_OPTIONS_TO_MAKE_AUTHENTICATED_REQUESTS_AN_ACCESS_TOKEN_WITH_ONLY_PUBLIC_ACCESS_WILL_DO', $errorMessage);
$errorMessage = JText::sprintf('COM_COMPONENTBUILDER_SBR_YOU_CAN_ADD_A_BGITHUB_ACCESS_TOKENB_TO_COMPONENTBUILDER_GLOBAL_OPTIONS_TO_MAKE_AUTHENTICATED_REQUESTS_TO_GITHUB_AN_ACCESS_TOKEN_WITH_ONLY_PUBLIC_ACCESS_WILL_DO_TO_RETRIEVE_S', $errorMessage, $type);
}
// set error notice
$message['error'] = $errorMessage;
@@ -2497,6 +2597,36 @@ protected static function githubErrorHandeler($message, &$github)
return false;
}
/**
* set the github token
*
* @return array of errors on success
*
*/
protected static function setGithubToken($url)
{
// first check if token already set
if (strpos($url, 'access_token=') !== false)
{
// make sure the token is loaded
if (!self::checkString(self::$gitHubAccessToken))
{
// get the global settings
if (!self::checkObject(self::$params))
{
self::$params = JComponentHelper::getParams('com_componentbuilder');
}
self::$gitHubAccessToken = self::$params->get('github_access_token', null);
}
// make sure the token is loaded at this point
if (self::checkString(self::$gitHubAccessToken))
{
$url .= '&access_token=' . self::$gitHubAccessToken;
}
}
return $url;
}
/**
* get Dynamic Scripts

0 comments on commit 2b1e0a6

Please sign in to comment.
You can’t perform that action at this time.