Exemplo n.º 1
0
 /** returns type on success, false on failure */
 public static function isAcceptable($content_type)
 {
     $ok_type = false;
     try {
         list($type, $subtype) = Dase_Media::parseMimeType($content_type);
     } catch (Exception $e) {
         return false;
     }
     foreach (Dase_Media::getAcceptedTypes() as $t) {
         list($acceptedType, $acceptedSubtype) = explode('/', $t);
         if ($acceptedType == '*' || $acceptedType == $type) {
             if ($acceptedSubtype == '*' || $acceptedSubtype == $subtype) {
                 $ok_type = $type . "/" . $subtype;
             }
         }
     }
     return $ok_type;
 }
Exemplo n.º 2
0
 public function getAtompubServiceDoc($app_root)
 {
     $svc = new Dase_Atom_Service();
     $ws = $svc->addWorkspace($this->collection_name . ' Workspace');
     $coll = $ws->addCollection($app_root . '/collection/' . $this->ascii_id . '.atom', $this->collection_name . ' Items');
     $coll->addAccept('application/atom+xml;type=entry');
     $coll->addCategorySet()->addCategory('item', 'http://daseproject.org/category/entrytype');
     $atts = $coll->addCategorySet('yes', 'http://daseproject.org/category/metadata');
     foreach ($this->getAttributes() as $att) {
         $atts->addCategory($att->ascii_id, '', $att->attribute_name);
     }
     $media_repos = $app_root . '/media/' . $this->ascii_id . '.atom';
     $media_coll = $ws->addCollection($media_repos, $this->collection_name . ' Media');
     foreach (Dase_Media::getAcceptedTypes() as $type) {
         //$media_coll->addAccept($type,true);
         $media_coll->addAccept($type);
     }
     //json items collection
     $ws->addCollection($app_root . '/collection/' . $this->ascii_id . '.atom', $this->collection_name . ' JSON Items')->addAccept('application/json');
     $item_types_repos = $app_root . '/collection/' . $this->ascii_id . '/item_types.atom';
     $ws->addCollection($item_types_repos, $this->collection_name . ' Item Types')->addAccept('application/atom+xml;type=entry')->addCategorySet()->addCategory('item_type', 'http://daseproject.org/category/entrytype');
     $attributes_repos = $app_root . '/collection/' . $this->ascii_id . '/attributes.atom';
     $atts_repos = $ws->addCollection($attributes_repos, $this->collection_name . ' Attributes');
     $atts_repos->addAccept('application/atom+xml;type=entry')->addCategorySet()->addCategory('attribute', 'http://daseproject.org/category/entrytype', '', true);
     $html_inp_types = $atts_repos->addAccept('application/atom+xml;type=entry')->addCategorySet('yes', 'http://daseproject.org/category/html_input_type');
     foreach (array('text', 'textarea', 'select', 'radio', 'checkbox', 'noedit', 'list') as $inp) {
         $html_inp_types->addCategory($inp);
     }
     return $svc->asXml();
 }
Exemplo n.º 3
0
 public function getAtomPubServiceDoc($app_root)
 {
     $c = $this->getCollection();
     $app = new Dase_Atom_Service();
     $workspace = $app->addWorkspace($c->collection_name . ' Item ' . $this->serial_number . ' Workspace');
     $media_coll = $workspace->addCollection($app_root . '/item/' . $this->p_collection_ascii_id . '/' . $this->serial_number . '/media.atom', $c->collection_name . ' Item ' . $this->serial_number . ' Media');
     foreach (Dase_Media::getAcceptedTypes() as $type) {
         $media_coll->addAccept($type);
     }
     $comments_coll = $workspace->addCollection($app_root . '/item/' . $this->p_collection_ascii_id . '/' . $this->serial_number . '/comments.atom', $c->collection_name . ' Item ' . $this->serial_number . ' Comments');
     $comments_coll->addAccept('text/plain');
     $comments_coll->addAccept('text/html');
     $comments_coll->addAccept('application/xhtml+xml');
     $metadata_coll = $workspace->addCollection($app_root . '/item/' . $this->p_collection_ascii_id . '/' . $this->serial_number . '/metadata.atom', $c->collection_name . ' Item ' . $this->serial_number . ' Metadata');
     $metadata_coll->addAccept('application/x-www-form-urlencoded');
     $metadata_coll->addAccept('application/json');
     return $app->asXml();
 }