/** * create mail body for plain text and html mail * * @param string $filename the shared file * @param string $link link to the shared file * @param int $expiration expiration date (timestamp) * @return array an array of the html mail body and the plain text mail body */ private function createMailBody($filename, $link, $expiration) { $formatedDate = $expiration ? $this->l->l('date', $expiration) : null; $html = new \OC_Template("core", "mail", ""); $html->assign('link', $link); $html->assign('user_displayname', $this->senderDisplayName); $html->assign('filename', $filename); $html->assign('expiration', $formatedDate); $htmlMail = $html->fetchPage(); $alttext = new \OC_Template("core", "altmail", ""); $alttext->assign('link', $link); $alttext->assign('user_displayname', $this->senderDisplayName); $alttext->assign('filename', $filename); $alttext->assign('expiration', $formatedDate); $alttextMail = $alttext->fetchPage(); return array($htmlMail, $alttextMail); }
/** * @dataProvider firstDayDataProvider * @param $expected * @param $lang */ public function testFirstWeekDay($expected, $lang) { $l = new OC_L10N('test'); $l->forceLanguage($lang); $this->assertSame($expected, $l->l('firstday', 'firstday')); }
<?php OCP\JSON::checkLoggedIn(); OCP\JSON::callCheck(); $l = new OC_L10N('core'); if (!isset($_FILES['rootcert_import'])) { OCP\JSON::error(array('error' => 'No certificate uploaded')); exit; } $data = file_get_contents($_FILES['rootcert_import']['tmp_name']); $filename = basename($_FILES['rootcert_import']['name']); $certificateManager = \OC::$server->getCertificateManager(); try { $cert = $certificateManager->addCertificate($data, $filename); OCP\JSON::success(array('name' => $cert->getName(), 'commonName' => $cert->getCommonName(), 'organization' => $cert->getOrganization(), 'validFrom' => $cert->getIssueDate()->getTimestamp(), 'validTill' => $cert->getExpireDate()->getTimestamp(), 'validFromString' => $l->l('date', $cert->getIssueDate()), 'validTillString' => $l->l('date', $cert->getExpireDate()), 'issuer' => $cert->getIssuerName(), 'issuerOrganization' => $cert->getIssuerOrganization())); } catch (\Exception $e) { OCP\JSON::error(array('error' => 'Couldn\'t import SSL root certificate, allowed formats: PEM and DER')); }
/** * Creates a relative datetime string (with today, yesterday) or the normal date * * @param \OC_L10N $l * @param $timestamp * @return string */ protected function generateRelativeDatetime(\OC_L10N $l, $timestamp) { $dateOfTimestamp = $l->l('date', $timestamp); $dateOfToday = $l->l('date', time()); $dateOfYesterday = $l->l('date', time() - 3600 * 24); if ($dateOfTimestamp === $dateOfToday) { return (string) $l->t('Today %s', $l->l('time', $timestamp)); } if ($dateOfTimestamp === $dateOfYesterday) { return (string) $l->t('Yesterday %s', $l->l('time', $timestamp)); } return (string) $l->l('datetime', $timestamp); }
public function testNumericToDateTime() { $l = new OC_L10N('test'); $this->assertSame('February 13, 2009 23:31', $l->l('datetime', 1234567890)); }