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


PHP elgg_is_xhr函数代码示例

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


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

示例1: trip_companions_page_handler

/**
 * Gestor de páginas
 *
 * @param array $page Array of page routing elements
 * @return bool
 */
function trip_companions_page_handler($page)
{
    //system_message("page handler " . elgg_extract(0, $page));
    // only logged in users can do things
    elgg_gatekeeper();
    if (elgg_extract(0, $page) === 'add' && elgg_is_xhr()) {
        echo elgg_view('resources/evaluationcontent/add_form');
        return true;
    }
    if (elgg_extract(0, $page) === 'import') {
        echo elgg_view('resources/trip_companions/add_form');
        return true;
    }
    $friends = $groups = 0;
    switch ($page[0]) {
        case 'groups':
            $groups = 10;
            break;
        default:
            $friends = $groups = 10;
            break;
    }
    $page_owner = elgg_get_logged_in_user_entity();
    elgg_set_page_owner_guid($page_owner->guid);
    elgg_set_context("trip_companions");
    $content = elgg_view('resources/trip_companions/list', array('owner' => $page_owner, 'friends' => $friends, 'groups' => $groups));
    if ($content) {
        echo $content;
        return true;
    }
    return false;
}
开发者ID:rosanamontes,项目名称:teranga.go,代码行数:38,代码来源:start.php

示例2: execute

 public function execute()
 {
     $this->uploads = hypeApps()->uploader->handle('dropzone', array('subtype' => $this->subtype, 'container_guid' => $this->container_guid, 'access_id' => ACCESS_PRIVATE));
     $this->output = array();
     if (!elgg_is_xhr()) {
         return;
     }
     foreach ($this->uploads as $upload) {
         $messages = array();
         $success = true;
         if ($upload->error) {
             $messages[] = $upload->error;
             $success = false;
             $guid = false;
         } else {
             $file = $upload->file;
             if (!$file instanceof \ElggEntity) {
                 $messages[] = elgg_echo('dropzone:file_not_entity');
                 $success = false;
             } else {
                 $guid = $file->getGUID();
                 $html = elgg_view('input/hidden', array('name' => $this->input_name, 'value' => $file->getGUID()));
             }
         }
         $file_output = array('messages' => $messages, 'success' => $success, 'guid' => $guid, 'html' => $html);
         $output[] = elgg_trigger_plugin_hook('upload:after', 'dropzone', array('upload' => $upload), $file_output);
     }
     $this->result->output = json_encode($output);
 }
开发者ID:n8b,项目名称:VMN,代码行数:29,代码来源:uploadAction.php

示例3: stripe_page_handler

/**
 * Stripe related pages
 *
 * @param array $page
 * @param string $handler
 * @return boolean
 */
function stripe_page_handler($page, $handler)
{
    gatekeeper();
    $username = elgg_extract(0, $page, false);
    if ($username) {
        $user = get_user_by_username($username);
    }
    if (!elgg_instanceof($user) || !$user->canEdit()) {
        $user = elgg_get_logged_in_user_entity();
        forward("{$handler}/{$user->username}");
    }
    elgg_set_context('settings');
    elgg_set_page_owner_guid($user->guid);
    elgg_push_breadcrumb(elgg_echo('stripe:billing'), 'billing');
    $context = elgg_extract(1, $page, 'cards');
    $action = elgg_extract(2, $page, 'all');
    $view = "stripe/pages/{$context}/{$action}";
    if (elgg_view_exists($view)) {
        $params = array('entity' => $user, 'id' => elgg_extract(3, $page, false), 'context' => $page);
        $title = elgg_echo("stripe:{$context}:{$action}");
        $content = elgg_view($view, $params);
        $sidebar = elgg_view('stripe/sidebar', $params);
        $filter = elgg_view("stripe/filters/{$context}/{$action}", $params);
    }
    if ($content) {
        if (elgg_is_xhr()) {
            echo $content;
        } else {
            $layout = elgg_view_layout('content', array('title' => $title, 'content' => $content, 'sidebar' => $sidebar, 'filter' => $filter));
            echo elgg_view_page($title, $layout);
        }
        return true;
    }
    return false;
}
开发者ID:Daltonmedia,项目名称:stripe,代码行数:42,代码来源:page_handlers.php

示例4: staticsites_page_handler

/**
 * Page handler for static sites
 * 
 * This page handler will behave like a REST-ful api endpoint for GET request
 * Since static sites 'containers' are groups, the resource naming and endpoints
 * will look like:
 * 
 * GET  - {elgg_url}/staticsites/{group_guid}/page/{id}
 * GET  - {elgg_url}/staticsites/{group_guid}/pages
 *
 */
function staticsites_page_handler($params)
{
    // Logged in only
    gatekeeper();
    $is_xhr = elgg_is_xhr();
    $is_xhr = 1;
    // Debug
    if ($is_xhr && $params[0]) {
        // Check for container_guid as first param
        if (is_numeric($params[0])) {
            $container_guid = $params[0];
            unset($params[0]);
            $params = array_values($params);
        }
        switch ($params[0]) {
            case "page":
                staticsites_handle_page_request($params, $container_guid);
                break;
            case "pages":
                staticsites_handle_pages_request($params, $container_guid);
                break;
            default:
                return FALSE;
                break;
        }
    } else {
        return FALSE;
    }
    return TRUE;
}
开发者ID:THINKGlobalSchool,项目名称:staticsites,代码行数:41,代码来源:start.php

示例5: handlePages

 /**
  * Handles embedded URLs
  *
  * @param array $page URL segments
  * @return boolean
  */
 function handlePages($page)
 {
     $url = get_input('url');
     $handle = get_input('handle');
     $iframe = get_input('iframe', false);
     $site = elgg_get_site_entity();
     if (!$handle) {
         $handle = $site->guid;
     }
     if (!$url || !$handle) {
         return false;
     }
     $parse = elgg_is_logged_in();
     switch ($page[0]) {
         default:
             $data = $this->model->get($url, $handle, $parse);
             $layout = elgg_view('output/card', array('href' => $url, 'handle' => $handle));
             if (elgg_is_xhr()) {
                 echo $layout;
             } else {
                 $shell = $iframe ? 'iframe' : 'default';
                 echo elgg_view_page($data['title'], $layout, $shell);
             }
             break;
         case 'json':
             $data = $this->model->get($url, $handle, $parse);
             header('Content-Type: application/json');
             echo json_encode($data);
             exit;
     }
     return true;
 }
开发者ID:n8b,项目名称:VMN,代码行数:38,代码来源:Router.php

示例6: file_tools_page_handler

function file_tools_page_handler($page)
{
    $include_file = false;
    switch ($page[0]) {
        case "list":
            if (elgg_is_xhr() && !empty($page[1])) {
                elgg_set_page_owner_guid($page[1]);
                if (get_input("folder_guid", false) !== false) {
                    set_input("draw_page", false);
                }
                if (isset($page[2])) {
                    set_input("folder_guid", $page[2]);
                }
                $include_file = dirname(dirname(__FILE__)) . "/pages/list.php";
            }
            break;
        case "folder":
            if ($page[1] == 'new') {
                if (!empty($page[2])) {
                    elgg_set_page_owner_guid($page[2]);
                }
                $include_file = dirname(dirname(__FILE__)) . "/pages/folder/new.php";
            } elseif ($page[1] == 'edit') {
                if (!empty($page[2])) {
                    set_input("folder_guid", $page[2]);
                    $include_file = dirname(dirname(__FILE__)) . "/pages/folder/edit.php";
                }
            }
            break;
        case "file":
            if ($page[1] == 'new') {
                if (!empty($page[2])) {
                    elgg_set_page_owner_guid($page[2]);
                }
                $include_file = dirname(dirname(__FILE__)) . "/pages/file/new.php";
            } elseif ($page[1] == 'edit') {
                set_input("guid", $page[2]);
                $include_file = dirname(dirname(__FILE__)) . "/pages/file/edit.php";
            } elseif ($page[1] == 'download') {
                $include_file = dirname(dirname(__FILE__)) . "/pages/file/download.php";
            }
            break;
        case "proc":
            if (file_exists(dirname(dirname(__FILE__)) . "/procedures/" . $page[1] . "/" . $page[2] . ".php")) {
                $include_file = dirname(dirname(__FILE__)) . "/procedures/" . $page[1] . "/" . $page[2] . ".php";
            } else {
                echo json_encode(array('valid' => 0));
                exit;
            }
            break;
    }
    if (!empty($include_file)) {
        include $include_file;
        return true;
    } else {
        forward("file/all");
    }
}
开发者ID:pleio,项目名称:file_tools,代码行数:58,代码来源:page_handlers.php

示例7: reportedcontent_page_handler

/**
 * Reported content page handler
 *
 * Serves the add report page
 *
 * @param array $page Array of page routing elements
 * @return bool
 */
function reportedcontent_page_handler($page)
{
    // only logged in users can report things
    elgg_gatekeeper();
    if (elgg_extract(0, $page) === 'add' && elgg_is_xhr()) {
        echo elgg_view('resources/reportedcontent/add_form');
        return true;
    }
    echo elgg_view('resources/reportedcontent/add');
    return true;
}
开发者ID:elgg,项目名称:reportedcontent,代码行数:19,代码来源:start.php

示例8: embed_page_handler

/**
 * Page handler for embeds
 * 
 * @param array $page
 */
function embed_page_handler($page)
{
    $params = array('output' => '', 'status' => 0, 'system_messages' => array('error' => array(), 'success' => array()));
    $container_guid = get_input('container_guid');
    if ($container_guid && get_entity($container_guid)) {
        elgg_set_page_owner_guid($container_guid);
    }
    switch ($page[0]) {
        default:
        case 'tab':
            $default_tab = elgg_is_active_plugin('file') ? 'file' : 'content_items';
            $embed_tab = elgg_extract(1, $page, $default_tab);
            $title = elgg_echo("embed:embed");
            $filter = elgg_view('embed/filter', array('filter_context' => $embed_tab));
            $view = "embed/tab/{$embed_tab}";
            if (elgg_view_exists($view)) {
                $content = elgg_view($view);
            } else {
                $embed_tab = elgg_get_config('embed_tab');
                if ($embed_tab instanceof \ElggMenuItem) {
                    $view = $embed_tab->getData('view');
                    $options = $embed_tab->getData('options');
                    if ($view) {
                        $content = elgg_view($view);
                    } else {
                        if ($options) {
                            $content = elgg_view('embed/get_list', array('options' => $options));
                        }
                    }
                }
            }
            if (empty($content)) {
                $content = elgg_autop(elgg_echo('embed:section:invalid'));
            }
            $params['output'] = elgg_view_layout('one_column', array('title' => $title, 'content' => $filter . $content, 'class' => 'embed-wrapper'));
            break;
    }
    $system_messages = system_messages(NULL, "");
    if (isset($system_messages['success'])) {
        $params['system_messages']['success'] = $system_messages['success'];
    }
    if (isset($system_messages['error'])) {
        $params['system_messages']['error'] = $system_messages['error'];
        $params['status'] = -1;
    }
    // We do not want to serve this page via non-xhr requests
    if (!elgg_is_xhr()) {
        register_error(elgg_echo('embed:error:non_xhr_request'));
        return false;
    }
    echo json_encode($params);
    exit;
}
开发者ID:hypejunction,项目名称:hypeembed,代码行数:58,代码来源:page_handlers.php

示例9: ajax_list_view

/**
 * Filter AJAX output
 *
 * @param string $hook		Equals 'view'
 * @param string $type		Equals 'all'
 * @param string $return	View output
 * @param array $params		Additional params
 * @staticvar string $maps_ajax_output
 * @return string			Filtered output
 */
function ajax_list_view($hook, $type, $return, $params)
{
    static $maps_ajax_output;
    if (!elgg_is_xhr() || !get_input('mapbox')) {
        return $return;
    }
    $vars = elgg_extract('vars', $params);
    $map = elgg_extract('list', $vars);
    if ($type == 'page/components/mapbox' && $map instanceof ElggMap && (!get_input('hash') || $map->getHash() == get_input('hash'))) {
        $maps_ajax_output = $return;
    }
    if ($type == 'page/default' || ($type = 'page/layouts/maps_ajax')) {
        return $maps_ajax_output;
    }
    return elgg_in_context('mapbox') ? $return : '';
}
开发者ID:hypejunction,项目名称:hypemaps,代码行数:26,代码来源:hooks.php

示例10: reportedcontent_page_handler

/**
 * Reported content page handler
 *
 * Serves the add report page
 *
 * @param array $page Array of page routing elements
 * @return bool
 */
function reportedcontent_page_handler($page)
{
    // only logged in users can report things
    elgg_gatekeeper();
    if (elgg_extract(0, $page) === 'add' && elgg_is_xhr()) {
        echo elgg_view('resources/reportedcontent/add_form');
        return true;
    }
    $title = elgg_echo('reportedcontent:this');
    $content = elgg_view_form('reportedcontent/add');
    $sidebar = elgg_echo('reportedcontent:instructions');
    $params = array('title' => $title, 'content' => $content, 'sidebar' => $sidebar);
    $body = elgg_view_layout('one_sidebar', $params);
    echo elgg_view_page($title, $body);
    return true;
}
开发者ID:ibou77,项目名称:elgg,代码行数:24,代码来源:start.php

示例11: hj_framework_view_list

function hj_framework_view_list($list_id, $getter_options = array(), $list_options = array(), $viewer_options = array(), $getter = 'elgg_get_entities')
{
    $default_list_options = array('list_type' => 'list', 'list_class' => null, 'item_class' => null, 'base_url' => current_page_url(), 'num_pages' => 5, 'pagination' => true, 'limit_key' => "__lim_{$list_id}", 'offset_key' => "__off_{$list_id}", 'order_by_key' => "__ord_{$list_id}", 'direction_key' => "__dir_{$list_id}", 'reverse_list' => false);
    $list_options = array_merge($default_list_options, $list_options);
    if (!isset($getter_options['limit'])) {
        $getter_options['limit'] = get_input($list_options['limit_key'], 10);
    }
    if (!isset($getter_options['offset'])) {
        $getter_options['offset'] = get_input($list_options['offset_key'], 0);
    }
    $porder_by = get_input($list_options['order_by_key'], '');
    $pdirection = get_input($list_options['direction_key'], 'DESC');
    $getter_options = hj_framework_get_order_by_clause($porder_by, $pdirection, $getter_options);
    if (isset($list_options['filter_callback']) && is_callable($list_options['filter_callback'])) {
        $getter_options = call_user_func_array($list_options['filter_callback'], array($list_id, $getter_options));
    }
    $getter_options = elgg_trigger_plugin_hook('custom_sql_clause', 'framework:lists', array('list_id' => $list_id, 'list_options' => $list_options, 'viewer_options' => $viewer_options), $getter_options);
    $getter_options['count'] = true;
    $count = $getter($getter_options);
    //error_log(print_r($getter_options, true));
    $getter_options['count'] = false;
    $entities = $getter($getter_options);
    if ($list_options['reverse_list']) {
        $entities = array_reverse($entities);
    }
    $params = array('list_id' => $list_id, 'entities' => $entities, 'count' => $count, 'list_options' => $list_options, 'getter_options' => $getter_options, 'viewer_options' => $viewer_options, 'getter' => $getter);
    if (elgg_view_exists("page/components/grids/{$list_options['list_type']}")) {
        $list = elgg_view("page/components/grids/{$list_options['list_type']}", $params, false, false, 'default');
    } else {
        $list = elgg_view("page/components/grids/list", $params, false, false, 'default');
    }
    if (elgg_is_xhr() && get_input('view') == 'xhr') {
        if (elgg_view_exists("page/components/grids/{$list_options['list_type']}")) {
            $json_list = elgg_view("page/components/grids/{$list_options['list_type']}", $params, false, false, 'xhr');
        } else {
            $json_list = elgg_view("page/components/grids/list", $params, false, false, 'xhr');
        }
        global $XHR_GLOBAL;
        $XHR_GLOBAL['lists'][$list_id] = $json_list;
    }
    return elgg_view('page/components/grids/wrapper', array('body' => $list));
}
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:42,代码来源:lists.php

示例12: longtextMenuPrepare

 /**
  * Change menu item in the longtext menu
  *
  * @param string         $hook         'prepare'
  * @param string         $type         'menu:longtext'
  * @param ElggMenuItem[] $return_value the current menu items
  * @param array          $params       supplied params
  *
  * @return ElggMenuItem[]
  */
 public static function longtextMenuPrepare($hook, $type, $return_value, $params)
 {
     if (!is_array($return_value)) {
         return;
     }
     foreach ($return_value as $section => $menu_items) {
         if (!is_array($menu_items)) {
             continue;
         }
         foreach ($menu_items as $menu_item) {
             if ($menu_item->getName() !== 'embed') {
                 continue;
             }
             if (elgg_is_xhr()) {
                 echo elgg_format_element('script', [], 'require(["embed_extended/site"]);');
             } else {
                 elgg_require_js('embed_extended/site');
             }
             $link_class = $menu_item->getLinkClass();
             $link_class = str_ireplace('elgg-lightbox', 'elgg-embed-lightbox', $link_class);
             $menu_item->setLinkClass($link_class);
         }
     }
 }
开发者ID:epsylon,项目名称:Hydra-dev,代码行数:34,代码来源:Menus.php

示例13: elgg_view_form

<?php

//hack! Elgg engine should take care of this, or blog/save form should be coded better
if (elgg_is_xhr() && isset($vars['entity_guid'])) {
    elgg_set_page_owner_guid($vars['entity_guid']);
}
echo elgg_view_form('messageboard/add', array(), $vars);
开发者ID:amcfarlane1251,项目名称:ongarde,代码行数:7,代码来源:composer.php

示例14: abs

}
$offset = abs((int) elgg_extract('offset', $vars, 0));
// because you can say $vars['limit'] = 0
if (!($limit = (int) elgg_extract('limit', $vars, elgg_get_config('default_limit')))) {
    $limit = 10;
}
$offset_key = elgg_extract('offset_key', $vars, 'offset');
$url_fragment = elgg_extract('url_fragment', $vars, '');
// some views pass an empty string for base_url
if (isset($vars['base_url']) && $vars['base_url']) {
    $base_url = $vars['base_url'];
} else {
    if (isset($vars['baseurl']) && $vars['baseurl']) {
        elgg_deprecated_notice("Use 'base_url' instead of 'baseurl' for the navigation/pagination view", 1.8);
        $base_url = $vars['baseurl'];
    } elseif (elgg_is_xhr() && !empty($_SERVER['HTTP_REFERER'])) {
        $base_url = $_SERVER['HTTP_REFERER'];
    } else {
        $base_url = current_page_url();
    }
}
$base_url_has_fragment = preg_match('~#.~', $base_url);
$get_href = function ($offset) use($base_url, $base_url_has_fragment, $offset_key, $url_fragment) {
    $link = elgg_http_add_url_query_elements($base_url, array($offset_key => $offset));
    if (!$base_url_has_fragment && $offset) {
        $link .= "#{$url_fragment}";
    }
    return $link;
};
if ($count <= $limit && $offset == 0) {
    // no need for pagination
开发者ID:ethanWallace,项目名称:wet4,代码行数:31,代码来源:pagination.php

示例15: elgg_ajax_gatekeeper

/**
 * Require that the current request be an XHR. If not, execution of the current function
 * will end and a 400 response page will be sent.
 *
 * @return void
 * @since 1.12.0
 */
function elgg_ajax_gatekeeper()
{
    if (!elgg_is_xhr()) {
        register_error(_elgg_services()->translator->translate('ajax:not_is_xhr'));
        forward(null, '400');
    }
}
开发者ID:thehereward,项目名称:Elgg,代码行数:14,代码来源:pagehandler.php


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