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.

This commit is contained in:
Llewellyn van der Merwe 2019-09-10 18:47:39 +02:00
parent e3f22d631c
commit 2b1e0a65fa
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
61 changed files with 726 additions and 330 deletions

View File

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

View File

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

View File

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

View File

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

View File

@ -67,6 +67,21 @@
folder="extension" folder="extension"
filter="cmd" 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) --> <!-- Spacer_hr_one Field. Type: Spacer. A None Database Field. (joomla) -->
<field type="spacer" name="spacer_hr_one" hr="true" class="spacer_hr_one" /> <field type="spacer" name="spacer_hr_one" hr="true" class="spacer_hr_one" />
<!-- Manage_jcb_package_directories Field. Type: Radio. (joomla) --> <!-- Manage_jcb_package_directories Field. Type: Radio. (joomla) -->

View File

@ -60,6 +60,20 @@ class Get
*/ */
public $params; 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 * The global placeholders
* *
@ -1665,7 +1679,12 @@ class Get
if (ComponentbuilderHelper::checkArray($component->addjoomla_plugins)) if (ComponentbuilderHelper::checkArray($component->addjoomla_plugins))
{ {
$joomla_plugins = array_map(function($array) use(&$component) { $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)); }, array_values($component->addjoomla_plugins));
} }
unset($component->addjoomla_plugins); unset($component->addjoomla_plugins);

View File

@ -9135,11 +9135,13 @@ class Interpretation extends Fields
*/ */
public function setGetItemsModelMethod($viewName_single, $viewName_list, $config = array('functionName' => 'getExportData', 'docDesc' => 'Method to get list export data.', 'type' => 'export')) public function setGetItemsModelMethod($viewName_single, $viewName_list, $config = array('functionName' => 'getExportData', 'docDesc' => 'Method to get list export data.', 'type' => 'export'))
{ {
// start the query string
$query = ''; $query = '';
if ($this->eximportView[$viewName_list] || 'export' !== $config['type']) // check if this is the export method
$isExport = ('export' === $config['type']);
// check if this view has export feature, and or if this is not an export method
if ((isset($this->eximportView[$viewName_list]) && $this->eximportView[$viewName_list]) || !$isExport)
{ {
$isExport = ('export' === $config['type']);
$query = PHP_EOL . PHP_EOL . $this->_t(1) . "/**"; $query = PHP_EOL . PHP_EOL . $this->_t(1) . "/**";
$query .= PHP_EOL . $this->_t(1) . " * " . $config['docDesc']; $query .= PHP_EOL . $this->_t(1) . " * " . $config['docDesc'];
$query .= PHP_EOL . $this->_t(1) . " *"; $query .= PHP_EOL . $this->_t(1) . " *";
@ -9170,6 +9172,25 @@ class Interpretation extends Fields
$query .= PHP_EOL . $this->_t(3) . "\$query->where('a.id IN (' . implode(',',\$pks) . ')');"; $query .= PHP_EOL . $this->_t(3) . "\$query->where('a.id IN (' . implode(',',\$pks) . ')');";
// add custom filtering php // add custom filtering php
$query .= $this->getCustomScriptBuilder('php_getlistquery', $viewName_single, PHP_EOL . PHP_EOL . $this->_t(1)); $query .= $this->getCustomScriptBuilder('php_getlistquery', $viewName_single, PHP_EOL . PHP_EOL . $this->_t(1));
// first check if we export of text only is avalable
if ($this->exportTextOnly)
{
// add switch
$query .= PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Get global switch to activate text only export";
$query .= PHP_EOL . $this->_t(3) . "\$export_text_only = JComponentHelper::getParams('com_" . $this->componentCodeName . "')->get('export_text_only', 0);";
// first check if we have custom queries
$custom_query = $this->setCustomQuery($viewName_list, $viewName_single, $this->_t(2), true);
}
// if values were returned add the area
if (isset($custom_query) && ComponentbuilderHelper::checkString($custom_query))
{
$query .= PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Add these queries only if text only is required";
$query .= PHP_EOL . $this->_t(3) . "if (\$export_text_only)";
$query .= PHP_EOL . $this->_t(3) . "{";
// add the custom fields query
$query .= $custom_query;
$query .= PHP_EOL . $this->_t(3) . "}";
}
// add access levels if the view has access set // add access levels if the view has access set
if (isset($this->accessBuilder[$viewName_single]) && ComponentbuilderHelper::checkString($this->accessBuilder[$viewName_single])) if (isset($this->accessBuilder[$viewName_single]) && ComponentbuilderHelper::checkString($this->accessBuilder[$viewName_single]))
{ {
@ -9188,15 +9209,33 @@ class Interpretation extends Fields
$query .= PHP_EOL . $this->_t(3) . "if (\$db->getNumRows())"; $query .= PHP_EOL . $this->_t(3) . "if (\$db->getNumRows())";
$query .= PHP_EOL . $this->_t(3) . "{"; $query .= PHP_EOL . $this->_t(3) . "{";
$query .= PHP_EOL . $this->_t(4) . "\$items = \$db->loadObjectList();"; $query .= PHP_EOL . $this->_t(4) . "\$items = \$db->loadObjectList();";
$query .= $this->setGetItemsMethodStringFix($viewName_single, $viewName_list, $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh], $this->_t(2), $isExport); // set the string fixing code
// add translations $query .= $this->setGetItemsMethodStringFix($viewName_single, $viewName_list, $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh], $this->_t(2), $isExport, true);
if (!$isExport) // first check if we export of text only is avalable
if ($this->exportTextOnly)
{ {
$query .= $this->setSelectionTranslationFix($viewName_list, $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh], $this->_t(2)); $query_translations = $this->setSelectionTranslationFix($viewName_list, $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh], $this->_t(3));
}
// add translations
if (isset($query_translations) && ComponentbuilderHelper::checkString($query_translations))
{
$query .= PHP_EOL . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Add these translation only if text only is required";
$query .= PHP_EOL . $this->_t(3) . "if (\$export_text_only)";
$query .= PHP_EOL . $this->_t(3) . "{";
$query .= $query_translations;
$query .= PHP_EOL . $this->_t(3) . "}";
} }
// add custom php to getItems method after all // add custom php to getItems method after all
$query .= $this->getCustomScriptBuilder('php_getitems_after_all', $viewName_single, PHP_EOL . PHP_EOL . $this->_t(2)); $query .= $this->getCustomScriptBuilder('php_getitems_after_all', $viewName_single, PHP_EOL . PHP_EOL . $this->_t(2));
$query .= PHP_EOL . $this->_t(4) . "return \$items;"; // in privacy export we must return array of arrays
if ('privacy' === $config['type'])
{
$query .= PHP_EOL . $this->_t(4) . "return json_decode(json_encode(\$items), true);";
}
else
{
$query .= PHP_EOL . $this->_t(4) . "return \$items;";
}
$query .= PHP_EOL . $this->_t(3) . "}"; $query .= PHP_EOL . $this->_t(3) . "}";
$query .= PHP_EOL . $this->_t(2) . "}"; $query .= PHP_EOL . $this->_t(2) . "}";
$query .= PHP_EOL . $this->_t(2) . "return false;"; $query .= PHP_EOL . $this->_t(2) . "return false;";
@ -9521,7 +9560,7 @@ class Interpretation extends Fields
return ''; return '';
} }
public function setCustomQuery($viewName_list, $viewName_single) public function setCustomQuery($viewName_list, $viewName_single, $tab = '', $just_text = false)
{ {
if (isset($this->customBuilder[$viewName_list]) && ComponentbuilderHelper::checkArray($this->customBuilder[$viewName_list])) if (isset($this->customBuilder[$viewName_list]) && ComponentbuilderHelper::checkArray($this->customBuilder[$viewName_list]))
{ {
@ -9529,11 +9568,20 @@ class Interpretation extends Fields
foreach ($this->customBuilder[$viewName_list] as $filter) foreach ($this->customBuilder[$viewName_list] as $filter)
{ {
// only load this if table is set // only load this if table is set
if (isset($this->customBuilderList[$viewName_list]) && ComponentbuilderHelper::checkArray($this->customBuilderList[$viewName_list]) && in_array($filter['code'], $this->customBuilderList[$viewName_list]) && isset($filter['custom']['table']) && ComponentbuilderHelper::checkString($filter['custom']['table']) && $filter['method'] == 0) if ((isset($this->customBuilderList[$viewName_list]) && ComponentbuilderHelper::checkArray($this->customBuilderList[$viewName_list]) && in_array($filter['code'], $this->customBuilderList[$viewName_list]) && isset($filter['custom']['table']) && ComponentbuilderHelper::checkString($filter['custom']['table']) && $filter['method'] == 0)
|| ($just_text && isset($filter['custom']['table']) && ComponentbuilderHelper::checkString($filter['custom']['table']) && $filter['method'] == 0))
{ {
$query .= PHP_EOL . PHP_EOL . $this->_t(2) . "//" . $this->setLine(__LINE__) . " From the " . ComponentbuilderHelper::safeString(ComponentbuilderHelper::safeString($filter['custom']['table'], 'w')) . " table."; $query .= PHP_EOL . PHP_EOL . $this->_t(2) . $tab . "//" . $this->setLine(__LINE__) . " From the " . ComponentbuilderHelper::safeString(ComponentbuilderHelper::safeString($filter['custom']['table'], 'w')) . " table.";
$query .= PHP_EOL . $this->_t(2) . "\$query->select(\$db->quoteName('" . $filter['custom']['db'] . "." . $filter['custom']['text'] . "','" . $filter['code'] . "_" . $filter['custom']['text'] . "'));"; // we want to at times just have the words and not the ids as well
$query .= PHP_EOL . $this->_t(2) . "\$query->join('LEFT', \$db->quoteName('" . $filter['custom']['table'] . "', '" . $filter['custom']['db'] . "') . ' ON (' . \$db->quoteName('a." . $filter['code'] . "') . ' = ' . \$db->quoteName('" . $filter['custom']['db'] . "." . $filter['custom']['id'] . "') . ')');"; if ($just_text)
{
$query .= PHP_EOL . $this->_t(2) . $tab . "\$query->select(\$db->quoteName('" . $filter['custom']['db'] . "." . $filter['custom']['text'] . "','" . $filter['code'] . "'));";
}
else
{
$query .= PHP_EOL . $this->_t(2) . $tab . "\$query->select(\$db->quoteName('" . $filter['custom']['db'] . "." . $filter['custom']['text'] . "','" . $filter['code'] . "_" . $filter['custom']['text'] . "'));";
}
$query .= PHP_EOL . $this->_t(2) . $tab . "\$query->join('LEFT', \$db->quoteName('" . $filter['custom']['table'] . "', '" . $filter['custom']['db'] . "') . ' ON (' . \$db->quoteName('a." . $filter['code'] . "') . ' = ' . \$db->quoteName('" . $filter['custom']['db'] . "." . $filter['custom']['id'] . "') . ')');";
} }
// build the field type file // build the field type file
$this->setCustomFieldTypeFile($filter, $viewName_list, $viewName_single); $this->setCustomFieldTypeFile($filter, $viewName_list, $viewName_single);
@ -11804,7 +11852,7 @@ class Interpretation extends Fields
$allow[] = $this->_t(3) . "{"; $allow[] = $this->_t(3) . "{";
$allow[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " We have to unset then (TODO)"; $allow[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " We have to unset then (TODO)";
$allow[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Hiddend field can not handel array value"; $allow[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Hiddend field can not handel array value";
$allow[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Even if we conver to json we get an error"; $allow[] = $this->_t(4) . "//" . $this->setLine(__LINE__) . " Even if we convert to json we get an error";
$allow[] = $this->_t(4) . "\$form->removeField('" . $fieldName . "');"; $allow[] = $this->_t(4) . "\$form->removeField('" . $fieldName . "');";
$allow[] = $this->_t(3) . "}"; $allow[] = $this->_t(3) . "}";
$allow[] = $this->_t(2) . "}"; $allow[] = $this->_t(2) . "}";
@ -12458,7 +12506,7 @@ class Interpretation extends Fields
public function setPopulateState(&$view) public function setPopulateState(&$view)
{ {
// rest buket // reset buket
$state = ''; $state = '';
// keep track of all fields already added // keep track of all fields already added
$donelist = array(); $donelist = array();
@ -12665,11 +12713,12 @@ class Interpretation extends Fields
return $checkin; return $checkin;
} }
public function setGetItemsMethodStringFix($viewName_single, $viewName_list, $Component, $tab = '', $export = false) public function setGetItemsMethodStringFix($viewName_single, $viewName_list, $Component, $tab = '', $export = false, $all = false)
{ {
// add the fix if this view has the need for it // add the fix if this view has the need for it
$fix = ''; $fix = '';
$forEachStart = ''; $forEachStart = '';
$fix_access = '';
// encryption switches // encryption switches
foreach ($this->cryptionTypes as $cryptionType) foreach ($this->cryptionTypes as $cryptionType)
{ {
@ -12686,21 +12735,22 @@ class Interpretation extends Fields
// check if the item has permissions. // check if the item has permissions.
if ($coreLoad && isset($core['core.access']) && isset($this->permissionBuilder[$core['core.access']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder[$core['core.access']]) && in_array($viewName_single, $this->permissionBuilder[$core['core.access']])) if ($coreLoad && isset($core['core.access']) && isset($this->permissionBuilder[$core['core.access']]) && ComponentbuilderHelper::checkArray($this->permissionBuilder[$core['core.access']]) && in_array($viewName_single, $this->permissionBuilder[$core['core.access']]))
{ {
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Remove items the user can't access."; $fix_access = PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "//" . $this->setLine(__LINE__) . " Remove items the user can't access.";
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "\$access = (\$user->authorise('" . $core['core.access'] . "', 'com_" . $component . "." . $viewName_single . ".' . (int) \$item->id) && \$user->authorise('" . $core['core.access'] . "', 'com_" . $component . "'));"; $fix_access .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "\$access = (\$user->authorise('" . $core['core.access'] . "', 'com_" . $component . "." . $viewName_single . ".' . (int) \$item->id) && \$user->authorise('" . $core['core.access'] . "', 'com_" . $component . "'));";
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (!\$access)"; $fix_access .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (!\$access)";
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "{"; $fix_access .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "{";
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "unset(\$items[\$nr]);"; $fix_access .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "unset(\$items[\$nr]);";
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "continue;"; $fix_access .= PHP_EOL . $this->_t(1) . $tab . $this->_t(4) . "continue;";
$fix .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "}" . PHP_EOL; $fix_access .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "}" . PHP_EOL;
} }
if (!$export) // get the correct array
if ($export || $all)
{ {
$methodName = 'getItemsMethodListStringFixBuilder'; $methodName = 'getItemsMethodEximportStringFixBuilder';
} }
else else
{ {
$methodName = 'getItemsMethodEximportStringFixBuilder'; $methodName = 'getItemsMethodListStringFixBuilder';
} }
// load the relations before modeling // load the relations before modeling
if (isset($this->fieldRelations[$viewName_list]) && ComponentbuilderHelper::checkArray($this->fieldRelations[$viewName_list])) if (isset($this->fieldRelations[$viewName_list]) && ComponentbuilderHelper::checkArray($this->fieldRelations[$viewName_list]))
@ -12922,10 +12972,10 @@ class Interpretation extends Fields
} }
} }
// close the foreach if needed // close the foreach if needed
if (ComponentbuilderHelper::checkString($fix) || $export) if (ComponentbuilderHelper::checkString($fix) || ComponentbuilderHelper::checkString($fix_access) || $export || $all)
{ {
// start the loop // start the loop
$forEachStart = PHP_EOL . PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . "//" . $this->setLine(__LINE__) . " set values to display correctly."; $forEachStart = PHP_EOL . PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . "//" . $this->setLine(__LINE__) . " Set values to display correctly.";
$forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . "if (" . $Component . "Helper::checkArray(\$items))"; $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . "if (" . $Component . "Helper::checkArray(\$items))";
$forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . "{"; $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(1) . "{";
// do not add to export since it is already done // do not add to export since it is already done
@ -12937,19 +12987,43 @@ class Interpretation extends Fields
$forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "\$user = JFactory::getUser();"; $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "\$user = JFactory::getUser();";
$forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "}"; $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "}";
} }
// the permissional acttion switch
$hasPermissional = false;
// add the permissional removal of values the user has not right to view or access // add the permissional removal of values the user has not right to view or access
if (isset($this->permissionFields[$viewName_single]) && ComponentbuilderHelper::checkArray($this->permissionFields[$viewName_single])) if ($this->strictFieldExportPermissions && isset($this->permissionFields[$viewName_single]) && ComponentbuilderHelper::checkArray($this->permissionFields[$viewName_single]))
{ {
$forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "//" . $this->setLine(__LINE__) . " -- get global permissional control activation. (default is inactive) ---"; foreach ($this->permissionFields[$viewName_single] as $fieldName => $permission_options)
$forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "//" . $this->setLine(__LINE__) . " to use this feature add a global option radio button to your"; {
$forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "//" . $this->setLine(__LINE__) . " component with a value of 1 as on/activate and 0 as inactive/off"; if (!$hasPermissional)
$forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "//" . $this->setLine(__LINE__) . " make sure it has the name: strict_permission_per_field"; {
$forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "\$strict_permission_per_field = JComponentHelper::getParams('com_" . $component . "')->get('strict_permission_per_field', 0);" . PHP_EOL; foreach($permission_options as $permission_option => $fieldType)
{
if (!$hasPermissional)
{
switch ($permission_option)
{
case 'access':
case 'view':
$hasPermissional = true;
break;
}
}
}
}
}
// add the notes and get the global switch
if ($hasPermissional)
{
$forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "//" . $this->setLine(__LINE__) . " Get global permissional control activation. (default is inactive)";
$forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "\$strict_permission_per_field = JComponentHelper::getParams('com_" . $component . "')->get('strict_permission_per_field', 0);" . PHP_EOL;
}
} }
$forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "foreach (\$items as \$nr => &\$item)"; $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "foreach (\$items as \$nr => &\$item)";
$forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "{"; $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(2) . "{";
// add the access options
$forEachStart .= $fix_access;
// add the permissional removal of values the user has not right to view or access // add the permissional removal of values the user has not right to view or access
if (isset($this->permissionFields[$viewName_single]) && ComponentbuilderHelper::checkArray($this->permissionFields[$viewName_single])) if ($hasPermissional)
{ {
$forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "//" . $this->setLine(__LINE__) . " use permissional control if globaly set."; $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "//" . $this->setLine(__LINE__) . " use permissional control if globaly set.";
$forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (\$strict_permission_per_field)"; $forEachStart .= PHP_EOL . $this->_t(1) . $tab . $this->_t(3) . "if (\$strict_permission_per_field)";

View File

@ -12,6 +12,8 @@
// No direct access to this file // No direct access to this file
defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/** /**
* Componentbuilder component helper. * Componentbuilder component helper.
*/ */
@ -61,14 +63,14 @@ abstract class ComponentbuilderHelper
/** /**
* The VDM packages paths * 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 $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 * 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 $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 * The bolerplate paths
@ -76,9 +78,6 @@ abstract class ComponentbuilderHelper
public static $bolerplatePath = 'https://raw.githubusercontent.com/vdm-io/boilerplate/jcb/'; 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'; 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 * The array of constant paths
* *
@ -2413,66 +2412,163 @@ abstract class ComponentbuilderHelper
/** /**
* get the github repo file list * The github access token
* **/
* @return array on success 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) public static function getGithubRepoFileList($type, $target)
{ {
// get the current Packages (public) // get the repo data
if (!$repoData = self::get($type)) if (($repoData = self::getGithubRepoData($type, $target, 'tree')) !== false)
{ {
if (self::urlExists($target)) return $repoData->tree;
{
$repoData = self::getFileContents($target);
if (self::checkJson($repoData))
{
$test = json_decode($repoData);
if (self::checkObject($test) && isset($test->tree) && self::checkArray($test->tree) )
{
// remember to set it
self::set($type, $repoData);
}
// check if we have error message from github
elseif ($errorMessage = self::githubErrorHandeler(array('error' => null), $test))
{
if (self::checkString($errorMessage['error']))
{
JFactory::getApplication()->enqueueMessage($errorMessage['error'], 'Error');
}
$repoData = false;
}
}
else
{
$repoData = false;
}
}
else
{
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_EXIST', $target), 'Error');
}
}
// 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) )
{
return $repoData->tree;
}
} }
return false; return false;
} }
/** /**
* get the github error messages * get the github repo file list
* *
* @return array of errors on success * @return array on success
* *
*/ */
protected static function githubErrorHandeler($message, &$github) 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 ('nomemory' === $type || !$repoData = self::get($type))
{
// add the token if not already added
$_url = self::setGithubToken($url);
// check if the url exist
if (self::urlExists($_url))
{
// get the data from github
if (($repoData = self::getFileContents($_url)) !== false && self::checkJson($repoData))
{
$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))
{
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), $github_returned, $type)) !== false)
{
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'];
}
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
{
// 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
{
// 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))
{
if ('object' === $return_type)
{
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, $type)
{ {
if (self::checkObject($github) && isset($github->message) && self::checkString($github->message)) if (self::checkObject($github) && isset($github->message) && self::checkString($github->message))
{ {
@ -2481,13 +2577,17 @@ abstract class ComponentbuilderHelper
// add the documentation URL // add the documentation URL
if (isset($github->documentation_url) && self::checkString($github->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 // check the message
if (strpos($errorMessage, 'Authenticated') !== false) if (strpos($errorMessage, 'Authenticated') !== false)
{ {
if ('nomemory' === $type)
{
$type = 'data';
}
// add little more help if it is an access token issue // 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 // set error notice
$message['error'] = $errorMessage; $message['error'] = $errorMessage;
@ -2497,6 +2597,36 @@ abstract class ComponentbuilderHelper
return false; 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 * get Dynamic Scripts

View File

@ -3031,12 +3031,15 @@ COM_COMPONENTBUILDER_COMPONENT_PLUGINS="Component Plugins"
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_ADDJOOMLA_PLUGINS="Addjoomla Plugins" COM_COMPONENTBUILDER_COMPONENT_PLUGINS_ADDJOOMLA_PLUGINS="Addjoomla Plugins"
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_ADDJOOMLA_PLUGINS_DESCRIPTION="Setup the Joomla plugins for this component." COM_COMPONENTBUILDER_COMPONENT_PLUGINS_ADDJOOMLA_PLUGINS_DESCRIPTION="Setup the Joomla plugins for this component."
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_ADDJOOMLA_PLUGINS_LABEL="Joomla Plugins" COM_COMPONENTBUILDER_COMPONENT_PLUGINS_ADDJOOMLA_PLUGINS_LABEL="Joomla Plugins"
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_COMPILE_AMP_EXPORT="Compile &amp; Export"
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_COMPILE_ONLY="Compile (only)"
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_CREATED_BY_DESC="The user that created this Component Plugins." COM_COMPONENTBUILDER_COMPONENT_PLUGINS_CREATED_BY_DESC="The user that created this Component Plugins."
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_CREATED_BY_LABEL="Created By" COM_COMPONENTBUILDER_COMPONENT_PLUGINS_CREATED_BY_LABEL="Created By"
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_CREATED_DATE_DESC="The date this Component Plugins was created." COM_COMPONENTBUILDER_COMPONENT_PLUGINS_CREATED_DATE_DESC="The date this Component Plugins was created."
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_CREATED_DATE_LABEL="Created Date" COM_COMPONENTBUILDER_COMPONENT_PLUGINS_CREATED_DATE_LABEL="Created Date"
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_EDIT="Editing the Component Plugins" COM_COMPONENTBUILDER_COMPONENT_PLUGINS_EDIT="Editing the Component Plugins"
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_ERROR_UNIQUE_ALIAS="Another Component Plugins has the same alias." COM_COMPONENTBUILDER_COMPONENT_PLUGINS_ERROR_UNIQUE_ALIAS="Another Component Plugins has the same alias."
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_EXPORT_ONLY="Export (only)"
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_ID="Id" COM_COMPONENTBUILDER_COMPONENT_PLUGINS_ID="Id"
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_JOOMLA_COMPONENT="Joomla Component" COM_COMPONENTBUILDER_COMPONENT_PLUGINS_JOOMLA_COMPONENT="Joomla Component"
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_JOOMLA_COMPONENT_DESCRIPTION="Select a Joomla Component" COM_COMPONENTBUILDER_COMPONENT_PLUGINS_JOOMLA_COMPONENT_DESCRIPTION="Select a Joomla Component"
@ -3056,6 +3059,8 @@ COM_COMPONENTBUILDER_COMPONENT_PLUGINS_PLUGIN_LABEL="Plugins"
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_PUBLISHING="Publishing" COM_COMPONENTBUILDER_COMPONENT_PLUGINS_PUBLISHING="Publishing"
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Component Plugins to customise the alias." COM_COMPONENTBUILDER_COMPONENT_PLUGINS_SAVE_WARNING="Alias already existed so a number was added at the end. You can re-edit the Component Plugins to customise the alias."
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_STATUS="Status" COM_COMPONENTBUILDER_COMPONENT_PLUGINS_STATUS="Status"
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_TARGET_DESCRIPTION="Association"
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_TARGET_LABEL="Target"
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_VERSION_DESC="A count of the number of times this Component Plugins has been revised." COM_COMPONENTBUILDER_COMPONENT_PLUGINS_VERSION_DESC="A count of the number of times this Component Plugins has been revised."
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_VERSION_LABEL="Revision" COM_COMPONENTBUILDER_COMPONENT_PLUGINS_VERSION_LABEL="Revision"
COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS="Component Site Views" COM_COMPONENTBUILDER_COMPONENT_SITE_VIEWS="Component Site Views"
@ -3375,6 +3380,10 @@ COM_COMPONENTBUILDER_CONFIG_FORCE_LOAD="Force"
COM_COMPONENTBUILDER_CONFIG_FROMNAME_DESCRIPTION="Text displayed in the header &quot;From:&quot; field when sending a site email. Usually the site name." COM_COMPONENTBUILDER_CONFIG_FROMNAME_DESCRIPTION="Text displayed in the header &quot;From:&quot; field when sending a site email. Usually the site name."
COM_COMPONENTBUILDER_CONFIG_FROMNAME_HINT="From Name Here" COM_COMPONENTBUILDER_CONFIG_FROMNAME_HINT="From Name Here"
COM_COMPONENTBUILDER_CONFIG_FROMNAME_LABEL="From Name" COM_COMPONENTBUILDER_CONFIG_FROMNAME_LABEL="From Name"
COM_COMPONENTBUILDER_CONFIG_GITHUB_ACCESS_TOKEN_DESCRIPTION="This is only needed when you are on a shared IP or/and have reached the public free limit of API queries to gitHub. So unless you have seen some kind of error that directed you here to add an <b>access token</b> you can just ignore this field."
COM_COMPONENTBUILDER_CONFIG_GITHUB_ACCESS_TOKEN_HINT="OAUTH-TOKEN"
COM_COMPONENTBUILDER_CONFIG_GITHUB_ACCESS_TOKEN_LABEL="gitHub Access Token<br /><small>Check <a href='https://developer.github.com/v3/#authentication' target='_blank'>https://developer.github.com/v3/#authentication</a> for more info.</small>"
COM_COMPONENTBUILDER_CONFIG_GITHUB_ACCESS_TOKEN_MESSAGE="Error! Please add token here."
COM_COMPONENTBUILDER_CONFIG_GIT_FOLDER_PATH_DESCRIPTION="Here you can set the path to the git folder." COM_COMPONENTBUILDER_CONFIG_GIT_FOLDER_PATH_DESCRIPTION="Here you can set the path to the git folder."
COM_COMPONENTBUILDER_CONFIG_GIT_FOLDER_PATH_HINT="/home/user/git" COM_COMPONENTBUILDER_CONFIG_GIT_FOLDER_PATH_HINT="/home/user/git"
COM_COMPONENTBUILDER_CONFIG_GIT_FOLDER_PATH_LABEL="Git Folder Path" COM_COMPONENTBUILDER_CONFIG_GIT_FOLDER_PATH_LABEL="Git Folder Path"
@ -7269,7 +7278,7 @@ COM_COMPONENTBUILDER_RIGHT_OF_TABS="Right of Tabs"
COM_COMPONENTBUILDER_RUN_EXPANSION="Run Expansion" COM_COMPONENTBUILDER_RUN_EXPANSION="Run Expansion"
COM_COMPONENTBUILDER_SAVE_SUCCESS="Great! Item successfully saved." COM_COMPONENTBUILDER_SAVE_SUCCESS="Great! Item successfully saved."
COM_COMPONENTBUILDER_SAVE_WARNING="The value already existed so please select another." COM_COMPONENTBUILDER_SAVE_WARNING="The value already existed so please select another."
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="%s<br />You can add an <b>access token<b/> to getBible global options to make authenticated requests. An access token with only public access will do." 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="%s<br />You can add a <b>gitHub Access Token</b> to Componentbuilder global options to make authenticated requests to gitHub. An access token with only public access will do to retrieve %s."
COM_COMPONENTBUILDER_SEARCHABLE="Searchable" COM_COMPONENTBUILDER_SEARCHABLE="Searchable"
COM_COMPONENTBUILDER_SEE_ALL_IMPORT_INFO="See All Import Info" COM_COMPONENTBUILDER_SEE_ALL_IMPORT_INFO="See All Import Info"
COM_COMPONENTBUILDER_SELECTION="selection" COM_COMPONENTBUILDER_SELECTION="selection"
@ -8313,7 +8322,10 @@ COM_COMPONENTBUILDER_THE_SEARCH_FOR_THE_SNIPPETS_ARE_CASE_SENSITIVE_SO_IF_YOU_CH
COM_COMPONENTBUILDER_THE_SERVER_DETAILS_FOR_BID_SB_COULD_NOT_BE_RETRIEVED="The server details for <b>(ID: %s)</b> could not be retrieved!" COM_COMPONENTBUILDER_THE_SERVER_DETAILS_FOR_BID_SB_COULD_NOT_BE_RETRIEVED="The server details for <b>(ID: %s)</b> could not be retrieved!"
COM_COMPONENTBUILDER_THE_SNIPPETS_WERE_SUCCESSFULLY_EXPORTED="The Snippets Were Successfully Exported!" COM_COMPONENTBUILDER_THE_SNIPPETS_WERE_SUCCESSFULLY_EXPORTED="The Snippets Were Successfully Exported!"
COM_COMPONENTBUILDER_THE_SNIPPET_WAS_SUCCESSFULLY_EXPORTED="The Snippet Was Successfully Exported!" COM_COMPONENTBUILDER_THE_SNIPPET_WAS_SUCCESSFULLY_EXPORTED="The Snippet Was Successfully Exported!"
COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DID_NOT_RETURN_S_DATA="The url (%s) set to retrieve the packages did not return %s data!"
COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DID_NOT_RETURN_VALID_DATA="The url (%s) set to retrieve the packages did not return valid data!"
COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_EXIST="The url (%s) set to retrieve the packages does not exist!" COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_EXIST="The url (%s) set to retrieve the packages does not exist!"
COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_RETURN_ANY_DATA="The url (%s) set to retrieve the packages does not return any data!"
COM_COMPONENTBUILDER_THE_WIKI_IS_LOADING="The wiki is loading" COM_COMPONENTBUILDER_THE_WIKI_IS_LOADING="The wiki is loading"
COM_COMPONENTBUILDER_THIS_BSB_IS_NOT_LINKED_TO_ANY_OTHER_AREAS_OF_JCB_AT_THIS_TIME="This <b>%s</b> is not linked to any other areas of JCB at this time!" COM_COMPONENTBUILDER_THIS_BSB_IS_NOT_LINKED_TO_ANY_OTHER_AREAS_OF_JCB_AT_THIS_TIME="This <b>%s</b> is not linked to any other areas of JCB at this time!"
COM_COMPONENTBUILDER_THIS_PACKAGE_BPASSEDB_THE_CHECKSUM_VALIDATIONBR_BR_SMALLMANUALLY_ALSO_VALIDATE_THAT_THE_CORRECT_CHECKSUM_WAS_USEDSMALLBR_THIS_CHECKSUM_BSB_MUST_BE_THE_SAME_AS_THE_ONE_FOUND_A_S_SA="This package <b>PASSED</b> the checksum validation!<br /><br /><small>Manually also validate that the correct checksum was used.</small><br />This checksum: <b>%s</b> must be the same as the one found @ <a %s %s</a>" COM_COMPONENTBUILDER_THIS_PACKAGE_BPASSEDB_THE_CHECKSUM_VALIDATIONBR_BR_SMALLMANUALLY_ALSO_VALIDATE_THAT_THE_CORRECT_CHECKSUM_WAS_USEDSMALLBR_THIS_CHECKSUM_BSB_MUST_BE_THE_SAME_AS_THE_ONE_FOUND_A_S_SA="This package <b>PASSED</b> the checksum validation!<br /><br /><small>Manually also validate that the correct checksum was used.</small><br />This checksum: <b>%s</b> must be the same as the one found @ <a %s %s</a>"

View File

@ -114,7 +114,7 @@ class ComponentbuilderModelAdmin_views extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.
@ -376,7 +376,7 @@ class ComponentbuilderModelAdmin_views extends JModelList
{ {
$items = $db->loadObjectList(); $items = $db->loadObjectList();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)

View File

@ -84,7 +84,7 @@ class ComponentbuilderModelAdmins_custom_tabs extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -84,7 +84,7 @@ class ComponentbuilderModelAdmins_fields extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -84,7 +84,7 @@ class ComponentbuilderModelAdmins_fields_conditions extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -84,7 +84,7 @@ class ComponentbuilderModelAdmins_fields_relations extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -3212,13 +3212,14 @@ class ComponentbuilderModelAjax extends JModelList
{ {
// secure path // secure path
$path = ComponentbuilderHelper::safeString(str_replace('.json','',$path), 'filename', '', false).'.json'; $path = ComponentbuilderHelper::safeString(str_replace('.json','',$path), 'filename', '', false).'.json';
// base path
$base_path = basename($path);
// set url // set url
$url = ComponentbuilderHelper::$snippetPath.rawurlencode(basename($path)); $url = ComponentbuilderHelper::$snippetPath.rawurlencode($base_path);
// get the snippets // get the snippets
$snippet = ComponentbuilderHelper::getFileContents($url); if (($snippet = ComponentbuilderHelper::getGithubRepoData('lib_snippet_' . $base_path, $url)) !== false)
if (ComponentbuilderHelper::checkJson($snippet))
{ {
return $this->saveSnippet(json_decode($snippet, true), $status, $user); return $this->saveSnippet($snippet, $status, $user);
} }
return array('message' => JText::_('COM_COMPONENTBUILDER_ERROR_THE_PATH_HAS_A_MISMATCH_AND_COULD_THEREFORE_NOT_RETRIEVE_THE_SNIPPET_FROM_GITHUB'), 'status' => 'danger'); return array('message' => JText::_('COM_COMPONENTBUILDER_ERROR_THE_PATH_HAS_A_MISMATCH_AND_COULD_THEREFORE_NOT_RETRIEVE_THE_SNIPPET_FROM_GITHUB'), 'status' => 'danger');
} }

View File

@ -90,7 +90,7 @@ class ComponentbuilderModelClass_extendings extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -94,7 +94,7 @@ class ComponentbuilderModelClass_methods extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.
@ -303,7 +303,7 @@ class ComponentbuilderModelClass_methods extends JModelList
{ {
$items = $db->loadObjectList(); $items = $db->loadObjectList();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)

View File

@ -94,7 +94,7 @@ class ComponentbuilderModelClass_properties extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.
@ -303,7 +303,7 @@ class ComponentbuilderModelClass_properties extends JModelList
{ {
$items = $db->loadObjectList(); $items = $db->loadObjectList();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)

View File

@ -84,7 +84,7 @@ class ComponentbuilderModelComponents_admin_views extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -84,7 +84,7 @@ class ComponentbuilderModelComponents_config extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -84,7 +84,7 @@ class ComponentbuilderModelComponents_custom_admin_menus extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -84,7 +84,7 @@ class ComponentbuilderModelComponents_custom_admin_views extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -84,7 +84,7 @@ class ComponentbuilderModelComponents_dashboard extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -84,7 +84,7 @@ class ComponentbuilderModelComponents_files_folders extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -84,7 +84,7 @@ class ComponentbuilderModelComponents_mysql_tweaks extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -84,7 +84,7 @@ class ComponentbuilderModelComponents_placeholders extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -84,7 +84,7 @@ class ComponentbuilderModelComponents_plugins extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -84,7 +84,7 @@ class ComponentbuilderModelComponents_site_views extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -84,7 +84,7 @@ class ComponentbuilderModelComponents_updates extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -106,7 +106,7 @@ class ComponentbuilderModelCustom_admin_views extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.
@ -317,7 +317,7 @@ class ComponentbuilderModelCustom_admin_views extends JModelList
{ {
$items = $db->loadObjectList(); $items = $db->loadObjectList();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)

View File

@ -102,7 +102,7 @@ class ComponentbuilderModelCustom_codes extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.
@ -350,7 +350,7 @@ class ComponentbuilderModelCustom_codes extends JModelList
{ {
$items = $db->loadObjectList(); $items = $db->loadObjectList();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)

View File

@ -94,7 +94,7 @@ class ComponentbuilderModelDynamic_gets extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.
@ -300,7 +300,7 @@ class ComponentbuilderModelDynamic_gets extends JModelList
{ {
$items = $db->loadObjectList(); $items = $db->loadObjectList();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)

View File

@ -118,7 +118,7 @@ class ComponentbuilderModelFields extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.
@ -415,7 +415,7 @@ class ComponentbuilderModelFields extends JModelList
{ {
$items = $db->loadObjectList(); $items = $db->loadObjectList();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)

View File

@ -264,7 +264,7 @@ class ComponentbuilderModelFieldtype extends JModelAdmin
{ {
$items = $db->loadObjectList(); $items = $db->loadObjectList();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -102,7 +102,7 @@ class ComponentbuilderModelFieldtypes extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.
@ -269,7 +269,7 @@ class ComponentbuilderModelFieldtypes extends JModelList
{ {
$items = $db->loadObjectList(); $items = $db->loadObjectList();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)

View File

@ -120,6 +120,23 @@
default="0" default="0"
button="false" button="false"
/> />
<!-- Target Field. Type: List. (joomla) -->
<field
type="list"
name="target"
label="COM_COMPONENTBUILDER_COMPONENT_PLUGINS_TARGET_LABEL"
description="COM_COMPONENTBUILDER_COMPONENT_PLUGINS_TARGET_DESCRIPTION"
class="list_class"
multiple="false"
default="0">
<!-- Option Set. -->
<option value="1">
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_COMPILE_ONLY</option>
<option value="2">
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_EXPORT_ONLY</option>
<option value="0">
COM_COMPONENTBUILDER_COMPONENT_PLUGINS_COMPILE_AMP_EXPORT</option>
</field>
</form> </form>
</field> </field>
<!-- Note_on_joomla_plugins Field. Type: Note. A None Database Field. (joomla) --> <!-- Note_on_joomla_plugins Field. Type: Note. A None Database Field. (joomla) -->

View File

@ -102,7 +102,7 @@ class ComponentbuilderModelHelp_documents extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.
@ -306,7 +306,7 @@ class ComponentbuilderModelHelp_documents extends JModelList
{ {
$items = $db->loadObjectList(); $items = $db->loadObjectList();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)

View File

@ -2032,7 +2032,7 @@ class ComponentbuilderModelJoomla_components extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.
@ -2190,7 +2190,7 @@ class ComponentbuilderModelJoomla_components extends JModelList
// Get the encryption object. // Get the encryption object.
$basic = new FOFEncryptAes($basickey); $basic = new FOFEncryptAes($basickey);
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)

View File

@ -45,28 +45,23 @@ class ComponentbuilderModelJoomla_plugins extends JModelList
public function getBoilerplate() public function getBoilerplate()
{ {
// get boilerplate repo root details // get boilerplate repo root details
if (($result = ComponentbuilderHelper::getFileContents(ComponentbuilderHelper::$bolerplateAPI)) !== false && ComponentbuilderHelper::checkJson($result)) if (($repo_tree = ComponentbuilderHelper::getGithubRepoFileList('boilerplate', ComponentbuilderHelper::$bolerplateAPI)) !== false)
{ {
$result = json_decode($result); $found = array_values(array_filter(
// check if we have a three $repo_tree,
if (isset($result->tree) && ComponentbuilderHelper::checkArray($result->tree)) function($tree) {
{ if (isset($tree->path) && $tree->path === 'plugins')
$found = array_values(array_filter( {
$result->tree, return true;
function($tree) {
if (isset($tree->path) && $tree->path === 'plugins')
{
return true;
}
return false;
} }
)); return false;
// make sure we have the correct boilerplate
if (ComponentbuilderHelper::checkArray($found) && count($found) == 1 && method_exists(__CLASS__, 'getPluginsBoilerplate'))
{
// get the plugins boilerplate
return $this->getPluginsBoilerplate($found[0]->url);
} }
));
// make sure we have the correct boilerplate
if (ComponentbuilderHelper::checkArray($found) && count($found) == 1 && method_exists(__CLASS__, 'getPluginsBoilerplate'))
{
// get the plugins boilerplate
return $this->getPluginsBoilerplate($found[0]->url);
} }
} }
return false; return false;
@ -81,85 +76,80 @@ class ComponentbuilderModelJoomla_plugins extends JModelList
protected function getPluginsBoilerplate($url) protected function getPluginsBoilerplate($url)
{ {
// get boilerplate root for plugins // get boilerplate root for plugins
if (($result = ComponentbuilderHelper::getFileContents($url)) !== false && ComponentbuilderHelper::checkJson($result)) if (($plugin_tree = ComponentbuilderHelper::getGithubRepoFileList('boilerplate_plugins', $url)) !== false)
{ {
$result = json_decode($result); // get the app object
// check if we have a tree $app = JFactory::getApplication();
if (isset($result->tree) && ComponentbuilderHelper::checkArray($result->tree)) // set the table names
{ $tables = array();
// get the app object $tables['e'] = 'class_extends';
$app = JFactory::getApplication(); $tables['g'] = 'joomla_plugin_group';
// set the table names $tables['m'] = 'class_method';
$tables = array(); $tables['p'] = 'class_property';
$tables['e'] = 'class_extends'; // load the needed models
$tables['g'] = 'joomla_plugin_group'; $models = array();
$tables['m'] = 'class_method'; $models['e'] = ComponentbuilderHelper::getModel($tables['e']);
$tables['p'] = 'class_property'; $models['g'] = ComponentbuilderHelper::getModel($tables['g']);
// load the needed models $models['p'] = ComponentbuilderHelper::getModel($tables['p']);
$models = array(); $models['m'] = ComponentbuilderHelper::getModel($tables['m']);
$models['e'] = ComponentbuilderHelper::getModel($tables['e']); // get the needed data of each plugin group
$models['g'] = ComponentbuilderHelper::getModel($tables['g']); $groups = array_map(
$models['p'] = ComponentbuilderHelper::getModel($tables['p']); function($tree) use(&$app, &$models, &$tables){
$models['m'] = ComponentbuilderHelper::getModel($tables['m']); if (($fooClass = ComponentbuilderHelper::getFileContents(ComponentbuilderHelper::$bolerplatePath . '/plugins/' . $tree->path . '/foo.php')) !== false && ComponentbuilderHelper::checkString($fooClass))
// get the needed data of each plugin group {
$groups = array_map( // extract the boilerplate class extends and check if already set
function($tree) use(&$app, &$models, &$tables){ if (($classExtends = ComponentbuilderHelper::extractBoilerplateClassExtends($fooClass, 'plugins')) !== false &&
if (($fooClass = ComponentbuilderHelper::getFileContents(ComponentbuilderHelper::$bolerplatePath . '/plugins/' . $tree->path . '/foo.php')) !== false && ComponentbuilderHelper::checkString($fooClass)) ($classExtendsID = ComponentbuilderHelper::getVar('class_extends', $classExtends, 'name', 'id')) === false)
{ {
// extract the boilerplate class extends and check if already set // load the extends class name
if (($classExtends = ComponentbuilderHelper::extractBoilerplateClassExtends($fooClass, 'plugins')) !== false && $class = array('id' => 0, 'published' => 1, 'version' => 1, 'name' => $classExtends);
($classExtendsID = ComponentbuilderHelper::getVar('class_extends', $classExtends, 'name', 'id')) === false) // extract the boilerplate class header
$class['head'] = ComponentbuilderHelper::extractBoilerplateClassHeader($fooClass, $classExtends, 'plugins');
// extract the boilerplate class comment
$class['comment'] = ComponentbuilderHelper::extractBoilerplateClassComment($fooClass, $classExtends, 'plugins');
// set the extension type
$class['extension_type'] = 'plugins';
// store the class
$this->storePluginBoilerplate($tables['e'], $models['e'], $class, $app);
// work around
$classExtendsID = ComponentbuilderHelper::getVar('class_extends', $classExtends, 'name', 'id');
}
// set plugin group if not already set
if (($pluginGroupID = ComponentbuilderHelper::getVar('joomla_plugin_group', $tree->path, 'name', 'id')) === false)
{
// load the plugin group name
$pluginGroup = array('id' => 0, 'published' => 1, 'version' => 1, 'name' => $tree->path, 'class_extends' => $classExtendsID);
// store the group
$this->storePluginBoilerplate($tables['g'], $models['g'], $pluginGroup, $app);
// work around
$pluginGroupID = ComponentbuilderHelper::getVar('joomla_plugin_group', $tree->path, 'name', 'id');
}
// extract the boilerplate class property and methods
if (($classProperiesMethods = ComponentbuilderHelper::extractBoilerplateClassPropertiesMethods($fooClass, $classExtends, 'plugins', $pluginGroupID)) !== false)
{
// create the properties found
if (isset($classProperiesMethods['property']) && ComponentbuilderHelper::checkArray($classProperiesMethods['property']))
{ {
// load the extends class name foreach ($classProperiesMethods['property'] as $_property)
$class = array('id' => 0, 'published' => 1, 'version' => 1, 'name' => $classExtends);
// extract the boilerplate class header
$class['head'] = ComponentbuilderHelper::extractBoilerplateClassHeader($fooClass, $classExtends, 'plugins');
// extract the boilerplate class comment
$class['comment'] = ComponentbuilderHelper::extractBoilerplateClassComment($fooClass, $classExtends, 'plugins');
// set the extension type
$class['extension_type'] = 'plugins';
// store the class
$this->storePluginBoilerplate($tables['e'], $models['e'], $class, $app);
// work around
$classExtendsID = ComponentbuilderHelper::getVar('class_extends', $classExtends, 'name', 'id');
}
// set plugin group if not already set
if (($pluginGroupID = ComponentbuilderHelper::getVar('joomla_plugin_group', $tree->path, 'name', 'id')) === false)
{
// load the plugin group name
$pluginGroup = array('id' => 0, 'published' => 1, 'version' => 1, 'name' => $tree->path, 'class_extends' => $classExtendsID);
// store the group
$this->storePluginBoilerplate($tables['g'], $models['g'], $pluginGroup, $app);
// work around
$pluginGroupID = ComponentbuilderHelper::getVar('joomla_plugin_group', $tree->path, 'name', 'id');
}
// extract the boilerplate class property and methods
if (($classProperiesMethods = ComponentbuilderHelper::extractBoilerplateClassPropertiesMethods($fooClass, $classExtends, 'plugins', $pluginGroupID)) !== false)
{
// create the properties found
if (isset($classProperiesMethods['property']) && ComponentbuilderHelper::checkArray($classProperiesMethods['property']))
{ {
foreach ($classProperiesMethods['property'] as $_property) // force update by default
{ $this->storePluginBoilerplate($tables['p'], $models['p'], $_property, $app);
// force update by default
$this->storePluginBoilerplate($tables['p'], $models['p'], $_property, $app);
}
} }
// create the method found (TODO just create for now but we could later add a force update) }
if (isset($classProperiesMethods['method']) && ComponentbuilderHelper::checkArray($classProperiesMethods['method'])) // create the method found (TODO just create for now but we could later add a force update)
if (isset($classProperiesMethods['method']) && ComponentbuilderHelper::checkArray($classProperiesMethods['method']))
{
foreach ($classProperiesMethods['method'] as $_method)
{ {
foreach ($classProperiesMethods['method'] as $_method) // force update by default
{ $this->storePluginBoilerplate($tables['m'], $models['m'], $_method, $app);
// force update by default
$this->storePluginBoilerplate($tables['m'], $models['m'], $_method, $app);
}
} }
} }
} }
}, }
$result->tree },
); $plugin_tree
} );
} }
} }
@ -215,6 +205,7 @@ class ComponentbuilderModelJoomla_plugins extends JModelList
return true; return true;
} }
/** /**
* Method to auto-populate the model state. * Method to auto-populate the model state.
* *
@ -273,7 +264,7 @@ class ComponentbuilderModelJoomla_plugins extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -84,7 +84,7 @@ class ComponentbuilderModelJoomla_plugins_files_folders_urls extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -84,7 +84,7 @@ class ComponentbuilderModelJoomla_plugins_updates extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -86,7 +86,7 @@ class ComponentbuilderModelLanguage_translations extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.
@ -318,7 +318,7 @@ class ComponentbuilderModelLanguage_translations extends JModelList
{ {
$items = $db->loadObjectList(); $items = $db->loadObjectList();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)

View File

@ -213,7 +213,7 @@ class ComponentbuilderModelLanguages extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.
@ -356,7 +356,7 @@ class ComponentbuilderModelLanguages extends JModelList
{ {
$items = $db->loadObjectList(); $items = $db->loadObjectList();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)

View File

@ -98,7 +98,7 @@ class ComponentbuilderModelLayouts extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.
@ -289,7 +289,7 @@ class ComponentbuilderModelLayouts extends JModelList
{ {
$items = $db->loadObjectList(); $items = $db->loadObjectList();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)

View File

@ -98,7 +98,7 @@ class ComponentbuilderModelLibraries extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -84,7 +84,7 @@ class ComponentbuilderModelLibraries_config extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -84,7 +84,7 @@ class ComponentbuilderModelLibraries_files_folders_urls extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -90,7 +90,7 @@ class ComponentbuilderModelPlaceholders extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.
@ -235,7 +235,7 @@ class ComponentbuilderModelPlaceholders extends JModelList
{ {
$items = $db->loadObjectList(); $items = $db->loadObjectList();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)

View File

@ -244,7 +244,7 @@ class ComponentbuilderModelServer extends JModelAdmin
{ {
$items = $db->loadObjectList(); $items = $db->loadObjectList();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -90,7 +90,7 @@ class ComponentbuilderModelServers extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.
@ -283,7 +283,7 @@ class ComponentbuilderModelServers extends JModelList
// Get the encryption object. // Get the encryption object.
$basic = new FOFEncryptAes($basickey); $basic = new FOFEncryptAes($basickey);
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)

View File

@ -110,7 +110,7 @@ class ComponentbuilderModelSite_views extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.
@ -321,7 +321,7 @@ class ComponentbuilderModelSite_views extends JModelList
{ {
$items = $db->loadObjectList(); $items = $db->loadObjectList();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)

View File

@ -90,7 +90,7 @@ class ComponentbuilderModelSnippet_types extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.

View File

@ -216,7 +216,7 @@ class ComponentbuilderModelSnippets extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.
@ -377,7 +377,7 @@ class ComponentbuilderModelSnippets extends JModelList
{ {
$items = $db->loadObjectList(); $items = $db->loadObjectList();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)

View File

@ -98,7 +98,7 @@ class ComponentbuilderModelTemplates extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.
@ -289,7 +289,7 @@ class ComponentbuilderModelTemplates extends JModelList
{ {
$items = $db->loadObjectList(); $items = $db->loadObjectList();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)

View File

@ -90,7 +90,7 @@ class ComponentbuilderModelValidation_rules extends JModelList
// load parent items // load parent items
$items = parent::getItems(); $items = parent::getItems();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
// Get the user object if not set. // Get the user object if not set.
@ -233,7 +233,7 @@ class ComponentbuilderModelValidation_rules extends JModelList
{ {
$items = $db->loadObjectList(); $items = $db->loadObjectList();
// set values to display correctly. // Set values to display correctly.
if (ComponentbuilderHelper::checkArray($items)) if (ComponentbuilderHelper::checkArray($items))
{ {
foreach ($items as $nr => &$item) foreach ($items as $nr => &$item)

View File

@ -18,7 +18,7 @@ JHtml::_('script', 'system/core.js', false, true);
JHtml::_('behavior.keepalive'); JHtml::_('behavior.keepalive');
?> ?>
<script type="text/javascript"> <script type="text/javascript">
<?php if ($this->hasPackage && $this->dataType === 'smart_package'): ?> <?php if (isset($this->hasPackage) && $this->hasPackage && $this->dataType === 'smart_package'): ?>
Joomla.continueExtImport = function() Joomla.continueExtImport = function()
{ {
var form = document.getElementById('adminForm'); var form = document.getElementById('adminForm');
@ -168,7 +168,7 @@ jQuery(document).ready(function($) {
<div style="text-align:right;"><small><a href="https://github.com/Llewellynvdm" target="_blank" style="color:gray">&lt;&lt;ewe&gt;&gt;yn</a></small></div> <div style="text-align:right;"><small><a href="https://github.com/Llewellynvdm" target="_blank" style="color:gray">&lt;&lt;ewe&gt;&gt;yn</a></small></div>
</div> </div>
<div id="installer-import"> <div id="installer-import">
<?php if ($this->hasPackage && $this->dataType === 'smart_package') : ?> <?php if (isset($this->hasPackage) && $this->hasPackage && $this->dataType === 'smart_package') : ?>
<?php <?php
if (isset($this->packageInfo['name']) && ComponentbuilderHelper::checkArray($this->packageInfo['name'])) if (isset($this->packageInfo['name']) && ComponentbuilderHelper::checkArray($this->packageInfo['name']))
{ {
@ -277,7 +277,7 @@ jQuery(document).ready(function($) {
</fieldset> </fieldset>
<?php echo JHtml::_('bootstrap.endTab'); ?> <?php echo JHtml::_('bootstrap.endTab'); ?>
<?php if ($this->vdmPackages && ComponentbuilderHelper::checkArray($this->vdmPackages)): ?> <?php if (isset($this->vdmPackages) && ComponentbuilderHelper::checkArray($this->vdmPackages)): ?>
<?php echo JHtml::_('bootstrap.addTab', 'jcbImportTab', 'url_vdm', JText::_('COM_COMPONENTBUILDER_VDM_PACKAGES', true)); ?> <?php echo JHtml::_('bootstrap.addTab', 'jcbImportTab', 'url_vdm', JText::_('COM_COMPONENTBUILDER_VDM_PACKAGES', true)); ?>
<div class="span12" id="vdm_packages_installer"> <div class="span12" id="vdm_packages_installer">
<div class="alert alert-success"> <div class="alert alert-success">
@ -308,7 +308,7 @@ jQuery(document).ready(function($) {
<?php echo JHtml::_('bootstrap.endTab'); ?> <?php echo JHtml::_('bootstrap.endTab'); ?>
<?php endif; ?> <?php endif; ?>
<?php if ($this->jcbPackages && ComponentbuilderHelper::checkArray($this->jcbPackages)) : ?> <?php if (isset($this->jcbPackages) && ComponentbuilderHelper::checkArray($this->jcbPackages)) : ?>
<?php echo JHtml::_('bootstrap.addTab', 'jcbImportTab', 'url_jcb', JText::_('COM_COMPONENTBUILDER_JCB_COMMUNITY_PACKAGES', true)); ?> <?php echo JHtml::_('bootstrap.addTab', 'jcbImportTab', 'url_jcb', JText::_('COM_COMPONENTBUILDER_JCB_COMMUNITY_PACKAGES', true)); ?>
<div class="span12" id="jcb_packages_installer"> <div class="span12" id="jcb_packages_installer">
<div class="alert alert-success"> <div class="alert alert-success">
@ -349,12 +349,12 @@ jQuery(document).ready(function($) {
</form> </form>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
<?php if (($this->vdmPackages && ComponentbuilderHelper::checkArray($this->vdmPackages)) || ($this->jcbPackages && ComponentbuilderHelper::checkArray($this->jcbPackages))): ?> <?php if ((isset($this->vdmPackages) && $this->vdmPackages && ComponentbuilderHelper::checkArray($this->vdmPackages)) || (isset($this->jcbPackages) && $this->jcbPackages && ComponentbuilderHelper::checkArray($this->jcbPackages))): ?>
// set packages that are on the page // set packages that are on the page
var packages = {}; var packages = {};
jQuery(document).ready(function($) jQuery(document).ready(function($)
{ {
<?php if ($this->jcbPackages && ComponentbuilderHelper::checkArray($this->jcbPackages)): ?> <?php if (isset($this->jcbPackages) && $this->jcbPackages && ComponentbuilderHelper::checkArray($this->jcbPackages)): ?>
// get all jcb packages // get all jcb packages
jQuery("#jcb_package option").each(function() jQuery("#jcb_package option").each(function()
{ {
@ -362,7 +362,7 @@ jQuery(document).ready(function($)
packages[key] = 'jcb'; packages[key] = 'jcb';
}); });
<?php endif; ?> <?php endif; ?>
<?php if ($this->vdmPackages && ComponentbuilderHelper::checkArray($this->vdmPackages)): ?> <?php if (isset($this->vdmPackages) && $this->vdmPackages && ComponentbuilderHelper::checkArray($this->vdmPackages)): ?>
// get all vdm packages // get all vdm packages
jQuery("#vdm_package option").each(function() jQuery("#vdm_package option").each(function()
{ {

View File

@ -310,7 +310,7 @@ class ComponentbuilderViewImport_joomla_components extends JViewLegacy
$form[] = $sleutle; $form[] = $sleutle;
} }
} }
elseif ('vdm_package' === $type && in_array('vdm', $this->directories) && $vdmListObjects = ComponentbuilderHelper::getGithubRepoFileList('vdmGithubPackages', ComponentbuilderHelper::$vdmGithubPackagesUrl.ComponentbuilderHelper::$accessToken)) elseif ('vdm_package' === $type && in_array('vdm', $this->directories) && $vdmListObjects = ComponentbuilderHelper::getGithubRepoFileList('vdmGithubPackages', ComponentbuilderHelper::$vdmGithubPackagesUrl))
{ {
if (ComponentbuilderHelper::checkArray($vdmListObjects)) if (ComponentbuilderHelper::checkArray($vdmListObjects))
{ {
@ -354,7 +354,7 @@ class ComponentbuilderViewImport_joomla_components extends JViewLegacy
} }
} }
} }
elseif ('jcb_package' === $type && in_array('jcb', $this->directories) && $jcbListObjects = ComponentbuilderHelper::getGithubRepoFileList('communityGithubPackages', ComponentbuilderHelper::$jcbGithubPackagesUrl.ComponentbuilderHelper::$accessToken)) elseif ('jcb_package' === $type && in_array('jcb', $this->directories) && $jcbListObjects = ComponentbuilderHelper::getGithubRepoFileList('communityGithubPackages', ComponentbuilderHelper::$jcbGithubPackagesUrl))
{ {
if (ComponentbuilderHelper::checkArray($jcbListObjects)) if (ComponentbuilderHelper::checkArray($jcbListObjects))
{ {

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.2" method="upgrade"> <extension type="component" version="3.2" method="upgrade">
<name>COM_COMPONENTBUILDER</name> <name>COM_COMPONENTBUILDER</name>
<creationDate>5th September, 2019</creationDate> <creationDate>10th September, 2019</creationDate>
<author>Llewellyn van der Merwe</author> <author>Llewellyn van der Merwe</author>
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail> <authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl> <authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>

View File

@ -5630,7 +5630,7 @@ class com_componentbuilderInstallerScript
$admin_view_action_log_config->type_title = 'ADMIN_VIEW'; $admin_view_action_log_config->type_title = 'ADMIN_VIEW';
$admin_view_action_log_config->type_alias = 'com_componentbuilder.admin_view'; $admin_view_action_log_config->type_alias = 'com_componentbuilder.admin_view';
$admin_view_action_log_config->id_holder = 'id'; $admin_view_action_log_config->id_holder = 'id';
$admin_view_action_log_config->title_holder = ''; $admin_view_action_log_config->title_holder = 'system_name';
$admin_view_action_log_config->table_name = '#__componentbuilder_admin_view'; $admin_view_action_log_config->table_name = '#__componentbuilder_admin_view';
$admin_view_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; $admin_view_action_log_config->text_prefix = 'COM_COMPONENTBUILDER';
@ -7721,7 +7721,7 @@ class com_componentbuilderInstallerScript
$admin_view_action_log_config->type_title = 'ADMIN_VIEW'; $admin_view_action_log_config->type_title = 'ADMIN_VIEW';
$admin_view_action_log_config->type_alias = 'com_componentbuilder.admin_view'; $admin_view_action_log_config->type_alias = 'com_componentbuilder.admin_view';
$admin_view_action_log_config->id_holder = 'id'; $admin_view_action_log_config->id_holder = 'id';
$admin_view_action_log_config->title_holder = ''; $admin_view_action_log_config->title_holder = 'system_name';
$admin_view_action_log_config->table_name = '#__componentbuilder_admin_view'; $admin_view_action_log_config->table_name = '#__componentbuilder_admin_view';
$admin_view_action_log_config->text_prefix = 'COM_COMPONENTBUILDER'; $admin_view_action_log_config->text_prefix = 'COM_COMPONENTBUILDER';

View File

@ -12,6 +12,8 @@
// No direct access to this file // No direct access to this file
defined('_JEXEC') or die('Restricted access'); defined('_JEXEC') or die('Restricted access');
use Joomla\Utilities\ArrayHelper;
/** /**
* Componentbuilder component helper * Componentbuilder component helper
*/ */
@ -61,14 +63,14 @@ abstract class ComponentbuilderHelper
/** /**
* The VDM packages paths * 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 $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 * 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 $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 * The bolerplate paths
@ -76,9 +78,6 @@ abstract class ComponentbuilderHelper
public static $bolerplatePath = 'https://raw.githubusercontent.com/vdm-io/boilerplate/jcb/'; 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'; 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 * The array of constant paths
* *
@ -2413,66 +2412,163 @@ abstract class ComponentbuilderHelper
/** /**
* get the github repo file list * The github access token
* **/
* @return array on success 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) public static function getGithubRepoFileList($type, $target)
{ {
// get the current Packages (public) // get the repo data
if (!$repoData = self::get($type)) if (($repoData = self::getGithubRepoData($type, $target, 'tree')) !== false)
{ {
if (self::urlExists($target)) return $repoData->tree;
{
$repoData = self::getFileContents($target);
if (self::checkJson($repoData))
{
$test = json_decode($repoData);
if (self::checkObject($test) && isset($test->tree) && self::checkArray($test->tree) )
{
// remember to set it
self::set($type, $repoData);
}
// check if we have error message from github
elseif ($errorMessage = self::githubErrorHandeler(array('error' => null), $test))
{
if (self::checkString($errorMessage['error']))
{
JFactory::getApplication()->enqueueMessage($errorMessage['error'], 'Error');
}
$repoData = false;
}
}
else
{
$repoData = false;
}
}
else
{
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_EXIST', $target), 'Error');
}
}
// 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) )
{
return $repoData->tree;
}
} }
return false; return false;
} }
/** /**
* get the github error messages * get the github repo file list
* *
* @return array of errors on success * @return array on success
* *
*/ */
protected static function githubErrorHandeler($message, &$github) 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 ('nomemory' === $type || !$repoData = self::get($type))
{
// add the token if not already added
$_url = self::setGithubToken($url);
// check if the url exist
if (self::urlExists($_url))
{
// get the data from github
if (($repoData = self::getFileContents($_url)) !== false && self::checkJson($repoData))
{
$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))
{
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), $github_returned, $type)) !== false)
{
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'];
}
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
{
// 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
{
// 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))
{
if ('object' === $return_type)
{
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, $type)
{ {
if (self::checkObject($github) && isset($github->message) && self::checkString($github->message)) if (self::checkObject($github) && isset($github->message) && self::checkString($github->message))
{ {
@ -2481,13 +2577,17 @@ abstract class ComponentbuilderHelper
// add the documentation URL // add the documentation URL
if (isset($github->documentation_url) && self::checkString($github->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 // check the message
if (strpos($errorMessage, 'Authenticated') !== false) if (strpos($errorMessage, 'Authenticated') !== false)
{ {
if ('nomemory' === $type)
{
$type = 'data';
}
// add little more help if it is an access token issue // 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 // set error notice
$message['error'] = $errorMessage; $message['error'] = $errorMessage;
@ -2497,6 +2597,36 @@ abstract class ComponentbuilderHelper
return false; 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 * get Dynamic Scripts

View File

@ -62,7 +62,7 @@ COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS_NOT_FOUND="Package owner details not
COM_COMPONENTBUILDER_PACKAGE_OWNER_NOT_SET="Package Owner Not Set" COM_COMPONENTBUILDER_PACKAGE_OWNER_NOT_SET="Package Owner Not Set"
COM_COMPONENTBUILDER_PAIDLOCKED="Paid/Locked" COM_COMPONENTBUILDER_PAIDLOCKED="Paid/Locked"
COM_COMPONENTBUILDER_PROPERTY="Property" COM_COMPONENTBUILDER_PROPERTY="Property"
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="%s<br />You can add an <b>access token<b/> to getBible global options to make authenticated requests. An access token with only public access will do." 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="%s<br />You can add a <b>gitHub Access Token</b> to Componentbuilder global options to make authenticated requests to gitHub. An access token with only public access will do to retrieve %s."
COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_BIMPORT_PROCESSB_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_BDOES_NOTB_HAVE_THE_KEY_THEY_CAN_SEE_BWHERE_TO_GET_ITB="Since the owner details are displayed during <b>import process</b> before adding the key, this way if the user/dev <b>does not</b> have the key they can see <b>where to get it</b>." COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_BIMPORT_PROCESSB_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_BDOES_NOTB_HAVE_THE_KEY_THEY_CAN_SEE_BWHERE_TO_GET_ITB="Since the owner details are displayed during <b>import process</b> before adding the key, this way if the user/dev <b>does not</b> have the key they can see <b>where to get it</b>."
COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_IMPORT_PROCESS_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_DOES_NOT_HAVE_THE_KEY_THEY_CAN_SEE_WHERE_TO_GET_IT="Since the owner details are displayed during import process before adding the key, this way if the user/dev does not have the key they can see where to get it." COM_COMPONENTBUILDER_SINCE_THE_OWNER_DETAILS_ARE_DISPLAYED_DURING_IMPORT_PROCESS_BEFORE_ADDING_THE_KEY_THIS_WAY_IF_THE_USERDEV_DOES_NOT_HAVE_THE_KEY_THEY_CAN_SEE_WHERE_TO_GET_IT="Since the owner details are displayed during import process before adding the key, this way if the user/dev does not have the key they can see where to get it."
COM_COMPONENTBUILDER_SORRY_THIS_PLACEHOLDER_IS_ALREADY_IN_USE="Sorry this placeholder is already in use!" COM_COMPONENTBUILDER_SORRY_THIS_PLACEHOLDER_IS_ALREADY_IN_USE="Sorry this placeholder is already in use!"
@ -86,7 +86,10 @@ COM_COMPONENTBUILDER_THE_S_WAS_NOT_INSTALLED_BY_YOUR_REQUEST_AND_IS_ALSO_REMOVED
COM_COMPONENTBUILDER_THE_S_WAS_NOT_INSTALLED_BY_YOUR_REQUEST_AND_IS_STILL_IN_THE_TEMP_FOLDER="The %s was not Installed by your request and is still in the temp folder." COM_COMPONENTBUILDER_THE_S_WAS_NOT_INSTALLED_BY_YOUR_REQUEST_AND_IS_STILL_IN_THE_TEMP_FOLDER="The %s was not Installed by your request and is still in the temp folder."
COM_COMPONENTBUILDER_THE_S_WAS_SUCCESSFULLY_COMPILED="The %s was successfully compiled." COM_COMPONENTBUILDER_THE_S_WAS_SUCCESSFULLY_COMPILED="The %s was successfully compiled."
COM_COMPONENTBUILDER_THE_S_WAS_SUCCESSFULLY_INSTALLED_AND_REMOVED_FROM_TEMP_FOLDER="The %s was successfully Installed and removed from temp folder." COM_COMPONENTBUILDER_THE_S_WAS_SUCCESSFULLY_INSTALLED_AND_REMOVED_FROM_TEMP_FOLDER="The %s was successfully Installed and removed from temp folder."
COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DID_NOT_RETURN_S_DATA="The url (%s) set to retrieve the packages did not return %s data!"
COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DID_NOT_RETURN_VALID_DATA="The url (%s) set to retrieve the packages did not return valid data!"
COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_EXIST="The url (%s) set to retrieve the packages does not exist!" COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_EXIST="The url (%s) set to retrieve the packages does not exist!"
COM_COMPONENTBUILDER_THE_URL_S_SET_TO_RETRIEVE_THE_PACKAGES_DOES_NOT_RETURN_ANY_DATA="The url (%s) set to retrieve the packages does not return any data!"
COM_COMPONENTBUILDER_THIS_PACKAGE_HAS_NO_KEY="This package has no key." COM_COMPONENTBUILDER_THIS_PACKAGE_HAS_NO_KEY="This package has no key."
COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_BJCB_GLOBAL_OPTIONSB_GO_TO_THE_BCOMPANYB_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE="To change the package owner defaults. Open the <b>JCB Global Options</b>, go to the <b>Company</b> tab and add the correct company details there." COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_BJCB_GLOBAL_OPTIONSB_GO_TO_THE_BCOMPANYB_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE="To change the package owner defaults. Open the <b>JCB Global Options</b>, go to the <b>Company</b> tab and add the correct company details there."
COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_JCB_GLOBAL_OPTIONS_GO_TO_THE_COMPANY_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE="To change the package owner defaults. Open the JCB Global Options, go to the Company tab and add the correct company details there." COM_COMPONENTBUILDER_TO_CHANGE_THE_PACKAGE_OWNER_DEFAULTS_OPEN_THE_JCB_GLOBAL_OPTIONS_GO_TO_THE_COMPANY_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE="To change the package owner defaults. Open the JCB Global Options, go to the Company tab and add the correct company details there."