本文整理汇总了PHP中common_config函数的典型用法代码示例。如果您正苦于以下问题:PHP common_config函数的具体用法?PHP common_config怎么用?PHP common_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了common_config函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
*
* @param User $user
* @param boolean $indent
* @param boolean $outputMode: UserActivityStream::OUTPUT_STRING to return a string,
* or UserActivityStream::OUTPUT_RAW to go to raw output.
* Raw output mode will attempt to stream, keeping less
* data in memory but will leave $this->activities incomplete.
*/
function __construct($user, $indent = true, $outputMode = UserActivityStream::OUTPUT_STRING)
{
parent::__construct($user, null, $indent);
$this->outputMode = $outputMode;
if ($this->outputMode == self::OUTPUT_STRING) {
// String buffering? Grab all the notices now.
$notices = $this->getNotices();
} elseif ($this->outputMode == self::OUTPUT_RAW) {
// Raw output... need to restructure from the stringer init.
$this->xw = new XMLWriter();
$this->xw->openURI('php://output');
if (is_null($indent)) {
$indent = common_config('site', 'indent');
}
$this->xw->setIndent($indent);
// We'll fetch notices later.
$notices = array();
} else {
throw new Exception('Invalid outputMode provided to ' . __METHOD__);
}
// Assume that everything but notices is feasible
// to pull at once and work with in memory...
$subscriptions = $this->getSubscriptions();
$subscribers = $this->getSubscribers();
$groups = $this->getGroups();
$faves = $this->getFaves();
$objs = array_merge($subscriptions, $subscribers, $groups, $faves, $notices);
// Sort by create date
usort($objs, 'UserActivityStream::compareObject');
// We'll keep these around for later, and interleave them into
// the output stream with the user's notices.
foreach ($objs as $obj) {
$this->activities[] = $obj->asActivity();
}
}
示例2: prepare
function prepare($args)
{
parent::prepare($args);
if (common_config('singleuser', 'enabled')) {
$nickname_arg = User::singleUserNickname();
} else {
$nickname_arg = $this->arg('nickname');
}
$nickname = common_canonical_nickname($nickname_arg);
// Permanent redirect on non-canonical nickname
if ($nickname_arg != $nickname) {
$args = array('nickname' => $nickname);
if ($this->arg('page') && $this->arg('page') != 1) {
$args['page'] = $this->arg['page'];
}
common_redirect(common_local_url('peopletagsforuser', $args), 301);
}
$this->user = User::getKV('nickname', $nickname);
if (!$this->user) {
// TRANS: Client error displayed trying to perform an action related to a non-existing user.
$this->clientError(_('No such user.'), 404);
}
$this->tagged = $this->user->getProfile();
if (!$this->tagged) {
// TRANS: Error message displayed when referring to a user without a profile.
$this->serverError(_('User has no profile.'));
}
$this->page = $this->arg('page') ? $this->arg('page') + 0 : 1;
return true;
}
示例3: __construct
/**
* Constructor
*
* @param User $user the user for the feed
* @param User $cur the current authenticated user, if any
* @param boolean $indent flag to turn indenting on or off
*
* @return void
*/
function __construct($user, $cur = null, $indent = true)
{
parent::__construct($cur, $indent);
$this->user = $user;
if (!empty($user)) {
$profile = $user->getProfile();
$ao = ActivityObject::fromProfile($profile);
array_push($ao->extra, $profile->profileInfo($cur));
// XXX: For users, we generate an author _AND_ an <activity:subject>
// This is for backward compatibility with clients (especially
// StatusNet's clients) that assume the Atom will conform to an
// older version of the Activity Streams API. Subject should be
// removed in future versions of StatusNet.
$this->addAuthorRaw($ao->asString('author'));
$depMsg = 'Deprecation warning: activity:subject is present ' . 'only for backward compatibility. It will be ' . 'removed in the next version of StatusNet.';
$this->addAuthorRaw("<!--{$depMsg}-->\n" . $ao->asString('activity:subject'));
}
// TRANS: Title in atom user notice feed. %s is a user name.
$title = sprintf(_("%s timeline"), $user->nickname);
$this->setTitle($title);
$sitename = common_config('site', 'name');
$subtitle = sprintf(_('Updates from %1$s on %2$s!'), $user->nickname, $sitename);
$this->setSubtitle($subtitle);
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
$logo = $avatar ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
$this->setLogo($logo);
$this->setUpdated('now');
$this->addLink(common_local_url('showstream', array('nickname' => $user->nickname)));
$self = common_local_url('ApiTimelineUser', array('id' => $user->id, 'format' => 'atom'));
$this->setId($self);
$this->setSelfLink($self);
$this->addLink(common_local_url('sup', null, null, $user->id), array('rel' => 'http://api.friendfeed.com/2008/03#sup', 'type' => 'application/json'));
}
示例4: __construct
/**
* Constructor
*
* @param User $user the user for the feed
* @param User $cur the current authenticated user, if any
* @param boolean $indent flag to turn indenting on or off
*
* @return void
*/
function __construct($user, $cur = null, $indent = true)
{
parent::__construct($cur, $indent);
$this->user = $user;
if (!empty($user)) {
$profile = $user->getProfile();
$this->addAuthor($profile->nickname, $user->uri);
$this->setActivitySubject($profile->asActivityNoun('subject'));
}
// TRANS: Title in atom user notice feed. %s is a user name.
$title = sprintf(_("%s timeline"), $user->nickname);
$this->setTitle($title);
$sitename = common_config('site', 'name');
$subtitle = sprintf(_('Updates from %1$s on %2$s!'), $user->nickname, $sitename);
$this->setSubtitle($subtitle);
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
$logo = $avatar ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
$this->setLogo($logo);
$this->setUpdated('now');
$this->addLink(common_local_url('showstream', array('nickname' => $user->nickname)));
$self = common_local_url('ApiTimelineUser', array('id' => $user->id, 'format' => 'atom'));
$this->setId($self);
$this->setSelfLink($self);
$this->addLink(common_local_url('sup', null, null, $user->id), array('rel' => 'http://api.friendfeed.com/2008/03#sup', 'type' => 'application/json'));
}
示例5: updateKeys
function updateKeys(&$orig)
{
$this->_connect();
$parts = array();
foreach (array('id', 'service', 'uri', 'nickname') as $k) {
if (strcmp($this->{$k}, $orig->{$k}) != 0) {
$parts[] = $k . ' = ' . $this->_quote($this->{$k});
}
}
if (count($parts) == 0) {
// No changes
return true;
}
$toupdate = implode(', ', $parts);
$table = $this->tableName();
if (common_config('db', 'quote_identifiers')) {
$table = '"' . $table . '"';
}
$qry = 'UPDATE ' . $table . ' SET ' . $toupdate . ' WHERE id = ' . $this->id;
$orig->decache();
$result = $this->query($qry);
if ($result) {
$this->encache();
}
return $result;
}
示例6: handle
/**
* Handle the request
*
* Show the user's groups
*
* @param array $args $_REQUEST data (unused)
*
* @return void
*/
function handle($args)
{
parent::handle($args);
$sitename = common_config('site', 'name');
// TRANS: Used as title in check for group membership. %s is a user name.
$title = sprintf(_("%s's groups"), $this->user->nickname);
$taguribase = TagURI::base();
$id = "tag:{$taguribase}:Groups";
$link = common_local_url('usergroups', array('nickname' => $this->user->nickname));
$subtitle = sprintf(_('%1$s groups %2$s is a member of.'), $sitename, $this->user->nickname);
switch ($this->format) {
case 'xml':
$this->showXmlGroups($this->groups);
break;
case 'rss':
$this->showRssGroups($this->groups, $title, $link, $subtitle);
break;
case 'atom':
$selfuri = common_root_url() . 'api/statusnet/groups/list/' . $this->user->id . '.atom';
$this->showAtomGroups($this->groups, $title, $id, $link, $subtitle, $selfuri);
break;
case 'json':
$this->showJsonGroups($this->groups);
break;
default:
$this->clientError(_('API method not found.'), 404, $this->format);
break;
}
}
示例7: formData
/**
* Data elements of the form
*
* @return void
*/
function formData()
{
$this->out->hidden('subaction', 'apikey');
$this->out->elementStart('fieldset');
$this->out->elementStart('p');
// TRANS: Explanation of what needs to be done to connect to a Yammer network.
$this->out->text(_m('Before we can connect to your Yammer network, ' . 'you will need to register the importer as an ' . 'application authorized to pull data on your behalf. ' . 'This registration will work only for your own network. ' . 'Follow this link to register the app at Yammer; ' . 'you will be prompted to log in if necessary:'));
$this->out->elementEnd('p');
$this->out->elementStart('p', array('class' => 'magiclink'));
$this->out->element('a', array('href' => 'https://www.yammer.com/client_applications/new', 'target' => '_blank'), _m('Open Yammer application registration form'));
$this->out->elementEnd('p');
// TRANS: Instructions.
$this->out->element('p', array(), _m('Copy the consumer key and secret you are given into the form below:'));
$this->out->elementStart('ul', array('class' => 'form_data'));
$this->out->elementStart('li');
// TRANS: Field label for a Yammer consumer key.
$this->out->input('consumer_key', _m('Consumer key:'), common_config('yammer', 'consumer_key'));
$this->out->elementEnd('li');
$this->out->elementStart('li');
// TRANS: Field label for a Yammer consumer secret.
$this->out->input('consumer_secret', _m('Consumer secret:'), common_config('yammer', 'consumer_secret'));
$this->out->elementEnd('li');
$this->out->elementEnd('ul');
// TRANS: Button text for saving a Yammer API registration.
$this->out->submit('submit', _m('BUTTON', 'Save'), 'submit', null, _m('Save the entered consumer key and consumer secret.'));
$this->out->elementEnd('fieldset');
}
示例8: onArgsInitialize
function onArgsInitialize($args)
{
$path = common_config('site', 'path');
if (common_config('site', 'ssl') == 'always' && ($path == '/' || !$path)) {
header('Strict-Transport-Security: max-age=' . $this->max_age . +($this->includeSubDomains ? '; includeSubDomains' : ''));
}
}
示例9: handle
/**
* Class handler.
*
* @param array $args query arguments
*
* @return boolean false if user doesn't exist
*/
function handle($args)
{
parent::handle($args);
$type = $this->trimmed('type');
$short_name = '';
if ($type == 'people') {
$type = 'peoplesearch';
// TRANS: ShortName in the OpenSearch interface when trying to find users.
$short_name = _('People Search');
} else {
$type = 'noticesearch';
// TRANS: ShortName in the OpenSearch interface when trying to find notices.
$short_name = _('Notice Search');
}
header('Content-Type: application/opensearchdescription+xml');
$this->startXML();
$this->elementStart('OpenSearchDescription', array('xmlns' => 'http://a9.com/-/spec/opensearch/1.1/'));
$short_name = common_config('site', 'name') . ' ' . $short_name;
$this->element('ShortName', null, $short_name);
$this->element('Contact', null, common_config('site', 'email'));
$this->element('Url', array('type' => 'text/html', 'method' => 'get', 'template' => str_replace('---', '{searchTerms}', common_local_url($type, array('q' => '---')))));
$this->element('Image', array('height' => 16, 'width' => 16, 'type' => 'image/vnd.microsoft.icon'), common_path('favicon.ico'));
$this->element('Image', array('height' => 50, 'width' => 50, 'type' => 'image/png'), Theme::path('logo.png'));
$this->element('AdultContent', null, 'false');
$this->element('Language', null, common_language());
$this->element('OutputEncoding', null, 'UTF-8');
$this->element('InputEncoding', null, 'UTF-8');
$this->elementEnd('OpenSearchDescription');
$this->endXML();
}
示例10: prepare
/**
* Prepare to run
*/
function prepare($args)
{
parent::prepare($args);
if (!common_config('inboxes', 'enabled')) {
$this->serverError(_('Inboxes must be enabled for groups to work.'));
return false;
}
if (!common_logged_in()) {
$this->clientError(_('You must be logged in to leave a group.'));
return false;
}
$nickname_arg = $this->trimmed('nickname');
$nickname = common_canonical_nickname($nickname_arg);
// Permanent redirect on non-canonical nickname
if ($nickname_arg != $nickname) {
$args = array('nickname' => $nickname);
common_redirect(common_local_url('leavegroup', $args), 301);
return false;
}
if (!$nickname) {
$this->clientError(_('No nickname.'), 404);
return false;
}
$this->group = User_group::staticGet('nickname', $nickname);
if (!$this->group) {
$this->clientError(_('No such group.'), 404);
return false;
}
$cur = common_current_user();
if (!$cur->isMember($this->group)) {
$this->clientError(_('You are not a member of that group.'), 403);
return false;
}
return true;
}
示例11: prepare
/**
* Check for an API key, and throw an exception if it's not set
*
* @param array $args URL and POST params
*
* @return boolean continuation flag
*/
function prepare($args)
{
GNUsocial::setApi(true);
// reduce exception reports to aid in debugging
parent::prepare($args);
if (!common_config('globalapi', 'enabled')) {
throw new ClientException(_('Global API not enabled.'), 403);
}
$apikey = $this->trimmed('apikey');
if (empty($apikey)) {
throw new ClientException(_('No API key.'), 403);
}
$expected = common_config('globalapi', 'key');
if ($expected != $apikey) {
// FIXME: increment a counter by IP address to prevent brute-force
// attacks on the key.
throw new ClientException(_('Bad API key.'), 403);
}
$email = common_canonical_email($this->trimmed('email'));
if (empty($email)) {
throw new ClientException(_('No email address.'));
}
if (!Validate::email($email, common_config('email', 'check_domain'))) {
throw new ClientException(_('Invalid email address.'));
}
$this->email = $email;
return true;
}
示例12: show
/**
* Show the menu
*
* @return void
*/
function show()
{
$this->actionName = $this->action->trimmed('action');
$this->action->elementStart('ul', array('class' => 'nav'));
if (Event::handle('StartPublicGroupNav', array($this))) {
if (!common_config('singleuser', 'enabled')) {
// TRANS: Menu item in search group navigation panel.
$this->out->menuItem(common_local_url('public'), _m('MENU', 'Public'), _('Public timeline'), $this->actionName == 'public', 'nav_timeline_public');
}
// TRANS: Menu item in search group navigation panel.
$this->out->menuItem(common_local_url('groups'), _m('MENU', 'Groups'), _('User groups'), $this->actionName == 'groups', 'nav_groups');
if (!common_config('performance', 'high')) {
// TRANS: Menu item in search group navigation panel.
$this->out->menuItem(common_local_url('publictagcloud'), _m('MENU', 'Recent tags'), _('Recent tags'), $this->actionName == 'publictagcloud', 'nav_recent-tags');
}
if (count(common_config('nickname', 'featured')) > 0) {
// TRANS: Menu item in search group navigation panel.
$this->out->menuItem(common_local_url('featured'), _m('MENU', 'Featured'), _('Featured users'), $this->actionName == 'featured', 'nav_featured');
}
if (!common_config('singleuser', 'enabled')) {
// TRANS: Menu item in search group navigation panel.
$this->out->menuItem(common_local_url('favorited'), _m('MENU', 'Popular'), _('Popular notices'), $this->actionName == 'favorited', 'nav_timeline_favorited');
}
Event::handle('EndPublicGroupNav', array($this));
}
$this->action->elementEnd('ul');
}
示例13: getTags
function getTags()
{
$profile = Profile::current();
$keypart = sprintf('Inbox:notice_tag:%d:%d', $this->user->id, $profile->id);
$tag = Memcached_DataObject::cacheGet($keypart);
if ($tag === false) {
$stream = new InboxNoticeStream($this->user, $profile);
$ids = $stream->getNoticeIds(0, Inbox::MAX_NOTICES, null, null);
if (empty($ids)) {
$tag = array();
} else {
$weightexpr = common_sql_weight('notice_tag.created', common_config('tag', 'dropoff'));
// @fixme should we use the cutoff too? Doesn't help with indexing per-user.
$qry = 'SELECT notice_tag.tag, ' . $weightexpr . ' as weight ' . 'FROM notice_tag JOIN notice ' . 'ON notice_tag.notice_id = notice.id ' . 'WHERE notice.id in (' . implode(',', $ids) . ')' . 'GROUP BY notice_tag.tag ' . 'ORDER BY weight DESC ';
$limit = TAGS_PER_SECTION;
$offset = 0;
if (common_config('db', 'type') == 'pgsql') {
$qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset;
} else {
$qry .= ' LIMIT ' . $offset . ', ' . $limit;
}
$t = new Notice_tag();
$t->query($qry);
$tag = array();
while ($t->fetch()) {
$tag[] = clone $t;
}
}
Memcached_DataObject::cacheSet($keypart, $tag, 3600);
}
return new ArrayWrapper($tag);
}
示例14: getNoticeIds
function getNoticeIds($offset, $limit, $since_id, $max_id)
{
$notice = new Notice();
$notice->selectAdd();
// clears it
$notice->selectAdd('id');
$notice->orderBy('created DESC, id DESC');
if (!is_null($offset)) {
$notice->limit($offset, $limit);
}
if (common_config('public', 'localonly')) {
$notice->whereAdd('is_local = ' . Notice::LOCAL_PUBLIC);
} else {
// -1 == blacklisted, -2 == gateway (i.e. Twitter)
$notice->whereAdd('is_local !=' . Notice::LOCAL_NONPUBLIC);
$notice->whereAdd('is_local !=' . Notice::GATEWAY);
}
Notice::addWhereSinceId($notice, $since_id);
Notice::addWhereMaxId($notice, $max_id);
$ids = array();
if ($notice->find()) {
while ($notice->fetch()) {
$ids[] = $notice->id;
}
}
$notice->free();
$notice = NULL;
return $ids;
}
示例15: getStream
protected function getStream()
{
if (!$this->scoped instanceof Profile && common_config('public', 'localonly')) {
$this->clientError(_('Network wide public feed is not permitted without authorization'), 403);
}
return new NetworkPublicNoticeStream($this->scoped);
}