Пример #1
0
 /**
  * Models a collection media object for media feeds
  *
  * @param type $mediaObject
  * @param type $mediaObjectType
  * @param type $mediaObjectId
  *
  * return void;
  */
 public static function mediaObject(&$mediaObject, $collection)
 {
     //If the media object is not a collection! skip it
     //1.Load the collection!
     if (!is_object($collection) && is_a($collection, Entity::class)) {
         $thisModel = new Self();
         $attachment = $thisModel->loadObjectByURI($collection);
     }
     //If the media object is not a collection! skip it
     $objectTypeshaystack = array("collection");
     if (!in_array($collection->getObjectType(), $objectTypeshaystack)) {
         return;
     }
     //Nothing to do here if we can't deal with it!
     $collectionObject = new Media\Collection();
     //2.Get all the elements in the collection, limit 5 if more than 5
     //3.Trigger their timeline display
     $collectionObject->set("objectType", "collection");
     $collectionObject->set("uri", $collection->getObjectURI());
     //Now lets populate our collection with Items
     $collectionItems = $collection->getPropertyValue("collection_items");
     $collectionItemize = explode(",", $collectionItems);
     $collectionObject->set("totalItems", count($collectionItemize));
     if (is_array($collectionItemize) && !empty($collectionItemize)) {
         $items = array();
         foreach ($collectionItemize as $item) {
             $itemObject = Media\MediaLink::getNew();
             //@TODO Will probably need to query for objectType of items in collection?
             //@TODO Also this will help in removing objects from collections that have previously been deleted
             $itemObjectEntity = $thisModel->load->model("attachment", "system")->loadObjectByURI($item);
             //Load the item with the attachment to get all its properties
             //Now check object_id exists;
             //If not delete the object all together;
             //Also check if attachments_src is defined and exsits;
             //If attachments id does not exists, delete the item from this collection;
             $itemObjectURL = !empty($item) ? "/system/object/{$item}/" : "http://placeskull.com/100/100/999999";
             $itemObject->set("url", $itemObjectURL);
             $itemObject->set("uri", $item);
             $itemObject->set("height", null);
             $itemObject->set("width", null);
             $itemObject->set("type", $itemObjectEntity->getPropertyValue("attachment_type"));
             $itemObject->set("name", $itemObjectEntity->getPropertyValue("attachment_name"));
             $items[] = $itemObject::getArray();
             unset($itemObject);
         }
         $collectionObject->set("items", $items);
     }
     //Now set the collection Object as the media Object
     $mediaObject = $collectionObject;
     unset($collection);
     unset($collectionObject);
     //All done
     return true;
 }
Пример #2
0
 /**
  * Models a collection media object for media feeds
  *
  * @param type $mediaObject
  * @param type $mediaObjectType
  * @param type $mediaObjectId
  *
  * return void;
  */
 public static function mediaObject(&$mediaObject, $attachment)
 {
     //Allowed media objects
     $types = \Library\Config::getParam("allowed-types", array(), "attachments");
     //1.Load the collection!
     if (!is_object($attachment) && is_a($attachment, 'Platform\\Entity')) {
         $thisModel = new Self();
         $attachment = $thisModel->loadObjectByURI($attachment);
     }
     //If the media object is not a collection! skip it
     $objectTypeshaystack = array("attachment");
     if (!in_array($attachment->getObjectType(), $objectTypeshaystack)) {
         return;
     }
     //Nothing to do here if we can't deal with it!
     $attachmentObject = new MediaLink();
     //2.Get all the elements in the collection, limit 5 if more than 5
     //3.Trigger their timeline display
     $mediaObjectURI = $attachment->getObjectURI();
     $attachmentObject::set("objectType", "attachment");
     $attachmentObject::set("uri", $attachment->getObjectURI());
     //Now lets populate our collection with Items
     //@TODO Will probably need to query for objectType of items in collection?
     //@TODO Also this will help in removing objects from collections that have previously been deleted
     $attachmentObjectURL = !empty($mediaObjectURI) ? "/system/object/{$mediaObjectURI}" : "http://placeskull.com/100/100/999999";
     $attachmentObject->set("url", $attachmentObjectURL);
     $attachmentObject->set("uri", $mediaObjectURI);
     //AttachmentTypes
     //$mediaType  =  $attachment->getPropertyValue("attachment_type");
     $attachmentObject->set("name", $attachment->getPropertyValue("attachment_name"));
     $attachmentObject->set("type", $attachment->getPropertyValue("attachment_type"));
     $attachmentObject->set("height", null);
     $attachmentObject->set("width", null);
     //echo $mediaObjectURI;
     //Now set the collection Object as the media Object
     $mediaObject = $attachmentObject;
     return true;
 }