Пример #1
0
/**
 * Utility function used by import_extender_plugin_hook() to process
 * an ODDMetaData and add it to an entity. This function does not
 * hit ->save() on the entity (this lets you construct in memory)
 *
 * @param ElggEntity  $entity  The entity to add the data to.
 * @param ODDMetaData $element The OpenDD element
 *
 * @return bool
 * @access private
 */
function oddmetadata_to_elggextender(ElggEntity $entity, ODDMetaData $element)
{
    // Get the type of extender (metadata, type, attribute etc)
    $type = $element->getAttribute('type');
    $attr_name = $element->getAttribute('name');
    $attr_val = $element->getBody();
    switch ($type) {
        // Ignore volatile items
        case 'volatile':
            break;
        case 'annotation':
            $entity->annotate($attr_name, $attr_val);
            break;
        case 'metadata':
            $entity->setMetaData($attr_name, $attr_val, "", true);
            break;
        default:
            // Anything else assume attribute
            $entity->set($attr_name, $attr_val);
    }
    // Set time if appropriate
    $attr_time = $element->getAttribute('published');
    if ($attr_time) {
        $entity->set('time_updated', $attr_time);
    }
    return true;
}
Пример #2
0
 /**
  * Export this object
  *
  * @return array
  * @deprecated 1.9 Use toObject()
  */
 public function export()
 {
     elgg_deprecated_notice(__METHOD__ . ' has been deprecated', 1.9);
     $uuid = get_uuid_from_object($this);
     $meta = new ODDMetaData($uuid, guid_to_uuid($this->entity_guid), $this->attributes['name'], $this->attributes['value'], $this->attributes['type'], guid_to_uuid($this->owner_guid));
     $meta->setAttribute('published', date("r", $this->time_created));
     return $meta;
 }
Пример #3
0
 /**
  * Export this class into an array of ODD Elements containing all necessary fields.
  * Override if you wish to return more information than can be found in
  * $this->attributes (shouldn't happen)
  *
  * @return array
  * @deprecated 1.9
  */
 public function export()
 {
     elgg_deprecated_notice(__METHOD__ . ' has been deprecated', 1.9);
     $tmp = array();
     // Generate uuid
     $uuid = guid_to_uuid($this->getGUID());
     // Create entity
     $odd = new ODDEntity($uuid, $this->attributes['type'], get_subtype_from_id($this->attributes['subtype']));
     $tmp[] = $odd;
     $exportable_values = $this->getExportableValues();
     // Now add its attributes
     foreach ($this->attributes as $k => $v) {
         $meta = null;
         if (in_array($k, $exportable_values)) {
             switch ($k) {
                 case 'guid':
                     // Dont use guid in OpenDD
                 // Dont use guid in OpenDD
                 case 'type':
                     // Type and subtype already taken care of
                 // Type and subtype already taken care of
                 case 'subtype':
                     break;
                 case 'time_created':
                     // Created = published
                     $odd->setAttribute('published', date("r", $v));
                     break;
                 case 'site_guid':
                     // Container
                     $k = 'site_uuid';
                     $v = guid_to_uuid($v);
                     $meta = new ODDMetaData($uuid . "attr/{$k}/", $uuid, $k, $v);
                     break;
                 case 'container_guid':
                     // Container
                     $k = 'container_uuid';
                     $v = guid_to_uuid($v);
                     $meta = new ODDMetaData($uuid . "attr/{$k}/", $uuid, $k, $v);
                     break;
                 case 'owner_guid':
                     // Convert owner guid to uuid, this will be stored in metadata
                     $k = 'owner_uuid';
                     $v = guid_to_uuid($v);
                     $meta = new ODDMetaData($uuid . "attr/{$k}/", $uuid, $k, $v);
                     break;
                 default:
                     $meta = new ODDMetaData($uuid . "attr/{$k}/", $uuid, $k, $v);
             }
             // set the time of any metadata created
             if ($meta) {
                 $meta->setAttribute('published', date("r", $this->time_created));
                 $tmp[] = $meta;
             }
         }
     }
     // Now we do something a bit special.
     /*
      * This provides a rendered view of the entity to foreign sites.
      */
     elgg_set_viewtype('default');
     $view = elgg_view_entity($this, array('full_view' => true));
     elgg_set_viewtype();
     $tmp[] = new ODDMetaData($uuid . "volatile/renderedentity/", $uuid, 'renderedentity', $view, 'volatile');
     return $tmp;
 }
Пример #4
0
 /**
  * Export this object
  *
  * @return array
  */
 public function export()
 {
     $uuid = get_uuid_from_object($this);
     $meta = new ODDMetaData($uuid, guid_to_uuid($this->entity_guid), $this->attributes['name'], $this->attributes['value'], $this->attributes['type'], guid_to_uuid($this->owner_guid));
     $meta->setAttribute('published', date("r", $this->time_created));
     return $meta;
 }