本文整理汇总了PHP中OCP\IL10N类的典型用法代码示例。如果您正苦于以下问题:PHP IL10N类的具体用法?PHP IL10N怎么用?PHP IL10N使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IL10N类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(BackendInterface $caldavBackend, $calendarInfo, IL10N $l10n)
{
parent::__construct($caldavBackend, $calendarInfo);
if ($this->getName() === BirthdayService::BIRTHDAY_CALENDAR_URI) {
$this->calendarInfo['{DAV:}displayname'] = $l10n->t('Contact birthdays');
}
}
示例2: __construct
public function __construct(IL10N $l, ISession $session, ICrypto $crypto)
{
$this->session = $session;
$this->crypto = $crypto;
$this->setIdentifier('password::sessioncredentials')->setScheme(self::SCHEME_PASSWORD)->setText($l->t('Session credentials'))->addParameters([]);
\OCP\Util::connectHook('OC_User', 'post_login', $this, 'authenticate');
}
示例3: __construct
public function __construct(IL10N $l, ISession $session, ICredentialsManager $credentialsManager)
{
$this->session = $session;
$this->credentialsManager = $credentialsManager;
$this->setIdentifier('password::logincredentials')->setScheme(self::SCHEME_PASSWORD)->setText($l->t('Log-in credentials, save in database'))->addParameters([]);
\OCP\Util::connectHook('OC_User', 'post_login', $this, 'authenticate');
}
示例4: setUp
public function setUp()
{
parent::setUp();
$this->l10n = $this->getMockBuilder('\\OCP\\IL10N')->disableOriginalConstructor()->getMock();
$this->l10n->expects($this->any())->method('t')->will($this->returnCallback(function ($text, $parameters = array()) {
return vsprintf($text, $parameters);
}));
}
示例5: getNotificationTypes
/**
* @param \OCP\IL10N $l
* @return array Array "stringID of the type" => "translated string description for the setting"
*/
public function getNotificationTypes(\OCP\IL10N $l)
{
if (isset($this->notificationTypes[$l->getLanguageCode()])) {
return $this->notificationTypes[$l->getLanguageCode()];
}
// Allow apps to add new notification types
$notificationTypes = $this->activityManager->getNotificationTypes($l->getLanguageCode());
$this->notificationTypes[$l->getLanguageCode()] = $notificationTypes;
return $notificationTypes;
}
示例6: setUp
protected function setUp()
{
parent::setUp();
$this->urlGenerator = $this->getMockBuilder('OCP\\IURLGenerator')->disableOriginalConstructor()->getMock();
$this->infoCache = $this->getMockBuilder('OCA\\Activity\\ViewInfoCache')->disableOriginalConstructor()->getMock();
$this->l = $this->getMockBuilder('OCP\\IL10N')->disableOriginalConstructor()->getMock();
$this->l->expects($this->any())->method('t')->willReturnCallback(function ($string, $parameters) {
return vsprintf($string, $parameters);
});
}
示例7: setUp
protected function setUp()
{
parent::setUp();
$this->sessionMock = $this->getMockBuilder('OCA\\Encryption\\Session')->disableOriginalConstructor()->getMock();
$this->requestMock = $this->getMock('OCP\\IRequest');
$this->l10nMock = $this->getMockBuilder('OCP\\IL10N')->disableOriginalConstructor()->getMock();
$this->l10nMock->expects($this->any())->method('t')->will($this->returnCallback(function ($message) {
return $message;
}));
$this->controller = new StatusController('encryptionTest', $this->requestMock, $this->l10nMock, $this->sessionMock);
}
示例8: getNotificationTypes
/**
* @param \OCP\IL10N $l
* @return array Array "stringID of the type" => "translated string description for the setting"
*/
public function getNotificationTypes(\OCP\IL10N $l)
{
if (isset($this->notificationTypes[$l->getLanguageCode()])) {
return $this->notificationTypes[$l->getLanguageCode()];
}
$notificationTypes = array(self::TYPE_SHARED => $l->t('A file or folder has been <strong>shared</strong>'), self::TYPE_SHARE_CREATED => $l->t('A new file or folder has been <strong>created</strong>'), self::TYPE_SHARE_CHANGED => $l->t('A file or folder has been <strong>changed</strong>'), self::TYPE_SHARE_DELETED => $l->t('A file or folder has been <strong>deleted</strong>'), self::TYPE_SHARE_RESTORED => $l->t('A file or folder has been <strong>restored</strong>'));
// Allow other apps to add new notification types
$additionalNotificationTypes = $this->activityManager->getNotificationTypes($l->getLanguageCode());
$notificationTypes = array_merge($notificationTypes, $additionalNotificationTypes);
$this->notificationTypes[$l->getLanguageCode()] = $notificationTypes;
return $notificationTypes;
}
示例9: getNameString
public function getNameString(IL10N $l10n)
{
$name = $this->getName();
if ($name === null) {
$name = $l10n->t('Unknown artist');
if (!is_string($name)) {
/** @var \OC_L10N_String $name */
$name = $name->__toString();
}
}
return $name;
}
示例10: setUp
protected function setUp()
{
parent::setUp();
$this->manager = $this->getMockBuilder('OCA\\AnnouncementCenter\\Manager')->disableOriginalConstructor()->getMock();
$this->l = $this->getMockBuilder('OCP\\IL10N')->disableOriginalConstructor()->getMock();
$this->l->expects($this->any())->method('t')->willReturnCallback(function ($string, $args) {
return vsprintf($string, $args);
});
$this->factory = $this->getMockBuilder('OCP\\L10N\\IFactory')->disableOriginalConstructor()->getMock();
$this->factory->expects($this->any())->method('get')->willReturn($this->l);
$this->notifier = new NotificationsNotifier($this->manager, $this->factory);
}
示例11: updatePrivateKeyPassword
/**
* @NoAdminRequired
* @UseSession
*
* @param string $oldPassword
* @param string $newPassword
* @return DataResponse
*/
public function updatePrivateKeyPassword($oldPassword, $newPassword)
{
$result = false;
$uid = $this->userSession->getUser()->getUID();
$errorMessage = $this->l->t('Could not update the private key password.');
//check if password is correct
$passwordCorrect = $this->userManager->checkPassword($uid, $newPassword);
if ($passwordCorrect !== false) {
$encryptedKey = $this->keyManager->getPrivateKey($uid);
$decryptedKey = $this->crypt->decryptPrivateKey($encryptedKey, $oldPassword);
if ($decryptedKey) {
$encryptedKey = $this->crypt->symmetricEncryptFileContent($decryptedKey, $newPassword);
$header = $this->crypt->generateHeader();
if ($encryptedKey) {
$this->keyManager->setPrivateKey($uid, $header . $encryptedKey);
$this->session->setPrivateKey($decryptedKey);
$result = true;
}
} else {
$errorMessage = $this->l->t('The old password was not correct, please try again.');
}
} else {
$errorMessage = $this->l->t('The current log-in password was not correct, please try again.');
}
if ($result === true) {
$this->session->setStatus(Session::INIT_SUCCESSFUL);
return new DataResponse(['message' => (string) $this->l->t('Private key password successfully updated.')]);
} else {
return new DataResponse(['message' => (string) $errorMessage], Http::STATUS_BAD_REQUEST);
}
}
示例12: format
/**
* @param IEvent $event
* @param string $parameter The parameter to be formatted
* @param bool $allowHtml Should HTML be used to format the parameter?
* @param bool $verbose Should paths, names, etc be shortened or full length
* @return string The formatted parameter
*/
public function format(IEvent $event, $parameter, $allowHtml, $verbose = false)
{
// If the username is empty, the action has been performed by a remote
// user, or via a public share. We don't know the username in that case
if ($parameter === '') {
if ($allowHtml === null) {
return '<user display-name="' . Util::sanitizeHTML($this->l->t('"remote user"')) . '">' . Util::sanitizeHTML('') . '</user>';
}
if ($allowHtml) {
return '<strong>' . $this->l->t('"remote user"') . '</strong>';
} else {
return $this->l->t('"remote user"');
}
}
$user = $this->manager->get($parameter);
$displayName = $user ? $user->getDisplayName() : $parameter;
$parameter = Util::sanitizeHTML($parameter);
if ($allowHtml === null) {
return '<user display-name="' . Util::sanitizeHTML($displayName) . '">' . Util::sanitizeHTML($parameter) . '</user>';
}
if ($allowHtml) {
$avatarPlaceholder = '';
if ($this->config->getSystemValue('enable_avatars', true)) {
$avatarPlaceholder = '<div class="avatar" data-user="' . $parameter . '"></div>';
}
return $avatarPlaceholder . '<strong>' . Util::sanitizeHTML($displayName) . '</strong>';
} else {
return $displayName;
}
}
示例13: fopen
/**
* Asynchronously scan data that are written to the file
* @param string $path
* @param string $mode
* @return resource | bool
*/
public function fopen($path, $mode)
{
$stream = $this->storage->fopen($path, $mode);
if (is_resource($stream) && $this->isWritingMode($mode)) {
try {
$scanner = $this->scannerFactory->getScanner();
$scanner->initAsyncScan();
return CallBackWrapper::wrap($stream, null, function ($data) use($scanner) {
$scanner->onAsyncData($data);
}, function () use($scanner, $path) {
$status = $scanner->completeAsyncScan();
if (intval($status->getNumericStatus()) === \OCA\Files_Antivirus\Status::SCANRESULT_INFECTED) {
//prevent from going to trashbin
if (App::isEnabled('files_trashbin')) {
\OCA\Files_Trashbin\Storage::preRenameHook([]);
}
$owner = $this->getOwner($path);
$this->unlink($path);
if (App::isEnabled('files_trashbin')) {
\OCA\Files_Trashbin\Storage::postRenameHook([]);
}
\OC::$server->getActivityManager()->publishActivity('files_antivirus', Activity::SUBJECT_VIRUS_DETECTED, [$path, $status->getDetails()], Activity::MESSAGE_FILE_DELETED, [], $path, '', $owner, Activity::TYPE_VIRUS_DETECTED, Activity::PRIORITY_HIGH);
throw new InvalidContentException($this->l10n->t('Virus %s is detected in the file. Upload cannot be completed.', $status->getDetails()));
}
});
} catch (\Exception $e) {
$message = implode(' ', [__CLASS__, __METHOD__, $e->getMessage()]);
$this->logger->warning($message);
}
}
return $stream;
}
示例14: setLogLevel
/**
* set log level for logger
*
* @param int $level
* @return JSONResponse
*/
public function setLogLevel($level)
{
if ($level < 0 || $level > 4) {
return new JSONResponse(['message' => (string) $this->l10n->t('log-level out of allowed range')], Http::STATUS_BAD_REQUEST);
}
$this->config->setSystemValue('loglevel', $level);
return new JSONResponse(['level' => $level]);
}
示例15: validatePrice
private function validatePrice()
{
$price = $this->request->getParam("price");
$name = $this->l10n->t("Price");
if (!$this->validator->validateRequired($name, $price)) {
return;
}
$this->validator->validateFloat($name, $price);
}