Component-Builder/script.php

11236 lines
699 KiB
PHP
Raw Permalink Normal View History

2016-01-30 20:28:43 +00:00
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
2022-07-09 15:45:08 +00:00
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;
use Joomla\CMS\Installer\Adapter\ComponentAdapter;
use VDM\Joomla\FOF\Encrypt\AES;
use VDM\Joomla\Utilities\StringHelper;
use VDM\Joomla\Utilities\JsonHelper;
use VDM\Joomla\Utilities\ArrayHelper;
use VDM\Joomla\Utilities\GetHelper;
JHTML::_('bootstrap.renderModal');
/**
* Script File of Componentbuilder Component
*/
class com_componentbuilderInstallerScript
{
/**
* Constructor
*
* @param JAdapterInstance $parent The object responsible for running this script
*/
public function __construct(ComponentAdapter $parent) {}
/**
* Called on installation
*
* @param ComponentAdapter $parent The object responsible for running this script
*
* @return boolean True on success
*/
public function install(ComponentAdapter $parent) {}
/**
* Called on uninstallation
*
* @param ComponentAdapter $parent The object responsible for running this script
*/
public function uninstall(ComponentAdapter $parent)
2016-01-30 20:28:43 +00:00
{
// Get Application object
$app = JFactory::getApplication();
// Get The Database object
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Joomla_component alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_component') );
2016-01-30 20:28:43 +00:00
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$joomla_component_found = $db->getNumRows();
2016-01-30 20:28:43 +00:00
// Now check if there were any rows
if ($joomla_component_found)
2016-01-30 20:28:43 +00:00
{
// Since there are load the needed joomla_component type ids
$joomla_component_ids = $db->loadColumn();
// Remove Joomla_component from the content type table
$joomla_component_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_component') );
2016-01-30 20:28:43 +00:00
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($joomla_component_condition);
2016-01-30 20:28:43 +00:00
$db->setQuery($query);
// Execute the query to remove Joomla_component items
$joomla_component_done = $db->execute();
if ($joomla_component_done)
2016-01-30 20:28:43 +00:00
{
// If successfully remove Joomla_component add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_component) type alias was removed from the <b>#__content_type</b> table'));
2016-01-30 20:28:43 +00:00
}
// Remove Joomla_component items from the contentitem tag map table
$joomla_component_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_component') );
2016-01-30 20:28:43 +00:00
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($joomla_component_condition);
2016-01-30 20:28:43 +00:00
$db->setQuery($query);
// Execute the query to remove Joomla_component items
$joomla_component_done = $db->execute();
if ($joomla_component_done)
2016-01-30 20:28:43 +00:00
{
// If successfully remove Joomla_component add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_component) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
2016-01-30 20:28:43 +00:00
}
// Remove Joomla_component items from the ucm content table
$joomla_component_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.joomla_component') );
2016-01-30 20:28:43 +00:00
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($joomla_component_condition);
2016-01-30 20:28:43 +00:00
$db->setQuery($query);
// Execute the query to remove Joomla_component items
$joomla_component_done = $db->execute();
if ($joomla_component_done)
2016-01-30 20:28:43 +00:00
{
// If successfully removed Joomla_component add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_component) type alias was removed from the <b>#__ucm_content</b> table'));
2016-01-30 20:28:43 +00:00
}
// Make sure that all the Joomla_component items are cleared from DB
foreach ($joomla_component_ids as $joomla_component_id)
2016-01-30 20:28:43 +00:00
{
// Remove Joomla_component items from the ucm base table
$joomla_component_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_component_id);
2016-01-30 20:28:43 +00:00
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($joomla_component_condition);
2016-01-30 20:28:43 +00:00
$db->setQuery($query);
// Execute the query to remove Joomla_component items
2016-01-30 20:28:43 +00:00
$db->execute();
// Remove Joomla_component items from the ucm history table
$joomla_component_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_component_id);
2016-01-30 20:28:43 +00:00
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($joomla_component_condition);
2016-01-30 20:28:43 +00:00
$db->setQuery($query);
// Execute the query to remove Joomla_component items
2016-01-30 20:28:43 +00:00
$db->execute();
}
}
2019-12-03 02:17:35 +00:00
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Joomla_module alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_module') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$joomla_module_found = $db->getNumRows();
// Now check if there were any rows
if ($joomla_module_found)
{
// Since there are load the needed joomla_module type ids
$joomla_module_ids = $db->loadColumn();
// Remove Joomla_module from the content type table
$joomla_module_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_module') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($joomla_module_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_module items
$joomla_module_done = $db->execute();
if ($joomla_module_done)
{
// If successfully remove Joomla_module add queued success message.
2019-12-03 02:17:35 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_module) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Joomla_module items from the contentitem tag map table
$joomla_module_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_module') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($joomla_module_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_module items
$joomla_module_done = $db->execute();
if ($joomla_module_done)
{
// If successfully remove Joomla_module add queued success message.
2019-12-03 02:17:35 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_module) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Joomla_module items from the ucm content table
$joomla_module_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.joomla_module') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($joomla_module_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_module items
$joomla_module_done = $db->execute();
if ($joomla_module_done)
{
// If successfully removed Joomla_module add queued success message.
2019-12-03 02:17:35 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_module) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Joomla_module items are cleared from DB
foreach ($joomla_module_ids as $joomla_module_id)
{
// Remove Joomla_module items from the ucm base table
$joomla_module_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_module_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($joomla_module_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_module items
$db->execute();
// Remove Joomla_module items from the ucm history table
$joomla_module_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_module_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($joomla_module_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_module items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Joomla_plugin alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_plugin') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$joomla_plugin_found = $db->getNumRows();
// Now check if there were any rows
if ($joomla_plugin_found)
{
// Since there are load the needed joomla_plugin type ids
$joomla_plugin_ids = $db->loadColumn();
// Remove Joomla_plugin from the content type table
$joomla_plugin_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_plugin') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($joomla_plugin_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_plugin items
$joomla_plugin_done = $db->execute();
if ($joomla_plugin_done)
{
// If successfully remove Joomla_plugin add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_plugin) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Joomla_plugin items from the contentitem tag map table
$joomla_plugin_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.joomla_plugin') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($joomla_plugin_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_plugin items
$joomla_plugin_done = $db->execute();
if ($joomla_plugin_done)
{
// If successfully remove Joomla_plugin add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_plugin) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Joomla_plugin items from the ucm content table
$joomla_plugin_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.joomla_plugin') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($joomla_plugin_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_plugin items
$joomla_plugin_done = $db->execute();
if ($joomla_plugin_done)
{
// If successfully removed Joomla_plugin add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.joomla_plugin) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Joomla_plugin items are cleared from DB
foreach ($joomla_plugin_ids as $joomla_plugin_id)
{
// Remove Joomla_plugin items from the ucm base table
$joomla_plugin_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_plugin_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($joomla_plugin_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_plugin items
$db->execute();
// Remove Joomla_plugin items from the ucm history table
$joomla_plugin_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $joomla_plugin_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($joomla_plugin_condition);
$db->setQuery($query);
// Execute the query to remove Joomla_plugin items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Power alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.power') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$power_found = $db->getNumRows();
// Now check if there were any rows
if ($power_found)
{
// Since there are load the needed power type ids
$power_ids = $db->loadColumn();
// Remove Power from the content type table
$power_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.power') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($power_condition);
$db->setQuery($query);
// Execute the query to remove Power items
$power_done = $db->execute();
if ($power_done)
{
// If successfully remove Power add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.power) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Power items from the contentitem tag map table
$power_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.power') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($power_condition);
$db->setQuery($query);
// Execute the query to remove Power items
$power_done = $db->execute();
if ($power_done)
{
// If successfully remove Power add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.power) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Power items from the ucm content table
$power_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.power') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($power_condition);
$db->setQuery($query);
// Execute the query to remove Power items
$power_done = $db->execute();
if ($power_done)
{
// If successfully removed Power add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.power) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Power items are cleared from DB
foreach ($power_ids as $power_id)
{
// Remove Power items from the ucm base table
$power_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $power_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($power_condition);
$db->setQuery($query);
// Execute the query to remove Power items
$db->execute();
// Remove Power items from the ucm history table
$power_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $power_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($power_condition);
$db->setQuery($query);
// Execute the query to remove Power items
$db->execute();
}
}
2016-01-30 20:28:43 +00:00
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Admin_view alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_view') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$admin_view_found = $db->getNumRows();
// Now check if there were any rows
if ($admin_view_found)
{
// Since there are load the needed admin_view type ids
$admin_view_ids = $db->loadColumn();
// Remove Admin_view from the content type table
$admin_view_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_view') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Admin_view items
$admin_view_done = $db->execute();
if ($admin_view_done)
2016-01-30 20:28:43 +00:00
{
// If successfully remove Admin_view add queued success message.
2016-01-30 20:28:43 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.admin_view) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Admin_view items from the contentitem tag map table
$admin_view_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.admin_view') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Admin_view items
$admin_view_done = $db->execute();
if ($admin_view_done)
2016-01-30 20:28:43 +00:00
{
// If successfully remove Admin_view add queued success message.
2016-01-30 20:28:43 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.admin_view) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Admin_view items from the ucm content table
$admin_view_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.admin_view') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Admin_view items
$admin_view_done = $db->execute();
if ($admin_view_done)
2016-01-30 20:28:43 +00:00
{
// If successfully removed Admin_view add queued success message.
2016-01-30 20:28:43 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.admin_view) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Admin_view items are cleared from DB
foreach ($admin_view_ids as $admin_view_id)
{
// Remove Admin_view items from the ucm base table
$admin_view_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $admin_view_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Admin_view items
$db->execute();
// Remove Admin_view items from the ucm history table
$admin_view_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $admin_view_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Admin_view items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Custom_admin_view alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.custom_admin_view') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$custom_admin_view_found = $db->getNumRows();
// Now check if there were any rows
if ($custom_admin_view_found)
{
// Since there are load the needed custom_admin_view type ids
$custom_admin_view_ids = $db->loadColumn();
// Remove Custom_admin_view from the content type table
$custom_admin_view_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.custom_admin_view') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($custom_admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Custom_admin_view items
$custom_admin_view_done = $db->execute();
if ($custom_admin_view_done)
2016-01-30 20:28:43 +00:00
{
// If successfully remove Custom_admin_view add queued success message.
2016-01-30 20:28:43 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.custom_admin_view) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Custom_admin_view items from the contentitem tag map table
$custom_admin_view_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.custom_admin_view') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($custom_admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Custom_admin_view items
$custom_admin_view_done = $db->execute();
if ($custom_admin_view_done)
2016-01-30 20:28:43 +00:00
{
// If successfully remove Custom_admin_view add queued success message.
2016-01-30 20:28:43 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.custom_admin_view) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Custom_admin_view items from the ucm content table
$custom_admin_view_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.custom_admin_view') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($custom_admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Custom_admin_view items
$custom_admin_view_done = $db->execute();
if ($custom_admin_view_done)
2016-01-30 20:28:43 +00:00
{
// If successfully removed Custom_admin_view add queued success message.
2016-01-30 20:28:43 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.custom_admin_view) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Custom_admin_view items are cleared from DB
foreach ($custom_admin_view_ids as $custom_admin_view_id)
{
// Remove Custom_admin_view items from the ucm base table
$custom_admin_view_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $custom_admin_view_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($custom_admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Custom_admin_view items
$db->execute();
// Remove Custom_admin_view items from the ucm history table
$custom_admin_view_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $custom_admin_view_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($custom_admin_view_condition);
$db->setQuery($query);
// Execute the query to remove Custom_admin_view items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Site_view alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.site_view') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$site_view_found = $db->getNumRows();
// Now check if there were any rows
if ($site_view_found)
{
// Since there are load the needed site_view type ids
$site_view_ids = $db->loadColumn();
// Remove Site_view from the content type table
$site_view_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.site_view') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($site_view_condition);
$db->setQuery($query);
// Execute the query to remove Site_view items
$site_view_done = $db->execute();
if ($site_view_done)
2016-01-30 20:28:43 +00:00
{
// If successfully remove Site_view add queued success message.
2016-01-30 20:28:43 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.site_view) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Site_view items from the contentitem tag map table
$site_view_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.site_view') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($site_view_condition);
$db->setQuery($query);
// Execute the query to remove Site_view items
$site_view_done = $db->execute();
if ($site_view_done)
2016-01-30 20:28:43 +00:00
{
// If successfully remove Site_view add queued success message.
2016-01-30 20:28:43 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.site_view) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Site_view items from the ucm content table
$site_view_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.site_view') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($site_view_condition);
$db->setQuery($query);
// Execute the query to remove Site_view items
$site_view_done = $db->execute();
if ($site_view_done)
2016-01-30 20:28:43 +00:00
{
// If successfully removed Site_view add queued success message.
2016-01-30 20:28:43 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.site_view) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Site_view items are cleared from DB
foreach ($site_view_ids as $site_view_id)
{
// Remove Site_view items from the ucm base table
$site_view_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $site_view_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($site_view_condition);
$db->setQuery($query);
// Execute the query to remove Site_view items
$db->execute();
// Remove Site_view items from the ucm history table
$site_view_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $site_view_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($site_view_condition);
$db->setQuery($query);
// Execute the query to remove Site_view items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Template alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.template') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$template_found = $db->getNumRows();
// Now check if there were any rows
if ($template_found)
{
// Since there are load the needed template type ids
$template_ids = $db->loadColumn();
// Remove Template from the content type table
$template_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.template') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($template_condition);
$db->setQuery($query);
// Execute the query to remove Template items
$template_done = $db->execute();
if ($template_done)
2016-01-30 20:28:43 +00:00
{
// If successfully remove Template add queued success message.
2016-01-30 20:28:43 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.template) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Template items from the contentitem tag map table
$template_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.template') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($template_condition);
$db->setQuery($query);
// Execute the query to remove Template items
$template_done = $db->execute();
if ($template_done)
2016-01-30 20:28:43 +00:00
{
// If successfully remove Template add queued success message.
2016-01-30 20:28:43 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.template) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Template items from the ucm content table
$template_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.template') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($template_condition);
$db->setQuery($query);
// Execute the query to remove Template items
$template_done = $db->execute();
if ($template_done)
2016-01-30 20:28:43 +00:00
{
// If successfully removed Template add queued success message.
2016-01-30 20:28:43 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.template) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Template items are cleared from DB
foreach ($template_ids as $template_id)
{
// Remove Template items from the ucm base table
$template_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $template_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($template_condition);
$db->setQuery($query);
// Execute the query to remove Template items
$db->execute();
// Remove Template items from the ucm history table
$template_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $template_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($template_condition);
$db->setQuery($query);
// Execute the query to remove Template items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Layout alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.layout') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$layout_found = $db->getNumRows();
// Now check if there were any rows
if ($layout_found)
{
// Since there are load the needed layout type ids
$layout_ids = $db->loadColumn();
// Remove Layout from the content type table
$layout_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.layout') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($layout_condition);
$db->setQuery($query);
// Execute the query to remove Layout items
$layout_done = $db->execute();
if ($layout_done)
2016-01-30 20:28:43 +00:00
{
// If successfully remove Layout add queued success message.
2016-01-30 20:28:43 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.layout) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Layout items from the contentitem tag map table
$layout_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.layout') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($layout_condition);
$db->setQuery($query);
// Execute the query to remove Layout items
$layout_done = $db->execute();
if ($layout_done)
2016-01-30 20:28:43 +00:00
{
// If successfully remove Layout add queued success message.
2016-01-30 20:28:43 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.layout) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Layout items from the ucm content table
$layout_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.layout') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($layout_condition);
$db->setQuery($query);
// Execute the query to remove Layout items
$layout_done = $db->execute();
if ($layout_done)
2016-01-30 20:28:43 +00:00
{
// If successfully removed Layout add queued success message.
2016-01-30 20:28:43 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.layout) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Layout items are cleared from DB
foreach ($layout_ids as $layout_id)
{
// Remove Layout items from the ucm base table
$layout_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $layout_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($layout_condition);
$db->setQuery($query);
// Execute the query to remove Layout items
$db->execute();
// Remove Layout items from the ucm history table
$layout_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $layout_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($layout_condition);
$db->setQuery($query);
// Execute the query to remove Layout items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Dynamic_get alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.dynamic_get') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$dynamic_get_found = $db->getNumRows();
// Now check if there were any rows
if ($dynamic_get_found)
{
// Since there are load the needed dynamic_get type ids
$dynamic_get_ids = $db->loadColumn();
// Remove Dynamic_get from the content type table
$dynamic_get_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.dynamic_get') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($dynamic_get_condition);
$db->setQuery($query);
// Execute the query to remove Dynamic_get items
$dynamic_get_done = $db->execute();
if ($dynamic_get_done)
2016-01-30 20:28:43 +00:00
{
// If successfully remove Dynamic_get add queued success message.
2016-01-30 20:28:43 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.dynamic_get) type alias was removed from the <b>#__content_type</b> table'));
}
// Remove Dynamic_get items from the contentitem tag map table
$dynamic_get_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.dynamic_get') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__contentitem_tag_map'));
$query->where($dynamic_get_condition);
$db->setQuery($query);
// Execute the query to remove Dynamic_get items
$dynamic_get_done = $db->execute();
if ($dynamic_get_done)
2016-01-30 20:28:43 +00:00
{
// If successfully remove Dynamic_get add queued success message.
2016-01-30 20:28:43 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.dynamic_get) type alias was removed from the <b>#__contentitem_tag_map</b> table'));
}
// Remove Dynamic_get items from the ucm content table
$dynamic_get_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_componentbuilder.dynamic_get') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_content'));
$query->where($dynamic_get_condition);
$db->setQuery($query);
// Execute the query to remove Dynamic_get items
$dynamic_get_done = $db->execute();
if ($dynamic_get_done)
2016-01-30 20:28:43 +00:00
{
// If successfully removed Dynamic_get add queued success message.
2016-01-30 20:28:43 +00:00
$app->enqueueMessage(JText::_('The (com_componentbuilder.dynamic_get) type alias was removed from the <b>#__ucm_content</b> table'));
}
// Make sure that all the Dynamic_get items are cleared from DB
foreach ($dynamic_get_ids as $dynamic_get_id)
{
// Remove Dynamic_get items from the ucm base table
$dynamic_get_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $dynamic_get_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_base'));
$query->where($dynamic_get_condition);
$db->setQuery($query);
// Execute the query to remove Dynamic_get items
$db->execute();
// Remove Dynamic_get items from the ucm history table
$dynamic_get_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $dynamic_get_id);
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__ucm_history'));
$query->where($dynamic_get_condition);
$db->setQuery($query);
// Execute the query to remove Dynamic_get items
$db->execute();
}
}
// Create a new query object.
$query = $db->getQuery(true);
// Select id from content type table
$query->select($db->quoteName('type_id'));
$query->from($db->quoteName('#__content_types'));
// Where Custom_code alias is found
$query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.custom_code') );
$db->setQuery($query);
// Execute query to see if alias is found
$db->execute();
$custom_code_found = $db->getNumRows();
// Now check if there were any rows
if ($custom_code_found)
{
// Since there are load the needed custom_code type ids
$custom_code_ids = $db->loadColumn();
// Remove Custom_code from the content type table
$custom_code_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_componentbuilder.custom_code') );
// Create a new query object.
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__content_types'));
$query->where($custom_code_condition);
$db->setQuery($query);
// Execute the query to remove Custom_code items
$custom_code_done = $db->execute();
if ($custom_code_done)
{
// If successfully remove Custom_code add queued success message.
$app->enqueueMessage(JText::_('The (com_componentbuilder.custom_code) type alias was removed from the <b>#__content_type</b> table'));
}