2015-08-24 20:22:07 +00:00
|
|
|
<?php
|
2021-10-18 19:47:53 +00:00
|
|
|
/*----------------------------------------------------------------------------------| www.vdm.io |----/
|
|
|
|
Vast Development Method
|
|
|
|
/-------------------------------------------------------------------------------------------------------/
|
|
|
|
|
|
|
|
@version 2.0.3
|
|
|
|
@build 18th October, 2021
|
|
|
|
@created 18th October, 2016
|
|
|
|
@package Demo
|
|
|
|
@subpackage router.php
|
|
|
|
@author Llewellyn van der Merwe <https://www.vdm.io/>
|
|
|
|
@copyright Copyright (C) 2015. All Rights Reserved
|
|
|
|
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____
|
|
|
|
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _)
|
|
|
|
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )(
|
|
|
|
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__)
|
|
|
|
|
|
|
|
/------------------------------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
// No direct access to this file
|
|
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
|
2021-10-19 17:28:23 +00:00
|
|
|
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;
|
|
|
|
|
2021-10-18 19:47:53 +00:00
|
|
|
/**
|
|
|
|
* Routing class from com_demo
|
|
|
|
*
|
|
|
|
* @since 3.3
|
|
|
|
*/
|
2021-10-19 17:28:23 +00:00
|
|
|
class DemoRouter extends RouterView
|
2021-10-18 19:47:53 +00:00
|
|
|
{
|
|
|
|
/**
|
2021-10-19 17:28:23 +00:00
|
|
|
* The database driver
|
2021-10-18 19:47:53 +00:00
|
|
|
*
|
2021-10-19 17:28:23 +00:00
|
|
|
* @var \JDatabaseDriver
|
|
|
|
* @since 1.0
|
|
|
|
*/
|
|
|
|
protected $db;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Search Component router constructor
|
2021-10-18 19:47:53 +00:00
|
|
|
*
|
2021-10-19 17:28:23 +00:00
|
|
|
* @param CMSApplication $app The application object
|
|
|
|
* @param SiteMenu $menu The menu object to work with
|
2021-10-18 19:47:53 +00:00
|
|
|
*/
|
2021-10-19 17:28:23 +00:00
|
|
|
public function __construct($app = null, $menu = null)
|
2021-10-18 19:47:53 +00:00
|
|
|
{
|
2021-10-19 17:28:23 +00:00
|
|
|
$this->db = Factory::getDbo();
|
2021-10-18 19:47:53 +00:00
|
|
|
|
2021-10-19 17:28:23 +00:00
|
|
|
$looks = new RouterViewConfiguration('looks');
|
|
|
|
$this->registerView($looks);
|
2021-10-18 19:47:53 +00:00
|
|
|
|
2021-10-19 17:28:23 +00:00
|
|
|
$look = (new RouterViewConfiguration('look'))
|
|
|
|
->setParent($looks)
|
|
|
|
->setKey('id');
|
|
|
|
$this->registerView($look);
|
2021-10-18 19:47:53 +00:00
|
|
|
|
2021-10-19 17:28:23 +00:00
|
|
|
$looking = (new RouterViewConfiguration('looking'))
|
|
|
|
->setParent($look, 'id')
|
|
|
|
->setKey('id');
|
2021-10-18 19:47:53 +00:00
|
|
|
|
2021-10-19 17:28:23 +00:00
|
|
|
$this->registerView($looking);
|
2021-10-18 19:47:53 +00:00
|
|
|
|
2021-10-19 17:28:23 +00:00
|
|
|
$export = (new RouterViewConfiguration('export'))
|
|
|
|
->setKey('cms_version');
|
|
|
|
$this->registerView($export);
|
2021-10-18 19:47:53 +00:00
|
|
|
|
2021-10-19 17:28:23 +00:00
|
|
|
parent::__construct($app, $menu);
|
2021-10-18 19:47:53 +00:00
|
|
|
|
2021-10-19 17:28:23 +00:00
|
|
|
$this->attachRule(new MenuRules($this));
|
|
|
|
$this->attachRule(new StandardRules($this));
|
|
|
|
$this->attachRule(new NomenuRules($this));
|
|
|
|
}
|
2021-10-18 19:47:53 +00:00
|
|
|
|
2021-10-19 17:28:23 +00:00
|
|
|
/**
|
|
|
|
* Method to get the segment(s) for looks
|
|
|
|
*
|
|
|
|
* @param string $id ID of the looks 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 getLooksSegment($id, $query)
|
|
|
|
{
|
|
|
|
return $this->getLookSegment($id, $query);
|
2021-10-18 19:47:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-10-19 17:28:23 +00:00
|
|
|
* 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
|
2021-10-18 19:47:53 +00:00
|
|
|
*
|
2021-10-19 17:28:23 +00:00
|
|
|
* @return mixed The id of this item or false
|
|
|
|
*/
|
|
|
|
public function getLooksId($segment, $query)
|
|
|
|
{
|
|
|
|
return $this->getLookId($segment, $query);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Method to get the segment(s) for a look
|
2021-10-18 19:47:53 +00:00
|
|
|
*
|
2021-10-19 17:28:23 +00:00
|
|
|
* @param string $id ID of the application to retrieve the segments for
|
|
|
|
* @param array $query The request that is built right now
|
2021-10-18 19:47:53 +00:00
|
|
|
*
|
2021-10-19 17:28:23 +00:00
|
|
|
* @return array|string The segments of this item
|
2021-10-18 19:47:53 +00:00
|
|
|
*/
|
2021-10-19 17:28:23 +00:00
|
|
|
public function getLookSegment($id, $query)
|
|
|
|
{
|
|
|
|
if (!strpos($id, ':'))
|
2017-04-08 18:35:55 +00:00
|
|
|
{
|
2021-10-19 17:28:23 +00:00
|
|
|
$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();
|
2021-10-18 19:47:53 +00:00
|
|
|
}
|
|
|
|
|
2021-10-19 17:28:23 +00:00
|
|
|
list($void, $segment) = explode(':', $id, 2);
|
|
|
|
|
|
|
|
return array($void => $segment);
|
|
|
|
}
|
2021-10-18 19:47:53 +00:00
|
|
|
|
2021-10-19 17:28:23 +00:00
|
|
|
/**
|
|
|
|
* Method to get the segment(s) for a look
|
|
|
|
*
|
|
|
|
* @param string $segment Segment of the application to retrieve the ID for
|
|
|
|
* @param array $query The request that is parsed right now
|
|
|
|
*
|
|
|
|
* @return mixed The id of this item or false
|
|
|
|
*/
|
|
|
|
public function getLookId($segment, $query)
|
2021-10-18 19:47:53 +00:00
|
|
|
{
|
2021-10-19 17:28:23 +00:00
|
|
|
$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);
|
2021-10-18 19:47:53 +00:00
|
|
|
|
2021-10-19 17:28:23 +00:00
|
|
|
return (int) $this->db->loadResult();
|
2021-10-18 19:47:53 +00:00
|
|
|
}
|
2021-10-19 17:28:23 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)
|
2021-10-18 19:47:53 +00:00
|
|
|
{
|
2021-10-19 17:28:23 +00:00
|
|
|
if (!strpos($id, ':'))
|
2021-10-18 19:47:53 +00:00
|
|
|
{
|
2021-10-19 17:28:23 +00:00
|
|
|
$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();
|
2021-10-18 19:47:53 +00:00
|
|
|
}
|
|
|
|
|
2021-10-19 17:28:23 +00:00
|
|
|
list($void, $segment) = explode(':', $id, 2);
|
2021-10-18 19:47:53 +00:00
|
|
|
|
2021-10-19 17:28:23 +00:00
|
|
|
return array($void => $segment);
|
|
|
|
}
|
2021-10-18 19:47:53 +00:00
|
|
|
|
2021-10-19 17:28:23 +00:00
|
|
|
/**
|
|
|
|
* 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();
|
|
|
|
}
|
2015-12-03 02:17:44 +00:00
|
|
|
}
|