Compare commits
9 Commits
master
...
ohrionmart
Author | SHA1 | Date | |
---|---|---|---|
d02e705931 | |||
3d55688430 | |||
7d22d45065 | |||
1829772135 | |||
86db494dee | |||
7cf887d589 | |||
732dc01904 | |||
e8f8b4633e | |||
5a9ae0973a |
@ -21,8 +21,6 @@
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
JHtml::_('behavior.tabstate');
|
||||
|
||||
// Access check.
|
||||
if (!JFactory::getUser()->authorise('core.manage', 'com_demo'))
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ class DemoTableLook extends JTable
|
||||
parent::__construct('#__demo_look', 'id', $db);
|
||||
|
||||
// Adding History Options
|
||||
JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_demo.look'));
|
||||
// JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_demo.look'));
|
||||
}
|
||||
|
||||
public function bind($array, $ignore = '')
|
||||
|
@ -21,7 +21,6 @@
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
JHtml::_('behavior.tooltip');
|
||||
|
||||
?>
|
||||
<div id="j-main-container">
|
||||
|
@ -27,7 +27,7 @@ JHtml::_('formbehavior.chosen', 'select');
|
||||
JHtml::_('behavior.keepalive');
|
||||
$componentParams = $this->params; // will be removed just use $this->params instead
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
<!-- <script type="text/javascript">
|
||||
// waiting spinner
|
||||
var outerDiv = jQuery('body');
|
||||
jQuery('<div id="loading"></div>')
|
||||
@ -49,7 +49,7 @@ $componentParams = $this->params; // will be removed just use $this->params inst
|
||||
jQuery('#loading').hide();
|
||||
});
|
||||
</script>
|
||||
<div id="demo_loader" style="display: none;">
|
||||
<div id="demo_loader" style="display: none;"> -->
|
||||
<form action="<?php echo JRoute::_('index.php?option=com_demo&layout=edit&id='. (int) $this->item->id . $this->referral); ?>" method="post" name="adminForm" id="adminForm" class="form-validate" enctype="multipart/form-data">
|
||||
|
||||
<?php echo JLayoutHelper::render('look.details_above', $this); ?>
|
||||
|
@ -32,11 +32,11 @@ class DemoViewLooks extends JViewLegacy
|
||||
*/
|
||||
function display($tpl = null)
|
||||
{
|
||||
if ($this->getLayout() !== 'modal')
|
||||
{
|
||||
// Include helper submenu
|
||||
DemoHelper::addSubmenu('looks');
|
||||
}
|
||||
// if ($this->getLayout() !== 'modal')
|
||||
// {
|
||||
// // Include helper submenu
|
||||
// DemoHelper::addSubmenu('looks');
|
||||
// }
|
||||
|
||||
// Assign data to the view
|
||||
$this->items = $this->get('Items');
|
||||
|
2
demo.xml
2
demo.xml
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="component" version="3.2" method="upgrade">
|
||||
<extension type="component" version="4.0" method="upgrade">
|
||||
<name>COM_DEMO</name>
|
||||
<creationDate>18th October, 2021</creationDate>
|
||||
<author>Llewellyn van der Merwe</author>
|
||||
|
@ -50,4 +50,21 @@
|
||||
<maintainerurl>https://www.vdm.io/</maintainerurl>
|
||||
<targetplatform name="joomla" version="3.*"/>
|
||||
</update>
|
||||
<update>
|
||||
<name>Demo</name>
|
||||
<description>Demo Component</description>
|
||||
<element>com_demo</element>
|
||||
<type>component</type>
|
||||
<version>2.0.3</version>
|
||||
<infourl title="Demo!">https://www.vdm.io/</infourl>
|
||||
<downloads>
|
||||
<downloadurl type="full" format="zip">http://domain.com/demo.zip</downloadurl>
|
||||
</downloads>
|
||||
<tags>
|
||||
<tag>stable</tag>
|
||||
</tags>
|
||||
<maintainer>Llewellyn van der Merwe</maintainer>
|
||||
<maintainerurl>https://www.vdm.io/</maintainerurl>
|
||||
<targetplatform name="joomla" version="4.*"/>
|
||||
</update>
|
||||
</updates>
|
324
script.php
324
script.php
@ -328,26 +328,26 @@ 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
|
||||
{
|
||||
// $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.'));
|
||||
}
|
||||
}
|
||||
// $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))
|
||||
@ -480,31 +480,31 @@ class com_demoInstallerScript
|
||||
$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"}]}';
|
||||
// $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);
|
||||
// // 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);
|
||||
// Field to update.
|
||||
$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();
|
||||
// // Install the global extenstion assets permission.
|
||||
// $query = $db->getQuery(true);
|
||||
// // Field to update.
|
||||
// $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();
|
||||
|
||||
// Install the global extension params.
|
||||
$query = $db->getQuery(true);
|
||||
@ -521,93 +521,93 @@ class com_demoInstallerScript
|
||||
$allDone = $db->execute();
|
||||
|
||||
|
||||
// Get Application object
|
||||
$app = JFactory::getApplication();
|
||||
// Get Application object
|
||||
$app = JFactory::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_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 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);
|
||||
// $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 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);
|
||||
// // 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 = 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"}]}';
|
||||
// // 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"}]}';
|
||||
|
||||
// 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();
|
||||
// // 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);
|
||||
}
|
||||
// // 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">
|
||||
@ -616,61 +616,61 @@ 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';
|
||||
// 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();
|
||||
// // 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 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';
|
||||
// // 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();
|
||||
// // 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())
|
||||
{
|
||||
$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);
|
||||
}
|
||||
// // Set the object into the content types table.
|
||||
// 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;
|
||||
}
|
||||
|
@ -21,8 +21,6 @@
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
JHtml::_('behavior.tabstate');
|
||||
|
||||
// Set the component css/js
|
||||
$document = JFactory::getDocument();
|
||||
$document->addStyleSheet('components/com_demo/assets/css/site.css');
|
||||
|
354
site/router.php
354
site/router.php
@ -21,239 +21,183 @@
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Component\Router\RouterView;
|
||||
use Joomla\CMS\Component\Router\RouterViewConfiguration;
|
||||
use Joomla\CMS\Component\Router\Rules\MenuRules;
|
||||
use Joomla\CMS\Component\Router\Rules\StandardRules;
|
||||
use Joomla\CMS\Component\Router\Rules\NomenuRules;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Menu\SiteMenu;
|
||||
|
||||
/**
|
||||
* Routing class from com_demo
|
||||
*
|
||||
* @since 3.3
|
||||
*/
|
||||
class DemoRouter extends JComponentRouterBase
|
||||
class DemoRouter extends RouterView
|
||||
{
|
||||
/**
|
||||
* Build the route for the com_demo component
|
||||
* The database driver
|
||||
*
|
||||
* @param array &$query An array of URL arguments
|
||||
*
|
||||
* @return array The URL arguments to use to assemble the subsequent URL.
|
||||
*
|
||||
* @since 3.3
|
||||
* @var \JDatabaseDriver
|
||||
* @since 1.0
|
||||
*/
|
||||
public function build(&$query)
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* Search Component router constructor
|
||||
*
|
||||
* @param CMSApplication $app The application object
|
||||
* @param SiteMenu $menu The menu object to work with
|
||||
*/
|
||||
public function __construct($app = null, $menu = null)
|
||||
{
|
||||
$segments = array();
|
||||
$this->db = Factory::getDbo();
|
||||
|
||||
// Get a menu item based on Itemid or currently active
|
||||
$params = JComponentHelper::getParams('com_demo');
|
||||
|
||||
if (empty($query['Itemid']))
|
||||
{
|
||||
$menuItem = $this->menu->getActive();
|
||||
}
|
||||
else
|
||||
{
|
||||
$menuItem = $this->menu->getItem($query['Itemid']);
|
||||
}
|
||||
$looks = new RouterViewConfiguration('looks');
|
||||
$this->registerView($looks);
|
||||
|
||||
$mView = (empty($menuItem->query['view'])) ? null : $menuItem->query['view'];
|
||||
$mId = (empty($menuItem->query['id'])) ? null : $menuItem->query['id'];
|
||||
$look = (new RouterViewConfiguration('look'))
|
||||
->setParent($looks)
|
||||
->setKey('id');
|
||||
$this->registerView($look);
|
||||
|
||||
if (isset($query['view']))
|
||||
{
|
||||
$view = $query['view'];
|
||||
$looking = (new RouterViewConfiguration('looking'))
|
||||
->setParent($look, 'id')
|
||||
->setKey('id');
|
||||
|
||||
if (empty($query['Itemid']) && !(isset($view) && isset($query['id']) && ($view === 'look' || $view === 'looks' || $view === 'looking')))
|
||||
{
|
||||
$segments[] = $query['view'];
|
||||
}
|
||||
$this->registerView($looking);
|
||||
|
||||
unset($query['view']);
|
||||
}
|
||||
|
||||
// Are we dealing with a item that is attached to a menu item?
|
||||
if (isset($view) && ($mView == $view) and (isset($query['id'])) and ($mId == (int) $query['id']))
|
||||
{
|
||||
unset($query['view']);
|
||||
unset($query['catid']);
|
||||
unset($query['id']);
|
||||
return $segments;
|
||||
}
|
||||
$export = (new RouterViewConfiguration('export'))
|
||||
->setKey('cms_version');
|
||||
$this->registerView($export);
|
||||
|
||||
if (isset($view) && isset($query['id']) && ($view === 'look' || $view === 'looks' || $view === 'looking'))
|
||||
{
|
||||
if ($mId != (int) $query['id'] || $mView != $view)
|
||||
{
|
||||
if (($view === 'look' || $view === 'looks' || $view === 'looking'))
|
||||
{
|
||||
$segments[] = $view;
|
||||
$id = explode(':', $query['id']);
|
||||
if (count($id) == 2)
|
||||
{
|
||||
$segments[] = $id[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
$segments[] = $id[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
unset($query['id']);
|
||||
}
|
||||
|
||||
$total = count($segments);
|
||||
parent::__construct($app, $menu);
|
||||
|
||||
for ($i = 0; $i < $total; $i++)
|
||||
{
|
||||
$segments[$i] = str_replace(':', '-', $segments[$i]);
|
||||
}
|
||||
|
||||
return $segments;
|
||||
|
||||
$this->attachRule(new MenuRules($this));
|
||||
$this->attachRule(new StandardRules($this));
|
||||
$this->attachRule(new NomenuRules($this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the segments of a URL.
|
||||
* Method to get the segment(s) for looks
|
||||
*
|
||||
* @param array &$segments The segments of the URL to parse.
|
||||
* @param string $id ID of the looks to retrieve the segments for
|
||||
* @param array $query The request that is built right now
|
||||
*
|
||||
* @return array The URL attributes to be used by the application.
|
||||
*
|
||||
* @since 3.3
|
||||
* @return array|string The segments of this item
|
||||
*/
|
||||
public function parse(&$segments)
|
||||
{
|
||||
$count = count($segments);
|
||||
$vars = array();
|
||||
|
||||
//Handle View and Identifier
|
||||
switch($segments[0])
|
||||
{
|
||||
case 'look':
|
||||
$vars['view'] = 'look';
|
||||
if (is_numeric($segments[$count-1]))
|
||||
{
|
||||
$vars['id'] = (int) $segments[$count-1];
|
||||
}
|
||||
break;
|
||||
case 'looks':
|
||||
$vars['view'] = 'looks';
|
||||
if (is_numeric($segments[$count-1]))
|
||||
{
|
||||
$vars['id'] = (int) $segments[$count-1];
|
||||
}
|
||||
elseif ($segments[$count-1])
|
||||
{
|
||||
$id = $this->getVar('look', $segments[$count-1], 'alias', 'id');
|
||||
if($id)
|
||||
{
|
||||
$vars['id'] = $id;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'looking':
|
||||
$vars['view'] = 'looking';
|
||||
if (is_numeric($segments[$count-1]))
|
||||
{
|
||||
$vars['id'] = (int) $segments[$count-1];
|
||||
}
|
||||
elseif ($segments[$count-1])
|
||||
{
|
||||
$id = $this->getVar('look', $segments[$count-1], 'alias', 'id');
|
||||
if($id)
|
||||
{
|
||||
$vars['id'] = $id;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
protected function getVar($table, $where = null, $whereString = null, $what = null, $category = false, $operator = '=', $main = 'demo')
|
||||
public function getLooksSegment($id, $query)
|
||||
{
|
||||
if(!$where || !$what || !$whereString)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
$query->select($db->quoteName(array($what)));
|
||||
if ('categories' == $table || 'category' == $table || $category)
|
||||
{
|
||||
$getTable = '#__categories';
|
||||
$query->from($db->quoteName($getTable));
|
||||
// we need this to target the components categories (TODO will keep an eye on this)
|
||||
$query->where($db->quoteName('extension') . ' LIKE '. $db->quote((string)'com_' . $main . '%'));
|
||||
}
|
||||
else
|
||||
{
|
||||
// we must check if the table exist (TODO not ideal)
|
||||
$tables = $db->getTableList();
|
||||
$app = JFactory::getApplication();
|
||||
$prefix = $app->get('dbprefix');
|
||||
$check = $prefix.$main.'_'.$table;
|
||||
if (in_array($check, $tables))
|
||||
{
|
||||
$getTable = '#__'.$main.'_'.$table;
|
||||
$query->from($db->quoteName($getTable));
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (is_numeric($where))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
elseif ($this->checkString($where))
|
||||
{
|
||||
// we must first check if this table has the column
|
||||
$columns = $db->getTableColumns($getTable);
|
||||
if (isset($columns[$whereString]))
|
||||
{
|
||||
$query->where($db->quoteName($whereString) . ' '.$operator.' '. $db->quote((string)$where));
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
return $db->loadResult();
|
||||
}
|
||||
return false;
|
||||
return $this->getLookSegment($id, $query);
|
||||
}
|
||||
|
||||
protected function checkString($string)
|
||||
|
||||
/**
|
||||
* Method to get the segment(s) for looks
|
||||
*
|
||||
* @param string $segment Segment of the contact to retrieve the ID for
|
||||
* @param array $query The request that is parsed right now
|
||||
*
|
||||
* @return mixed The id of this item or false
|
||||
*/
|
||||
public function getLooksId($segment, $query)
|
||||
{
|
||||
if (isset($string) && is_string($string) && strlen($string) > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
return $this->getLookId($segment, $query);
|
||||
}
|
||||
}
|
||||
|
||||
function DemoBuildRoute(&$query)
|
||||
{
|
||||
$router = new DemoRouter;
|
||||
|
||||
return $router->build($query);
|
||||
}
|
||||
/**
|
||||
* Method to get the segment(s) for a look
|
||||
*
|
||||
* @param string $id ID of the application to retrieve the segments for
|
||||
* @param array $query The request that is built right now
|
||||
*
|
||||
* @return array|string The segments of this item
|
||||
*/
|
||||
public function getLookSegment($id, $query)
|
||||
{
|
||||
if (!strpos($id, ':'))
|
||||
{
|
||||
$dbquery = $this->db->getQuery(true);
|
||||
$dbquery->select($this->db->quoteName('alias'))
|
||||
->from($this->db->quoteName('#__demo_look'))
|
||||
->where('id = ' . $dbquery->q((int) $id));
|
||||
$this->db->setQuery($dbquery);
|
||||
|
||||
function DemoParseRoute($segments)
|
||||
{
|
||||
$router = new DemoRouter;
|
||||
$id .= ':' . $this->db->loadResult();
|
||||
}
|
||||
|
||||
return $router->parse($segments);
|
||||
list($void, $segment) = explode(':', $id, 2);
|
||||
|
||||
return array($void => $segment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the segment(s) for a look
|
||||
*
|
||||
* @param string $segment Segment of the application to retrieve the ID for
|
||||
* @param array $query The request that is parsed right now
|
||||
*
|
||||
* @return mixed The id of this item or false
|
||||
*/
|
||||
public function getLookId($segment, $query)
|
||||
{
|
||||
$query = $this->db->getQuery(true);
|
||||
$query->select($this->db->quoteName('id'))
|
||||
->from($this->db->quoteName('#__demo_look'))
|
||||
->where('alias = ' . $this->db->quote($segment));
|
||||
$this->db->setQuery($query);
|
||||
|
||||
return (int) $this->db->loadResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the segment(s) for a looking
|
||||
*
|
||||
* @param string $id ID of the looking to retrieve the segments for
|
||||
* @param array $query The request that is built right now
|
||||
*
|
||||
* @return array|string The segments of this item
|
||||
*/
|
||||
public function getLookingSegment($id, $query)
|
||||
{
|
||||
if (!strpos($id, ':'))
|
||||
{
|
||||
$dbquery = $this->db->getQuery(true);
|
||||
$dbquery->select($this->db->quoteName('alias'))
|
||||
->from($this->db->quoteName('#__demo_look'))
|
||||
->where('id = ' . $dbquery->q((int) $id));
|
||||
$this->db->setQuery($dbquery);
|
||||
|
||||
$id .= ':' . $this->db->loadResult();
|
||||
}
|
||||
|
||||
list($void, $segment) = explode(':', $id, 2);
|
||||
|
||||
return array($void => $segment);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the segment(s) for a looking
|
||||
*
|
||||
* @param string $segment Segment of the looking to retrieve the ID for
|
||||
* @param array $query The request that is parsed right now
|
||||
*
|
||||
* @return mixed The id of this item or false
|
||||
*/
|
||||
public function getLookingId($segment, $query)
|
||||
{
|
||||
$dbQuery = $this->db->getQuery(true);
|
||||
$dbQuery->select($this->db->quoteName('id'))
|
||||
->from($this->db->quoteName('#__demo_look'))
|
||||
->where(
|
||||
[
|
||||
$this->db->quoteName('alias') . ' = ' . $this->db->quote($segment),
|
||||
$this->db->quoteName('id') . ' = ' . (int) $query['id'],
|
||||
]
|
||||
);;
|
||||
$this->db->setQuery($dbQuery);
|
||||
|
||||
return (int) $this->db->loadResult();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user