24 lines
497 B
PHP
24 lines
497 B
PHP
<?php
|
|
|
|
use EesyPHP\Check;
|
|
use EesyPHP\Log;
|
|
use EesyPHP\Tpl;
|
|
|
|
use EesyPHPExample\Db\Item;
|
|
|
|
function get_item_from_url($id, $fatal=false) {
|
|
if (!Check :: id($id))
|
|
Log :: fatal(_('Invalid element identifier.'));
|
|
|
|
$item = Item :: get($id);
|
|
if(!$item instanceof Item) {
|
|
$error = sprintf(_("Item #%s not found."), $id);
|
|
if ($fatal)
|
|
Log :: fatal($error);
|
|
Tpl :: add_error($error);
|
|
return false;
|
|
}
|
|
return $item;
|
|
}
|
|
|
|
# vim: tabstop=2 shiftwidth=2 softtabstop=2 expandtab
|