本文整理汇总了PHP中ElggObject::getURL方法的典型用法代码示例。如果您正苦于以下问题:PHP ElggObject::getURL方法的具体用法?PHP ElggObject::getURL怎么用?PHP ElggObject::getURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ElggObject
的用法示例。
在下文中一共展示了ElggObject::getURL方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tgswire_save_post
/**
* Create a new wire post, the TGS way
*
* @param string $text The post text
* @param int $userid The user's guid
* @param int $access_id Public/private etc
* @param int $parent_guid Parent post guid (if any)
* @param string $method The method (default: 'site')
* @param int $container_guid Container guid (for group wire posts)
* @return guid or false if failure
*/
function tgswire_save_post($text, $userid, $access_id, $parent_guid = 0, $method = "site", $container_guid = NULL)
{
$post = new ElggObject();
$post->subtype = "thewire";
$post->owner_guid = $userid;
$post->access_id = $access_id;
// Check if we're removing the limit
if (elgg_get_plugin_setting('limit_wire_chars', 'wire-extender') == 'yes') {
// only 200 characters allowed
$text = elgg_substr($text, 0, 200);
}
// If supplied with a container_guid, use it
if ($container_guid) {
$post->container_guid = $container_guid;
}
// no html tags allowed so we escape
$post->description = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
$post->method = $method;
//method: site, email, api, ...
$tags = thewire_get_hashtags($text);
if ($tags) {
$post->tags = $tags;
}
// must do this before saving so notifications pick up that this is a reply
if ($parent_guid) {
$post->reply = true;
}
$guid = $post->save();
// set thread guid
if ($parent_guid) {
$post->addRelationship($parent_guid, 'parent');
// name conversation threads by guid of first post (works even if first post deleted)
$parent_post = get_entity($parent_guid);
$post->wire_thread = $parent_post->wire_thread;
} else {
// first post in this thread
$post->wire_thread = $guid;
}
if ($guid) {
add_to_river('river/object/thewire/create', 'create', $post->owner_guid, $post->guid);
// let other plugins know we are setting a user status
$params = array('entity' => $post, 'user' => $post->getOwnerEntity(), 'message' => $post->description, 'url' => $post->getURL(), 'origin' => 'thewire');
elgg_trigger_plugin_hook('status', 'user', $params);
}
return $guid;
}
示例2: hypefaker_add_wire
function hypefaker_add_wire($owner, $parent = null)
{
$locale = elgg_get_plugin_setting('locale', 'hypeFaker', 'en_US');
$faker = Factory::create($locale);
$wire = new ElggObject();
$wire->subtype = 'thewire';
$wire->owner_guid = $owner->guid;
$tags = $faker->words(5);
$text = $faker->text(80);
foreach ($tags as $tag) {
$text .= " #{$tag}";
}
if ($parent) {
$wire->reply = true;
$username = $parent->getOwnerEntity()->username;
$text = "@{$username} {$text}";
}
$limit = elgg_get_plugin_setting('limit', 'thewire');
if ($limit > 0) {
$text = elgg_substr($text, 0, $limit);
}
$wire->description = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
$wire->tags = $tags;
$wire->method = 'faker';
$wire->access_id = ACCESS_PUBLIC;
$wire->__faker = true;
if ($wire->save()) {
if ($parent) {
$wire->addRelationship($parent->guid, 'parent');
$wire->wire_thread = $parent->wire_thread;
} else {
$wire->wire_thread = $wire->guid;
}
elgg_create_river_item(array('view' => 'river/object/thewire/create', 'action_type' => 'create', 'subject_guid' => $wire->owner_guid, 'object_guid' => $wire->guid));
$params = array('entity' => $wire, 'user' => $owner, 'message' => $wire->description, 'url' => $wire->getURL(), 'origin' => 'thewire');
elgg_trigger_plugin_hook('status', 'user', $params);
return $wire;
}
return false;
}
示例3: parseEvent
/**
* @SWG\Definition(
* definition="Event",
* required={"guid","title"},
* @SWG\Property(property="guid", type="integer"),
* @SWG\Property(property="title", type="string"),
* @SWG\Property(property="description", type="string"),
* @SWG\Property(property="start_time", type="string"),
* @SWG\Property(property="end_time", type="string"),
* @SWG\Property(property="url", type="string"),
* @SWG\Property(property="icon_url", type="string"),
* @SWG\Property(property="time_created", type="string")
* )
*/
private function parseEvent(\ElggObject $event)
{
$start_time = mktime(date("H", $event->start_time), date("i", $event->start_time), 0, date("n", $event->start_day), date("j", $event->start_day), date("Y", $event->start_day));
if ($event->end_ts) {
$end_time = date('c', $event->end_ts);
} else {
$end_time = null;
}
return array('guid' => $event->guid, 'title' => html_entity_decode($event->title, ENT_QUOTES), 'description' => html_entity_decode($event->description, ENT_QUOTES), 'start_time' => date('c', $start_time), 'end_time' => $end_time, 'url' => $event->getURL(), 'icon_url' => $event->getIconURL(), 'time_created' => date('c', $event->time_created));
}
示例4: ElggObject
<?php
// only logged in users can add blog posts
gatekeeper();
// get the form input
$title = get_input('title');
$body = get_input('body');
$tags = string_to_tag_array(get_input('tags'));
// create a new blog object
$blogpost = new ElggObject();
$blogpost->title = $title;
$blogpost->description = $body;
$blogpost->subtype = "blog";
// for now make all blog posts public
$blogpost->access_id = ACCESS_PUBLIC;
// owner is logged in user
$blogpost->owner_guid = get_loggedin_userid();
// save tags as metadata
$blogpost->tags = $tags;
// save to database
$blogpost->save();
// forward user to a page that displays the post
forward($blogpost->getURL());
示例5: 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);
}
示例6: ElggObject
<?php
// only logged in users can add blog posts
gatekeeper();
// get the form input
$title = get_input('title');
$body = get_input('id');
$keyword = get_input('keyword');
// create a new search object
$search_obj = new ElggObject();
$search_obj->title = $title;
$search_obj->id = $id;
$search_obj->keyword = $keyword;
$search_obj->subtype = "mmsearch";
// for now make all blog posts public
$search_obj->access_id = ACCESS_PUBLIC;
// owner is logged in user
$search_obj->owner_guid = get_loggedin_userid();
// save to database
$search_obj->save();
// forward user to a page that displays the post
forward($search_obj->getURL());
示例7: thewire_tools_save_post
/**
* Save a wire post, overrules the default function because we need to support groups
*
* @param string $text the text of the post
* @param int $userid the owner of the post
* @param int $access_id the access level of the post
* @param int $parent_guid is this a reply on another post
* @param string $method which method was used
*
* @return bool|int the GUID of the new wire post or false
*/
function thewire_tools_save_post($text, $userid, $access_id, $parent_guid = 0, $method = "site")
{
// set correct container
$container_guid = $userid;
// check the access id
if ($access_id == ACCESS_PRIVATE) {
// private wire posts aren"t allowed
$access_id = ACCESS_LOGGED_IN;
} elseif (thewire_tools_groups_enabled()) {
// allow the saving of a wire post in a group (if enabled)
if (!in_array($access_id, array(ACCESS_FRIENDS, ACCESS_LOGGED_IN, ACCESS_PUBLIC))) {
// try to find a group with access_id
$group_options = array("type" => "group", "limit" => 1, "metadata_name_value_pairs" => array("group_acl" => $access_id));
$groups = elgg_get_entities_from_metadata($group_options);
if (!empty($groups)) {
$group = $groups[0];
if ($group->thewire_enable == "no") {
// not allowed to post in this group
register_error(elgg_echo("thewire_tools:groups:error:not_enabled"));
// let creation of object fail
return false;
} else {
$container_guid = $group->getGUID();
}
}
}
}
// create the new post
$post = new ElggObject();
$post->subtype = "thewire";
$post->owner_guid = $userid;
$post->container_guid = $container_guid;
$post->access_id = $access_id;
// only xxx characters allowed (see plugin setting)
$text = elgg_substr($text, 0, thewire_tools_get_wire_length());
// no html tags allowed so we escape
$post->description = htmlspecialchars($text, ENT_NOQUOTES, "UTF-8");
$post->method = $method;
//method: site, email, api, ...
$tags = thewire_get_hashtags($text);
if (!empty($tags)) {
$post->tags = $tags;
}
// must do this before saving so notifications pick up that this is a reply
if ($parent_guid) {
$post->reply = true;
}
$guid = $post->save();
// set thread guid
if ($parent_guid) {
$post->addRelationship($parent_guid, "parent");
// name conversation threads by guid of first post (works even if first post deleted)
$parent_post = get_entity($parent_guid);
$post->wire_thread = $parent_post->wire_thread;
} else {
// first post in this thread
$post->wire_thread = $guid;
}
if ($guid) {
add_to_river("river/object/thewire/create", "create", $post->getOwnerGUID(), $post->getGUID());
// let other plugins know we are setting a user status
$params = array("entity" => $post, "user" => $post->getOwnerEntity(), "message" => $post->description, "url" => $post->getURL(), "origin" => "thewire");
elgg_trigger_plugin_hook("status", "user", $params);
}
return $guid;
}
示例8: thewire_save_post
/**
* Create a new wire post.
*
* @param string $text The post text
* @param int $userid The user's guid
* @param int $access_id Public/private etc
* @param int $parent_guid Parent post guid (if any)
* @param string $method The method (default: 'site')
* @return guid or false if failure
*/
function thewire_save_post($text, $userid, $access_id, $parent_guid = 0, $method = "site")
{
$post = new ElggObject();
$post->subtype = "thewire";
$post->owner_guid = $userid;
$post->access_id = $access_id;
// Character limit is now from config
$limit = elgg_get_plugin_setting('limit', 'thewire');
if ($limit > 0) {
$text = elgg_substr($text, 0, $limit);
}
// no html tags allowed so we escape
$post->description = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
$post->method = $method;
//method: site, email, api, ...
$tags = thewire_get_hashtags($text);
if ($tags) {
$post->tags = $tags;
}
// must do this before saving so notifications pick up that this is a reply
if ($parent_guid) {
$post->reply = true;
}
$guid = $post->save();
// set thread guid
if ($parent_guid) {
$post->addRelationship($parent_guid, 'parent');
// name conversation threads by guid of first post (works even if first post deleted)
$parent_post = get_entity($parent_guid);
$post->wire_thread = $parent_post->wire_thread;
} else {
// first post in this thread
$post->wire_thread = $guid;
}
if ($guid) {
elgg_create_river_item(array('view' => 'river/object/thewire/create', 'action_type' => 'create', 'subject_guid' => $post->owner_guid, 'object_guid' => $post->guid));
// let other plugins know we are setting a user status
$params = array('entity' => $post, 'user' => $post->getOwnerEntity(), 'message' => $post->description, 'url' => $post->getURL(), 'origin' => 'thewire');
elgg_trigger_plugin_hook('status', 'user', $params);
}
return $guid;
}
示例9: golfscore_post
function golfscore_post($user, $score, $golf_course)
{
$body = elgg_view('output/url', array('href' => "profile/{$user->username}", 'text' => $user->name, 'is_trusted' => true));
$body .= ' shot an ';
$body .= elgg_view('output/url', array('href' => "golfscore/view?golf_score_id={$score->golf_score_id}", 'text' => $score->total_score, 'is_trusted' => true));
$body .= " at ";
$body .= elgg_view('output/url', array('href' => "golfscore/all?golf_course_id={$golf_course->golf_course_id}", 'text' => $golf_course->course_name, 'is_trusted' => true));
$body .= " Course";
$access_id = ACCESS_PUBLIC;
$method = 'site';
$post = new ElggObject();
$post->subtype = "thewire";
$post->owner_guid = $user->guid;
$post->access_id = $access_id;
// only 200 characters allowed
// $text = elgg_substr($body, 0, 200);
$text = $body;
// no html tags allowed so we escape
$post->description = $text;
//htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
$post->method = $method;
//method: site, email, api, ...
$tags = thewire_get_hashtags($text);
if ($tags) {
$post->tags = $tags;
}
$guid = $post->save();
// first post in this thread
$post->wire_thread = $guid;
if ($guid) {
add_to_river('river/object/thewire/create', 'create', $post->owner_guid, $post->guid);
// let other plugins know we are setting a user status
$params = array('entity' => $post, 'user' => $post->getOwnerEntity(), 'message' => $post->description, 'url' => $post->getURL(), 'origin' => 'thewire');
elgg_trigger_plugin_hook('status', 'user', $params);
}
//elgg_trigger_plugin_hook('thewire','post', array('body' => $body), false);
}
示例10: ElggObject
$reply = get_entity($guid);
$original_topic = $reply->getContainerEntity();
$user_guid = $reply->getOwnerGUID();
$group_guid = $original_topic->getContainerGUID();
$grouptopic = new ElggObject();
$grouptopic->subtype = "discussion";
$grouptopic->owner_guid = $user_guid;
$grouptopic->container_guid = $group_guid;
$grouptopic->access_id = $original_topic->access_id;
$grouptopic->title = $title;
$grouptopic->description = $reply->description;
$grouptopic->status = 'open';
if (!$grouptopic->save()) {
register_error(elgg_echo('discussion:error:notsaved'));
forward(REFERER);
}
elgg_delete_river(array('object_guid' => $reply->guid));
elgg_create_river_item(array('view' => 'river/object/discussion/create', 'action_type' => 'create', 'subject_guid' => $user_guid, 'object_guid' => $grouptopic->guid, 'posted' => $reply->time_created));
// Replace the original content with a note and add a link that takes to the new topic
$link = elgg_view('output/url', array('href' => $grouptopic->getURL(), 'text' => elgg_echo('cg:form:offtopic:warning:link')));
$warning_text = elgg_echo('cg:form:offtopic:warning');
$reply->description = "[{$warning_text} {$link}]";
$reply->save();
$user = get_user($user_guid);
$site = elgg_get_site_entity();
$subject = elgg_echo('cg:forum:offtopic:notify:title', array(), $user->language);
$message = elgg_echo('cg:forum:offtopic:notify:body', array($user->name, $site->name, elgg_get_excerpt($grouptopic->description, 80), $grouptopic->getURL()), $user->language);
// Let the user know that the comment was moved
notify_user($user_guid, $site->guid, $subject, $message, array('action' => 'move', 'object' => $grouptopic));
system_message(elgg_echo('cg:forum:offtopic:success'));
forward($grouptopic->getURL());
示例11: foreach
// don't change access if not an owner/admin
$user = elgg_get_logged_in_user_entity();
foreach ($input as $name => $value) {
$publication->{$name} = $value;
}
}
// need to add check to make sure user can write to container
$publication->container_guid = $container_guid;
if ($publication->save()) {
if (($icon_file = get_resized_image_from_uploaded_file("image", 100, 100)) && ($icon_sizes = elgg_get_config("icon_sizes"))) {
// create icon
$prefix = "publications/" . $publication->getGUID();
$fh = new ElggFile();
$fh->owner_guid = $publication->getOwnerGUID();
foreach ($icon_sizes as $icon_name => $icon_info) {
if ($icon_file = get_resized_image_from_uploaded_file("image", $icon_info["w"], $icon_info["h"], $icon_info["square"], $icon_info["upscale"])) {
$fh->setFilename($prefix . $icon_name . ".jpg");
if ($fh->open("write")) {
$fh->write($icon_file);
$fh->close();
}
}
}
$publication->icontime = time();
}
system_message(elgg_echo('publications:saved'));
forward($publication->getURL());
} else {
register_error(elgg_echo('publications:error:notsaved'));
forward(REFERER);
}
示例12: foreach
if ($parent_guid) {
$task->subtype = 'task';
} else {
$task->subtype = 'task_top';
}
$new_task = true;
}
if (sizeof($input) > 0) {
foreach ($input as $name => $value) {
$task->{$name} = $value;
echo $name . ',';
}
}
// need to add check to make sure user can write to container
$task->container_guid = $container_guid;
if ($parent_guid) {
$task->parent_guid = $parent_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);
}
forward($task->getURL());
} else {
register_error(elgg_echo('tasks:notsaved'));
forward(REFERER);
}
示例13: thewire_tools_save_post
/**
* Save a wire post, overrules the default function because we need to support groups
*
* @param string $text the text of the post
* @param int $userid the owner of the post
* @param int $access_id the access level of the post
* @param int $parent_guid is this a reply on another post
* @param string $method which method was used
* @param int $reshare_guid is the a (re)share of some content item
*
* @return bool|int the GUID of the new wire post or false
*/
function thewire_tools_save_post($text, $userid, $access_id, $parent_guid = 0, $method = "site", $reshare_guid = 0)
{
// set correct container
$container_guid = $userid;
// check the access id
if ($access_id == ACCESS_PRIVATE) {
// private wire posts aren't allowed
$access_id = ACCESS_LOGGED_IN;
} elseif (thewire_tools_groups_enabled()) {
// allow the saving of a wire post in a group (if enabled)
if (!in_array($access_id, [ACCESS_FRIENDS, ACCESS_LOGGED_IN, ACCESS_PUBLIC])) {
// try to find a group with access_id
$group_options = ['type' => 'group', 'limit' => 1, 'metadata_name_value_pairs' => ['group_acl' => $access_id]];
$groups = elgg_get_entities_from_metadata($group_options);
if (!empty($groups)) {
$group = $groups[0];
if ($group->thewire_enable == 'no') {
// not allowed to post in this group
register_error(elgg_echo('thewire_tools:groups:error:not_enabled'));
// let creation of object fail
return false;
} else {
$container_guid = $group->getGUID();
}
}
}
}
// create the new post
$post = new ElggObject();
$post->subtype = 'thewire';
$post->owner_guid = $userid;
$post->container_guid = $container_guid;
$post->access_id = $access_id;
// only xxx characters allowed (see plugin setting of thewire, 0 is unlimited)
$max_length = thewire_tools_get_wire_length();
if ($max_length) {
$text = elgg_substr($text, 0, $max_length);
}
// no html tags allowed so we escape
$post->description = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
$post->method = $method;
//method: site, email, api, ...
$tags = thewire_get_hashtags($text);
if (!empty($tags)) {
$post->tags = $tags;
}
// must do this before saving so notifications pick up that this is a reply
if ($parent_guid) {
$post->reply = true;
}
$guid = $post->save();
if ($guid) {
// set thread guid
if ($parent_guid) {
$post->addRelationship($parent_guid, 'parent');
// name conversation threads by guid of first post (works even if first post deleted)
$parent_post = get_entity($parent_guid);
$post->wire_thread = $parent_post->wire_thread;
} else {
// first post in this thread
$post->wire_thread = $guid;
}
// add reshare
if ($reshare_guid) {
$post->addRelationship($reshare_guid, 'reshare');
}
// add to river
elgg_create_river_item(['view' => 'river/object/thewire/create', 'action_type' => 'create', 'subject_guid' => $post->getOwnerGUID(), 'object_guid' => $post->getGUID()]);
// let other plugins know we are setting a user status
$params = ['entity' => $post, 'user' => $post->getOwnerEntity(), 'message' => $post->description, 'url' => $post->getURL(), 'origin' => 'thewire'];
elgg_trigger_plugin_hook('status', 'user', $params);
}
return $guid;
}
示例14: parseObject
/**
* @SWG\Definition(
* definition="FileFolder",
* required={"guid","subtype","title"},
* @SWG\Property(property="guid", type="integer"),
* @SWG\Property(property="subtype", type="string", enum={"file", "folder"}),
* @SWG\Property(property="title", type="string"),
* @SWG\Property(property="time_created", type="string")
* )
*/
private function parseObject(\ElggObject $object)
{
$subtype = $object->getSubtype();
$data = array('guid' => $object->guid, 'subtype' => $subtype, 'title' => html_entity_decode($object->title, ENT_QUOTES), 'time_created' => date('c', $object->time_created));
if ($subtype == "file") {
$data['url'] = elgg_normalize_url('file/download/' . $object->guid);
} else {
$data['url'] = $object->getURL();
}
return $data;
}
示例15: ElggObject
<?php
// only logged in users can add blog posts
gatekeeper();
// get the form input
$title = get_input('title');
$body = get_input('body');
$tags = string_to_tag_array(get_input('tags'));
$container_guid = get_input('container');
// create a new blog object
$groupfeed = new ElggObject();
$groupfeed->title = $title;
$groupfeed->description = $body;
$groupfeed->subtype = "groupfeed";
// for now make all blog posts public
$groupfeed->access_id = ACCESS_PUBLIC;
// owner is logged in user
$groupfeed->owner_guid = get_loggedin_userid();
// save tags as metadata
$groupfeed->tags = $tags;
// adds to group
$groupfeed->container_guid = $container_guid;
// save to database
$groupfeed->save();
// forward user to a page that displays the post
forward($groupfeed->getURL());