Esempio n. 1
0
    if (is_demo()) {
        $resp['errors'][] = \Meta\Builder::demoMsg();
    }
    if (!$resp['errors']) {
        $pages = \Meta\Builder::read('pages');
        unset($pages[$page_name]['objects'][$id]);
        $pages[$page_name]['objects'] = $pages[$page_name]['objects'];
        \Meta\Builder::write('pages', $pages);
    }
    echo json_encode($resp);
});
route_add('builder/page/object-save/*/*', function ($path, $oid) {
    $errors = array();
    $object = null;
    if (is_demo()) {
        $errors[] = \Meta\Builder::demoMsg();
    }
    if (strlen($_REQUEST['label']) == 0) {
        $errors[] = 'Label field is required';
    }
    if (!$errors) {
        $pages = \Meta\Builder::read('pages');
        $page = new \Meta\Builder\Page($path, $pages[$path]);
        $pages[$path] = $page->toArray();
        // current object
        $object = $page->objects[$oid];
        $object instanceof \Meta\Builder\Object;
        $newData = array_merge($object->toArray(), $_REQUEST);
        if ($object instanceof \Meta\Builder\Object\View) {
            $newData['paginate'] = isset($_REQUEST['paginate']);
            $newData['enableSearchBox'] = isset($_REQUEST['enableSearchBox']);