Get Demo Component to work on both J3! and J4! via legacy approach #1
@ -21,7 +21,7 @@
|
|||||||
// No direct access to this file
|
// No direct access to this file
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
JHtml::_('behavior.tabstate');
|
//JHtml::_('behavior.tabstate');
|
||||||
|
|
||||||
// Access check.
|
// Access check.
|
||||||
if (!JFactory::getUser()->authorise('core.manage', 'com_demo'))
|
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 '',
|
`mobile_phone` VARCHAR(64) NOT NULL DEFAULT '',
|
||||||
`name` VARCHAR(255) NOT NULL DEFAULT '',
|
`name` VARCHAR(255) NOT NULL DEFAULT '',
|
||||||
`website` 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,
|
`published` TINYINT(3) NOT NULL DEFAULT 1,
|
||||||
`created_by` INT(10) unsigned NOT NULL DEFAULT 0,
|
`created_by` INT(10) unsigned NOT NULL DEFAULT 0,
|
||||||
`modified_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);
|
parent::__construct('#__demo_look', 'id', $db);
|
||||||
|
|
||||||
// Adding History Options
|
// Adding History Options
|
||||||
JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_demo.look'));
|
// JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_demo.look'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function bind($array, $ignore = '')
|
public function bind($array, $ignore = '')
|
||||||
@ -332,7 +332,7 @@ class DemoTableLook extends JTable
|
|||||||
$this->alias = $this->name;
|
$this->alias = $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->alias = JApplication::stringURLSafe($this->alias);
|
$this->alias = JApplicationHelper::stringURLSafe($this->alias);
|
||||||
|
|
||||||
if (trim(str_replace('-', '', $this->alias)) == '')
|
if (trim(str_replace('-', '', $this->alias)) == '')
|
||||||
{
|
{
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
// No direct access to this file
|
// No direct access to this file
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
JHtml::_('behavior.tooltip');
|
//JHtml::_('behavior.tooltip');
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<div id="j-main-container">
|
<div id="j-main-container">
|
||||||
|
@ -22,13 +22,13 @@
|
|||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
|
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
|
||||||
JHtml::_('behavior.tooltip');
|
//JHtml::_('behavior.tooltip');
|
||||||
JHtml::_('behavior.formvalidation');
|
JHtml::_('behavior.formvalidator');
|
||||||
JHtml::_('formbehavior.chosen', 'select');
|
JHtml::_('formbehavior.chosen', 'select');
|
||||||
JHtml::_('behavior.keepalive');
|
JHtml::_('behavior.keepalive');
|
||||||
$componentParams = $this->params; // will be removed just use $this->params instead
|
$componentParams = $this->params; // will be removed just use $this->params instead
|
||||||
?>
|
?>
|
||||||
<script type="text/javascript">
|
<!--<script type="text/javascript">
|
||||||
// waiting spinner
|
// waiting spinner
|
||||||
var outerDiv = jQuery('body');
|
var outerDiv = jQuery('body');
|
||||||
jQuery('<div id="loading"></div>')
|
jQuery('<div id="loading"></div>')
|
||||||
@ -50,7 +50,7 @@ $componentParams = $this->params; // will be removed just use $this->params inst
|
|||||||
jQuery('#loading').hide();
|
jQuery('#loading').hide();
|
||||||
});
|
});
|
||||||
</script>
|
</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">
|
<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); ?>
|
<?php echo JLayoutHelper::render('look.details_above', $this); ?>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
// No direct access to this file
|
// No direct access to this file
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
JHtml::_('behavior.tooltip');
|
//JHtml::_('behavior.tooltip');
|
||||||
JHtml::_('behavior.multiselect');
|
JHtml::_('behavior.multiselect');
|
||||||
JHtml::_('dropdown.init');
|
JHtml::_('dropdown.init');
|
||||||
JHtml::_('formbehavior.chosen', '.multipleAccessLevels', null, array('placeholder_text_multiple' => '- ' . JText::_('COM_DEMO_FILTER_SELECT_ACCESS') . ' -'));
|
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)
|
function display($tpl = null)
|
||||||
{
|
{
|
||||||
if ($this->getLayout() !== 'modal')
|
// if ($this->getLayout() !== 'modal')
|
||||||
{
|
// {
|
||||||
// Include helper submenu
|
// // Include helper submenu
|
||||||
DemoHelper::addSubmenu('looks');
|
// DemoHelper::addSubmenu('looks');
|
||||||
}
|
// }
|
||||||
|
|
||||||
// Assign data to the view
|
// Assign data to the view
|
||||||
$this->items = $this->get('Items');
|
$this->items = $this->get('Items');
|
||||||
|
2
demo.xml
2
demo.xml
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?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>
|
<name>COM_DEMO</name>
|
||||||
<creationDate>8th February, 2021</creationDate>
|
<creationDate>8th February, 2021</creationDate>
|
||||||
<author>Llewellyn van der Merwe</author>
|
<author>Llewellyn van der Merwe</author>
|
||||||
|
@ -32,6 +32,23 @@
|
|||||||
<maintainer>Llewellyn van der Merwe</maintainer>
|
<maintainer>Llewellyn van der Merwe</maintainer>
|
||||||
<maintainerurl>https://www.vdm.io/</maintainerurl>
|
<maintainerurl>https://www.vdm.io/</maintainerurl>
|
||||||
<targetplatform name="joomla" version="3.*"/>
|
<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="3.*" />
|
||||||
</update>
|
</update>
|
||||||
<update>
|
<update>
|
||||||
<name>Demo</name>
|
<name>Demo</name>
|
||||||
@ -48,6 +65,6 @@
|
|||||||
</tags>
|
</tags>
|
||||||
<maintainer>Llewellyn van der Merwe</maintainer>
|
<maintainer>Llewellyn van der Merwe</maintainer>
|
||||||
<maintainerurl>https://www.vdm.io/</maintainerurl>
|
<maintainerurl>https://www.vdm.io/</maintainerurl>
|
||||||
<targetplatform name="joomla" version="3.*"/>
|
<targetplatform name="joomla" version="4.*" />
|
||||||
</update>
|
</update>
|
||||||
</updates>
|
</updates>
|
380
script.php
380
script.php
@ -21,7 +21,17 @@
|
|||||||
// No direct access to this file
|
// No direct access to this file
|
||||||
defined('_JEXEC') or die('Restricted access');
|
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
|
* Script File of Demo Component
|
||||||
@ -33,7 +43,7 @@ class com_demoInstallerScript
|
|||||||
*
|
*
|
||||||
* @param JAdapterInstance $parent The object responsible for running this script
|
* @param JAdapterInstance $parent The object responsible for running this script
|
||||||
*/
|
*/
|
||||||
public function __construct(JAdapterInstance $parent) {}
|
public function __construct(ComponentAdapter $parent) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on installation
|
* Called on installation
|
||||||
@ -42,20 +52,20 @@ class com_demoInstallerScript
|
|||||||
*
|
*
|
||||||
* @return boolean True on success
|
* @return boolean True on success
|
||||||
*/
|
*/
|
||||||
public function install(JAdapterInstance $parent) {}
|
public function install(ComponentAdapter $parent) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called on uninstallation
|
* Called on uninstallation
|
||||||
*
|
*
|
||||||
* @param JAdapterInstance $parent The object responsible for running this script
|
* @param JAdapterInstance $parent The object responsible for running this script
|
||||||
*/
|
*/
|
||||||
public function uninstall(JAdapterInstance $parent)
|
public function uninstall(ComponentAdapter $parent)
|
||||||
{
|
{
|
||||||
// Get Application object
|
// Get Application object
|
||||||
$app = JFactory::getApplication();
|
$app = Factory::getApplication();
|
||||||
|
|
||||||
// Get The Database object
|
// Get The Database object
|
||||||
$db = JFactory::getDbo();
|
$db = Factory::getDbo();
|
||||||
|
|
||||||
// Create a new query object.
|
// Create a new query object.
|
||||||
$query = $db->getQuery(true);
|
$query = $db->getQuery(true);
|
||||||
@ -325,36 +335,36 @@ class com_demoInstallerScript
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get the biggest rule column in the assets table at this point.
|
// 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";
|
// $get_rule_length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1";
|
||||||
$db->setQuery($get_rule_length);
|
// $db->setQuery($get_rule_length);
|
||||||
if ($db->execute())
|
// if ($db->execute())
|
||||||
{
|
// {
|
||||||
$rule_length = $db->loadResult();
|
// $rule_length = $db->loadResult();
|
||||||
// Check the size of the rules column
|
// // Check the size of the rules column
|
||||||
if ($rule_length < 5120)
|
// if ($rule_length < 5120)
|
||||||
{
|
// {
|
||||||
// Revert the assets table rules column back to the default
|
// // 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.';";
|
// $revert_rule = "ALTER TABLE `#__assets` CHANGE `rules` `rules` varchar(5120) NOT NULL COMMENT 'JSON encoded access control.';";
|
||||||
$db->setQuery($revert_rule);
|
// $db->setQuery($revert_rule);
|
||||||
$db->execute();
|
// $db->execute();
|
||||||
$app->enqueueMessage(JText::_('Reverted the <b>#__assets</b> table rules column back to its default size of varchar(5120)'));
|
// $app->enqueueMessage(JText::_('Reverted the <b>#__assets</b> table rules column back to its default size of varchar(5120)'));
|
||||||
}
|
// }
|
||||||
else
|
// 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.
|
// Set db if not set already.
|
||||||
if (!isset($db))
|
if (!isset($db))
|
||||||
{
|
{
|
||||||
$db = JFactory::getDbo();
|
$db = Factory::getDbo();
|
||||||
}
|
}
|
||||||
// Set app if not set already.
|
// Set app if not set already.
|
||||||
if (!isset($app))
|
if (!isset($app))
|
||||||
{
|
{
|
||||||
$app = JFactory::getApplication();
|
$app = Factory::getApplication();
|
||||||
}
|
}
|
||||||
// Remove Demo from the action_logs_extensions table
|
// Remove Demo from the action_logs_extensions table
|
||||||
$demo_action_logs_extensions = array( $db->quoteName('extension') . ' = ' . $db->quote('com_demo') );
|
$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.
|
// Set db if not set already.
|
||||||
if (!isset($db))
|
if (!isset($db))
|
||||||
{
|
{
|
||||||
$db = JFactory::getDbo();
|
$db = Factory::getDbo();
|
||||||
}
|
}
|
||||||
// Set app if not set already.
|
// Set app if not set already.
|
||||||
if (!isset($app))
|
if (!isset($app))
|
||||||
{
|
{
|
||||||
$app = JFactory::getApplication();
|
$app = Factory::getApplication();
|
||||||
}
|
}
|
||||||
// Remove Demo Look from the action_log_config table
|
// Remove Demo Look from the action_log_config table
|
||||||
$look_action_log_config = array( $db->quoteName('type_alias') . ' = '. $db->quote('com_demo.look') );
|
$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
|
* @return boolean True on success
|
||||||
*/
|
*/
|
||||||
public function update(JAdapterInstance $parent){}
|
public function update(ComponentAdapter $parent){}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called before any type of action
|
* Called before any type of action
|
||||||
@ -420,10 +430,10 @@ class com_demoInstallerScript
|
|||||||
*
|
*
|
||||||
* @return boolean True on success
|
* @return boolean True on success
|
||||||
*/
|
*/
|
||||||
public function preflight($type, JAdapterInstance $parent)
|
public function preflight($type, ComponentAdapter $parent)
|
||||||
{
|
{
|
||||||
// get application
|
// get application
|
||||||
$app = JFactory::getApplication();
|
$app = Factory::getApplication();
|
||||||
// is redundant or so it seems ...hmmm let me know if it works again
|
// is redundant or so it seems ...hmmm let me know if it works again
|
||||||
if ($type === 'uninstall')
|
if ($type === 'uninstall')
|
||||||
{
|
{
|
||||||
@ -463,10 +473,10 @@ class com_demoInstallerScript
|
|||||||
*
|
*
|
||||||
* @return boolean True on success
|
* @return boolean True on success
|
||||||
*/
|
*/
|
||||||
public function postflight($type, JAdapterInstance $parent)
|
public function postflight($type, ComponentAdapter $parent)
|
||||||
{
|
{
|
||||||
// get application
|
// get application
|
||||||
$app = JFactory::getApplication();
|
$app = Factory::getApplication();
|
||||||
// We check if we have dynamic folders to copy
|
// We check if we have dynamic folders to copy
|
||||||
$this->setDynamicF0ld3rs($app, $parent);
|
$this->setDynamicF0ld3rs($app, $parent);
|
||||||
// set the default component settings
|
// set the default component settings
|
||||||
@ -474,34 +484,34 @@ class com_demoInstallerScript
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Get The Database object
|
// Get The Database object
|
||||||
$db = JFactory::getDbo();
|
$db = Factory::getDbo();
|
||||||
|
//
|
||||||
// Create the look content type object.
|
// // Create the look content type object.
|
||||||
$look = new stdClass();
|
// $look = new stdClass();
|
||||||
$look->type_title = 'Demo Look';
|
// $look->type_title = 'Demo Look';
|
||||||
$look->type_alias = 'com_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->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->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->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->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.
|
// // Set the object into the content types table.
|
||||||
$look_Inserted = $db->insertObject('#__content_types', $look);
|
// $look_Inserted = $db->insertObject('#__content_types', $look);
|
||||||
|
|
||||||
|
|
||||||
// Install the global extenstion assets permission.
|
// Install the global extenstion assets permission.
|
||||||
$query = $db->getQuery(true);
|
// $query = $db->getQuery(true);
|
||||||
// Field to update.
|
// Field to update.
|
||||||
$fields = array(
|
// $fields = array(
|
||||||
$db->quoteName('rules') . ' = ' . $db->quote('{"site.looks.access":{"1":1}}'),
|
// $db->quoteName('rules') . ' = ' . $db->quote('{"site.looks.access":{"1":1}}'),
|
||||||
);
|
// );
|
||||||
// Condition.
|
// Condition.
|
||||||
$conditions = array(
|
// $conditions = array(
|
||||||
$db->quoteName('name') . ' = ' . $db->quote('com_demo')
|
// $db->quoteName('name') . ' = ' . $db->quote('com_demo')
|
||||||
);
|
// );
|
||||||
$query->update($db->quoteName('#__assets'))->set($fields)->where($conditions);
|
// $query->update($db->quoteName('#__assets'))->set($fields)->where($conditions);
|
||||||
$db->setQuery($query);
|
// $db->setQuery($query);
|
||||||
$allDone = $db->execute();
|
// $allDone = $db->execute();
|
||||||
|
|
||||||
// Install the global extenstion params.
|
// Install the global extenstion params.
|
||||||
$query = $db->getQuery(true);
|
$query = $db->getQuery(true);
|
||||||
@ -519,92 +529,92 @@ class com_demoInstallerScript
|
|||||||
|
|
||||||
|
|
||||||
// Get Application object
|
// 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');
|
$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 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";
|
// $get_rule_length = "SELECT CHAR_LENGTH(`rules`) as rule_size FROM #__assets ORDER BY rule_size DESC LIMIT 1";
|
||||||
$db->setQuery($get_rule_length);
|
// $db->setQuery($get_rule_length);
|
||||||
if ($db->execute())
|
// if ($db->execute())
|
||||||
{
|
// {
|
||||||
$rule_length = $db->loadResult();
|
// $rule_length = $db->loadResult();
|
||||||
// Check the size of the rules column
|
// // Check the size of the rules column
|
||||||
if ($rule_length <= 5600)
|
// if ($rule_length <= 5600)
|
||||||
{
|
// {
|
||||||
// Fix the assets table rules column size
|
// // 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';";
|
// $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->setQuery($fix_rules_size);
|
||||||
$db->execute();
|
// $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.'));
|
// $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">
|
// echo '<a target="_blank" href="https://www.vdm.io/" title="Demo">
|
||||||
<img src="components/com_demo/assets/images/vdm-component.jpg"/>
|
// <img src="components/com_demo/assets/images/vdm-component.jpg"/>
|
||||||
</a>';
|
// </a>';
|
||||||
|
|
||||||
// Set db if not set already.
|
// Set db if not set already.
|
||||||
if (!isset($db))
|
// if (!isset($db))
|
||||||
{
|
// {
|
||||||
$db = JFactory::getDbo();
|
// $db = Factory::getDbo();
|
||||||
}
|
// }
|
||||||
// Create the demo action logs extensions object.
|
// // Create the demo action logs extensions object.
|
||||||
$demo_action_logs_extensions = new stdClass();
|
// $demo_action_logs_extensions = new stdClass();
|
||||||
$demo_action_logs_extensions->extension = 'com_demo';
|
// $demo_action_logs_extensions->extension = 'com_demo';
|
||||||
|
//
|
||||||
// Set the object into the action logs extensions table.
|
// // 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.
|
// // Set db if not set already.
|
||||||
if (!isset($db))
|
// if (!isset($db))
|
||||||
{
|
// {
|
||||||
$db = JFactory::getDbo();
|
// $db = Factory::getDbo();
|
||||||
}
|
// }
|
||||||
// Create the look action log config object.
|
// // Create the look action log config object.
|
||||||
$look_action_log_config = new stdClass();
|
// $look_action_log_config = new stdClass();
|
||||||
$look_action_log_config->type_title = 'LOOK';
|
// $look_action_log_config->type_title = 'LOOK';
|
||||||
$look_action_log_config->type_alias = 'com_demo.look';
|
// $look_action_log_config->type_alias = 'com_demo.look';
|
||||||
$look_action_log_config->id_holder = 'id';
|
// $look_action_log_config->id_holder = 'id';
|
||||||
$look_action_log_config->title_holder = 'name';
|
// $look_action_log_config->title_holder = 'name';
|
||||||
$look_action_log_config->table_name = '#__demo_look';
|
// $look_action_log_config->table_name = '#__demo_look';
|
||||||
$look_action_log_config->text_prefix = 'COM_DEMO';
|
// $look_action_log_config->text_prefix = 'COM_DEMO';
|
||||||
|
//
|
||||||
// Set the object into the action log config table.
|
// // Set the object into the action log config table.
|
||||||
$look_Inserted = $db->insertObject('#__action_log_config', $look_action_log_config);
|
// $look_Inserted = $db->insertObject('#__action_log_config', $look_action_log_config);
|
||||||
}
|
}
|
||||||
// do any updates needed
|
// do any updates needed
|
||||||
if ($type === 'update')
|
if ($type === 'update')
|
||||||
{
|
{
|
||||||
|
|
||||||
// Get The Database object
|
// Get The Database object
|
||||||
$db = JFactory::getDbo();
|
// $db = Factory::getDbo();
|
||||||
|
|
||||||
// Create the look content type object.
|
// Create the look content type object.
|
||||||
$look = new stdClass();
|
// $look = new stdClass();
|
||||||
$look->type_title = 'Demo Look';
|
// $look->type_title = 'Demo Look';
|
||||||
$look->type_alias = 'com_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->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->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->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->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.
|
// Check if look type is already in content_type DB.
|
||||||
$look_id = null;
|
// $look_id = null;
|
||||||
$query = $db->getQuery(true);
|
// $query = $db->getQuery(true);
|
||||||
$query->select($db->quoteName(array('type_id')));
|
// $query->select($db->quoteName(array('type_id')));
|
||||||
$query->from($db->quoteName('#__content_types'));
|
// $query->from($db->quoteName('#__content_types'));
|
||||||
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($look->type_alias));
|
// $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($look->type_alias));
|
||||||
$db->setQuery($query);
|
// $db->setQuery($query);
|
||||||
$db->execute();
|
// $db->execute();
|
||||||
|
//
|
||||||
// Set the object into the content types table.
|
// // Set the object into the content types table.
|
||||||
if ($db->getNumRows())
|
// if ($db->getNumRows())
|
||||||
{
|
// {
|
||||||
$look->type_id = $db->loadResult();
|
// $look->type_id = $db->loadResult();
|
||||||
$look_Updated = $db->updateObject('#__content_types', $look, 'type_id');
|
// $look_Updated = $db->updateObject('#__content_types', $look, 'type_id');
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
$look_Inserted = $db->insertObject('#__content_types', $look);
|
// $look_Inserted = $db->insertObject('#__content_types', $look);
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
echo '<a target="_blank" href="https://www.vdm.io/" title="Demo">
|
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>';
|
<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.
|
// Set db if not set already.
|
||||||
if (!isset($db))
|
// if (!isset($db))
|
||||||
{
|
// {
|
||||||
$db = JFactory::getDbo();
|
// $db = Factory::getDbo();
|
||||||
}
|
// }
|
||||||
// Create the demo action logs extensions object.
|
// // Create the demo action logs extensions object.
|
||||||
$demo_action_logs_extensions = new stdClass();
|
// $demo_action_logs_extensions = new stdClass();
|
||||||
$demo_action_logs_extensions->extension = 'com_demo';
|
// $demo_action_logs_extensions->extension = 'com_demo';
|
||||||
|
//
|
||||||
// Check if demo action log extension is already in action logs extensions DB.
|
// // Check if demo action log extension is already in action logs extensions DB.
|
||||||
$query = $db->getQuery(true);
|
// $query = $db->getQuery(true);
|
||||||
$query->select($db->quoteName(array('id')));
|
// $query->select($db->quoteName(array('id')));
|
||||||
$query->from($db->quoteName('#__action_logs_extensions'));
|
// $query->from($db->quoteName('#__action_logs_extensions'));
|
||||||
$query->where($db->quoteName('extension') . ' LIKE '. $db->quote($demo_action_logs_extensions->extension));
|
// $query->where($db->quoteName('extension') . ' LIKE '. $db->quote($demo_action_logs_extensions->extension));
|
||||||
$db->setQuery($query);
|
// $db->setQuery($query);
|
||||||
$db->execute();
|
// $db->execute();
|
||||||
|
//
|
||||||
// Set the object into the action logs extensions table if not found.
|
// // Set the object into the action logs extensions table if not found.
|
||||||
if (!$db->getNumRows())
|
// if (!$db->getNumRows())
|
||||||
{
|
// {
|
||||||
$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.
|
// // Set db if not set already.
|
||||||
if (!isset($db))
|
// if (!isset($db))
|
||||||
{
|
// {
|
||||||
$db = JFactory::getDbo();
|
// $db = Factory::getDbo();
|
||||||
}
|
// }
|
||||||
// Create the look action log config object.
|
// // Create the look action log config object.
|
||||||
$look_action_log_config = new stdClass();
|
// $look_action_log_config = new stdClass();
|
||||||
$look_action_log_config->id = null;
|
// $look_action_log_config->id = null;
|
||||||
$look_action_log_config->type_title = 'LOOK';
|
// $look_action_log_config->type_title = 'LOOK';
|
||||||
$look_action_log_config->type_alias = 'com_demo.look';
|
// $look_action_log_config->type_alias = 'com_demo.look';
|
||||||
$look_action_log_config->id_holder = 'id';
|
// $look_action_log_config->id_holder = 'id';
|
||||||
$look_action_log_config->title_holder = 'name';
|
// $look_action_log_config->title_holder = 'name';
|
||||||
$look_action_log_config->table_name = '#__demo_look';
|
// $look_action_log_config->table_name = '#__demo_look';
|
||||||
$look_action_log_config->text_prefix = 'COM_DEMO';
|
// $look_action_log_config->text_prefix = 'COM_DEMO';
|
||||||
|
//
|
||||||
// Check if look action log config is already in action_log_config DB.
|
// // Check if look action log config is already in action_log_config DB.
|
||||||
$query = $db->getQuery(true);
|
// $query = $db->getQuery(true);
|
||||||
$query->select($db->quoteName(array('id')));
|
// $query->select($db->quoteName(array('id')));
|
||||||
$query->from($db->quoteName('#__action_log_config'));
|
// $query->from($db->quoteName('#__action_log_config'));
|
||||||
$query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($look_action_log_config->type_alias));
|
// $query->where($db->quoteName('type_alias') . ' LIKE '. $db->quote($look_action_log_config->type_alias));
|
||||||
$db->setQuery($query);
|
// $db->setQuery($query);
|
||||||
$db->execute();
|
// $db->execute();
|
||||||
|
//
|
||||||
// Set the object into the content types table.
|
// 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->id = $db->loadResult();
|
||||||
$look_action_log_config_Updated = $db->updateObject('#__action_log_config', $look_action_log_config, 'id');
|
// $look_action_log_config_Updated = $db->updateObject('#__action_log_config', $look_action_log_config, 'id');
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
$look_action_log_config_Inserted = $db->insertObject('#__action_log_config', $look_action_log_config);
|
// $look_action_log_config_Inserted = $db->insertObject('#__action_log_config', $look_action_log_config);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
// No direct access to this file
|
// No direct access to this file
|
||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
JHtml::_('behavior.tabstate');
|
//JHtml::_('behavior.tabstate');
|
||||||
|
|
||||||
// Set the component css/js
|
// Set the component css/js
|
||||||
$document = JFactory::getDocument();
|
$document = JFactory::getDocument();
|
||||||
|
@ -141,15 +141,15 @@ class DemoModelLooking extends JModelItem
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Load the JEvent Dispatcher
|
// Load the JEvent Dispatcher
|
||||||
JPluginHelper::importPlugin('content');
|
// JPluginHelper::importPlugin('content');
|
||||||
$this->_dispatcher = JEventDispatcher::getInstance();
|
// $this->_dispatcher = JEventDispatcher::getInstance();
|
||||||
// Check if item has params, or pass whole item.
|
// Check if item has params, or pass whole item.
|
||||||
$params = (isset($data->params) && DemoHelper::checkJson($data->params)) ? json_decode($data->params) : $data;
|
$params = (isset($data->params) && DemoHelper::checkJson($data->params)) ? json_decode($data->params) : $data;
|
||||||
// Make sure the content prepare plugins fire on description
|
// Make sure the content prepare plugins fire on description
|
||||||
$_description = new stdClass();
|
$_description = new stdClass();
|
||||||
$_description->text =& $data->description; // value must be in text
|
$_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
|
// 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.
|
// Checking if description has uikit components that must be loaded.
|
||||||
$this->uikitComp = DemoHelper::getUikitComp($data->description,$this->uikitComp);
|
$this->uikitComp = DemoHelper::getUikitComp($data->description,$this->uikitComp);
|
||||||
|
|
||||||
|
351
site/router.php
351
site/router.php
@ -21,239 +21,184 @@
|
|||||||
// No direct access to this file
|
// No direct access to this file
|
||||||
defined('_JEXEC') or die('Restricted access');
|
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
|
* Routing class from com_demo
|
||||||
*
|
*
|
||||||
* @since 3.3
|
* @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
|
* @var \JDatabaseDriver
|
||||||
*
|
* @since 1.0
|
||||||
* @return array The URL arguments to use to assemble the subsequent URL.
|
|
||||||
*
|
|
||||||
* @since 3.3
|
|
||||||
*/
|
*/
|
||||||
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
|
$looks = new RouterViewConfiguration('looks');
|
||||||
$params = JComponentHelper::getParams('com_demo');
|
$this->registerView($looks);
|
||||||
|
|
||||||
if (empty($query['Itemid']))
|
$look = (new RouterViewConfiguration('look'))
|
||||||
{
|
->setParent($looks)
|
||||||
$menuItem = $this->menu->getActive();
|
->setKey('id');
|
||||||
}
|
$this->registerView($look);
|
||||||
else
|
|
||||||
{
|
|
||||||
$menuItem = $this->menu->getItem($query['Itemid']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$mView = (empty($menuItem->query['view'])) ? null : $menuItem->query['view'];
|
$looking = (new RouterViewConfiguration('looking'))
|
||||||
$mId = (empty($menuItem->query['id'])) ? null : $menuItem->query['id'];
|
->setParent($look, 'id')
|
||||||
|
->setKey('id');
|
||||||
|
|
||||||
if (isset($query['view']))
|
$this->registerView($looking);
|
||||||
{
|
|
||||||
$view = $query['view'];
|
|
||||||
|
|
||||||
if (empty($query['Itemid']))
|
$export = (new RouterViewConfiguration('export'))
|
||||||
{
|
->setKey('cms_version');
|
||||||
$segments[] = $query['view'];
|
$this->registerView($export);
|
||||||
}
|
|
||||||
|
|
||||||
unset($query['view']);
|
parent::__construct($app, $menu);
|
||||||
}
|
|
||||||
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
|
$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.
|
* @return array|string The segments of this item
|
||||||
*
|
|
||||||
* @since 3.3
|
|
||||||
*/
|
*/
|
||||||
public function parse(&$segments)
|
public function getLooksSegment($id, $query)
|
||||||
{
|
{
|
||||||
$count = count($segments);
|
return $this->getLookSegment($id, $query);
|
||||||
$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')
|
/**
|
||||||
|
* 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(!$where || !$what || !$whereString)
|
return $this->getLookId($segment, $query);
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function checkString($string)
|
/**
|
||||||
|
* 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 (isset($string) && is_string($string) && strlen($string) > 0)
|
if (!strpos($id, ':'))
|
||||||
{
|
{
|
||||||
return 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);
|
||||||
|
|
||||||
|
$id .= ':' . $this->db->loadResult();
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
list($void, $segment) = explode(':', $id, 2);
|
||||||
|
|
||||||
|
return array($void => $segment);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
function DemoBuildRoute(&$query)
|
* Method to get the segment(s) for an application
|
||||||
{
|
*
|
||||||
$router = new DemoRouter;
|
* @param string $segment Segment of the application to retrieve the ID for
|
||||||
|
* @param array $query The request that is parsed right now
|
||||||
return $router->build($query);
|
*
|
||||||
}
|
* @return mixed The id of this item or false
|
||||||
|
*/
|
||||||
function DemoParseRoute($segments)
|
public function getLookId($segment, $query)
|
||||||
{
|
{
|
||||||
$router = new DemoRouter;
|
$query = $this->db->getQuery(true);
|
||||||
|
$query->select($this->db->quoteName('id'))
|
||||||
return $router->parse($segments);
|
->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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -22,12 +22,12 @@
|
|||||||
defined('_JEXEC') or die('Restricted access');
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
|
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
|
||||||
JHtml::_('behavior.tooltip');
|
//JHtml::_('behavior.tooltip');
|
||||||
JHtml::_('behavior.formvalidation');
|
JHtml::_('behavior.formvalidator');
|
||||||
JHtml::_('formbehavior.chosen', 'select');
|
JHtml::_('formbehavior.chosen', 'select');
|
||||||
JHtml::_('behavior.keepalive');
|
JHtml::_('behavior.keepalive');
|
||||||
JHtml::_('behavior.tabstate');
|
//JHtml::_('behavior.tabstate');
|
||||||
JHtml::_('behavior.calendar');
|
//JHtml::_('behavior.calendar');
|
||||||
?>
|
?>
|
||||||
<div class="demo-look">
|
<div class="demo-look">
|
||||||
<?php echo $this->toolbar->render(); ?>
|
<?php echo $this->toolbar->render(); ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user