Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7e64d49

Browse filesBrowse files
committed
Revert PR 46081
1 parent dae20eb commit 7e64d49
Copy full SHA for 7e64d49

File tree

Expand file treeCollapse file tree

2 files changed

+0
-141
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+0
-141
lines changed
Open diff view settings
Collapse file

‎administrator/components/com_finder/src/Model/FilterModel.php‎

Copy file name to clipboardExpand all lines: administrator/components/com_finder/src/Model/FilterModel.php
-135Lines changed: 0 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@
1111
namespace Joomla\Component\Finder\Administrator\Model;
1212

1313
use Joomla\CMS\Factory;
14-
use Joomla\CMS\Filter\OutputFilter;
1514
use Joomla\CMS\Form\Form;
1615
use Joomla\CMS\MVC\Model\AdminModel;
1716
use Joomla\Component\Finder\Administrator\Table\FilterTable;
18-
use Joomla\String\StringHelper;
1917

2018
// phpcs:disable PSR1.Files.SideEffects
2119
\defined('_JEXEC') or die;
@@ -153,137 +151,4 @@ public function getTotal()
153151

154152
return $db->setQuery($query)->loadResult();
155153
}
156-
157-
/**
158-
* Method to save the form data.
159-
*
160-
* Overrides the parent to correctly handle the 'save2copy' task for Finder filters.
161-
*
162-
* @param array $data The form data.
163-
*
164-
* @return boolean True on success, false on failure.
165-
*
166-
* @since 5.4.1
167-
*/
168-
public function save($data)
169-
{
170-
$app = Factory::getApplication();
171-
$task = $app->getInput()->get('task', '', 'cmd');
172-
173-
if ($task === 'save2copy') {
174-
$data['filter_id'] = 0;
175-
176-
$title = trim((string) ($data['title'] ?? ''));
177-
$alias = trim((string) ($data['alias'] ?? ''));
178-
179-
if ($alias === '') {
180-
$alias = OutputFilter::stringURLSafe($title);
181-
}
182-
183-
// Generate unique title + alias
184-
list($title, $alias) = $this->generateNewTitleAndAlias($title, $alias);
185-
186-
$data['title'] = $title;
187-
$data['alias'] = $alias;
188-
}
189-
190-
return parent::save($data);
191-
}
192-
193-
/**
194-
* Generate a new unique title and alias for a copied filter.
195-
* Follows the same logic as Joomla's core content models.
196-
*
197-
* @param string $title The original title.
198-
* @param string $alias The original alias.
199-
*
200-
* @return array Array with [newTitle, newAlias].
201-
*
202-
* @since 5.4.1
203-
*/
204-
protected function generateNewTitleAndAlias(string $title, string $alias): array
205-
{
206-
$db = $this->getDatabase();
207-
208-
if (preg_match('/^(.*?)(?:\s\((\d+)\))?$/', $title, $matches)) {
209-
$baseTitle = trim($matches[1]);
210-
} else {
211-
$baseTitle = trim($title);
212-
}
213-
214-
$baseAlias = trim($alias ?: OutputFilter::stringURLSafe($title));
215-
216-
$likeTitle = $db->quote($db->escape($baseTitle, true) . '%', false);
217-
218-
$query = $db->getQuery(true)
219-
->select($db->quoteName('title'))
220-
->from($db->quoteName('#__finder_filters'))
221-
->where($db->quoteName('title') . ' LIKE ' . $likeTitle);
222-
223-
$existingTitles = $db->setQuery($query)->loadColumn();
224-
225-
$maxNum = 0;
226-
foreach ($existingTitles as $existing) {
227-
if (preg_match('/^\Q' . $baseTitle . '\E(?:\s\((\d+)\))?$/', $existing, $matches)) {
228-
$num = isset($matches[1]) ? (int) $matches[1] : 1;
229-
if ($num > $maxNum) {
230-
$maxNum = $num;
231-
}
232-
}
233-
}
234-
235-
$nextNum = $maxNum + 1;
236-
237-
$newTitle = $baseTitle;
238-
if ($nextNum > 1) {
239-
$newTitle .= ' (' . $nextNum . ')';
240-
}
241-
242-
// Build a unique alias
243-
$newAlias = $this->getUniqueAlias($baseAlias);
244-
245-
return [$newTitle, $newAlias];
246-
}
247-
248-
/**
249-
* Ensure a unique alias in the table by incrementing with dash style.
250-
*
251-
*
252-
* @param string $base The starting alias (already URL-safe).
253-
*
254-
* @return string A unique alias.
255-
*
256-
* @since 5.4.1
257-
*/
258-
protected function getUniqueAlias(string $base): string
259-
{
260-
$alias = $base !== '' ? $base : OutputFilter::stringURLSafe(uniqid('filter-', true));
261-
262-
while ($this->aliasExists($alias)) {
263-
$alias = StringHelper::increment($alias, 'dash');
264-
}
265-
266-
return $alias;
267-
}
268-
269-
/**
270-
* Check whether an alias exists in the table.
271-
*
272-
* @param string $alias The alias to test.
273-
*
274-
* @return boolean True if it exists, false otherwise.
275-
*
276-
* @since 5.4.1
277-
*/
278-
protected function aliasExists(string $alias): bool
279-
{
280-
$db = $this->getDatabase();
281-
$query = $db->getQuery(true)
282-
->select('COUNT(*)')
283-
->from($db->quoteName('#__finder_filters'))
284-
->where($db->quoteName('alias') . ' = :alias')
285-
->bind(':alias', $alias);
286-
287-
return (int) $db->setQuery($query)->loadResult() > 0;
288-
}
289154
}
Collapse file

‎administrator/components/com_finder/tmpl/filters/default.php‎

Copy file name to clipboardExpand all lines: administrator/components/com_finder/tmpl/filters/default.php
-6Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@
5959
<th scope="col">
6060
<?php echo HTMLHelper::_('searchtools.sort', 'JGLOBAL_TITLE', 'a.title', $listDirn, $listOrder); ?>
6161
</th>
62-
<th scope="col">
63-
<?php echo HTMLHelper::_('searchtools.sort', 'JALIAS', 'a.alias', $listDirn, $listOrder); ?>
64-
</th>
6562
<th scope="col" class="w-10 d-none d-md-table-cell">
6663
<?php echo HTMLHelper::_('searchtools.sort', 'COM_FINDER_HEADING_CREATED_BY', 'a.created_by_alias', $listDirn, $listOrder); ?>
6764
</th>
@@ -106,9 +103,6 @@
106103
<?php echo $escapedTitle; ?>
107104
<?php endif; ?>
108105
</th>
109-
<td class="d-none d-md-table-cell">
110-
<?php echo $item->alias; ?>
111-
</td>
112106
<td class="d-none d-md-table-cell">
113107
<?php echo $item->created_by_alias ?: $item->user_name; ?>
114108
</td>

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.