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


PHP current_page_url函数代码示例

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


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

示例1: rijkshuisstijl_site_menu_prepare

function rijkshuisstijl_site_menu_prepare($hook, $type, $value, $params)
{
    $selected = false;
    foreach ($value as $section) {
        foreach ($section as $item) {
            if ($item->getSelected()) {
                $selected = true;
                break 2;
            }
        }
    }
    if (!$selected) {
        $current_url = current_page_url();
        $site_url = elgg_get_site_url();
        foreach ($value as $section_name => $section) {
            foreach ($section as $key => $item) {
                // do not highlight external links
                if (strpos($item->getHref(), $site_url) !== 0) {
                    continue;
                }
                // do not highlight links to main site URL
                if ($item->getHref() == $site_url) {
                    continue;
                }
                if (strpos($current_url, $item->getHref()) === 0) {
                    $value[$section_name][$key]->setSelected(true);
                    break 2;
                }
            }
        }
    }
    return $return;
}
开发者ID:pleio,项目名称:rijkshuisstijl,代码行数:33,代码来源:hooks.php

示例2: crud_page_handler

/**
 * CRUD page handler
 *
 * URLs take the form of
 *  List crud objects in group:   <crud_type>/owner/<guid>
 *  View crud object:             <crud_type>/view/<guid>
 *  Add crud object:              <crud_type>/add/<guid>
 *  Edit crud object:             <crud_type>/edit/<guid>
 *
 * @param array $page Array of url segments for routing
 * @return bool
 */
function crud_page_handler($page)
{
    elgg_load_library('elgg:crud');
    if (!isset($page[0])) {
        $page[0] = 'all';
    }
    $page_url = current_page_url();
    $site_url = elgg_get_site_url();
    $current_url = str_replace($site_url, "", $page_url);
    $crud_type = current(explode('/', $current_url));
    $crud_handler = crud_get_handler($crud_type);
    $crud_module = $crud_handler->module;
    elgg_push_breadcrumb(elgg_echo($crud_module), '');
    switch ($page[0]) {
        case 'owner':
        case 'group':
            crud_handle_list_page($crud_handler, $page[1]);
            break;
        case 'add':
            crud_handle_edit_page($crud_handler, 'add', $page[1]);
            break;
        case 'edit':
            crud_handle_edit_page($crud_handler, 'edit', $page[1]);
            break;
        case 'view':
            crud_handle_view_page($crud_handler, $page[1]);
            break;
        case 'edit_general':
            crud_handle_edit_page($crud_handler, 'edit_general', $page[1]);
            break;
        default:
            return false;
    }
    return true;
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:47,代码来源:start.php

示例3: router

/**
 * hook called on route, all
 * check if $returnvalue['handler'] to see if we need to replace it
 * if the handler is an original handler, we want to foward it to the new url
 * 
 * @param type $hook
 * @param type $type
 * @param type $returnvalue
 * @param type $params
 * @return array
 */
function router($hook, $type, $returnvalue, $params)
{
    if (elgg_get_config('pagehandler_hijack')) {
        return $returnvalue;
    }
    $handlers = get_replacement_handlers();
    if (in_array($returnvalue['handler'], array_keys($handlers))) {
        // we have been given an old handler -> we should forward to the replacement
        // probably from an old link or something
        $currenturl = current_page_url();
        //get everything after the pagehandler
        $afterhandler = str_replace(elgg_get_site_url() . $returnvalue['handler'], "", $currenturl);
        $newurl = elgg_get_site_url() . $handlers[$returnvalue['handler']] . $afterhandler;
        // forward to the new url
        forward($newurl);
    }
    if (in_array($returnvalue['handler'], $handlers)) {
        // we need to do something about it
        // get the original handler
        $original = array_search($returnvalue['handler'], $handlers);
        if (!empty($original)) {
            // reset the context for non-hijack aware code
            elgg_set_context($original);
            // let the system load content for the original handler
            $returnvalue['handler'] = $original;
            $returnvalue['identifier'] = $original;
            // set a flag so we don't infinite loop ourselves in route hooks
            elgg_set_config('pagehandler_hijack', true);
            return elgg_trigger_plugin_hook('route', $original, null, $returnvalue);
        }
    }
}
开发者ID:n8b,项目名称:VMN,代码行数:43,代码来源:hooks.php

示例4: elgg_modifications_pagesetup

function elgg_modifications_pagesetup()
{
    $user = elgg_get_logged_in_user_entity();
    if (!$user) {
        return;
    }
    if (elgg_in_context("accept_terms")) {
        return;
    }
    $site = elgg_get_site_entity();
    if ($site->isPublicPage()) {
        return;
    }
    if (!empty($_SESSION["terms_accepted"])) {
        return;
    }
    if (elgg_get_plugin_setting("accept_terms", "elgg_modifications") === "no") {
        return;
    }
    $user_ts = $user->getPrivateSetting("general_terms_accepted");
    if (empty($user_ts)) {
        $_SESSION["terms_forward_from"] = current_page_url();
        forward("accept_terms");
    } else {
        // user has accepted the terms, so don't check again
        $_SESSION["terms_accepted"] = $user_ts;
    }
}
开发者ID:pleio,项目名称:elgg_modifications,代码行数:28,代码来源:start.php

示例5: au_subgroups_pagehandler

function au_subgroups_pagehandler($page)
{
    // dirty check to avoid duplicate page handlers
    // since this should only be called from the route, groups hook
    if (strpos(current_page_url(), elgg_get_site_url() . 'au_subgroups') === 0) {
        return false;
    }
    switch ($page[0]) {
        case 'add':
            set_input('au_subgroup', true);
            set_input('au_subgroup_parent_guid', $page[1]);
            elgg_set_page_owner_guid($page[1]);
            echo elgg_view('resources/au_subgroups/add');
            return true;
            break;
        case 'list':
            elgg_set_page_owner_guid($page[1]);
            echo elgg_view('resources/au_subgroups/list');
            break;
        case 'delete':
            elgg_set_page_owner_guid($page[1]);
            echo elgg_view('resources/au_subgroups/delete');
            break;
        case 'openclosed':
            set_input('filter', $page[1]);
            echo elgg_view('resources/au_subgroups/openclosed');
            return true;
            break;
    }
    return false;
}
开发者ID:hypeJunction,项目名称:au_subgroups,代码行数:31,代码来源:start.php

示例6: user_support_get_help_context

/**
 * Get the context for a page, for the help system
 *
 * @param string $url the (optional) url to get the context for
 *
 * @return bool|string
 */
function user_support_get_help_context($url = "")
{
    if (empty($url)) {
        $url = current_page_url();
    }
    if (empty($url)) {
        return false;
    }
    $path = parse_url($url, PHP_URL_PATH);
    if (empty($path)) {
        return false;
    }
    $parts = explode("/", $path);
    $page_owner = elgg_get_page_owner_entity();
    if (empty($page_owner)) {
        $page_owner = elgg_get_logged_in_user_entity();
    }
    $new_parts = array();
    foreach ($parts as $index => $part) {
        if (empty($part)) {
            continue;
        } elseif (is_numeric($part) || !empty($page_owner) && $page_owner->username == $part) {
            break;
        } else {
            $new_parts[] = $part;
        }
    }
    if (empty($new_parts)) {
        return false;
    }
    return implode("/", $new_parts);
}
开发者ID:lorea,项目名称:Hydra-dev,代码行数:39,代码来源:functions.php

示例7: deleteRequest

 /**
  * Listen to the delete of a membership request
  *
  * @param stirng            $event        the name of the event
  * @param stirng            $type         the type of the event
  * @param \ElggRelationship $relationship the relationship
  *
  * @return void
  */
 public static function deleteRequest($event, $type, $relationship)
 {
     if (!$relationship instanceof \ElggRelationship) {
         return;
     }
     if ($relationship->relationship !== 'membership_request') {
         // not a membership request
         return;
     }
     $action_pattern = '/action\\/groups\\/killrequest/i';
     if (!preg_match($action_pattern, current_page_url())) {
         // not in the action, so do nothing
         return;
     }
     $group = get_entity($relationship->guid_two);
     $user = get_user($relationship->guid_one);
     if (empty($user) || !$group instanceof \ElggGroup) {
         return;
     }
     if ($user->getGUID() === elgg_get_logged_in_user_guid()) {
         // user kills own request
         return;
     }
     $reason = get_input('reason');
     if (empty($reason)) {
         $body = elgg_echo('group_tools:notify:membership:declined:message', [$user->name, $group->name, $group->getURL()]);
     } else {
         $body = elgg_echo('group_tools:notify:membership:declined:message:reason', [$user->name, $group->name, $reason, $group->getURL()]);
     }
     $subject = elgg_echo('group_tools:notify:membership:declined:subject', [$group->name]);
     $params = ['object' => $group, 'action' => 'delete'];
     notify_user($user->getGUID(), $group->getGUID(), $subject, $body, $params);
 }
开发者ID:coldtrick,项目名称:group_tools,代码行数:42,代码来源:Membership.php

示例8: bookmarks_init

/**
 * Bookmark init
 */
function bookmarks_init()
{
    $root = dirname(__FILE__);
    elgg_register_library('elgg:bookmarks', "{$root}/lib/bookmarks.php");
    // actions
    $action_path = "{$root}/actions/bookmarks";
    elgg_register_action('bookmarks/save', "{$action_path}/save.php");
    elgg_register_action('bookmarks/delete', "{$action_path}/delete.php");
    elgg_register_action('bookmarks/share', "{$action_path}/share.php");
    // menus
    elgg_register_menu_item('site', array('name' => 'bookmarks', 'text' => elgg_echo('bookmarks'), 'href' => 'bookmarks/all'));
    elgg_register_plugin_hook_handler('register', 'menu:page', 'bookmarks_page_menu');
    elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'bookmarks_owner_block_menu');
    elgg_register_page_handler('bookmarks', 'bookmarks_page_handler');
    elgg_extend_view('css/elgg', 'bookmarks/css');
    elgg_extend_view('js/elgg', 'bookmarks/js');
    elgg_register_widget_type('bookmarks', elgg_echo('bookmarks'), elgg_echo('bookmarks:widget:description'));
    if (elgg_is_logged_in()) {
        $user_guid = elgg_get_logged_in_user_guid();
        $address = urlencode(current_page_url());
        elgg_register_menu_item('extras', array('name' => 'bookmark', 'text' => elgg_view_icon('push-pin-alt'), 'href' => "bookmarks/add/{$user_guid}?address={$address}", 'title' => elgg_echo('bookmarks:this'), 'rel' => 'nofollow'));
    }
    // Register granular notification for this type
    register_notification_object('object', 'bookmarks', elgg_echo('bookmarks:new'));
    // Listen to notification events and supply a more useful message
    elgg_register_plugin_hook_handler('notify:entity:message', 'object', 'bookmarks_notify_message');
    // Register a URL handler for bookmarks
    elgg_register_entity_url_handler('object', 'bookmarks', 'bookmark_url');
    // Register entity type for search
    elgg_register_entity_type('object', 'bookmarks');
    // Groups
    add_group_tool_option('bookmarks', elgg_echo('bookmarks:enablebookmarks'), true);
    elgg_extend_view('groups/tool_latest', 'bookmarks/group_module');
}
开发者ID:redvabel,项目名称:Vabelgg,代码行数:37,代码来源:start.php

示例9: blog_get_page_content_read

/**
 * Get page components to view a blog post.
 *
 * @param int $guid GUID of a blog entity.
 * @return array
 */
function blog_get_page_content_read($guid = NULL)
{
    $return = array();
    $blog = get_entity($guid);
    // no header or tabs for viewing an individual blog
    $return['filter'] = '';
    if (!elgg_instanceof($blog, 'object', 'blog')) {
        register_error(elgg_echo('noaccess'));
        $_SESSION['last_forward_from'] = current_page_url();
        forward('');
    }
    $return['title'] = $blog->title;
    $container = $blog->getContainerEntity();
    $crumbs_title = $container->name;
    if (elgg_instanceof($container, 'group')) {
        elgg_push_breadcrumb($crumbs_title, "blog/group/{$container->guid}/all");
    } else {
        elgg_push_breadcrumb($crumbs_title, "blog/owner/{$container->username}");
    }
    elgg_push_breadcrumb($blog->title);
    $return['content'] = elgg_view_entity($blog, array('full_view' => true));
    // check to see if we should allow comments
    if ($blog->comments_on != 'Off' && $blog->status == 'published') {
        $return['content'] .= elgg_view_comments($blog);
    }
    return $return;
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:33,代码来源:blog.php

示例10: bookmarks_init

/**
 * Bookmark init
 */
function bookmarks_init()
{
    $root = dirname(__FILE__);
    elgg_register_library('elgg:bookmarks', "{$root}/lib/bookmarks.php");
    // actions
    $action_path = "{$root}/actions/bookmarks";
    elgg_register_action('bookmarks/save', "{$action_path}/save.php");
    elgg_register_action('bookmarks/delete', "{$action_path}/delete.php");
    elgg_register_action('bookmarks/share', "{$action_path}/share.php");
    // menus
    elgg_register_menu_item('site', array('name' => 'bookmarks', 'text' => elgg_echo('bookmarks'), 'href' => 'bookmarks/all'));
    elgg_register_plugin_hook_handler('register', 'menu:page', 'bookmarks_page_menu');
    elgg_register_plugin_hook_handler('register', 'menu:owner_block', 'bookmarks_owner_block_menu');
    elgg_register_page_handler('bookmarks', 'bookmarks_page_handler');
    elgg_extend_view('elgg.css', 'bookmarks/css');
    elgg_extend_view('elgg.js', 'bookmarks/js');
    elgg_register_widget_type('bookmarks', elgg_echo('bookmarks'), elgg_echo('bookmarks:widget:description'));
    if (elgg_is_logged_in()) {
        $user_guid = elgg_get_logged_in_user_guid();
        $address = urlencode(current_page_url());
        elgg_register_menu_item('extras', array('name' => 'bookmark', 'text' => elgg_view_icon('push-pin-alt'), 'href' => "bookmarks/add/{$user_guid}?address={$address}", 'title' => elgg_echo('bookmarks:this'), 'rel' => 'nofollow'));
    }
    // Register for notifications
    elgg_register_notification_event('object', 'bookmarks', array('create'));
    elgg_register_plugin_hook_handler('prepare', 'notification:create:object:bookmarks', 'bookmarks_prepare_notification');
    // Register bookmarks view for ecml parsing
    elgg_register_plugin_hook_handler('get_views', 'ecml', 'bookmarks_ecml_views_hook');
    // Register a URL handler for bookmarks
    elgg_register_plugin_hook_handler('entity:url', 'object', 'bookmark_set_url');
    // Register entity type for search
    elgg_register_entity_type('object', 'bookmarks');
    // Groups
    add_group_tool_option('bookmarks', elgg_echo('bookmarks:enablebookmarks'), true);
    elgg_extend_view('groups/tool_latest', 'bookmarks/group_module');
}
开发者ID:bhargavgarlapati,项目名称:Elgg,代码行数:38,代码来源:start.php

示例11: loginrequired_init

function loginrequired_init()
{
    global $CONFIG;
    // No need to do all the checking below if the user is already logged in... performance is key :)
    //  if (elgg_is_logged_in()) return;
    elgg_extend_view('css/elgg', 'loginrequired/css');
    //  elgg_unextend_view('page/elements/header', 'search/header');
    elgg_register_plugin_hook_handler('index', 'system', 'loginrequired_index', 1);
    elgg_register_plugin_hook_handler('login_required', 'login_required', 'login_required_default_allowed_list');
    // Get the current page URL without any ? & parameters... this is required for the registration page to work properly
    $current_url = current_page_url();
    $parameters_start = strrpos($current_url, '?');
    if ($parameters_start) {
        $current_url = substr($current_url, 0, $parameters_start);
    }
    // Always allow index page
    if ($current_url == $CONFIG->url) {
        return;
    }
    $allow = array();
    // Allow should have pages
    $allow[] = '_graphics';
    $allow[] = 'action/login';
    $allow[] = 'register';
    $allow[] = 'action/register';
    $allow[] = 'forgotpassword';
    $allow[] = 'resetpassword';
    $allow[] = 'action/user/requestnewpassword';
    $allow[] = 'action/user/passwordreset';
    $allow[] = 'action/security/refreshtoken';
    $allow[] = 'ajax/view/js/languages';
    $allow[] = 'upgrade\\.php';
    $allow[] = 'xml-rpc\\.php';
    $allow[] = 'mt/mt-xmlrpc\\.cgi';
    $allow[] = 'css/.*';
    $allow[] = 'js/.*';
    $allow[] = 'cache/css/.*';
    $allow[] = 'cache/js/.*';
    // Allow other plugin developers to edit the array values
    $add_allow = elgg_trigger_plugin_hook('login_required', 'login_required');
    // If more URL's are added... merge both with original list
    if (is_array($add_allow)) {
        $allow = array_merge($allow, $add_allow);
    }
    // Any public_pages defined via Elgg's walled garden plugin hook?
    $plugins = elgg_trigger_plugin_hook('public_pages', 'walled_garden', NULL, array());
    // If more URL's are added... merge both with original list
    if (is_array($plugins)) {
        $allow = array_merge($allow, $plugins);
    }
    // Check if current page is in allowed list... otherwise redirect to login
    foreach ($allow as $public) {
        $pattern = "`^{$CONFIG->url}{$public}/*\$`i";
        if (preg_match($pattern, $current_url)) {
            return;
        }
    }
    gatekeeper();
}
开发者ID:remy40,项目名称:gvrs,代码行数:59,代码来源:start.php

示例12: walledgarden_pagesetup

function walledgarden_pagesetup()
{
    global $CONFIG;
    if (current_page_url() != $CONFIG->url && !defined('externalpage') && !isloggedin()) {
        forward();
        exit;
    }
}
开发者ID:adamboardman,项目名称:Elgg,代码行数:8,代码来源:start.php

示例13: stripe_pagesetup

/**
 * Setup menus at page setup
 */
function stripe_pagesetup()
{
    elgg_register_menu_item('page', array('name' => 'stripe:customers', 'href' => 'admin/stripe/customers', 'text' => elgg_echo('admin:stripe:customers'), 'context' => 'admin', 'section' => 'stripe'));
    $user = elgg_get_page_owner_entity();
    elgg_register_menu_item('page', array('name' => 'stripe:cards', 'href' => "billing/{$user->username}/cards/all", 'text' => elgg_echo('stripe:cards:all'), 'selected' => substr_count(current_page_url(), 'cards/all'), 'context' => 'settings', 'section' => 'stripe'));
    elgg_register_menu_item('page', array('name' => 'stripe:charges', 'href' => "billing/{$user->username}/charges/all", 'text' => elgg_echo('stripe:charges:all'), 'selected' => substr_count(current_page_url(), 'charges/all'), 'context' => 'settings', 'section' => 'stripe'));
    elgg_register_menu_item('page', array('name' => 'stripe:invoices', 'href' => "billing/{$user->username}/invoices/all", 'text' => elgg_echo('stripe:invoices:all'), 'selected' => substr_count(current_page_url(), 'invoices/all'), 'context' => 'settings', 'section' => 'stripe'));
    elgg_register_menu_item('page', array('name' => 'stripe:subscriptions', 'href' => "billing/{$user->username}/subscriptions/all", 'text' => elgg_echo('stripe:subscriptions:all'), 'selected' => substr_count(current_page_url(), 'subscriptions/all'), 'context' => 'settings', 'section' => 'stripe'));
}
开发者ID:Daltonmedia,项目名称:stripe,代码行数:12,代码来源:events.php

示例14: questions_filter_menu_handler

/**
 * Change the filter menu for the questions context
 *
 * @param string $hook the 'register' hook
 * @param string $type the 'menu:filter' type
 * @param array $items the current menu items
 * @param array $params the supplied parameters
 */
function questions_filter_menu_handler($hook, $type, $items, $params)
{
    if (!empty($items) && is_array($items) && elgg_in_context("questions")) {
        $page_owner = elgg_get_page_owner_entity();
        // change some menu items
        foreach ($items as $key => $item) {
            // remove friends
            if ($item->getName() == "friend") {
                unset($items[$key]);
            }
            // in group context
            if (elgg_instanceof($page_owner, "group")) {
                // remove mine
                if ($item->getName() == "mine") {
                    unset($items[$key]);
                }
                // highlight all
                if ($item->getName() == "all") {
                    $item->setHref("questions/group/" . $page_owner->getGUID() . "/all");
                    $current_page = current_page_url();
                    if (stristr($current_page, "questions/group/" . $page_owner->getGUID() . "/all")) {
                        $item->setSelected(true);
                    }
                }
            }
        }
        if (elgg_instanceof($page_owner, "group")) {
            $expertContainer = $page_owner;
        } else {
            $expertContainer = null;
        }
        if (questions_is_expert($expertContainer) && !questions_workflow_enabled($expertContainer)) {
            if (elgg_instanceof($page_owner, "group")) {
                $items[] = ElggMenuItem::factory(array("name" => "todo_group", "text" => elgg_echo("questions:menu:filter:todo_group"), "href" => "questions/todo/" . $page_owner->getGUID(), "priority" => 710));
            } else {
                $items[] = ElggMenuItem::factory(array("name" => "todo", "text" => elgg_echo("questions:menu:filter:todo"), "href" => "questions/todo", "priority" => 700));
            }
        }
        if (questions_is_expert() && questions_workflow_enabled($expertContainer)) {
            if (elgg_instanceof($page_owner, "group")) {
                $url = "questions/group/" . $page_owner->getGUID() . "/workflow";
            } else {
                $url = "questions/workflow";
            }
            $items[] = ElggMenuItem::factory(array("name" => "workflow", "text" => elgg_echo("questions:menu:workflow"), "href" => $url, "priority" => 705));
        }
        if (elgg_is_admin_logged_in() | questions_is_expert($expertContainer) && questions_experts_enabled()) {
            $experts_href = "questions/experts";
            if (elgg_instanceof($page_owner, "group")) {
                $experts_href .= "/" . elgg_get_page_owner_guid();
            }
            $items[] = ElggMenuItem::factory(array("name" => "experts", "text" => elgg_echo("questions:menu:filter:experts"), "href" => $experts_href, "priority" => 800));
        }
    }
    return $items;
}
开发者ID:Pleio,项目名称:questions,代码行数:64,代码来源:hooks.php

示例15: stripe_actions_menu

/**
 * Create a Stripe object menu
 *
 * @param string $hook		Equals 'register'
 * @param string $type		Equals 'stripe-actions'
 * @param array $return		Current menu
 * @param array $params		Additional params
 * @return array
 */
function stripe_actions_menu($hook, $type, $return, $params)
{
    $object = elgg_extract('object', $params);
    switch ($object->object) {
        case 'card':
            $user = stripe_get_user_from_customer_id($object->customer);
            if (!elgg_instanceof($user) || !$user->canEdit()) {
                return $return;
            }
            $stripe = new StripeClient();
            $default = $stripe->getDefaultCard($user->guid);
            if ($default->id == $object->id) {
                $return[] = ElggMenuItem::factory(array('name' => 'default', 'text' => elgg_echo('stripe:cards:default'), 'href' => false));
            } else {
                $return[] = ElggMenuItem::factory(array('name' => 'default', 'text' => elgg_echo('stripe:cards:make_default'), 'href' => "action/stripe/cards/set_default?card_id={$object->id}&customer_id={$object->customer}", 'is_action' => 800, 'class' => 'elgg-requires-confirmation', 'rel' => elgg_echo('question:areyousure')));
                $return[] = ElggMenuItem::factory(array('name' => 'remove', 'text' => elgg_echo('stripe:cards:remove'), 'href' => "action/stripe/cards/set_default?card_id={$object->id}&customer_id={$object->customer}", 'is_action' => true, 'priority' => 900, 'class' => 'elgg-requires-confirmation', 'rel' => elgg_echo('question:areyousure')));
            }
            break;
        case 'charge':
            $user = stripe_get_user_from_customer_id($object->customer);
            if (!elgg_instanceof($user) || !$user->canEdit()) {
                return $return;
            }
            $full = elgg_normalize_url("billing/{$user->username}/charges/view/{$object->id}");
            if (current_page_url() !== $full) {
                $return[] = ElggMenuItem::factory(array('name' => 'details', 'text' => elgg_echo('stripe:charges:view'), 'href' => $full));
            }
            break;
        case 'invoice':
            $user = stripe_get_user_from_customer_id($object->customer);
            if (!elgg_instanceof($user) || !$user->canEdit()) {
                return $return;
            }
            if (isset($object->id)) {
                $full = elgg_normalize_url("billing/{$user->username}/invoices/view/{$object->id}");
                if (current_page_url() !== $full) {
                    $return[] = ElggMenuItem::factory(array('name' => 'details', 'text' => elgg_echo('stripe:invoices:view'), 'href' => $full));
                }
            }
            break;
        case 'subscription':
            $user = stripe_get_user_from_customer_id($object->customer);
            if (!elgg_instanceof($user) || !$user->canEdit()) {
                return $return;
            }
            $upcoming = elgg_normalize_url("billing/{$user->username}/invoices/upcoming/{$object->id}");
            if (current_page_url() !== $upcoming) {
                $return[] = ElggMenuItem::factory(array('name' => 'details', 'text' => elgg_echo('stripe:invoices:upcoming'), 'href' => $upcoming));
            }
            if (!$object->cancel_at_period_end) {
                $return[] = ElggMenuItem::factory(array('name' => 'cancel', 'text' => elgg_echo('subscriptions:cancel'), 'href' => "action/stripe/subscriptions/cancel?subscription_id={$object->id}&customer_id={$object->customer}", 'is_action' => 800, 'class' => 'elgg-requires-confirmation', 'rel' => elgg_echo('question:areyousure')));
            }
            break;
    }
    return $return;
}
开发者ID:Daltonmedia,项目名称:stripe,代码行数:65,代码来源:hooks.php


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