@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'); jimport('joomla.installer.installer'); jimport('joomla.installer.helper'); /** * 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 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 Help_document alias is found $query->where( $db->quoteName('type_alias') . ' = '. $db->quote('com_demo.help_document') ); $db->setQuery($query); // Execute query to see if alias is found $db->execute(); $help_document_found = $db->getNumRows(); // Now check if there were any rows if ($help_document_found) { // Since there are load the needed help_document type ids $help_document_ids = $db->loadColumn(); // Remove Help_document from the content type table $help_document_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_demo.help_document') ); // Create a new query object. $query = $db->getQuery(true); $query->delete($db->quoteName('#__content_types')); $query->where($help_document_condition); $db->setQuery($query); // Execute the query to remove Help_document items $help_document_done = $db->execute(); if ($help_document_done); { // If succesfully remove Help_document add queued success message. $app->enqueueMessage(JText::_('The (com_demo.help_document) type alias was removed from the #__content_type table')); } // Remove Help_document items from the contentitem tag map table $help_document_condition = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_demo.help_document') ); // Create a new query object. $query = $db->getQuery(true); $query->delete($db->quoteName('#__contentitem_tag_map')); $query->where($help_document_condition); $db->setQuery($query); // Execute the query to remove Help_document items $help_document_done = $db->execute(); if ($help_document_done); { // If succesfully remove Help_document add queued success message. $app->enqueueMessage(JText::_('The (com_demo.help_document) type alias was removed from the #__contentitem_tag_map table')); } // Remove Help_document items from the ucm content table $help_document_condition = array( $db->quoteName('core_type_alias') . ' = ' . $db->quote('com_demo.help_document') ); // Create a new query object. $query = $db->getQuery(true); $query->delete($db->quoteName('#__ucm_content')); $query->where($help_document_condition); $db->setQuery($query); // Execute the query to remove Help_document items $help_document_done = $db->execute(); if ($help_document_done); { // If succesfully remove Help_document add queued success message. $app->enqueueMessage(JText::_('The (com_demo.help_document) type alias was removed from the #__ucm_content table')); } // Make sure that all the Help_document items are cleared from DB foreach ($help_document_ids as $help_document_id) { // Remove Help_document items from the ucm base table $help_document_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $help_document_id); // Create a new query object. $query = $db->getQuery(true); $query->delete($db->quoteName('#__ucm_base')); $query->where($help_document_condition); $db->setQuery($query); // Execute the query to remove Help_document items $db->execute(); // Remove Help_document items from the ucm history table $help_document_condition = array( $db->quoteName('ucm_type_id') . ' = ' . $help_document_id); // Create a new query object. $query = $db->getQuery(true); $query->delete($db->quoteName('#__ucm_history')); $query->where($help_document_condition); $db->setQuery($query); // Execute the query to remove Help_document 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); $help_document_done = $db->execute(); if ($help_document_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 info@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!