@copyright Copyright (C) 2015. All Rights Reserved @license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html ____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____ (_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _) .-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )( \____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__) /------------------------------------------------------------------------------------------------------*/ // No direct access to this file defined('_JEXEC') or die('Restricted access'); JHTML::_('behavior.modal'); /** * Script File of Demo Component */ class com_demoInstallerScript { /** * method to install the component * * @return void */ function install($parent) { } /** * method to uninstall the component * * @return void */ function uninstall($parent) { // Get Application object $app = JFactory::getApplication(); // Get The Database object $db = JFactory::getDbo(); // Create a new query object. $query = $db->getQuery(true); // Select ids from fields $query->select($db->quoteName('id')); $query->from($db->quoteName('#__fields')); // Where look context is found $query->where( $db->quoteName('context') . ' = '. $db->quote('com_demo.look') ); $db->setQuery($query); // Execute query to see if context is found $db->execute(); $look_found = $db->getNumRows(); // Now check if there were any rows if ($look_found) { // Since there are load the needed look field ids $look_field_ids = $db->loadColumn(); // Remove look from the field table $look_condition = array( $db->quoteName('context') . ' = '. $db->quote('com_demo.look') ); // Create a new query object. $query = $db->getQuery(true); $query->delete($db->quoteName('#__fields')); $query->where($look_condition); $db->setQuery($query); // Execute the query to remove look items $look_done = $db->execute(); if ($look_done) { // If succesfully remove look add queued success message. $app->enqueueMessage(JText::_('The fields with type (com_demo.look) context was removed from the #__fields table')); } // Also Remove look field values $look_condition = array( $db->quoteName('field_id') . ' IN ('. implode(',', $look_field_ids) .')'); // Create a new query object. $query = $db->getQuery(true); $query->delete($db->quoteName('#__fields_values')); $query->where($look_condition); $db->setQuery($query); // Execute the query to remove look field values $look_done = $db->execute(); if ($look_done) { // If succesfully remove look add queued success message. $app->enqueueMessage(JText::_('The fields values for look was removed from the #__fields_values table')); } } // Create a new query object. $query = $db->getQuery(true); // Select ids from field groups $query->select($db->quoteName('id')); $query->from($db->quoteName('#__fields_groups')); // Where look context is found $query->where( $db->quoteName('context') . ' = '. $db->quote('com_demo.look') ); $db->setQuery($query); // Execute query to see if context is found $db->execute(); $look_found = $db->getNumRows(); // Now check if there were any rows if ($look_found) { // Remove look from the field groups table $look_condition = array( $db->quoteName('context') . ' = '. $db->quote('com_demo.look') ); // Create a new query object. $query = $db->getQuery(true); $query->delete($db->quoteName('#__fields_groups')); $query->where($look_condition); $db->setQuery($query); // Execute the query to remove look items $look_done = $db->execute(); if ($look_done) { // If succesfully remove look add queued success message. $app->enqueueMessage(JText::_('The field groups with type (com_demo.look) context was removed from the #__fields_groups table')); } } // 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 look alias is found $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_demo.look') ); $db->setQuery($query); // Execute query to see if alias is found $db->execute(); $look_found = $db->getNumRows(); // Now check if there were any rows if ($look_found) { // Since there are load the needed look type ids $look_ids = $db->loadColumn(); // Remove look from the content type table $look_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_demo.look') ); // Create a new query object. $query = $db->getQuery(true); $query->delete($db->quoteName('#__content_types')); $query->where($look_condition); $db->setQuery($query); // Execute the query to remove look items $look_done = $db->execute(); if ($look_done) { // If succesfully remove look add queued success message. $app->enqueueMessage(JText::_('The (com_demo.look) type alias was removed from the #__content_type table')); } // Remove look items from the contentitem tag map table $look_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_demo.look') ); // Create a new query object. $query = $db->getQuery(true); $query->delete($db->quoteName('#__contentitem_tag_map')); $query->where($look_condition); $db->setQuery($query); // Execute the query to remove look items $look_done = $db->execute(); if ($look_done) { // If succesfully remove look add queued success message. $app->enqueueMessage(JText::_('The (com_demo.look) type alias was removed from the #__contentitem_tag_map table')); } // Remove look items from the ucm content table $look_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_demo.look') ); // Create a new query object. $query = $db->getQuery(true); $query->delete($db->quoteName('#__ucm_content')); $query->where($look_condition); $db->setQuery($query); // Execute the query to remove look items $look_done = $db->execute(); if ($look_done) { // If succesfully remove look add queued success message. $app->enqueueMessage(JText::_('The (com_demo.look) type alias was removed from the #__ucm_content table')); } // Make sure that all the look items are cleared from DB foreach ($look_ids as $look_id) { // Remove look items from the ucm base table $look_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $look_id); // Create a new query object. $query = $db->getQuery(true); $query->delete($db->quoteName('#__ucm_base')); $query->where($look_condition); $db->setQuery($query); // Execute the query to remove look items $db->execute(); // Remove look items from the ucm history table $look_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $look_id); // Create a new query object. $query = $db->getQuery(true); $query->delete($db->quoteName('#__ucm_history')); $query->where($look_condition); $db->setQuery($query); // Execute the query to remove look 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 Look alias is found $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_demo.look') ); $db->setQuery($query); // Execute query to see if alias is found $db->execute(); $look_found = $db->getNumRows(); // Now check if there were any rows if ($look_found) { // Since there are load the needed look type ids $look_ids = $db->loadColumn(); // Remove Look from the content type table $look_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_demo.look') ); // Create a new query object. $query = $db->getQuery(true); $query->delete($db->quoteName('#__content_types')); $query->where($look_condition); $db->setQuery($query); // Execute the query to remove Look items $look_done = $db->execute(); if ($look_done) { // If succesfully remove Look add queued success message. $app->enqueueMessage(JText::_('The (com_demo.look) type alias was removed from the #__content_type table')); } // Remove Look items from the contentitem tag map table $look_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_demo.look') ); // Create a new query object. $query = $db->getQuery(true); $query->delete($db->quoteName('#__contentitem_tag_map')); $query->where($look_condition); $db->setQuery($query); // Execute the query to remove Look items $look_done = $db->execute(); if ($look_done) { // If succesfully remove Look add queued success message. $app->enqueueMessage(JText::_('The (com_demo.look) type alias was removed from the #__contentitem_tag_map table')); } // Remove Look items from the ucm content table $look_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_demo.look') ); // Create a new query object. $query = $db->getQuery(true); $query->delete($db->quoteName('#__ucm_content')); $query->where($look_condition); $db->setQuery($query); // Execute the query to remove Look items $look_done = $db->execute(); if ($look_done) { // If succesfully remove Look add queued success message. $app->enqueueMessage(JText::_('The (com_demo.look) type alias was removed from the #__ucm_content table')); } // Make sure that all the Look items are cleared from DB foreach ($look_ids as $look_id) { // Remove Look items from the ucm base table $look_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $look_id); // Create a new query object. $query = $db->getQuery(true); $query->delete($db->quoteName('#__ucm_base')); $query->where($look_condition); $db->setQuery($query); // Execute the query to remove Look items $db->execute(); // Remove Look items from the ucm history table $look_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $look_id); // Create a new query object. $query = $db->getQuery(true); $query->delete($db->quoteName('#__ucm_history')); $query->where($look_condition); $db->setQuery($query); // Execute the query to remove Look items $db->execute(); } } // If All related items was removed queued success message. $app->enqueueMessage(JText::_('All related items was removed from the #__ucm_base table')); $app->enqueueMessage(JText::_('All related items was removed from the #__ucm_history table')); // Remove demo assets from the assets table $demo_condition = array( $db->quoteName('name') . ' LIKE ' . $db->quote('com_demo%') ); // Create a new query object. $query = $db->getQuery(true); $query->delete($db->quoteName('#__assets')); $query->where($demo_condition); $db->setQuery($query); $look_done = $db->execute(); if ($look_done) { // If succesfully remove demo add queued success message. $app->enqueueMessage(JText::_('All related items was removed from the #__assets table')); } // little notice as after service, in case of bad experience with component. echo '
Please let me know at joomla@vdm.io.
We at Vast Development Method are committed to building extensions that performs proficiently! You can help us, really!
Send me your thoughts on improvements that is needed, trust me, I will be very grateful!
Visit us at https://www.vdm.io/ today!