当前位置: 首页>>代码示例>>PHP>>正文


PHP create_metadata函数代码示例

本文整理汇总了PHP中create_metadata函数的典型用法代码示例。如果您正苦于以下问题:PHP create_metadata函数的具体用法?PHP create_metadata怎么用?PHP create_metadata使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了create_metadata函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testElggEntityDisableAndEnable

 public function testElggEntityDisableAndEnable()
 {
     global $CONFIG;
     // add annotations and metadata to check if they're disabled.
     $annotation_id = create_annotation($this->entity->guid, 'test_annotation_' . rand(), 'test_value_' . rand());
     $metadata_id = create_metadata($this->entity->guid, 'test_metadata_' . rand(), 'test_value_' . rand());
     $this->assertTrue($this->entity->disable());
     // ensure disabled by comparing directly with database
     $entity = get_data_row("SELECT * FROM {$CONFIG->dbprefix}entities WHERE guid = '{$this->entity->guid}'");
     $this->assertIdentical($entity->enabled, 'no');
     $annotation = get_data_row("SELECT * FROM {$CONFIG->dbprefix}annotations WHERE id = '{$annotation_id}'");
     $this->assertIdentical($annotation->enabled, 'no');
     $metadata = get_data_row("SELECT * FROM {$CONFIG->dbprefix}metadata WHERE id = '{$metadata_id}'");
     $this->assertIdentical($metadata->enabled, 'no');
     // re-enable for deletion to work
     $this->assertTrue($this->entity->enable());
     // check enabled
     // check annotations and metadata enabled.
     $entity = get_data_row("SELECT * FROM {$CONFIG->dbprefix}entities WHERE guid = '{$this->entity->guid}'");
     $this->assertIdentical($entity->enabled, 'yes');
     $annotation = get_data_row("SELECT * FROM {$CONFIG->dbprefix}annotations WHERE id = '{$annotation_id}'");
     $this->assertIdentical($annotation->enabled, 'yes');
     $metadata = get_data_row("SELECT * FROM {$CONFIG->dbprefix}metadata WHERE id = '{$metadata_id}'");
     $this->assertIdentical($metadata->enabled, 'yes');
     $this->assertTrue($this->entity->delete());
     $this->entity = null;
 }
开发者ID:tjcaverly,项目名称:Elgg,代码行数:27,代码来源:ElggEntityTest.php

示例2: izapMarkVisitor

/**
 *funtion to mark the visitor
 */
function izapMarkVisitor()
{
    $ProfileEntity = elgg_get_page_owner_entity();
    $ProfileName = $ProfileEntity->name;
    $ProfileGuid = $ProfileEntity->guid;
    $ProfileOwner = $ProfileEntity->owner_guid;
    $ProfileAccess = $ProfileEntity->access_id;
    $VisitorEntity = elgg_get_logged_in_user_entity();
    $VisitorName = $VisitorEntity->name;
    $VisitorGuid = $VisitorEntity->guid;
    $VisitorsArray = array();
    if ($VisitorGuid != $ProfileGuid && $VisitorEntity && $ProfileEntity) {
        $md = elgg_get_metadata(array('guid' => $ProfileGuid, 'metadata_name' => 'izapProfileVisitor', 'limit' => false));
        $Metadata = array();
        if ($md && count($md) == 1) {
            $Metadata = $md[0];
        } else {
            $Metadata = $md;
        }
        if ($Metadata) {
            $Id = $Metadata->id;
            $VisitorsArray = unserialize($Metadata->value);
            array_unshift($VisitorsArray, $VisitorGuid);
            $InsertArray = array_slice(array_unique($VisitorsArray), 0, 10);
            $InsertArray = serialize($InsertArray);
            izap_update_metadata($Id, 'izapProfileVisitor', $InsertArray, 'text', $ProfileOwner, ACCESS_PUBLIC);
        } else {
            array_unshift($VisitorsArray, $VisitorGuid);
            $InsertArray = serialize($VisitorsArray);
            create_metadata($ProfileGuid, 'izapProfileVisitor', $InsertArray, 'text', $ProfileOwner, ACCESS_PUBLIC);
        }
    }
}
开发者ID:Daltonmedia,项目名称:izap_profile_visitors,代码行数:36,代码来源:izap_profile_visitors_lib.php

示例3: testElggGetEntitiesFromMetadata

 public function testElggGetEntitiesFromMetadata()
 {
     global $CONFIG, $METASTRINGS_CACHE, $METASTRINGS_DEADNAME_CACHE;
     $METASTRINGS_CACHE = $METASTRINGS_DEADNAME_CACHE = array();
     $this->object->title = 'Meta Unit Test';
     $this->object->save();
     $this->create_metastring('metaUnitTest');
     $this->create_metastring('tested');
     $this->assertTrue(create_metadata($this->object->guid, 'metaUnitTest', 'tested'));
     // check value with improper case
     $options = array('metadata_names' => 'metaUnitTest', 'metadata_values' => 'Tested', 'limit' => 10, 'metadata_case_sensitive' => TRUE);
     $this->assertFalse(elgg_get_entities_from_metadata($options));
     // compare forced case with ignored case
     $options = array('metadata_names' => 'metaUnitTest', 'metadata_values' => 'tested', 'limit' => 10, 'metadata_case_sensitive' => TRUE);
     $case_true = elgg_get_entities_from_metadata($options);
     $this->assertIsA($case_true, 'array');
     $options = array('metadata_names' => 'metaUnitTest', 'metadata_values' => 'Tested', 'limit' => 10, 'metadata_case_sensitive' => FALSE);
     $case_false = elgg_get_entities_from_metadata($options);
     $this->assertIsA($case_false, 'array');
     $this->assertIdentical($case_true, $case_false);
     // check deprecated get_entities_from_metadata() function
     $deprecated = get_entities_from_metadata('metaUnitTest', 'tested', '', '', 0, 10, 0, '', 0, FALSE, TRUE);
     $this->assertIdentical($deprecated, $case_true);
     // check entity list
     //$this->dump(list_entities_from_metadata('metaUnitTest', 'Tested', '', '', 0, 10, TRUE, TRUE, TRUE, FALSE));
     // clean up
     $this->delete_metastrings();
     $this->object->delete();
 }
开发者ID:ashwiniravi,项目名称:Elgg-Social-Network-Single-Sign-on-and-Web-Statistics,代码行数:29,代码来源:metadata.php

示例4: addTaggedWirePost

function addTaggedWirePost($hook, $type, $params)
{
    global $CONFIG;
    $id = insert_data("insert into {$CONFIG->dbprefix}river " . " set type = '" . $params['type'] . "', " . " subtype = '" . $params['subtype'] . "', " . " action_type = '" . $params['action_type'] . "', " . " access_id = '" . $params['access_id'] . "', " . " view = '" . $params['view'] . "', " . " subject_guid = '" . $params['subject_guid'] . "', " . " object_guid = '" . $params['object_guid'] . "', " . " annotation_id = '" . $params['annotation_id'] . "', " . " posted = '" . $params['posted'] . "';");
    $tags = "";
    if (isset($_SESSION['role'])) {
        switch ($_SESSION['role']) {
            case "learner":
                $tags = "Learner-Apprenant";
                break;
            case "instructor":
                $tags = "Instructor-Instructeur";
                break;
            case "developer":
                $tags = "Developer-Développeur";
                break;
            case "trainingmgr":
                $tags = "trainingmgr";
                break;
        }
        $roleTags = $_SESSION['role'];
    }
    if ($roleTags) {
        $metaID = create_metadata($params['object_guid'], "tags", "{$tags}", "text", elgg_get_logged_in_user_guid(), 2, true);
    }
    if ($id) {
        update_entity_last_action($object_guid, $posted);
        $river_items = elgg_get_river(array('id' => $id));
        if ($river_items) {
            elgg_trigger_event('created', 'river', $river_items[0]);
        }
    }
    return false;
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:34,代码来源:start.php

示例5: publication_create_user

/**
 * Extend the create user function to include additional information
 * for invited authors
 *
 * @param string $event
 * @param string $object_type
 * @param ElggUser $object
 */
function publication_create_user($event, $object_type, $object)
{
    $author = get_input($key);
    $publication = get_input($key);
    if (empty($author) || empty($publication)) {
        return;
    }
    create_metadata($object->getGUID(), "exauthor_name", $author, "", $object->getGUID(), ACCESS_PUBLIC);
    create_metadata($object->getGUID(), "firstpublication", $publication, "", $object->getGUID(), ACCESS_PUBLIC);
}
开发者ID:Beaufort8,项目名称:elgg-publication,代码行数:18,代码来源:events.php

示例6: put

 /**
  * {@inheritdoc}
  */
 public function put(ParameterBag $params)
 {
     $owner = get_entity($params->guid);
     if (!$owner->canEdit()) {
         throw new GraphException("You are not allowed to modify this user's profile", HttpResponse::HTTP_FORBIDDEN);
     }
     $profile_fields = (array) elgg_get_config('profile_fields');
     $access_id = $params->access_id !== null ? $params->access_id : get_default_access($owner);
     $input = array();
     foreach ($profile_fields as $field => $valuetype) {
         // Making sure the consumer has sent these fields with the request
         if (isset($params->{$field}) && $this->request->get($field) !== null) {
             $value = $params->{$field};
             $value = _elgg_html_decode($value);
             if (!is_array($value) && $valuetype != 'longtext' && elgg_strlen($value) > 250) {
                 throw new GraphException(elgg_echo('profile:field_too_long', array(elgg_echo("profile:{$field}")), HttpResponse::HTTP_BAD_REQUEST));
             }
             if ($value && $valuetype == 'url' && !preg_match('~^https?\\://~i', $value)) {
                 $value = "http://{$value}";
             }
             if ($valuetype == 'tags') {
                 $value = string_to_tag_array($value);
             }
             if ($valuetype == 'email' && !empty($value) && !is_email_address($value)) {
                 throw new GraphException(elgg_echo('profile:invalid_email', array(elgg_echo("profile:{$field}"))), HttpResponse::HTTP_BAD_REQUEST);
             }
             $input[$field] = $value;
         }
     }
     // go through custom fields
     if (sizeof($input) > 0) {
         foreach ($input as $shortname => $value) {
             $options = array('guid' => $owner->guid, 'metadata_name' => $shortname, 'limit' => false);
             elgg_delete_metadata($options);
             if (!is_null($value) && $value !== '') {
                 // only create metadata for non empty values (0 is allowed) to prevent metadata records
                 // with empty string values #4858
                 if (is_array($value)) {
                     $i = 0;
                     foreach ($value as $interval) {
                         $i++;
                         $multiple = $i > 1 ? TRUE : FALSE;
                         create_metadata($owner->guid, $shortname, $interval, 'text', $owner->guid, $access_id, $multiple);
                     }
                 } else {
                     create_metadata($owner->getGUID(), $shortname, $value, 'text', $owner->getGUID(), $access_id);
                 }
             }
         }
         $owner->save();
         // Notify of profile update
         elgg_trigger_event('profileupdate', $owner->type, $owner);
     }
     return $this->get($params);
 }
开发者ID:hypejunction,项目名称:hypegraph,代码行数:58,代码来源:UserProfile.php

示例7: testElggGetMetadataCount

 public function testElggGetMetadataCount()
 {
     $this->object->title = 'Meta Unit Test';
     $this->object->save();
     $guid = $this->object->getGUID();
     create_metadata($guid, 'tested', 'tested1', 'text', 0, ACCESS_PUBLIC, true);
     create_metadata($guid, 'tested', 'tested2', 'text', 0, ACCESS_PUBLIC, true);
     $count = (int) elgg_get_metadata(array('metadata_names' => array('tested'), 'guid' => $guid, 'count' => true));
     $this->assertIdentical($count, 2);
     $this->object->delete();
 }
开发者ID:elainenaomi,项目名称:labxp2014,代码行数:11,代码来源:metadata.php

示例8: createMetadata

 public function createMetadata($max = 1)
 {
     $metadata = array();
     for ($i = 0; $i < $max; $i++) {
         $name = 'test_metadata_name' . rand();
         $value = 'test_metadata_value' . rand();
         $id = create_metadata($this->object->guid, $name, $value);
         $metadata[] = $id;
     }
     return $metadata;
 }
开发者ID:rasul,项目名称:Elgg,代码行数:11,代码来源:metastrings.php

示例9: save

 /**
  * Save metadata object
  *
  * @return int|bool the metadata object id or true if updated
  *
  * @throws IOException
  */
 public function save()
 {
     if ($this->id > 0) {
         return update_metadata($this->id, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id);
     } else {
         $this->id = create_metadata($this->entity_guid, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id);
         if (!$this->id) {
             throw new \IOException("Unable to save new " . get_class());
         }
         return $this->id;
     }
 }
开发者ID:ibou77,项目名称:elgg,代码行数:19,代码来源:ElggMetadata.php

示例10: save

 /**
  * Save matadata object
  *
  * @return int the metadata object id
  */
 function save()
 {
     if ($this->id > 0) {
         return update_metadata($this->id, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id);
     } else {
         $this->id = create_metadata($this->entity_guid, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id);
         if (!$this->id) {
             throw new IOException(elgg_echo('IOException:UnableToSaveNew', array(get_class())));
         }
         return $this->id;
     }
 }
开发者ID:redvabel,项目名称:Vabelgg,代码行数:17,代码来源:ElggMetadata.php

示例11: td_get_exif

/**
 * Pull EXIF data from image file
 * 
 * @param TidypicsImage $file
 */
function td_get_exif($file)
{
    // catch for those who don't have exif module loaded
    if (!is_callable('exif_read_data')) {
        return;
    }
    $mime = $file->mimetype;
    if ($mime != 'image/jpeg' && $mime != 'image/pjpeg') {
        return;
    }
    $filename = $file->getFilenameOnFilestore();
    $exif = exif_read_data($filename);
    create_metadata($file->getGUID(), "tp_exif", serialize($exif), "text", $file->getOwnerGUID(), ACCESS_PUBLIC);
}
开发者ID:rijojoy,项目名称:MyIceBerg,代码行数:19,代码来源:exif.php

示例12: publication_create_user

function publication_create_user($event, $object_type, $object)
{
    foreach ($_POST as $key => $value) {
        if ($key == 'author') {
            $author = $value;
        }
        if ($key == 'publication') {
            $publication = $value;
        }
    }
    if ($author && $publication) {
        create_metadata($object->guid, 'exauthor_name', $author, "", $object->guid, ACCESS_PUBLIC);
        create_metadata($object->guid, 'firstpublication', $publication, "", $object->guid, ACCESS_PUBLIC);
    }
}
开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:15,代码来源:start.php

示例13: elggpg_import_key

function elggpg_import_key($public_key, $user)
{
    $gpg = new gnupg();
    $info = $gpg->import($public_key);
    $new_fp = $info['fingerprint'];
    $user_fp = current(elgg_get_metadata(array('guid' => $user->guid, 'metadata_name' => 'openpgp_publickey')));
    $access_id = ACCESS_LOGGED_IN;
    if ($user_fp && $user_fp->value != $new_fp) {
        update_metadata($user_fp->id, $user_fp->name, $new_fp, 'text', $user->guid, $access_id);
        $info['imported'] = 1;
    } elseif (!$user_fp) {
        create_metadata($user->guid, "openpgp_publickey", $new_fp, 'text', $user->guid, $access_id);
        $info['imported'] = 1;
    }
    $info['key_id'] = elggpg_fp2keyid($new_fp);
    return $info;
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:17,代码来源:elggpg.php

示例14: stripe_register_user

/**
 * Check if the email of the user has already been associated with a Stripe customer
 * If so, map them
 *
 * @param string $event
 * @param string $type
 * @param ElggUser $user
 * @param true
 */
function stripe_register_user($event, $type, $user)
{
    $customer_ref = elgg_get_plugin_setting($user->email, 'stripe');
    if (!$customer_ref) {
        return;
    }
    $customer_ref = unserialize($customer_ref);
    if (is_array($customer_ref) && sizeof($customer_ref)) {
        $user->setPrivateSetting('stripe_customer_id', $customer_ref[0]);
        $customer_ref = array_reverse($customer_ref);
        foreach ($customer_ref as $c_ref) {
            create_metadata($user->guid, 'stripe_customer_id', $c_ref, '', $user->guid, ACCESS_PUBLIC, true);
        }
    }
    elgg_unset_plugin_setting($user->email, 'stripe');
    return true;
}
开发者ID:Daltonmedia,项目名称:stripe,代码行数:26,代码来源:events.php

示例15: group_icon_url_override

function group_icon_url_override($hook, $type, $returnvalue, $params)
{
    $group = $params['entity'];
    $size = $params['size'];
    $icontime = $group->icontime;
    if (null === $icontime) {
        $file = new ElggFile();
        $file->owner_guid = $group->owner_guid;
        $file->setFilename("groups/" . $group->guid . "large.jpg");
        $icontime = $file->exists() ? time() : 0;
        create_metadata($group->guid, 'icontime', $icontime, 'integer', $group->owner_guid, ACCESS_PUBLIC);
    }
    if ($icontime) {
        // return thumbnail
        return "groupicon/{$group->guid}/{$size}/{$group->name}.jpg";
    }
    return "mod/groups/graphics/default{$size}.gif";
}
开发者ID:centillien,项目名称:metatags,代码行数:18,代码来源:start.php


注:本文中的create_metadata函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。