https://joomla.stackexchange.com/q/26382/12352

Created Diff never expires
10 removals
41 lines
9 additions
39 lines
class BookstoreRouter extends JComponentRouterView
class BookstoreRouter extends JComponentRouterView
{
{
public function __construct($app = null, $menu = null)
public function __construct($app = null, $menu = null)
{
{
$books = new JComponentRouterViewconfiguration('books');
$books = new JComponentRouterViewconfiguration('books');
$books->setNestable();
$this->registerView($books);
$this->registerView($books);


$book = new JComponentRouterViewconfiguration('book');
$book = new JComponentRouterViewconfiguration('book');
$book->setKey('id')->setParent($books);
$book->setKey('id')->setParent($books);
$this->registerView($book);
$this->registerView($book);


parent::__construct($app, $menu);
parent::__construct($app, $menu);


$this->attachRule(new JComponentRouterRulesMenu($this));
$this->attachRule(new JComponentRouterRulesMenu($this));
$this->attachRule(new JComponentRouterRulesStandard($this));
$this->attachRule(new JComponentRouterRulesStandard($this));
$this->attachRule(new JComponentRouterRulesNomenu($this));
$this->attachRule(new JComponentRouterRulesNomenu($this));
}
}


public function getBookSegment($id, $query)
public function getBookSegment($id, $query)
{
{
if (!strpos($id, ':'))
if (strpos($query['id'], ':') === false) {
{
$db = JFactory::getDbo();
$db = JFactory::getDbo();
$dbquery = $db->getQuery(true);
$dbquery = $db->getQuery(true);
$dbquery->select($dbquery->qn('alias'))
$dbquery->select($db->quoteName('alias'))
->from($dbquery->qn('#__bookstore_books'))
->from($db->quoteName('#__bookstore_books'))
->where('id = ' . $dbquery->q($id));
->where('id = ' . $db->quote($id));
$db->setQuery($dbquery);
$db->setQuery($dbquery);


$id .= ':' . $db->loadResult();
$id .= ':' . $db->loadResult();
}
}


return array((int) $id => $id);
return array((int)$id => $id);
}
}


public function getBookId($segment, $query)
public function getBookId($segment, $query)
{
{
return (int) $segment;
return (int)$segment;
}
}
}
}