Ejemplo n.º 1
0
        if ($image) {
            $image = basename($image);
        } else {
            $errors[] = array('message' => FileManager::Error());
        }
        $category->set('categoryimage', $image);
    }
    $image = $category->get('categoryimage');
    // get description, if any
    $description = trim(@$_POST['categorydescr']);
    $category->set('categorydescr', $description);
    // if no errors encountered above
    if (empty($errors)) {
        // save the changes
        if (Download_Category::MODE_ADD == $mode) {
            $category->add($name, $image, $description);
        } else {
            $category->save();
        }
        // redirect to category admin page
        Typeframe::Redirect(Download_Category::MODE_ADD == $mode ? 'Category added.' : 'Category updated.', $typef_app_dir, 1, false);
        return;
    }
    // add errors and inputs
    $_POST['categoryimage'] = $category->get('categoryimage');
    $pm->setVariable('errors', $errors);
    $pm->setVariable('category', $_POST);
}
// set category in template, if no errors
if (empty($errors)) {
    $pm->setVariable('category', $category);