75c34345f9
Generic: Repo Health / Site Health (push) Has been cancelled
Generic: Repo Health / Access control (push) Has been cancelled
Generic: Repo Health / Scripts governance (push) Has been cancelled
Generic: Repo Health / Repository health (push) Has been cancelled
Generic: Repo Health / Report Issues (push) Has been cancelled
Rename root source directory from src/ to source/ and update all references in Makefile, manifest.xml, .gitignore, CI workflows, and wiki documentation. Internal Joomla namespace paths (src/Extension) are unchanged as they are plugin-internal structure. CI workflows updated to check source/ first with src/ fallback for backward compatibility across repos. Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
92 lines
2.9 KiB
PHP
92 lines
2.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @package MokoJoomCross
|
|
* @subpackage com_mokojoomcross
|
|
* @author Moko Consulting <hello@mokoconsulting.tech>
|
|
* @copyright Copyright (C) 2026 Moko Consulting. All rights reserved.
|
|
* @license GNU General Public License version 3 or later; see LICENSE
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
*/
|
|
|
|
namespace Joomla\Component\MokoJoomCross\Administrator\Model;
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
use Joomla\CMS\MVC\Model\ListModel;
|
|
|
|
class PostsModel extends ListModel
|
|
{
|
|
/**
|
|
* Constructor.
|
|
*
|
|
* @param array $config Configuration array
|
|
*/
|
|
public function __construct($config = [])
|
|
{
|
|
if (empty($config['filter_fields'])) {
|
|
$config['filter_fields'] = [
|
|
'id', 'a.id',
|
|
'article_id', 'a.article_id',
|
|
'service_id', 'a.service_id',
|
|
'status', 'a.status',
|
|
'created', 'a.created',
|
|
'posted_at', 'a.posted_at',
|
|
];
|
|
}
|
|
|
|
parent::__construct($config);
|
|
}
|
|
|
|
/**
|
|
* Build an SQL query to load the list data.
|
|
*
|
|
* @return \Joomla\Database\QueryInterface
|
|
*/
|
|
protected function getListQuery()
|
|
{
|
|
$db = $this->getDatabase();
|
|
$query = $db->getQuery(true);
|
|
|
|
$query->select('a.*')
|
|
->select($db->quoteName('c.title', 'article_title'))
|
|
->select($db->quoteName('s.title', 'service_title'))
|
|
->select($db->quoteName('s.service_type'))
|
|
->from($db->quoteName('#__mokojoomcross_posts', 'a'))
|
|
->join('LEFT', $db->quoteName('#__content', 'c')
|
|
. ' ON ' . $db->quoteName('c.id') . ' = ' . $db->quoteName('a.article_id'))
|
|
->join('LEFT', $db->quoteName('#__mokojoomcross_services', 's')
|
|
. ' ON ' . $db->quoteName('s.id') . ' = ' . $db->quoteName('a.service_id'));
|
|
|
|
// Filter by status
|
|
$status = $this->getState('filter.status');
|
|
|
|
if (!empty($status)) {
|
|
$query->where($db->quoteName('a.status') . ' = ' . $db->quote($status));
|
|
}
|
|
|
|
// Filter by service
|
|
$serviceId = $this->getState('filter.service_id');
|
|
|
|
if (!empty($serviceId)) {
|
|
$query->where($db->quoteName('a.service_id') . ' = ' . (int) $serviceId);
|
|
}
|
|
|
|
// Filter by search (article title or message content)
|
|
$search = $this->getState('filter.search');
|
|
|
|
if (!empty($search)) {
|
|
$search = '%' . $db->escape(trim($search), true) . '%';
|
|
$query->where('(' . $db->quoteName('c.title') . ' LIKE ' . $db->quote($search)
|
|
. ' OR ' . $db->quoteName('a.message') . ' LIKE ' . $db->quote($search) . ')');
|
|
}
|
|
|
|
// Ordering
|
|
$orderCol = $this->state->get('list.ordering', 'a.created');
|
|
$orderDirn = $this->state->get('list.direction', 'DESC');
|
|
$query->order($db->escape($orderCol) . ' ' . $db->escape($orderDirn));
|
|
|
|
return $query;
|
|
}
|
|
}
|