本文整理汇总了PHP中Streams::requestedFields方法的典型用法代码示例。如果您正苦于以下问题:PHP Streams::requestedFields方法的具体用法?PHP Streams::requestedFields怎么用?PHP Streams::requestedFields使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Streams
的用法示例。
在下文中一共展示了Streams::requestedFields方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Streams_stream_response_data
function Streams_stream_response_data()
{
// happens only during non-GET requests
if (isset(Streams::$cache['removed_count'])) {
return array('removed_count' => Streams::$cache['removed_count']);
}
if (isset(Streams::$cache['result'])) {
return Streams::$cache['result'];
}
if (isset(Streams::$cache['stream'])) {
$user = Users::loggedInUser();
$userId = $user ? $user->id : "";
return Streams::$cache['stream']->exportArray(array('asUserId' => $userId));
}
$publisherId = Streams::requestedPublisherId(true);
$name = Streams::requestedName(true);
$fields = Streams::requestedFields();
$user = Users::loggedInUser();
$userId = $user ? $user->id : 0;
$streams = array();
foreach (Streams::fetch($userId, $publisherId, $name, $fields) as $key => $stream) {
$streams[$key] = $stream->exportArray(array('asUserId' => $userId));
if ($userId && !empty($_REQUEST['join'])) {
$stream->join();
// NOTE: one of the rare times we may change state in a response handler
}
}
return Streams::$cache['result'] = array('stream' => empty($streams) ? null : reset($streams));
}
示例2: Streams_stream_response_streams
function Streams_stream_response_streams()
{
// happens only during non-GET requests
$publisherId = Streams::requestedPublisherId(true);
$name = Streams::requestedName(true);
$fields = Streams::requestedFields();
$limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : null;
$user = Users::loggedInUser();
$userId = $user ? $user->id : "";
$streams = Streams::fetch($userId, $publisherId, $name, $fields ? $fields : '*', $limit ? compact('limit') : array());
return Streams::$cache['streams'] = Db::exportArray($streams);
}
示例3: Streams_stream_response_stream
function Streams_stream_response_stream()
{
// happens only during non-GET requests
if (isset(Streams::$cache['stream'])) {
return Streams::$cache['stream']->exportArray();
}
$publisherId = Streams::requestedPublisherId(true);
$name = Streams::requestedName(true);
$fields = Streams::requestedFields();
$user = Users::loggedInUser();
$userId = $user ? $user->id : "";
Streams::$cache['stream'] = $stream = Streams::fetchOne($userId, $publisherId, $name, $fields, array('withParticipant' => true));
return $stream ? $stream->exportArray() : null;
}
示例4: Streams_stream_response_streams
function Streams_stream_response_streams()
{
// happens only during non-GET requests
$publisherId = Streams::requestedPublisherId(true);
$name = Streams::requestedName(true);
$fields = Streams::requestedFields();
$limit = isset($_REQUEST['limit']) ? $_REQUEST['limit'] : null;
$user = Users::loggedInUser();
$userId = $user ? $user->id : "";
$options = array('withParticipant' => true);
if (isset($limit)) {
$options['limit'] = $limit;
}
$streams = Streams::fetch($userId, $publisherId, $name, $fields ? $fields : '*', $options);
return Streams::$cache['streams'] = Db::exportArray($streams);
}
示例5: Broadcast_stream_response_content
function Broadcast_stream_response_content()
{
$publisherId = Streams::requestedPublisherId(true);
$name = Streams::requestedName(true);
$fields = Streams::requestedFields();
$user = Users::loggedInUser();
$userId = $user ? $user->id : 0;
if (isset(Streams::$cache['stream'])) {
$stream = Streams::$cache['stream'];
} else {
$streams = Streams::fetch($userId, $publisherId, $name, $fields, array('limit' => 30));
if (empty($streams)) {
throw new Q_Exception("No such stream", 'name');
}
$stream = reset($streams);
}
if ($publisherId != $userId and !$stream->testReadLevel('content')) {
return "This belongs to someone else.";
}
if ($publisherId != $userId and !$stream->testReadLevel('content')) {
throw new Users_Exception_NotAuthorized();
}
$userIds = array();
$agreements = Broadcast_Agreement::select('userId')->where(array('publisherId' => $publisherId, 'streamName' => $name, 'platform' => 'facebook'))->fetchDbRows();
foreach ($agreements as $a) {
$userIds[] = $a->userId;
}
if ($userIds) {
$agreed_users = Users_User::select('*')->where(array('id' => $userIds))->fetchDbRows();
} else {
$agreed_users = array();
}
$src = 'Broadcast/widget?';
$q = array('publisherId' => $publisherId, 'streamName' => $name);
foreach (array('css', 'button', 'checkmark', 'explanation') as $field) {
if (isset($_REQUEST[$field])) {
$q[$field] = $_REQUEST[$field];
}
}
$src .= http_build_query($q, null, '&');
$style = 'border: 0px;';
$code = Q_Html::tag('iframe', compact('src', 'style'), '');
Q_Response::addScript('plugins/Broadcast/js/Broadcast.js');
return Q::view('Broadcast/content/stream.php', compact('publisherId', 'name', 'fields', 'user', 'stream', 'agreed_users', 'code'));
}
示例6: Streams_stream_response_content
function Streams_stream_response_content()
{
$publisherId = Streams::requestedPublisherId(true);
$name = Streams::requestedName(true);
$fields = Streams::requestedFields();
$user = Users::loggedInUser();
$userId = $user ? $user->id : 0;
$stream = isset(Streams::$cache['stream']) ? Streams::$cache['stream'] : null;
if (!isset($stream)) {
throw new Q_Exception_MissingRow(array('table' => 'stream', 'criteria' => 'that name'));
}
if ($publisherId != $userId and !$stream->testReadLevel('content')) {
Q_Response::setNotice('Streams/stream/response/content', 'This content is hidden from you.', true);
return '';
}
// show stream as usual
return Q::view('Streams/content/stream.php', compact('publisherId', 'name', 'fields', 'user', 'stream'));
}
示例7: Streams_stream_response
/**
* Used to get a stream
*
* @param {array} $_REQUEST
* @param {string} $_REQUEST.publisherId Required
* @param {string} $_REQUEST.streamName Required streamName or name
* @param {integer} [$_REQUEST.messages] optionally pass a number here to fetch latest messages
* @param {integer} [$_REQUEST.participants] optionally pass a number here to fetch participants
* @return {void}
*/
function Streams_stream_response()
{
// this handler is only for GET requests
if (Q_Request::method() !== 'GET') {
return null;
}
$publisherId = Streams::requestedPublisherId(true);
$name = Streams::requestedName(true);
$fields = Streams::requestedFields();
$user = Users::loggedInUser();
$userId = $user ? $user->id : "";
if (isset(Streams::$cache['stream'])) {
$stream = Streams::$cache['stream'];
} else {
$streams = Streams::fetch($userId, $publisherId, $name, $fields ? $fields : '*', array('withParticipant' => true));
if (Q_Request::slotName('streams')) {
Q_Response::setSlot('streams', Db::exportArray($streams));
}
if (empty($streams)) {
if (Q_Request::slotName('stream')) {
Q_Response::setSlot('stream', null);
Q_Response::setSlot('messages', null);
Q_Response::setSlot('participants', null);
Q_Response::setSlot('related', null);
Q_Response::setSlot('relatedTo', null);
} else {
if (!Q_Request::slotName('streams')) {
$app = Q_Config::expect('Q', 'app');
Q_Dispatcher::forward("{$app}/notFound");
}
}
return null;
}
// The rest of the data is joined only on the first stream
Streams::$cache['stream'] = $stream = reset($streams);
}
if (empty($stream)) {
if (Q_Request::slotName('stream')) {
Q_Response::setSlot('stream', null);
}
return null;
}
if ($userId && !empty($_REQUEST['join'])) {
$stream->join();
// NOTE: one of the rare times we may change state in a response handler
}
if (Q_Request::slotName('stream')) {
Q_Response::setSlot('stream', $stream->exportArray());
}
if (!empty($_REQUEST['messages'])) {
$max = -1;
$limit = $_REQUEST['messages'];
$messages = false;
$type = isset($_REQUEST['messageType']) ? $_REQUEST['messageType'] : null;
if ($stream->testReadLevel('messages')) {
$messages = Db::exportArray($stream->getMessages(compact('type', 'max', 'limit')));
}
Q_Response::setSlot('messages', $messages);
}
if (!empty($_REQUEST['participants'])) {
$limit = $_REQUEST['participants'];
$participants = false;
if ($stream->testReadLevel('participants')) {
$participants = Db::exportArray($stream->getParticipants(compact('limit', 'offset')));
}
Q_Response::setSlot('participants', $participants);
}
}