eesyphp/example/includes/url-helpers.php

25 lines
489 B
PHP
Raw Normal View History

2020-04-18 00:51:33 +02:00
<?php
use EesyPHP\Check;
use EesyPHP\Log;
use EesyPHP\Tpl;
2024-02-02 18:19:38 +01:00
use EesyPHPExample\Db;
2020-04-18 00:51:33 +02:00
function get_item_from_url($id, $fatal=false) {
if (!Check :: id($id))
Log :: fatal(_('Invalid element identifier.'));
2020-04-18 00:51:33 +02:00
2024-02-02 18:19:38 +01:00
$item = Db :: get_item($id);
2022-04-24 17:43:44 +02:00
if(!is_array($item)) {
$error = sprintf(_("Item #%s not found."), $id);
2022-04-24 17:43:44 +02:00
if ($fatal)
Log :: fatal($error);
Tpl :: add_error($error);
2022-04-24 17:43:44 +02:00
return false;
}
return $item;
2020-04-18 00:51:33 +02:00
}
# vim: tabstop=2 shiftwidth=2 softtabstop=2 expandtab