Esempio n. 1
0
                    if (!is_string($val) && !empty($val)) {
                        throw new Exception("'{$key}' must be a collection key or FALSE (" . gettype($val) . ")", Z_ERROR_INVALID_INPUT);
                    }
                    break;
                case 'relations':
                    if ($requestParams['v'] < 2) {
                        throw new Exception("Invalid property '{$key}'", Z_ERROR_INVALID_INPUT);
                    }
                    if (!is_object($val) && !(is_array($val) && empty($val))) {
                        throw new Exception("'{$key}' property must be an object", Z_ERROR_INVALID_INPUT);
                    }
                    foreach ($val as $predicate => $object) {
                        switch ($predicate) {
                            case 'owl:sameAs':
                                break;
                            default:
                                throw new Exception("Unsupported predicate '{$predicate}'", Z_ERROR_INVALID_INPUT);
                        }
                        if (!preg_match('/^http:\\/\\/zotero.org\\/(users|groups)\\/[0-9]+\\/(publications\\/)?collections\\/[A-Z0-9]{8}$/', $object)) {
                            throw new Exception("'{$key}' values currently must be Zotero collection URIs", Z_ERROR_INVALID_INPUT);
                        }
                    }
                    break;
                default:
                    throw new Exception("Invalid property '{$key}'", Z_ERROR_INVALID_INPUT);
            }
        }
    }
}
Zotero_Collections::init();