Get Demo Component to work on both J3! and J4! via legacy approach #1
@ -21,7 +21,7 @@
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
JHtml::_('behavior.tabstate');
|
||||
//JHtml::_('behavior.tabstate');
|
||||
|
||||
// Access check.
|
||||
if (!JFactory::getUser()->authorise('core.manage', 'com_demo'))
|
||||
|
@ -10,7 +10,7 @@ CREATE TABLE IF NOT EXISTS `#__demo_look` (
|
||||
`mobile_phone` VARCHAR(64) NOT NULL DEFAULT '',
|
||||
`name` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`website` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`params` text NOT NULL,
|
||||
`params` text NULL,
|
||||
`published` TINYINT(3) NOT NULL DEFAULT 1,
|
||||
`created_by` INT(10) unsigned NOT NULL DEFAULT 0,
|
||||
`modified_by` INT(10) unsigned NOT NULL DEFAULT 0,
|
||||
|
@ -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 = '')
|
||||
@ -332,7 +332,7 @@ class DemoTableLook extends JTable
|
||||
$this->alias = $this->name;
|
||||
}
|
||||
|
||||
$this->alias = JApplication::stringURLSafe($this->alias);
|
||||
$this->alias = JApplicationHelper::stringURLSafe($this->alias);
|
||||
|
||||
if (trim(str_replace('-', '', $this->alias)) == '')
|
||||
{
|
||||
|
@ -21,7 +21,7 @@
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
JHtml::_('behavior.tooltip');
|
||||
//JHtml::_('behavior.tooltip');
|
||||
|
||||
?>
|
||||
<div id="j-main-container">
|
||||
|
@ -22,13 +22,13 @@
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
|
||||
JHtml::_('behavior.tooltip');
|
||||
JHtml::_('behavior.formvalidation');
|
||||
//JHtml::_('behavior.tooltip');
|
||||
JHtml::_('behavior.formvalidator');
|
||||
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>')
|
||||
@ -50,7 +50,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); ?>
|
||||
|
@ -21,7 +21,7 @@
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
JHtml::_('behavior.tooltip');
|
||||
//JHtml::_('behavior.tooltip');
|
||||
JHtml::_('behavior.multiselect');
|
||||
JHtml::_('dropdown.init');
|
||||
JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_DEMO_FILTER_SELECT_ACCESS') . ' -'));
|
||||
|
@ -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>8th February, 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>
|
380
script.php
380
script.php
@ -21,7 +21,17 @@
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
JHTML::_('behavior.modal');
|
||||
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
|
||||
@ -33,7 +43,7 @@ class com_demoInstallerScript
|
||||
*
|
||||
* @param JAdapterInstance $parent The object responsible for running this script
|
||||
*/
|
||||
public function __construct(JAdapterInstance $parent) {}
|
||||
public function __construct(ComponentAdapter $parent) {}
|
||||
|
||||
/**
|
||||
* Called on installation
|
||||
@ -42,20 +52,20 @@ class com_demoInstallerScript
|
||||
*
|
||||
* @return boolean True on success
|
||||
*/
|
||||
public function install(JAdapterInstance $parent) {}
|
||||
public function install(ComponentAdapter $parent) {}
|
||||
|
||||
/**
|
||||
* Called on uninstallation
|
||||
*
|
||||
* @param JAdapterInstance $parent The object responsible for running this script
|
||||
*/
|
||||
public function uninstall(JAdapterInstance $parent)
|
||||
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') );
|
||||
@ -410,7 +420,7 @@ class com_demoInstallerScript
|
||||
*
|
||||
* @return boolean True on success
|
||||
*/
|
||||
public function update(JAdapterInstance $parent){}
|
||||
public function update(ComponentAdapter $parent){}
|
||||
|
||||
/**
|
||||
* Called before any type of action
|
||||
@ -420,10 +430,10 @@ class com_demoInstallerScript
|
||||
*
|
||||
* @return boolean True on success
|
||||
*/
|
||||
public function preflight($type, JAdapterInstance $parent)
|
||||
public function preflight($type, ComponentAdapter $parent)
|
||||
{
|
||||
// get application
|
||||
$app = JFactory::getApplication();
|
||||
$app = Factory::getApplication();
|
||||
// is redundant or so it seems ...hmmm let me know if it works again
|
||||
if ($type === 'uninstall')
|
||||
{
|
||||
@ -463,10 +473,10 @@ class com_demoInstallerScript
|
||||
*
|
||||
* @return boolean True on success
|
||||
*/
|
||||
public function postflight($type, JAdapterInstance $parent)
|
||||
public function postflight($type, ComponentAdapter $parent)
|
||||
{
|
||||
// get application
|
||||
$app = JFactory::getApplication();
|
||||
$app = Factory::getApplication();
|
||||
// We check if we have dynamic folders to copy
|
||||
$this->setDynamicF0ld3rs($app, $parent);
|
||||
// set the default component settings
|
||||
@ -474,34 +484,34 @@ class com_demoInstallerScript
|
||||
{
|
||||
|
||||
// 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);
|
||||
@ -519,92 +529,92 @@ class com_demoInstallerScript
|
||||
|
||||
|
||||
// Get Application object
|
||||
$app = JFactory::getApplication();
|
||||
$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);
|
||||
// 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,61 +623,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';
|
||||
|
||||
// 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())
|
||||
{
|
||||
$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);
|
||||
}
|
||||
// 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,7 +21,7 @@
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
JHtml::_('behavior.tabstate');
|
||||
//JHtml::_('behavior.tabstate');
|
||||
|
||||
// Set the component css/js
|
||||
$document = JFactory::getDocument();
|
||||
|
@ -141,15 +141,15 @@ class DemoModelLooking extends JModelItem
|
||||
return false;
|
||||
}
|
||||
// Load the JEvent Dispatcher
|
||||
JPluginHelper::importPlugin('content');
|
||||
$this->_dispatcher = JEventDispatcher::getInstance();
|
||||
// JPluginHelper::importPlugin('content');
|
||||
// $this->_dispatcher = JEventDispatcher::getInstance();
|
||||
// Check if item has params, or pass whole item.
|
||||
$params = (isset($data->params) && DemoHelper::checkJson($data->params)) ? json_decode($data->params) : $data;
|
||||
// Make sure the content prepare plugins fire on description
|
||||
$_description = new stdClass();
|
||||
$_description->text =& $data->description; // value must be in text
|
||||
// Since all values are now in text (Joomla Limitation), we also add the field name (description) to context
|
||||
$this->_dispatcher->trigger("onContentPrepare", array('com_demo.looking.description', &$_description, &$params, 0));
|
||||
// $this->_dispatcher->trigger("onContentPrepare", array('com_demo.looking.description', &$_description, &$params, 0));
|
||||
// Checking if description has uikit components that must be loaded.
|
||||
$this->uikitComp = DemoHelper::getUikitComp($data->description,$this->uikitComp);
|
||||
|
||||
|
331
site/router.php
331
site/router.php
@ -21,239 +21,184 @@
|
||||
// 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)
|
||||
{
|
||||
$segments = array();
|
||||
protected $db;
|
||||
|
||||
// Get a menu item based on Itemid or currently active
|
||||
$params = JComponentHelper::getParams('com_demo');
|
||||
|
||||
if (empty($query['Itemid']))
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$menuItem = $this->menu->getActive();
|
||||
}
|
||||
else
|
||||
{
|
||||
$menuItem = $this->menu->getItem($query['Itemid']);
|
||||
}
|
||||
$this->db = Factory::getDbo();
|
||||
|
||||
$mView = (empty($menuItem->query['view'])) ? null : $menuItem->query['view'];
|
||||
$mId = (empty($menuItem->query['id'])) ? null : $menuItem->query['id'];
|
||||
$looks = new RouterViewConfiguration('looks');
|
||||
$this->registerView($looks);
|
||||
|
||||
if (isset($query['view']))
|
||||
{
|
||||
$view = $query['view'];
|
||||
$look = (new RouterViewConfiguration('look'))
|
||||
->setParent($looks)
|
||||
->setKey('id');
|
||||
$this->registerView($look);
|
||||
|
||||
if (empty($query['Itemid']))
|
||||
{
|
||||
$segments[] = $query['view'];
|
||||
}
|
||||
$looking = (new RouterViewConfiguration('looking'))
|
||||
->setParent($look, 'id')
|
||||
->setKey('id');
|
||||
|
||||
unset($query['view']);
|
||||
}
|
||||
$this->registerView($looking);
|
||||
|
||||
// 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);
|
||||
|
||||
for ($i = 0; $i < $total; $i++)
|
||||
{
|
||||
$segments[$i] = str_replace(':', '-', $segments[$i]);
|
||||
}
|
||||
|
||||
return $segments;
|
||||
parent::__construct($app, $menu);
|
||||
|
||||
$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)
|
||||
public function getLooksSegment($id, $query)
|
||||
{
|
||||
$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 $this->getLookSegment($id, $query);
|
||||
}
|
||||
|
||||
return $vars;
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
return $this->getLookId($segment, $query);
|
||||
}
|
||||
|
||||
protected function getVar($table, $where = null, $whereString = null, $what = null, $category = false, $operator = '=', $main = 'demo')
|
||||
/**
|
||||
* 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(!$where || !$what || !$whereString)
|
||||
if (!strpos($id, ':'))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
// Get a db connection.
|
||||
$db = JFactory::getDbo();
|
||||
// Create a new query object.
|
||||
$query = $db->getQuery(true);
|
||||
$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);
|
||||
|
||||
$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;
|
||||
$id .= ':' . $this->db->loadResult();
|
||||
}
|
||||
|
||||
protected function checkString($string)
|
||||
{
|
||||
if (isset($string) && is_string($string) && strlen($string) > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
list($void, $segment) = explode(':', $id, 2);
|
||||
|
||||
return array($void => $segment);
|
||||
}
|
||||
|
||||
function DemoBuildRoute(&$query)
|
||||
/**
|
||||
* Method to get the segment(s) for an application
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
$router = new DemoRouter;
|
||||
$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 $router->build($query);
|
||||
return (int) $this->db->loadResult();
|
||||
}
|
||||
|
||||
function DemoParseRoute($segments)
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
$router = new DemoRouter;
|
||||
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();
|
||||
}
|
||||
|
||||
return $router->parse($segments);
|
||||
}
|
@ -22,12 +22,12 @@
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
|
||||
JHtml::_('behavior.tooltip');
|
||||
JHtml::_('behavior.formvalidation');
|
||||
//JHtml::_('behavior.tooltip');
|
||||
JHtml::_('behavior.formvalidator');
|
||||
JHtml::_('formbehavior.chosen', 'select');
|
||||
JHtml::_('behavior.keepalive');
|
||||
JHtml::_('behavior.tabstate');
|
||||
JHtml::_('behavior.calendar');
|
||||
//JHtml::_('behavior.tabstate');
|
||||
//JHtml::_('behavior.calendar');
|
||||
?>
|
||||
<div class="demo-look">
|
||||
<?php echo $this->toolbar->render(); ?>
|
||||
|
Loading…
Reference in New Issue
Block a user