本文整理汇总了PHP中elgg_normalize_url函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_normalize_url函数的具体用法?PHP elgg_normalize_url怎么用?PHP elgg_normalize_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_normalize_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: legacy_urls_redirect
/**
* Redirect the requestor to the new URL
* Checks the plugin setting to determine the course of action:
* a) Displays an error page with the new URL
* b) Forwards to the new URL and displays an error message
* c) Silently forwards to the new URL
*
* @param string $url Relative or absolute URL
* @return mixed
*/
function legacy_urls_redirect($url)
{
$method = elgg_get_plugin_setting('redirect_method', 'legacy_urls');
// we only show landing page or queue warning if html generating page
$viewtype = elgg_get_viewtype();
if ($viewtype != 'default' && !elgg_does_viewtype_fallback($viewtype)) {
$method = 'immediate';
}
switch ($method) {
case 'landing':
$content = elgg_view('legacy_urls/message', array('url' => $url));
$body = elgg_view_layout('error', array('content' => $content));
echo elgg_view_page('', $body, 'error');
return true;
break;
case 'immediate_error':
// drop through after setting error message
register_error(elgg_echo('changebookmark'));
case 'immediate':
default:
$url = elgg_normalize_url($url);
header("HTTP/1.1 301 Moved Permanently");
header("Location: {$url}");
exit;
break;
}
}
示例2: daily
/**
* Add menu items to the filter menu
*
* @param string $hook 'cron'
* @param string $type 'daily'
* @param string $return_value optional output
* @param array $params supplied params
*
* @return void
*/
public static function daily($hook, $type, $return_value, $params)
{
if (!static_out_of_date_enabled()) {
return;
}
$time = elgg_extract('time', $params, time());
$days = (int) elgg_get_plugin_setting('out_of_date_days', 'static');
$site = elgg_get_site_entity();
$options = ['type' => 'object', 'subtype' => \StaticPage::SUBTYPE, 'limit' => false, 'modified_time_upper' => $time - $days * 24 * 60 * 60, 'modified_time_lower' => $time - ($days + 1) * 24 * 60 * 60, 'order_by' => 'e.time_updated DESC'];
// ignore access
$ia = elgg_set_ignore_access(true);
$batch = new \ElggBatch('elgg_get_entities', $options);
$users = [];
foreach ($batch as $entity) {
$last_editors = $entity->getAnnotations(['annotation_name' => 'static_revision', 'limit' => 1, 'order_by' => 'n_table.time_created DESC']);
if (empty($last_editors)) {
continue;
}
$users[$last_editors[0]->getOwnerGUID()] = $last_editors[0]->getOwnerEntity();
}
// restore access
elgg_set_ignore_access($ia);
if (empty($users)) {
return;
}
foreach ($users as $user) {
$subject = elgg_echo('static:out_of_date:notification:subject');
$message = elgg_echo('static:out_of_date:notification:message', [$user->name, elgg_normalize_url('static/out_of_date/' . $user->username)]);
notify_user($user->getGUID(), $site->getGUID(), $subject, $message, [], 'email');
}
}
示例3: testElggNormalizeURL
/**
* Test elgg_normalize_url()
*/
public function testElggNormalizeURL()
{
$conversions = array('http://example.com' => 'http://example.com', 'https://example.com' => 'https://example.com', 'http://example-time.com' => 'http://example-time.com', '//example.com' => '//example.com', 'ftp://example.com/file' => 'ftp://example.com/file', 'mailto:brett@elgg.org' => 'mailto:brett@elgg.org', 'javascript:alert("test")' => 'javascript:alert("test")', 'app://endpoint' => 'app://endpoint', 'example.com' => 'http://example.com', 'example.com/subpage' => 'http://example.com/subpage', 'page/handler' => elgg_get_site_url() . 'page/handler', 'page/handler?p=v&p2=v2' => elgg_get_site_url() . 'page/handler?p=v&p2=v2', 'mod/plugin/file.php' => elgg_get_site_url() . 'mod/plugin/file.php', 'mod/plugin/file.php?p=v&p2=v2' => elgg_get_site_url() . 'mod/plugin/file.php?p=v&p2=v2', 'rootfile.php' => elgg_get_site_url() . 'rootfile.php', 'rootfile.php?p=v&p2=v2' => elgg_get_site_url() . 'rootfile.php?p=v&p2=v2', '/page/handler' => elgg_get_site_url() . 'page/handler', '/page/handler?p=v&p2=v2' => elgg_get_site_url() . 'page/handler?p=v&p2=v2', '/mod/plugin/file.php' => elgg_get_site_url() . 'mod/plugin/file.php', '/mod/plugin/file.php?p=v&p2=v2' => elgg_get_site_url() . 'mod/plugin/file.php?p=v&p2=v2', '/rootfile.php' => elgg_get_site_url() . 'rootfile.php', '/rootfile.php?p=v&p2=v2' => elgg_get_site_url() . 'rootfile.php?p=v&p2=v2');
foreach ($conversions as $input => $output) {
$this->assertIdentical($output, elgg_normalize_url($input));
}
}
示例4: post
/**
* {@inheritdoc}
*/
public function post(ParameterBag $params)
{
$user = elgg_get_logged_in_user_entity();
$group = get_entity($params->guid);
// join or request
$join = false;
if ($group->isPublicMembership() || $group->canEdit($user->guid)) {
// anyone can join public groups and admins can join any group
$join = true;
} else {
if (check_entity_relationship($group->guid, 'invited', $user->guid)) {
// user has invite to closed group
$join = true;
}
}
if ($join) {
if (groups_join_group($group, $user)) {
$msg = elgg_echo("groups:joined");
} else {
throw new GraphException(elgg_echo("groups:cantjoin"));
}
} else {
if (!add_entity_relationship($user->guid, 'membership_request', $group->guid)) {
throw new GraphException(elgg_echo("groups:joinrequestnotmade"));
}
$owner = $group->getOwnerEntity();
$url = elgg_normalize_url("groups/requests/{$group->guid}");
$subject = elgg_echo('groups:request:subject', array($user->name, $group->name), $owner->language);
$body = elgg_echo('groups:request:body', array($group->getOwnerEntity()->name, $user->name, $group->name, $user->getURL(), $url), $owner->language);
// Notify group owner
notify_user($owner->guid, $user->getGUID(), $subject, $body);
$msg = elgg_echo("groups:joinrequestmade");
}
return array('nodes' => array('member' => check_entity_relationship($user->guid, 'member', $group->guid), 'invited' => check_entity_relationship($group->guid, 'invited', $user->guid), 'membership_request' => check_entity_relationship($user->guid, 'membership_request', $group->guid)));
}
示例5: testElggNormalizeURL
/**
* Test elgg_normalize_url()
*/
public function testElggNormalizeURL()
{
$conversions = array('http://example.com' => 'http://example.com', 'https://example.com' => 'https://example.com', '//example.com' => '//example.com', 'example.com' => 'http://example.com', 'example.com/subpage' => 'http://example.com/subpage', 'page/handler' => elgg_get_site_url() . 'page/handler', 'page/handler?p=v&p2=v2' => elgg_get_site_url() . 'page/handler?p=v&p2=v2', 'mod/plugin/file.php' => elgg_get_site_url() . 'mod/plugin/file.php', 'mod/plugin/file.php?p=v&p2=v2' => elgg_get_site_url() . 'mod/plugin/file.php?p=v&p2=v2', 'rootfile.php' => elgg_get_site_url() . 'rootfile.php', 'rootfile.php?p=v&p2=v2' => elgg_get_site_url() . 'rootfile.php?p=v&p2=v2', '/page/handler' => elgg_get_site_url() . 'page/handler', '/page/handler?p=v&p2=v2' => elgg_get_site_url() . 'page/handler?p=v&p2=v2', '/mod/plugin/file.php' => elgg_get_site_url() . 'mod/plugin/file.php', '/mod/plugin/file.php?p=v&p2=v2' => elgg_get_site_url() . 'mod/plugin/file.php?p=v&p2=v2', '/rootfile.php' => elgg_get_site_url() . 'rootfile.php', '/rootfile.php?p=v&p2=v2' => elgg_get_site_url() . 'rootfile.php?p=v&p2=v2');
foreach ($conversions as $input => $output) {
$this->assertIdentical($output, elgg_normalize_url($input));
}
}
示例6: community_theme_setup_head
/**
* Register items for the html head
*
* @param string $hook Hook name ('head')
* @param string $type Hook type ('page')
* @param array $data Array of items for head
* @return array
*/
function community_theme_setup_head($hook, $type, $data)
{
$data['metas'][] = array('http-equiv' => 'X-UA-Compatible', 'content' => 'IE=edge');
$data['metas'][] = array('name' => 'viewport', 'content' => 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0');
$data['links'][] = array('rel' => 'icon', 'href' => elgg_normalize_url('mod/community_theme/graphics/favicon.ico'));
return $data;
}
示例7: triggerMentionNotificationEvent
/**
* This functions performs actions when a wire post is created
*
* @param string $event 'create'
* @param string $type 'object'
* @param \ElggObject $object the ElggObject created
*
* @return void
*/
public static function triggerMentionNotificationEvent($event, $type, \ElggObject $object)
{
if (!elgg_instanceof($object, 'object', 'thewire')) {
return;
}
// @todo replace with decent Elgg 2.0 notification event handling
//send out notification to users mentioned in a wire post
$usernames = [];
preg_match_all("/\\@([A-Za-z0-9\\_\\.\\-]+)/i", $object->description, $usernames);
if (empty($usernames)) {
return;
}
$usernames = array_unique($usernames[0]);
$params = ['object' => $object, 'action' => 'mention'];
foreach ($usernames as $username) {
$username = str_ireplace('@', '', $username);
$user = get_user_by_username($username);
if (empty($user) || $user->getGUID() == $object->getOwnerGUID()) {
continue;
}
$setting = thewire_tools_get_notification_settings($user->getGUID());
if (empty($setting)) {
continue;
}
$subject = elgg_echo('thewire_tools:notify:mention:subject');
$message = elgg_echo('thewire_tools:notify:mention:message', [$user->name, $object->getOwnerEntity()->name, elgg_normalize_url("thewire/search/@{$user->username}")]);
notify_user($user->getGUID(), $object->getOwnerGUID(), $subject, $message, $params, $setting);
}
}
示例8: membershipRequest
/**
* Notify the group admins about a membership request
*
* @param string $event create
* @param string $type membership_request
* @param \ElggRelationship $relationship the created membership request relation
*
* @return void
*/
public static function membershipRequest($event, $type, $relationship)
{
if (!$relationship instanceof \ElggRelationship) {
return;
}
if ($relationship->relationship !== 'membership_request') {
return;
}
// only send a message if group admins are allowed
if (!group_tools_multiple_admin_enabled()) {
return;
}
$user = get_user($relationship->guid_one);
$group = get_entity($relationship->guid_two);
if (empty($user) || !$group instanceof \ElggGroup) {
return;
}
// Notify group admins
$options = ['relationship' => 'group_admin', 'relationship_guid' => $group->getGUID(), 'inverse_relationship' => true, 'type' => 'user', 'limit' => false, 'wheres' => ["e.guid <> {$group->getOwnerGUID()}"]];
$url = elgg_normalize_url("groups/requests/{$group->getGUID()}");
$subject = elgg_echo('groups:request:subject', [$user->name, $group->name]);
$admins = new \ElggBatch('elgg_get_entities_from_relationship', $options);
foreach ($admins as $a) {
$body = elgg_echo('groups:request:body', [$a->name, $user->name, $group->name, $user->getURL(), $url]);
notify_user($a->getGUID(), $user->getGUID(), $subject, $body);
}
}
示例9: view_hook
/**
* replace any http images with https urls
*
* @param type $h
* @param type $t
* @param type $r
* @param type $p
* @return type
*/
function view_hook($h, $t, $r, $p)
{
$http_url = str_replace('https://', 'http://', elgg_get_site_url());
if (preg_match_all('/<img[^>]+src\\s*=\\s*["\']?([^"\' ]+)[^>]*>/', $r, $extracted_image)) {
foreach ($extracted_image[0] as $key => $i) {
if (strpos($extracted_image[1][$key], elgg_get_site_url()) !== false) {
continue;
// already one of our links
}
// check if this is our url being requested over http, and rewrite to https
if (strpos($extracted_image[1][$key], $http_url) === 0) {
$https_image = str_replace('http://', 'https://', $extracted_image[1][$key]);
$replacement_image = str_replace($extracted_image[1][$key], $https_image, $i);
$r = str_replace($i, $replacement_image, $r);
continue;
}
if (!is_https($extracted_image[1][$key])) {
// replace this url
$url = urlencode($extracted_image[1][$key]);
if (strpos($url, 'http') === 0) {
$token = get_token($extracted_image[1][$key]);
$new_url = elgg_normalize_url('mod/image_proxy/image.php?url=' . $url . '&token=' . $token);
$replacement_image = str_replace($extracted_image[1][$key], $new_url, $i);
$r = str_replace($i, $replacement_image, $r);
}
}
}
}
return $r;
}
示例10: handle
/**
* {@inheritdoc}
*/
protected function handle()
{
$uri = '/' . ltrim($this->argument('uri'), '/');
$method = $this->argument('method') ?: 'GET';
$add_csrf_tokens = $this->option('tokens');
$site_url = elgg_get_site_url();
$uri = substr(elgg_normalize_url($uri), strlen($site_url));
$path_key = Application::GET_PATH_KEY;
$parameters = [];
$query = trim((string) $this->option('query'), '?');
parse_str($query, $parameters);
if ($add_csrf_tokens) {
$ts = time();
$parameters['__elgg_ts'] = $ts;
$parameters['__elgg_token'] = _elgg_services()->actions->generateActionToken($ts);
}
$request = Request::create("?{$path_key}=" . urlencode($uri), $method, $parameters);
$cookie_name = _elgg_services()->config->getCookieConfig()['session']['name'];
$session_id = _elgg_services()->session->getId();
$request->cookies->set($cookie_name, $session_id);
$request->headers->set('Referer', elgg_normalize_url());
if ($this->option('export')) {
elgg_set_viewtype('json');
$request->headers->set('X-Elgg-Ajax-API', '2');
}
_elgg_services()->setValue('request', $request);
Application::index();
}
示例11: thewire_tools_create_object_event_handler
/**
* This functions performs actions when a wire post is created
*
* @param string $event 'create'
* @param string $type 'object'
* @param ElggObject $object the ElggObject created
*
* @return void
*/
function thewire_tools_create_object_event_handler($event, $type, ElggObject $object)
{
if (empty($object) || !elgg_instanceof($object, "object", "thewire")) {
return;
}
//send out notification to users mentioned in a wire post
$usernames = array();
preg_match_all("/\\@([A-Za-z0-9\\_\\.\\-]+)/i", $object->description, $usernames);
if (empty($usernames)) {
return;
}
$usernames = array_unique($usernames[0]);
$params = array("object" => $object, "action" => "mention");
foreach ($usernames as $username) {
$username = str_ireplace("@", "", $username);
$user = get_user_by_username($username);
if (empty($user) || $user->getGUID() == $object->getOwnerGUID()) {
continue;
}
$setting = thewire_tools_get_notification_settings($user->getGUID());
if (empty($setting)) {
continue;
}
$subject = elgg_echo("thewire_tools:notify:mention:subject");
$message = elgg_echo("thewire_tools:notify:mention:message", array($user->name, $object->getOwnerEntity()->name, elgg_normalize_url("thewire/search/@" . $user->username)));
notify_user($user->getGUID(), $object->getOwnerGUID(), $subject, $message, $params, $setting);
}
}
示例12: images_ui_entity_url
/**
* Image URL handler
*
* @param string $hook "entity:url"
* @param string $type "object"
* @param string $return URL
* @param array $params Hook params
* @return array
*/
function images_ui_entity_url($hook, $type, $return, $params)
{
$entity = elgg_extract('entity', $params);
if (!images()->isImage($entity)) {
return;
}
return elgg_normalize_url("/images/view/{$entity->guid}");
}
示例13: get_marker_icons_path
/**
* Get path location of marker icons
* @return string
*/
function get_marker_icons_path($url = false)
{
$path = elgg_get_plugin_setting('icons_path', PLUGIN_ID);
if (!$path) {
$path = PLUGIN_ID . '/graphics/icons/';
}
return $url ? elgg_normalize_url('mod/' . $path) : elgg_get_plugins_path() . $path;
}
示例14: category_icon_url
/**
* Update category icon URL
*
* @param string $hook Equals 'entity:icon:url'
* @param string $type Equals 'object'
* @param string $return Current icon URL
* @param array $params Additional params
* @return string Updated icon URL
*/
function category_icon_url($hook, $type, $return, $params)
{
$entity = elgg_extract('entity', $params);
$size = elgg_extract('size', $params, 'medium');
if (!elgg_instanceof($entity, 'object', HYPECATEGORIES_SUBTYPE)) {
return $return;
}
return elgg_normalize_url(PAGEHANDLER . '/icon/' . $entity->guid . '/' . $size);
}
示例15: getURL
/**
* Get url
*
* @see ElggEntity::getURL()
* @return string
*/
public function getURL()
{
$friendly_title = $this->friendly_title;
if (!empty($friendly_title)) {
return elgg_normalize_url("wizard/{$this->friendly_title}");
}
// something went wrong, use fallback url
$friendly_title = elgg_get_friendly_title($this->title);
return elgg_normalize_url("wizard/view/{$this->getGUID()}/{$friendly_title}");
}