- md5
- 8f1f2eeefb699ec23020c35d0d93ea14
- sha1
- 3245440a761319bce3d404c4810435979d5a4dc2
- sha256
- 547bf0feeeea059bc9b8f07da5307720f94f6815f3df0044ce4bf583a9851077
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
<?php
/**
* @package Joomla.Administrator
* @subpackage com_finder
*
* @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\Component\Finder\Administrator\Model;
use Joomla\CMS\Factory;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\Database\ParameterType;
/**
* Index Item model class for Finder.
*
* @since 5.0.0
*/
class ItemModel extends BaseDatabaseModel
{
/**
* Stock method to auto-populate the model state.
*
* @return void
*
* @since 5.0.0
*/
protected function populateState()
{
// Get the pk of the record from the request.
$pk = Factory::getApplication()->getInput()->getInt('id');
$this->setState('item.link_id', $pk);
}
/**
* Get a finder link object
*
* @return object
*
* @since 5.0.0
*/
public function getItem()
{
$link_id = (int) $this->getState('item.link_id');
$db = $this->getDatabase();
$query = $db->getQuery(true)
->select('*')
->from($db->quoteName('#__finder_links', 'l'))
->where($db->quoteName('l.link_id') . ' = :link_id')
->bind(':link_id', $link_id, ParameterType::INTEGER);
$db->setQuery($query);
return $db->loadObject();
}
/**
* Get terms associated with a finder link
*
* @return object[]
*
* @since 5.0.0
*/
public function getTerms()
{
$link_id = (int) $this->getState('item.link_id');
$db = $this->getDatabase();
$query = $db->getQuery(true)
->select('t.*, l.*')
->from($db->quoteName('#__finder_links_terms', 'l'))
->leftJoin($db->quoteName('#__finder_terms', 't') . ' ON ' . $db->quoteName('t.term_id') . ' = ' . $db->quoteName('l.term_id'))
->where($db->quoteName('l.link_id') . ' = :link_id')
->order('l.weight')
->bind(':link_id', $link_id, ParameterType::INTEGER);
$db->setQuery($query);
return $db->loadObjectList();
}
/**
* Get taxonomies associated with a finder link
*
* @return \stdClass[]
*
* @since 5.0.0
*/
public function getTaxonomies()
{
$link_id = (int) $this->getState('item.link_id');
$db = $this->getDatabase();
$query = $db->getQuery(true)
->select('t.*, m.*')
->from($db->quoteName('#__finder_taxonomy_map', 'm'))
->leftJoin($db->quoteName('#__finder_taxonomy', 't') . ' ON ' . $db->quoteName('t.id') . ' = ' . $db->quoteName('m.node_id'))
->where($db->quoteName('m.link_id') . ' = :link_id')
->order('t.title')
->bind(':link_id', $link_id, ParameterType::INTEGER);
$db->setQuery($query);
return $db->loadObjectList();
}
}
The same content is in 109 releases, Joomla 5.0.0-alpha3 to 6.0.0-beta3. See them all, or every version of this file.