fixed gh-383 to insure the new button works on frontend/site. Improved the JCB package import to also now import the new placeholder feature values correctly.

This commit is contained in:
Llewellyn van der Merwe 2019-03-04 14:47:28 +02:00
parent 9fcb317275
commit 098c82c222
No known key found for this signature in database
GPG Key ID: CAD7B16D27AF28C5
15 changed files with 176 additions and 49 deletions

View File

@ -146,11 +146,11 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 23rd February, 2019
+ *Last Build*: 4th March, 2019
+ *Version*: 2.9.13
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **203476**
+ *Line count*: **203595**
+ *Field count*: **1114**
+ *File count*: **1337**
+ *Folder count*: **209**

View File

@ -146,11 +146,11 @@ TODO
+ *Author*: [Llewellyn van der Merwe](mailto:llewellyn@joomlacomponentbuilder.com)
+ *Name*: [Component Builder](https://github.com/vdm-io/Joomla-Component-Builder)
+ *First Build*: 30th April, 2015
+ *Last Build*: 23rd February, 2019
+ *Last Build*: 4th March, 2019
+ *Version*: 2.9.13
+ *Copyright*: Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
+ *Line count*: **203476**
+ *Line count*: **203595**
+ *Field count*: **1114**
+ *File count*: **1337**
+ *Folder count*: **209**

View File

@ -5,7 +5,7 @@
* @created 30th April, 2015
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 - 2018 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
*/

View File

@ -5,7 +5,7 @@
* @created 30th April, 2015
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 - 2018 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
*/

View File

@ -5,7 +5,7 @@
* @created 30th April, 2015
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 - 2018 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
*/

View File

@ -5,7 +5,7 @@
* @created 30th April, 2015
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 - 2018 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
*/

View File

@ -5,7 +5,7 @@
* @created 30th April, 2015
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 - 2018 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
*/
@ -8083,21 +8083,29 @@ class Interpretation extends Fields
$headerscript .= PHP_EOL . '{';
$headerscript .= PHP_EOL . $this->_t(1) . '$return .= "&return=" . $_return;';
$headerscript .= PHP_EOL . '}';
$headerscript .= PHP_EOL . '//' . $this->setLine(__LINE__) . ' set the referral values';
$headerscript .= PHP_EOL . '$ref = ($id) ? "&ref=' . $viewName_single . '&refid=" . $id . "&return=" . urlencode(base64_encode($return)) : "";';
$headerscript .= PHP_EOL . '//' . $this->setLine(__LINE__) . ' check if return value was set';
$headerscript .= PHP_EOL . 'if (' . $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh] . 'Helper::checkString($return))';
$headerscript .= PHP_EOL . '{';
$headerscript .= PHP_EOL . $this->_t(1) . '//' . $this->setLine(__LINE__) . ' set the referral values';
$headerscript .= PHP_EOL . $this->_t(1) . '$ref = ($id) ? "&ref=' . $viewName_single . '&refid=" . $id . "&return=" . urlencode(base64_encode($return)) : "&return=" . urlencode(base64_encode($return));';
$headerscript .= PHP_EOL . '}';
$headerscript .= PHP_EOL . 'else';
$headerscript .= PHP_EOL . '{';
$headerscript .= PHP_EOL . $this->_t(1) . '$ref = ($id) ? "&ref=' . $viewName_single . '&refid=" . $id : "";';
$headerscript .= PHP_EOL . '}';
if ($addNewButon > 0)
{
// add the link for new
if ($addNewButon == 1 || $addNewButon == 2)
{
$headerscript .= PHP_EOL . '//' . $this->setLine(__LINE__) . ' set the create new URL';
$headerscript .= PHP_EOL . '$new = "index.php?option=com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '&view=' . $single . '&layout=edit".$ref;';
$headerscript .= PHP_EOL . '$new = "index.php?option=com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '&view=' . $list . '&task=' . $single . '.edit" . $ref;';
}
// and the link for close and new
if ($addNewButon == 2 || $addNewButon == 3)
{
$headerscript .= PHP_EOL . '//' . $this->setLine(__LINE__) . ' set the create new and close URL';
$headerscript .= PHP_EOL . '$close_new = "index.php?option=com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '&view=' . $single . '&layout=edit";';
$headerscript .= PHP_EOL . '$close_new = "index.php?option=com_' . $this->fileContentStatic[$this->hhh . 'component' . $this->hhh] . '&view=' . $list . '&task=' . $single . '.edit";';
}
$headerscript .= PHP_EOL . '//' . $this->setLine(__LINE__) . ' load the action object';
$headerscript .= PHP_EOL . '$can = ' . $this->fileContentStatic[$this->hhh . 'Component' . $this->hhh] . 'Helper::getActions(' . "'" . $single . "'" . ');';

View File

@ -5,7 +5,7 @@
* @created 30th April, 2015
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 - 2018 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
*/

View File

@ -4080,6 +4080,10 @@ abstract class ComponentbuilderHelper
{
$checked_out = (int) $item->checked_out;
}
else
{
$checked_out = self::getVar($view, $item->id, 'id', 'checked_out', '=', str_replace('com_', '', $component));
}
}
elseif (self::checkArray($item) && isset($item['id']))
{
@ -4088,6 +4092,14 @@ abstract class ComponentbuilderHelper
{
$checked_out = (int) $item['checked_out'];
}
else
{
$checked_out = self::getVar($view, $item['id'], 'id', 'checked_out', '=', str_replace('com_', '', $component));
}
}
elseif (is_numeric($item) && $item > 0)
{
$checked_out = self::getVar($view, $item, 'id', 'checked_out', '=', str_replace('com_', '', $component));
}
// set the link title
$title = self::safeString(JText::_('COM_COMPONENTBUILDER_EDIT') . ' ' . $view, 'W');
@ -4180,6 +4192,10 @@ abstract class ComponentbuilderHelper
{
$checked_out = (int) $item->checked_out;
}
else
{
$checked_out = self::getVar($view, $item->id, 'id', 'checked_out', '=', str_replace('com_', '', $component));
}
}
elseif (self::checkArray($item) && isset($item['id']))
{
@ -4188,6 +4204,14 @@ abstract class ComponentbuilderHelper
{
$checked_out = (int) $item['checked_out'];
}
else
{
$checked_out = self::getVar($view, $item['id'], 'id', 'checked_out', '=', str_replace('com_', '', $component));
}
}
elseif (is_numeric($item) && $item > 0)
{
$checked_out = self::getVar($view, $item, 'id', 'checked_out', '=', str_replace('com_', '', $component));
}
// set the link title
$title = self::safeString(JText::_('COM_COMPONENTBUILDER_EDIT') . ' ' . $view, 'W');

View File

@ -26,12 +26,20 @@ if ($_return = $jinput->get('return', null, 'base64'))
{
$return .= "&return=" . $_return;
}
// set the referral values
$ref = ($id) ? "&ref=fieldtype&refid=" . $id . "&return=" . urlencode(base64_encode($return)) : "";
// check if return value was set
if (ComponentbuilderHelper::checkString($return))
{
// set the referral values
$ref = ($id) ? "&ref=fieldtype&refid=" . $id . "&return=" . urlencode(base64_encode($return)) : "&return=" . urlencode(base64_encode($return));
}
else
{
$ref = ($id) ? "&ref=fieldtype&refid=" . $id : "";
}
// set the create new URL
$new = "index.php?option=com_componentbuilder&view=field&layout=edit".$ref;
$new = "index.php?option=com_componentbuilder&view=fields&task=field.edit" . $ref;
// set the create new and close URL
$close_new = "index.php?option=com_componentbuilder&view=field&layout=edit";
$close_new = "index.php?option=com_componentbuilder&view=fields&task=field.edit";
// load the action object
$can = ComponentbuilderHelper::getActions('field');

View File

@ -26,8 +26,16 @@ if ($_return = $jinput->get('return', null, 'base64'))
{
$return .= "&return=" . $_return;
}
// set the referral values
$ref = ($id) ? "&ref=server&refid=" . $id . "&return=" . urlencode(base64_encode($return)) : "";
// check if return value was set
if (ComponentbuilderHelper::checkString($return))
{
// set the referral values
$ref = ($id) ? "&ref=server&refid=" . $id . "&return=" . urlencode(base64_encode($return)) : "&return=" . urlencode(base64_encode($return));
}
else
{
$ref = ($id) ? "&ref=server&refid=" . $id : "";
}
?>
<div class="form-vertical">

View File

@ -699,7 +699,7 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
// the array of tables to store
$tables = array(
'validation_rule', 'fieldtype', 'field', 'admin_view', 'snippet', 'dynamic_get', 'custom_admin_view', 'site_view',
'template', 'layout', 'joomla_component', 'language', 'language_translation', 'custom_code',
'template', 'layout', 'joomla_component', 'language', 'language_translation', 'custom_code', 'placeholder',
'admin_fields', 'admin_fields_conditions', 'admin_fields_relations', 'admin_custom_tabs', 'component_admin_views',
'component_site_views', 'component_custom_admin_views', 'component_updates', 'component_mysql_tweaks',
'component_custom_admin_menus', 'component_config', 'component_dashboard', 'component_files_folders',
@ -2746,6 +2746,10 @@ class ComponentbuilderModelImport_joomla_components extends JModelLegacy
$retryAgain = 2;
}
break;
case 'placeholder':
// search for placeholder (since there should only be one)
$getter = 'target';
break;
case 'custom_code':
// search for custom code
$getter = array('comment_type', 'target');

View File

@ -66,6 +66,8 @@ class ComponentbuilderModelJoomla_components extends JModelList
protected $smartBox = array();
protected $smartIDs = array();
protected $customCodeM = array();
protected $placeholderM = array();
protected $placeholderS = array();
protected $fieldTypes = array();
protected $isMultiple = array();
@ -254,7 +256,9 @@ class ComponentbuilderModelJoomla_components extends JModelList
// component image
$this->moveIt(array($item->image), 'image');
// set the custom code ID's
$this->setCustomCodeIds($item, 'joomla_component');
$this->setCodePlaceholdersIds($item, 'joomla_component');
// set the placeholder ID's
$this->setCodePlaceholdersIds($item, 'joomla_component', 'placeholder');
// set the language strings for this component
$this->setLanguageTranslation($item->id);
// load to global object
@ -351,6 +355,11 @@ class ComponentbuilderModelJoomla_components extends JModelList
{
$this->setData('custom_code', array_values($this->smartIDs['custom_code']), 'id');
}
// add placeholder
if (isset($this->smartIDs['placeholder']) && ComponentbuilderHelper::checkArray($this->smartIDs['placeholder']))
{
$this->setData('placeholder', array_values($this->smartIDs['placeholder']), 'id');
}
// set limiter
$limit = 0;
// and add those custom codes found in custom codes
@ -614,10 +623,14 @@ class ComponentbuilderModelJoomla_components extends JModelList
{
$this->smartIDs['layout'] = array();
}
elseif ('custom_code' === $table && 'id' === $key)
elseif ('custom_code' === $table && 'id' === $key && !isset($this->smartIDs['custom_code']))
{
$this->smartIDs['custom_code'] = array();
}
elseif ('placeholder' === $table && 'id' === $key && !isset($this->smartIDs['placeholder']))
{
$this->smartIDs['placeholder'] = array();
}
// start loading the data
if (!isset($this->smartBox[$table]))
{
@ -666,7 +679,9 @@ class ComponentbuilderModelJoomla_components extends JModelList
// load to global object
$this->smartBox[$table][$item->id] = $item;
// set the custom code ID's
$this->setCustomCodeIds($item, $table);
$this->setCodePlaceholdersIds($item, $table);
// set the placeholder ID's
$this->setCodePlaceholdersIds($item, $table, 'placeholder');
// actions to take if table is component_files_folders
if ('component_files_folders' === $table && 'clone' !== $this->activeType)
{
@ -866,7 +881,7 @@ class ComponentbuilderModelJoomla_components extends JModelList
// the array of tables to store
$tables = array(
'fieldtype', 'field', 'admin_view', 'snippet', 'dynamic_get', 'custom_admin_view', 'site_view',
'template', 'layout', 'joomla_component', 'language', 'language_translation', 'custom_code',
'template', 'layout', 'joomla_component', 'language', 'language_translation', 'custom_code', 'placeholder',
'admin_fields', 'admin_fields_conditions', 'admin_fields_relations', 'admin_custom_tabs', 'component_admin_views',
'component_site_views', 'component_custom_admin_views', 'component_updates', 'component_mysql_tweaks',
'component_custom_admin_menus', 'component_config', 'component_dashboard', 'component_files_folders',
@ -1378,15 +1393,16 @@ class ComponentbuilderModelJoomla_components extends JModelList
}
/**
* Set the ids of the found custom code
* Set the ids of the found code placeholders
*
* @param object $item The item being searched
* @param string $target The target table
* @param string $type The type of placeholder to search and set
*
* @return void
*
*/
protected function setCustomCodeIds($item, $target)
protected function setCodePlaceholdersIds($item, $target, $type = 'custom_code')
{
if ($keys = $this->getCodeSearchKeys($target))
{
@ -1415,6 +1431,9 @@ class ComponentbuilderModelJoomla_components extends JModelList
// search and open the base64 strings
$this->searchOpenBase64($value, $keys['base64_search'][$key]);
}
// based on the type of search
if ('custom_code' === $type)
{
// search the value to see if it has custom code
$codeArray = ComponentbuilderHelper::getAllBetween($value, '[CUSTOMC' . 'ODE=',']');
if (ComponentbuilderHelper::checkArray($codeArray))
@ -1433,17 +1452,49 @@ class ComponentbuilderModelJoomla_components extends JModelList
// if numeric add to ids
if (is_numeric($func))
{
$this->setSmartIDs($func, 'custom_code');
$this->setSmartIDs($func, $type);
}
elseif (ComponentbuilderHelper::checkString($func))
{
if (($funcID = ComponentbuilderHelper::getVar('custom_code', $func, 'function_name', 'id')) !== false && is_numeric($funcID))
if (($funcID = ComponentbuilderHelper::getVar($type, $func, 'function_name', 'id')) !== false && is_numeric($funcID))
{
$this->setSmartIDs($funcID, 'custom_code');
$this->setSmartIDs($funcID, $type);
}
else
{
// set a notice that custom code was not found
// set a notice that custom code was not found (weird)
}
}
}
}
}
}
elseif ('placeholder' === $type)
{
// check if we already have the placeholder search array
if (!componentbuilderHelper::checkArray($this->placeholderM) && !componentbuilderHelper::checkArray($this->placeholderS))
{
$this->placeholderS = ComponentbuilderHelper::getVars($type, 1, 'published', 'target');
}
// only continue search if placeholders found
if (componentbuilderHelper::checkArray($this->placeholderS))
{
foreach ($this->placeholderS as $remove => $placeholder)
{
// search the value to see if it has this placeholder and is not already set
if (!isset($this->placeholderM[$placeholder]) && strpos($value, $placeholder) !== false)
{
// add only once
$this->placeholderM[$placeholder] = $placeholder;
unset($this->placeholderS[$remove]);
// get the ID
if (($placeholderID = ComponentbuilderHelper::getVar($type, $placeholder, 'target', 'id')) !== false && is_numeric($placeholderID))
{
$this->setSmartIDs($placeholderID, $type);
}
else
{
// set a notice that placeholder was not found (weird)
}
}
}

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>23rd February, 2019</creationDate>
<creationDate>4th March, 2019</creationDate>
<author>Llewellyn van der Merwe</author>
<authorEmail>llewellyn@joomlacomponentbuilder.com</authorEmail>
<authorUrl>http://www.joomlacomponentbuilder.com</authorUrl>

View File

@ -4080,6 +4080,10 @@ abstract class ComponentbuilderHelper
{
$checked_out = (int) $item->checked_out;
}
else
{
$checked_out = self::getVar($view, $item->id, 'id', 'checked_out', '=', str_replace('com_', '', $component));
}
}
elseif (self::checkArray($item) && isset($item['id']))
{
@ -4088,6 +4092,14 @@ abstract class ComponentbuilderHelper
{
$checked_out = (int) $item['checked_out'];
}
else
{
$checked_out = self::getVar($view, $item['id'], 'id', 'checked_out', '=', str_replace('com_', '', $component));
}
}
elseif (is_numeric($item) && $item > 0)
{
$checked_out = self::getVar($view, $item, 'id', 'checked_out', '=', str_replace('com_', '', $component));
}
// set the link title
$title = self::safeString(JText::_('COM_COMPONENTBUILDER_EDIT') . ' ' . $view, 'W');
@ -4180,6 +4192,10 @@ abstract class ComponentbuilderHelper
{
$checked_out = (int) $item->checked_out;
}
else
{
$checked_out = self::getVar($view, $item->id, 'id', 'checked_out', '=', str_replace('com_', '', $component));
}
}
elseif (self::checkArray($item) && isset($item['id']))
{
@ -4188,6 +4204,14 @@ abstract class ComponentbuilderHelper
{
$checked_out = (int) $item['checked_out'];
}
else
{
$checked_out = self::getVar($view, $item['id'], 'id', 'checked_out', '=', str_replace('com_', '', $component));
}
}
elseif (is_numeric($item) && $item > 0)
{
$checked_out = self::getVar($view, $item, 'id', 'checked_out', '=', str_replace('com_', '', $component));
}
// set the link title
$title = self::safeString(JText::_('COM_COMPONENTBUILDER_EDIT') . ' ' . $view, 'W');