Пример #1
0
include '../../../inc/includes.php';
$img = new PluginPositionsImageItem();
if (isset($_POST["add"]) && isset($_POST['type'])) {
    $test = explode(";", $_POST['type']);
    if (isset($test[0]) && isset($test[1]) && !empty($test[1])) {
        $_POST['type'] = $test[1];
        $_POST['itemtype'] = $test[0];
        if ($img->canCreate()) {
            if (!empty($_POST["img"])) {
                $img->addItemImage($_POST);
            } else {
                Session::addMessageAfterRedirect(__('No picture uploaded', 'positions'), false, ERROR);
            }
        }
    }
    Html::back();
} else {
    if (isset($_POST["delete"])) {
        $img->getFromDB($_POST["id"], -1);
        foreach ($_POST["item"] as $key => $val) {
            if ($val == 1) {
                $img->delete(array('id' => $key));
            }
        }
        Html::back();
    } else {
        Html::header(PluginPositionsPosition::getTypeName(), '', "tools", "pluginpositionsmenu", "config");
        $img->showConfigForm();
        Html::footer();
    }
}