当前位置: 首页>>代码示例>>PHP>>正文


PHP Util::getL10N方法代码示例

本文整理汇总了PHP中OCP\Util::getL10N方法的典型用法代码示例。如果您正苦于以下问题:PHP Util::getL10N方法的具体用法?PHP Util::getL10N怎么用?PHP Util::getL10N使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCP\Util的用法示例。


在下文中一共展示了Util::getL10N方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: show

 /**
  * @PublicPage
  * @NoCSRFRequired
  *
  * @return TemplateResponse
  */
 public function show()
 {
     try {
         $user = $this->activityManager->getCurrentUserId();
         $userLang = $this->config->getUserValue($user, 'core', 'lang');
         // Overwrite user and language in the helper
         $l = Util::getL10N('activity', $userLang);
         $l->forceLanguage($userLang);
         $this->helper->setL10n($l);
         $this->helper->setUser($user);
         $description = (string) $l->t('Personal activity feed for %s', $user);
         $activities = $this->data->read($this->helper, $this->settings, 0, self::DEFAULT_PAGE_SIZE, 'all', $user);
     } catch (\UnexpectedValueException $e) {
         $l = Util::getL10N('activity');
         $description = (string) $l->t('Your feed URL is invalid');
         $activities = [['activity_id' => -1, 'timestamp' => time(), 'subject' => true, 'subjectformatted' => ['full' => $description]]];
     }
     $response = new TemplateResponse('activity', 'rss', ['rssLang' => $l->getLanguageCode(), 'rssLink' => $this->urlGenerator->linkToRouteAbsolute('activity.Feed.show'), 'rssPubDate' => date('r'), 'description' => $description, 'activities' => $activities], '');
     if ($this->request->getHeader('accept') !== null && stristr($this->request->getHeader('accept'), 'application/rss+xml')) {
         $response->addHeader('Content-Type', 'application/rss+xml');
     } else {
         $response->addHeader('Content-Type', 'text/xml; charset=UTF-8');
     }
     return $response;
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:31,代码来源:feed.php

示例2: sendMail

 public static function sendMail($path)
 {
     if (!\OCP\User::isLoggedIn()) {
         return;
     }
     $config = \OC::$server->getConfig();
     $user = \OC::$server->getUserSession()->getUser();
     $email = $user->getEMailAddress();
     $displayName = $user->getDisplayName();
     if (strval($displayName) === '') {
         $displayName = $user->getUID();
     }
     \OCP\Util::writeLog('files_antivirus', 'Email: ' . $email, \OCP\Util::DEBUG);
     if (!empty($email)) {
         try {
             $tmpl = new \OCP\Template('files_antivirus', 'notification');
             $tmpl->assign('file', $path);
             $tmpl->assign('host', \OC::$server->getRequest()->getServerHost());
             $tmpl->assign('user', $displayName);
             $msg = $tmpl->fetchPage();
             $from = \OCP\Util::getDefaultEmailAddress('security-noreply');
             $mailer = \OC::$server->getMailer();
             $message = $mailer->createMessage();
             $message->setSubject(\OCP\Util::getL10N('files_antivirus')->t('Malware detected'));
             $message->setFrom([$from => 'ownCloud Notifier']);
             $message->setTo([$email => $displayName]);
             $message->setPlainBody($msg);
             $message->setHtmlBody($msg);
             $mailer->send($message);
         } catch (\Exception $e) {
             \OC::$server->getLogger()->error(__METHOD__ . ', exception: ' . $e->getMessage(), ['app' => 'files_antivirus']);
         }
     }
 }
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:34,代码来源:notification.php

示例3: testHooksDeleteUser

 /**
  * @dataProvider getTemplateData
  */
 public function testHooksDeleteUser($constructorActive, $forceActive)
 {
     $l = \OCP\Util::getL10N('activity');
     $navigation = new Navigation($l, \OC::$server->getActivityManager(), \OC::$server->getURLGenerator(), $constructorActive);
     $output = $navigation->getTemplate($forceActive)->fetchPage();
     // Get only the template part with the navigation links
     $navigationLinks = substr($output, strpos($output, '<li>') + 4);
     $navigationLinks = substr($navigationLinks, 0, strrpos($navigationLinks, '</li>'));
     // Remove tabs and new lines
     $navigationLinks = str_replace(array("\t", "\n"), '', $navigationLinks);
     // Turn the list of links into an array
     $navigationEntries = explode('</li><li>', $navigationLinks);
     $links = $navigation->getLinkList();
     // Check whether all top links are available
     foreach ($links['top'] as $link) {
         $found = false;
         foreach ($navigationEntries as $navigationEntry) {
             if (strpos($navigationEntry, 'data-navigation="' . $link['id'] . '"') !== false) {
                 $found = true;
                 $this->assertContains('href="' . $link['url'] . '">' . $link['name'] . '</a>', $navigationEntry);
                 if ($forceActive == $link['id']) {
                     $this->assertContains('class="active"', $navigationEntry);
                 } else {
                     if ($forceActive == null && $constructorActive == $link['id']) {
                         $this->assertContains('class="active"', $navigationEntry);
                     }
                 }
             }
         }
         $this->assertTrue($found, 'Could not find navigation entry "' . $link['name'] . '"');
     }
     // Check size of app links
     $this->assertSame(1, sizeof($links['apps']));
     $this->assertNotContains('data-navigation="files"', $navigationLinks, 'Files app should not be included when there are no other apps.');
 }
开发者ID:droiter,项目名称:openwrt-on-android,代码行数:38,代码来源:navigationtest.php

示例4: testGet

 /**
  * @dataProvider getData
  */
 public function testGet($user, $start, $count, $expected)
 {
     $_GET['start'] = $start;
     $_GET['count'] = $count;
     \OC_User::setUserId($user);
     $sessionUser = \OC::$server->getUserSession()->getUser();
     $this->assertInstanceOf('OCP\\IUser', $sessionUser);
     $this->assertEquals($user, $sessionUser->getUID());
     $activityManager = new ActivityManager($this->getMock('OCP\\IRequest'), $this->getMock('OCP\\IUserSession'), $this->getMock('OCP\\IConfig'));
     $activityManager->registerExtension(function () {
         return new Extension(\OCP\Util::getL10N('activity', 'en'), $this->getMock('\\OCP\\IURLGenerator'));
     });
     $this->overwriteService('ActivityManager', $activityManager);
     $result = \OCA\Activity\Api::get(array('_route' => 'get_cloud_activity'));
     $this->restoreService('ActivityManager');
     $this->assertEquals(100, $result->getStatusCode());
     $data = $result->getData();
     $this->assertEquals(sizeof($expected), sizeof($data));
     while (!empty($expected)) {
         $assertExpected = array_shift($expected);
         $assertData = array_shift($data);
         foreach ($assertExpected as $key => $value) {
             $this->assertArrayHasKey($key, $assertData);
             if ($value !== null) {
                 $this->assertEquals($value, $assertData[$key]);
             }
         }
     }
 }
开发者ID:ynott,项目名称:activity,代码行数:32,代码来源:apitest.php

示例5: testGetTypeIcon

 /**
  * @dataProvider getTypeIconData
  */
 public function testGetTypeIcon($type, $expected)
 {
     $manager = $this->getMock('\\OCP\\Activity\\IManager');
     $manager->expects($this->any())->method('getTypeIcon')->willReturn('');
     $dataHelper = new DataHelper($manager, new ParameterHelper($manager, new View(''), $this->getMockBuilder('OCP\\IConfig')->disableOriginalConstructor()->getMock(), Util::getL10N('activity')), Util::getL10N('activity'));
     $this->assertEquals($expected, $dataHelper->getTypeIcon($type));
 }
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:10,代码来源:datahelpertest.php

示例6: testTranslation

 /**
  * @dataProvider translationData
  */
 public function testTranslation($text, $params, $stripPath, $highlightParams, $expected)
 {
     $config = $this->getMockBuilder('OCP\\IConfig')->disableOriginalConstructor()->getMock();
     $config->expects($this->any())->method('getSystemValue')->with('enable_avatars', true)->willReturn(true);
     $dataHelper = new \OCA\Activity\DataHelper($this->getMock('\\OCP\\Activity\\IManager'), new \OCA\Activity\ParameterHelper(new \OC\Files\View(''), $config, \OCP\Util::getL10N('activity')), \OCP\Util::getL10N('activity'));
     $this->assertEquals($expected, (string) $dataHelper->translation('files', $text, $params, $stripPath, $highlightParams));
 }
开发者ID:droiter,项目名称:openwrt-on-android,代码行数:10,代码来源:datahelpertest.php

示例7: translation

 /**
  * @brief Translate an event string with the translations from the app where it was send from
  * @param string $app The app where this event comes from
  * @param string $text The text including placeholders
  * @param array $params The parameter for the placeholder
  * @return string translated
  */
 public static function translation($app, $text, $params)
 {
     $l = \OCP\Util::getL10N($app);
     $result = $l->t($text, $params);
     unset($l);
     return $result;
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:14,代码来源:data.php

示例8: setUp

	public function setUp() {
		parent::setUp();
		$this->originalWEBROOT =\OC::$WEBROOT;
		\OC::$WEBROOT = '';
		$l = \OCP\Util::getL10N('activity');
		$this->view = new \OC\Files\View('');
		$this->parameterHelper = new \OCA\Activity\ParameterHelper($this->view, $l);
	}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:8,代码来源:parameterhelpertest.php

示例9: testSetL10n

 public function testSetL10n()
 {
     /** @var GroupHelper $helper */
     /** @var \PHPUnit_Framework_MockObject_MockObject $dataHelperMock */
     list($helper, $dataHelperMock) = $this->setUpHelpers();
     $l = \OCP\Util::getL10N('activity', 'de');
     $dataHelperMock->expects($this->once())->method('setL10n')->with($l);
     $helper->setL10n($l);
 }
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:9,代码来源:grouphelpertest.php

示例10: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->activityLanguage = $activityLanguage = \OCP\Util::getL10N('activity', 'en');
     $activityManager = new ActivityManager($this->getMock('OCP\\IRequest'), $this->getMock('OCP\\IUserSession'), $this->getMock('OCP\\IConfig'));
     $activityManager->registerExtension(function () use($activityLanguage) {
         return new Extension($activityLanguage, $this->getMock('\\OCP\\IURLGenerator'));
     });
     $this->data = new Data($activityManager);
 }
开发者ID:Ebimedia,项目名称:owncloud,代码行数:10,代码来源:datatest.php

示例11: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->activityLanguage = $activityLanguage = \OCP\Util::getL10N('activity', 'en');
     $this->activityManager = new ActivityManager($this->getMock('OCP\\IRequest'), $this->getMock('OCP\\IUserSession'), $this->getMock('OCP\\IConfig'));
     $this->session = $this->getMockBuilder('OCP\\IUserSession')->disableOriginalConstructor()->getMock();
     $this->activityManager->registerExtension(function () use($activityLanguage) {
         return new Extension($activityLanguage, $this->getMock('\\OCP\\IURLGenerator'));
     });
     $this->data = new Data($this->activityManager, \OC::$server->getDatabaseConnection(), $this->session);
 }
开发者ID:amin-hedayati,项目名称:activity,代码行数:11,代码来源:datatest.php

示例12: register

 /**
  * Registers the preLogin hook to catch wether or not the user accepted the
  * disclaimer
  */
 public function register()
 {
     $callback = function ($user, $password) {
         $appId = Application::APP_ID;
         if (!isset($_POST[$appId . 'Checkbox'])) {
             $message = \OCP\Util::getL10N($appId)->t('Please read and ' . 'agree the disclaimer before proceeding');
             throw new LoginException($message);
         }
     };
     $this->userManager->listen('\\OC\\User', 'preLogin', $callback);
 }
开发者ID:RepoHell,项目名称:agreedisclaimer,代码行数:15,代码来源:userhooks.php

示例13: setUp

 protected function setUp()
 {
     parent::setUp();
     $this->originalWEBROOT = \OC::$WEBROOT;
     \OC::$WEBROOT = '';
     $l = \OCP\Util::getL10N('activity');
     $this->view = new \OC\Files\View('');
     $manager = $this->getMock('\\OCP\\Activity\\IManager');
     $manager->expects($this->any())->method('getSpecialParameterList')->will($this->returnValue(false));
     $this->parameterHelper = new \OCA\Activity\ParameterHelper($manager, $this->view, $l);
 }
开发者ID:BacLuc,项目名称:newGryfiPage,代码行数:11,代码来源:parameterhelpertest.php

示例14: testHooksDeleteUser

 /**
  * @dataProvider getTemplateData
  */
 public function testHooksDeleteUser($constructorActive, $forceActive, $matchTags, $notMatchTags)
 {
     $l = \OCP\Util::getL10N('activity');
     $navigation = new Navigation($l, $constructorActive);
     $output = $navigation->getTemplate($forceActive)->fetchPage();
     foreach ($matchTags as $matcher) {
         $this->assertTag($matcher, $output);
     }
     foreach ($notMatchTags as $matcher) {
         $this->assertNotTag($matcher, $output);
     }
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:15,代码来源:navigationtest.php

示例15: getNotificationTypes

 /**
  * Get a list with enabled notification types for a user
  *
  * @param string	$user	Name of the user
  * @param string	$method	Should be one of 'stream' or 'email'
  * @return array
  */
 public function getNotificationTypes($user, $method)
 {
     $l = Util::getL10N('activity');
     $types = $this->data->getNotificationTypes($l);
     $notificationTypes = array();
     foreach ($types as $type => $desc) {
         if ($this->getUserSetting($user, $method, $type)) {
             $notificationTypes[] = $type;
         }
     }
     return $notificationTypes;
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:19,代码来源:usersettings.php


注:本文中的OCP\Util::getL10N方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。