Example #1
0
 /**
  * @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;
 }
Example #2
0
 /**
  * @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;
 }
Example #3
0
 /**
  * @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
  * @param bool $stripPath Shall we strip the path from file names?
  * @param bool $highlightParams Shall we highlight the parameters in the string?
  *             They will be highlighted with `<strong>`, all data will be passed through
  *             \OCP\Util::sanitizeHTML() before, so no XSS is possible.
  * @return string translated
  */
 public function translation($app, $text, $params, $stripPath = false, $highlightParams = false)
 {
     if (!$text) {
         return '';
     }
     $preparedParams = $this->parameterHelper->prepareParameters($params, $this->parameterHelper->getSpecialParameterList($app, $text), $stripPath, $highlightParams);
     // Allow apps to correctly translate their activities
     $translation = $this->activityManager->translate($app, $text, $preparedParams, $stripPath, $highlightParams, $this->l->getLanguageCode());
     if ($translation !== false) {
         return $translation;
     }
     $l = Util::getL10N($app, $this->l->getLanguageCode());
     return $l->t($text, $preparedParams);
 }
Example #4
0
 /**
  * @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
         $this->l = $this->l10nFactory->get('activity', $userLang);
         $parser = new PlainTextParser($this->l);
         $this->helper->setL10n($this->l);
         $this->helper->setUser($user);
         $description = (string) $this->l->t('Personal activity feed for %s', $user);
         $response = $this->data->get($this->helper, $this->settings, $user, 0, self::DEFAULT_PAGE_SIZE, 'desc', 'all');
         $data = $response['data'];
         $activities = [];
         foreach ($data as $activity) {
             $activity['subject_prepared'] = $parser->parseMessage($activity['subject_prepared']);
             $activity['message_prepared'] = $parser->parseMessage($activity['message_prepared']);
             $activities[] = $activity;
         }
     } catch (\UnexpectedValueException $e) {
         $this->l = $this->l10nFactory->get('activity');
         $description = (string) $this->l->t('Your feed URL is invalid');
         $activities = [['activity_id' => -1, 'timestamp' => time(), 'subject' => true, 'subject_prepared' => $description]];
     }
     $response = new TemplateResponse('activity', 'rss', ['rssLang' => $this->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;
 }
Example #5
0
 /**
  * @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 IParameter[] $params The parameter for the placeholder
  * @return string translated
  */
 public function translation($app, $text, array $params)
 {
     if (!$text) {
         return '';
     }
     $preparedParams = [];
     foreach ($params as $parameter) {
         $preparedParams[] = $parameter->format();
     }
     // Allow apps to correctly translate their activities
     $translation = $this->activityManager->translate($app, $text, $preparedParams, false, false, $this->l->getLanguageCode());
     if ($translation !== false) {
         return $translation;
     }
     $l = $this->l10Nfactory->get($app, $this->l->getLanguageCode());
     return $l->t($text, $preparedParams);
 }