Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
317 changes: 0 additions & 317 deletions administrator/components/com_admin/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -889,326 +889,9 @@ public function postflight($action, $installer)
// Update UCM content types.
$this->updateContentTypes();

$db = Factory::getDbo();
Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_menus/Table/');

$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 4.0.0
*/
private function contactItems(Table $tableItem): array
{
// Check for the Contact parent Id Menu Item
$keys = [
'menutype' => 'main',
'type' => 'component',
'title' => 'com_contact',
'parent_id' => 1,
'client_id' => 1,
];

$contactMenuitem = $tableItem->load($keys);

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

$parentId = $tableItem->id;
$componentId = ExtensionHelper::getExtensionRecord('com_fields', 'component')->extension_id;

// Add Contact 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' => null,
'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' => 'mod_menu_fields',
'alias' => 'Contact Custom Fields',
'note' => '',
'path' => 'contact/Custom Fields',
'link' => 'index.php?option=com_fields&context=com_contact.contact',
'type' => 'component',
'published' => 1,
'parent_id' => $parentId,
'level' => 2,
'component_id' => $componentId,
'checked_out' => null,
'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' => 'mod_menu_fields_group',
'alias' => 'Contact Custom Fields Group',
'note' => '',
'path' => 'contact/Custom Fields Group',
'link' => 'index.php?option=com_fields&view=groups&context=com_contact.contact',
'type' => 'component',
'published' => 1,
'parent_id' => $parentId,
'level' => 2,
'component_id' => $componentId,
'checked_out' => null,
'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 $menuItems;
}

/**
* Prepare the finder menu items
*
* @return array Menu items
*
* @since 4.0.0
*/
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,
];

$finderMenuitem = $tableItem->load($keys);

if (!$finderMenuitem) {
return [];
}

$parentId = $tableItem->id;
$componentId = ExtensionHelper::getExtensionRecord('com_finder', 'component')->extension_id;

// 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' => null,
'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' => null,
'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' => null,
'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' => null,
'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' => null,
'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 $menuItems;
}

/**
* Updates content type table classes.
*
Expand Down