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


PHP Q_Response::slots方法代码示例

本文整理汇总了PHP中Q_Response::slots方法的典型用法代码示例。如果您正苦于以下问题:PHP Q_Response::slots方法的具体用法?PHP Q_Response::slots怎么用?PHP Q_Response::slots使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Q_Response的用法示例。


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

示例1: Users_thumbnail_response

function Users_thumbnail_response()
{
    $slots = Q_Response::slots(true);
    if (isset($slots['data'])) {
        return;
    }
    if (!isset($_REQUEST['hash'])) {
        throw new Q_Exception_WrongValue(array('field' => 'hash', 'range' => "identifier hash"));
    }
    $hash = $_REQUEST['hash'];
    header("Content-type: image/png");
    $gravatar = isset($_REQUEST['gravatar']) ? $_REQUEST['gravatar'] : Q_Config::get('Users', 'login', 'gravatar', false);
    $result = Q_Image::avatar($hash, isset($_REQUEST['size']) ? $_REQUEST['size'] : null, isset($_REQUEST['type']) ? $_REQUEST['type'] : null, $gravatar);
    if ($gravatar) {
        echo $result;
    } else {
        imagepng($result);
    }
    return false;
}
开发者ID:dmitriz,项目名称:Platform,代码行数:20,代码来源:response.php

示例2: Streams_batch_response_batch

function Streams_batch_response_batch()
{
    if (empty($_REQUEST['batch'])) {
        throw new Q_Exception_RequiredField(array('field' => 'batch'));
    }
    try {
        $batch = json_decode($_REQUEST['batch'], true);
    } catch (Exception $e) {
    }
    if (empty($batch)) {
        throw new Q_Exception_WrongValue(array('field' => 'batch', 'range' => 'valid JSON'));
    }
    if (empty($batch['args'])) {
        throw new Q_Exception_RequiredField(array('field' => 'args'));
    }
    // Gather the publisher ids and stream names to fetch
    $to_fetch = array();
    foreach ($batch['args'] as $args) {
        if (count($args) < 4) {
            continue;
        }
        list($action, $slots, $publisherId, $name) = $args;
        if (empty($to_fetch[$publisherId])) {
            $to_fetch[$publisherId] = array();
        }
        $to_fetch[$publisherId][] = $name;
    }
    $user = Users::loggedInUser();
    $userId = $user ? $user->id : "";
    // Fetch the actual streams
    $streams = array();
    foreach ($to_fetch as $publisherId => $names) {
        if (empty($streams[$publisherId])) {
            $streams[$publisherId] = array();
        }
        $streams[$publisherId] = array_merge($streams[$publisherId], Streams::fetch($userId, $publisherId, $names, '*'));
    }
    // Now, build the result
    $result = array();
    foreach ($batch['args'] as $args) {
        try {
            $action = $args[0];
            $prev_request = $_REQUEST;
            $extra = !empty($args[4]) ? $args[4] : null;
            if (is_array($extra)) {
                foreach ($extra as $k => $v) {
                    $_REQUEST[$k] = $v;
                }
            }
            switch ($action) {
                case 'stream':
                    break;
                case 'message':
                    if (!is_array($extra)) {
                        $_REQUEST['ordinal'] = $extra;
                    }
                    break;
                case 'participant':
                    if (!is_array($extra)) {
                        $_REQUEST['userId'] = $extra;
                    }
                    break;
                default:
                    throw new Q_Exception_WrongValue(array('field' => 'action', 'range' => "'stream', 'message' or 'participant'"));
            }
            Q_Request::$slotNames_override = is_array($args[1]) ? $args[1] : explode(',', $args[1]);
            Q_Request::$method_override = 'GET';
            if (count($args) >= 4) {
                Streams::$requestedPublisherId_override = $publisherId = $args[2];
                Streams::$requestedName_override = $name = $args[3];
                if (empty($streams[$publisherId][$name])) {
                    throw new Q_Exception_MissingRow(array('table' => 'Stream', 'criteria' => "{publisherId: '{$publisherId}', name: '{$name}'}"));
                }
                Streams::$cache['stream'] = $streams[$publisherId][$name];
            }
            Q::event("Streams/{$action}/response", compact('streams', 'publisherId', 'name', 'extra', 'user', 'userId'));
            $slots = Q_Response::slots(true);
            unset($slots['batch']);
            $result[] = compact('slots');
        } catch (Exception $e) {
            $result[] = array('errors' => Q_Exception::toArray(array($e)));
        }
        $prev_request = $_REQUEST;
        Q_Request::$slotNames_override = null;
        Q_Request::$method_override = null;
        Streams::$requestedPublisherId_override = null;
        Streams::$requestedName_override = null;
    }
    return $result;
}
开发者ID:dmitriz,项目名称:Platform,代码行数:90,代码来源:batch.php

示例3: Q_response


//.........这里部分代码省略.........
        }
    }
    // What to do if this is an AJAX request
    if ($isAjax) {
        $to_encode = array();
        if (Q_Response::$redirected) {
            // We already called Q_Response::redirect
            $to_encode['redirect']['url'] = Q_Uri::url(Q_Response::$redirected);
            try {
                $to_encode['redirect']['uri'] = Q_Uri::from(Q_Response::$redirected)->toArray();
            } catch (Exception $e) {
                // couldn't get internal URI
            }
        } else {
            if (is_array($slotNames)) {
                foreach ($slotNames as $slotName) {
                    Q_Response::fillSlot($slotName, 'default', Q::ifset($idPrefixes, $slotName, null));
                }
                // Go through the slots again, because other handlers may have overwritten
                // their contents using Q_Response::setSlot()
                foreach ($slotNames as $sn) {
                    Q_Response::fillSlot($sn, 'default', Q::ifset($idPrefixes, $slotName, null));
                }
                if (Q_Response::$redirected) {
                    // While rendering the slots we called Q_Redirect
                    $to_encode['redirect']['url'] = Q_Uri::url(Q_Response::$redirected);
                    try {
                        $to_encode['redirect']['uri'] = Q_Uri::from(Q_Response::$redirected)->toArray();
                    } catch (Exception $e) {
                        // couldn't get internal URI
                    }
                } else {
                    if (Q_Request::isLoadExtras()) {
                        $to_encode['slots'] = Q_Response::slots(true);
                        // add stylesheets, stylesinline, scripts, scriptlines, scriptdata, templates
                        foreach (array_merge(array(''), $slotNames) as $slotName) {
                            $temp = Q_Response::stylesheetsArray($slotName);
                            if ($temp) {
                                $to_encode['stylesheets'][$slotName] = $temp;
                            }
                            $temp = Q_Response::stylesInline($slotName);
                            if ($temp) {
                                $to_encode['stylesInline'][$slotName] = $temp;
                            }
                            $temp = Q_Response::scriptsArray($slotName);
                            if ($temp) {
                                $to_encode['scripts'][$slotName] = $temp;
                            }
                            $temp = Q_Response::scriptLines($slotName, true, "\n", false);
                            if ($temp) {
                                $to_encode['scriptLines'][$slotName] = $temp;
                            }
                            $temp = Q_Response::scriptData($slotName);
                            if ($temp) {
                                $to_encode['scriptData'][$slotName] = $temp;
                            }
                            $temp = Q_Response::templateData($slotName);
                            if ($temp) {
                                $to_encode['templates'][$slotName] = $temp;
                            }
                        }
                    } else {
                        $to_encode['slots'] = Q_Response::slots(true);
                        // add stylesinline, scriptlines, scriptdata, templates
                        foreach (array_merge(array(''), $slotNames) as $slotName) {
                            $temp = Q_Response::stylesInline($slotName);
开发者ID:atirjavid,项目名称:Platform,代码行数:67,代码来源:response.php


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