本文整理汇总了PHP中common_language函数的典型用法代码示例。如果您正苦于以下问题:PHP common_language函数的具体用法?PHP common_language怎么用?PHP common_language使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了common_language函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: common_init_language
function common_init_language()
{
mb_internal_encoding('UTF-8');
$language = common_language();
// So we don't have to make people install the gettext locales
$locale_set = common_init_locale($language);
bindtextdomain("laconica", common_config('site', 'locale_path'));
bind_textdomain_codeset("laconica", "UTF-8");
textdomain("laconica");
setlocale(LC_CTYPE, 'C');
if (!$locale_set) {
common_log(LOG_INFO, 'Language requested:' . $language . ' - locale could not be set:', __FILE__);
}
}
示例3: common_init_language
function common_init_language()
{
mb_internal_encoding('UTF-8');
// Note that this setlocale() call may "fail" but this is harmless;
// gettext will still select the right language.
$language = common_language();
$locale_set = common_init_locale($language);
if (!$locale_set) {
// The requested locale doesn't exist on the system.
//
// gettext seems very picky... We first need to setlocale()
// to a locale which _does_ exist on the system, and _then_
// we can set in another locale that may not be set up
// (say, ga_ES for Galego/Galician) it seems to take it.
//
// For some reason C and POSIX which are guaranteed to work
// don't do the job. en_US.UTF-8 should be there most of the
// time, but not guaranteed.
$ok = common_init_locale("en_US");
if (!$ok) {
// Try to find a complete, working locale...
// @fixme shelling out feels awfully inefficient
// but I don't think there's a more standard way.
$all = `locale -a`;
foreach (explode("\n", $all) as $locale) {
if (preg_match('/\\.utf[-_]?8$/i', $locale)) {
$ok = setlocale(LC_ALL, $locale);
if ($ok) {
break;
}
}
}
if (!$ok) {
common_log(LOG_ERR, "Unable to find a UTF-8 locale on this system; UI translations may not work.");
}
}
$locale_set = common_init_locale($language);
}
common_init_gettext();
}
示例4: etag
/**
* An entity tag for this notice
*
* Returns an Etag based on the action name, language, and
* timestamps of the notice
*
* @return string etag
*/
function etag()
{
if (!empty($this->notice)) {
return '"' . implode(':', array($this->arg('action'), common_user_cache_hash($this->auth_user), common_language(), $this->notice->id, strtotime($this->notice->created))) . '"';
}
return null;
}
示例5: showContent
/**
* Content area of the page
*
* Shows a form for uploading an avatar.
*
* @return void
*/
function showContent()
{
$user = common_current_user();
$profile = $user->getProfile();
$this->elementStart('form', array('method' => 'post', 'id' => 'form_settings_profile', 'class' => 'form_settings', 'action' => common_local_url('profilesettings')));
$this->elementStart('fieldset');
// TRANS: Profile settings form legend.
$this->element('legend', null, _('Profile information'));
$this->hidden('token', common_session_token());
// too much common patterns here... abstractable?
$this->elementStart('ul', 'form_data');
if (Event::handle('StartProfileFormData', array($this))) {
$this->elementStart('li');
// TRANS: Field label in form for profile settings.
$this->input('nickname', _('Nickname'), $this->arg('nickname') ? $this->arg('nickname') : $profile->nickname, _('1-64 lowercase letters or numbers, no punctuation or spaces.'));
$this->elementEnd('li');
$this->elementStart('li');
// TRANS: Field label in form for profile settings.
$this->input('fullname', _('Full name'), $this->arg('fullname') ? $this->arg('fullname') : $profile->fullname);
$this->elementEnd('li');
$this->elementStart('li');
// TRANS: Field label in form for profile settings.
$this->input('homepage', _('Homepage'), $this->arg('homepage') ? $this->arg('homepage') : $profile->homepage, _('URL of your homepage, blog, or profile on another site.'));
$this->elementEnd('li');
$this->elementStart('li');
$maxBio = Profile::maxBio();
if ($maxBio > 0) {
// TRANS: Tooltip for field label in form for profile settings. Plural
// TRANS: is decided by the number of characters available for the
// TRANS: biography (%d).
$bioInstr = sprintf(_m('Describe yourself and your interests in %d character.', 'Describe yourself and your interests in %d characters.', $maxBio), $maxBio);
} else {
// TRANS: Tooltip for field label in form for profile settings.
$bioInstr = _('Describe yourself and your interests.');
}
// TRANS: Text area label in form for profile settings where users can provide
// TRANS: their biography.
$this->textarea('bio', _('Bio'), $this->arg('bio') ? $this->arg('bio') : $profile->bio, $bioInstr);
$this->elementEnd('li');
$this->elementStart('li');
// TRANS: Field label in form for profile settings.
$this->input('location', _('Location'), $this->arg('location') ? $this->arg('location') : $profile->location, _('Where you are, like "City, State (or Region), Country".'));
$this->elementEnd('li');
if (common_config('location', 'share') == 'user') {
$this->elementStart('li');
// TRANS: Checkbox label in form for profile settings.
$this->checkbox('sharelocation', _('Share my current location when posting notices'), $this->arg('sharelocation') ? $this->arg('sharelocation') : $user->shareLocation());
$this->elementEnd('li');
}
Event::handle('EndProfileFormData', array($this));
$this->elementStart('li');
// TRANS: Field label in form for profile settings.
$this->input('tags', _('Tags'), $this->arg('tags') ? $this->arg('tags') : implode(' ', $user->getSelfTags()), _('Tags for yourself (letters, numbers, -, ., and _), comma- or space- separated.'));
$this->elementEnd('li');
$this->elementStart('li');
$language = common_language();
// TRANS: Dropdownlist label in form for profile settings.
$this->dropdown('language', _('Language'), get_nice_language_list(), _('Preferred language.'), false, $language);
$this->elementEnd('li');
$timezone = common_timezone();
$timezones = array();
foreach (DateTimeZone::listIdentifiers() as $k => $v) {
$timezones[$v] = $v;
}
$this->elementStart('li');
// TRANS: Dropdownlist label in form for profile settings.
$this->dropdown('timezone', _('Timezone'), $timezones, _('What timezone are you normally in?'), true, $timezone);
$this->elementEnd('li');
$this->elementStart('li');
$this->checkbox('autosubscribe', _('Automatically subscribe to whoever ' . 'subscribes to me (best for non-humans)'), $this->arg('autosubscribe') ? $this->boolean('autosubscribe') : $user->autosubscribe);
$this->elementEnd('li');
$this->elementStart('li');
$this->dropdown('subscribe_policy', _('Subscription policy'), array(User::SUBSCRIBE_POLICY_OPEN => _('Let anyone follow me'), User::SUBSCRIBE_POLICY_MODERATE => _('Ask me first')), _('Whether other users need your permission to follow your updates.'), false, empty($user->subscribe_policy) ? User::SUBSCRIBE_POLICY_OPEN : $user->subscribe_policy);
$this->elementEnd('li');
}
$this->elementStart('li');
$this->checkbox('private_stream', _('Make updates visible only to my followers'), $this->arg('private_stream') ? $this->boolean('private_stream') : $user->private_stream);
$this->elementEnd('li');
$this->elementEnd('ul');
// TRANS: Button to save input in profile settings.
$this->submit('save', _m('BUTTON', 'Save'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
}
示例6: etag
/**
* An entity tag for this page
*
* Shows the ETag for the page, based on the notice ID and timestamps
* for the notice, profile, and avatar. It's weak, since we change
* the date text "one hour ago", etc.
*
* @return string etag
*/
function etag()
{
$avtime = $this->avatar ? strtotime($this->avatar->modified) : 0;
return 'W/"' . implode(':', array($this->arg('action'), common_user_cache_hash(), common_language(), $this->notice->id, strtotime($this->notice->created), strtotime($this->profile->modified), $avtime)) . '"';
}
示例7: etag
/**
* Return etag, if applicable.
*
* MAY override
*
* @return string etag http header
*/
function etag()
{
return 'W/"' . implode(':', array($this->arg('action'), common_user_cache_hash(), common_language(), $this->file->id)) . '"';
}
示例8: showContent
/**
* Content area of the page
*
* Shows a form for uploading an avatar.
*
* @return void
*/
function showContent()
{
$user = common_current_user();
$profile = $user->getProfile();
$this->elementStart('form', array('method' => 'post', 'id' => 'form_settings_profile', 'class' => 'form_settings', 'action' => common_local_url('profilesettings')));
$this->elementStart('fieldset');
$this->element('legend', null, _('Profile information'));
$this->hidden('token', common_session_token());
// too much common patterns here... abstractable?
$this->elementStart('ul', 'form_data');
if (Event::handle('StartProfileFormData', array($this))) {
$this->elementStart('li');
$this->input('nickname', _('Nickname'), $this->arg('nickname') ? $this->arg('nickname') : $profile->nickname, _('1-64 lowercase letters or numbers, no punctuation or spaces'));
$this->elementEnd('li');
$this->elementStart('li');
$this->input('fullname', _('Full name'), $this->arg('fullname') ? $this->arg('fullname') : $profile->fullname);
$this->elementEnd('li');
$this->elementStart('li');
$this->input('homepage', _('Homepage'), $this->arg('homepage') ? $this->arg('homepage') : $profile->homepage, _('URL of your homepage, blog, or profile on another site'));
$this->elementEnd('li');
$this->elementStart('li');
$maxBio = Profile::maxBio();
if ($maxBio > 0) {
$bioInstr = sprintf(_('Describe yourself and your interests in %d chars'), $maxBio);
} else {
$bioInstr = _('Describe yourself and your interests');
}
$this->textarea('bio', _('Bio'), $this->arg('bio') ? $this->arg('bio') : $profile->bio, $bioInstr);
$this->elementEnd('li');
$this->elementStart('li');
$this->input('location', _('Location'), $this->arg('location') ? $this->arg('location') : $profile->location, _('Where you are, like "City, State (or Region), Country"'));
$this->elementEnd('li');
if (common_config('location', 'share') == 'user') {
$this->elementStart('li');
$this->checkbox('sharelocation', _('Share my current location when posting notices'), $this->arg('sharelocation') ? $this->arg('sharelocation') : $user->shareLocation());
$this->elementEnd('li');
}
Event::handle('EndProfileFormData', array($this));
$this->elementStart('li');
$this->input('tags', _('Tags'), $this->arg('tags') ? $this->arg('tags') : implode(' ', $user->getSelfTags()), _('Tags for yourself (letters, numbers, -, ., and _), comma- or space- separated'));
$this->elementEnd('li');
$this->elementStart('li');
$language = common_language();
$this->dropdown('language', _('Language'), get_nice_language_list(), _('Preferred language'), false, $language);
$this->elementEnd('li');
$timezone = common_timezone();
$timezones = array();
foreach (DateTimeZone::listIdentifiers() as $k => $v) {
$timezones[$v] = $v;
}
$this->elementStart('li');
$this->dropdown('timezone', _('Timezone'), $timezones, _('What timezone are you normally in?'), true, $timezone);
$this->elementEnd('li');
$this->elementStart('li');
$this->checkbox('autosubscribe', _('Automatically subscribe to whoever ' . 'subscribes to me (best for non-humans)'), $this->arg('autosubscribe') ? $this->boolean('autosubscribe') : $user->autosubscribe);
$this->elementEnd('li');
}
$this->elementEnd('ul');
$this->submit('save', _('Save'));
$this->elementEnd('fieldset');
$this->elementEnd('form');
}
示例9: primaryCssLink
function primaryCssLink($mainTheme = null, $media = null)
{
$theme = new Theme($mainTheme);
// Some themes may have external stylesheets, such as using the
// Google Font APIs to load webfonts.
foreach ($theme->getExternals() as $url) {
$this->cssLink($url, $mainTheme, $media);
}
// If the currently-selected theme has dependencies on other themes,
// we'll need to load their display.css files as well in order.
$baseThemes = $theme->getDeps();
foreach ($baseThemes as $baseTheme) {
$this->cssLink('css/display.css', $baseTheme, $media);
}
$this->cssLink('css/display.css', $mainTheme, $media);
// Additional styles for RTL languages
if (is_rtl(common_language())) {
if (file_exists(Theme::file('css/rtl.css'))) {
$this->cssLink('css/rtl.css', $mainTheme, $media);
}
}
}
示例10: negotiateLanguage
function negotiateLanguage($filenames, $defaultFilename = null)
{
// XXX: do this better
$langcode = common_language();
foreach ($filenames as $filename) {
if (preg_match('/\\.' . $langcode . '$/', $filename)) {
return $filename;
}
}
return $defaultFilename;
}
示例11: etag
/**
* An entity tag for this list
*
* Returns an Etag based on the action name, language, user ID and
* timestamps of the first and last list the user has joined
*
* @return string etag
*/
function etag()
{
if (!empty($this->list)) {
return '"' . implode(':', array($this->arg('action'), common_language(), $this->user->id, strtotime($this->list->created), strtotime($this->list->modified))) . '"';
}
return null;
}
示例12: getName
/**
* Get the name for this location in the given language
*
* @param string $language language to use, default = current
*
* @return string location name or null if not found
*/
function getName($language = null)
{
if (is_null($language)) {
$language = common_language();
}
if (array_key_exists($language, $this->names)) {
return $this->names[$language];
} else {
$name = null;
Event::handle('LocationNameLanguage', array($this, $language, &$name));
if (!empty($name)) {
$this->names[$language] = $name;
return $name;
}
}
}
示例13: etag
/**
* An entity tag for this action
*
* Returns an Etag based on the action name, language, user ID, and
* timestamps of the first and last profiles in the subscriptions list
* There's also an indicator to show whether this action is being called
* as /api/statuses/(friends|followers) or /api/(friends|followers)/ids
*
* @return string etag
*/
function etag()
{
if (!empty($this->profiles) && count($this->profiles) > 0) {
$last = count($this->profiles) - 1;
return '"' . implode(':', array($this->arg('action'), common_language(), $this->user->id, isset($this->ids_only) ? 'IDs' : 'Profiles', strtotime($this->profiles[0]->created), strtotime($this->profiles[$last]->created))) . '"';
}
return null;
}
示例14: define
<?php
define('FLUIDFRAME', true);
define('INSTALLDIR', dirname(__FILE__));
require_once INSTALLDIR . '/lib/core.php';
try {
Fluidframe::init();
$_lang = common_language();
} catch (Exception $e) {
common_error($e->getTraceAsString());
$error = new ErrorAction('en');
$error->setErrorMessage(500, $e->getMessage());
$error->handle();
}
// get the incoming request URL path
$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
// get the route based on the path and server
$route = $router->match($path, $_SERVER);
if (empty($route)) {
$error = new ErrorAction($_lang);
$error->setErrorMessage(404, 'Unkown page');
$error->handle();
}
// does the route indicate an action?
if (isset($route->params['action'])) {
// take the action class directly from the route
$action = $route->params['action'];
} else {
// use a default action class
$action = 'home';
}
示例15: getLanguage
function getLanguage()
{
// FIXME: correct language for interface
return common_language();
}