本文整理汇总了PHP中t函数的典型用法代码示例。如果您正苦于以下问题:PHP t函数的具体用法?PHP t怎么用?PHP t使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了t函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: authenticate
/**
* Authenticates the password.
* This is the 'authenticate' validator as declared in rules().
*/
public function authenticate($attribute, $params)
{
if (!$this->hasErrors()) {
$identity = new UserIdentity($this->username, $this->password);
$identity->authenticate();
switch ($identity->errorCode) {
case UserIdentity::ERROR_NONE:
$duration = $this->rememberMe ? Yii::app()->controller->module->rememberMeTime : 0;
Yii::app()->user->login($identity, $duration);
break;
case UserIdentity::ERROR_EMAIL_INVALID:
$this->addError("username", t("Email is incorrect."));
break;
case UserIdentity::ERROR_USERNAME_INVALID:
$this->addError("username", t("Username is incorrect."));
break;
case UserIdentity::ERROR_STATUS_NOTACTIV:
$this->addError("status", t("You account is not activated."));
break;
case UserIdentity::ERROR_STATUS_BAN:
$this->addError("status", t("You account is blocked."));
break;
case UserIdentity::ERROR_PASSWORD_INVALID:
$this->addError("password", t("Password is incorrect."));
break;
}
}
}
示例2: __construct
public function __construct()
{
parent::__construct();
$oCommentModel = new CommentModel();
$sComment = $this->httpRequest->post('comment');
$sCurrentTime = $this->dateTime->get()->dateTime('Y-m-d H:i:s');
$iTimeDelay = (int) DbConfig::getSetting('timeDelaySendComment');
$sTable = $this->httpRequest->get('table');
$iRecipientId = $this->httpRequest->get('recipient', 'int');
$iSenderId = (int) $this->session->get('member_id');
if (!$oCommentModel->idExists($iRecipientId, $sTable)) {
\PFBC\Form::setError('form_comment', t('The comment recipient does not exists.'));
} elseif (!$oCommentModel->checkWaitSend($iSenderId, $iTimeDelay, $sCurrentTime, $sTable)) {
\PFBC\Form::setError('form_comment', Form::waitWriteMsg($iTimeDelay));
} elseif ($oCommentModel->isDuplicateContent($iSenderId, $sComment, $sTable)) {
\PFBC\Form::setError('form_comment', Form::duplicateContentMsg());
} else {
if (!$oCommentModel->add($sComment, $iRecipientId, $iSenderId, 1, $sCurrentTime, $sTable)) {
\PFBC\Form::setError('form_comment', t('Oops! Error when adding comment.'));
} else {
/* Clean All Data of CommentModel Cache */
(new Framework\Cache\Cache())->start(CommentCoreModel::CACHE_GROUP, null, null)->clear();
HeaderUrl::redirect(Uri::get('comment', 'comment', 'read', $sTable . ',' . $iRecipientId), t('The comment has been sent successfully!'));
}
}
unset($oCommentModel);
}
示例3: prepare_remote_upgrade
public function prepare_remote_upgrade($remoteMPID = 0)
{
$tp = new TaskPermission();
if ($tp->canInstallPackages()) {
$mri = MarketplaceRemoteItem::getByID($remoteMPID);
if (!is_object($mri)) {
$this->set('error', array(t('Invalid marketplace item ID.')));
return;
}
$local = Package::getbyHandle($mri->getHandle());
if (!is_object($local) || $local->isPackageInstalled() == false) {
$this->set('error', array(Package::E_PACKAGE_NOT_FOUND));
return;
}
$r = $mri->downloadUpdate();
if ($r != false) {
if (!is_array($r)) {
$this->set('error', array($r));
} else {
$errors = Package::mapError($r);
$this->set('error', $errors);
}
} else {
$this->redirect('/dashboard/extend/update', 'do_update', $mri->getHandle());
}
}
}
示例4: cmstheme_breadcrumb
/**
* Implemensts hook_breadcrumb().
*
* tth@bellcom.dk check if there is a better way to do this...
*/
function cmstheme_breadcrumb($variables)
{
$breadcrumb = $variables['breadcrumb'];
$nid = arg(1);
if (is_numeric($nid)) {
$node = node_load($nid);
}
if (!empty($breadcrumb)) {
$output = '<div class="breadcrumb you-are-here">' . t('Du er her: ') . '</div>';
$title = drupal_get_title();
$breadcrumb[0] = l(t('Forside'), '<front>', array('attributes' => array('title' => 'Forside')));
$breadcrumb[] = '<a href="#" title="' . $title . '">' . $title . '</a>';
if ($title == 'Søg') {
unset($breadcrumb);
$breadcrumb[0] = l(t('Forside'), '<front>', array('attributes' => array('title' => 'Forside')));
$breadcrumb[] = '<a href="#" title="Søgning">Søgning</a>';
}
if (isset($node) && is_object($node) && $node->type == 'meeting') {
unset($breadcrumb);
$breadcrumb[0] = l(t('Forside'), '<front>', array('attributes' => array('title' => 'Forside')));
$breadcrumb[] = l(t('Politik & planer'), 'politik-og-planer', array('attributes' => array('title' => 'Politik og planer')));
$breadcrumb[] = l(t('Søg i dagsordener og referater'), 'dagsorden-og-referat', array('attributes' => array('title' => 'Søg i dagsordner og referater')));
$breadcrumb[] = l(t($title), '#');
}
$output .= '<div class="breadcrumb">' . implode('<div class="bread-crumb"> > </div> ', $breadcrumb) . '</div>';
return $output;
}
}
示例5: testUriFunctions
/**
* Test the getViaUri() and getViaScheme() methods and target functions.
*/
function testUriFunctions()
{
$config = $this->config('system.file');
$instance = \Drupal::service('stream_wrapper_manager')->getViaUri($this->scheme . '://foo');
$this->assertEqual($this->classname, get_class($instance), 'Got correct class type for dummy URI.');
$instance = \Drupal::service('stream_wrapper_manager')->getViaUri('public://foo');
$this->assertEqual('Drupal\\Core\\StreamWrapper\\PublicStream', get_class($instance), 'Got correct class type for public URI.');
// Test file_uri_target().
$this->assertEqual(file_uri_target('public://foo/bar.txt'), 'foo/bar.txt', 'Got a valid stream target from public://foo/bar.txt.');
$this->assertEqual(file_uri_target('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=='), 'image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==', t('Got a valid stream target from a data URI.'));
$this->assertFalse(file_uri_target('foo/bar.txt'), 'foo/bar.txt is not a valid stream.');
$this->assertFalse(file_uri_target('public://'), 'public:// has no target.');
$this->assertFalse(file_uri_target('data:'), 'data: has no target.');
// Test file_build_uri() and
// Drupal\Core\StreamWrapper\LocalStream::getDirectoryPath().
$this->assertEqual(file_build_uri('foo/bar.txt'), 'public://foo/bar.txt', 'Expected scheme was added.');
$this->assertEqual(\Drupal::service('stream_wrapper_manager')->getViaScheme('public')->getDirectoryPath(), PublicStream::basePath(), 'Expected default directory path was returned.');
$this->assertEqual(\Drupal::service('stream_wrapper_manager')->getViaScheme('temporary')->getDirectoryPath(), $config->get('path.temporary'), 'Expected temporary directory path was returned.');
$config->set('default_scheme', 'private')->save();
$this->assertEqual(file_build_uri('foo/bar.txt'), 'private://foo/bar.txt', 'Got a valid URI from foo/bar.txt.');
// Test file_create_url()
// TemporaryStream::getExternalUrl() uses Url::fromRoute(), which needs
// route information to work.
$this->container->get('router.builder')->rebuild();
$this->assertTrue(strpos(file_create_url('temporary://test.txt'), 'system/temporary?file=test.txt'), 'Temporary external URL correctly built.');
$this->assertTrue(strpos(file_create_url('public://test.txt'), Settings::get('file_public_path') . '/test.txt'), 'Public external URL correctly built.');
$this->assertTrue(strpos(file_create_url('private://test.txt'), 'system/files/test.txt'), 'Private external URL correctly built.');
}
示例6: testInputDemoForm
/**
* Test example forms provided by fapi_example.
*/
public function testInputDemoForm()
{
// Test for a link to the form_example in the Tools menu.
$this->drupalGet('');
$this->assertResponse(200, 'The Home page is available.');
$this->assertLinkByHref('examples/fapi_example');
// Test for a link to the simple_form example on the form_example page.
$this->drupalGet('examples/fapi_example');
$this->assertLinkByHref('examples/fapi_example/input_demo');
// Verify that anonymous can access the simpletest_examples page.
$this->drupalGet('examples/fapi_example/input_demo');
$this->assertResponse(200, 'The Demo of Common Input Elements page is available.');
// Post the form.
$edit = ['tests_taken[SAT]' => TRUE, 'color' => '#ff6bf1', 'expiration' => '2015-10-21', 'email' => 'somebody@example.org', 'quantity' => '4', 'password' => 'letmein', 'password_confirm[pass1]' => 'letmein', 'password_confirm[pass2]' => 'letmein', 'size' => '76', 'active' => '1', 'search' => 'my search string', 'favorite' => 'blue', 'phone' => '555-555-5555', 'table[1]' => TRUE, 'table[3]' => TRUE, 'text' => 'This is a test of my form.', 'subject' => 'Form test', 'weight' => '3'];
$this->drupalPostForm('/examples/fapi_example/input_demo', $edit, t('Submit'));
$this->assertText('Value for What standardized tests did you take?: Array ( [SAT] => SAT )');
$this->assertText('Value for Color: #ff6bf1');
$this->assertText('Value for Content expiration: 2015-10-21');
$this->assertText('Value for Email: somebody@example.org');
$this->assertText('Value for Quantity: 4');
$this->assertText('Value for Password: letmein');
$this->assertText('Value for New Password: letmein');
$this->assertText('Value for Size: 76');
$this->assertText('Value for active: 1');
$this->assertText('Value for Search: my search string');
$this->assertText('Value for Favorite color: blue');
$this->assertText('Value for Phone: 555-555-5555');
$this->assertText('Value for Users: Array ( [1] => 1 [3] => 3 )');
$this->assertText('Value for Text: This is a test of my form.');
$this->assertText('Value for Subject: Form test');
$this->assertText('Value for Weight: 3');
}
示例7: testReEnabledField
/**
* Test the behavior of a field module after being disabled and re-enabled.
*/
function testReEnabledField()
{
// Add a telephone field to the article content type.
$field_storage = entity_create('field_storage_config', array('name' => 'field_telephone', 'entity_type' => 'node', 'type' => 'telephone'));
$field_storage->save();
entity_create('field_instance_config', array('field_storage' => $field_storage, 'bundle' => 'article', 'label' => 'Telephone Number'))->save();
entity_get_form_display('node', 'article', 'default')->setComponent('field_telephone', array('type' => 'telephone_default', 'settings' => array('placeholder' => '123-456-7890')))->save();
entity_get_display('node', 'article', 'default')->setComponent('field_telephone', array('type' => 'telephone_link', 'weight' => 1))->save();
// Display the article node form and verify the telephone widget is present.
$this->drupalGet('node/add/article');
$this->assertFieldByName("field_telephone[0][value]", '', 'Widget found.');
// Submit an article node with a telephone field so data exist for the
// field.
$edit = array('title[0][value]' => $this->randomName(), 'field_telephone[0][value]' => "123456789");
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertRaw('<a href="tel:123456789">');
// Test that the module can't be uninstalled from the UI while there is data
// for it's fields.
$admin_user = $this->drupalCreateUser(array('access administration pages', 'administer modules'));
$this->drupalLogin($admin_user);
$this->drupalGet('admin/modules');
$this->assertText('Fields type(s) in use');
$field_storage->delete();
$this->drupalGet('admin/modules');
$this->assertText('Fields pending deletion');
$this->cronRun();
$this->assertNoText('Fields type(s) in use');
$this->assertNoText('Fields pending deletion');
}
示例8: doDisplay
protected function doDisplay(array $context, array $blocks = array())
{
$tags = array();
$filters = array("t" => 14);
$functions = array();
try {
$this->env->getExtension('sandbox')->checkSecurity(array(), array('t'), array());
} catch (Twig_Sandbox_SecurityError $e) {
$e->setTemplateFile($this->getTemplateName());
if ($e instanceof Twig_Sandbox_SecurityNotAllowedTagError && isset($tags[$e->getTagName()])) {
$e->setTemplateLine($tags[$e->getTagName()]);
} elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFilterError && isset($filters[$e->getFilterName()])) {
$e->setTemplateLine($filters[$e->getFilterName()]);
} elseif ($e instanceof Twig_Sandbox_SecurityNotAllowedFunctionError && isset($functions[$e->getFunctionName()])) {
$e->setTemplateLine($functions[$e->getFunctionName()]);
}
throw $e;
}
// line 13
echo "<a href=\"";
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, isset($context["url"]) ? $context["url"] : null, "html", null, true));
echo "\"";
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->escapeFilter($this->env, $this->getAttribute(isset($context["attributes"]) ? $context["attributes"] : null, "addClass", array(0 => "feed-icon"), "method"), "html", null, true));
echo ">\n ";
// line 14
echo $this->env->getExtension('sandbox')->ensureToStringAllowed($this->env->getExtension('drupal_core')->renderVar(t("Subscribe to @title", array("@title" => isset($context["title"]) ? $context["title"] : null))));
echo "\n</a>\n";
}
开发者ID:OCIODOE,项目名称:drupal8,代码行数:28,代码来源:4e8adf0e8cae99397b0688f558f6863de5fc0fd1bb8d110086e07e0cd06416d9.php
示例9: shareaholic_form_node_form_alter
/**
* Implements hook_form_node_form_alter().
*
* When the node form is presented, add additional options
* for Shareaholic Apps
*
* @param Array $form - Nested array of form elements
* @param Array $form_state - keyed array containing form state
* @param $form_id - String representing the name of the form itself
*/
function shareaholic_form_node_form_alter(&$form, &$form_state, $form_id)
{
$node = $form['#node'];
$form['shareaholic_options'] = array('#type' => 'fieldset', '#access' => TRUE, '#title' => 'Shareaholic Options', '#collapsible' => TRUE, '#collapsed' => TRUE, '#group' => 'additional_settings', '#weight' => 100);
// I have to namespace it this way because Drupal can't add
// the shareholic_options name to it
// when you process the form on submit!!!
$form['shareaholic_options']['shareaholic_hide_share_buttons'] = array('#type' => 'checkbox', '#title' => 'Hide Share Buttons');
$form['shareaholic_options']['shareaholic_hide_recommendations'] = array('#type' => 'checkbox', '#title' => 'Hide Related Content');
$form['shareaholic_options']['shareaholic_exclude_from_recommendations'] = array('#type' => 'checkbox', '#title' => 'Exclude from Related Content');
$form['shareaholic_options']['shareaholic_exclude_og_tags'] = array('#type' => 'checkbox', '#title' => 'Do not include Open Graph tags');
if (!db_table_exists('shareaholic_content_settings')) {
$form['shareaholic_options']['shareaholic_message'] = array('#type' => 'markup', '#markup' => '<p style="color:#FF0000;">' . t('Action required: you have some pending updates required by Shareaholic. Please go to update.php for more information.') . '</p>');
}
if ($node->shareaholic_options['shareaholic_exclude_from_recommendations']) {
$form['shareaholic_options']['shareaholic_exclude_from_recommendations']['#attributes'] = array('checked' => 'checked');
}
if ($node->shareaholic_options['shareaholic_hide_recommendations']) {
$form['shareaholic_options']['shareaholic_hide_recommendations']['#attributes'] = array('checked' => 'checked');
}
if ($node->shareaholic_options['shareaholic_hide_share_buttons']) {
$form['shareaholic_options']['shareaholic_hide_share_buttons']['#attributes'] = array('checked' => 'checked');
}
if ($node->shareaholic_options['shareaholic_exclude_og_tags']) {
$form['shareaholic_options']['shareaholic_exclude_og_tags']['#attributes'] = array('checked' => 'checked');
}
}
示例10: propertyDefinitions
/**
* {@inheritdoc}
*/
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition)
{
$properties['value'] = DataDefinition::create('string')->setLabel(t('Text'))->setRequired(TRUE);
$properties['format'] = DataDefinition::create('filter_format')->setLabel(t('Text format'));
$properties['processed'] = DataDefinition::create('string')->setLabel(t('Processed text'))->setDescription(t('The text with the text format applied.'))->setComputed(TRUE)->setClass('\\Drupal\\text\\TextProcessed')->setSetting('text source', 'value');
return $properties;
}
示例11: testFormsWithOverrides
/**
* Tests that overrides do not affect forms or listing screens.
*/
public function testFormsWithOverrides()
{
$this->drupalLogin($this->drupalCreateUser(['administer site configuration']));
$original_label = 'Default';
$overridden_label = 'Overridden label';
$edited_label = 'Edited label';
$config_test_storage = $this->container->get('entity.manager')->getStorage('config_test');
// Set up an override.
$settings['config']['config_test.dynamic.dotted.default']['label'] = (object) array('value' => $overridden_label, 'required' => TRUE);
$this->writeSettings($settings);
// Test that the overridden label is loaded with the entity.
$this->assertEqual($config_test_storage->load('dotted.default')->label(), $overridden_label);
// Test that the original label on the listing page is intact.
$this->drupalGet('admin/structure/config_test');
$this->assertText($original_label);
$this->assertNoText($overridden_label);
// Test that the original label on the editing page is intact.
$this->drupalGet('admin/structure/config_test/manage/dotted.default');
$elements = $this->xpath('//input[@name="label"]');
$this->assertIdentical((string) $elements[0]['value'], $original_label);
$this->assertNoText($overridden_label);
// Change to a new label and test that the listing now has the edited label.
$edit = array('label' => $edited_label);
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->drupalGet('admin/structure/config_test');
$this->assertNoText($overridden_label);
$this->assertText($edited_label);
// Test that the editing page now has the edited label.
$this->drupalGet('admin/structure/config_test/manage/dotted.default');
$elements = $this->xpath('//input[@name="label"]');
$this->assertIdentical((string) $elements[0]['value'], $edited_label);
// Test that the overridden label is still loaded with the entity.
$this->assertEqual($config_test_storage->load('dotted.default')->label(), $overridden_label);
}
示例12: get
function get()
{
require_once 'include/acl_selectors.php';
if (!local_channel()) {
notice(t('Permission denied.') . EOL);
return;
}
if (\App::$argc != 2) {
return;
}
$contact_id = intval(\App::$argv[1]);
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", intval($contact_id), intval(local_channel()));
if (!count($r)) {
notice(t('Contact not found.') . EOL);
return;
}
$contact = $r[0];
$o = '<h3>' . t('Suggest Friends') . '</h3>';
$o .= '<div id="fsuggest-desc" >' . sprintf(t('Suggest a friend for %s'), $contact['name']) . '</div>';
$o .= '<form id="fsuggest-form" action="fsuggest/' . $contact_id . '" method="post" >';
// FIXME contact_selector deprecated, removed
// $o .= contact_selector('suggest','suggest-select', false,
// array('size' => 4, 'exclude' => $contact_id, 'networks' => 'DFRN_ONLY', 'single' => true));
$o .= '<div id="fsuggest-submit-wrapper"><input id="fsuggest-submit" type="submit" name="submit" value="' . t('Submit') . '" /></div>';
$o .= '</form>';
return $o;
}
示例13: __construct
public function __construct()
{
parent::__construct();
$oUser = new UserCore();
$oUserModel = new UserCoreModel();
$oExistsModel = new ExistsCoreModel();
$oValidate = new Validate();
$aUserData = json_decode($this->file->getFile('http://api.randomuser.me/?results=' . $this->httpRequest->post('num')), true);
foreach ($aUserData['results'] as $aUser) {
$aUser = $aUser['user'];
$sEmail = trim($aUser['email']);
$sUsername = trim($aUser['username']);
if ($oValidate->email($sEmail) && !$oExistsModel->email($sEmail) && $oValidate->username($sUsername)) {
$aData['username'] = $sUsername;
$aData['email'] = $sEmail;
$aData['first_name'] = $aUser['name']['first'];
$aData['last_name'] = $aUser['name']['last'];
$aData['password'] = $aUser['password'];
$aData['sex'] = $aUser['gender'];
$aData['match_sex'] = array($oUser->getMatchSex($aData['sex']));
$aData['country'] = 'US';
$aData['city'] = $aUser['location']['city'];
$aData['state'] = $aUser['location']['state'];
$aData['zip_code'] = $aUser['location']['zip'];
$aData['birth_date'] = $this->dateTime->get($aUser['dob'])->date('Y-m-d');
$aData['avatar'] = $aUser['picture']['large'];
$aData['ip'] = Ip::get();
$aData['profile_id'] = $oUserModel->add(escape($aData, true));
$this->_addAvatar($aData, $oUser);
}
}
unset($oUser, $oUserModel, $oExistsModel, $oValidate, $aUser, $aData, $aUserData);
\PFBC\Form::setSuccess('form_add_fake_profiles', t('Users has been successfully added.'));
}
示例14: check_index
/**
* @return string An error message suitable for inclusion in the task log
*/
static function check_index()
{
list($remaining) = search::stats();
if ($remaining) {
site_status::warning(t('Your search index needs to be updated. <a href="%url" class="g-dialog-link">Fix this now</a>', array("url" => html::mark_clean(url::site("admin/maintenance/start/search_task::update_index?csrf=__CSRF__")))), "search_index_out_of_date");
}
}
示例15: testRequiredAttributes
/**
* Test that required alt/title fields gets validated right.
*/
function testRequiredAttributes()
{
$field_name = strtolower($this->randomMachineName());
$field_settings = array('alt_field' => 1, 'alt_field_required' => 1, 'title_field' => 1, 'title_field_required' => 1, 'required' => 1);
$instance = $this->createImageField($field_name, 'article', array(), $field_settings);
$images = $this->drupalGetTestFiles('image');
// Let's just use the first image.
$image = $images[0];
$this->uploadNodeImage($image, $field_name, 'article');
// Look for form-required for the alt text.
$elements = $this->xpath('//label[@for="edit-' . $field_name . '-0-alt" and @class="js-form-required form-required"]/following-sibling::input[@id="edit-' . $field_name . '-0-alt"]');
$this->assertTrue(isset($elements[0]), 'Required marker is shown for the required alt text.');
$elements = $this->xpath('//label[@for="edit-' . $field_name . '-0-title" and @class="js-form-required form-required"]/following-sibling::input[@id="edit-' . $field_name . '-0-title"]');
$this->assertTrue(isset($elements[0]), 'Required marker is shown for the required title text.');
$this->assertText(t('Alternative text field is required.'));
$this->assertText(t('Title field is required.'));
$instance->setSetting('alt_field_required', 0);
$instance->setSetting('title_field_required', 0);
$instance->save();
$edit = array('title[0][value]' => $this->randomMachineName());
$this->drupalPostForm('node/add/article', $edit, t('Save and publish'));
$this->assertNoText(t('Alternative text field is required.'));
$this->assertNoText(t('Title field is required.'));
$instance->setSetting('required', 0);
$instance->setSetting('alt_field_required', 1);
$instance->setSetting('title_field_required', 1);
$instance->save();
$edit = array('title[0][value]' => $this->randomMachineName());
$this->drupalPostForm('node/add/article', $edit, t('Save and publish'));
$this->assertNoText(t('Alternative text field is required.'));
$this->assertNoText(t('Title field is required.'));
}