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


PHP ElggObject::annotate方法代码示例

本文整理汇总了PHP中ElggObject::annotate方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggObject::annotate方法的具体用法?PHP ElggObject::annotate怎么用?PHP ElggObject::annotate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ElggObject的用法示例。


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

示例1: testCanGetEntitiesByAnnotationCreationTime

 public function testCanGetEntitiesByAnnotationCreationTime()
 {
     $prefix = elgg_get_config('dbprefix');
     $users = elgg_get_entities(array('type' => 'user', 'limit' => 1));
     // create some test annotations
     $subtypes = $this->getRandomValidSubtypes(array('object'), 1);
     $subtype = $subtypes[0];
     $annotation_name = 'test_annotation_name_' . rand();
     // our targets
     $valid1 = new \ElggObject();
     $valid1->subtype = $subtype;
     $valid1->save();
     $id1 = $valid1->annotate($annotation_name, 1, ACCESS_PUBLIC, $users[0]->guid);
     // this one earlier
     $yesterday = time() - 86400;
     update_data("\n\t\t\tUPDATE {$prefix}annotations\n\t\t\tSET time_created = {$yesterday}\n\t\t\tWHERE id = {$id1}\n\t\t");
     $valid2 = new \ElggObject();
     $valid2->subtype = $subtype;
     $valid2->save();
     $valid2->annotate($annotation_name, 1, ACCESS_PUBLIC, $users[0]->guid);
     $options = array('annotation_owner_guid' => $users[0]->guid, 'annotation_created_time_lower' => time() - 3600, 'annotation_name' => $annotation_name);
     $entities = elgg_get_entities_from_annotations($options);
     $this->assertEqual(1, count($entities));
     $this->assertEqual($valid2->guid, $entities[0]->guid);
     $options = array('annotation_owner_guid' => $users[0]->guid, 'annotation_created_time_upper' => time() - 3600, 'annotation_name' => $annotation_name);
     $entities = elgg_get_entities_from_annotations($options);
     $this->assertEqual(1, count($entities));
     $this->assertEqual($valid1->guid, $entities[0]->guid);
     $valid1->delete();
     $valid2->delete();
 }
开发者ID:elgg,项目名称:elgg,代码行数:31,代码来源:ElggCoreGetEntitiesFromAnnotationsTest.php

示例2: hypefaker_add_page

function hypefaker_add_page($owner, $container, $parent = null)
{
    $locale = elgg_get_plugin_setting('locale', 'hypeFaker', 'en_US');
    $faker = Factory::create($locale);
    $access_array = get_write_access_array($owner->guid);
    $access_id = array_rand($access_array, 1);
    $write_access_array = get_write_access_array($owner->guid);
    unset($write_access_array[ACCESS_PUBLIC]);
    $write_access_id = array_rand($write_access_array, 1);
    $page = new ElggObject();
    $page->subtype = $parent ? 'page' : 'page_top';
    $page->owner_guid = $owner->guid;
    $page->container_guid = $container->guid;
    $page->title = $faker->sentence(6);
    $page->description = $faker->text(500);
    $page->tags = $faker->words(5);
    $page->access_id = $access_id;
    $page->write_access_id = $write_access_id;
    $page->__faker = true;
    if ($parent) {
        $page->parent_guid = $parent->guid;
    }
    if ($page->save()) {
        $page->annotate('page', $page->description, $page->access_id, $page->owner_guid);
        elgg_create_river_item(array('view' => 'river/object/page/create', 'action_type' => 'create', 'subject_guid' => $page->owner_guid, 'object_guid' => $page->getGUID()));
        // add some revisions
        $users = elgg_get_entities_from_metadata(array('types' => 'user', 'limit' => rand(1, 10), 'order_by' => 'RAND()', 'metadata_names' => '__faker'));
        foreach ($users as $user) {
            if ($page->canAnnotate($user->guid, 'page')) {
                $last_revision = $faker->text(500);
                $page->annotate('page', $last_annotation, $page->access_id, $user->guid);
            }
        }
        if (!empty($last_revision)) {
            $page->description = $last_revision;
            $page->save();
        }
        return $page;
    }
    return false;
}
开发者ID:hypejunction,项目名称:hypefaker,代码行数:41,代码来源:gen_pages.php

示例3: testElggDeleteAnnotations

 public function testElggDeleteAnnotations()
 {
     $e = new ElggObject();
     $e->save();
     for ($i = 0; $i < 30; $i++) {
         $e->annotate('test_annotation', rand(0, 10000));
     }
     $options = array('guid' => $e->getGUID(), 'limit' => 0);
     $annotations = elgg_get_annotations($options);
     $this->assertIdentical(30, count($annotations));
     $this->assertTrue(elgg_delete_annotations($options));
     $annotations = elgg_get_annotations($options);
     $this->assertTrue(empty($annotations));
     $this->assertTrue($e->delete());
 }
开发者ID:duanhv,项目名称:mdg-social,代码行数:15,代码来源:annotations.php

示例4: testElggEntityGetAndSetAnnotations

 public function testElggEntityGetAndSetAnnotations()
 {
     $this->assertIdentical($this->entity->getAnnotations(array('annotation_name' => 'non_existent')), array());
     // save entity and check for annotation
     $this->entity->annotate('non_existent', 'foo');
     $annotations = $this->entity->getAnnotations(array('annotation_name' => 'non_existent'));
     $this->assertIsA($annotations[0], '\\ElggAnnotation');
     $this->assertIdentical($annotations[0]->name, 'non_existent');
     $this->assertEqual($this->entity->countAnnotations('non_existent'), 1);
     // @todo belongs in Annotations API test class
     $this->assertIdentical($annotations, elgg_get_annotations(array('guid' => $this->entity->getGUID())));
     $this->assertIdentical($annotations, elgg_get_annotations(array('guid' => $this->entity->getGUID(), 'type' => 'object')));
     $this->assertIdentical(false, elgg_get_annotations(array('guid' => $this->entity->getGUID(), 'type' => 'object', 'subtype' => 'fail')));
     //  clear annotation
     $this->assertTrue($this->entity->deleteAnnotations());
     $this->assertEqual($this->entity->countAnnotations('non_existent'), 0);
     // @todo belongs in Annotations API test class
     $this->assertIdentical(array(), elgg_get_annotations(array('guid' => $this->entity->getGUID())));
     $this->assertIdentical(array(), elgg_get_annotations(array('guid' => $this->entity->getGUID(), 'type' => 'object')));
 }
开发者ID:elgg,项目名称:elgg,代码行数:20,代码来源:ElggEntityTest.php

示例5: foreach

        if ($page_guid == $tree_page->guid) {
            $previous_parent = $page->parent_guid;
            $children = elgg_get_entities_from_metadata(array('metadata_name' => 'parent_guid', 'metadata_value' => $page->getGUID()));
            if ($children) {
                foreach ($children as $child) {
                    $child->parent_guid = $previous_parent;
                }
            }
        }
    }
    $page->parent_guid = $parent_guid;
}
if ($page->save()) {
    //check in the page becaused the user just saved it
    if ($page->deleteMetadata("checkedOut")) {
        system_message(elgg_echo('pages:checked_in'));
    } else {
        system_message('Page could not be checked in. It is still locked for editing');
    }
    elgg_clear_sticky_form('page');
    // Now save description as an annotation
    $page->annotate('page', $page->description, $page->access_id);
    system_message(elgg_echo('pages:saved'));
    if ($new_page) {
        add_to_river('river/object/page/create', 'create', elgg_get_logged_in_user_guid(), $page->guid);
    }
    forward($page->getURL());
} else {
    register_error(elgg_echo('pages:error:notsaved'));
    forward(REFERER);
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:31,代码来源:edit.php

示例6: forward

    $grouptopic->container_guid = $group_guid;
    // For now, set its access to public (we'll add an access dropdown shortly)
    $grouptopic->access_id = $access;
    // Set its title and description appropriately
    $grouptopic->title = $title;
    // Before we can set metadata, we need to save the topic
    if (!$grouptopic->save()) {
        register_error(elgg_echo("grouptopic:error"));
        forward("pg/groups/forum/{$group_guid}/");
    }
    // Now let's add tags. We can pass an array directly to the object property! Easy.
    if (is_array($tagarray)) {
        $grouptopic->tags = $tagarray;
    }
    // add metadata
    $grouptopic->status = $status;
    // the current status i.e sticky, closed, resolved, open
    // now add the topic message as an annotation
    $grouptopic->annotate('group_topic_post', $message, $access, $user);
    // add to river
    add_to_river('river/forum/topic/create', 'create', $_SESSION['user']->guid, $grouptopic->guid);
    // Success message
    system_message(elgg_echo("grouptopic:created"));
    // Forward to the group forum page
    global $CONFIG;
    $url = $CONFIG->wwwroot . "pg/groups/forum/{$group_guid}/";
    forward($url);
}
?>

开发者ID:portokallidis,项目名称:Metamorphosis-Meducator,代码行数:29,代码来源:addtopic.php

示例7: forward

            $error = elgg_echo('blog:error:cannot_save' . "{$name}={$value}");
            break;
        }
    }
}
// only try to save base entity if no errors
if (!$error) {
    if ($blog->save()) {
        // remove sticky form entries
        elgg_clear_sticky_form();
        // remove autosave draft if exists
        $blog->clearAnnotations('blog_auto_save');
        // if this was an edit, create a revision
        if (!$new_post && $revision_value) {
            // create a revision annotation
            $blog->annotate('blog_revision', $revision_value);
        }
        system_message(elgg_echo('blog:message:saved'));
        forward($success_forward_url);
    } else {
        register_error(elgg_echo('blog:error:cannot_save'));
        forward($error_forward_url);
    }
} else {
    register_error($error);
    forward($error_forward_url);
}
// forward with success or failure
if ($error) {
    register_error($error);
    forward($error_forward_url);
开发者ID:adamboardman,项目名称:Elgg,代码行数:31,代码来源:save.php

示例8: pleio_api_save_wiki

function pleio_api_save_wiki($content = "", $title = "", $wiki_id = null, $parent_id = null, $group_id = 0, $access_id = 0, $write_access_id = 0)
{
    $wiki_id = $wiki_id ? $wiki_id : null;
    $user = elgg_get_logged_in_user_entity();
    $user_id = $user !== false ? $user->guid : 0;
    if (!$content && !$wiki_id || !$user_id) {
        return new ErrorResult(elgg_echo("pages:error:no_save"));
    }
    $parent = false;
    $swordfish_group = $group_id ? pleio_api_swordfish_group($group_id) : false;
    if ($swordfish_group) {
        $group = get_entity($group_id);
        $url = pleio_api_swordfish_baseurl($group->site_guid) . "post-page";
        $swordfish_name = pleio_api_swordfish_username($user->username);
        $params = array("title" => $title, "content" => $content);
        if (!$wiki_id) {
            $params["commentAllowed"] = 1;
        }
        if ($wiki_id) {
            $params["wikiId"] = $wiki_id;
        } elseif ($parent_id) {
            $params["parentId"] = $parent_id;
        } elseif ($group_id) {
            $params["groupId"] = $swordfish_group;
        } else {
            return new ErrorResult("Selecteer minimaal een groep of bovenliggende wiki");
        }
        if ($access_id != ACCESS_PRIVATE) {
            $params["visibility"] = "internally_published";
        } else {
            $params["visibility"] = "private";
        }
        $result = pleio_api_call_swordfish_api($swordfish_name, $url, "POST", $params);
        if ($result->ok) {
            if (strpos($result->headers["CONTENT-TYPE"], "json")) {
                $response = json_decode($result->response);
                return new SaveSuccessResult(elgg_echo("pages:saved"), $response->id);
            } else {
                return new ErrorResult($result->headers["BOBO-EXCEPTION-VALUE"]);
            }
        } else {
            return new ErrorResult($result->headers["BOBO-EXCEPTION-VALUE"]);
        }
    } else {
        if ($wiki_id) {
            $wiki = get_entity($wiki_id);
        } else {
            $wiki = new ElggObject();
            $wiki->owner_guid = $user_id;
            $wiki->subtype = "page_top";
            $wiki->parent_guid = 0;
        }
        if ($group_id) {
            $wiki->container_guid = $group_id;
        }
        if ($access_id !== "") {
            $wiki->access_id = $access_id;
        }
        if ($write_access_id !== "") {
            $wiki->write_access_id = $write_access_id;
        }
        if (isset($parent_id)) {
            $parent = get_entity($parent_id);
            if ($parent) {
                $wiki->subtype = "page";
                $wiki->parent_guid = $parent_id;
                $wiki->access_id = $parent->access_id;
                $wiki->container_guid = $parent->container_guid;
                $wiki->site_guid = $parent->site_guid;
            }
        }
        if ($title) {
            $wiki->title = $title;
        }
        if ($content) {
            $wiki->description = $content;
        }
        if (!$wiki->save()) {
            return new ErrorResult(elgg_echo("pages:error:no_save"));
        }
        $wiki->annotate('page', $wiki->description, $wiki->access_id);
        if (!$wiki_id) {
            add_to_river('river/object/page/create', 'create', $user_id, $wiki->guid);
        }
        return new SaveSuccessResult(elgg_echo("pages:saved"), $wiki->guid);
    }
}
开发者ID:appstaat,项目名称:pleio_api,代码行数:87,代码来源:methods.php

示例9: testElggAnnotationExists

 public function testElggAnnotationExists()
 {
     $e = new ElggObject();
     $e->save();
     $guid = $e->getGUID();
     $this->assertFalse(elgg_annotation_exists($guid, 'test_annotation'));
     $e->annotate('test_annotation', rand(0, 10000));
     $this->assertTrue(elgg_annotation_exists($guid, 'test_annotation'));
     // this metastring should always exist but an annotation of this name should not
     $this->assertFalse(elgg_annotation_exists($guid, 'email'));
     $options = array('guid' => $guid, 'limit' => 0);
     $this->assertTrue(elgg_disable_annotations($options));
     $this->assertTrue(elgg_annotation_exists($guid, 'test_annotation'));
     $this->assertTrue($e->delete());
     $this->assertFalse(elgg_annotation_exists($guid, 'test_annotation'));
 }
开发者ID:elainenaomi,项目名称:labxp2014,代码行数:16,代码来源:annotations.php

示例10: testNewObjectLoadedFromCacheDuringSaveOperations

 /**
  * Make sure entity is loaded from cache during save operations
  * See #10612
  */
 public function testNewObjectLoadedFromCacheDuringSaveOperations()
 {
     $object = new \ElggObject();
     $object->subtype = 'elgg_entity_test_subtype';
     // Add temporary metadata, annotation and private settings
     // to extend the scope of tests and catch issues with save operations
     $object->test_metadata = 'bar';
     $object->annotate('test_annotation', 'baz');
     $object->setPrivateSetting('test_setting', 'foo');
     $metadata_called = false;
     $metadata_event_handler = function ($event, $type, $metadata) use(&$metadata_called) {
         /* @var $metadata \ElggMetadata */
         $entity = get_entity($metadata->entity_guid);
         $this->assertEqual($metadata->entity_guid, $entity->guid);
         $metadata_called = true;
     };
     $annotation_called = false;
     $annotation_event_handler = function ($event, $type, $annotation) use(&$annotation_called) {
         /* @var $metadata \ElggAnnotation */
         $entity = get_entity($annotation->entity_guid);
         $this->assertEqual($annotation->entity_guid, $entity->guid);
         $annotation_called = true;
     };
     elgg_register_event_handler('create', 'metadata', $metadata_event_handler);
     elgg_register_event_handler('create', 'annotation', $annotation_event_handler);
     $object->save();
     elgg_unregister_event_handler('create', 'metadata', $metadata_event_handler);
     elgg_unregister_event_handler('create', 'annotation', $annotation_event_handler);
     $object->delete();
     $this->assertTrue($metadata_called);
     $this->assertTrue($annotation_called);
 }
开发者ID:,项目名称:,代码行数:36,代码来源:

示例11: elseif

        if (!$blog->save()) {
            $error = elgg_echo('blog:error:cannot_save');
        }
    }
    // creat draft annotation
    if (!$error) {
        // annotations don't have a "time_updated" so
        // we have to delete everything or the times are wrong.
        // don't save if nothing changed
        if ($auto_save_annotations = $blog->getAnnotations('blog_auto_save', 1)) {
            $auto_save = $auto_save_annotations[0];
        } else {
            $auto_save == FALSE;
        }
        if (!$auto_save) {
            $annotation_id = $blog->annotate('blog_auto_save', $description);
        } elseif ($auto_save instanceof ElggAnnotation && $auto_save->value != $description) {
            $blog->clearAnnotations('blog_auto_save');
            $annotation_id = $blog->annotate('blog_auto_save', $description);
        } elseif ($auto_save instanceof ElggAnnotation && $auto_save->value == $description) {
            // this isn't an error because we have an up to date annotation.
            $annotation_id = $auto_save->id;
        }
        if (!$annotation_id) {
            $error = elgg_echo('blog:error:cannot_auto_save');
        }
    }
} else {
    $error = elgg_echo('blog:error:missing:description');
}
if ($error) {
开发者ID:adamboardman,项目名称:Elgg,代码行数:31,代码来源:auto_save_revision.php

示例12: elseif

    } else {
        if (strtotime($expiration_date) < time()) {
            $page->unpublished = true;
        }
    }
}
// save the page
if ($page->save()) {
    //check in the page becaused the user just saved it
    if ($page->deleteMetadata("checkedOut")) {
        system_message(elgg_echo('pages:checked_in'));
    } else {
        system_message('Page could not be checked in. It is still locked for editing');
    }
    elgg_clear_sticky_form("page");
    // Now save description as an annotation
    $page->annotate("page", $page->description, $page->access_id);
    system_message(elgg_echo("pages:saved"));
    if ($new_page && !$page->unpublished) {
        add_to_river("river/object/page/create", "create", $user->getGUID(), $page->getGUID());
    } elseif ($page->getOwnerGUID() != $user->getGUID()) {
        // not the owner edited the page, notify the owner
        $subject = elgg_echo("pages_tools:notify:edit:subject", array($page->title));
        $msg = elgg_echo("pages_tools:notify:edit:message", array($page->title, $user->name, $page->getURL()));
        notify_user($page->getOwnerGUID(), $user->getGUID(), $subject, $msg);
    }
    forward($page->getURL());
} else {
    register_error(elgg_echo("pages:error:no_save"));
    forward(REFERER);
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:31,代码来源:edit.php

示例13: foreach

if (sizeof($input) > 0) {
    foreach ($input as $name => $value) {
        $task->{$name} = $value;
    }
}
$list_guid = $input['list_guid'];
if ($list_guid) {
    $task->list_guid = $list_guid;
} else {
    $task->list_guid = 0;
}
$task->container_guid = $container_guid;
if ($task->save()) {
    elgg_clear_sticky_form('task');
    // Now save description as an annotation
    $task->annotate('task', $task->description, $task->access_id);
    system_message(elgg_echo('tasks:saved'));
    if ($new_task) {
        add_to_river('river/object/task/create', 'create', elgg_get_logged_in_user_guid(), $task->guid);
    }
    if ($new_task && $referer_guid && ($referer_entity = get_entity($referer_guid))) {
        $link = elgg_view('output/url', array('href' => $task->getURL(), 'text' => $task->title));
        $annotation = create_annotation($referer_entity->guid, 'generic_comment', elgg_echo('tasks:this:referer:comment', array($link)), "", elgg_get_logged_in_user_guid(), $referer_entity->access_id);
    }
    $task_json = array();
    foreach ($task->getExportableValues() as $v) {
        $task_json[$v] = $task->{$v};
    }
    $task_json['list_guid'] = $task->list_guid;
    echo json_encode($task_json);
    forward($task->getURL());
开发者ID:lorea,项目名称:Hydra-dev,代码行数:31,代码来源:edit.php

示例14: mediawiki_set_personal_watch

/**
 * Add a personal watch for a user
 * 
 * @param ElggObject $watch The watch entity
 * @param int $user_guid Should be the group owner
 * 
 */
function mediawiki_set_personal_watch($watch, $user_guid)
{
    $watch->annotate('personal', 'yes', ACCESS_PUBLIC, $user_guid);
}
开发者ID:surevine-elgg,项目名称:mediawiki,代码行数:11,代码来源:model.php


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