Skip to content

Commit

Permalink
Merge branch '4.0-dev' into j4/cleanup/plg_system_cache
Browse files Browse the repository at this point in the history
  • Loading branch information
SharkyKZ committed Jan 13, 2020
2 parents 2e3ab6f + 5609d00 commit 9b215ba
Show file tree
Hide file tree
Showing 58 changed files with 1,071 additions and 491 deletions.
259 changes: 218 additions & 41 deletions administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -6104,6 +6104,68 @@ public function postflight($action, $installer)

$tableItem = new \Joomla\Component\Menus\Administrator\Table\MenuTable($db);

$contactItems = $this->contactItems($tableItem);
$finderItems = $this->finderItems($tableItem);

$menuItems = array_merge($contactItems, $finderItems);

foreach ($menuItems as $menuItem)
{
// Check an existing record
$keys = [
'menutype' => $menuItem['menutype'],
'type' => $menuItem['type'],
'title' => $menuItem['title'],
'parent_id' => $menuItem['parent_id'],
'client_id' => $menuItem['client_id'],
];

if ($tableItem->load($keys))
{
continue;
}

$newTableItem = new \Joomla\Component\Menus\Administrator\Table\MenuTable($db);

// Bind the data.
if (!$newTableItem->bind($menuItem))
{
return false;
}

$newTableItem->setLocation($menuItem['parent_id'], 'last-child');

// Check the data.
if (!$newTableItem->check())
{
return false;
}

// Store the data.
if (!$newTableItem->store())
{
return false;
}

// Rebuild the tree path.
if (!$newTableItem->rebuildPath($newTableItem->id))
{
return false;
}
}

return true;
}

/**
* Prepare the contact menu items
*
* @return array Menu items
*
* @since __DEPLOY_VERSION__
*/
private function contactItems(Table $tableItem): array
{
// Check for the Contact parent Id Menu Item
$keys = [
'menutype' => 'main',
Expand All @@ -6117,7 +6179,7 @@ public function postflight($action, $installer)

if (!$contactMenuitem)
{
return false;
return [];
}

$parentId = $tableItem->id;
Expand Down Expand Up @@ -6202,51 +6264,166 @@ public function postflight($action, $installer)
]
];

foreach ($menuItems as $menuItem)
{
// Check an existing record
$keys = [
'menutype' => $menuItem['menutype'],
'type' => $menuItem['type'],
'title' => $menuItem['title'],
'parent_id' => $menuItem['parent_id'],
'client_id' => $menuItem['client_id'],
];

if ($tableItem->load($keys))
{
continue;
}

$newTableItem = new \Joomla\Component\Menus\Administrator\Table\MenuTable($db);
return $menuItems;
}

// Bind the data.
if (!$newTableItem->bind($menuItem))
{
return false;
}
/**
* Prepare the finder menu items
*
* @return array Menu items
*
* @since __DEPLOY_VERSION__
*/
private function finderItems(Table $tableItem): array
{
// Check for the Finder parent Id Menu Item
$keys = [
'menutype' => 'main',
'type' => 'component',
'title' => 'com_finder',
'parent_id' => 1,
'client_id' => 1,
];

$newTableItem->setLocation($menuItem['parent_id'], 'last-child');
$finderMenuitem = $tableItem->load($keys);

// Check the data.
if (!$newTableItem->check())
{
return false;
}
if (!$finderMenuitem)
{
return [];
}

// Store the data.
if (!$newTableItem->store())
{
return false;
}
$parentId = $tableItem->id;
$componentId = ExtensionHelper::getExtensionRecord('com_finder')->extension_id;

// Rebuild the tree path.
if (!$newTableItem->rebuildPath($newTableItem->id))
{
return false;
}
}
// Add Finder Fields Menu Items.
$menuItems = [
[
'menutype' => 'main',
'title' => '-',
'alias' => microtime(true),
'note' => '',
'path' => '',
'link' => '#',
'type' => 'separator',
'published' => 1,
'parent_id' => $parentId,
'level' => 2,
'component_id' => $componentId,
'checked_out' => 0,
'checked_out_time' => null,
'browserNav' => 0,
'access' => 0,
'img' => '',
'template_style_id' => 0,
'params' => '{}',
'home' => 0,
'language' => '*',
'client_id' => 1,
'publish_up' => null,
'publish_down' => null,
],
[
'menutype' => 'main',
'title' => 'com_finder_index',
'alias' => 'Smart-Search-Index',
'note' => '',
'path' => 'Smart Search/Index',
'link' => 'index.php?option=com_finder&view=index',
'type' => 'component',
'published' => 1,
'parent_id' => $parentId,
'level' => 2,
'component_id' => $componentId,
'checked_out' => 0,
'checked_out_time' => null,
'browserNav' => 0,
'access' => 0,
'img' => '',
'template_style_id' => 0,
'params' => '{}',
'home' => 0,
'language' => '*',
'client_id' => 1,
'publish_up' => null,
'publish_down' => null,
],
[
'menutype' => 'main',
'title' => 'com_finder_maps',
'alias' => 'Smart-Search-Maps',
'note' => '',
'path' => 'Smart Search/Maps',
'link' => 'index.php?option=com_finder&view=maps',
'type' => 'component',
'published' => 1,
'parent_id' => $parentId,
'level' => 2,
'component_id' => $componentId,
'checked_out' => 0,
'checked_out_time' => null,
'browserNav' => 0,
'access' => 0,
'img' => '',
'template_style_id' => 0,
'params' => '{}',
'home' => 0,
'language' => '*',
'client_id' => 1,
'publish_up' => null,
'publish_down' => null,
],
[
'menutype' => 'main',
'title' => 'com_finder_filters',
'alias' => 'Smart-Search-Filters',
'note' => '',
'path' => 'Smart Search/Filters',
'link' => 'index.php?option=com_finder&view=filters',
'type' => 'component',
'published' => 1,
'parent_id' => $parentId,
'level' => 2,
'component_id' => $componentId,
'checked_out' => 0,
'checked_out_time' => null,
'browserNav' => 0,
'access' => 0,
'img' => '',
'template_style_id' => 0,
'params' => '{}',
'home' => 0,
'language' => '*',
'client_id' => 1,
'publish_up' => null,
'publish_down' => null,
],
[
'menutype' => 'main',
'title' => 'com_finder_searches',
'alias' => 'Smart-Search-Searches',
'note' => '',
'path' => 'Smart Search/Searches',
'link' => 'index.php?option=com_finder&view=searches',
'type' => 'component',
'published' => 1,
'parent_id' => $parentId,
'level' => 2,
'component_id' => $componentId,
'checked_out' => 0,
'checked_out_time' => null,
'browserNav' => 0,
'access' => 0,
'img' => '',
'template_style_id' => 0,
'params' => '{}',
'home' => 0,
'language' => '*',
'client_id' => 1,
'publish_up' => null,
'publish_down' => null,
]
];

return true;
return $menuItems;
}
}
34 changes: 0 additions & 34 deletions administrator/components/com_finder/Helper/FinderHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;

/**
* Helper class for Finder.
Expand All @@ -29,39 +28,6 @@ class FinderHelper
*/
public static $extension = 'com_finder';

/**
* Configure the Linkbar.
*
* @param string $vName The name of the active view.
*
* @return void
*
* @since 2.5
*/
public static function addSubmenu($vName)
{
\JHtmlSidebar::addEntry(
Text::_('COM_FINDER_SUBMENU_INDEX'),
'index.php?option=com_finder&view=index',
$vName === 'index'
);
\JHtmlSidebar::addEntry(
Text::_('COM_FINDER_SUBMENU_MAPS'),
'index.php?option=com_finder&view=maps',
$vName === 'maps'
);
\JHtmlSidebar::addEntry(
Text::_('COM_FINDER_SUBMENU_FILTERS'),
'index.php?option=com_finder&view=filters',
$vName === 'filters'
);
\JHtmlSidebar::addEntry(
Text::_('COM_FINDER_SUBMENU_SEARCHES'),
'index.php?option=com_finder&view=searches',
$vName === 'searches'
);
}

/**
* Gets the finder system plugin extension id.
*
Expand Down
13 changes: 0 additions & 13 deletions administrator/components/com_finder/View/Filters/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\Component\Finder\Administrator\Helper\FinderHelper;

/**
* Filters view class for Finder.
Expand All @@ -44,15 +43,6 @@ class HtmlView extends BaseHtmlView
*/
protected $pagination;

/**
* The HTML markup for the sidebar
*
* @var string
*
* @since 3.6.1
*/
protected $sidebar;

/**
* The model state
*
Expand Down Expand Up @@ -106,8 +96,6 @@ public function display($tpl = null)
$this->filterForm = $this->get('FilterForm');
$this->activeFilters = $this->get('ActiveFilters');

FinderHelper::addSubmenu('filters');

// Check for errors.
if (count($errors = $this->get('Errors')))
{
Expand All @@ -116,7 +104,6 @@ public function display($tpl = null)

// Configure the toolbar.
$this->addToolbar();
$this->sidebar = \JHtmlSidebar::render();

return parent::display($tpl);
}
Expand Down

0 comments on commit 9b215ba

Please sign in to comment.