mirror of
https://github.com/Karaka-Management/oms-Tasks.git
synced 2026-01-25 21:48:41 +00:00
bump
This commit is contained in:
parent
421f0743d1
commit
f6a19bab02
|
|
@ -30,6 +30,76 @@ use phpOMS\System\MimeType;
|
|||
*/
|
||||
final class SearchController extends Controller
|
||||
{
|
||||
/**
|
||||
* Api method to search for tags
|
||||
*
|
||||
* @param RequestAbstract $request Request
|
||||
* @param ResponseAbstract $response Response
|
||||
* @param array $data Generic data
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @api
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function searchTag(RequestAbstract $request, ResponseAbstract $response, array $data = []) : void
|
||||
{
|
||||
$search = $request->getDataString('search') ?? '';
|
||||
|
||||
$searchIdStartPos = \stripos($search, ':');
|
||||
$patternStartPos = $searchIdStartPos === false
|
||||
? -1
|
||||
: \stripos($search, ' ', $searchIdStartPos);
|
||||
|
||||
$pattern = \substr($search, $patternStartPos + 1);
|
||||
|
||||
/** @var \Modules\Tasks\Models\Task[] $tasks */
|
||||
$tasks = TaskMapper::getAll()
|
||||
->with('tags')
|
||||
->with('tags/title')
|
||||
->with('taskElements')
|
||||
->where('tags/title/language', $response->header->l11n->language)
|
||||
->where('tags/title/content', $pattern)
|
||||
->sort('createdAt', OrderType::DESC)
|
||||
->sort('taskElements/createdAt', OrderType::ASC)
|
||||
->limit(8)
|
||||
//->limit(1, 'taskElements')
|
||||
->execute();
|
||||
|
||||
$results = [];
|
||||
$count = 0;
|
||||
|
||||
foreach ($tasks as $task) {
|
||||
if ($count >= 8) {
|
||||
break;
|
||||
}
|
||||
|
||||
// @performance Check if this can be combined with the above getAll()
|
||||
// https://github.com/Karaka-Management/oms-Tasks/issues/41
|
||||
if (!TaskMapper::hasReadingPermission($request->header->account, $task->id)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
++$count;
|
||||
|
||||
$results[] = [
|
||||
'title' => $task->title,
|
||||
'summary' => \substr(\trim($task->description), 0, 500),
|
||||
'link' => '{/base}/task/view?id=' . $task->id,
|
||||
'account' => '',
|
||||
'createdAt' => $task->createdAt,
|
||||
'image' => '',
|
||||
'tags' => $task->tags,
|
||||
'type' => 'list_links',
|
||||
'module' => 'Tasks',
|
||||
];
|
||||
}
|
||||
|
||||
$response->header->set('Content-Type', MimeType::M_JSON . '; charset=utf-8', true);
|
||||
$response->add($request->uri->__toString(), $results);
|
||||
}
|
||||
|
||||
/**
|
||||
* Api method to search for tags
|
||||
*
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ echo $this->data['nav']->render(); ?>
|
|||
<?php foreach ($task->tags as $tag) : ?>
|
||||
<a href="<?= $url; ?>">
|
||||
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>">
|
||||
<?= empty($tag->icon) ? '' : ''; ?>
|
||||
<?= empty($tag->icon) ? '' : '<i class="g-icon">' . $this->printHtml($tag->icon) . '</i>'; ?>
|
||||
<?= $this->printHtml($tag->getL11n()); ?>
|
||||
</span>
|
||||
</a>
|
||||
|
|
@ -150,7 +150,7 @@ echo $this->data['nav']->render(); ?>
|
|||
<?php foreach ($task->tags as $tag) : ?>
|
||||
<a href="<?= $url; ?>">
|
||||
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>">
|
||||
<?= empty($tag->icon) ? '' : ''; ?>
|
||||
<?= empty($tag->icon) ? '' : '<i class="g-icon">' . $this->printHtml($tag->icon) . '</i>'; ?>
|
||||
<?= $this->printHtml($tag->getL11n()); ?>
|
||||
</span>
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ echo $this->data['nav']->render(); ?>
|
|||
<?php foreach ($task->tags as $tag) : ?>
|
||||
<a href="<?= $url; ?>">
|
||||
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>">
|
||||
<?= empty($tag->icon) ? '' : ''; ?>
|
||||
<?= empty($tag->icon) ? '' : '<i class="g-icon">' . $this->printHtml($tag->icon) . '</i>'; ?>
|
||||
<?= $this->printHtml($tag->getL11n()); ?>
|
||||
</span>
|
||||
</a>
|
||||
|
|
|
|||
|
|
@ -87,7 +87,8 @@ echo $this->data['nav']->render(); ?>
|
|||
<?php
|
||||
foreach ($task->tags as $tag) : ?>
|
||||
<span class="tag" style="background: <?= $this->printHtml($tag->color); ?>">
|
||||
<?= empty($tag->icon) ? '' : ''; ?><?= $this->printHtml($tag->getL11n()); ?>
|
||||
<?= empty($tag->icon) ? '' : '<i class="g-icon">' . $this->printHtml($tag->icon) . '</i>'; ?>
|
||||
<?= $this->printHtml($tag->getL11n()); ?>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
<?php if (!empty($taskMedia)) : ?>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user