Exemplo n.º 1
0
Arquivo: edit.php Projeto: rjha/sc
use com\indigloo\exception\UIException;
if (isset($_POST['save']) && $_POST['save'] == 'Save') {
    $gWeb = \com\indigloo\core\Web::getInstance();
    $fvalues = array();
    $fUrl = \com\indigloo\Url::tryFormUrl("fUrl");
    try {
        $fhandler = new Form\Handler('web-form-1', $_POST);
        $fhandler->addRule('links_json', 'links_json', array('rawData' => 1));
        $fhandler->addRule('images_json', 'images_json', array('rawData' => 1));
        $fhandler->addRule('group_names', 'Tags', array('maxlength' => 64, 'rawData' => 1));
        $fhandler->addRule('qUrl', 'qUrl', array('required' => 1, 'rawData' => 1));
        $fvalues = $fhandler->getValues();
        $qUrl = base64_decode($fvalues['qUrl']);
        if ($fhandler->hasErrors()) {
            throw new UIException($fhandler->getErrors());
        }
        $groupDao = new \com\indigloo\sc\dao\Group();
        $group_names = $fvalues['group_names'];
        $group_slug = $groupDao->nameToSlug($group_names);
        $postDao = new com\indigloo\sc\dao\Post();
        $title = Util::abbreviate($fvalues['description'], 128);
        $postDao->update($fvalues['post_id'], $title, $fvalues['description'], $_POST['links_json'], $_POST['images_json'], $group_slug, $fvalues['category']);
        //success
        header("Location: " . $qUrl);
    } catch (UIException $ex) {
        $gWeb->store(Constants::STICKY_MAP, $fvalues);
        $gWeb->store(Constants::FORM_ERRORS, $ex->getMessages());
        header("Location: " . $fUrl);
        exit(1);
    }
}