Added notice to the compiler where it detects mismatching category view target names. Added the update script for categories in JCB. Made adjustments all across JCB to act according to gh-561 implementation.

This commit is contained in:
Llewellyn van der Merwe 2020-05-30 20:49:13 +02:00
parent f2b2228dd7
commit 70635ff6f0
Signed by untrusted user: Llewellyn
GPG Key ID: EFC0C720A240551C
15 changed files with 154 additions and 58 deletions

View File

@ -144,11 +144,11 @@ 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*: 29th May, 2020 + *Last Build*: 30th May, 2020
+ *Version*: 2.11.2 + *Version*: 2.11.2
+ *Copyright*: Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 - 2020 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*: **282456** + *Line count*: **282524**
+ *Field count*: **1522** + *Field count*: **1522**
+ *File count*: **1785** + *File count*: **1785**
+ *Folder count*: **295** + *Folder count*: **295**

View File

@ -144,11 +144,11 @@ 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*: 29th May, 2020 + *Last Build*: 30th May, 2020
+ *Version*: 2.11.2 + *Version*: 2.11.2
+ *Copyright*: Copyright (C) 2015 - 2020 Vast Development Method. All rights reserved. + *Copyright*: Copyright (C) 2015 - 2020 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*: **282456** + *Line count*: **282524**
+ *Field count*: **1522** + *Field count*: **1522**
+ *File count*: **1785** + *File count*: **1785**
+ *Folder count*: **295** + *Folder count*: **295**

View File

@ -4112,7 +4112,7 @@ class Fields extends Structure
{ {
$this->setScriptMediaSwitch[$typeName] = $typeName; $this->setScriptMediaSwitch[$typeName] = $typeName;
} }
// setup gategory for this view // setup category for this view
if ($dbSwitch && $typeName === 'category') if ($dbSwitch && $typeName === 'category')
{ {
if (isset($this->catOtherName[$view_name_list]) if (isset($this->catOtherName[$view_name_list])
@ -4134,13 +4134,37 @@ class Fields extends Structure
$field['settings']->xml, 'extension="', '"' $field['settings']->xml, 'extension="', '"'
), $this->placeholders ), $this->placeholders
); );
// if they left out the extention for some reason // if they left out the extension for some reason
if (!ComponentbuilderHelper::checkString($_extension)) if (!ComponentbuilderHelper::checkString($_extension))
{ {
$_extension = 'com_' . $this->componentCodeName . '.' $_extension = 'com_' . $this->componentCodeName . '.'
. $otherView; . $otherView;
} }
// load the category builder // check the context (does our target match)
if (strpos($_extension, '.') !== false)
{
$target_view = trim(explode('.', $_extension)[1]);
// from my understanding the target extension view and the otherView must align
// so I will here check that it does, and if not raise an error message to fix this
if ($target_view !== $otherView)
{
$target_extension = trim(explode('.', $_extension)[0]);
$correction = $target_extension . '.' . $otherView;
$this->app->enqueueMessage(
JText::sprintf('<hr /><h3>Category targeting view mismatch</h3>
<a>The <a href="index.php?option=com_componentbuilder&view=fields&task=field.edit&id=%s" target="_blank" title="open field">
category field</a> in <b>(%s) admin view</b> has a mismatching target view.
<br />To correct the mismatch, the <b>extension</b> value <code>%s</code> in the <a href="index.php?option=com_componentbuilder&view=fields&task=field.edit&id=%s" target="_blank" title="open category field">
field</a> must be changed to <code>%s</code>
for <a href="https://github.com/vdm-io/Joomla-Component-Builder/issues/561" target="_blank" title="view issue on gitHub">
best category integration with Joomla</a>.
<br /><b>Please watch <a href="https://youtu.be/R4WQgcu6Xns" target="_blank" title="very important info on the topic">
this tutorial</a> before proceeding!!!</b>,
<a href="https://gist.github.com/Llewellynvdm/e053dc39ae3b2bf769c76a3e62c75b95" target="_blank" title="first watch the tutorial to understand how to use this code">code fix</a></p>', $field['field'], $view_name_single, $_extension, $field['field'], $correction), 'Error'
);
}
}
// load the category builder - TODO must move all to single view
$this->categoryBuilder[$view_name_list] = array('code' => $name, $this->categoryBuilder[$view_name_list] = array('code' => $name,
'name' => $listLangName, 'name' => $listLangName,
'extension' => $_extension); 'extension' => $_extension);

View File

@ -8476,19 +8476,21 @@ class Interpretation extends Fields
public function getCategoryContentType($view, $views, $component) public function getCategoryContentType($view, $views, $component)
{ {
// get the other view
$otherView = $this->catCodeBuilder[$view]['view'];
$category = $this->catCodeBuilder[$view]['code']; $category = $this->catCodeBuilder[$view]['code'];
$Component = ComponentbuilderHelper::safeString($component, 'F'); $Component = ComponentbuilderHelper::safeString($component, 'F');
$View = ComponentbuilderHelper::safeString($view, 'F'); $View = ComponentbuilderHelper::safeString($view, 'F');
// build uninstall script for content types // build uninstall script for content types
$this->uninstallScriptBuilder[$View . ' ' . $category] = 'com_' $this->uninstallScriptBuilder[$View . ' ' . $category] = 'com_'
. $component . '.' . $views . '.category'; . $component . '.' . $otherView . '.category';
$this->uninstallScriptContent[$View . ' ' . $category] = $View . ' ' $this->uninstallScriptContent[$View . ' ' . $category] = $View . ' '
. $category; . $category;
// set the title // set the title
$array['type_title'] = $Component . ' ' . $View . ' ' $array['type_title'] = $Component . ' ' . $View . ' '
. ComponentbuilderHelper::safeString($category, 'F'); . ComponentbuilderHelper::safeString($category, 'F');
// set the alias // set the alias
$array['type_alias'] = 'com_' . $component . '.' . $views . '.category'; $array['type_alias'] = 'com_' . $component . '.' . $otherView . '.category';
// set the table // set the table
$array['table'] $array['table']
= '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}'; = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}';
@ -11450,13 +11452,10 @@ class Interpretation extends Fields
// if to be linked // if to be linked
if ($item['type'] === 'category' && !$item['title']) if ($item['type'] === 'category' && !$item['title'])
{ {
// get the other view
$otherViews = $this->catCodeBuilder[$viewName_single]['views'];
// return the link to category // return the link to category
return 'index.php?option=com_categories&task=category.edit&id=<?php echo (int)$item->' return 'index.php?option=com_categories&task=category.edit&id=<?php echo (int)$item->'
. $item['code'] . '; ?>&extension=com_' . $item['code'] . '; ?>&extension='
. $this->componentCodeName . '.' . $otherViews; . $this->categoryBuilder[$viewName_list]['extension'];
} }
elseif ($item['type'] === 'user' && !$item['title']) elseif ($item['type'] === 'user' && !$item['title'])
{ {
@ -11517,11 +11516,10 @@ class Interpretation extends Fields
if ($item['type'] === 'category' && !$item['title']) if ($item['type'] === 'category' && !$item['title'])
{ {
// get the other view // get the other view
$otherViews = $this->catCodeBuilder[$viewName_single]['views']; $otherView = $this->catCodeBuilder[$viewName_single]['view'];
// return the authority to category // return the authority to category
return $user . "->authorise('core.edit', 'com_" return $user . "->authorise('core.edit', 'com_"
. $this->componentCodeName . "." . $otherViews . $this->componentCodeName . "." . $otherView
. ".category.' . (int)\$item->" . $item['code'] . ")"; . ".category.' . (int)\$item->" . $item['code'] . ")";
} }
elseif ($item['type'] === 'user' && !$item['title']) elseif ($item['type'] === 'user' && !$item['title'])
@ -17459,6 +17457,10 @@ class Interpretation extends Fields
$otherViews = $viewName_list; $otherViews = $viewName_list;
$otherView = $viewName_single; $otherView = $viewName_single;
} }
// set the OtherView value
$this->fileContentDynamic['category' . $otherView][$this->hhh
. 'otherview' . $this->hhh]
= $otherView;
// load the category helper details in not already loaded // load the category helper details in not already loaded
if (!isset( if (!isset(
$this->fileContentDynamic['category' . $otherView][$this->hhh $this->fileContentDynamic['category' . $otherView][$this->hhh
@ -17593,7 +17595,7 @@ class Interpretation extends Fields
. " If the category has been passed in the URL check it."; . " If the category has been passed in the URL check it.";
$allow[] = $this->_t(3) $allow[] = $this->_t(3)
. "\$allow = \$user->authorise('core.create', \$this->option . '." . "\$allow = \$user->authorise('core.create', \$this->option . '."
. $otherViews . ".category.' . \$categoryId);"; . $otherView . ".category.' . \$categoryId);";
$allow[] = $this->_t(2) . "}"; $allow[] = $this->_t(2) . "}";
$allow[] = PHP_EOL . $this->_t(2) . "if (\$allow === null)"; $allow[] = PHP_EOL . $this->_t(2) . "if (\$allow === null)";
$allow[] = $this->_t(2) . "{"; $allow[] = $this->_t(2) . "{";
@ -18168,6 +18170,8 @@ class Interpretation extends Fields
) . " Check for existing item."; ) . " Check for existing item.";
$getForm[] = $this->_t(2) . "//" . $this->setLine(__LINE__) $getForm[] = $this->_t(2) . "//" . $this->setLine(__LINE__)
. " Modify the form based on Edit State access controls."; . " Modify the form based on Edit State access controls.";
// get the other view
$otherView = $this->catCodeBuilder[$viewName_single]['view'];
// check if the item has permissions. // check if the item has permissions.
if ($coreLoad && isset($core['core.edit.state']) if ($coreLoad && isset($core['core.edit.state'])
&& isset($this->permissionBuilder[$core['core.edit.state']]) && isset($this->permissionBuilder[$core['core.edit.state']])
@ -18185,7 +18189,7 @@ class Interpretation extends Fields
. $viewName_single . ".' . (int) \$id))"; . $viewName_single . ".' . (int) \$id))";
$getForm[] = $this->_t(3) $getForm[] = $this->_t(3)
. "|| (isset(\$catid) && \$catid != 0 && !\$user->authorise('core.edit.state', 'com_" . "|| (isset(\$catid) && \$catid != 0 && !\$user->authorise('core.edit.state', 'com_"
. $component . "." . $viewName_list . $component . "." . $otherView
. ".category.' . (int) \$catid))"; . ".category.' . (int) \$catid))";
$getForm[] = $this->_t(3) $getForm[] = $this->_t(3)
. "|| (\$id == 0 && !\$user->authorise('" . "|| (\$id == 0 && !\$user->authorise('"
@ -18199,7 +18203,7 @@ class Interpretation extends Fields
. $component . "." . $viewName_single . ".' . (int) \$id))"; . $component . "." . $viewName_single . ".' . (int) \$id))";
$getForm[] = $this->_t(3) $getForm[] = $this->_t(3)
. "|| (isset(\$catid) && \$catid != 0 && !\$user->authorise('core.edit.state', 'com_" . "|| (isset(\$catid) && \$catid != 0 && !\$user->authorise('core.edit.state', 'com_"
. $component . "." . $viewName_list . $component . "." . $otherView
. ".category.' . (int) \$catid))"; . ".category.' . (int) \$catid))";
$getForm[] = $this->_t(3) $getForm[] = $this->_t(3)
. "|| (\$id == 0 && !\$user->authorise('core.edit.state', 'com_" . "|| (\$id == 0 && !\$user->authorise('core.edit.state', 'com_"
@ -18728,7 +18732,7 @@ class Interpretation extends Fields
$allow[] = PHP_EOL . $this->_t(3) . "\$user = JFactory::getUser();"; $allow[] = PHP_EOL . $this->_t(3) . "\$user = JFactory::getUser();";
$allow[] = $this->_t(3) $allow[] = $this->_t(3)
. "\$allow = \$user->authorise('core.delete', 'com_" . "\$allow = \$user->authorise('core.delete', 'com_"
. $component . "." . $otherViews . $component . "." . $otherView
. ".category.' . (int) \$record->catid);"; . ".category.' . (int) \$record->catid);";
// check if the item has permissions. // check if the item has permissions.
if ($coreLoad if ($coreLoad
@ -18882,7 +18886,7 @@ class Interpretation extends Fields
$allow[] = $this->_t(2) . "{"; $allow[] = $this->_t(2) . "{";
$allow[] = $this->_t(3) $allow[] = $this->_t(3)
. "\$catpermission = \$user->authorise('core.edit.state', 'com_" . "\$catpermission = \$user->authorise('core.edit.state', 'com_"
. $component . "." . $otherViews . $component . "." . $otherView
. ".category.' . (int) \$record->catid);"; . ".category.' . (int) \$record->catid);";
$allow[] = $this->_t(3) $allow[] = $this->_t(3)
. "if (!\$catpermission && !is_null(\$catpermission))"; . "if (!\$catpermission && !is_null(\$catpermission))";

View File

@ -6033,12 +6033,12 @@ abstract class ComponentbuilderHelper
if ($user->authorise('field.access', 'com_componentbuilder') && $user->authorise('field.submenu', 'com_componentbuilder')) if ($user->authorise('field.access', 'com_componentbuilder') && $user->authorise('field.submenu', 'com_componentbuilder'))
{ {
JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_FIELDS'), 'index.php?option=com_componentbuilder&view=fields', $submenu === 'fields'); JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_FIELDS'), 'index.php?option=com_componentbuilder&view=fields', $submenu === 'fields');
JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_FIELD_FIELDS_CATEGORIES'), 'index.php?option=com_categories&view=categories&extension=com_componentbuilder.fields', $submenu === 'categories.fields'); JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_FIELD_FIELDS_CATEGORIES'), 'index.php?option=com_categories&view=categories&extension=com_componentbuilder.field', $submenu === 'categories.field');
} }
if ($user->authorise('fieldtype.access', 'com_componentbuilder') && $user->authorise('fieldtype.submenu', 'com_componentbuilder')) if ($user->authorise('fieldtype.access', 'com_componentbuilder') && $user->authorise('fieldtype.submenu', 'com_componentbuilder'))
{ {
JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_FIELDTYPES'), 'index.php?option=com_componentbuilder&view=fieldtypes', $submenu === 'fieldtypes'); JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_SUBMENU_FIELDTYPES'), 'index.php?option=com_componentbuilder&view=fieldtypes', $submenu === 'fieldtypes');
JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_FIELDTYPE_FIELDTYPES_CATEGORIES'), 'index.php?option=com_categories&view=categories&extension=com_componentbuilder.fieldtypes', $submenu === 'categories.fieldtypes'); JHtmlSidebar::addEntry(JText::_('COM_COMPONENTBUILDER_FIELDTYPE_FIELDTYPES_CATEGORIES'), 'index.php?option=com_categories&view=categories&extension=com_componentbuilder.fieldtype', $submenu === 'categories.fieldtype');
} }
if ($user->authorise('language_translation.access', 'com_componentbuilder') && $user->authorise('language_translation.submenu', 'com_componentbuilder')) if ($user->authorise('language_translation.access', 'com_componentbuilder') && $user->authorise('language_translation.submenu', 'com_componentbuilder'))
{ {

View File

@ -118,8 +118,8 @@ $can = ComponentbuilderHelper::getActions('field');
<?php echo JText::_($item->store); ?> <?php echo JText::_($item->store); ?>
</td> </td>
<td> <td>
<?php if ($user->authorise('core.edit', 'com_componentbuilder.fields.category.' . (int)$item->catid)): ?> <?php if ($user->authorise('core.edit', 'com_componentbuilder.field.category.' . (int)$item->catid)): ?>
<a href="index.php?option=com_categories&task=category.edit&id=<?php echo (int)$item->catid; ?>&extension=com_componentbuilder.fields"><?php echo $displayData->escape($item->category_title); ?></a> <a href="index.php?option=com_categories&task=category.edit&id=<?php echo (int)$item->catid; ?>&extension=com_componentbuilder.field"><?php echo $displayData->escape($item->category_title); ?></a>
<?php else: ?> <?php else: ?>
<?php echo $displayData->escape($item->category_title); ?> <?php echo $displayData->escape($item->category_title); ?>
<?php endif; ?> <?php endif; ?>

View File

@ -227,8 +227,7 @@
type="category" type="category"
name="catid" name="catid"
label="COM_COMPONENTBUILDER_FIELD_CATID_LABEL" label="COM_COMPONENTBUILDER_FIELD_CATID_LABEL"
extension="com_componentbuilder.fields" extension="com_componentbuilder.field"
default=""
description="COM_COMPONENTBUILDER_FIELD_CATID_DESCRIPTION" description="COM_COMPONENTBUILDER_FIELD_CATID_DESCRIPTION"
class="inputbox" class="inputbox"
/> />

View File

@ -449,7 +449,7 @@
type="category" type="category"
name="catid" name="catid"
label="COM_COMPONENTBUILDER_FIELDTYPE_CATID_LABEL" label="COM_COMPONENTBUILDER_FIELDTYPE_CATID_LABEL"
extension="com_componentbuilder.fieldtypes" extension="com_componentbuilder.fieldtype"
default="" default=""
description="COM_COMPONENTBUILDER_FIELDTYPE_CATID_DESCRIPTION" description="COM_COMPONENTBUILDER_FIELDTYPE_CATID_DESCRIPTION"
class="inputbox" class="inputbox"

View File

@ -95,8 +95,8 @@ $edit = "index.php?option=com_componentbuilder&view=fields&task=field.edit";
</td> </td>
<td class="nowrap"> <td class="nowrap">
<div class="name"> <div class="name">
<?php if ($this->user->authorise('core.edit', 'com_componentbuilder.fields.category.' . (int)$item->catid)): ?> <?php if ($this->user->authorise('core.edit', 'com_componentbuilder.field.category.' . (int)$item->catid)): ?>
<a href="index.php?option=com_categories&task=category.edit&id=<?php echo (int)$item->catid; ?>&extension=com_componentbuilder.fields"><?php echo $this->escape($item->category_title); ?></a> <a href="index.php?option=com_categories&task=category.edit&id=<?php echo (int)$item->catid; ?>&extension=com_componentbuilder.field"><?php echo $this->escape($item->category_title); ?></a>
<?php else: ?> <?php else: ?>
<?php echo $this->escape($item->category_title); ?> <?php echo $this->escape($item->category_title); ?>
<?php endif; ?> <?php endif; ?>

View File

@ -196,7 +196,7 @@ class ComponentbuilderViewFields extends JViewLegacy
JHtmlSidebar::addFilter( JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_CATEGORY'), JText::_('JOPTION_SELECT_CATEGORY'),
'filter_category_id', 'filter_category_id',
JHtml::_('select.options', JHtml::_('category.options', 'com_componentbuilder.fields'), 'value', 'text', $this->state->get('filter.category_id')) JHtml::_('select.options', JHtml::_('category.options', 'com_componentbuilder.field'), 'value', 'text', $this->state->get('filter.category_id'))
); );
if ($this->canBatch && $this->canCreate && $this->canEdit) if ($this->canBatch && $this->canCreate && $this->canEdit)
@ -205,7 +205,7 @@ class ComponentbuilderViewFields extends JViewLegacy
JHtmlBatch_::addListSelection( JHtmlBatch_::addListSelection(
JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_CATEGORY'), JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_CATEGORY'),
'batch[category]', 'batch[category]',
JHtml::_('select.options', JHtml::_('category.options', 'com_componentbuilder.fields'), 'value', 'text') JHtml::_('select.options', JHtml::_('category.options', 'com_componentbuilder.field'), 'value', 'text')
); );
} }

View File

@ -77,8 +77,8 @@ $edit = "index.php?option=com_componentbuilder&view=fieldtypes&task=fieldtype.ed
</td> </td>
<td class="nowrap"> <td class="nowrap">
<div class="name"> <div class="name">
<?php if ($this->user->authorise('core.edit', 'com_componentbuilder.fieldtypes.category.' . (int)$item->catid)): ?> <?php if ($this->user->authorise('core.edit', 'com_componentbuilder.fieldtype.category.' . (int)$item->catid)): ?>
<a href="index.php?option=com_categories&task=category.edit&id=<?php echo (int)$item->catid; ?>&extension=com_componentbuilder.fieldtypes"><?php echo $this->escape($item->category_title); ?></a> <a href="index.php?option=com_categories&task=category.edit&id=<?php echo (int)$item->catid; ?>&extension=com_componentbuilder.fieldtype"><?php echo $this->escape($item->category_title); ?></a>
<?php else: ?> <?php else: ?>
<?php echo $this->escape($item->category_title); ?> <?php echo $this->escape($item->category_title); ?>
<?php endif; ?> <?php endif; ?>

View File

@ -191,7 +191,7 @@ class ComponentbuilderViewFieldtypes extends JViewLegacy
JHtmlSidebar::addFilter( JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_CATEGORY'), JText::_('JOPTION_SELECT_CATEGORY'),
'filter_category_id', 'filter_category_id',
JHtml::_('select.options', JHtml::_('category.options', 'com_componentbuilder.fieldtypes'), 'value', 'text', $this->state->get('filter.category_id')) JHtml::_('select.options', JHtml::_('category.options', 'com_componentbuilder.fieldtype'), 'value', 'text', $this->state->get('filter.category_id'))
); );
if ($this->canBatch && $this->canCreate && $this->canEdit) if ($this->canBatch && $this->canCreate && $this->canEdit)
@ -200,7 +200,7 @@ class ComponentbuilderViewFieldtypes extends JViewLegacy
JHtmlBatch_::addListSelection( JHtmlBatch_::addListSelection(
JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_CATEGORY'), JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_CATEGORY'),
'batch[category]', 'batch[category]',
JHtml::_('select.options', JHtml::_('category.options', 'com_componentbuilder.fieldtypes'), 'value', 'text') JHtml::_('select.options', JHtml::_('category.options', 'com_componentbuilder.fieldtype'), 'value', 'text')
); );
} }
} }

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>29th May, 2020</creationDate> <creationDate>30th May, 2020</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

@ -1516,7 +1516,7 @@ class com_componentbuilderInstallerScript
$query->select($db->quoteName('type_id')); $query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types')); $query->from($db->quoteName('#__content_types'));
// Where Field catid alias is found // Where Field catid alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.fields.category') ); $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.field.category') );
$db->setQuery($query); $db->setQuery($query);
// Execute query to see if alias is found // Execute query to see if alias is found
$db->execute(); $db->execute();
@ -1527,7 +1527,7 @@ class com_componentbuilderInstallerScript
// Since there are load the needed field_catid type ids // Since there are load the needed field_catid type ids
$field_catid_ids = $db->loadColumn(); $field_catid_ids = $db->loadColumn();
// Remove Field catid from the content type table // Remove Field catid from the content type table
$field_catid_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.fields.category') ); $field_catid_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.field.category') );
// Create a new query object. // Create a new query object.
$query = $db->getQuery(true); $query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types')); $query->delete($db->quoteName('#__content_types'));
@ -1538,11 +1538,11 @@ class com_componentbuilderInstallerScript
if ($field_catid_done) if ($field_catid_done)
{ {
// If succesfully remove Field catid add queued success message. // If succesfully remove Field catid add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.fields.category) type alias was removed from the <b>#__content_type</b> table')); $app->enqueueMessage(JText::_('The (com_componentbuilder.field.category) type alias was removed from the <b>#__content_type</b> table'));
} }
// Remove Field catid items from the contentitem tag map table // Remove Field catid items from the contentitem tag map table
$field_catid_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.fields.category') ); $field_catid_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.field.category') );
// Create a new query object. // Create a new query object.
$query = $db->getQuery(true); $query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map')); $query->delete($db->quoteName('#__contentitem_tag_map'));
@ -1553,11 +1553,11 @@ class com_componentbuilderInstallerScript
if ($field_catid_done) if ($field_catid_done)
{ {
// If succesfully remove Field catid add queued success message. // If succesfully remove Field catid add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.fields.category) type alias was removed from the <b>#__contentitem_tag_map</b> table')); $app->enqueueMessage(JText::_('The (com_componentbuilder.field.category) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
} }
// Remove Field catid items from the ucm content table // Remove Field catid items from the ucm content table
$field_catid_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.fields.category') ); $field_catid_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.field.category') );
// Create a new query object. // Create a new query object.
$query = $db->getQuery(true); $query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content')); $query->delete($db->quoteName('#__ucm_content'));
@ -1568,7 +1568,7 @@ class com_componentbuilderInstallerScript
if ($field_catid_done) if ($field_catid_done)
{ {
// If succesfully remove Field catid add queued success message. // If succesfully remove Field catid add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.fields.category) type alias was removed from the <b>#__ucm_content</b> table')); $app->enqueueMessage(JText::_('The (com_componentbuilder.field.category) type alias was removed from the <b>#__ucm_content</b> table'));
} }
// Make sure that all the Field catid items are cleared from DB // Make sure that all the Field catid items are cleared from DB
@ -1688,7 +1688,7 @@ class com_componentbuilderInstallerScript
$query->select($db->quoteName('type_id')); $query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types')); $query->from($db->quoteName('#__content_types'));
// Where Fieldtype catid alias is found // Where Fieldtype catid alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.fieldtypes.category') ); $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.fieldtype.category') );
$db->setQuery($query); $db->setQuery($query);
// Execute query to see if alias is found // Execute query to see if alias is found
$db->execute(); $db->execute();
@ -1699,7 +1699,7 @@ class com_componentbuilderInstallerScript
// Since there are load the needed fieldtype_catid type ids // Since there are load the needed fieldtype_catid type ids
$fieldtype_catid_ids = $db->loadColumn(); $fieldtype_catid_ids = $db->loadColumn();
// Remove Fieldtype catid from the content type table // Remove Fieldtype catid from the content type table
$fieldtype_catid_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.fieldtypes.category') ); $fieldtype_catid_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.fieldtype.category') );
// Create a new query object. // Create a new query object.
$query = $db->getQuery(true); $query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types')); $query->delete($db->quoteName('#__content_types'));
@ -1710,11 +1710,11 @@ class com_componentbuilderInstallerScript
if ($fieldtype_catid_done) if ($fieldtype_catid_done)
{ {
// If succesfully remove Fieldtype catid add queued success message. // If succesfully remove Fieldtype catid add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.fieldtypes.category) type alias was removed from the <b>#__content_type</b> table')); $app->enqueueMessage(JText::_('The (com_componentbuilder.fieldtype.category) type alias was removed from the <b>#__content_type</b> table'));
} }
// Remove Fieldtype catid items from the contentitem tag map table // Remove Fieldtype catid items from the contentitem tag map table
$fieldtype_catid_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.fieldtypes.category') ); $fieldtype_catid_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.fieldtype.category') );
// Create a new query object. // Create a new query object.
$query = $db->getQuery(true); $query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map')); $query->delete($db->quoteName('#__contentitem_tag_map'));
@ -1725,11 +1725,11 @@ class com_componentbuilderInstallerScript
if ($fieldtype_catid_done) if ($fieldtype_catid_done)
{ {
// If succesfully remove Fieldtype catid add queued success message. // If succesfully remove Fieldtype catid add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.fieldtypes.category) type alias was removed from the <b>#__contentitem_tag_map</b> table')); $app->enqueueMessage(JText::_('The (com_componentbuilder.fieldtype.category) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
} }
// Remove Fieldtype catid items from the ucm content table // Remove Fieldtype catid items from the ucm content table
$fieldtype_catid_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.fieldtypes.category') ); $fieldtype_catid_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.fieldtype.category') );
// Create a new query object. // Create a new query object.
$query = $db->getQuery(true); $query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content')); $query->delete($db->quoteName('#__ucm_content'));
@ -1740,7 +1740,7 @@ class com_componentbuilderInstallerScript
if ($fieldtype_catid_done) if ($fieldtype_catid_done)
{ {
// If succesfully remove Fieldtype catid add queued success message. // If succesfully remove Fieldtype catid add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.fieldtypes.category) type alias was removed from the <b>#__ucm_content</b> table')); $app->enqueueMessage(JText::_('The (com_componentbuilder.fieldtype.category) type alias was removed from the <b>#__ucm_content</b> table'));
} }
// Make sure that all the Fieldtype catid items are cleared from DB // Make sure that all the Fieldtype catid items are cleared from DB
@ -5890,6 +5890,75 @@ class com_componentbuilderInstallerScript
JFile::delete($wiki_menu); JFile::delete($wiki_menu);
} }
} }
// target version less then or equal to 2.11.2
if (count($this->JCBversion) == 3 && $this->JCBversion[0] <= 2 && ($this->JCBversion[1] < 11 || ($this->JCBversion[1] == 11 && $this->JCBversion[2] <= 2)))
{
// we need to make a database correction for the field categories and the fieldtype categories
$fix_categories = array(
'com_componentbuilder.fields' => 'com_componentbuilder.field',
'com_componentbuilder.fieldtypes' => 'com_componentbuilder.fieldtype'
);
// targeted tables (to fix all places categories are mapped into Joomla)
$fix_tables = array(
'content_types' => array(
'id' => 'type_id',
'key' => 'type_alias',
'suffix' => '.category'),
'contentitem_tag_map' => array(
'id' => 'type_id',
'key' => 'type_alias',
'suffix' => '.category'),
'ucm_content' => array(
'id' => 'core_content_id',
'key' => 'core_type_alias',
'suffix' => '.category'),
'categories' => array(
'id' => 'id',
'key' => 'extension',
'suffix' => '')
);
// the script that does the work
foreach ($fix_categories as $fix => $category)
{
// loop over the targeted tables
foreach ($fix_tables as $_table => $_update)
{
// Create a new query object.
$query = $db->getQuery(true);
// get all type_ids
$query->select($db->quoteName($_update['id']));
$query->from($db->quoteName('#__' . $_table));
$query->where( $db->quoteName($_update['key']) . ' = ' . $db->quote($fix . $_update['suffix']));
// Reset the query using our newly populated query object.
$db->setQuery($query);
$db->execute();
if ($db->getNumRows())
{
// all these must be updated
$ids = $db->loadColumn();
// Fields to update.
$fields = array(
$db->quoteName($_update['key']) . ' = ' . $db->quote($category . $_update['suffix'])
);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName($_update['id']) . ' IN (' . implode(', ', $ids) . ')'
);
$query->update($db->quoteName('#__' . $_table))->set($fields)->where($conditions);
$db->setQuery($query);
$result = $db->execute();
// on success
if ($result)
{
$app->enqueueMessage("<p>Updated <b>#__$_table - " . $_update['key'] . "</b> from <b>$fix</b>" . $_update['suffix'] . " to <b>$category</b>" . $_update['suffix'] . "!</p>", 'Notice');
}
}
}
}
}
} }
} }
@ -6136,7 +6205,7 @@ class com_componentbuilderInstallerScript
// Create the field category content type object. // Create the field category content type object.
$field_category = new stdClass(); $field_category = new stdClass();
$field_category->type_title = 'Componentbuilder Field Catid'; $field_category->type_title = 'Componentbuilder Field Catid';
$field_category->type_alias = 'com_componentbuilder.fields.category'; $field_category->type_alias = 'com_componentbuilder.field.category';
$field_category->table = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}'; $field_category->table = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}';
$field_category->field_mappings = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}'; $field_category->field_mappings = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}';
$field_category->router = 'ComponentbuilderHelperRoute::getCategoryRoute'; $field_category->router = 'ComponentbuilderHelperRoute::getCategoryRoute';
@ -6160,7 +6229,7 @@ class com_componentbuilderInstallerScript
// Create the fieldtype category content type object. // Create the fieldtype category content type object.
$fieldtype_category = new stdClass(); $fieldtype_category = new stdClass();
$fieldtype_category->type_title = 'Componentbuilder Fieldtype Catid'; $fieldtype_category->type_title = 'Componentbuilder Fieldtype Catid';
$fieldtype_category->type_alias = 'com_componentbuilder.fieldtypes.category'; $fieldtype_category->type_alias = 'com_componentbuilder.fieldtype.category';
$fieldtype_category->table = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}'; $fieldtype_category->table = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}';
$fieldtype_category->field_mappings = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}'; $fieldtype_category->field_mappings = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}';
$fieldtype_category->router = 'ComponentbuilderHelperRoute::getCategoryRoute'; $fieldtype_category->router = 'ComponentbuilderHelperRoute::getCategoryRoute';
@ -7850,7 +7919,7 @@ class com_componentbuilderInstallerScript
// Create the field category content type object. // Create the field category content type object.
$field_category = new stdClass(); $field_category = new stdClass();
$field_category->type_title = 'Componentbuilder Field Catid'; $field_category->type_title = 'Componentbuilder Field Catid';
$field_category->type_alias = 'com_componentbuilder.fields.category'; $field_category->type_alias = 'com_componentbuilder.field.category';
$field_category->table = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}'; $field_category->table = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}';
$field_category->field_mappings = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}'; $field_category->field_mappings = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}';
$field_category->router = 'ComponentbuilderHelperRoute::getCategoryRoute'; $field_category->router = 'ComponentbuilderHelperRoute::getCategoryRoute';
@ -7908,7 +7977,7 @@ class com_componentbuilderInstallerScript
// Create the fieldtype category content type object. // Create the fieldtype category content type object.
$fieldtype_category = new stdClass(); $fieldtype_category = new stdClass();
$fieldtype_category->type_title = 'Componentbuilder Fieldtype Catid'; $fieldtype_category->type_title = 'Componentbuilder Fieldtype Catid';
$fieldtype_category->type_alias = 'com_componentbuilder.fieldtypes.category'; $fieldtype_category->type_alias = 'com_componentbuilder.fieldtype.category';
$fieldtype_category->table = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}'; $fieldtype_category->table = '{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}';
$fieldtype_category->field_mappings = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}'; $fieldtype_category->field_mappings = '{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias","core_created_time":"created_time","core_modified_time":"modified_time","core_body":"description", "core_hits":"hits","core_publish_up":"null","core_publish_down":"null","core_access":"access", "core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language", "core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey", "core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"}, "special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}';
$fieldtype_category->router = 'ComponentbuilderHelperRoute::getCategoryRoute'; $fieldtype_category->router = 'ComponentbuilderHelperRoute::getCategoryRoute';

View File

@ -85,8 +85,8 @@ abstract class ComponentbuilderHelperRoute
} }
$views = array( $views = array(
"com_componentbuilder.fields" => "field", "com_componentbuilder.field" => "field",
"com_componentbuilder.fieldtypes" => "fieldtype"); "com_componentbuilder.fieldtype" => "fieldtype");
$view = $views[$category->extension]; $view = $views[$category->extension];
if ($id < 1 || !($category instanceof JCategoryNode)) if ($id < 1 || !($category instanceof JCategoryNode))