本文整理汇总了PHP中elgg_http_add_url_query_elements函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_http_add_url_query_elements函数的具体用法?PHP elgg_http_add_url_query_elements怎么用?PHP elgg_http_add_url_query_elements使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_http_add_url_query_elements函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testElggHttpAddURLQueryElementsRemoveElements
/**
* Test elgg_http_add_url_query_elements() removal of parameters
*
* @dataProvider providerElggHttpAddURLQueryElementsRemoveElements
*/
public function testElggHttpAddURLQueryElementsRemoveElements($input, $params, $output)
{
$this->assertEquals($output, elgg_http_add_url_query_elements($input, $params));
if ($params === array('foo' => null)) {
$this->assertEquals($output, elgg_http_remove_url_query_element($input, 'foo'));
}
}
示例2: group_tools_groupicon_page_handler
/**
* Take over the groupicon page handler for fallback
*
* @param array $page the url elements
*
* @return void
*/
function group_tools_groupicon_page_handler($page)
{
// group guid
if (!isset($page[0])) {
header("HTTP/1.1 400 Bad Request");
exit;
}
$group_guid = $page[0];
$group = get_entity($group_guid);
if (empty($group) || !elgg_instanceof($group, "group")) {
header("HTTP/1.1 400 Bad Request");
exit;
}
$owner_guid = $group->getOwnerGUID();
$icontime = (int) $group->icontime;
if (empty($icontime)) {
header("HTTP/1.1 404 Not Found");
exit;
}
// size
$size = "medium";
if (isset($page[1])) {
$icon_sizes = elgg_get_config("icon_sizes");
if (!empty($icon_sizes) && array_key_exists($page[1], $icon_sizes)) {
$size = $page[1];
}
}
$params = array("group_guid" => $group_guid, "guid" => $owner_guid, "size" => $size, "icontime" => $icontime);
$url = elgg_http_add_url_query_elements("mod/group_tools/pages/groups/thumbnail.php", $params);
forward($url);
}
示例3: prepare
/**
* Prepares notification elements
* @return \stdClass
*/
public function prepare()
{
$object_type = $this->getObjectType();
$object_link = elgg_view('output/url', array('text' => $this->object->getDisplayName(), 'href' => elgg_http_add_url_query_elements($this->object->getURL(), array('active_tab' => 'comments'))));
if ($this->author->guid == $this->object->owner_guid) {
$object_summary_title = elgg_echo('interactions:ownership:own', array($object_type), $this->language);
} else {
if ($this->recipient->guid == $this->object->owner_guid) {
$object_summary_title = elgg_echo('interactions:ownership:your', array($object_type), $this->language);
} else {
$object_owner = $this->object->getOwnerEntity() ?: elgg_get_site_entity();
$object_summary_title = elgg_echo('interactions:ownership:owner', array($object_owner->getDisplayName(), $object_type), $this->language);
}
}
if ($this->object instanceof Comment) {
$object_full_title = $object_summary_title;
} else {
$object_full_title = $object_summary_title . ' ' . $object_link;
}
if ($this->root->guid !== $this->object->guid) {
$root_link = elgg_view('output/url', array('text' => $this->root->getDisplayName(), 'href' => elgg_http_add_url_query_elements($this->root->getURL(), array('active_tab' => 'comments'))));
$object_full_title .= ' ' . elgg_echo('interactions:comment:in_thread', array($root_link));
}
$author_link = elgg_view('output/url', array('text' => $this->author->name, 'href' => $this->author->getURL()));
$object_summary_link = elgg_view('output/url', array('text' => $object_summary_title, 'href' => elgg_http_add_url_query_elements($this->object->getURL(), array('active_tab' => 'comments'))));
$action_type = $this->getActionType();
$notification = new \stdClass();
$notification->summary = elgg_echo('interactions:response:email:subject', array($author_link, $action_type, $object_summary_link), $this->language);
$notification->subject = strip_tags($notification->summary);
$notification->body = elgg_echo('interactions:response:email:body', array($author_link, $action_type, $object_full_title, $this->getComment(), $this->comment->getURL(), $this->root->getURL(), $this->author->getDisplayName(), $this->author->getURL()), $this->language);
return $notification;
}
示例4: register_event_title_menu
/**
* Register title menu items for an event
*
* @param Event $event
* @return void
*/
function register_event_title_menu($event, $ts = null, $calendar = null)
{
if (!$event instanceof Event) {
return;
}
$calendar_count = 0;
if (elgg_is_logged_in()) {
$calendar_count = Calendar::getCalendars(elgg_get_logged_in_user_entity(), true);
}
if ($calendar_count) {
// may be different than the calendar being viewed
// make the add/remove button work for the current calendar if they own it
// or their default calendar if they're viewing another calendar
if ($calendar->owner_guid == elgg_get_logged_in_user_guid()) {
$mycalendar = $calendar;
} else {
$mycalendar = Calendar::getPublicCalendar(elgg_get_logged_in_user_entity());
}
$text = elgg_echo('events:add_to_calendar:default');
$add_remove_calendar = $mycalendar->guid;
if ($mycalendar->hasEvent($event)) {
$text = elgg_echo('events:remove_from_calendar:default');
$add_remove_calendar = '';
}
elgg_register_menu_item('title', array('name' => 'add_to_calendar', 'href' => elgg_http_add_url_query_elements('action/calendar/add_event', array('event_guid' => $event->guid, 'calendars[]' => $add_remove_calendar)), 'is_action' => true, 'data-object-event' => true, 'data-guid' => $event->guid, 'text' => $text, 'data-calendar-count' => $calendar_count, 'link_class' => 'elgg-button elgg-button-action events-ui-event-action-addtocalendar', 'priority' => 100));
}
if ($event->canEdit()) {
elgg_register_menu_item('title', array('name' => 'delete', 'text' => elgg_echo('events_ui:cancel'), 'href' => 'action/events/cancel?guid=' . $event->guid . '&ts=' . $ts, 'is_action' => true, 'link_class' => 'elgg-button elgg-button-delete elgg-requires-confirmation events-ui-event-action-cancel', 'data-object-event' => true, 'data-guid' => $event->guid, 'priority' => 300));
}
if ($event->canEdit() && $event->isRecurring()) {
elgg_register_menu_item('title', array('name' => 'delete_all', 'text' => elgg_echo('events_ui:cancel:all'), 'href' => 'action/events/delete?guid=' . $event->guid, 'is_action' => true, 'link_class' => 'elgg-button elgg-button-delete elgg-requires-confirmation events-ui-event-action-cancel-all', 'rel' => elgg_echo('events_ui:cancel:all:confirm'), 'data-object-event' => true, 'data-guid' => $event->guid, 'priority' => 400));
}
}
示例5: register
/**
* Add a menu item to the user hover dropdown
*
* @param string $hook the name of the hook
* @param string $type the type of the hook
* @param \ElggMenuItem[] $return_value current menu items
* @param array $params supplied params
*
* @return void|\ElggMenuItem[]
*/
public static function register($hook, $type, $return_value, $params)
{
static $user_dirs;
if (!elgg_is_admin_logged_in()) {
return;
}
if (empty($params) || !is_array($params)) {
return;
}
$user = elgg_extract('entity', $params);
if (!$user instanceof \ElggUser) {
return;
}
if (!isset($user_dirs)) {
$user_dirs = [];
}
// save in a static for performance when viewing user listings
if (!isset($user_dirs[$user->getGUID()])) {
$user_dirs[$user->getGUID()] = false;
$edl = new \Elgg\EntityDirLocator($user->getGUID());
$path = $edl->getPath();
if (is_dir(elgg_get_data_path() . $path)) {
$path = substr($path, 0, -1);
$user_dirs[$user->getGUID()] = \ElggMenuItem::factory(['name' => 'dataroot-browser', 'text' => elgg_echo('dataroot_browser:menu:user_hover'), 'href' => elgg_http_add_url_query_elements('admin/administer_utilities/dataroot_browser', ['dir' => $path]), 'is_trusted' => true, 'section' => 'admin']);
}
}
if (empty($user_dirs[$user->getGUID()])) {
return;
}
$return_value[] = $user_dirs[$user->getGUID()];
return $return_value;
}
示例6: home_annotation_menu_setup
function home_annotation_menu_setup($hook, $type, $return, $params)
{
$annotation = $params['annotation'];
/* @var ElggAnnotation $annotation */
if ($annotation->name == 'generic_comment' && $annotation->canEdit()) {
$url = elgg_http_add_url_query_elements('action/comments/delete', array('annotation_id' => $annotation->id));
$options = array('name' => 'delete', 'href' => $url, 'text' => elgg_echo('home:delete'), 'title' => elgg_echo('home:delete'), 'confirm' => elgg_echo('deleteconfirm'), 'encode_text' => false);
$return[] = ElggMenuItem::factory($options);
}
return $return;
}
示例7: normalize
/**
* Prefixes the URL with the page handler ID and normalizes it
*
* @param mixed $url URL as string or array of segments
* @param array $query Query params to add to the URL
* @return string
*/
public function normalize($url = '', $query = array())
{
if (is_array($url)) {
$url = implode('/', $url);
}
$url = implode('/', array($this->getPageHandlerId(), $url));
if (!empty($query)) {
$url = elgg_http_add_url_query_elements($url, $query);
}
return elgg_normalize_url($url);
}
示例8: testElggHttpAddURLQueryElementsRemoveElements
/**
* Test elgg_http_add_url_query_elements() removal of parameters
*/
public function testElggHttpAddURLQueryElementsRemoveElements()
{
$tests = array(array('?foo=bar', array('foo' => ''), '?foo='), array('?foo=bar', array('foo' => 0), '?foo=0'), array('?foo=bar', array('foo' => false), '?foo=0'), array('?foo=bar', array('foo' => null), '?'), array('/?foo=bar', array('foo' => null), '/'), array('/path?foo=bar', array('foo' => null), '/path'), array('example.com', array('foo' => null), 'example.com'), array('example.com?foo=bar', array('foo' => null), 'example.com'), array('example.com/path?foo=bar', array('foo' => null), 'example.com/path'), array('http://example.com', array('foo' => null), 'http://example.com?'), array('http://example.com?foo=bar', array('foo' => null), 'http://example.com?'), array('http://example.com/?foo=bar#anchor', array('foo' => null), 'http://example.com/#anchor'), array('http://example.com/path?foo=bar', array('foo' => null), 'http://example.com/path'), array('https://example.com?foo=bar', array('foo' => null), 'https://example.com?'), array('https://example.com/path?foo=bar', array('foo' => null), 'https://example.com/path'), array('http://example-time.com?foo=bar', array('foo' => null), 'http://example-time.com?'), array('http://example-time.com/path?foo=bar', array('foo' => null), 'http://example-time.com/path'), array('ftp://example.com/?foo=bar', array('foo' => null), 'ftp://example.com/'), array('ftp://example.com/file?foo=bar', array('foo' => null), 'ftp://example.com/file'), array('app://endpoint?foo=bar', array('foo' => null), 'app://endpoint?'), array('app://endpoint/path?foo=bar', array('foo' => null), 'app://endpoint/path'), array('https://example.com?foo=123&bar=abc', array('foo' => null, 'foo2' => 'bar2'), 'https://example.com?bar=abc&foo2=bar2'), array('https://example.com/path?bar=abc&foo=123', array('foo' => null, 'foo2' => 'bar'), 'https://example.com/path?bar=abc&foo2=bar'), array('https://example.com?foo=123&bar=abc', array('foo' => null, 'foo2' => 'bar2', '123' => 456), 'https://example.com?bar=abc&foo2=bar2&123=456'), array('https://example.com/path?foo=123&bar=abc', array('foo2' => 'bar', 'foo' => null), 'https://example.com/path?bar=abc&foo2=bar'));
foreach ($tests as $test) {
list($input, $params, $output) = $test;
$this->assertEquals($output, elgg_http_add_url_query_elements($input, $params));
if ($params === array('foo' => null)) {
$this->assertEquals($output, elgg_http_remove_url_query_element($input, 'foo'));
}
}
}
示例9: parse
public function parse($url = '', array $options = array())
{
$meta = array('url' => $url);
if (!$url) {
return $meta;
}
$apikey = $this->config->get('embedly_key');
$endpoint = $this->config->get('embedly_endpoint');
$apiurl = elgg_http_add_url_query_elements($endpoint, array('key' => $apikey, 'url' => $url));
$json = $this->httpResource->read($apiurl, $options);
return $json ? @json_decode($json, true) : $meta;
}
示例10: relatedgroups_related_menu_setup
function relatedgroups_related_menu_setup($hook, $type, $return, $params)
{
$group = elgg_get_page_owner_entity();
$othergroup = $params['entity'];
if ($group instanceof ElggGroup && $group->canEdit() && $othergroup instanceof ElggGroup && elgg_in_context('relatedgroups')) {
// Delete all previous links
$return = array();
$url = elgg_http_add_url_query_elements('action/relatedgroups/remove', array('group' => $group->guid, 'othergroup' => $othergroup->guid));
$options = array('name' => 'delete', 'href' => $url, 'text' => "<span class=\"elgg-icon elgg-icon-delete\"></span>", 'confirm' => elgg_echo('deleteconfirm'), 'text_encode' => false);
$return[] = ElggMenuItem::factory($options);
}
return $return;
}
示例11: setupEntityMenu
/**
* Setup API Consumer entity menu
*
* @param string $hook "register"
* @param string $type "menu:entity"
* @param array $return Menu
* @param array $params Hook params
* @return array
*/
function setupEntityMenu($hook, $type, $return, $params)
{
$entity = elgg_extract('entity', $params);
if (!$entity instanceof Consumer) {
return;
}
if (!$entity->canEdit()) {
return;
}
$return[] = ElggMenuItem::factory(array('name' => 'keygen', 'text' => elgg_echo('graph:consumers:keygen'), 'href' => elgg_http_add_url_query_elements('action/admin/graph/consumers/keygen', array('guid' => $entity->guid)), 'is_action' => true, 'priority' => 100));
$return[] = ElggMenuItem::factory(array('name' => 'edit', 'text' => elgg_echo('edit'), 'href' => elgg_http_add_url_query_elements('admin/graph/consumers/edit', array('guid' => $entity->guid)), 'priority' => 200));
$return[] = ElggMenuItem::factory(array('name' => 'delete', 'text' => elgg_echo('delete'), 'href' => elgg_http_add_url_query_elements('action/admin/graph/consumers/delete', array('guid' => $entity->guid)), 'is_action' => true, 'data-confirm' => elgg_echo('question:areyousure'), 'priority' => 900));
return $return;
}
示例12: searchPluginProjects
/**
* Used to search for community plugins using title/description
* @param array $options
* @return array|false
*/
static function searchPluginProjects($options = array())
{
// $mt = microtime(true);
$query = elgg_extract('q', $options, '%');
if (!$query) {
$query = '%';
}
$url = self::getCommunityPageURL() . 'search';
$url = elgg_http_add_url_query_elements($url, array('q' => $query, 'category' => elgg_extract('category', $options, ''), 'sort' => elgg_extract('sort', $options, 'relevance'), 'order' => elgg_extract('order', $options, 'desc'), 'entity_type' => 'object', 'entity_subtype' => 'plugin_project', 'search_type' => 'entities', 'view' => 'rss', 'limit' => elgg_extract('limit', $options, 10), 'offset' => elgg_extract('offset', $options, 0)));
list($content, $meta) = srokap_http::getUrlWithMetadata($url);
// var_dump($url);
// var_dump(microtime(true) - $mt);
return self::handlePluginProjectsRssResult($content);
}
示例13: elgg_file_viewer_get_public_url
/**
* Get publicly accessible URL for the file
*
* @param ElggFile $file
* @return string
*/
function elgg_file_viewer_get_public_url($file)
{
if (!elgg_instanceof($file, 'object', 'file')) {
return '';
}
if (!elgg_is_logged_in()) {
return $file->getURL();
}
$user = elgg_get_logged_in_user_entity();
$token = create_user_token($user->username);
$base_url = elgg_normalize_url("services/api/rest/ob");
$params = array('method' => 'efv.download', 'guid' => $file->getGUID(), 'auth_token' => $token);
return elgg_http_add_url_query_elements($base_url, $params);
}
示例14: reportedcontent_user_hover_menu
/**
* Add report user link to hover menu
*/
function reportedcontent_user_hover_menu($hook, $type, $return, $params)
{
if (!elgg_is_logged_in()) {
return;
}
$user = elgg_extract('entity', $params);
/* @var ElggUser $user */
if (elgg_get_logged_in_user_guid() == $user->guid) {
return;
}
$href = elgg_http_add_url_query_elements('reportedcontent/add', ['address' => $user->getURL(), 'title' => $user->name]);
$return[] = \ElggMenuItem::factory(['name' => 'reportuser', 'text' => elgg_echo('reportedcontent:user'), 'href' => $href, 'section' => 'action', 'link_class' => 'elgg-lightbox', 'deps' => 'elgg/reportedcontent']);
return $return;
}
示例15: legacy_urls_prepare_url
/**
* Adds query parameters to URL for redirect
*
* @param string $url The URL
* @param array $query_vars Additional query parameters in associate array
* @return string
*/
function legacy_urls_prepare_url($url, array $query_vars = array())
{
$params = array();
// Elgg munges the request in htaccess rules so cannot use $_GET
$query = parse_url(_elgg_services()->request->server->get('REQUEST_URI'), PHP_URL_QUERY);
if ($query) {
parse_str($query, $params);
}
$params = array_merge($params, $query_vars);
if ($params) {
return elgg_http_add_url_query_elements($url, $params);
} else {
return $url;
}
}