Moved from (behavior::modal) to (bootstrap::renderModal), JAdapterInstance -> ComponentAdapter, added some namespaces and commented out necessary code to install, update and uninstall on j3! & j4!

This commit is contained in:
Oh 2021-10-16 18:42:23 +02:00
parent fa04654e94
commit 16c0b2af69
Signed by untrusted user: Oh
GPG Key ID: F91C6D0A21225F8A

View File

@ -1,61 +1,71 @@
<?php
/*----------------------------------------------------------------------------------| www.vdm.io |----/
Vast Development Method
/-------------------------------------------------------------------------------------------------------/
@version 2.0.3
@build 8th February, 2021
@created 18th October, 2016
@package Demo
@subpackage script.php
@author Llewellyn van der Merwe <https://www.vdm.io/>
@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
{
/**
* Constructor
*
* @param JAdapterInstance $parent The object responsible for running this script
*/
public function __construct(JAdapterInstance $parent) {}
/**
* Called on installation
*
* @param JAdapterInstance $parent The object responsible for running this script
*
* @return boolean True on success
*/
public function install(JAdapterInstance $parent) {}
/**
* Called on uninstallation
*
* @param JAdapterInstance $parent The object responsible for running this script
*/
public function uninstall(JAdapterInstance $parent)
/*----------------------------------------------------------------------------------| www.vdm.io |----/
Vast Development Method
/-------------------------------------------------------------------------------------------------------/
@version 2.0.3
@build 8th February, 2021
@created 18th October, 2016
@package Demo
@subpackage script.php
@author Llewellyn van der Merwe <https://www.vdm.io/>
@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');
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Installer\Adapter\ComponentAdapter;
//use Joomla\CMS\Installer\InstallerScript;
//use Joomla\CMS\Filesystem\File;
//use Joomla\CMS\Filesystem\Folder;
//use Joomla\CMS\Installer\InstallerAdapter;
//use Joomla\CMS\Language\Text;
//use Joomla\CMS\Table\Table;
HTMLHelper::_('bootstrap.renderModal');
/**
* Script File of Demo Component
*/
class com_demoInstallerScript
{
/**
* Constructor
*
* @param JAdapterInstance $parent The object responsible for running this script
*/
public function __construct(ComponentAdapter $parent) {}
/**
* Called on installation
*
* @param JAdapterInstance $parent The object responsible for running this script
*
* @return boolean True on success
*/
public function install(ComponentAdapter $parent) {}
/**
* Called on uninstallation
*
* @param JAdapterInstance $parent The object responsible for running this script
*/
public function uninstall(ComponentAdapter $parent)
{
// Get Application object
$app = JFactory::getApplication();
$app = Factory::getApplication();
// Get The Database object
$db = JFactory::getDbo();
$db = Factory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
@ -325,36 +335,36 @@ class com_demoInstallerScript
}
// Get the biggest rule column in the assets table at this point.
$get_rule_length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1";
$db->setQuery($get_rule_length);
if ($db->execute())
{
$rule_length = $db->loadResult();
// Check the size of the rules column
if ($rule_length < 5120)
{
// Revert the assets table rules column back to the default
$revert_rule = "ALTER TABLE `#__assets` CHANGE `rules` `rules` varchar(5120) NOT NULL COMMENT 'JSON encoded access control.';";
$db->setQuery($revert_rule);
$db->execute();
$app->enqueueMessage(JText::_('Reverted the <b>#__assets</b> table rules column back to its default size of varchar(5120)'));
}
else
{
$app->enqueueMessage(JText::_('Could not revert the <b>#__assets</b> table rules column back to its default size of varchar(5120), since there is still one or more components that still requires the column to be larger.'));
}
}
// $get_rule_length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1";
// $db->setQuery($get_rule_length);
// if ($db->execute())
// {
// $rule_length = $db->loadResult();
// // Check the size of the rules column
// if ($rule_length < 5120)
// {
// // Revert the assets table rules column back to the default
// $revert_rule = "ALTER TABLE `#__assets` CHANGE `rules` `rules` varchar(5120) NOT NULL COMMENT 'JSON encoded access control.';";
// $db->setQuery($revert_rule);
// $db->execute();
// $app->enqueueMessage(JText::_('Reverted the <b>#__assets</b> table rules column back to its default size of varchar(5120)'));
// }
// else
// {
//
// $app->enqueueMessage(JText::_('Could not revert the <b>#__assets</b> table rules column back to its default size of varchar(5120), since there is still one or more components that still requires the column to be larger.'));
// }
// }
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
$db = Factory::getDbo();
}
// Set app if not set already.
if (!isset($app))
{
$app = JFactory::getApplication();
$app = Factory::getApplication();
}
// Remove Demo from the action_logs_extensions table
$demo_action_logs_extensions = array( $db->quoteName('extension') . ' = ' . $db->quote('com_demo') );
@ -374,12 +384,12 @@ class com_demoInstallerScript
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
$db = Factory::getDbo();
}
// Set app if not set already.
if (!isset($app))
{
$app = JFactory::getApplication();
$app = Factory::getApplication();
}
// Remove Demo Look from the action_log_config table
$look_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_demo.look') );
@ -394,114 +404,114 @@ class com_demoInstallerScript
{
// If successfully removed Demo Look add queued success message.
$app->enqueueMessage(JText::_('The com_demo.look type alias was removed from the <b>#__action_log_config</b> table'));
}
// little notice as after service, in case of bad experience with component.
echo '<h2>Did something go wrong? Are you disappointed?</h2>
<p>Please let me know at <a href="mailto:joomla@vdm.io">joomla@vdm.io</a>.
<br />We at Vast Development Method are committed to building extensions that performs proficiently! You can help us, really!
<br />Send me your thoughts on improvements that is needed, trust me, I will be very grateful!
<br />Visit us at <a href="https://www.vdm.io/" target="_blank">https://www.vdm.io/</a> today!</p>';
}
/**
* Called on update
*
* @param JAdapterInstance $parent The object responsible for running this script
*
* @return boolean True on success
*/
public function update(JAdapterInstance $parent){}
/**
* Called before any type of action
*
* @param string $type Which action is happening (install|uninstall|discover_install|update)
* @param JAdapterInstance $parent The object responsible for running this script
*
* @return boolean True on success
*/
public function preflight($type, JAdapterInstance $parent)
{
// get application
$app = JFactory::getApplication();
// is redundant or so it seems ...hmmm let me know if it works again
if ($type === 'uninstall')
{
return true;
}
// the default for both install and update
$jversion = new JVersion();
if (!$jversion->isCompatible('3.8.0'))
{
$app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error');
return false;
}
// do any updates needed
if ($type === 'update')
{
}
// do any install needed
if ($type === 'install')
{
}
// check if the PHPExcel stuff is still around
if (JFile::exists(JPATH_ADMINISTRATOR . '/components/com_demo/helpers/PHPExcel.php'))
{
// We need to remove this old PHPExcel folder
$this->removeFolder(JPATH_ADMINISTRATOR . '/components/com_demo/helpers/PHPExcel');
// We need to remove this old PHPExcel file
JFile::delete(JPATH_ADMINISTRATOR . '/components/com_demo/helpers/PHPExcel.php');
}
return true;
}
/**
* Called after any type of action
*
* @param string $type Which action is happening (install|uninstall|discover_install|update)
* @param JAdapterInstance $parent The object responsible for running this script
*
* @return boolean True on success
*/
public function postflight($type, JAdapterInstance $parent)
{
// get application
$app = JFactory::getApplication();
}
// little notice as after service, in case of bad experience with component.
echo '<h2>Did something go wrong? Are you disappointed?</h2>
<p>Please let me know at <a href="mailto:joomla@vdm.io">joomla@vdm.io</a>.
<br />We at Vast Development Method are committed to building extensions that performs proficiently! You can help us, really!
<br />Send me your thoughts on improvements that is needed, trust me, I will be very grateful!
<br />Visit us at <a href="https://www.vdm.io/" target="_blank">https://www.vdm.io/</a> today!</p>';
}
/**
* Called on update
*
* @param JAdapterInstance $parent The object responsible for running this script
*
* @return boolean True on success
*/
public function update(ComponentAdapter $parent){}
/**
* Called before any type of action
*
* @param string $type Which action is happening (install|uninstall|discover_install|update)
* @param JAdapterInstance $parent The object responsible for running this script
*
* @return boolean True on success
*/
public function preflight($type, ComponentAdapter $parent)
{
// get application
$app = Factory::getApplication();
// is redundant or so it seems ...hmmm let me know if it works again
if ($type === 'uninstall')
{
return true;
}
// the default for both install and update
$jversion = new JVersion();
if (!$jversion->isCompatible('3.8.0'))
{
$app->enqueueMessage('Please upgrade to at least Joomla! 3.8.0 before continuing!', 'error');
return false;
}
// do any updates needed
if ($type === 'update')
{
}
// do any install needed
if ($type === 'install')
{
}
// check if the PHPExcel stuff is still around
if (JFile::exists(JPATH_ADMINISTRATOR . '/components/com_demo/helpers/PHPExcel.php'))
{
// We need to remove this old PHPExcel folder
$this->removeFolder(JPATH_ADMINISTRATOR . '/components/com_demo/helpers/PHPExcel');
// We need to remove this old PHPExcel file
JFile::delete(JPATH_ADMINISTRATOR . '/components/com_demo/helpers/PHPExcel.php');
}
return true;
}
/**
* Called after any type of action
*
* @param string $type Which action is happening (install|uninstall|discover_install|update)
* @param JAdapterInstance $parent The object responsible for running this script
*
* @return boolean True on success
*/
public function postflight($type, ComponentAdapter $parent)
{
// get application
$app = Factory::getApplication();
// We check if we have dynamic folders to copy
$this->setDynamicF0ld3rs($app, $parent);
// set the default component settings
if ($type === 'install')
$this->setDynamicF0ld3rs($app, $parent);
// set the default component settings
if ($type === 'install')
{
// Get The Database object
$db = JFactory::getDbo();
// Create the look content type object.
$look = new stdClass();
$look->type_title = 'Demo Look';
$look->type_alias = 'com_demo.look';
$look->table = '{"special": {"dbtable": "#__demo_look","key": "id","type": "Look","prefix": "demoTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
$look->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "metadata","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "metakey","core_metadesc": "metadesc","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description","website":"website","image":"image","dateofbirth":"dateofbirth","mobile_phone":"mobile_phone","email":"email","add":"add","alias":"alias"}}';
$look->router = 'DemoHelperRoute::getLookRoute';
$look->content_history_options = '{"formFile": "administrator/components/com_demo/models/forms/look.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","add"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}';
// Set the object into the content types table.
$look_Inserted = $db->insertObject('#__content_types', $look);
$db = Factory::getDbo();
//
// // Create the look content type object.
// $look = new stdClass();
// $look->type_title = 'Demo Look';
// $look->type_alias = 'com_demo.look';
// $look->table = '{"special": {"dbtable": "#__demo_look","key": "id","type": "Look","prefix": "demoTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
// $look->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "metadata","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "metakey","core_metadesc": "metadesc","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description","website":"website","image":"image","dateofbirth":"dateofbirth","mobile_phone":"mobile_phone","email":"email","add":"add","alias":"alias"}}';
// $look->router = 'DemoHelperRoute::getLookRoute';
// $look->content_history_options = '{"formFile": "administrator/components/com_demo/models/forms/look.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","add"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}';
//
// // Set the object into the content types table.
// $look_Inserted = $db->insertObject('#__content_types', $look);
// Install the global extenstion assets permission.
$query = $db->getQuery(true);
// $query = $db->getQuery(true);
// Field to update.
$fields = array(
$db->quoteName('rules') . ' = ' . $db->quote('{"site.looks.access":{"1":1}}'),
);
// $fields = array(
// $db->quoteName('rules') . ' = ' . $db->quote('{"site.looks.access":{"1":1}}'),
// );
// Condition.
$conditions = array(
$db->quoteName('name') . ' = ' . $db->quote('com_demo')
);
$query->update($db->quoteName('#__assets'))->set($fields)->where($conditions);
$db->setQuery($query);
$allDone = $db->execute();
// $conditions = array(
// $db->quoteName('name') . ' = ' . $db->quote('com_demo')
// );
// $query->update($db->quoteName('#__assets'))->set($fields)->where($conditions);
// $db->setQuery($query);
// $allDone = $db->execute();
// Install the global extenstion params.
$query = $db->getQuery(true);
@ -518,93 +528,93 @@ class com_demoInstallerScript
$allDone = $db->execute();
// Get Application object
$app = JFactory::getApplication();
// Get Application object
$app = Factory::getApplication();
$app->enqueueMessage('This is a demo component developed in <a href="http://vdm.bz/component-builder" taget="_balnk" title="Joomla Component Builder">JCB</a>! You can build more components like this with JCB, checkout our page on <a href="https://github.com/vdm-io/Joomla-Component-Builder" taget="_balnk" title="Joomla Component Builder">github</a> for more info. The future of <a href="http://vdm.bz/component-builder" taget="_balnk" title="Joomla Component Builder">Joomla Component Development</a> is Here!', 'Info');
// Get the biggest rule column in the assets table at this point.
$get_rule_length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1";
$db->setQuery($get_rule_length);
if ($db->execute())
{
$rule_length = $db->loadResult();
// Check the size of the rules column
if ($rule_length <= 5600)
{
// Fix the assets table rules column size
$fix_rules_size = "ALTER TABLE `#__assets` CHANGE `rules` `rules` TEXT NOT NULL COMMENT 'JSON encoded access control. Enlarged to TEXT by JCB';";
$db->setQuery($fix_rules_size);
$db->execute();
$app->enqueueMessage(JText::_('The <b>#__assets</b> table rules column was resized to the TEXT datatype for the components possible large permission rules.'));
}
}
echo '<a target="_blank" href="https://www.vdm.io/" title="Demo">
<img src="components/com_demo/assets/images/vdm-component.jpg"/>
</a>';
// // Get the biggest rule column in the assets table at this point.
// $get_rule_length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1";
// $db->setQuery($get_rule_length);
// if ($db->execute())
// {
// $rule_length = $db->loadResult();
// // Check the size of the rules column
// if ($rule_length <= 5600)
// {
// // Fix the assets table rules column size
// $fix_rules_size = "ALTER TABLE `#__assets` CHANGE `rules` `rules` TEXT NOT NULL COMMENT 'JSON encoded access control. Enlarged to TEXT by JCB';";
// $db->setQuery($fix_rules_size);
// $db->execute();
// $app->enqueueMessage(JText::_('The <b>#__assets</b> table rules column was resized to the TEXT datatype for the components possible large permission rules.'));
// }
// }
// echo '<a target="_blank" href="https://www.vdm.io/" title="Demo">
// <img src="components/com_demo/assets/images/vdm-component.jpg"/>
// </a>';
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Create the demo action logs extensions object.
$demo_action_logs_extensions = new stdClass();
$demo_action_logs_extensions->extension = 'com_demo';
// Set the object into the action logs extensions table.
$demo_action_logs_extensions_Inserted = $db->insertObject('#__action_logs_extensions', $demo_action_logs_extensions);
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Create the look action log config object.
$look_action_log_config = new stdClass();
$look_action_log_config->type_title = 'LOOK';
$look_action_log_config->type_alias = 'com_demo.look';
$look_action_log_config->id_holder = 'id';
$look_action_log_config->title_holder = 'name';
$look_action_log_config->table_name = '#__demo_look';
$look_action_log_config->text_prefix = 'COM_DEMO';
// Set the object into the action log config table.
$look_Inserted = $db->insertObject('#__action_log_config', $look_action_log_config);
}
// do any updates needed
if ($type === 'update')
// if (!isset($db))
// {
// $db = Factory::getDbo();
// }
// // Create the demo action logs extensions object.
// $demo_action_logs_extensions = new stdClass();
// $demo_action_logs_extensions->extension = 'com_demo';
//
// // Set the object into the action logs extensions table.
// $demo_action_logs_extensions_Inserted = $db->insertObject('#__action_logs_extensions', $demo_action_logs_extensions);
//
// // Set db if not set already.
// if (!isset($db))
// {
// $db = Factory::getDbo();
// }
// // Create the look action log config object.
// $look_action_log_config = new stdClass();
// $look_action_log_config->type_title = 'LOOK';
// $look_action_log_config->type_alias = 'com_demo.look';
// $look_action_log_config->id_holder = 'id';
// $look_action_log_config->title_holder = 'name';
// $look_action_log_config->table_name = '#__demo_look';
// $look_action_log_config->text_prefix = 'COM_DEMO';
//
// // Set the object into the action log config table.
// $look_Inserted = $db->insertObject('#__action_log_config', $look_action_log_config);
}
// do any updates needed
if ($type === 'update')
{
// Get The Database object
$db = JFactory::getDbo();
// $db = Factory::getDbo();
// Create the look content type object.
$look = new stdClass();
$look->type_title = 'Demo Look';
$look->type_alias = 'com_demo.look';
$look->table = '{"special": {"dbtable": "#__demo_look","key": "id","type": "Look","prefix": "demoTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
$look->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "metadata","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "metakey","core_metadesc": "metadesc","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description","website":"website","image":"image","dateofbirth":"dateofbirth","mobile_phone":"mobile_phone","email":"email","add":"add","alias":"alias"}}';
$look->router = 'DemoHelperRoute::getLookRoute';
$look->content_history_options = '{"formFile": "administrator/components/com_demo/models/forms/look.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","add"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}';
// $look = new stdClass();
// $look->type_title = 'Demo Look';
// $look->type_alias = 'com_demo.look';
// $look->table = '{"special": {"dbtable": "#__demo_look","key": "id","type": "Look","prefix": "demoTable","config": "array()"},"common": {"dbtable": "#__ucm_content","key": "ucm_id","type": "Corecontent","prefix": "JTable","config": "array()"}}';
// $look->field_mappings = '{"common": {"core_content_item_id": "id","core_title": "name","core_state": "published","core_alias": "alias","core_created_time": "created","core_modified_time": "modified","core_body": "null","core_hits": "hits","core_publish_up": "null","core_publish_down": "null","core_access": "access","core_params": "params","core_featured": "null","core_metadata": "metadata","core_language": "null","core_images": "null","core_urls": "null","core_version": "version","core_ordering": "ordering","core_metakey": "metakey","core_metadesc": "metadesc","core_catid": "null","core_xreference": "null","asset_id": "asset_id"},"special": {"name":"name","description":"description","website":"website","image":"image","dateofbirth":"dateofbirth","mobile_phone":"mobile_phone","email":"email","add":"add","alias":"alias"}}';
// $look->router = 'DemoHelperRoute::getLookRoute';
// $look->content_history_options = '{"formFile": "administrator/components/com_demo/models/forms/look.xml","hideFields": ["asset_id","checked_out","checked_out_time","version"],"ignoreChanges": ["modified_by","modified","checked_out","checked_out_time","version","hits"],"convertToInt": ["published","ordering","add"],"displayLookup": [{"sourceColumn": "created_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"},{"sourceColumn": "access","targetTable": "#__viewlevels","targetColumn": "id","displayColumn": "title"},{"sourceColumn": "modified_by","targetTable": "#__users","targetColumn": "id","displayColumn": "name"}]}';
// Check if look type is already in content_type DB.
$look_id = null;
$query = $db->getQuery(true);
$query->select($db->quoteName(array('type_id')));
$query->from($db->quoteName('#__content_types'));
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($look->type_alias));
$db->setQuery($query);
$db->execute();
// Set the object into the content types table.
if ($db->getNumRows())
{
$look->type_id = $db->loadResult();
$look_Updated = $db->updateObject('#__content_types', $look, 'type_id');
}
else
{
$look_Inserted = $db->insertObject('#__content_types', $look);
}
// $look_id = null;
// $query = $db->getQuery(true);
// $query->select($db->quoteName(array('type_id')));
// $query->from($db->quoteName('#__content_types'));
// $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($look->type_alias));
// $db->setQuery($query);
// $db->execute();
//
// // Set the object into the content types table.
// if ($db->getNumRows())
// {
// $look->type_id = $db->loadResult();
// $look_Updated = $db->updateObject('#__content_types', $look, 'type_id');
// }
// else
// {
// $look_Inserted = $db->insertObject('#__content_types', $look);
// }
echo '<a target="_blank" href="https://www.vdm.io/" title="Demo">
@ -613,164 +623,164 @@ class com_demoInstallerScript
<h3>Upgrade to Version 2.0.3 Was Successful! Let us know if anything is not working as expected.</h3>';
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Create the demo action logs extensions object.
$demo_action_logs_extensions = new stdClass();
$demo_action_logs_extensions->extension = 'com_demo';
// Check if demo action log extension is already in action logs extensions DB.
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id')));
$query->from($db->quoteName('#__action_logs_extensions'));
$query->where($db->quoteName('extension') . ' LIKE '. $db->quote($demo_action_logs_extensions->extension));
$db->setQuery($query);
$db->execute();
// Set the object into the action logs extensions table if not found.
if (!$db->getNumRows())
{
$demo_action_logs_extensions_Inserted = $db->insertObject('#__action_logs_extensions', $demo_action_logs_extensions);
}
// Set db if not set already.
if (!isset($db))
{
$db = JFactory::getDbo();
}
// Create the look action log config object.
$look_action_log_config = new stdClass();
$look_action_log_config->id = null;
$look_action_log_config->type_title = 'LOOK';
$look_action_log_config->type_alias = 'com_demo.look';
$look_action_log_config->id_holder = 'id';
$look_action_log_config->title_holder = 'name';
$look_action_log_config->table_name = '#__demo_look';
$look_action_log_config->text_prefix = 'COM_DEMO';
// Check if look action log config is already in action_log_config DB.
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id')));
$query->from($db->quoteName('#__action_log_config'));
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($look_action_log_config->type_alias));
$db->setQuery($query);
$db->execute();
// if (!isset($db))
// {
// $db = Factory::getDbo();
// }
// // Create the demo action logs extensions object.
// $demo_action_logs_extensions = new stdClass();
// $demo_action_logs_extensions->extension = 'com_demo';
//
// // Check if demo action log extension is already in action logs extensions DB.
// $query = $db->getQuery(true);
// $query->select($db->quoteName(array('id')));
// $query->from($db->quoteName('#__action_logs_extensions'));
// $query->where($db->quoteName('extension') . ' LIKE '. $db->quote($demo_action_logs_extensions->extension));
// $db->setQuery($query);
// $db->execute();
//
// // Set the object into the action logs extensions table if not found.
// if (!$db->getNumRows())
// {
// $demo_action_logs_extensions_Inserted = $db->insertObject('#__action_logs_extensions', $demo_action_logs_extensions);
// }
//
// // Set db if not set already.
// if (!isset($db))
// {
// $db = Factory::getDbo();
// }
// // Create the look action log config object.
// $look_action_log_config = new stdClass();
// $look_action_log_config->id = null;
// $look_action_log_config->type_title = 'LOOK';
// $look_action_log_config->type_alias = 'com_demo.look';
// $look_action_log_config->id_holder = 'id';
// $look_action_log_config->title_holder = 'name';
// $look_action_log_config->table_name = '#__demo_look';
// $look_action_log_config->text_prefix = 'COM_DEMO';
//
// // Check if look action log config is already in action_log_config DB.
// $query = $db->getQuery(true);
// $query->select($db->quoteName(array('id')));
// $query->from($db->quoteName('#__action_log_config'));
// $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($look_action_log_config->type_alias));
// $db->setQuery($query);
// $db->execute();
//
// Set the object into the content types table.
if ($db->getNumRows())
// if ($db->getNumRows())
// {
// $look_action_log_config->id = $db->loadResult();
// $look_action_log_config_Updated = $db->updateObject('#__action_log_config', $look_action_log_config, 'id');
// }
// else
// {
// $look_action_log_config_Inserted = $db->insertObject('#__action_log_config', $look_action_log_config);
// }
}
return true;
}
/**
* Remove folders with files
*
* @param string $dir The path to folder to remove
* @param boolean $ignore The folders and files to ignore and not remove
*
* @return boolean True in all is removed
*
*/
protected function removeFolder($dir, $ignore = false)
{
if (JFolder::exists($dir))
{
$it = new RecursiveDirectoryIterator($dir);
$it = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
// remove ending /
$dir = rtrim($dir, '/');
// now loop the files & folders
foreach ($it as $file)
{
$look_action_log_config->id = $db->loadResult();
$look_action_log_config_Updated = $db->updateObject('#__action_log_config', $look_action_log_config, 'id');
if ('.' === $file->getBasename() || '..' === $file->getBasename()) continue;
// set file dir
$file_dir = $file->getPathname();
// check if this is a dir or a file
if ($file->isDir())
{
$keeper = false;
if ($this->checkArray($ignore))
{
foreach ($ignore as $keep)
{
if (strpos($file_dir, $dir.'/'.$keep) !== false)
{
$keeper = true;
}
}
}
if ($keeper)
{
continue;
}
JFolder::delete($file_dir);
}
else
{
$keeper = false;
if ($this->checkArray($ignore))
{
foreach ($ignore as $keep)
{
if (strpos($file_dir, $dir.'/'.$keep) !== false)
{
$keeper = true;
}
}
}
if ($keeper)
{
continue;
}
JFile::delete($file_dir);
}
}
else
// delete the root folder if not ignore found
if (!$this->checkArray($ignore))
{
$look_action_log_config_Inserted = $db->insertObject('#__action_log_config', $look_action_log_config);
}
}
return true;
}
/**
* Remove folders with files
*
* @param string $dir The path to folder to remove
* @param boolean $ignore The folders and files to ignore and not remove
*
* @return boolean True in all is removed
*
*/
protected function removeFolder($dir, $ignore = false)
{
if (JFolder::exists($dir))
{
$it = new RecursiveDirectoryIterator($dir);
$it = new RecursiveIteratorIterator($it, RecursiveIteratorIterator::CHILD_FIRST);
// remove ending /
$dir = rtrim($dir, '/');
// now loop the files & folders
foreach ($it as $file)
{
if ('.' === $file->getBasename() || '..' === $file->getBasename()) continue;
// set file dir
$file_dir = $file->getPathname();
// check if this is a dir or a file
if ($file->isDir())
{
$keeper = false;
if ($this->checkArray($ignore))
{
foreach ($ignore as $keep)
{
if (strpos($file_dir, $dir.'/'.$keep) !== false)
{
$keeper = true;
}
}
}
if ($keeper)
{
continue;
}
JFolder::delete($file_dir);
}
else
{
$keeper = false;
if ($this->checkArray($ignore))
{
foreach ($ignore as $keep)
{
if (strpos($file_dir, $dir.'/'.$keep) !== false)
{
$keeper = true;
}
}
}
if ($keeper)
{
continue;
}
JFile::delete($file_dir);
}
}
// delete the root folder if not ignore found
if (!$this->checkArray($ignore))
{
return JFolder::delete($dir);
}
return true;
}
return false;
}
/**
* Check if have an array with a length
*
* @input array The array to check
*
* @returns bool/int number of items in array on success
*/
protected function checkArray($array, $removeEmptyString = false)
{
if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
{
foreach ($array as $key => $string)
{
if (empty($string))
{
unset($array[$key]);
}
}
return $this->checkArray($array, false);
}
return $nr;
}
return false;
return JFolder::delete($dir);
}
return true;
}
return false;
}
/**
* Check if have an array with a length
*
* @input array The array to check
*
* @returns bool/int number of items in array on success
*/
protected function checkArray($array, $removeEmptyString = false)
{
if (isset($array) && is_array($array) && ($nr = count((array)$array)) > 0)
{
// also make sure the empty strings are removed
if ($removeEmptyString)
{
foreach ($array as $key => $string)
{
if (empty($string))
{
unset($array[$key]);
}
}
return $this->checkArray($array, false);
}
return $nr;
}
return false;
}
/**
@ -806,5 +816,5 @@ class com_demoInstallerScript
}
}
}
}
}
}
}