27505f7501
Completes the MokoJoomCross → MokoSuiteCross rebrand across all language string keys, Joomla event names, documentation, and wiki pages. - 1,151 language key references renamed (COM_, PLG_, PKG_ prefixes) - Event names renamed (onMokoJoomCross* → onMokoSuiteCross*) - CLAUDE.md, CHANGELOG.md, wiki docs updated - Zero mokojoomcross references remaining in codebase Closes #128, closes #138
92 lines
2.9 KiB
PHP
92 lines
2.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @package MokoSuiteCross
|
|
* @subpackage com_mokosuitecross
|
|
* @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\MokoSuiteCross\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('#__mokosuitecross_posts', 'a'))
|
|
->join('LEFT', $db->quoteName('#__content', 'c')
|
|
. ' ON ' . $db->quoteName('c.id') . ' = ' . $db->quoteName('a.article_id'))
|
|
->join('LEFT', $db->quoteName('#__mokosuitecross_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;
|
|
}
|
|
}
|