本文整理汇总了PHP中Language::getAll方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::getAll方法的具体用法?PHP Language::getAll怎么用?PHP Language::getAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Language
的用法示例。
在下文中一共展示了Language::getAll方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: edit
/**
* Edit a role
*/
public function edit()
{
$param = array('id' => 'edit-role-form', 'model' => 'Role', 'reference' => array('id' => $this->roleId), 'fieldsets' => array('form' => array('nofieldset' => true, new HiddenInput(array('field' => 'removable', 'default' => 1, 'readonly' => true)), new TextInput(array('field' => 'name', 'maxlength' => 32, 'label' => Lang::get('roles.form-name-label'), 'required' => true)), new ColorInput(array('field' => 'color', 'label' => Lang::get('roles.form-color-label'), 'default' => '#000'))), '_submits' => array(new SubmitInput(array('name' => 'valid', 'value' => Lang::get('main.valid-button'))), new DeleteInput(array('name' => 'delete', 'value' => Lang::get('main.delete-button'), 'notDisplayed' => $this->roleId == -1)), new ButtonInput(array('name' => 'cancel', 'value' => Lang::get('main.cancel-button'), 'onclick' => 'app.dialog("close")')))), 'onsuccess' => 'app.dialog("close"); app.load(app.getUri("list-roles"), {selector : "#admin-roles-tab"});');
foreach (Language::getAll() as $language) {
$param['fieldsets']['form'][] = new TextInput(array('name' => "translation[{$language->tag}]", "independant" => true, 'required' => $language->tag == LANGUAGE, "label" => Lang::get("roles.role-label-label", array('lang' => $language->tag)), "default" => Lang::exists("roles.role-" . $this->roleId . "-label") ? Lang::get("roles.role-" . $this->roleId . "-label", array(), 0, $language->tag) : ''));
}
$form = new Form($param);
if (!$form->submitted()) {
return View::make(Theme::getSelected()->getView("dialogbox.tpl"), array('icon' => 'user', 'title' => Lang::get('roles.form-title'), 'page' => $form));
} else {
if ($form->submitted() == "delete") {
$form->delete(Form::NO_EXIT);
if ($key) {
$key->delete();
}
return $form->response(Form::STATUS_SUCCESS);
} else {
if ($form->check()) {
try {
$roleId = $form->register(Form::NO_EXIT);
// Create the language key for the translations of the role name
foreach (App::request()->getBody('translation') as $tag => $translation) {
Language::getByTag($tag)->saveTranslations(array('roles' => array("role-{$roleId}-label" => $translation)));
}
return $form->response(Form::STATUS_SUCCESS);
} catch (Exception $e) {
return $form->response(Form::STATUS_ERROR, DEBUG_MODE ? $e->getMessage() : "");
}
}
}
}
}
示例2: __construct
/**
* Constructor
*
* @param array $filters The filters
*/
public function __construct($filters)
{
$options = array();
// active languages
$languages = array();
$allLanguages = Language::getAll('tag');
foreach ($allLanguages as $tag => $language) {
$options[$tag] = $language->label;
if ($language->active) {
$languages[$tag] = $language;
}
}
if (!in_array($filters['tag'], array_keys($allLanguages))) {
$filters['tag'] = Lang::DEFAULT_LANGUAGE;
}
$param = array('id' => 'language-filter-form', 'method' => 'get', 'action' => App::router()->getUri('language-keys-list'), 'fieldsets' => array('filters' => array('nofieldset' => true, new SelectInput(array('name' => 'tag', 'options' => $options, 'default' => $filters['tag'], 'style' => 'width: 80%; margin-right: 5px;', 'label' => Lang::get('language.filter-language-label'), 'after' => Icon::make(array('icon' => 'pencil', 'class' => 'text-primary edit-lang', 'title' => Lang::get('language.filter-language-edit'))) . (count($allLanguages) > 1 && Option::get('main.language') != $filters['tag'] && $filters['tag'] != Lang::DEFAULT_LANGUAGE ? Icon::make(array('icon' => 'close', 'class' => 'text-danger delete-lang', 'title' => Lang::get('language.filter-language-delete'))) : ''))), new RadioInput(array('name' => 'keys', 'options' => array('missing' => Lang::get('language.filter-keys-missing'), 'all' => Lang::get('language.filter-keys-all')), 'default' => isset($filters['keys']) ? $filters['keys'] : 'all', 'label' => Lang::get('language.filter-keys-label'), 'labelWidth' => '100%', 'layout' => 'vertical')))));
$this->form = new Form($param);
}
示例3: language_select_list
function language_select_list($module, $id, $current_language, $translated_languages)
{
$mobile_version = c2cTools::mobileVersion();
$items = array();
foreach (Language::getAll() as $language => $value) {
$lang = format_language_c2c($language);
if ($current_language == $language) {
$items[] = '<div class="current_lang">' . ($mobile_version ? $language : $lang) . '</div>';
} else {
$existing_lang = in_array($language, $translated_languages);
$options = $existing_lang ? array('class' => 'translated') : array('class' => 'not_translated', 'rel' => 'nofollow');
if (!$mobile_version) {
$items[] = link_to($lang, "@document_by_id_lang?module={$module}&id={$id}&lang={$language}", $options);
} else {
$items[] = $existing_lang ? link_to($language, "@document_by_id_lang?module={$module}&id={$id}&lang={$language}", $options) : '<span class="not_translated">' . $language . '</span>';
}
}
}
return implode(' | ', $items);
}
示例4: jump
if ($action == 'move_up') {
$language->moveUp();
} else {
$language->moveDown();
}
Messages::addNotice('Order changed');
jump('?page=language');
break;
case 'set_default':
$language->setDefault();
Messages::addNotice('Changed');
jump('?page=language');
break;
case 'change_status':
if ($language->isActive()) {
$language->status = Language::STATUS_INACTIVE;
} else {
$language->status = Language::STATUS_ACTIVE;
}
$language->save();
Messages::addNotice('Status changed');
jump('?page=language');
break;
default:
$languages = $language->getAll("ORDER BY display_order ASC");
$smarty->assign('languages', $languages);
$action = 'list';
$smarty->assign('CONTENT', 'language/list.tpl');
break;
}
$smarty->assign('language', $language);
示例5: picto_tag
$portal_url = 'http://' . $portal_config['url'];
} else {
$portal_url = '@document_by_id?module=portals&id=' . $portal_config['id'];
}
echo '<li>', picto_tag('picto_portals'), link_to(__($portal_config['name']), $portal_url), '</li>';
}
}
?>
</ul>
</li>
<li><?php
echo f_link_to(__('Forum'), '?lang=' . $lang);
?>
<ul>
<li><?php
$languages = Language::getAll();
echo picto_tag('action_comment'), f_link_to(__('All topics'), '');
?>
<ul>
<?php
$last_item = end($languages);
reset($languages);
foreach ($languages as $key => $value) {
?>
<li<?php
if ($value == $last_item) {
?>
class="lilast"<?php
}
?>
><?php
示例6: settings
/**
* Display and treat application settings
*/
public function settings()
{
$languages = array_map(function ($language) {
return $language->label;
}, Language::getAll('tag'));
$roleObjects = Role::getListByExample(new DBExample(array('id' => array('$ne' => 0))), 'id');
$roles = array();
foreach ($roleObjects as $role) {
$roles[$role->id] = Lang::get("roles.role-{$role->id}-label");
}
$items = MenuItem::getAvailableItems();
$menuItems = array();
foreach ($items as $item) {
if ($item->action && !preg_match('/^(javascript\\:|#)/', $item->action) && (!$item->target || $item->target == 'newtab')) {
if ($item->label === 'user.username') {
$item->label = App::session()->getUser()->username;
}
$menuItems[$item->action] = $item->label;
} else {
foreach ($item->visibleItems as $subitem) {
if ($item->label === 'user.username') {
$item->label = App::session()->getUser()->username;
}
if (!preg_match('/^(javascript\\:|#)/', $subitem->action) && (!$subitem->target || $subitem->target == 'newtab')) {
$menuItems[$subitem->action] = $item->label . " > " . $subitem->label;
}
}
}
}
$api = new HawkApi();
try {
$updates = $api->getCoreAvailableUpdates();
} catch (\Hawk\HawkApiException $e) {
$updates = array();
}
$param = array('id' => 'settings-form', 'upload' => true, 'fieldsets' => array('main' => array(new TextInput(array('name' => 'main_sitename', 'required' => true, 'default' => Option::get('main.sitename'), 'label' => Lang::get('admin.settings-sitename-label'))), new SelectInput(array('name' => 'main_language', 'required' => true, 'options' => $languages, 'default' => Option::get('main.language'), 'label' => Lang::get('admin.settings-language-label'))), new SelectInput(array('name' => 'main_timezone', 'required' => true, 'options' => array_combine(\DateTimeZone::listIdentifiers(), \DateTimeZone::listIdentifiers()), 'default' => Option::get('main.timezone'), 'label' => Lang::get('admin.settings-timezone-label'))), new SelectInput(array('name' => 'main_currency', 'required' => true, 'options' => array('EUR' => 'Euro (€)', 'USD' => 'US Dollar ($)'), 'default' => Option::get('main.currency'), 'label' => Lang::get('admin.settings-currency-label'))), new FileInput(array('name' => 'logo', 'label' => Lang::get('admin.settings-logo-label'), 'after' => Option::get('main.logo') ? '<img src="' . Plugin::get('main')->getUserfilesUrl(Option::get('main.logo')) . '" class="settings-logo-preview" />' : '', 'maxSize' => 200000, 'extensions' => array('gif', 'png', 'jpg', 'jpeg'))), new FileInput(array('name' => 'favicon', 'label' => Lang::get('admin.settings-favicon-label'), 'after' => Option::get('main.favicon') ? '<img src="' . Plugin::get('main')->getUserfilesUrl(Option::get('main.favicon')) . '" class="settings-favicon-preview" />' : '', 'maxSize' => 20000, 'extensions' => array('gif', 'png', 'jpg', 'jpeg', 'ico')))), 'referencing' => call_user_func(function () use($languages) {
$inputs = array();
foreach ($languages as $tag => $language) {
$inputs[] = new TextInput(array('name' => 'main_page-title-' . $tag, 'default' => Option::get('main.page-title-' . $tag)));
$inputs[] = new TextareaInput(array('name' => 'main_page-description-' . $tag, 'default' => Option::get('main.page-description-' . $tag)));
$inputs[] = new TextInput(array('name' => 'main_page-keywords-' . $tag, 'default' => Option::get('main.page-keywords-' . $tag)));
}
return $inputs;
}), 'home' => array(new RadioInput(array('name' => 'main_home-page-type', 'options' => array('default' => Lang::get('admin.settings-home-page-type-default'), 'custom' => Lang::get('admin.settings-home-page-type-custom'), 'page' => Lang::get('admin.settings-home-page-type-page')), 'default' => Option::get('main.home-page-type') ? Option::get('main.home-page-type') : 'default', 'label' => Lang::get('admin.settings-home-page-type-label'), 'layout' => 'vertical', 'attributes' => array('e-value' => 'homePage.type'))), new WysiwygInput(array('name' => 'main_home-page-html', 'id' => 'home-page-html', 'label' => Lang::get('admin.settings-home-page-html-label'), 'default' => Option::get('main.home-page-html'))), new SelectInput(array('name' => 'main_home-page-item', 'id' => 'home-page-item', 'label' => Lang::get('admin.settings-home-page-item-label'), 'options' => $menuItems, 'value' => Option::get('main.home-page-item'))), new CheckboxInput(array('name' => 'main_open-last-tabs', 'label' => Lang::get('admin.settings-open-last-tabs'), 'default' => Option::get('main.open-last-tabs'), 'dataType' => 'int'))), 'users' => array(new RadioInput(array('name' => 'main_allow-guest', 'options' => array(0 => Lang::get('main.no-txt'), 1 => Lang::get('main.yes-txt')), 'default' => Option::get('main.allow-guest') ? Option::get('main.allow-guest') : 0, 'label' => Lang::get('admin.settings-allow-guest-label'))), new RadioInput(array('name' => 'main_open-register', 'options' => array(0 => Lang::get('admin.settings-open-register-off'), 1 => Lang::get('admin.settings-open-register-on')), 'layout' => 'vertical', 'label' => Lang::get('admin.settings-open-registers-label'), 'default' => Option::get('main.open-register') ? Option::get('main.open-register') : 0, 'attributes' => array('e-value' => 'register.open'))), new CheckboxInput(array('name' => 'main_confirm-register-email', 'label' => Lang::get('admin.settings-confirm-email-label'), 'default' => Option::get('main.confirm-register-email'), 'dataType' => 'int', 'attributes' => array('e-value' => 'register.checkEmail'))), new WysiwygInput(array('name' => 'main_confirm-email-content', 'id' => 'settings-confirm-email-content-input', 'default' => Option::get('main.confirm-email-content'), 'label' => Lang::get('admin.settings-confirm-email-content-label'), 'labelWidth' => 'auto')), new CheckboxInput(array('name' => 'main_confirm-register-terms', 'label' => Lang::get('admin.settings-confirm-terms-label'), 'default' => Option::get('main.confirm-register-terms'), 'dataType' => 'int', 'labelWidth' => 'auto', 'attributes' => array('e-value' => 'register.checkTerms'))), new WysiwygInput(array('name' => 'main_terms', 'id' => 'settings-terms-input', 'label' => Lang::get('admin.settings-terms-label'), 'labelWidth' => 'auto', 'default' => Option::get('main.terms'))), new SelectInput(array('name' => 'roles_default-role', 'label' => Lang::get('admin.settings-default-role-label'), 'options' => $roles, 'default' => Option::get('roles.default-role')))), 'email' => array(new EmailInput(array('name' => 'main_mailer-from', 'default' => Option::get('main.mailer-from') ? Option::get('main.mailer-from') : App::session()->getUser()->email, 'label' => Lang::get('admin.settings-mailer-from-label'))), new TextInput(array('name' => 'main_mailer-from-name', 'default' => Option::get('main.mailer-from-name') ? Option::get('main.mailer-from-name') : App::session()->getUser()->getDisplayName(), 'label' => Lang::get('admin.settings-mailer-from-name-label'))), new SelectInput(array('name' => 'main_mailer-type', 'default' => Option::get('main.mailer-type'), 'options' => array('mail' => Lang::get('admin.settings-mailer-type-mail-value'), 'smtp' => Lang::get('admin.settings-mailer-type-smtp-value'), 'pop3' => Lang::get('admin.settings-mailer-type-pop3-value')), 'label' => Lang::get('admin.settings-mailer-type-label'), 'attributes' => array('e-value' => 'mail.type'))), new TextInput(array('name' => 'main_mailer-host', 'default' => Option::get('main.mailer-host'), 'label' => Lang::get('admin.settings-mailer-host-label'))), new IntegerInput(array('name' => 'main_mailer-port', 'default' => Option::get('main.mailer-port'), 'label' => Lang::get('admin.settings-mailer-port-label'), 'size' => 4)), new TextInput(array('name' => 'main_mailer-username', 'default' => Option::get('main.mailer-username'), 'label' => Lang::get('admin.settings-mailer-username-label'))), new PasswordInput(array('name' => 'main_mailer-password', 'encrypt' => 'Crypto::aes256Encode', 'decrypt' => 'Crypto::aes256Decode', 'default' => Option::get('main.mailer-password'), 'label' => Lang::get('admin.settings-mailer-password-label'))), new SelectInput(array('name' => 'main_smtp-secured', 'options' => array('' => Lang::get('main.no-txt'), 'ssl' => 'SSL', 'tsl' => 'TSL'), 'label' => Lang::get('admin.settings-smtp-secured-label')))), '_submits' => array(empty($updates) ? new HtmlInput(array('value' => '<span class="btn btn-success">' . Lang::get('admin.hawk-version-up-to-date', array('version' => HAWK_VERSION)) . '</span>')) : new ButtonInput(array('name' => 'update-hawk', 'value' => Lang::get('admin.update-page-update-hawk-btn', array('version' => end($updates)['version'])), 'icon' => 'refresh', 'id' => 'update-hawk-btn', 'attributes' => array('e-click' => 'function(){ updateHawk("' . end($updates)['version'] . '"); }'), 'class' => 'btn-warning')), new SubmitInput(array('name' => 'save', 'value' => Lang::get('main.valid-button'), 'class' => 'pull-right')))));
$form = new Form($param);
if (!$form->submitted()) {
// Display the form
$this->addCss(Plugin::current()->getCssUrl('settings.less'));
$page = View::make(Plugin::current()->getView('settings.tpl'), array('form' => $form, 'languages' => $languages));
$this->addKeysToJavaScript('admin.update-page-confirm-update-hawk');
$this->addJavaScript(Plugin::current()->getJsUrl('settings.js'));
return NoSidebarTab::make(array('icon' => 'cogs', 'title' => Lang::get('admin.settings-page-name'), 'description' => Lang::get('admin.settings-page-description'), 'page' => $page));
} else {
// treat the form
try {
if ($form->check()) {
// register scalar values
foreach ($form->inputs as $name => $field) {
if (!$field instanceof \Hawk\FileInput && !$field instanceof \Hawk\ButtonInput && !$field instanceof \Hawk\HtmlInput) {
$value = $field->dbvalue();
if ($value === null) {
$value = '0';
}
$optionName = str_replace('_', '.', $name);
App::logger()->error("Option name =" . $optionName . 'X');
App::logger()->error("basename=" . $value . 'X');
Option::set($optionName, $value);
} elseif ($field instanceof \Hawk\FileInput) {
$upload = Upload::getInstance($name);
if ($upload) {
try {
$file = $upload->getFile();
$dir = Plugin::get('main')->getPublicUserfilesDir();
if (!is_dir($dir)) {
mkdir($dir, 0755);
}
if ($name == 'favicon') {
$basename = uniqid() . '.ico';
$generator = new \PHPICO($file->tmpFile, array(array(16, 16), array(32, 32), array(48, 48), array(64, 64)));
$generator->save_ico($dir . $basename);
} else {
$basename = uniqid() . '.' . $file->extension;
$upload->move($file, $dir, $basename);
}
// remove the old image
@unlink($dir . Option::get("main.{$name}"));
App::logger()->error("Option name = " . $name);
App::logger()->error("main.{$name}");
App::logger()->error("basename=" . $basename);
Option::set("main.{$name}", $basename);
} catch (ImageException $e) {
$form->error($name, Lang::get('form.image-format'));
throw $e;
}
}
}
}
//.........这里部分代码省略.........
示例7: dirname
<?php
$dirname = dirname(__FILE__);
include $dirname . '/../bootstrap/unit.php';
include $dirname . '/../../config/config.php';
require_once $dirname . '/../../apps/frontend/lib/Language.class.php';
require_once $sf_symfony_lib_dir . '/util/sfYaml.class.php';
// load some fixtures
$app_yml = sfYaml::load($dirname . '/../../apps/frontend/config/app.yml');
$c2c_avaible_languages = $app_yml['all']['languages']['c2c'];
$forum_translations = $app_yml['all']['languages']['punbb'];
sfConfig::set('app_languages_c2c', $c2c_avaible_languages);
sfConfig::set('app_languages_punbb', $forum_translations);
// initiate lime_test
$t = new lime_test(8, new lime_output_color());
// ::getAll()
$t->diag('::getAll()');
$t->isa_ok(Language::getAll(), 'array', '::getAll() return an array');
// ::getPunBBLanguages()
$t->diag('::getPunBBLanguages()');
$t->isa_ok(Language::getPunBBLanguages(), 'array', '::getPunBBLanguages() return an array');
// ::translateForPunBB($symfony_lang)
$t->diag('::translateForPunBB($symfony_lang)');
foreach ($c2c_avaible_languages as $short_language_tag => $long_language_tag) {
$t->is(Language::translateForPunBB($short_language_tag), $forum_translations[$short_language_tag], 'Language::translateForPunBB(' . $short_language_tag . ') return ' . $forum_translations[$short_language_tag]);
}
示例8: delete
/**
* Delete a profile question
*/
public function delete()
{
$question = ProfileQuestion::getByName($this->name);
if ($question->editable) {
$params = json_decode($question->parameters, true);
$question->delete();
// Remove the language keys for the label and the options
$keysToRemove = array('admin' => array('profile-question-' . $this->name . '-label'));
if (!empty($params['options'])) {
foreach ($params['options'] as $i => $value) {
$keysToRemove['admin'][] = 'profile-question-' . $this->name . '-option-' . $i;
}
}
foreach (Language::getAll() as $language) {
$language->removeTranslations($keysToRemove);
}
}
}
示例9: setPreferedLanguage
public function setPreferedLanguage($prefered_language)
{
if (!in_array($prefered_language, array_keys(Language::getAll()))) {
throw new exception('bad language code');
}
$user_languages = $this->getPreferedLanguageList();
$user_new_languages[] = $prefered_language;
if ($user_languages[0] != $prefered_language) {
for ($i = 0, $n = count($user_languages); $i < $n; $i++) {
if ($user_languages[$i] != $prefered_language) {
$user_new_languages[] = $user_languages[$i];
}
}
} else {
$user_new_languages = $user_languages;
}
// save in bdd and session
$this->savePreferedLanguageList($user_new_languages);
}
示例10: addKey
/**
* Add a new language key
*/
public function addKey()
{
$form = $this->keyForm();
if ($form->check()) {
try {
$key = self::DEFAULT_KEY_PLUGIN . '.' . $form->getData('key');
if (Lang::exists($key)) {
$form->error('key', Lang::get('language.key-already-exists'));
return $form->response(Form::STATUS_CHECK_ERROR);
}
foreach (Language::getAll() as $language) {
$translation = $form->getData("translation[{$language->tag}]");
if ($translation) {
$language->saveTranslations(array(self::DEFAULT_KEY_PLUGIN => array($form->getData('key') => $translation)));
}
}
App::logger()->info('A new language key has been added');
return $form->response(Form::STATUS_SUCCESS);
} catch (Exception $e) {
App::logger()->error('An error occured while adding a language key : ' . $e->getMessage());
return $form->response(Form::STATUS_ERROR);
}
}
}