本文整理汇总了PHP中Q_Config类的典型用法代码示例。如果您正苦于以下问题:PHP Q_Config类的具体用法?PHP Q_Config怎么用?PHP Q_Config使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Q_Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Streams_0_8_1_Streams_mysql
function Streams_0_8_1_Streams_mysql()
{
$app = Q_Config::expect('Q', 'app');
// template for community stream
$stream = new Streams_Stream();
$stream->publisherId = '';
$stream->name = 'Streams/community/';
$stream->type = 'Streams/template';
$stream->title = "Community";
$stream->content = '';
$readLevel = Streams::$READ_LEVEL['content'];
$writeLevel = Streams::$WRITE_LEVEL['join'];
$adminLevel = Streams::$ADMIN_LEVEL['invite'];
$stream->save();
// app community stream, for announcements
$stream = new Streams_Stream();
$stream->publisherId = $app;
$stream->name = 'Streams/community/main';
$stream->type = 'Streams/community';
$stream->title = "{$app} Community";
$stream->save();
// symlink the labels folder
$cwd = getcwd();
chdir(USERS_PLUGIN_FILES_DIR . DS . 'Users' . DS . 'icons');
if (!file_exists('Streams')) {
symlink(STREAMS_PLUGIN_FILES_DIR . DS . 'Streams' . DS . 'icons' . DS . 'labels' . DS . 'Streams', 'Streams');
}
chdir($cwd);
}
示例2: Users_user_response_data
function Users_user_response_data($params)
{
// Get Gravatar info
// WARNING: INTERNET_REQUEST
$hash = md5(strtolower(trim($identifier)));
$thumbnailUrl = Q_Request::baseUrl() . "/action.php/Users/thumbnail?hash={$hash}&size=80&type=" . Q_Config::get('Users', 'login', 'iconType', 'wavatar');
$json = @file_get_contents("http://www.gravatar.com/{$hash}.json");
$result = json_decode($json, true);
if ($result) {
if ($type === 'email') {
$result['emailExists'] = !empty($exists);
} else {
if ($type === 'mobile') {
$result['mobileExists'] = !empty($exists);
}
}
return $result;
}
// otherwise, return default
$email_parts = explode('@', $identifier, 2);
$result = array("entry" => array(array("id" => "571", "hash" => "357a20e8c56e69d6f9734d23ef9517e8", "requestHash" => "357a20e8c56e69d6f9734d23ef9517e8", "profileUrl" => "http://gravatar.com/test", "preferredUsername" => ucfirst($email_parts[0]), "thumbnailUrl" => $thumbnailUrl, "photos" => array(), "displayName" => "", "urls" => array())));
if ($type === 'email') {
$result['emailExists'] = !empty($exists);
} else {
$result['mobileExists'] = !empty($exists);
}
if ($terms_label = Users::termsLabel('register')) {
$result['termsLabel'] = $terms_label;
}
return $result;
}
示例3: Q_response_dashboard
function Q_response_dashboard()
{
$app = Q_Config::expect('Q', 'app');
$slogan = "Powered by Q.";
$user = Users::loggedInUser();
return Q::view("{$app}/dashboard.php", compact('slogan', 'user'));
}
示例4: Overlay_before_Q_responseExtras
function Overlay_before_Q_responseExtras()
{
$app = Q_Config::expect('Q', 'app');
Q_Response::addStylesheet('plugins/Q/css/Q.css');
Q_Response::addStylesheet('css/Overlay.css', '@end');
Q_Response::addStylesheet('http://fonts.googleapis.com/css?family=Open+Sans:400italic,400,300,700');
if (Q_Config::get('Q', 'firebug', false)) {
Q_Response::addScript("https://getfirebug.com/firebug-lite-debug.js");
}
Q_Response::addScript('js/Overlay.js');
Q_Response::setMeta("title", "Customize My Pic!");
Q_Response::setMeta("description", "Make a statement on Facebook by customizing your profile picture, even from your smartphone.");
Q_Response::setMeta("image", Q_Html::themedUrl('img/icon/icon.png'));
if (Q_Request::isIE()) {
header("X-UA-Compatible", "IE=edge");
}
header('Vary: User-Agent');
// running an event for loading action-specific extras (if there are any)
$uri = Q_Dispatcher::uri();
$module = $uri->module;
$action = $uri->action;
$event = "{$module}/{$action}/response/responseExtras";
if (Q::canHandle($event)) {
Q::event($event);
}
}
示例5: Streams_invite_response_data
function Streams_invite_response_data()
{
if (isset(Streams::$cache['invited'])) {
return Streams::$cache['invited'];
}
$user = Users::loggedInUser(true);
$publisherId = Streams::requestedPublisherId();
$streamType = Streams::requestedType();
$invitingUserId = Streams::requestedField('invitingUserId');
$limit = Q::ifset($_REQUEST, 'limit', Q_Config::get('Streams', 'invites', 'limit', 100));
$invited = Streams_Invited::select('*')->where(array('userId' => $user->id, 'state' => 'pending', 'expireTime <' => new Db_Expression('CURRENT_TIMESTAMP')))->limit($limit)->fetchDbRows(null, null, 'token');
$query = Streams_Invite::select('*')->where(array('token' => array_keys($invited)));
if (isset($publisherId)) {
$query = $query->where(array('publisherId' => $publisherId));
}
if (isset($streamType)) {
$query = $query->where(array('streamName' => new Db_Range($streamType . '/', true, false, true)));
}
if (isset($invitingUserId)) {
$query = $query->where(array('invitingUserId' => $invitingUserId));
}
$invites = $query->fetchDbRows();
$streams = array();
foreach ($invites as $invite) {
$stream = new Streams_Stream();
$stream->publisherId = $invite->publisherId;
$stream->name = $invite->streamName;
if ($stream->retrieve()) {
$streams[$invite->token] = $stream->exportArray();
$streams[$invite->token]['displayName'] = $invite->displayName;
}
}
return compact('streams', 'invites');
}
示例6: Q_file_post
/**
* Used by HTTP clients to upload a new file to the server
* @class Q/file
* @method post
* @param {array} [$params] Parameters that can come from the request
* @param {string} [$params.data] Required if $_FILES is empty. Base64-encoded image data URI - see RFC 2397
* @param {string} [$params.path="uploads"] parent path under web dir (see subpath)
* @param {string} [$params.subpath=""] subpath that should follow the path, to save the image under
* @param {string} [$params.name] override the name of the file, after the subpath
*/
function Q_file_post($params = null)
{
$p = $params ? $params : Q::take($_REQUEST, array('data', 'path', 'subpath'));
if (!empty($_FILES)) {
$file = reset($_FILES);
if ($tmp = $file['tmp_name']) {
if (empty($p['data'])) {
$p['data'] = file_get_contents($tmp);
$p['name'] = $file['name'];
}
unlink($tmp);
}
} else {
if (empty($p['data'])) {
throw new Q_Exception_RequiredField(array('field' => 'data'), 'data');
}
$p['data'] = base64_decode(chunk_split(substr($p['data'], strpos($p['data'], ',') + 1)));
}
$timeLimit = Q_Config::get('Q', 'uploads', 'limits', 'file', 'time', 5 * 60 * 60);
set_time_limit($timeLimit);
// default is 5 min
$data = Q_File::save($p);
if (empty($params)) {
Q_Response::setSlot('data', $data);
}
return $data;
}
示例7: Streams_0_8_6_Streams_mysql
function Streams_0_8_6_Streams_mysql()
{
$app = Q_Config::expect('Q', 'app');
// access for managing communities
$access = new Streams_Access();
$access->publisherId = $app;
$access->streamName = 'Streams/community*';
$access->ofUserId = '';
$access->ofContactLabel = "{$app}/admins";
$access->readLevel = Streams::$READ_LEVEL['messages'];
$access->writeLevel = Streams::$WRITE_LEVEL['edit'];
$access->adminLevel = Streams::$ADMIN_LEVEL['manage'];
$access->save();
// access for managing categories
$access = new Streams_Access();
$access->publisherId = $app;
$access->streamName = 'Streams/category/';
$access->ofUserId = '';
$access->ofContactLabel = "{$app}/admins";
$access->readLevel = Streams::$READ_LEVEL['messages'];
$access->writeLevel = Streams::$WRITE_LEVEL['close'];
$access->adminLevel = Streams::$ADMIN_LEVEL['manage'];
$access->save();
// template to help users relate things to Streams/category streams
Streams_Stream::insert(array('publisherId' => '', 'name' => 'Streams/category/', 'type' => 'Streams/template', 'title' => 'Untitled Category', 'icon' => 'Streams/category', 'content' => '', 'attributes' => null, 'readLevel' => Streams::$READ_LEVEL['messages'], 'writeLevel' => Streams::$WRITE_LEVEL['relate'], 'adminLevel' => Streams::$ADMIN_LEVEL['invite']))->execute();
// template to help users create subcategories for things
Streams_RelatedTo::insert(array('toPublisherId' => '', 'toStreamName' => 'Streams/category/', 'type' => 'subcategories', 'fromPublisherId' => '', 'fromStreamName' => 'Streams/category/'))->execute();
}
示例8: Streams_interests_response
function Streams_interests_response()
{
// serve a javascript file and tell client to cache it
$app = Q_Config::expect('Q', 'app');
$communityId = Q::ifset($_REQUEST, 'communityId', $app);
$tree = new Q_Tree();
$tree->load("files/Streams/interests/{$communityId}.json");
$categories = $tree->getAll();
foreach ($categories as $category => &$v1) {
foreach ($v1 as $k2 => &$v2) {
if (!Q::isAssociative($v2)) {
ksort($v1);
break;
}
ksort($v2);
}
}
header('Content-Type: text/javascript');
header("Pragma: ", true);
// 1 day
header("Cache-Control: public, max-age=86400");
// 1 day
$expires = date("D, d M Y H:i:s T", time() + 86400);
header("Expires: {$expires}");
// 1 day
$json = Q::json_encode($categories, true);
echo "Q.setObject(['Q', 'Streams', 'Interests', 'all', '{$communityId}'], {$json});";
return false;
}
示例9: Q_noModule
/**
* Override Q/noModule handler.
* just goes on to render our app's response,
* which will echo a 404 view.
*/
function Q_noModule($params)
{
header("HTTP/1.0 404 Not Found");
Q_Dispatcher::uri()->module = Q_Config::expect('Q', 'app');
Q_Dispatcher::uri()->action = 'notFound';
Q::event('Q/response', $params);
}
示例10: Q_errors_native
function Q_errors_native($params)
{
echo Q::view('Q/errors.php', $params);
$app = Q_Config::expect('Q', 'app');
Q::log("{$app}: Errors in " . ceil(Q::milliseconds()) . "ms\n");
Q::log($params);
}
示例11: Broadcast_before_Streams_message_Broadcast
function Broadcast_before_Streams_message_Broadcast($params)
{
extract($params);
if (!empty($_REQUEST['link'])) {
$parts = parse_url($_REQUEST['link']);
if (empty($parts['host'])) {
throw new Q_Exception_WrongType(array('field' => 'link', 'type' => 'a valid url'), 'link');
}
}
$content = array();
foreach (array('link', 'description', 'picture') as $field) {
if (!empty($_REQUEST[$field])) {
$content[$field] = $_REQUEST[$field];
}
}
if (!empty($_REQUEST['content'])) {
$content['message'] = $_REQUEST['content'];
}
if (!$content) {
throw new Q_Exception_RequiredField(array('field' => 'content'), 'content');
}
// Manually adding a link for 'Manage or Remove'
$appUrl = Q_Config::get('Users', 'facebookApps', 'Broadcast', 'url', '');
$content['actions'] = Q::json_encode(array(array('name' => 'Manage or Remove', 'link' => $appUrl)));
$message->broadcast_instructions = Q::json_encode($content);
}
示例12: Users_0_9_2_Users_mysql
function Users_0_9_2_Users_mysql()
{
$app = Q_Config::expect('Q', 'app');
$communityId = Users::communityId();
$rows = Users_Session::select('COUNT(1)')->where($criteria)->fetchAll(PDO::FETCH_NUM);
$count = $rows[0][0];
$limit = 100;
$offset = 0;
$sessions = Users_Session::select('*')->orderBy('id')->limit($limit, $offset)->caching(false)->fetchDbRows();
echo "Adding userId to sessions...";
while ($sessions) {
foreach ($sessions as $s) {
$parsed = Q::json_decode($s->content, true);
if (empty($parsed['Users']['loggedInUser']['id'])) {
continue;
}
$s->userId = $parsed['Users']['loggedInUser']['id'];
}
Users_Session::insertManyAndExecute($sessions, array('onDuplicateKeyUpdate' => array('userId' => new Db_Expression("VALUES(userId)"))));
$min = min($offset + $limit, $count);
echo "[100D";
echo "Updated {$min} of {$count} sessions";
$offset += $limit;
if ($offset > $count) {
break;
}
$sessions = Users_Session::select('*')->orderBy('id')->limit($limit, $offset)->caching(false)->fetchDbRows();
}
echo "\n";
}
示例13: Streams_0_8_8_Streams_mysql
function Streams_0_8_8_Streams_mysql()
{
$app = Q_Config::expect('Q', 'app');
$user = Users_User::fetch($app, true);
Streams::create($app, $app, 'Streams/resource', array('name' => 'Streams/invitations', 'readLevel' => 0, 'writeLevel' => 0, 'adminLevel' => 0));
Streams_Access::insert(array('publisherId' => $app, 'streamName' => "Streams/invitations", 'ofUserId' => '', 'grantedByUserId' => null, 'ofContactLabel' => "{$app}/admins", 'readLevel' => Streams::$READ_LEVEL['messages'], 'writeLevel' => Streams::$WRITE_LEVEL['close'], 'adminLevel' => Streams::$ADMIN_LEVEL['invite']))->execute();
}
示例14: Streams_invitations_response
/**
* Displays an HTML document that can be printed, ideally with line breaks.
* Uses a particular view for the layout.
* @param {array} $_REQUEST
* @param {string} $_REQUEST.invitingUserId Required. The id of the user that generated the invitations with a call to Streams::invite.
* @param {string} $_REQUEST.batch Required. The name of the batch under which invitations were saved during a call to Streams::invite.
* @param {string} [$_REQUEST.limit=100] The maximum number of invitations to show on the page
* @param {string} [$_REQUEST.offset=0] Used for paging
* @param {string} [$_REQUEST.title='Invitations'] Override the title of the document
* @param {string} [$_REQUEST.layout='default'] The name of the layout to use for the HTML document
* @see Users::addLink()
*/
function Streams_invitations_response()
{
Q_Request::requireFields(array('batch', 'invitingUserId'), true);
$invitingUserId = $_REQUEST['invitingUserId'];
$batch = $_REQUEST['batch'];
$title = Q::ifset($_REQUEST, 'layout', 'title');
$layoutKey = Q::ifset($_REQUEST, 'layout', 'default');
$limit = min(1000, Q::ifset($_REQUEST, 'limit', 100));
$offset = Q::ifset($_REQUEST, 'offset', 0);
$layout = Q_Config::expect('Streams', 'invites', 'layout', $layoutKey);
$app = Q_Config::expect('Q', 'app');
$pattern = Streams::invitationsPath($invitingUserId) . DS . $batch . DS . "*.html";
$filenames = glob($pattern);
$parts = array();
foreach ($filenames as $f) {
if (--$offset > 0) {
continue;
}
$parts[] = file_get_contents($f);
if (--$limit == 0) {
break;
}
}
$content = implode("\n\n<div class='Q_pagebreak Streams_invitations_separator'></div>\n\n", $parts);
echo Q::view($layout, compact('content', 'parts'));
return false;
}
示例15: Streams_invitations_response
/**
* Displays an HTML document that can be printed, ideally with line breaks.
* Uses a particular view for the layout.
* @param {array} $_REQUEST
* @param {string} $_REQUEST.invitingUserId Required. The id of the user that generated the invitations with a call to Streams::invite.
* @param {string} $_REQUEST.batch Required. The name of the batch under which invitations were saved during a call to Streams::invite.
* @param {string} [$_REQUEST.limit=100] The maximum number of invitations to show on the page
* @param {string} [$_REQUEST.offset=0] Used for paging
* @param {string} [$_REQUEST.title='Invitations'] Override the title of the document
* @param {string} [$_REQUEST.layout='default'] The name of the layout to use for the HTML document
* @see Users::addLink()
*/
function Streams_invitations_response()
{
Q_Request::requireFields(array('batch', 'invitingUserId'), true);
$invitingUserId = $_REQUEST['invitingUserId'];
$batch = $_REQUEST['batch'];
$user = Users::loggedInUser(true);
$stream = Streams::fetchOne(null, $invitingUserId, 'Streams/invitations', true);
if (!$stream->testReadLevel('content')) {
throw new Users_Exception_NotAuthorized();
}
$title = Q::ifset($_REQUEST, 'layout', 'title');
$layoutKey = Q::ifset($_REQUEST, 'layout', 'default');
$limit = min(1000, Q::ifset($_REQUEST, 'limit', 100));
$offset = Q::ifset($_REQUEST, 'offset', 0);
$layout = Q_Config::expect('Streams', 'invites', 'layout', $layoutKey);
$pattern = Streams::invitationsPath($invitingUserId) . DS . $batch . DS . "*.html";
$filenames = glob($pattern);
$parts = array();
foreach ($filenames as $f) {
if (--$offset > 0) {
continue;
}
$parts[] = file_get_contents($f);
if (--$limit == 0) {
break;
}
}
$content = implode("\n\n<div class='Q_pagebreak Streams_invitations_separator'></div>\n\n", $parts);
echo Q::view($layout, compact('title', 'content', 'parts'));
return false;
}