6a717342db
Five new admin views with models, templates, and list UI:
- Conditions: condition sets with group/rule counts and inline publish
- Snippets: reusable text blocks with {snippet alias} syntax
- Replacements: search/replace rules with regex and area badges
- Templates: content templates with category and description
- Modules: advanced module manager with position and client badges
Also adds togglePublished endpoint to DisplayController.
Claude-Session: https://claude.ai/code/session_01Jo2JpjCwfHAh2HHRSjczKq
70 lines
2.1 KiB
PHP
70 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* @package MokoSuiteClient
|
|
* @subpackage com_mokosuiteclient
|
|
* @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 Moko\Component\MokoSuiteClient\Administrator\Model;
|
|
|
|
defined('_JEXEC') or die;
|
|
|
|
use Joomla\CMS\Factory;
|
|
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
|
|
use Joomla\Database\DatabaseInterface;
|
|
|
|
class ReplacementsModel extends BaseDatabaseModel
|
|
{
|
|
public function getItems(array $filters = [], int $limit = 50, int $offset = 0): array
|
|
{
|
|
$db = Factory::getContainer()->get(DatabaseInterface::class);
|
|
$query = $db->getQuery(true)
|
|
->select('*')
|
|
->from($db->quoteName('#__mokosuiteclient_replacements'));
|
|
|
|
if (!empty($filters['search']))
|
|
{
|
|
$search = $db->quote('%' . $db->escape($filters['search'], true) . '%');
|
|
$query->where('(' . $db->quoteName('name') . ' LIKE ' . $search
|
|
. ' OR ' . $db->quoteName('search') . ' LIKE ' . $search . ')');
|
|
}
|
|
|
|
if ($filters['published'] !== '' && $filters['published'] !== null)
|
|
{
|
|
$query->where($db->quoteName('published') . ' = ' . (int) $filters['published']);
|
|
}
|
|
|
|
$query->order($db->quoteName('ordering') . ' ASC, ' . $db->quoteName('name') . ' ASC');
|
|
$db->setQuery($query, $offset, $limit);
|
|
|
|
return $db->loadObjectList() ?: [];
|
|
}
|
|
|
|
public function getTotal(array $filters = []): int
|
|
{
|
|
$db = Factory::getContainer()->get(DatabaseInterface::class);
|
|
$query = $db->getQuery(true)
|
|
->select('COUNT(*)')
|
|
->from($db->quoteName('#__mokosuiteclient_replacements'));
|
|
|
|
if (!empty($filters['search']))
|
|
{
|
|
$search = $db->quote('%' . $db->escape($filters['search'], true) . '%');
|
|
$query->where('(' . $db->quoteName('name') . ' LIKE ' . $search
|
|
. ' OR ' . $db->quoteName('search') . ' LIKE ' . $search . ')');
|
|
}
|
|
|
|
if ($filters['published'] !== '' && $filters['published'] !== null)
|
|
{
|
|
$query->where($db->quoteName('published') . ' = ' . (int) $filters['published']);
|
|
}
|
|
|
|
$db->setQuery($query);
|
|
|
|
return (int) $db->loadResult();
|
|
}
|
|
}
|