Added the community JCB package import option. Improved the jsonToString method to be more dynamic

This commit is contained in:
Llewellyn van der Merwe 2018-05-02 00:17:38 +02:00
parent 8b4efd640f
commit 88dbcee380
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
15 changed files with 702 additions and 137 deletions

View File

@ -126,11 +126,11 @@ Component Builder is mapped as a component in itself on my local development env
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](http://joomlacomponentbuilder.com)
+ *First Build*: 30th April, 2015
+ *Last Build*: 30th April, 2018
+ *Last Build*: 1st May, 2018
+ *Version*: 2.7.6
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+ *Line count*: **193305**
+ *Line count*: **193870**
+ *Field count*: **1027**
+ *File count*: **1201**
+ *Folder count*: **193**

View File

@ -126,11 +126,11 @@ Component Builder is mapped as a component in itself on my local development env
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](http://joomlacomponentbuilder.com)
+ *First Build*: 30th April, 2015
+ *Last Build*: 30th April, 2018
+ *Last Build*: 1st May, 2018
+ *Version*: 2.7.6
+ *Copyright*: Copyright (C) 2015. All Rights Reserved
+ *License*: GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
+ *Line count*: **193305**
+ *Line count*: **193870**
+ *Field count*: **1027**
+ *File count*: **1201**
+ *Folder count*: **193**

View File

@ -225,7 +225,7 @@ abstract class ###Component###Helper
return false;
}
public static function jsonToString($value, $sperator = ", ", $table = null)
public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name')
{
// check if string is JSON
$result = json_decode($value, true);
@ -239,7 +239,7 @@ abstract class ###Component###Helper
$names = array();
foreach ($result as $val)
{
if ($name = self::getVar($table, $val, 'id', 'name'))
if ($name = self::getVar($table, $val, $id, $name))
{
$names[] = $name;
}

View File

@ -35,7 +35,7 @@ defined('_JEXEC') or die('Restricted access');
abstract class ###Component###Helper
{###SITE_GLOBAL_EVENT_HELPER### ###SITE_CUSTOM_HELPER_SCRIPT### ###BOTH_CUSTOM_HELPER_SCRIPT###
public static function jsonToString($value, $sperator = ", ", $table = null)
public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name')
{
// check if string is JSON
$result = json_decode($value, true);
@ -49,7 +49,7 @@ abstract class ###Component###Helper
$names = array();
foreach ($result as $val)
{
if ($name = self::getVar($table, $val, 'id', 'name'))
if ($name = self::getVar($table, $val, $id, $name))
{
$names[] = $name;
}

View File

@ -46,6 +46,7 @@ class ComponentbuilderControllerAjax extends JControllerLegacy
$this->registerTask('isRead', 'ajax');
$this->registerTask('getComponentDetails', 'ajax');
$this->registerTask('getCronPath', 'ajax');
$this->registerTask('getJCBpackageInfo', 'ajax');
$this->registerTask('tableColumns', 'ajax');
$this->registerTask('fieldSelectOptions', 'ajax');
$this->registerTask('getDynamicScripts', 'ajax');
@ -235,6 +236,44 @@ class ComponentbuilderControllerAjax extends JControllerLegacy
}
}
break;
case 'getJCBpackageInfo':
try
{
$returnRaw = $jinput->get('raw', false, 'BOOLEAN');
$urlValue = $jinput->get('url', NULL, 'STRING');
if($urlValue && $user->id != 0)
{
$result = $this->getModel('ajax')->getJCBpackageInfo($urlValue);
}
else
{
$result = false;
}
if($callback = $jinput->get('callback', null, 'CMD'))
{
echo $callback . "(".json_encode($result).");";
}
elseif($returnRaw)
{
echo json_encode($result);
}
else
{
echo "(".json_encode($result).");";
}
}
catch(Exception $e)
{
if($callback = $jinput->get('callback', null, 'CMD'))
{
echo $callback."(".json_encode($e).");";
}
else
{
echo "(".json_encode($e).");";
}
}
break;
case 'tableColumns':
try
{

View File

@ -11851,7 +11851,7 @@ class Interpretation extends Fields
if (isset($item['custom']['table']))
{
$keyTableNAme = str_replace('#__' . $this->fileContentStatic['###component###'] . '_', '', $item['custom']['table']);
$fix .= PHP_EOL . "\t" . $tab . "\t\t\t\$item->" . $item['name'] . " = " . $Component . "Helper::jsonToString(\$item->" . $item['name'] . ", ', ', '" . $keyTableNAme . "');";
$fix .= PHP_EOL . "\t" . $tab . "\t\t\t\$item->" . $item['name'] . " = " . $Component . "Helper::jsonToString(\$item->" . $item['name'] . ", ', ', '" . $keyTableNAme . "', '".$item['custom']['id']."', '".$item['custom']['text']."');";
}
else
{

View File

@ -68,10 +68,16 @@ abstract class ComponentbuilderHelper
public static $snippetsPath = 'https://api.github.com/repos/vdm-io/Joomla-Component-Builder-Snippets/git/trees/master';
/**
* The packages paths
* The VDM packages paths
**/
public static $jcbGithubPackagesUrl = "https://api.github.com/repos/vdm-io/JCB-Packages/git/trees/master";
public static $jcbGithubPackageUrl = "https://github.com/vdm-io/JCB-Packages/raw/master/";
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/";
/**
* 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/";
// not needed at this time (maybe latter)
public static $accessToken = "";
@ -2036,6 +2042,138 @@ abstract class ComponentbuilderHelper
return false;
}
/**
* get the JCB package owner details display
**/
public static function getPackageOwnerDetailsDisplay(&$info, $trust = false)
{
$ownerDetails = '<h2 class="module-title nav-header">' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS') . '</h2>';
$ownerDetails .= '<ul>';
if (isset($info['getKeyFrom']['company']) && self::checkString($info['getKeyFrom']['company']))
{
$owner = $info['getKeyFrom']['company'];
$ownerDetails .= '<li>' . JText::sprintf('COM_COMPONENTBUILDER_EMCOMPANYEM_BSB', $info['getKeyFrom']['company']) . '</li>';
}
// add value only if set
if (isset($info['getKeyFrom']['owner']) && self::checkString($info['getKeyFrom']['owner']))
{
if (!isset($owner))
{
$owner = $info['getKeyFrom']['owner'];
}
$ownerDetails .= '<li>' . JText::sprintf('COM_COMPONENTBUILDER_EMOWNEREM_BSB', $info['getKeyFrom']['owner']) . '</li>';
}
// add value only if set
if (isset($info['getKeyFrom']['website']) && self::checkString($info['getKeyFrom']['website']))
{
$ownerDetails .= '<li>' . JText::sprintf('COM_COMPONENTBUILDER_EMWEBSITEEM_BSB', $info['getKeyFrom']['website']) . '</li>';
}
// add value only if set
if (isset($info['getKeyFrom']['email']) && self::checkString($info['getKeyFrom']['email']))
{
$ownerDetails .= '<li>' . JText::sprintf('COM_COMPONENTBUILDER_EMEMAILEM_BSB', $info['getKeyFrom']['email']) . '</li>';
}
// add value only if set
if (isset($info['getKeyFrom']['license']) && self::checkString($info['getKeyFrom']['license']))
{
$ownerDetails .= '<li>' . JText::sprintf('COM_COMPONENTBUILDER_EMLICENSEEM_BSB', $info['getKeyFrom']['license']) . '</li>';
}
// add value only if set
if (isset($info['getKeyFrom']['copyright']) && self::checkString($info['getKeyFrom']['copyright']))
{
$ownerDetails .= '<li>' . JText::sprintf('COM_COMPONENTBUILDER_EMCOPYRIGHTEM_BSB', $info['getKeyFrom']['copyright']) . '</li>';
}
$ownerDetails .= '</ul>';
// provide some details to how the user can get a key
if (isset($info['getKeyFrom']['buy_link']) && self::checkString($info['getKeyFrom']['buy_link']))
{
$ownerDetails .= '<hr />';
$ownerDetails .= JText::sprintf('COM_COMPONENTBUILDER_BGET_THE_KEY_FROMB_A_CLASSBTN_BTNPRIMARY_HREFS_TARGET_BLANK_TITLEGET_A_KEY_FROM_SSA', $info['getKeyFrom']['buy_link'], $owner, $owner);
}
// add more custom links
elseif (isset($info['getKeyFrom']['buy_links']) && self::checkArray($info['getKeyFrom']['buy_links']))
{
$buttons = array();
foreach ($info['getKeyFrom']['buy_links'] as $keyName => $link)
{
$buttons[] = JText::sprintf('COM_COMPONENTBUILDER_GET_THE_KEY_FROM_BSB_FOR_A_CLASSBTN_BTNPRIMARY_HREFS_TARGET_BLANK_TITLEGET_A_KEY_FROM_SSA', $owner, $link, $owner, $keyName);
}
$ownerDetails .= '<hr />';
$ownerDetails .= implode('<br />', $buttons);
}
// return the owner details
if (!isset($owner) && !$trust)
{
$ownerDetails = '<h2 style="color: #922924;">' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS_NOT_FOUND') . '</h2>';
$ownerDetails .= '<p style="color: #922924;">' . JText::_('COM_COMPONENTBUILDER_BE_CAUTIOUS_DO_NOT_CONTINUE_UNLESS_YOU_TRUST_THE_ORIGIN_OF_THIS_PACKAGE') . '</p>';
}
elseif (!isset($owner) && $trust)
{
$ownerDetails = '';
}
return $ownerDetails;
}
/**
* get the JCB package component details display
**/
public static function getPackageComponentsDetailsDisplay(&$info)
{
if (isset($info['name']) && self::checkArray($info['name']))
{
$cAmount = count((array) $info['name']);
$class2 = ($cAmount == 1) ? 'span12' : 'span6';
$counter = 1;
$display = array();
foreach ($info['name'] as $key => $value)
{
if ($cAmount > 1 && $counter == 3)
{
$display[] = '</div>';
$counter = 1;
}
if ($cAmount > 1 && $counter == 1)
{
$display[] = '<div>';
}
$display[] = '<div class="well well-small ' . $class2 . '">';
$display[] = '<h2 class="module-title nav-header">';
$display[] = JText::sprintf('COM_COMPONENTBUILDER_BSB_EMCOMPONENT_DETAILSEM', $value . ' v' . $info['component_version'][$key]);
$display[] = '</h2><p>';
$display[] = $info['short_description'][$key];
$display[] = '</p><ul><li>';
$display[] = JText::sprintf('COM_COMPONENTBUILDER_EMCOMPANY_NAMEEM_BSB', $info['companyname'][$key]);
$display[] = '</li><li>';
$display[] = JText::sprintf('COM_COMPONENTBUILDER_EMAUTHOREM_BSB', $info['author'][$key]);
$display[] = '</li><li>';
$display[] = JText::sprintf('COM_COMPONENTBUILDER_EMEMAILEM_BSB', $info['email'][$key]);
$display[] = '</li><li>';
$display[] = JText::sprintf('COM_COMPONENTBUILDER_EMWEBSITEEM_BSB', $info['website'][$key]);
$display[] = '</li></ul>';
$display[] = '<h2 class="nav-header">';
$display[] = JText::_('COM_COMPONENTBUILDER_LICENSE');
$display[] = '</h2><p>';
$display[] = $info['license'][$key];
$display[] = '</p><h2 class="nav-header">';
$display[] = JText::_('COM_COMPONENTBUILDER_COPYRIGHT');
$display[] = '</h2><p>';
$display[] = $info['copyright'][$key];
$display[] = '</p></div>';
$counter++;
}
// close the div if needed
if ($cAmount > 1)
{
$display[] = '</div>';
}
return implode("\n",$display);
}
return '<div>'.JText::_('COM_COMPONENTBUILDER_COPYRIGHT').'</div>';
}
/**
* prepare base64 string for url
**/
@ -3985,7 +4123,7 @@ abstract class ComponentbuilderHelper
return false;
}
public static function jsonToString($value, $sperator = ", ", $table = null)
public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name')
{
// check if string is JSON
$result = json_decode($value, true);
@ -3999,7 +4137,7 @@ abstract class ComponentbuilderHelper
$names = array();
foreach ($result as $val)
{
if ($name = self::getVar($table, $val, 'id', 'name'))
if ($name = self::getVar($table, $val, $id, $name))
{
$names[] = $name;
}

View File

@ -957,6 +957,7 @@ COM_COMPONENTBUILDER_CLEAR_TMP="Clear tmp"
COM_COMPONENTBUILDER_CLONE="Clone"
COM_COMPONENTBUILDER_CLONE_FAILED="Clone failed!"
COM_COMPONENTBUILDER_CLOSE_NEW="Close & New"
COM_COMPONENTBUILDER_COMMUNITY_PACKAGES="Community Packages"
COM_COMPONENTBUILDER_COMPANY="Company"
COM_COMPONENTBUILDER_COMPANY_NAME="Company Name"
COM_COMPONENTBUILDER_COMPANY_S="Company: %s"
@ -4184,8 +4185,8 @@ COM_COMPONENTBUILDER_HELP_MANAGER="Help"
COM_COMPONENTBUILDER_HI="Hi"
COM_COMPONENTBUILDER_HIDE="Hide"
COM_COMPONENTBUILDER_HTWOCURL_NOT_FOUNDHTWOPPLEASE_SETUP_CURL_ON_YOUR_SYSTEM_OR_BCOMPONENTBUILDERB_WILL_NOT_FUNCTION_CORRECTLYP="<h2>Curl Not Found!</h2><p>Please setup curl on your system, or <b>componentbuilder</b> will not function correctly!</p>"
COM_COMPONENTBUILDER_HTWODATA_IS_CORRUPTHTWOTHIS_COULD_BE_DUE_TO_BKEY_ERRORB_OR_BROKEN_PACKAGE="<h2>Data is corrupt!</h2>This could be due to <b>key error</b>, or broken package!"
COM_COMPONENTBUILDER_HTWODATA_IS_CORRUPTHTWOTHIS_COULD_BE_DUE_TO_BROKEN_PACKAGE="<h2>Data is corrupt!</h2>This could be due to broken package!"
COM_COMPONENTBUILDER_HTWODATA_IS_CORRUPTHTWOTHIS_COULD_BE_DUE_TO_KEY_ERROR_OR_BROKEN_PACKAGE="<h2>Data is corrupt!</h2>This could be due to key error, or broken package!"
COM_COMPONENTBUILDER_ICON="Icon"
COM_COMPONENTBUILDER_IMPORT_CONTINUE="Continue"
COM_COMPONENTBUILDER_IMPORT_DATA="Import Data"
@ -4247,7 +4248,9 @@ COM_COMPONENTBUILDER_ISSUE="issue"
COM_COMPONENTBUILDER_IS_NOT_ONLY_FOUR_LISTRADIOCHECKBOXES="Is Not (only 4 list/radio/checkboxes)"
COM_COMPONENTBUILDER_IS_ONLY_FOUR_LISTRADIOCHECKBOXES="Is (only 4 list/radio/checkboxes)"
COM_COMPONENTBUILDER_JCB_COMMUNITY="JCB Community"
COM_COMPONENTBUILDER_JCB_COMMUNITY_PACKAGES="JCB Community Packages"
COM_COMPONENTBUILDER_JCB_COMMUNITY_SNIPPETS="JCB Community Snippets"
COM_COMPONENTBUILDER_JCB_PACKAGE_INFO_PATH_DOES_NOT_WORK_WE_ADVICE_YOU_BNOT_TO_CONTINUEB_WITH_THE_IMPORT_OF_THE_SELECTED_PACKAGE="JCB Package info path does not work, we advice you <b>not to continue</b> with the import of the selected package!"
COM_COMPONENTBUILDER_JOOMLA_COMPONENT="Joomla Component"
COM_COMPONENTBUILDER_JOOMLA_COMPONENTS="Joomla Components"
COM_COMPONENTBUILDER_JOOMLA_COMPONENTS_ACCESS="Joomla Components Access"
@ -5437,6 +5440,7 @@ COM_COMPONENTBUILDER_OUT_OF_DATE="Out of Date"
COM_COMPONENTBUILDER_OWNER_DETAILS_WAS_SET="Owner details was set"
COM_COMPONENTBUILDER_OWNER_S="Owner: %s"
COM_COMPONENTBUILDER_PACKAGE="Package"
COM_COMPONENTBUILDER_PACKAGES_FROM_JCB_COMMUNITY="Packages from JCB Community"
COM_COMPONENTBUILDER_PACKAGES_FROM_VAST_DEVELOPMENT_METHOD="Packages from Vast Development Method"
COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS="Package Owner Details"
COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS_NOT_FOUND="Package owner details not found!"
@ -6462,6 +6466,7 @@ COM_COMPONENTBUILDER_THERE_ARE_NO_SNIPPETS_TO_UPDATE_AT_THIS_TIME="There are no
COM_COMPONENTBUILDER_THERE_HAS_BEEN_AN_ERROR_IF_THIS_CONTINUES_PLEASE_INFORM_YOUR_SYSTEM_ADMINISTRATOR_OF_A_TYPE_ERROR_IN_THE_FIELDS_DISPLAY_REQUEST="There has been an error, if this continues please inform your system administrator of a type error in the fields display request!"
COM_COMPONENTBUILDER_THERE_WAS_AN_ERROR_GETTING_THE_PACKAGE_INFO="There was an error getting the package info."
COM_COMPONENTBUILDER_THERE_WAS_A_PROBLEM_BNO_VIEW_OR_ID_FOUND_IN_SESSION_OR_VIEW_NOT_ALLOWED_TO_ACCESS_AREAB_WE_COULD_NOT_LOAD_ANY_LINKED_TO_VALUES_PLEASE_INFORM_YOUR_SYSTEM_ADMINISTRATOR="There was a problem, <b>no view or id found in session or view not allowed to access area</b>, we could not load any linked to values. Please inform your system administrator!"
COM_COMPONENTBUILDER_THESE_ARE_THE_SAME_PACKAGES_FOUND_ON_A_S_GITHUBA_AND_CAN_BE_IMPORTED_BY_SIMPLY_MAKING_A_SELECTION_AND_THEN_CLICKING_THE_GET_PACKAGE_BUTTONBR_SOME_OF_THESE_PACKAGES_WOULD_REQUIRE_A_KEY_SINCE_THEY_ARE_NOT_FREE="These are the same packages found on <a %s >gitHub</a> and can be imported by simply making a selection and then clicking the [Get Package] button.<br />Some of these packages would require a key, since they are not free."
COM_COMPONENTBUILDER_THESE_ARE_THE_SAME_PACKAGES_FOUND_ON_A_S_GITHUBA_AND_CAN_BE_IMPORTED_BY_SIMPLY_MAKING_A_SELECTION_AND_THEN_CLICKING_THE_GET_PACKAGE_BUTTONBR_SOME_OF_THESE_PACKAGES_WOULD_REQUIRE_A_KEY_SINCE_THEY_ARE_NOT_FREE_A_S_GET_A_KEY_TODAYA="These are the same packages found on <a %s >gitHub</a> and can be imported by simply making a selection and then clicking the [Get Package] button.<br />Some of these packages would require a key, since they are not free. <a %s >Get a key today!</a>."
COM_COMPONENTBUILDER_THESE_OPTIONS_ARE_NOT_AVAILABLE_TO_THE_FIELD_IF_BNONE_DBB_OPTION_IS_SELECTED="These options are not available to the field if <b>None DB</b> option is selected."
COM_COMPONENTBUILDER_THESE_OPTIONS_ARE_ONLY_AVAILABLE_TO_THE_FIELD_IF_BSHOW_IN_LIST_VIEWB_OPTION_IS_SELECTED="These options are only available to the field if <b>Show in list view</b> option is selected."

View File

@ -116,6 +116,29 @@ class ComponentbuilderModelAjax extends JModelList
return false;
}
/**
* get the JCB package info (html)
**/
public function getJCBpackageInfo($url)
{
// convert URL
$url = str_replace('.zip', '.info', $url);
// check if url exist
if ($info = ComponentbuilderHelper::getFileContents($url, false))
{
// Get the encryption object.
$opener = new FOFEncryptAes('V4stD3vel0pmEntMethOd@YoUrS3rv!s', 128);
$info = rtrim($opener->decryptString($info), "\0");
// check if we have json
if (ComponentbuilderHelper::checkJson($info))
{
$info = json_decode($info, true);
return array('owner' => ComponentbuilderHelper::getPackageOwnerDetailsDisplay($info, true), 'packages' => ComponentbuilderHelper::getPackageComponentsDetailsDisplay($info));
}
}
return array('error' => JText::_('COM_COMPONENTBUILDER_JCB_PACKAGE_INFO_PATH_DOES_NOT_WORK_WE_ADVICE_YOU_BNOT_TO_CONTINUEB_WITH_THE_IMPORT_OF_THE_SELECTED_PACKAGE'));
}
/**
* set the component display
**/

View File

@ -97,7 +97,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
protected $isMultiple = array();
protected $specialValue = false;
protected $checksum = null;
protected $checksumURLs = array('vdm' => 'https://raw.githubusercontent.com/vdm-io/JCB-Packages/master/');
protected $checksumURLs = array('vdm' => 'https://raw.githubusercontent.com/vdm-io/JCB-Packages/master/', 'jcb' => 'https://raw.githubusercontent.com/vdm-io/JCB-Community-Packages/master/');
protected $mustMerge = array('validation_rule', 'fieldtype', 'snippet', 'language', 'language_translation');
/**
@ -682,7 +682,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
$this->data = $data;
return true;
}
$this->app->enqueueMessage(JText::_('COM_COMPONENTBUILDER_HTWODATA_IS_CORRUPTHTWOTHIS_COULD_BE_DUE_TO_KEY_ERROR_OR_BROKEN_PACKAGE'), 'error');
$this->app->enqueueMessage(JText::_('COM_COMPONENTBUILDER_HTWODATA_IS_CORRUPTHTWOTHIS_COULD_BE_DUE_TO_BKEY_ERRORB_OR_BROKEN_PACKAGE'), 'error');
return false;
}
$this->app->enqueueMessage(JText::_('COM_COMPONENTBUILDER_HTWODATA_IS_CORRUPTHTWOTHIS_COULD_BE_DUE_TO_BROKEN_PACKAGE'), 'error');

View File

@ -110,6 +110,24 @@ JHtml::_('behavior.keepalive');
form.submit();
}
};
Joomla.submitbuttonJCB = function()
{
var form = document.getElementById('adminForm');
// do field validation
if (form.jcb_package.value == "" || form.jcb_package.value == "http://")
{
alert("<?php echo JText::_('COM_COMPONENTBUILDER_SELECT_THE_COMPONENT_YOUR_WOULD_LIKE_TO_IMPORT', true); ?>");
}
else
{
// set the url
form.import_url.value = form.jcb_package.value;
jQuery('#loading').css('display', 'block');
form.checksum.value = 'jcb';
form.gettype.value = 'url';
form.submit();
}
};
<?php endif; ?>
@ -190,97 +208,14 @@ jQuery(document).ready(function($) {
</div>
<?php if ($hasOwner): ?>
<div class="well span6">
<?php
$ownerDetails = '<h2 class="module-title nav-header">' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS') . '</h2>';
$ownerDetails .= '<ul>';
if (isset($this->packageInfo['getKeyFrom']['company']) && componentbuilderHelper::checkString($this->packageInfo['getKeyFrom']['company']))
{
$owner = $this->packageInfo['getKeyFrom']['company'];
$ownerDetails .= '<li>' . JText::sprintf('COM_COMPONENTBUILDER_EMCOMPANYEM_BSB', $this->packageInfo['getKeyFrom']['company']) . '</li>';
}
// add value only if set
if (isset($this->packageInfo['getKeyFrom']['owner']) && componentbuilderHelper::checkString($this->packageInfo['getKeyFrom']['owner']))
{
if (!isset($owner))
{
$owner = $this->packageInfo['getKeyFrom']['owner'];
}
$ownerDetails .= '<li>' . JText::sprintf('COM_COMPONENTBUILDER_EMOWNEREM_BSB', $this->packageInfo['getKeyFrom']['owner']) . '</li>';
}
// add value only if set
if (isset($this->packageInfo['getKeyFrom']['website']) && componentbuilderHelper::checkString($this->packageInfo['getKeyFrom']['website']))
{
$ownerDetails .= '<li>' . JText::sprintf('COM_COMPONENTBUILDER_EMWEBSITEEM_BSB', $this->packageInfo['getKeyFrom']['website']) . '</li>';
}
// add value only if set
if (isset($this->packageInfo['getKeyFrom']['email']) && componentbuilderHelper::checkString($this->packageInfo['getKeyFrom']['email']))
{
$ownerDetails .= '<li>' . JText::sprintf('COM_COMPONENTBUILDER_EMEMAILEM_BSB', $this->packageInfo['getKeyFrom']['email']) . '</li>';
}
// add value only if set
if (isset($this->packageInfo['getKeyFrom']['license']) && componentbuilderHelper::checkString($this->packageInfo['getKeyFrom']['license']))
{
$ownerDetails .= '<li>' . JText::sprintf('COM_COMPONENTBUILDER_EMLICENSEEM_BSB', $this->packageInfo['getKeyFrom']['license']) . '</li>';
}
// add value only if set
if (isset($this->packageInfo['getKeyFrom']['copyright']) && componentbuilderHelper::checkString($this->packageInfo['getKeyFrom']['copyright']))
{
$ownerDetails .= '<li>' . JText::sprintf('COM_COMPONENTBUILDER_EMCOPYRIGHTEM_BSB', $this->packageInfo['getKeyFrom']['copyright']) . '</li>';
}
$ownerDetails .= '</ul>';
// provide some details to how the user can get a key
if (isset($this->packageInfo['getKeyFrom']['buy_link']) && componentbuilderHelper::checkString($this->packageInfo['getKeyFrom']['buy_link']))
{
$ownerDetails .= '<hr />';
$ownerDetails .= JText::sprintf('COM_COMPONENTBUILDER_BGET_THE_KEY_FROMB_A_CLASSBTN_BTNPRIMARY_HREFS_TARGET_BLANK_TITLEGET_A_KEY_FROM_SSA', $this->packageInfo['getKeyFrom']['buy_link'], $owner, $owner);
}
// add more custom links
elseif (isset($this->packageInfo['getKeyFrom']['buy_links']) && componentbuilderHelper::checkArray($this->packageInfo['getKeyFrom']['buy_links']))
{
$buttons = array();
foreach ($this->packageInfo['getKeyFrom']['buy_links'] as $keyName => $link)
{
$buttons[] = JText::sprintf('COM_COMPONENTBUILDER_GET_THE_KEY_FROM_BSB_FOR_A_CLASSBTN_BTNPRIMARY_HREFS_TARGET_BLANK_TITLEGET_A_KEY_FROM_SSA', $owner, $link, $owner, $keyName);
}
$ownerDetails .= '<hr />';
$ownerDetails .= implode('<br />', $buttons);
}
// return the owner details
if (!isset($owner))
{
$ownerDetails = '<h2 style="color: #922924;">' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS_NOT_FOUND') . '</h2>';
$ownerDetails .= '<p style="color: #922924;">' . JText::_('COM_COMPONENTBUILDER_BE_CAUTIOUS_DO_NOT_CONTINUE_UNLESS_YOU_TRUST_THE_ORIGIN_OF_THIS_PACKAGE') . '</p>';
}
echo $ownerDetails;
?>
<?php echo ComponentbuilderHelper::getPackageOwnerDetailsDisplay($this->packageInfo); ?>
</div>
<?php endif; ?>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php if (isset($this->packageInfo['name']) && ComponentbuilderHelper::checkArray($this->packageInfo['name'])) : ?>
<?php echo JHtml::_('bootstrap.addTab', 'jcbImportTab', 'info', JText::sprintf('COM_COMPONENTBUILDER_S_BEING_IMPORTED', $comP)); ?>
<?php $class2 = ($cAmount == 1) ? 'span12' : 'span6'; ?>
<?php $counter = 1; foreach ($this->packageInfo['name'] as $key => $value): ?>
<?php if ($cAmount > 1 && $counter == 3) { echo '</div>'; $counter = 1;} ?>
<?php if ($cAmount > 1 && $counter == 1) { echo '<div>'; } ?>
<div class="well well-small <?php echo $class2; ?>">
<h2 class="module-title nav-header"><?php echo JText::sprintf('COM_COMPONENTBUILDER_BSB_EMCOMPONENT_DETAILSEM', $value . ' v' . $this->packageInfo['component_version'][$key]); ?></h2>
<p><?php echo $this->packageInfo['short_description'][$key]; ?></p>
<ul>
<li><?php echo JText::sprintf('COM_COMPONENTBUILDER_EMCOMPANY_NAMEEM_BSB', $this->packageInfo['companyname'][$key]); ?></li>
<li><?php echo JText::sprintf('COM_COMPONENTBUILDER_EMAUTHOREM_BSB', $this->packageInfo['author'][$key]); ?></li>
<li><?php echo JText::sprintf('COM_COMPONENTBUILDER_EMEMAILEM_BSB', $this->packageInfo['email'][$key]); ?></li>
<li><?php echo JText::sprintf('COM_COMPONENTBUILDER_EMWEBSITEEM_BSB', $this->packageInfo['website'][$key]); ?></li>
</ul>
<h2 class="nav-header"><?php echo JText::_('COM_COMPONENTBUILDER_LICENSE'); ?></h2>
<p><?php echo $this->packageInfo['license'][$key]; ?></p>
<h2 class="nav-header"><?php echo JText::_('COM_COMPONENTBUILDER_COPYRIGHT'); ?></h2>
<p><?php echo $this->packageInfo['copyright'][$key]; ?></p>
</div>
<?php $counter++; ?>
<?php endforeach; ?>
<?php echo ComponentbuilderHelper::getPackageComponentsDetailsDisplay($this->packageInfo); ?>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php endif; ?>
@ -338,25 +273,73 @@ jQuery(document).ready(function($) {
</fieldset>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php if ($this->vdmPackages): ?>
<?php if ($this->vdmPackages && ComponentbuilderHelper::checkArray($this->vdmPackages)): ?>
<?php echo JHtml::_('bootstrap.addTab', 'jcbImportTab', 'url_vdm', JText::_('COM_COMPONENTBUILDER_VDM_PACKAGES', true)); ?>
<fieldset class="uploadform">
<legend><?php echo JText::_("COM_COMPONENTBUILDER_PACKAGES_FROM_VAST_DEVELOPMENT_METHOD"); ?></legend>
<div class="span6">
<div class="alert alert-success">
<p><?php echo JText::sprintf('COM_COMPONENTBUILDER_ALL_OF_THESE_PACKAGES_ARE_A_FULLY_DEVELOPEDMAPPED_COMPONENTS_FOR_JCB_THEY_CAN_BE_SEEN_AS_DEMO_CONTENT_OR_BASE_IMAGES_FROM_WHICH_TO_START_YOUR_PROJECTBR_ALWAYS_MAKE_SURE_YOU_ARE_ON_THE_LATEST_VERSION_OF_JCB_BEFORE_IMPORTING_ANY_OF_THESE_PACKAGES_SHOULD_ANY_OF_THEM_FAIL_TO_IMPORT_A_S_PLEASE_LET_US_KNOWA', 'href="https://www.vdm.io/support" target="_blank" title="Should any of these packages fail to import please let us know, some need a key of course."'); ?></p>
<p><?php echo JText::sprintf('COM_COMPONENTBUILDER_THESE_ARE_THE_SAME_PACKAGES_FOUND_ON_A_S_GITHUBA_AND_CAN_BE_IMPORTED_BY_SIMPLY_MAKING_A_SELECTION_AND_THEN_CLICKING_THE_GET_PACKAGE_BUTTONBR_SOME_OF_THESE_PACKAGES_WOULD_REQUIRE_A_KEY_SINCE_THEY_ARE_NOT_FREE_A_S_GET_A_KEY_TODAYA', 'href="https://github.com/vdm-io/JCB-Packages" target="_blank" title="gitHub Reposetory"', 'href="http://vdm.bz/jcb-packages" target="_blank" title="get a key to import the paid packages."'); ?></p>
</div>
<?php foreach ($this->vdmPackages as $field): ?>
<div class="control-group">
<div class="control-label"><?php echo $field->label;?></div>
<div class="controls"><?php echo $field->input;?></div>
<fieldset class="uploadform">
<legend><?php echo JText::_("COM_COMPONENTBUILDER_PACKAGES_FROM_VAST_DEVELOPMENT_METHOD"); ?></legend>
<?php foreach ($this->vdmPackages as $field): ?>
<div class="control-group">
<div class="control-label"><?php echo $field->label;?></div>
<div class="controls"><?php echo $field->input;?></div>
</div>
<?php endforeach; ?>
<div class="form-actions">
<input type="button" class="btn btn-primary" value="<?php echo JText::_('COM_COMPONENTBUILDER_GET_PACKAGE'); ?>" onclick="Joomla.submitbuttonVDM()" />&nbsp;&nbsp;&nbsp;<small><span class="icon-shield"> </span><?php echo JText::_('COM_COMPONENTBUILDER_OFFICIAL_VDM_PACKAGES'); ?></small>
</div>
<div class="control-group"><small><?php echo JText::sprintf('COM_COMPONENTBUILDER_A_S_SPAN_CLASSICONFLAG_SPANREPORT_BROKEN_PACKAGEA', 'href="https://www.vdm.io/support" target="_blank" title="Should any of these packages fail to import please let us know"'); ?></small></div>
</fieldset>
</div>
<div class="span6">
<div id="vdm_packages_details">
</div>
<?php endforeach; ?>
<div class="form-actions">
<input type="button" class="btn btn-primary" value="<?php echo JText::_('COM_COMPONENTBUILDER_GET_PACKAGE'); ?>" onclick="Joomla.submitbuttonVDM()" />&nbsp;&nbsp;&nbsp;<small><span class="icon-shield"> </span><?php echo JText::_('COM_COMPONENTBUILDER_OFFICIAL_VDM_PACKAGES'); ?></small>
<div id="vdm_noticeboard" class="well well-small" >
<h2 class="module-title nav-header"><?php echo JText::_('COM_COMPONENTBUILDER_VDM_NOTICE_BOARD'); ?><span class="vdm-new-notice" style="display:none; color:red;"> (<?php echo JText::_('COM_COMPONENTBUILDER_NEW_NOTICE'); ?>)</span></h2>
<div class="noticeboard-md"><small><?php echo JText::_('COM_COMPONENTBUILDER_THE_NOTICE_BOARD_IS_LOADING'); ?><span class="loading-dots">.</span></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><br />
<div id="vdm_package_owner_details">
</div>
<div class="control-group"><small><?php echo JText::sprintf('COM_COMPONENTBUILDER_A_S_SPAN_CLASSICONFLAG_SPANREPORT_BROKEN_PACKAGEA', 'href="https://www.vdm.io/support" target="_blank" title="Should any of these packages fail to import please let us know"'); ?></small></div>
</fieldset>
</div>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php endif; ?>
<?php if ($this->jcbPackages && ComponentbuilderHelper::checkArray($this->jcbPackages)) : ?>
<?php echo JHtml::_('bootstrap.addTab', 'jcbImportTab', 'url_jcb', JText::_('COM_COMPONENTBUILDER_JCB_COMMUNITY_PACKAGES', true)); ?>
<div class="span6">
<div class="alert alert-success">
<p><?php echo JText::sprintf('COM_COMPONENTBUILDER_ALL_OF_THESE_PACKAGES_ARE_A_FULLY_DEVELOPEDMAPPED_COMPONENTS_FOR_JCB_THEY_CAN_BE_SEEN_AS_DEMO_CONTENT_OR_BASE_IMAGES_FROM_WHICH_TO_START_YOUR_PROJECTBR_ALWAYS_MAKE_SURE_YOU_ARE_ON_THE_LATEST_VERSION_OF_JCB_BEFORE_IMPORTING_ANY_OF_THESE_PACKAGES_SHOULD_ANY_OF_THEM_FAIL_TO_IMPORT_A_S_PLEASE_LET_US_KNOWA', 'href="https://www.jcb.io/support" target="_blank" title="Should any of these packages fail to import please let us know, some need a key of course."'); ?></p>
<p><?php echo JText::sprintf('COM_COMPONENTBUILDER_THESE_ARE_THE_SAME_PACKAGES_FOUND_ON_A_S_GITHUBA_AND_CAN_BE_IMPORTED_BY_SIMPLY_MAKING_A_SELECTION_AND_THEN_CLICKING_THE_GET_PACKAGE_BUTTONBR_SOME_OF_THESE_PACKAGES_WOULD_REQUIRE_A_KEY_SINCE_THEY_ARE_NOT_FREE', 'href="https://github.com/vdm-io/JCB-Community-Packages" target="_blank" title="gitHub Reposetory"'); ?></p>
</div>
<fieldset class="uploadform">
<legend><?php echo JText::_("COM_COMPONENTBUILDER_PACKAGES_FROM_JCB_COMMUNITY"); ?></legend>
<?php foreach ($this->jcbPackages as $field): ?>
<div class="control-group">
<div class="control-label"><?php echo $field->label;?></div>
<div class="controls"><?php echo $field->input;?></div>
</div>
<?php endforeach; ?>
<div class="form-actions">
<input type="button" class="btn btn-primary" value="<?php echo JText::_('COM_COMPONENTBUILDER_GET_PACKAGE'); ?>" onclick="Joomla.submitbuttonJCB()" />&nbsp;&nbsp;&nbsp;<small><span class="icon-shield"> </span><?php echo JText::_('COM_COMPONENTBUILDER_COMMUNITY_PACKAGES'); ?></small>
</div>
<div class="control-group"><small><?php echo JText::sprintf('COM_COMPONENTBUILDER_A_S_SPAN_CLASSICONFLAG_SPANREPORT_BROKEN_PACKAGEA', 'href="https://www.jcb.io/support" target="_blank" title="Should any of these packages fail to import please let us know"'); ?></small></div>
</fieldset>
</div>
<div class="span6">
<div id="jcb_packages_details">
</div>
<div id="jcb_noticeboard" class="well well-small" >
<h2 class="module-title nav-header"><?php echo JText::_('COM_COMPONENTBUILDER_VDM_NOTICE_BOARD'); ?><span class="vdm-new-notice" style="display:none; color:red;"> (<?php echo JText::_('COM_COMPONENTBUILDER_NEW_NOTICE'); ?>)</span></h2>
<div class="noticeboard-md"><small><?php echo JText::_('COM_COMPONENTBUILDER_THE_NOTICE_BOARD_IS_LOADING'); ?><span class="loading-dots">.</span></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><br />
<div id="jcb_package_owner_details">
</div>
</div>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php endif; ?>
@ -369,6 +352,105 @@ jQuery(document).ready(function($) {
</form>
</div>
<script type="text/javascript">
function getJCBpackageInfo(type){
// show spinner
jQuery('#loading').show();
jQuery('#'+type+'_noticeboard').hide();
// get value
var url = jQuery('#'+type+'_package').val();
if (url) {
var key = url.replace(/\W/g, '');
// check if the values are local
var result = jQuery.jStorage.get('JCB-packages-details'+key, null);
if (result) {
showJCBpackageInfo(result, key, type);
} else {
getJCBpackageInfoAgain(url, key, type);
}
} else {
// show spinner
jQuery('#loading').hide();
jQuery('#'+type+'_noticeboard').show();
jQuery('#'+type+'_package_owner_details').html(' ');
jQuery('#'+type+'_packages_details').html(' ');
}
}
function getJCBpackageInfoAgain(url, key,type){
getJCBpackageInfo_server(url).done(function(result) {
showJCBpackageInfo(result, key,type);
});
}
function showJCBpackageInfo(result, key,type){
if(result.owner || result.packages){
jQuery('#'+type+'_packages_details').html(result.packages);
jQuery('#'+type+'_package_owner_details').html(result.owner);
jQuery.jStorage.set('JCB-packages-details'+key, result, {TTL: expire});
} else {
if (result.error) {
jQuery('#'+type+'_packages_details').html(result.error);
}
jQuery('#'+type+'_package_owner_details').html(' ');
jQuery('#'+type+'_noticeboard').show();
}
// stop spinner
jQuery('#loading').hide();
}
function getJCBpackageInfo_server(url){
var getUrl = "index.php?option=com_componentbuilder&task=ajax.getJCBpackageInfo&format=json";
if(token.length > 0 && url.length > 0){
var request = 'token='+token+'&url=' + url;
}
return jQuery.ajax({
type: 'GET',
url: getUrl,
dataType: 'jsonp',
data: request,
jsonp: 'callback'
});
}
var noticeboard = "https://www.vdm.io/componentbuilder-noticeboard-md";
jQuery(document).ready(function () {
jQuery.get(noticeboard)
.success(function(board) {
if (board.length > 5) {
jQuery(".noticeboard-md").html(marked(board));
getIS(1,board).done(function(result) {
if (result){
jQuery(".vdm-new-notice").show();
getIS(2,board);
}
});
} else {
jQuery(".noticeboard-md").html(all_is_good);
}
})
.error(function(jqXHR, textStatus, errorThrown) {
jQuery(".noticeboard-md").html(all_is_good);
});
});
// to check is READ/NEW
function getIS(type,notice){
if (type == 1) {
var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.isNew&format=json");
} else if (type == 2) {
var getUrl = JRouter("index.php?option=com_componentbuilder&task=ajax.isRead&format=json");
}
if(token.length > 0 && notice.length){
var request = "token="+token+"&notice="+notice;
}
return jQuery.ajax({
type: "POST",
url: getUrl,
dataType: "jsonp",
data: request,
jsonp: "callback"
});
}
jQuery('#adminForm').on('change', '#haskey',function (e)
{
e.preventDefault();
@ -379,4 +461,34 @@ jQuery('#adminForm').on('change', '#haskey',function (e)
jQuery("#sleutle").closest('.control-group').hide();
}
});
// nice little dot trick :)
jQuery(document).ready( function($) {
var x=0;
setInterval(function() {
var dots = "";
x++;
for (var y=0; y < x%8; y++) {
dots+=".";
}
$(".loading-dots").text(dots);
} , 500);
});
<?php
$app = JFactory::getApplication();
?>
function JRouter(link) {
<?php
if ($app->isSite())
{
echo 'var url = "'.JURI::root().'";';
}
else
{
echo 'var url = "";';
}
?>
return url+link;
}
</script>

View File

@ -42,7 +42,6 @@ class ComponentbuilderViewImport_joomla_components extends JViewLegacy
protected $packageInfo;
protected $formPackage;
protected $vdmPackages = false;
protected $freePackages = array('JCB_demo.zip', 'JCB_helloWorld.zip');
public function display($tpl = null)
{
@ -51,6 +50,8 @@ class ComponentbuilderViewImport_joomla_components extends JViewLegacy
// Include helper submenu
ComponentbuilderHelper::addSubmenu('import');
}
// get component params
$this->params = JComponentHelper::getParams('com_componentbuilder');
$paths = new stdClass;
$paths->first = '';
@ -87,6 +88,7 @@ class ComponentbuilderViewImport_joomla_components extends JViewLegacy
// load the forms
$this->formPackage = $this->_getForm($this->dataType);
$this->vdmPackages = $this->_getForm('vdm_package');
$this->jcbPackages = $this->_getForm('jcb_package');
}
// Check for errors.
@ -95,10 +97,73 @@ class ComponentbuilderViewImport_joomla_components extends JViewLegacy
throw new Exception(implode("\n", $errors), 500);
}
// set the document
$this->setDocument();
// Display the template
parent::display($tpl);
}
/**
* Prepares the document
*/
protected function setDocument()
{
// always make sure jquery is loaded.
JHtml::_('jquery.framework');
// Add the JavaScript for JStore
$this->document->addScript(JURI::root() .'media/com_componentbuilder/js/jquery.json.min.js');
$this->document->addScript(JURI::root() .'media/com_componentbuilder/js/jstorage.min.js');
$this->document->addScript(JURI::root() .'media/com_componentbuilder/js/strtotime.js');
// add marked library
$this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/custom/marked.js");
// check if we should use browser storage
$setBrowserStorage = $this->params->get('set_browser_storage', null);
if ($setBrowserStorage)
{
// check what (Time To Live) show we use
$storageTimeToLive = $this->params->get('storage_time_to_live', 'global');
if ('global' == $storageTimeToLive)
{
// use the global session time
$session = JFactory::getSession();
// must have itin milliseconds
$expire = ($session->getExpire()*60)* 1000;
}
else
{
// use the Componentbuilder Global setting
if (0 != $storageTimeToLive)
{
// this will convert the time into milliseconds
$storageTimeToLive = $storageTimeToLive * 1000;
}
$expire = $storageTimeToLive;
}
}
else
{
// set to use no storage
$expire = 30000; // only 30 seconds
}
// Set the Time To Live To JavaScript
$this->document->addScriptDeclaration("var expire = ". (int) $expire.";");
$this->document->addScriptDeclaration("var all_is_good = '".JText::_('COM_COMPONENTBUILDER_ALL_IS_GOOD_THERE_IS_NO_NOTICE_AT_THIS_TIME')."';");
// add a token on the page for javascript
$this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';");
// add the Uikit v2 style sheets
$this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
$this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
// add Uikit v2 JavaScripts
$this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');
$this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true);
$this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true);
}
public function _getForm($type)
{
$form = array();
@ -243,9 +308,9 @@ class ComponentbuilderViewImport_joomla_components extends JViewLegacy
$form[] = $sleutle;
}
}
elseif ('vdm_package' === $type && $listObjects = ComponentbuilderHelper::getGithubRepoFileList('jcbGithubPackages', ComponentbuilderHelper::$jcbGithubPackagesUrl.ComponentbuilderHelper::$accessToken))
elseif ('vdm_package' === $type && $vdmListObjects = ComponentbuilderHelper::getGithubRepoFileList('vdmGithubPackages', ComponentbuilderHelper::$vdmGithubPackagesUrl.ComponentbuilderHelper::$accessToken))
{
if (ComponentbuilderHelper::checkArray($listObjects))
if (ComponentbuilderHelper::checkArray($vdmListObjects))
{
// get the vdm_package list field
$vdm_package = JFormHelper::loadFieldType('list',true);
@ -257,7 +322,8 @@ class ComponentbuilderViewImport_joomla_components extends JViewLegacy
'name' => 'vdm_package',
'label' => 'COM_COMPONENTBUILDER_PACKAGE',
'class' => 'list_class',
'description' => 'COM_COMPONENTBUILDER_SELECT_THE_PACKAGE_TO_IMPORT');
'description' => 'COM_COMPONENTBUILDER_SELECT_THE_PACKAGE_TO_IMPORT',
'onchange' => "getJCBpackageInfo('vdm')");
// load the list
$load = false;
// load the vdm_package attributes
@ -266,11 +332,11 @@ class ComponentbuilderViewImport_joomla_components extends JViewLegacy
$vdm_packageOptions = array();
$vdm_packageOptions[''] = 'COM_COMPONENTBUILDER__SELECT_PACKAGE_';
// load vdm_package options from array
foreach($listObjects as $listObject)
foreach($vdmListObjects as $vdmListObject)
{
if (strpos($listObject->path, '.zip') !== false)
if (strpos($vdmListObject->path, '.zip') !== false)
{
$vdm_packageOptions[ComponentbuilderHelper::$jcbGithubPackageUrl.$listObject->path] = $this->setPackageName($listObject->path);
$vdm_packageOptions[ComponentbuilderHelper::$vdmGithubPackageUrl.$vdmListObject->path] = $this->setPackageName($vdmListObject->path);
$load = true;
}
}
@ -286,22 +352,57 @@ class ComponentbuilderViewImport_joomla_components extends JViewLegacy
}
}
}
elseif ('jcb_package' === $type && $jcbListObjects = ComponentbuilderHelper::getGithubRepoFileList('jcbGithubPackages', ComponentbuilderHelper::$jcbGithubPackagesUrl.ComponentbuilderHelper::$accessToken))
{
if (ComponentbuilderHelper::checkArray($jcbListObjects))
{
// get the jcb_package list field
$jcb_package = JFormHelper::loadFieldType('list',true);
// start jcb_package xml
$jcb_packageXML = new SimpleXMLElement('<field/>');
// jcb_package attributes
$jcb_packageAttributes = array(
'type' => 'list',
'name' => 'jcb_package',
'label' => 'COM_COMPONENTBUILDER_PACKAGE',
'class' => 'list_class',
'description' => 'COM_COMPONENTBUILDER_SELECT_THE_PACKAGE_TO_IMPORT',
'onchange' => "getJCBpackageInfo('jcb')");
// load the list
$load = false;
// load the jcb_package attributes
ComponentbuilderHelper::xmlAddAttributes($jcb_packageXML, $jcb_packageAttributes);
// start the jcb_package options
$jcb_packageOptions = array();
$jcb_packageOptions[''] = 'COM_COMPONENTBUILDER__SELECT_PACKAGE_';
// load jcb_package options from array
foreach($jcbListObjects as $jcbListObject)
{
if (strpos($jcbListObject->path, '.zip') !== false)
{
$jcb_packageOptions[ComponentbuilderHelper::$jcbGithubPackageUrl.$jcbListObject->path] = $this->setPackageName($jcbListObject->path);
$load = true;
}
}
// only load if at least one item was found
if ($load)
{
// load the jcb_package options
ComponentbuilderHelper::xmlAddOptions($jcb_packageXML, $jcb_packageOptions);
// setup the jcb_package radio field
$jcb_package->setup($jcb_packageXML,'');
// add to form
$form[] = $jcb_package;
}
}
}
return $form;
}
public function setPackageName($name)
{
// the free switch
if (in_array($name, $this->freePackages))
{
$type = ' - free';
}
else
{
$type = ' - paid';
}
// return the name
return ComponentbuilderHelper::safeString( preg_replace('/(?<!^)([A-Z])/', '-\ \1', str_replace(array('.zip', 'JCB_'), '', $name)), 'W').$type;
return ComponentbuilderHelper::safeString( preg_replace('/(?<!^)([A-Z])/', '-\ \1', str_replace(array('.zip', 'JCB_'), '', $name)), 'W');
}
/**

View File

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

View File

@ -68,10 +68,16 @@ abstract class ComponentbuilderHelper
public static $snippetsPath = 'https://api.github.com/repos/vdm-io/Joomla-Component-Builder-Snippets/git/trees/master';
/**
* The packages paths
* The VDM packages paths
**/
public static $jcbGithubPackagesUrl = "https://api.github.com/repos/vdm-io/JCB-Packages/git/trees/master";
public static $jcbGithubPackageUrl = "https://github.com/vdm-io/JCB-Packages/raw/master/";
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/";
/**
* 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/";
// not needed at this time (maybe latter)
public static $accessToken = "";
@ -2036,6 +2042,138 @@ abstract class ComponentbuilderHelper
return false;
}
/**
* get the JCB package owner details display
**/
public static function getPackageOwnerDetailsDisplay(&$info, $trust = false)
{
$ownerDetails = '<h2 class="module-title nav-header">' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS') . '</h2>';
$ownerDetails .= '<ul>';
if (isset($info['getKeyFrom']['company']) && self::checkString($info['getKeyFrom']['company']))
{
$owner = $info['getKeyFrom']['company'];
$ownerDetails .= '<li>' . JText::sprintf('COM_COMPONENTBUILDER_EMCOMPANYEM_BSB', $info['getKeyFrom']['company']) . '</li>';
}
// add value only if set
if (isset($info['getKeyFrom']['owner']) && self::checkString($info['getKeyFrom']['owner']))
{
if (!isset($owner))
{
$owner = $info['getKeyFrom']['owner'];
}
$ownerDetails .= '<li>' . JText::sprintf('COM_COMPONENTBUILDER_EMOWNEREM_BSB', $info['getKeyFrom']['owner']) . '</li>';
}
// add value only if set
if (isset($info['getKeyFrom']['website']) && self::checkString($info['getKeyFrom']['website']))
{
$ownerDetails .= '<li>' . JText::sprintf('COM_COMPONENTBUILDER_EMWEBSITEEM_BSB', $info['getKeyFrom']['website']) . '</li>';
}
// add value only if set
if (isset($info['getKeyFrom']['email']) && self::checkString($info['getKeyFrom']['email']))
{
$ownerDetails .= '<li>' . JText::sprintf('COM_COMPONENTBUILDER_EMEMAILEM_BSB', $info['getKeyFrom']['email']) . '</li>';
}
// add value only if set
if (isset($info['getKeyFrom']['license']) && self::checkString($info['getKeyFrom']['license']))
{
$ownerDetails .= '<li>' . JText::sprintf('COM_COMPONENTBUILDER_EMLICENSEEM_BSB', $info['getKeyFrom']['license']) . '</li>';
}
// add value only if set
if (isset($info['getKeyFrom']['copyright']) && self::checkString($info['getKeyFrom']['copyright']))
{
$ownerDetails .= '<li>' . JText::sprintf('COM_COMPONENTBUILDER_EMCOPYRIGHTEM_BSB', $info['getKeyFrom']['copyright']) . '</li>';
}
$ownerDetails .= '</ul>';
// provide some details to how the user can get a key
if (isset($info['getKeyFrom']['buy_link']) && self::checkString($info['getKeyFrom']['buy_link']))
{
$ownerDetails .= '<hr />';
$ownerDetails .= JText::sprintf('COM_COMPONENTBUILDER_BGET_THE_KEY_FROMB_A_CLASSBTN_BTNPRIMARY_HREFS_TARGET_BLANK_TITLEGET_A_KEY_FROM_SSA', $info['getKeyFrom']['buy_link'], $owner, $owner);
}
// add more custom links
elseif (isset($info['getKeyFrom']['buy_links']) && self::checkArray($info['getKeyFrom']['buy_links']))
{
$buttons = array();
foreach ($info['getKeyFrom']['buy_links'] as $keyName => $link)
{
$buttons[] = JText::sprintf('COM_COMPONENTBUILDER_GET_THE_KEY_FROM_BSB_FOR_A_CLASSBTN_BTNPRIMARY_HREFS_TARGET_BLANK_TITLEGET_A_KEY_FROM_SSA', $owner, $link, $owner, $keyName);
}
$ownerDetails .= '<hr />';
$ownerDetails .= implode('<br />', $buttons);
}
// return the owner details
if (!isset($owner) && !$trust)
{
$ownerDetails = '<h2 style="color: #922924;">' . JText::_('COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS_NOT_FOUND') . '</h2>';
$ownerDetails .= '<p style="color: #922924;">' . JText::_('COM_COMPONENTBUILDER_BE_CAUTIOUS_DO_NOT_CONTINUE_UNLESS_YOU_TRUST_THE_ORIGIN_OF_THIS_PACKAGE') . '</p>';
}
elseif (!isset($owner) && $trust)
{
$ownerDetails = '';
}
return $ownerDetails;
}
/**
* get the JCB package component details display
**/
public static function getPackageComponentsDetailsDisplay(&$info)
{
if (isset($info['name']) && self::checkArray($info['name']))
{
$cAmount = count((array) $info['name']);
$class2 = ($cAmount == 1) ? 'span12' : 'span6';
$counter = 1;
$display = array();
foreach ($info['name'] as $key => $value)
{
if ($cAmount > 1 && $counter == 3)
{
$display[] = '</div>';
$counter = 1;
}
if ($cAmount > 1 && $counter == 1)
{
$display[] = '<div>';
}
$display[] = '<div class="well well-small ' . $class2 . '">';
$display[] = '<h2 class="module-title nav-header">';
$display[] = JText::sprintf('COM_COMPONENTBUILDER_BSB_EMCOMPONENT_DETAILSEM', $value . ' v' . $info['component_version'][$key]);
$display[] = '</h2><p>';
$display[] = $info['short_description'][$key];
$display[] = '</p><ul><li>';
$display[] = JText::sprintf('COM_COMPONENTBUILDER_EMCOMPANY_NAMEEM_BSB', $info['companyname'][$key]);
$display[] = '</li><li>';
$display[] = JText::sprintf('COM_COMPONENTBUILDER_EMAUTHOREM_BSB', $info['author'][$key]);
$display[] = '</li><li>';
$display[] = JText::sprintf('COM_COMPONENTBUILDER_EMEMAILEM_BSB', $info['email'][$key]);
$display[] = '</li><li>';
$display[] = JText::sprintf('COM_COMPONENTBUILDER_EMWEBSITEEM_BSB', $info['website'][$key]);
$display[] = '</li></ul>';
$display[] = '<h2 class="nav-header">';
$display[] = JText::_('COM_COMPONENTBUILDER_LICENSE');
$display[] = '</h2><p>';
$display[] = $info['license'][$key];
$display[] = '</p><h2 class="nav-header">';
$display[] = JText::_('COM_COMPONENTBUILDER_COPYRIGHT');
$display[] = '</h2><p>';
$display[] = $info['copyright'][$key];
$display[] = '</p></div>';
$counter++;
}
// close the div if needed
if ($cAmount > 1)
{
$display[] = '</div>';
}
return implode("\n",$display);
}
return '<div>'.JText::_('COM_COMPONENTBUILDER_COPYRIGHT').'</div>';
}
/**
* prepare base64 string for url
**/
@ -3363,7 +3501,7 @@ abstract class ComponentbuilderHelper
}
public static function jsonToString($value, $sperator = ", ", $table = null)
public static function jsonToString($value, $sperator = ", ", $table = null, $id = 'id', $name = 'name')
{
// check if string is JSON
$result = json_decode($value, true);
@ -3377,7 +3515,7 @@ abstract class ComponentbuilderHelper
$names = array();
foreach ($result as $val)
{
if ($name = self::getVar($table, $val, 'id', 'name'))
if ($name = self::getVar($table, $val, $id, $name))
{
$names[] = $name;
}

View File

@ -4,18 +4,24 @@ COM_COMPONENTBUILDER_API="Api"
COM_COMPONENTBUILDER_API_DESC="Sync Portal API"
COM_COMPONENTBUILDER_BACKUP_FAILED_PLEASE_TRY_AGAIN_IF_THE_ERROR_CONTINUE_PLEASE_CONTACT_YOUR_SYSTEM_ADMINISTRATOR="Backup failed, please try again. If the error continue, please contact your system administrator."
COM_COMPONENTBUILDER_BACKUP_WAS_DONE_SUCCESSFULLY="Backup was done successfully"
COM_COMPONENTBUILDER_BE_CAUTIOUS_DO_NOT_CONTINUE_UNLESS_YOU_TRUST_THE_ORIGIN_OF_THIS_PACKAGE="Be cautious! Do not continue unless you trust the origin of this package!"
COM_COMPONENTBUILDER_BGET_THE_KEY_FROMB_A_CLASSBTN_BTNPRIMARY_HREFS_TARGET_BLANK_TITLEGET_A_KEY_FROM_SSA="<b>Get the key from</b> <a class="btn btn-primary" href="%s" target="_blank" title="get a key from %s">%s</a>"
COM_COMPONENTBUILDER_BSB_EMCOMPONENT_DETAILSEM="<b>%s</b> <em>component details</em>"
COM_COMPONENTBUILDER_CHECK_YOUR_OWNER_DETAILS_IT_HAS_NOT_BEEN_SET_OPEN_THE_JCB_GLOBAL_OPTIONS_GO_TO_THE_COMPANY_TAB_AND_ADD_THE_CORRECT_COMPANY_DETAILS_THERE="Check your owner details, it has not been set. Open the JCB Global Options, go to the Company tab and add the correct company details there."
COM_COMPONENTBUILDER_COMPANY_S="Company: %s"
COM_COMPONENTBUILDER_COMPONENT_DID_NOT_COMPILE="Component did not compile!"
COM_COMPONENTBUILDER_COMPONENT_IS_NOT_PUBLISHED_OR_IS_CHECKED_OUT="Component is not published, or is checked out!"
COM_COMPONENTBUILDER_COMPONENT_WAS_NOT_FOUND="Component was not found!"
COM_COMPONENTBUILDER_COPYRIGHT="Copyright"
COM_COMPONENTBUILDER_COPYRIGHT_S="Copyright: %s"
COM_COMPONENTBUILDER_CREATE_NEW_S="Create New %s"
COM_COMPONENTBUILDER_DESCRIPTION="Description"
COM_COMPONENTBUILDER_EDIT_S="Edit %s"
COM_COMPONENTBUILDER_EMAIL_S="Email: %s"
COM_COMPONENTBUILDER_EMAIL_WITH_THE_NEW_KEY_WAS_SEND="Email with the new key was send"
COM_COMPONENTBUILDER_EMAUTHOREM_BSB="<em>Author</em>: <b>%s</b>"
COM_COMPONENTBUILDER_EMCOMPANYEM_BSB="<em>Company:</em> <b>%s</b>"
COM_COMPONENTBUILDER_EMCOMPANY_NAMEEM_BSB="<em>Company Name</em>: <b>%s</b>"
COM_COMPONENTBUILDER_EMCOPYRIGHTEM_BSB="<em>Copyright:</em> <b>%s</b>"
COM_COMPONENTBUILDER_EMEMAILEM_BSB="<em>Email:</em> <b>%s</b>"
COM_COMPONENTBUILDER_EMLICENSEEM_BSB="<em>License:</em> <b>%s</b>"
@ -25,9 +31,11 @@ COM_COMPONENTBUILDER_ERROR="Error!"
COM_COMPONENTBUILDER_EXAMPLE="Example"
COM_COMPONENTBUILDER_FILE="File"
COM_COMPONENTBUILDER_FOLDER="Folder"
COM_COMPONENTBUILDER_GET_THE_KEY_FROM_BSB_FOR_A_CLASSBTN_BTNPRIMARY_HREFS_TARGET_BLANK_TITLEGET_A_KEY_FROM_SSA="Get the key from <b>%s</b> for <a class="btn btn-primary" href="%s" target="_blank" title="get a key from %s">%s</a>"
COM_COMPONENTBUILDER_HTWOCURL_NOT_FOUNDHTWOPPLEASE_SETUP_CURL_ON_YOUR_SYSTEM_OR_BCOMPONENTBUILDERB_WILL_NOT_FUNCTION_CORRECTLYP="<h2>Curl Not Found!</h2><p>Please setup curl on your system, or <b>componentbuilder</b> will not function correctly!</p>"
COM_COMPONENTBUILDER_JOOMLA_COMPONENT_BUILDER_BACKUP_KEY="Joomla Component Builder - Backup Key"
COM_COMPONENTBUILDER_KEY_HAS_NOT_CHANGED="Key has not changed"
COM_COMPONENTBUILDER_LICENSE="License"
COM_COMPONENTBUILDER_LICENSE_S="License: %s"
COM_COMPONENTBUILDER_LINK="Link"
COM_COMPONENTBUILDER_LOCAL="Local"
@ -38,6 +46,7 @@ COM_COMPONENTBUILDER_NO_KEYS_WERE_FOUND_TO_ADD_AN_EXPORT_KEY_SIMPLY_OPEN_THE_COM
COM_COMPONENTBUILDER_OWNER_DETAILS_WAS_SET="Owner details was set"
COM_COMPONENTBUILDER_OWNER_S="Owner: %s"
COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS="Package Owner Details"
COM_COMPONENTBUILDER_PACKAGE_OWNER_DETAILS_NOT_FOUND="Package owner details not found!"
COM_COMPONENTBUILDER_PACKAGE_OWNER_NOT_SET="Package Owner Not Set"
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."