mirror of
https://github.com/Karaka-Management/oms-Search.git
synced 2026-01-11 18:48:41 +00:00
Went through todos
This commit is contained in:
parent
5209fafd28
commit
da39cf2892
|
|
@ -40,6 +40,30 @@ final class Installer extends InstallerAbstract
|
|||
*/
|
||||
public const PATH = __DIR__;
|
||||
|
||||
/**
|
||||
* Commands.
|
||||
*
|
||||
* Include consideres the state of the file during script execution.
|
||||
* This means setting it to empty has no effect if it was not empty before.
|
||||
* There are also other merging bugs that can happen.
|
||||
*
|
||||
* @var array
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static array $commands = [];
|
||||
|
||||
/**
|
||||
* Is first command load?
|
||||
*
|
||||
* Include consideres the state of the file during script execution.
|
||||
* This means setting it to empty has no effect if it was not empty before.
|
||||
* There are also other merging bugs that can happen.
|
||||
*
|
||||
* @var bool
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private static bool $isFirstLoad = true;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -58,6 +82,7 @@ final class Installer extends InstallerAbstract
|
|||
}
|
||||
|
||||
\file_put_contents(__DIR__ . '/SearchCommands.php', '<?php return [];');
|
||||
self::$isFirstLoad = false;
|
||||
parent::install($app, $info, $cfgHandler);
|
||||
}
|
||||
|
||||
|
|
@ -92,15 +117,18 @@ final class Installer extends InstallerAbstract
|
|||
throw new PermissionException(__DIR__ . '/SearchCommands.php');
|
||||
}
|
||||
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
$appRoutes = include __DIR__ . '/SearchCommands.php';
|
||||
if (self::$isFirstLoad) {
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
self::$commands = include __DIR__ . '/SearchCommands.php';
|
||||
self::$isFirstLoad = false;
|
||||
}
|
||||
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
$moduleRoutes = include $data['path'];
|
||||
|
||||
$appRoutes = \array_merge_recursive($appRoutes, $moduleRoutes);
|
||||
self::$commands = \array_merge_recursive(self::$commands, $moduleRoutes);
|
||||
|
||||
\file_put_contents(__DIR__ . '/SearchCommands.php', '<?php return ' . ArrayParser::serializeArray($appRoutes) . ';', \LOCK_EX);
|
||||
\file_put_contents(__DIR__ . '/SearchCommands.php', '<?php return ' . ArrayParser::serializeArray(self::$commands) . ';', \LOCK_EX);
|
||||
|
||||
return [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ namespace Modules\Search\Controller;
|
|||
use phpOMS\Application\ApplicationAbstract;
|
||||
use phpOMS\Contract\RenderableInterface;
|
||||
use phpOMS\Message\Http\HttpRequest;
|
||||
use phpOMS\Message\RequestAbstract;
|
||||
use phpOMS\Message\ResponseAbstract;
|
||||
use phpOMS\Router\WebRouter;
|
||||
use phpOMS\Views\View;
|
||||
|
|
@ -54,6 +53,9 @@ final class BackendController extends Controller
|
|||
*
|
||||
* @api
|
||||
*
|
||||
* @todo Search prioritization
|
||||
* https://github.com/Karaka-Management/oms-Search/issues/1
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function search(HttpRequest $request, ResponseAbstract $response, array $data = []) : RenderableInterface
|
||||
|
|
@ -68,8 +70,14 @@ final class BackendController extends Controller
|
|||
|
||||
$internalResponse->data = [];
|
||||
|
||||
$temp = empty($request->getDataString('search')) ? [] : $this->routeSearch($internalRequest, $internalResponse, $data);
|
||||
$view->data = empty($temp) ? [] : \reset($temp);
|
||||
$temp = empty($request->getDataString('search'))
|
||||
? []
|
||||
: $this->routeSearch($internalRequest, $internalResponse, $data);
|
||||
|
||||
$response->header = $internalResponse->header;
|
||||
|
||||
$responseData = \reset($temp);
|
||||
$view->data = empty($temp) || !\is_array($responseData) ? [] : $responseData;
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,13 +76,14 @@ foreach ($this->data as $controller) :
|
|||
?>
|
||||
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3">
|
||||
<section class="portlet">
|
||||
<div class="portlet-head">
|
||||
<div class="<?= empty($data['email']) && empty($data['phone']) && empty($data['city']) ? 'portlet-body' : 'portlet-head'; ?>">
|
||||
<a style="display: flex; align-items: center;" href="<?= UriFactory::build($data['link']); ?>">
|
||||
<img class="profile-image" alt="account" loading="lazy"
|
||||
src="<?= UriFactory::build($data['image']); ?>">
|
||||
<span style="margin-left: .5rem;"><?= $this->printHtml($data['title']); ?></span>
|
||||
</a>
|
||||
</div>
|
||||
<?php if (!empty($data['email']) || !empty($data['phone']) || !empty($data['city'])) : ?>
|
||||
<div class="portlet-body">
|
||||
<div>
|
||||
<table class="wf-100" style="font-size: .9rem;">
|
||||
|
|
@ -92,6 +93,7 @@ foreach ($this->data as $controller) :
|
|||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</section>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user