eesyphp/example/includes/url-helpers.php

23 lines
460 B
PHP
Raw Normal View History

2020-04-18 00:51:33 +02:00
<?php
use EesyPHP\Check;
use EesyPHP\Log;
use EesyPHP\Tpl;
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
2022-04-24 17:43:44 +02:00
$item = get_item($id);
if(!is_array($item)) {
$error = sprintf(_("Item #% s not found."), $id);
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