예제 #1
0
 function injectAtomEntryData(Dase_Atom_Entry $entry, $app_root)
 {
     $d = "http://daseproject.org/ns/1.0";
     //this function assumes p_collection_ascii_id & p_serial_number are set
     $entry->setId($this->getLink($app_root));
     $entry->setTitle($this->filename);
     $entry->addAuthor();
     $entry->setUpdated($this->updated);
     $entry->setSummary('');
     //for AtomPub
     $entry->setEdited($this->updated);
     $edit_url = $app_root . '/media/' . $this->p_collection_ascii_id . '/' . $this->p_serial_number;
     $entry->addLink($edit_url, 'edit');
     $ext = Dase_File::$types_map[$this->mime_type]['ext'];
     $edit_media_url = $app_root . '/media/' . $this->p_collection_ascii_id . '/' . $this->p_serial_number;
     $entry->addLink($edit_media_url, 'edit-media');
     //to which we can post form-encoded or json metadata pairs:
     $entry->addLink($app_root . '/item/' . $this->p_collection_ascii_id . '/' . $this->p_serial_number . '/metadata', 'http://daseproject.org/relation/edit-metadata');
     //link to the owning dase item using iana registered 'up' rel value
     $entry->addLink($app_root . '/item/' . $this->p_collection_ascii_id . '/' . $this->p_serial_number . '.atom', 'up');
     $entry->setMediaContent($this->getLink($app_root), $this->mime_type);
     $media_group = $entry->addElement('media:group', null, Dase_Atom::$ns['media']);
     //todo: beef up w/ bitrate, samplingrate, etc.
     foreach ($this->getDerivatives() as $med) {
         if ($med->size == 'thumbnail') {
             //$media_thumbnail = $entry->addElement('media:thumbnail',null,Dase_Atom::$ns['media']);
             $media_thumbnail = $media_group->appendChild($entry->dom->createElementNS(Dase_Atom::$ns['media'], 'thumbnail'));
             $media_thumbnail->setAttribute('url', $med->getLink($app_root));
             $media_thumbnail->setAttribute('width', $med->width);
             $media_thumbnail->setAttribute('height', $med->height);
         }
         if ($med->size == 'viewitem') {
             //$media_viewitem = $entry->addElement('media:content',null,Dase_Atom::$ns['media']);
             $media_viewitem = $media_group->appendChild($entry->dom->createElementNS(Dase_Atom::$ns['media'], 'content'));
             $media_viewitem->setAttribute('url', $med->getLink($app_root));
             $media_viewitem->setAttribute('width', $med->width);
             $media_viewitem->setAttribute('height', $med->height);
             $media_viewitem->setAttribute('fileSize', $med->file_size);
             $media_viewitem->setAttribute('type', $med->mime_type);
             $media_category = $media_viewitem->appendChild($entry->dom->createElement('media:category'));
             $media_category->appendChild($entry->dom->createTextNode($med->size));
         }
         if ($med->size != 'thumbnail' && $med->size != 'viewitem') {
             $media_content = $media_group->appendChild($entry->dom->createElementNS(Dase_Atom::$ns['media'], 'content'));
             $media_content->setAttribute('url', $med->getLink($app_root));
             $media_content->setAttribute('width', $med->width);
             $media_content->setAttribute('height', $med->height);
             $media_content->setAttribute('fileSize', $med->file_size);
             $media_content->setAttribute('type', $med->mime_type);
             $media_category = $media_content->appendChild($entry->dom->createElement('media:category'));
             $media_category->appendChild($entry->dom->createTextNode($med->size));
         }
     }
     return $entry->asXml();
 }
예제 #2
0
 function injectAtomEntryData(Dase_Atom_Entry $entry, $app_root)
 {
     $entry->setTitle('Collection Manager ' . $this->collection_ascii_id . '/' . $this->dase_user_eid);
     $entry->setId($app_root . '/manager/' . $this->collection_ascii_id . '/' . $this->dase_user_eid);
     $entry->addCategory('collection_manager', 'http://daseproject.org/category/entrytype');
     $entry->setUpdated($this->created);
     $entry->addAuthor($this->created_by_eid);
     $entry->addCategory($this->auth_level, 'http://daseproject.org/category/auth_level');
     $entry->addCategory($this->dase_user_eid, 'http://daseproject.org/category/eid');
     $entry->addCategory($this->collection_ascii_id, 'http://daseproject.org/category/collection');
     return $entry;
 }
예제 #3
0
 function injectAtomEntryData(Dase_Atom_Entry $entry, $collection_ascii_id, $app_root)
 {
     $entry->setTitle($this->name);
     $entry->setId($this->getUrl($collection_ascii_id, $app_root));
     $entry->setSummary($this->description);
     $entry->addLink($this->getUrl($collection_ascii_id, $app_root) . '.atom', 'edit');
     $entry->addLink($this->getUrl($collection_ascii_id, $app_root) . '/attributes.atom', 'http://daseproject.org/relation/item_type/attributes', 'application/atom+xml', '', $this->name . ' Attributes');
     $entry->addLink($this->getUrl($collection_ascii_id, $app_root) . '/attributes.json', 'http://daseproject.org/relation/item_type/attributes', 'application/json', '', $this->name . ' Attributes');
     $entry->addCategory('item_type', 'http://daseproject.org/category/entrytype', 'Item Type');
     if (is_numeric($this->updated)) {
         $updated = date(DATE_ATOM, $this->updated);
     } else {
         $updated = $this->updated;
     }
     $entry->setUpdated($updated);
     $entry->addAuthor();
     return $entry;
 }
예제 #4
0
 function injectAtomEntryData(Dase_Atom_Entry $entry, $app_root)
 {
     $url = $this->getUrl($this->ascii_id, $app_root);
     $entry->setTitle($this->collection_name);
     $entry->setId($url);
     $entry->setUpdated($this->updated);
     $entry->addAuthor();
     $entry->addLink($url . '.atom');
     $entry->addLink($url . '.atom', 'edit');
     $entry->addCategory('collection', 'http://daseproject.org/category/entrytype');
     if ($this->description) {
         $entry->setSummary($this->description);
     } else {
         $entry->setSummary(str_replace('_collection', '', $this->ascii_id));
     }
     if ($this->admin_notes) {
         $entry->setContent($this->admin_notes);
     }
     foreach ($this->getAttributes() as $a) {
         $entry->addCategory($a->ascii_id, "http://daseproject.org/category/attribute", $a->attribute_name);
     }
     foreach ($this->getItemTypes() as $item_type) {
         $entry->addCategory($item_type->ascii_id, "http://daseproject.org/category/item_type", $item_type->name);
     }
     if ($this->is_public) {
         $pub = "public";
     } else {
         $pub = "private";
     }
     $entry->addCategory($pub, "http://daseproject.org/category/status");
     if (!$this->visibility) {
         $this->visibility = 'user';
     }
     $entry->addCategory($this->visibility, "http://daseproject.org/category/visibility");
     $entry->addCategory($app_root, "http://daseproject.org/category/base_url");
     $entry->addCategory($this->item_count, "http://daseproject.org/category/item_count");
     return $entry;
 }
예제 #5
0
파일: Item.php 프로젝트: rakeshraushan/dase
 function injectAtomEntryData(Dase_Atom_Entry $entry, $app_root, $authorize_links = false)
 {
     if (!$this->id) {
         return false;
     }
     /* namespaces */
     $d = Dase_Atom::$ns['d'];
     $thr = Dase_Atom::$ns['thr'];
     /* resources */
     $base_url = $app_root . '/item/' . $this->p_collection_ascii_id . '/' . $this->serial_number;
     /* standard atom stuff */
     $entry->setId($base_url);
     $entry->addAuthor($this->created_by_eid);
     //todo: I think this can be simplified when DASe 1.0 is retired
     if (is_numeric($this->updated)) {
         $entry->setUpdated(date(DATE_ATOM, $this->updated));
     } else {
         $entry->setUpdated($this->updated);
     }
     if (is_numeric($this->created)) {
         $entry->setPublished(date(DATE_ATOM, $this->created));
     } else {
         $entry->setPublished($this->created);
     }
     //atompub
     $entry->setEdited($entry->getUpdated());
     //alternate link
     $entry->addLink($app_root . '/item/' . $this->p_collection_ascii_id . '/' . $this->serial_number, 'alternate');
     //the following 2 links should be unified
     //link to item metadata json, used for editing metadata
     $entry->addLink($app_root . '/item/' . $this->p_collection_ascii_id . '/' . $this->serial_number . '/metadata.json', 'http://daseproject.org/relation/metadata', 'application/json');
     //to which we can POST form-encoded or json metadata pairs:
     $entry->addLink($app_root . '/item/' . $this->p_collection_ascii_id . '/' . $this->serial_number . '/metadata', 'http://daseproject.org/relation/edit-metadata');
     //to which we can POST form-encoded or text/plain:
     $entry->addLink($app_root . '/item/' . $this->p_collection_ascii_id . '/' . $this->serial_number . '/item_type', 'http://daseproject.org/relation/edit-item_type');
     $entry->addLink($app_root . '/item/' . $this->p_collection_ascii_id . '/' . $this->serial_number . '.atom', 'edit', 'application/atom+xml');
     if ($authorize_links) {
         $entry->addLink($app_root . '/item/' . $this->p_collection_ascii_id . '/' . $this->serial_number . '.atom', 'http://daseproject.org/relation/cached', 'application/atom+xml');
     } else {
         $entry->addLink($app_root . '/item/' . $this->p_collection_ascii_id . '/' . $this->serial_number . '/authorized.atom', 'http://daseproject.org/relation/authorized', 'application/atom+xml');
     }
     $entry->addLink($app_root . '/item/' . $this->p_collection_ascii_id . '/' . $this->serial_number . '/content', 'http://daseproject.org/relation/edit-content');
     $entry->addLink($app_root . '/item/' . $this->p_collection_ascii_id . '/' . $this->serial_number . '.json', 'http://daseproject.org/relation/edit', 'application/json');
     $entry->addLink($app_root . '/collection/' . $this->p_collection_ascii_id . '/service', 'service', 'application/atomsvc+xml');
     $entry->addLink($app_root . '/collection/' . $this->p_collection_ascii_id . '/attributes.json', 'http://daseproject.org/relation/attributes', 'application/json');
     /**** COMMENT LINK (threading extension) **********/
     $replies = $entry->addLink($app_root . '/item/' . $this->p_collection_ascii_id . '/' . $this->serial_number . '/comments', 'replies');
     if ($this->comments_count) {
         //lookup
         $replies->setAttributeNS($thr, 'thr:count', $this->comments_count);
         //lookup
         $replies->setAttributeNS($thr, 'thr:updated', $this->comments_updated);
     }
     /* dase categories */
     $entry->setEntrytype('item');
     //allows us to replace all if/when necessary :(
     $entry->addCategory($app_root, "http://daseproject.org/category/base_url");
     $entry->addCategory($this->item_type_ascii_id, 'http://daseproject.org/category/item_type', $this->item_type_name);
     $entry->addCategory($this->p_collection_ascii_id, 'http://daseproject.org/category/collection', $this->collection_name);
     $entry->addCategory($this->id, 'http://daseproject.org/category/item_id');
     $entry->addCategory($this->serial_number, 'http://daseproject.org/category/serial_number');
     if ($this->status) {
         $entry->addCategory($this->status, 'http://daseproject.org/category/status');
     } else {
         $entry->addCategory('public', 'http://daseproject.org/category/status');
     }
     /********* METADATA **********/
     $item_metadata = $this->getMetadata(true);
     foreach ($item_metadata as $row) {
         if ($row['url']) {
             //create metadata LINK
             $metadata_link = $entry->addLink($row['url'], 'http://daseproject.org/relation/metadata-link/' . $this->p_collection_ascii_id . '/' . $row['ascii_id'], '', '', $row['value_text']);
             $metadata_link->setAttributeNS($d, 'd:attribute', $row['attribute_name']);
             $metadata_link->setAttributeNS($d, 'd:edit-id', $app_root . $row['edit-id']);
             if ($row['modifier']) {
                 $metadata_link->setAttributeNS($d, 'd:mod', $row['modifier']);
                 if ($row['modifier_type']) {
                     $metadata_link->setAttributeNS($d, 'd:modtype', $row['modifier_type']);
                 }
             }
         }
     }
     foreach ($item_metadata as $row) {
         if ($row['url']) {
             //already made metadata links
         } else {
             //create metadata CATEGORY
             if (0 == $row['collection_id']) {
                 $meta = $entry->addCategory($row['ascii_id'], 'http://daseproject.org/category/admin_metadata', $row['attribute_name'], $row['value_text']);
             } else {
                 if ($row['is_public']) {
                     $meta = $entry->addCategory($row['ascii_id'], 'http://daseproject.org/category/metadata', $row['attribute_name'], $row['value_text']);
                     $meta->setAttributeNS($d, 'd:edit-id', $app_root . $row['edit-id']);
                 } else {
                     $meta = $entry->addCategory($row['ascii_id'], 'http://daseproject.org/category/private_metadata', $row['attribute_name'], $row['value_text']);
                     $meta->setAttributeNS($d, 'd:edit-id', $app_root . $row['edit-id']);
                 }
                 if ('title' == $row['ascii_id'] || 'Title' == $row['attribute_name']) {
                     $entry->setTitle($row['value_text']);
                 }
                 if ('rights' == $row['ascii_id']) {
                     $entry->setRights($row['value_text']);
                 }
                 if ($row['modifier']) {
                     $meta->setAttributeNS($d, 'd:mod', $row['modifier']);
                     if ($row['modifier_type']) {
                         $meta->setAttributeNS($d, 'd:modtype', $row['modifier_type']);
                     }
                 }
             }
         }
     }
     //this will only "take" if there is not already a title
     $entry->setTitle($this->serial_number);
     /*******  MEDIA  ***********/
     $item_media = $this->getMedia();
     $token = $this->config->getAuth('token');
     if (isset($item_media['enclosure'])) {
         $enc = $item_media['enclosure'];
         if ($authorize_links) {
             $entry->addLink($this->getMediaUrl('enclosure', $app_root, $token), 'enclosure', $enc['mime_type'], $enc['file_size']);
         } else {
             $entry->addLink($this->getMediaUrl('enclosure', $app_root), 'enclosure', $enc['mime_type'], $enc['file_size']);
         }
     }
     /* edit-media link */
     $entry->addLink($this->getEditMediaUrl($app_root), 'edit-media');
     $media_url = $app_root . '/item/' . $this->p_collection_ascii_id . '/' . $this->serial_number . '/media';
     $entry->addLink($media_url, 'http://daseproject.org/relation/add-media');
     /* media rss ext */
     foreach ($this->getMedia() as $size => $med) {
         if ('thumbnail' == $size) {
             $media_thumbnail = $entry->addElement('media:thumbnail', '', Dase_Atom::$ns['media']);
             $media_thumbnail->setAttribute('url', $app_root . $med['url']);
             $media_thumbnail->setAttribute('width', $med['width']);
             $media_thumbnail->setAttribute('height', $med['height']);
         } else {
             if ($size != 'enclosure') {
                 $media_content = $entry->addElement('media:content', '', Dase_Atom::$ns['media']);
                 if ($authorize_links) {
                     $media_content->setAttribute('url', $this->getMediaUrl($size, $app_root, $token));
                 } else {
                     $media_content->setAttribute('url', $this->getMediaUrl($size, $app_root));
                 }
                 if ($med['width'] && $med['height']) {
                     $media_content->setAttribute('width', $med['width']);
                     $media_content->setAttribute('height', $med['height']);
                 }
                 $media_content->setAttribute('fileSize', $med['file_size']);
                 $media_content->setAttribute('type', $med['mime_type']);
                 $media_category = $media_content->appendChild($entry->dom->createElement('media:category'));
                 $media_category->appendChild($entry->dom->createTextNode($size));
             }
         }
     }
     return $entry;
 }
예제 #6
0
파일: Tag.php 프로젝트: rakeshraushan/dase
 function injectAtomEntryData(Dase_Atom_Entry $entry, $user = null, $app_root)
 {
     if (!$user) {
         $user = $this->getUser();
     }
     $entry->setTitle($this->name);
     if ($this->description) {
         $entry->setSummary($this->description);
     }
     $entry->setId($app_root . '/user/' . $user->eid . '/tag/' . $this->ascii_id);
     $updated = $this->updated ? $this->updated : '2005-01-01T00:00:01-06:00';
     $entry->setUpdated($updated);
     $entry->addAuthor($user->eid);
     $entry->addLink($app_root . '/tag/' . $user->eid . '/' . $this->ascii_id . '.atom', 'self');
     $entry->addLink($app_root . '/tag/' . $user->eid . '/' . $this->ascii_id . '/authorized.atom', 'http://daseproject.org/relation/authorized');
     $entry->addLink($app_root . '/tag/' . $user->eid . '/' . $this->ascii_id . '/entry.atom', 'edit');
     $entry->addLink($app_root . '/tag/' . $user->eid . '/' . $this->ascii_id . '/entry.json', 'http://daseproject.org/relation/edit', 'application/json');
     $entry->addLink($app_root . '/tag/' . $user->eid . '/' . $this->ascii_id, 'alternate');
     $tag_cat = new Dase_DBO_TagCategory($this->db);
     $tag_cat->tag_id = $this->id;
     foreach ($tag_cat->find() as $tc) {
         $entry->addCategory($tc->term, 'http://daseproject.org/category/' . $tc->scheme, $tc->label);
     }
     $entry->addCategory($app_root, "http://daseproject.org/category/base_url");
     $entry->addCategory("set", "http://daseproject.org/category/entrytype");
     $entry->addCategory($this->type, "http://daseproject.org/category/tag_type", $this->type);
     if ($this->is_public) {
         $pub = "public";
     } else {
         $pub = "private";
     }
     $entry->addCategory($pub, "http://daseproject.org/category/visibility");
     $entry->addCategory($this->background, "http://daseproject.org/category/background");
     return $entry;
 }
예제 #7
0
 function injectAtomEntryData(Dase_Atom_Entry $entry, $collection_ascii_id, $app_root)
 {
     $url = $this->getUrl($collection_ascii_id, $app_root);
     $entry->setTitle($this->attribute_name);
     $entry->setId($url);
     $entry->addLink($url . '.atom');
     $entry->addLink($url . '.atom', 'edit');
     $entry->addCategory('attribute', 'http://daseproject.org/category/entrytype');
     $entry->addCategory($this->html_input_type, 'http://daseproject.org/category/html_input_type');
     $entry->addCategory($this->is_repeatable, 'http://daseproject.org/category/repeatable');
     $entry->addCategory($this->is_required, 'http://daseproject.org/category/required');
     if (!$this->is_on_list_display) {
         $entry->addCategory('0', 'http://daseproject.org/category/list_display');
     } else {
         $entry->addCategory('1', 'http://daseproject.org/category/list_display');
     }
     foreach ($this->getItemTypes() as $type) {
         $entry->addCategory($type->ascii_id, 'http://daseproject.org/category/parent_item_type', $type->name);
     }
     //allows posting
     if (in_array($this->html_input_type, array('checkbox', 'select', 'radio'))) {
         $entry->addLink($url . '/defined', 'http://daseproject.org/relation/defined_values', 'application/atomcat+xml');
     }
     if ($this->modifier_type) {
         $entry->addCategory($this->modifier_type, 'http://daseproject.org/category/modifier_type');
     }
     if ($this->modifier_defined_list) {
         $entry->addCategory($this->modifier_defined_list, 'http://daseproject.org/category/modifier_defined_list');
     }
     foreach ($this->getDefinedValues() as $val) {
         $entry->addCategory($val, 'http://daseproject.org/category/defined_value');
     }
     $entry->setSummary($this->usage_notes);
     $entry->addCategory($this->sort_order, 'http://daseproject.org/category/sort_order');
     //compat
     if (is_numeric($this->updated)) {
         $updated = date(DATE_ATOM, $this->updated);
     } else {
         $updated = $this->updated;
     }
     $entry->setUpdated($updated);
     $entry->addAuthor();
     return $entry;
 }