本文整理汇总了PHP中i18n::s方法的典型用法代码示例。如果您正苦于以下问题:PHP i18n::s方法的具体用法?PHP i18n::s怎么用?PHP i18n::s使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类i18n
的用法示例。
在下文中一共展示了i18n::s方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: layout
/**
* list sections
*
* @param resource the SQL result
* @return an array of $url => (NULL, $title, NULL, 'section_123', NULL, 'visit this section')
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// hovering label
$href_title = i18n::s('View the section');
// we return an array of ($url => $attributes)
$items = array();
// process all items in the list
while ($item = SQL::fetch($result)) {
// the url to view this item
$url = Sections::get_permalink($item);
// initialize variables
$prefix = $suffix = '';
// list all components for this item
$items[$url] = array($prefix, ucfirst(Skin::strip($item['title'], 30)), $suffix, 'section_' . $item['id'], NULL, $href_title);
}
// end of processing
SQL::free($result);
return $items;
}
示例2: get_fields
/**
* preserve content across page modification
*
* @see overlays/overlay.php
*
* @param the hosting attributes
* @return a list of ($label, $input, $hint)
*/
function get_fields($host, $field_pos = NULL)
{
global $context;
// form fields
$fields = array();
// item identifier
if (!isset($this->attributes['overlay_id'])) {
$this->attributes['overlay_id'] = '';
}
// only associates can change the overlay id
if (Surfer::is_associate()) {
// isset($host['anchor']) && ($parent =& Anchors::get($host['anchor'])) && $parent->is_assigned()) {
$label = i18n::s('Overlay identifier');
$input = '<input type="text" name="overlay_id" value="' . encode_field($this->attributes['overlay_id']) . '" />';
} else {
$label = 'hidden';
$input = '<input type="hidden" name="overlay_id" value="' . encode_field($this->attributes['overlay_id']) . '" />';
}
// hidden attributes
foreach ($this->attributes as $name => $value) {
if (preg_match('/_content$/', $name)) {
$input .= '<input type="hidden" name="' . encode_field($name) . '" value="' . encode_field($value) . '" />';
}
}
// we do have something to preserve
$fields[] = array($label, $input);
// job done
return $fields;
}
示例3: layout
/**
* list links
*
* @param resource the SQL result
* @return array of resulting items, or NULL
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($url => $attributes)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
while ($item = SQL::fetch($result)) {
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// url is the link itself -- hack for xhtml compliance
$url = str_replace('&', '&', $item['link_url']);
// initialize variables
$prefix = $suffix = '';
// flag links that are dead, or created or updated very recently
if ($item['edit_date'] >= $context['fresh']) {
$suffix = NEW_FLAG;
}
// make a label
$label = Links::clean($item['title'], $item['link_url']);
// the main anchor link
if (is_object($anchor)) {
$suffix .= ' - <span class="details">' . sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()))) . '</span>';
}
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
}
// end of processing
SQL::free($result);
return $items;
}
示例4: check_file
function check_file($node)
{
global $context;
global $footprints;
$key = substr($node, strlen($context['path_to_root']));
// no extension to check
if (strpos($key, '.') === FALSE) {
} elseif (!strncmp($node, 'scripts/staging', 16)) {
} elseif (!strcmp($key, 'footprints.php')) {
} elseif (!strncmp(substr($key, -9), 'index.php', 9) && ($content = Safe::file_get_contents($node)) && !strcmp($content, Safe::mkdir_index_content())) {
} elseif (!strncmp($key, 'temporary/cache_i18n_locale_', 28)) {
} elseif (!strncmp(substr($key, -4), '.php', 4)) {
// one of the parameter files created by yacs
if (preg_match('/parameters\\/(agents|control|feeds|files|hooks|letters|root|scripts|services|skins|users|virtual_.+)\\.include\\.php$/i', $key)) {
} elseif (isset($footprints[$key])) {
$expected = $footprints[$key];
$actual = Scripts::hash($node);
if ($expected[0] != $actual[0] || $expected[1] != $actual[1]) {
$context['text'] .= sprintf(i18n::s('ERROR: File %s is missing or corrupted.'), $key) . BR . "\n";
}
} else {
$context['text'] .= sprintf(i18n::s('File %s is not part of Yacs.'), $key) . BR . "\n";
}
// not a safe file
} elseif (!preg_match('/\\.(bak|bat|css|done|dtd|fdb|flv|gif|ico|jpeg|jpg|js|jsmin|htc|htm|html|mo|off|on|pdf|png|po|pot|reg|sh|sql|swf|tgz|txt|xml|zip)$/i', $key)) {
$context['text'] .= sprintf(i18n::s('File %s is not part of Yacs.'), $key) . BR . "\n";
}
}
示例5: elseif
/**
* display content below main panel
*
* Everything is in a separate panel
*
* @param array the hosting record, if any
* @return some HTML to be inserted into the resulting page
*/
function &get_trailer_text($host = NULL)
{
$text = '';
// display the following only if at least one comment has been attached to this page
if (is_object($this->anchor) && !Comments::count_for_anchor($this->anchor->get_reference())) {
return $text;
}
// ask the surfer if he has not answered yet, and if the page has not been locked
$ask = TRUE;
if (isset($_COOKIE['rating_' . $host['id']])) {
$ask = FALSE;
} elseif (isset($host['locked']) && $host['locked'] == 'Y') {
$ask = FALSE;
}
// ask the surfer
if ($ask) {
$text = '<p style="line-height: 2.5em;">' . i18n::s('Has this page been useful to you?') . ' ' . Skin::build_link(Articles::get_url($host['id'], 'like'), i18n::s('Yes'), 'button') . ' ' . Skin::build_link(Articles::get_url($host['id'], 'dislike'), i18n::s('No'), 'button') . '</p>';
// or report on results
} elseif ($host['rating_count']) {
$text = '<p>' . Skin::build_rating_img((int) round($host['rating_sum'] / $host['rating_count'])) . ' ' . sprintf(i18n::ns('%d rating', '%d ratings', $host['rating_count']), $host['rating_count']) . '</p>';
}
// add a title
if ($text) {
$text = Skin::build_box(i18n::s('Feed-back'), $text);
}
// done
return $text;
}
示例6: layout
/**
* list versions
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// we return an array of ($url => $attributes)
$items = array();
// process all items in the list
while ($item = SQL::fetch($result)) {
// initialize variables
$prefix = $suffix = $icon = '';
// the url to view this item
$url = '_' . $item['id'];
// Versions::get_url($item['id']);
// version description
$label = sprintf(i18n::s('edited by %s %s'), ucfirst($item['edit_name']), Skin::build_date($item['edit_date']));
// command to view this version
$suffix .= ' ' . Skin::build_link(Versions::get_url($item['id'], 'view'), i18n::s('compare to current version'), 'button');
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'version', $icon);
}
// end of processing
SQL::free($result);
return $items;
}
示例7: layout
/**
* list articles
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return some text
$text = '';
// empty list
if (!SQL::count($result)) {
return $text;
}
// clear flows
$text .= '<br style="clear: left" />';
// process all items in the list
while ($item = SQL::fetch($result)) {
// get the related overlay
$overlay = Overlay::load($item, 'article:' . $item['id']);
// the url to view this item
$url = Articles::get_permalink($item);
// use the title to label the link
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['title']);
}
// the hovering title
if ($item['introduction'] && $context['skins_with_details'] == 'Y') {
$hover = strip_tags(Codes::beautify_introduction($item['introduction']));
} else {
$hover = i18n::s('View the page');
}
// title is a link to the target article
$title =& Skin::build_link($url, $title, 'basic', $hover);
// use the thumbnail for this article
if ($icon = trim($item['thumbnail_url'])) {
// fix relative path
if (!preg_match('/^(\\/|http:|https:|ftp:)/', $icon)) {
$icon = $context['url_to_root'] . $icon;
}
// use parameter of the control panel for this one
$options = '';
if (isset($context['classes_for_thumbnail_images'])) {
$options = 'class="' . $context['classes_for_thumbnail_images'] . '" ';
}
// build the complete HTML element
$icon = '<img src="' . $icon . '" alt="" title="' . encode_field($hover) . '" ' . $options . ' />';
// use default icon if nothing to display
} else {
$icon = MAP_IMG;
}
// use the image as a link to the target page
$icon =& Skin::build_link($url, $icon, 'basic', $hover);
// add a floating box
$text .= Skin::build_box($title, $icon, 'floating');
}
// clear flows
$text .= '<br style="clear: left" />';
// end of processing
SQL::free($result);
return $text;
}
示例8: layout
/**
* list servers
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// we return an array of ($url => $attributes)
$items = array();
// process all items in the list
while ($item = SQL::fetch($result)) {
// initialize variables
$prefix = $suffix = $icon = '';
// the url to view this item
$url = Servers::get_url($item['id']);
// use the title as a label
$label = Skin::strip($item['title'], 10);
// flag files uploaded recently
if ($item['edit_date'] >= $context['fresh']) {
$prefix = NEW_FLAG . $prefix;
}
// description
if ($item['description']) {
$suffix .= ' ' . ucfirst(trim($item['description']));
}
// the menu bar for associates and poster
if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
$menu = array(Servers::get_url($item['id'], 'edit') => i18n::s('Edit'), Servers::get_url($item['id'], 'delete') => i18n::s('Delete'));
$suffix .= ' ' . Skin::build_list($menu, 'menu');
}
// add a separator
if ($suffix) {
$suffix = ' - ' . $suffix;
}
// append details to the suffix
$suffix .= BR . '<span class="details">';
// details
$details = array();
// item poster
if ($item['edit_name']) {
$details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
}
// the edition date
$details[] = Skin::build_date($item['edit_date']);
// all details
if (count($details)) {
$suffix .= ucfirst(implode(', ', $details)) . "\n";
}
// end of details
$suffix .= '</span>';
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'server', $icon);
}
// end of processing
SQL::free($result);
return $items;
}
示例9: layout
/**
* list comments as successive notes in a thread
*
* @param resource the SQL result
* @return string the rendered text
**/
function layout($result)
{
global $context;
// we return formatted text
$text = '';
// empty list
if (!SQL::count($result)) {
return $text;
}
// build a list of comments
while ($item = SQL::fetch($result)) {
// automatic notification
if ($item['type'] == 'notification') {
$text = '<dd class="thread_other" style="font-style: italic;">' . ucfirst(trim($item['description'])) . '</dd>' . $text;
} else {
// link to user profile -- open links in separate window to enable side browsing of participant profiles
if ($item['create_id']) {
if ($user = Users::get($item['create_id']) && $user['full_name']) {
$hover = $user['full_name'];
} else {
$hover = NULL;
}
$author = Users::get_link($item['create_name'], $item['create_address'], $item['create_id'], TRUE, $hover);
} else {
$author = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'], TRUE);
}
// differentiate my posts from others
if (Surfer::get_id() && $item['create_id'] == Surfer::get_id()) {
$style = ' class="thread_me"';
} else {
$style = ' class="thread_other"';
}
// a clickable label
$stamp = '#';
// flag old items on same day
if (!strncmp($item['edit_date'], gmstrftime('%Y-%m-%d %H:%M:%S', time()), 10)) {
$stamp = Skin::build_time($item['edit_date']);
} else {
$stamp = Skin::build_date($item['edit_date']);
}
// append this at the end of the comment
$stamp = ' <div style="float: right; font-size: x-small">' . Skin::build_link(Comments::get_url($item['id']), $stamp, 'basic', i18n::s('Edit')) . '</div>';
// package everything --change order to get oldest first
$text = '<dt' . $style . '>' . $author . '</dt><dd' . $style . '>' . $stamp . ucfirst(trim($item['description'])) . '</dd>' . $text;
}
}
// end of processing
SQL::free($result);
// finalize the returned definition list
if ($text) {
$text = '<dl>' . $text . '</dl>';
}
// process yacs codes
$text = Codes::beautify($text);
return $text;
}
示例10: layout
/**
* list files
*
* @param resource the SQL result
* @return array of resulting items, or NULL
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($url => $attributes)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// sanity check
if (!isset($this->layout_variant)) {
$this->layout_variant = 'full';
}
// process all items in the list
while ($item = SQL::fetch($result)) {
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// download the file directly
$url = Files::get_url($item['id'], 'fetch', $item['file_name']);
// initialize variables
$prefix = $suffix = '';
// flag files that are dead, or created or updated very recently
if ($item['create_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= UPDATED_FLAG;
}
// signal restricted and private files
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// file title or file name
$label = Codes::beautify_title($item['title']);
if (!$label) {
$label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name']));
}
// the main anchor link, except on user profiles
if (is_object($anchor) && $anchor->get_reference() != $this->focus) {
$suffix .= ' - <span class="details">' . sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()))) . '</span>';
}
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
}
// end of processing
SQL::free($result);
return $items;
}
示例11: sprintf
/**
* list participants
*
* @see overlays/overlay.php
*
* @param array the hosting record
* @return some HTML to be inserted into the resulting page
*/
function &get_list_text($host = NULL)
{
global $context;
// we return some text
$text = '';
$to_avoid = NULL;
if ($id = Surfer::get_id()) {
$to_avoid = 'user:' . $id;
}
// page editors, except target surfer
if ($friends =& Members::list_users_by_posts_for_member('article:' . $host['id'], 0, USERS_LIST_SIZE, 'comma', $to_avoid)) {
$text = '<p class="details">' . sprintf(i18n::s('with %s'), Skin::build_list($friends, 'comma')) . '</p>';
}
return $text;
}
示例12: render_iframe
/**
* render an iframe
*
* @param string URL to be embedded
* @param string iframe parameters
* @return string the rendered text
**/
public static function render_iframe($url, $variant)
{
global $context;
// split parameters
$attributes = preg_split("/\\s*,\\s*/", $variant, 2);
// set a default size
if (!isset($attributes[0])) {
$attributes[0] = 320;
}
if (!isset($attributes[1])) {
$attributes[1] = 240;
}
$text = '<iframe src="' . $url . '" style="width: ' . $attributes[0] . 'px; height: ' . $attributes[1] . 'px" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0">' . "\n" . i18n::s('Your browser does not accept iframes') . '</iframe>';
return $text;
}
示例13: login
/**
* login
*
* The script checks provided name and password against remote server.
*
* This is done by transmitting the user name and the password
* while opening a FTP session to the server.
*
* @param string the nickname of the user
* @param string the submitted password
* @return TRUE on succesful authentication, FALSE othewise
*/
function login($name, $password)
{
global $context;
// we need some parameters
if (!isset($this->attributes['authenticator_parameters']) || !$this->attributes['authenticator_parameters']) {
Logger::error(i18n::s('Please provide parameters to the authenticator.'));
return FALSE;
}
// prepare network parameters
$server = $this->attributes['authenticator_parameters'];
if (strstr($server, ':')) {
list($server, $port) = explode(':', $server, 2);
} else {
$port = 21;
}
// open network socket
if (!($handle = Safe::fsockopen($server, $port))) {
Logger::error(sprintf(i18n::s('Impossible to connect to %.'), $this->attributes['authenticator_parameters']));
return FALSE;
}
// read welcome banner
if (!($line = fgets($handle, 256)) || !strstr($line, '2')) {
fclose($handle);
Logger::error(sprintf(i18n::s('Invalid banner message from %s.'), $this->attributes['authenticator_parameters']));
return FALSE;
}
// submit name
fputs($handle, "USER {$username}\r\n");
if (!($line = fgets($handle, 256)) || !strstr($line, '3')) {
fclose($handle);
Logger::error(sprintf(i18n::s('Impossible to submit name to %s.'), $this->attributes['authenticator_parameters']));
return FALSE;
}
// submit password
fputs($handle, "PASS {$password}\r\n");
if (!($line = fgets($handle, 256)) || !strstr($line, '2')) {
fclose($handle);
Logger::error(sprintf(i18n::s('Impossible to submit password to %s.'), $this->attributes['authenticator_parameters']));
return FALSE;
}
// close ftp session
fputs($handle, "QUIT\r\n");
fclose($handle);
// this is a valid user
return TRUE;
}
示例14: allow
/**
* check access rights
*
* @param string script name
* @paral string target anchor, if any
* @return boolean FALSE if access is denied, TRUE otherwise
*/
function allow($script, $anchor = NULL)
{
global $context;
// limit the scope of our check
if ($script != 'files/view.php' && $script != 'files/fetch.php' && $script != 'files/fetch_all.php' && $script != 'files/stream.php') {
return TRUE;
}
// sanity check
if (!$anchor) {
die(i18n::s('No anchor has been found.'));
}
// stop here if the agreement has been gathered previously
if (isset($_SESSION['agreements']) && is_array($agreements = $_SESSION['agreements'])) {
foreach ($agreements as $agreement) {
if ($agreement == $anchor) {
return TRUE;
}
}
}
// which agreement?
if (!$this->parameters) {
die(sprintf(i18n::s('No parameter has been provided to %s'), 'behaviors/agree_on_file_access'));
}
// do we have a related file to display?
if (!is_readable($context['path_to_root'] . 'behaviors/agreements/' . $this->parameters)) {
die(sprintf(i18n::s('Bad parameter to behavior <code>%s %s</code>'), 'agree_on_file_access', $this->parameters));
}
// splash message
$context['text'] .= '<p class="agreement">' . i18n::s('Before moving forward, please read following text and express yourself at the end of the page.') . '</p><hr/>' . "\n";
// load and display the file to be displayed
$context['text'] .= Codes::beautify(Safe::file_get_contents($context['path_to_root'] . 'behaviors/agreements/' . $this->parameters));
// target link to record agreement
if ($context['with_friendly_urls'] == 'Y') {
$agree_link = 'behaviors/agreements/agree.php/' . rawurlencode($anchor);
} else {
$agree_link = 'behaviors/agreements/agree.php?id=' . urlencode($anchor);
}
// display confirmation buttons at the end of the agreement
$context['text'] .= '<hr/><p class="agreement">' . i18n::s('Do you agree?');
$context['text'] .= ' ' . Skin::build_link($agree_link, i18n::s('Yes'), 'button');
$context['text'] .= ' ' . Skin::build_link('behaviors/agreements/deny.php', i18n::s('No'), 'button') . '</p>' . "\n";
// render the skin based only on text provided by this behavior
render_skin();
exit;
}
示例15: render
public function render($matches)
{
$count = isset($matches[0]) ? $matches[0] : 20;
// sanity check
if (!(int) $count) {
$count = 20;
}
// query the database and layout that stuff
if (!($text = Members::list_categories_by_count_for_anchor(NULL, 0, $count, 'cloud'))) {
$text = '<p>' . i18n::s('No item has been found.') . '</p>';
}
// we have an array to format
if (is_array($text)) {
$text = Skin::build_list($text, '2-columns');
}
// job done
return $text;
}