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


PHP create_annotation函数代码示例

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


在下文中一共展示了create_annotation函数的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: testElggGetAnnotationsCount

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

示例3: createAnnotations

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

示例4: like_post_API

function like_post_API($entity_guid)
{
    $params = array('types' => 'object', 'subtypes' => 'thewire', 'guid' => $entity_guid);
    $latest_wire = elgg_get_entities($params);
    if (elgg_annotation_exists($entity_guid, 'likes')) {
        //delete like
        if ($entity_guid) {
            $like = elgg_get_annotation_from_id($entity_guid);
        }
        if (!$like) {
            $likes = elgg_get_annotations(array('guid' => $entity_guid, 'annotation_owner_guid' => elgg_get_logged_in_user_guid(), 'annotation_name' => 'likes'));
            $like = $likes[0];
        }
        if ($latest_wire) {
            if ($like && $like->canEdit()) {
                $like->delete();
                //echo elgg_echo("likes:deleted");
                return '3';
                //return 'delete';
            } else {
                //echo elgg_echo("likes:notdeleted");
                //return 'notdelete';
                return '4';
            }
        } else {
            return '6';
        }
    } else {
        // Let's see if we can get an entity with the specified GUID
        $entity = get_entity($entity_guid);
        if (!$entity) {
            //echo elgg_echo("likes:notfound");
            //return'not found';
            return '5';
        }
        if ($latest_wire) {
            $user = elgg_get_logged_in_user_entity();
            $annotation_id = create_annotation($entity->guid, 'likes', "likes", "", $user->guid, $entity->access_id);
            // tell user annotation didn't work if that is the case
            if (!$annotation_id) {
                //echo elgg_echo("likes:failure");
                //return 'like failure';
                return '2';
            }
            // notify if poster wasn't owner
            return '1';
            //echo elgg_echo("likes:likes");
            //return 'like';
        } else {
            return '6';
        }
    }
}
开发者ID:shimarahimpur,项目名称:wireAPI,代码行数:53,代码来源:wire.php

示例5: save

 /**
  * Save this instance
  *
  * @return int an object id
  */
 function save()
 {
     if ($this->id > 0) {
         return update_annotation($this->id, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id);
     } else {
         $this->id = create_annotation($this->entity_guid, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id);
         if (!$this->id) {
             throw new IOException(sprintf(elgg_new('IOException:UnableToSaveNew'), get_class()));
         }
         return $this->id;
     }
 }
开发者ID:jricher,项目名称:Elgg,代码行数:17,代码来源:annotations.php

示例6: save

 /**
  * Save this instance
  *
  * @return int an object id
  *
  * @throws IOException
  */
 public function save()
 {
     if ($this->id > 0) {
         return update_annotation($this->id, $this->name, $this->value, $this->value_type, $this->owner_guid, $this->access_id);
     } else {
         $this->id = create_annotation($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:nooshin-mirzadeh,项目名称:web_2.0_benchmark,代码行数:19,代码来源:ElggAnnotation.php

示例7: testElggApiGettersEntitiesFromAnnotation

 public function testElggApiGettersEntitiesFromAnnotation()
 {
     // grab a few different users to annotation
     // there will always be at least 2 here because of the construct.
     $users = elgg_get_entities(array('type' => 'user', 'limit' => 2));
     // create some test annotations
     $subtypes = $this->getRandomValidSubtypes(array('object'), 1);
     $subtype = $subtypes[0];
     $annotation_name = 'test_annotation_name_' . rand();
     $annotation_value = rand(1000, 9999);
     $annotation_name2 = 'test_annotation_name_' . rand();
     $annotation_value2 = rand(1000, 9999);
     $guids = array();
     // our targets
     $valid = new \ElggObject();
     $valid->subtype = $subtype;
     $valid->save();
     $guids[] = $valid->getGUID();
     create_annotation($valid->getGUID(), $annotation_name, $annotation_value, 'integer', $users[0]->getGUID());
     $valid2 = new \ElggObject();
     $valid2->subtype = $subtype;
     $valid2->save();
     $guids[] = $valid2->getGUID();
     create_annotation($valid2->getGUID(), $annotation_name2, $annotation_value2, 'integer', $users[1]->getGUID());
     $options = array('annotation_owner_guid' => $users[0]->getGUID(), 'annotation_name' => $annotation_name);
     $entities = elgg_get_entities_from_annotations($options);
     foreach ($entities as $entity) {
         $this->assertTrue(in_array($entity->getGUID(), $guids));
         $annotations = $entity->getAnnotations(array('annotation_name' => $annotation_name));
         $this->assertEqual(count($annotations), 1);
         $this->assertEqual($annotations[0]->name, $annotation_name);
         $this->assertEqual($annotations[0]->value, $annotation_value);
         $this->assertEqual($annotations[0]->owner_guid, $users[0]->getGUID());
     }
     foreach ($guids as $guid) {
         if ($e = get_entity($guid)) {
             $e->delete();
         }
     }
 }
开发者ID:sephiroth88,项目名称:Elgg,代码行数:40,代码来源:ElggCoreGetEntitiesFromAnnotationsTest.php

示例8: save

 public function save($create_elgg_annotation = true)
 {
     if (parent::save()) {
         if (!$this->river_id && $create_elgg_annotation) {
             $container = $this->getContainerEntity();
             if (!elgg_instanceof($container, 'object', 'hjannotation')) {
                 $container = $this->findOriginalContainer();
             }
             if ($container->getType() != 'river') {
                 if ($id = create_annotation($container->guid, $this->annotation_name, $this->annotation_value, '', $this->owner_guid, $this->access_id)) {
                     $this->annotation_id = $id;
                 }
             }
         }
         $notify_settings = elgg_trigger_plugin_hook('hj:notification:setting', 'annotation', null, '');
         if ($notify_settings && in_array($this->annotation_name, $notify_settings)) {
             $this->sendNotification();
         }
         return $this->guid;
     }
     return false;
 }
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:22,代码来源:hjAnnotation.php

示例9: post

 /**
  * {@inheritdoc}
  */
 public function post(ParameterBag $params)
 {
     $entity_guid = (int) $params->guid;
     //check to see if the user has already liked the item
     if (elgg_annotation_exists($entity_guid, 'likes')) {
         throw new GraphException(elgg_echo("likes:alreadyliked"), HttpResponse::HTTP_NOT_MODIFIED);
     }
     // Let's see if we can get an entity with the specified GUID
     $entity = get_entity($entity_guid);
     if (!$entity) {
         throw new GraphException(elgg_echo("likes:notfound"), HttpResponse::HTTP_NOT_FOUND);
     }
     // limit likes through a plugin hook (to prevent liking your own content for example)
     if (!$entity->canAnnotate(0, 'likes')) {
         // plugins should register the error message to explain why liking isn't allowed
         throw new GraphException(elgg_echo("likes:notallowed"), HttpResponse::HTTP_FORBIDDEN);
     }
     $user = elgg_get_logged_in_user_entity();
     $annotation_id = create_annotation($entity->guid, 'likes', "likes", "", $user->guid, $entity->access_id);
     // tell user annotation didn't work if that is the case
     if (!$annotation_id) {
         throw new GraphException(elgg_echo("likes:failure"));
     }
     // notify if poster wasn't owner
     if ($entity->owner_guid != $user->guid) {
         $owner = $entity->getOwnerEntity();
         $annotation = elgg_get_annotation_from_id($annotation_id);
         $title_str = $entity->getDisplayName();
         if (!$title_str) {
             $title_str = elgg_get_excerpt($entity->description);
         }
         $site = elgg_get_site_entity();
         $subject = elgg_echo('likes:notifications:subject', array($user->name, $title_str), $owner->language);
         $body = elgg_echo('likes:notifications:body', array($owner->name, $user->name, $title_str, $site->name, $entity->getURL(), $user->getURL()), $owner->language);
         notify_user($entity->owner_guid, $user->guid, $subject, $body, array('action' => 'create', 'object' => $annotation));
     }
     return array('nodes' => array(elgg_get_annotation_from_id($annotation_id)));
 }
开发者ID:hypejunction,项目名称:hypegraph,代码行数:41,代码来源:ObjectLikes.php

示例10: likes_add

/**
 * Web service to like an entity
 *
 * @param string $entity_guid guid of object to like
 *
 * @return bool
 */
function likes_add($entity_guid)
{
    if (elgg_annotation_exists($entity_guid, 'likes')) {
        return elgg_echo("likes:alreadyliked");
    }
    // Let's see if we can get an entity with the specified GUID
    $entity = get_entity($entity_guid);
    if (!$entity) {
        return elgg_echo("likes:notfound");
    }
    // limit likes through a plugin hook (to prevent liking your own content for example)
    if (!$entity->canAnnotate(0, 'likes')) {
        return elgg_echo("likes:notallowed");
    }
    $user = elgg_get_logged_in_user_entity();
    $annotation = create_annotation($entity->guid, 'likes', "likes", "", $user->guid, $entity->access_id);
    // tell user annotation didn't work if that is the case
    if (!$annotation) {
        return elgg_echo("likes:failure");
    }
    elgg_create_river_item('annotation/annotatelike', 'likes', $user->guid, $entity->guid, "", 0, $annotation);
    return elgg_echo("likes:likes");
}
开发者ID:manlui,项目名称:elgg_with_rest_api,代码行数:30,代码来源:likes.php

示例11: update_last_view_time

/**
 * Update the last view time for this entity to the current time
 * 
 * @param $entity_guid
 * @param $user_guid
 */
function update_last_view_time($entity_guid, $user_guid)
{
    $entity = get_entity($entity_guid);
    if (!($user = get_entity($user_guid))) {
        $user = elgg_get_logged_in_user_entity();
    }
    if ($entity && $user) {
        // Get the last view annotation that has the last view time saved
        $options = array('types' => array($entity->type), 'guids' => array($entity_guid), 'annotation_owner_guids' => array($user->guid), 'annotation_names' => array('last_view_time'));
        if ($entity->getSubtype()) {
            $options['subtypes'] = array($entity->getSubtype());
        }
        $last_view_time = elgg_get_annotations($options);
        // It should exists only one annotation that has the last view time
        $last_view_time = $last_view_time[0];
        if ($last_view_time) {
            // Update the value of last view time with the current time
            return update_annotation($last_view_time->id, 'last_view_time', time(), 'integer', $user->guid, 2);
        } else {
            // Create one annotation with the current time that means the last view time
            return create_annotation($entity->guid, 'last_view_time', time(), 'integer', $user->guid, 2);
        }
    }
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:30,代码来源:views_counter.php

示例12: get_input

 * @subpackage Comments
 */
$entity_guid = (int) get_input('entity_guid');
$comment_text = get_input('generic_comment');
if (empty($comment_text)) {
    register_error(elgg_echo("generic_comment:blank"));
    forward(REFERER);
}
// Let's see if we can get an entity with the specified GUID
$entity = get_entity($entity_guid);
if (!$entity) {
    register_error(elgg_echo("generic_comment:notfound"));
    forward(REFERER);
}
$user = elgg_get_logged_in_user_entity();
$annotation = create_annotation($entity->guid, 'generic_comment', $comment_text, "", $user->guid, $entity->access_id);
// tell user annotation posted
if (!$annotation) {
    register_error(elgg_echo("generic_comment:failure"));
    forward(REFERER);
}
// notify if poster wasn't owner
if ($entity->owner_guid != $user->guid) {
    notify_user($entity->owner_guid, $user->guid, elgg_echo('generic_comment:email:subject'), elgg_echo('generic_comment:email:body', array($entity->title, $user->name, $comment_text, $entity->getURL(), $user->name, $user->getURL())));
}
// list the last comment
$options = array('guid' => $entity_guid, 'annotation_name' => 'generic_comment', 'pagination' => false, 'reverse_order_by' => true, 'limit' => 1);
echo elgg_list_annotations($options);
system_message(elgg_echo("generic_comment:posted"));
if ($entity->getSubtype() !== 'videolist') {
    //add to river
开发者ID:duanhv,项目名称:mdg-social,代码行数:31,代码来源:add.php

示例13: blog_post_comment2

function blog_post_comment2($guid, $text)
{
    $entity = get_entity($guid);
    $user = elgg_get_logged_in_user_entity();
    $annotation = create_annotation($entity->guid, 'generic_comment', $text, "", $user->guid, $entity->access_id);
    if ($annotation) {
        // notify if poster wasn't owner
        if ($entity->owner_guid != $user->guid) {
            notify_user($entity->owner_guid, $user->guid, elgg_echo('generic_comment:email:subject'), elgg_echo('generic_comment:email:body', array($entity->title, $user->name, $text, $user->name)));
        }
        //$return['success']['message'] = elgg_echo('generic_comment:posted');
        $return = "posted";
    } else {
        //$msg = elgg_echo('generic_comment:failure');
        //throw new InvalidParameterException($msg);
        $return = " not posted";
    }
    return $return;
}
开发者ID:elahegol,项目名称:APIPlugin,代码行数:19,代码来源:twoapp2.php

示例14: create_annotation

         $error_nouser++;
         continue;
     }
     if (!$user->canEdit()) {
         $error_canedit++;
         continue;
     }
     if ($user->guid == elgg_get_logged_in_user_guid()) {
         $error++;
         continue;
     }
     if ($user->isBanned()) {
         $banned++;
     } else {
         if ($user->ban(get_input('approval_message', 'admin decision'))) {
             create_annotation($user->guid, 'ban', get_input('approval_message', true), '', elgg_get_logged_in_user_guid(), ACCESS_PUBLIC);
             $subject = elgg_echo("db_explorer:ban:email:subject");
             if (get_input('notify_users', false)) {
                 $body = elgg_view('framework/db_explorer/notifications/ban', array('entity' => $user, 'setter' => elgg_get_logged_in_user_entity(), 'note' => get_input('notify_users_message')));
                 try {
                     elgg_send_email(elgg_get_site_entity()->email, $user->email, $subject, $body);
                 } catch (Exception $e) {
                     register_error($e->getMessage());
                 }
             }
             $success++;
         } else {
             $error++;
         }
     }
 }
开发者ID:hypejunction,项目名称:hypedbexplorer,代码行数:31,代码来源:ban.php

示例15: foreach

if (sizeof($input) > 0) {
    foreach ($input as $name => $value) {
        $markdown_wiki->{$name} = $value;
    }
}
if ($markdown_wiki->save()) {
    elgg_clear_sticky_form('markdown_wiki');
    elgg_load_library('markdown_wiki:fineDiff');
    // set diff
    $compare = new FineDiff($old_description, $markdown_wiki->description, array(FineDiff::wordDelimiters));
    $compared['word'] = calc_diff_markdown_wiki($compare->renderDiffToHTML());
    $compare = new FineDiff($old_description, $markdown_wiki->description, array(FineDiff::sentenceDelimiters));
    $compared['sentence'] = calc_diff_markdown_wiki($compare->renderDiffToHTML());
    $compare = new FineDiff($old_description, $markdown_wiki->description, array(FineDiff::paragraphDelimiters));
    $compared['paragraph'] = calc_diff_markdown_wiki($compare->renderDiffToHTML());
    $array_change = array('text' => $markdown_wiki->description, 'diff' => $compared, 'summary' => get_input('summary'));
    // Now save description as an annotation
    $annotation_id = create_annotation($markdown_wiki->guid, 'markdown_wiki', serialize($array_change), '', 0, $markdown_wiki->access_id);
    system_message(elgg_echo('markdown_wiki:saved'));
    if ($new_markdown_wiki) {
        add_to_river('river/object/markdown_wiki/create', 'create', $user_guid, $markdown_wiki->guid);
    } else {
        if (!get_input('minorchange', false)) {
            add_to_river('river/object/markdown_wiki/update', 'update', $user_guid, $markdown_wiki->guid, '', 0, $annotation_id);
        }
    }
    forward($markdown_wiki->getURL());
} else {
    register_error(elgg_echo('markdown_wiki:error:no_save'));
    forward(REFERER);
}
开发者ID:akudan,项目名称:elgg-markdown_wiki,代码行数:31,代码来源:edit.php


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