本文整理汇总了PHP中OCP\IURLGenerator类的典型用法代码示例。如果您正苦于以下问题:PHP IURLGenerator类的具体用法?PHP IURLGenerator怎么用?PHP IURLGenerator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IURLGenerator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: htmlError
/**
* @param IURLGenerator $urlGenerator
* @param string $appName
* @param \Exception $exception
*
* @return RedirectResponse
*/
public function htmlError($urlGenerator, $appName, Exception $exception)
{
$message = $exception->getMessage();
$code = $this->getHttpStatusCode($exception);
$url = $urlGenerator->linkToRoute($appName . '.page.error_page', ['code' => $code]);
$response = new RedirectResponse($url);
$response->addCookie('galleryErrorMessage', $message);
return $response;
}
开发者ID:patman15,项目名称:galleryplus,代码行数:16,代码来源:httperror.php
示例2: toCollection
public function toCollection(IURLGenerator $urlGenerator, $userFolder)
{
$nodes = $userFolder->getById($this->getFileId());
if (count($nodes) == 0) {
throw new \OCP\Files\NotFoundException();
}
// get the first valid node
$node = $nodes[0];
$path = $node->getPath();
$relativePath = $userFolder->getRelativePath($path);
return array('title' => $this->getTitle(), 'number' => $this->getNumber(), 'artistId' => $this->getArtistId(), 'albumId' => $this->getAlbumId(), 'files' => array($this->getMimetype() => $urlGenerator->getAbsoluteUrl('remote.php/webdav' . $relativePath)), 'id' => $this->getId());
}
开发者ID:ndurchx,项目名称:music,代码行数:12,代码来源:track.php
示例3: format
/**
* @param IEvent $event
* @param string $parameter The parameter to be formatted
* @return string The formatted parameter
*/
public function format(IEvent $event, $parameter)
{
$param = $this->fixLegacyFilename($parameter);
// If the activity is about the very same file, we use the current path
// for the link generation instead of the one that was saved.
$fileId = '';
if (is_array($param)) {
$fileId = key($param);
$param = $param[$fileId];
$info = $this->infoCache->getInfoById($this->user, $fileId, $param);
} elseif ($event->getObjectType() === 'files' && $event->getObjectName() === $param) {
$fileId = $event->getObjectId();
$info = $this->infoCache->getInfoById($this->user, $fileId, $param);
} else {
$info = $this->infoCache->getInfoByPath($this->user, $param);
}
if ($info['is_dir']) {
$linkData = ['dir' => $info['path']];
} else {
$parentDir = substr_count($info['path'], '/') === 1 ? '/' : dirname($info['path']);
$fileName = basename($info['path']);
$linkData = ['dir' => $parentDir, 'scrollto' => $fileName];
}
if ($info['view'] !== '') {
$linkData['view'] = $info['view'];
}
$param = trim($param, '/');
$fileLink = $this->urlGenerator->linkToRouteAbsolute('files.view.index', $linkData);
return '<file link="' . $fileLink . '" id="' . Util::sanitizeHTML($fileId) . '">' . Util::sanitizeHTML($param) . '</file>';
}
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:35,代码来源:FileFormatter.php
示例4: testIndexWithIE8RedirectAndViewAndDirDefined
public function testIndexWithIE8RedirectAndViewAndDirDefined()
{
$this->request->expects($this->once())->method('isUserAgent')->with(['/MSIE 8.0/'])->will($this->returnValue(true));
$this->urlGenerator->expects($this->once())->method('linkToRoute')->with('files.view.index')->will($this->returnValue('/apps/files/'));
$expected = new RedirectResponse('/apps/files/#?dir=MyDir&view=MyView');
$this->assertEquals($expected, $this->viewController->index('MyDir', 'MyView'));
}
开发者ID:kenwi,项目名称:core,代码行数:7,代码来源:ViewControllerTest.php
示例5: testFormat
/**
* @dataProvider dataFormat
*
* @param string $user
* @param string $parameter
* @param bool $isDir
* @param array $info
* @param bool $allowHtml
* @param bool $verbose
* @param string $expected
*/
public function testFormat($user, $parameter, $isDir, array $info, $allowHtml, $verbose, $expected)
{
/** @var \OCP\Activity\IEvent|\PHPUnit_Framework_MockObject_MockObject $event */
$event = $this->getMockBuilder('OCP\\Activity\\IEvent')->disableOriginalConstructor()->getMock();
if (!empty($info)) {
$event->expects($this->once())->method('getObjectType')->willReturn('files');
$event->expects($this->once())->method('getObjectName')->willReturn($parameter);
$event->expects($this->once())->method('getObjectId')->willReturn(42);
}
$this->urlGenerator->expects($allowHtml ? $this->once() : $this->never())->method('linkTo')->with('files', 'index.php', $this->anything())->willReturnCallback(function ($app, $file, $parameters) {
$paramList = [];
foreach ($parameters as $key => $value) {
$paramList[] = $key . '=' . urlencode($value);
}
return $app . '/' . $file . '?' . implode('&', $paramList);
});
$formatter = $this->getFormatter(['fixLegacyFilename'], $user);
$formatter->expects($this->once())->method('fixLegacyFilename')->willReturnArgument(0);
if (!empty($info)) {
$this->infoCache->expects($this->once())->method('getInfoById')->with($user, 42, $parameter)->willReturn($info);
} else {
$this->infoCache->expects($this->once())->method('getInfoByPath')->with($user, $parameter)->willReturn(['path' => $parameter, 'is_dir' => $isDir, 'exists' => true, 'view' => '']);
}
$this->assertSame($expected, $formatter->format($event, $parameter, $allowHtml, $verbose));
}
开发者ID:arietimmerman,项目名称:activity,代码行数:36,代码来源:fileformattertest.php
示例6: 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
示例7: execute
/**
* {@inheritdoc }
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$path = $input->getOption('path');
$privateKeyPath = $input->getOption('privateKey');
$keyBundlePath = $input->getOption('certificate');
if (is_null($path) || is_null($privateKeyPath) || is_null($keyBundlePath)) {
$documentationUrl = $this->urlGenerator->linkToDocs('developer-code-integrity');
$output->writeln('This command requires the --path, --privateKey and --certificate.');
$output->writeln('Example: ./occ integrity:sign-app --path="/Users/lukasreschke/Programming/myapp/" --privateKey="/Users/lukasreschke/private/myapp.key" --certificate="/Users/lukasreschke/public/mycert.crt"');
$output->writeln('For more information please consult the documentation: ' . $documentationUrl);
return null;
}
$privateKey = $this->fileAccessHelper->file_get_contents($privateKeyPath);
$keyBundle = $this->fileAccessHelper->file_get_contents($keyBundlePath);
if ($privateKey === false) {
$output->writeln(sprintf('Private key "%s" does not exists.', $privateKeyPath));
return null;
}
if ($keyBundle === false) {
$output->writeln(sprintf('Certificate "%s" does not exists.', $keyBundlePath));
return null;
}
$rsa = new RSA();
$rsa->loadKey($privateKey);
$x509 = new X509();
$x509->loadX509($keyBundle);
$x509->setPrivateKey($rsa);
$this->checker->writeAppSignature($path, $x509, $rsa);
$output->writeln('Successfully signed "' . $path . '"');
}
开发者ID:GitHubUser4234,项目名称:core,代码行数:33,代码来源:SignApp.php
示例8: setRSSToken
public function setRSSToken($rssToken)
{
if ($rssToken) {
$this->rssLink = $this->URLGenerator->getAbsoluteURL($this->URLGenerator->linkToRoute('activity.rss', array('token' => $rssToken)));
} else {
$this->rssLink = '';
}
}
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:8,代码来源:navigation.php
示例9: logout
/**
* @NoAdminRequired
* @UseSession
*
* @return RedirectResponse
*/
public function logout()
{
$loginToken = $this->request->getCookie('oc_token');
if (!is_null($loginToken)) {
$this->config->deleteUserValue($this->userSession->getUser()->getUID(), 'login_token', $loginToken);
}
$this->userSession->logout();
return new RedirectResponse($this->urlGenerator->linkToRouteAbsolute('core.login.showLoginForm'));
}
开发者ID:stweil,项目名称:owncloud-core,代码行数:15,代码来源:LoginController.php
示例10: getPreviewLink
/**
* @param string $path
* @param bool $isDir
* @return string
*/
protected function getPreviewLink($path, $isDir)
{
if ($isDir) {
return $this->urlGenerator->linkTo('files', 'index.php', array('dir' => $path));
} else {
$parentDir = substr_count($path, '/') === 1 ? '/' : dirname($path);
$fileName = basename($path);
return $this->urlGenerator->linkTo('files', 'index.php', array('dir' => $parentDir, 'scrollto' => $fileName));
}
}
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:15,代码来源:display.php
示例11: testLogoutWithToken
public function testLogoutWithToken()
{
$this->request->expects($this->once())->method('getCookie')->with('oc_token')->willReturn('MyLoginToken');
$user = $this->getMock('\\OCP\\IUser');
$user->expects($this->once())->method('getUID')->willReturn('JohnDoe');
$this->userSession->expects($this->once())->method('getUser')->willReturn($user);
$this->config->expects($this->once())->method('deleteUserValue')->with('JohnDoe', 'login_token', 'MyLoginToken');
$this->urlGenerator->expects($this->once())->method('linkToRouteAbsolute')->with('core.login.showLoginForm')->willReturn('/login');
$expected = new RedirectResponse('/login');
$this->assertEquals($expected, $this->loginController->logout());
}
开发者ID:stweil,项目名称:owncloud-core,代码行数:11,代码来源:LoginControllerTest.php
示例12: getLinkList
/**
* Get all items for the users we want to send an email to
*
* @return array Notification data (user => array of rows from the table)
*/
public function getLinkList()
{
$topEntries = [['id' => 'all', 'name' => (string) $this->l->t('All Activities'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList')]];
if ($this->user && $this->userSettings->getUserSetting($this->user, 'setting', 'self')) {
$topEntries[] = ['id' => 'self', 'name' => (string) $this->l->t('Activities by you'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'self'))];
$topEntries[] = ['id' => 'by', 'name' => (string) $this->l->t('Activities by others'), 'url' => $this->URLGenerator->linkToRoute('activity.Activities.showList', array('filter' => 'by'))];
}
$additionalEntries = $this->activityManager->getNavigation();
$topEntries = array_merge($topEntries, $additionalEntries['top']);
return array('top' => $topEntries, 'apps' => $additionalEntries['apps']);
}
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:16,代码来源:navigation.php
示例13: parse
/**
* @param string $file the xml file to be loaded
* @return null|array where null is an indicator for an error
*/
public function parse($file)
{
if (!file_exists($file)) {
return null;
}
libxml_use_internal_errors(true);
$loadEntities = libxml_disable_entity_loader(false);
$xml = simplexml_load_file($file);
libxml_disable_entity_loader($loadEntities);
if ($xml == false) {
libxml_clear_errors();
return null;
}
$array = $this->xmlToArray($xml);
if (is_null($array)) {
return null;
}
if (!array_key_exists('info', $array)) {
$array['info'] = array();
}
if (!array_key_exists('remote', $array)) {
$array['remote'] = array();
}
if (!array_key_exists('public', $array)) {
$array['public'] = array();
}
if (!array_key_exists('types', $array)) {
$array['types'] = array();
}
if (array_key_exists('documentation', $array) && is_array($array['documentation'])) {
foreach ($array['documentation'] as $key => $url) {
// If it is not an absolute URL we assume it is a key
// i.e. admin-ldap will get converted to go.php?to=admin-ldap
if (!$this->httpHelper->isHTTPURL($url)) {
$url = $this->urlGenerator->linkToDocs($url);
}
$array['documentation'][$key] = $url;
}
}
if (array_key_exists('types', $array)) {
if (is_array($array['types'])) {
foreach ($array['types'] as $type => $v) {
unset($array['types'][$type]);
if (is_string($type)) {
$array['types'][] = $type;
}
}
} else {
$array['types'] = array();
}
}
return $array;
}
开发者ID:TechArea,项目名称:core,代码行数:57,代码来源:infoparser.php
示例14: testAppNavigation
public function testAppNavigation()
{
$this->navigationManager->expects($this->once())->method('add')->willReturnCallback(function ($closure) {
$this->assertInstanceOf('\\Closure', $closure);
$navigation = $closure();
$this->assertInternalType('array', $navigation);
$this->assertCount(5, $navigation);
$this->assertSame(['id' => 'announcementcenter', 'order' => 10, 'href' => '/apps/announcementcenter/announcement', 'icon' => '/apps/announcementcenter/img/announcementcenter.svg', 'name' => 'Announcements'], $navigation);
});
$this->urlGenerator->expects($this->once())->method('linkToRoute')->with('announcementcenter.page.index')->willReturn('/apps/announcementcenter/announcement');
$this->urlGenerator->expects($this->once())->method('imagePath')->with('announcementcenter', 'announcementcenter.svg')->willReturn('/apps/announcementcenter/img/announcementcenter.svg');
$this->languageFactory->expects($this->once())->method('get')->with('announcementcenter')->willReturn($this->language);
include __DIR__ . '/../../appinfo/app.php';
}
开发者ID:arietimmerman,项目名称:announcementcenter,代码行数:14,代码来源:AppTest.php
示例15: redirectToErrorPage
/**
* Redirects the client to an error page
*
* @param string $message
* @param int $code
*
* @return RedirectResponse
*/
private function redirectToErrorPage($message, $code)
{
$url = $this->urlGenerator->linkToRoute($this->appName . '.page.error_page', ['code' => $code]);
$response = new RedirectResponse($url);
$response->addCookie('galleryErrorMessage', $message);
return $response;
}
开发者ID:patman15,项目名称:galleryplus,代码行数:15,代码来源:checkmiddleware.php
示例16: create
/**
* @NoAdminRequired
*
* @param string $username
* @param string $password
* @param array $groups
* @param string $email
* @return DataResponse
*/
public function create($username, $password, array $groups = array(), $email = '')
{
if ($email !== '' && !$this->mail->validateAddress($email)) {
return new DataResponse(array('message' => (string) $this->l10n->t('Invalid mail address')), Http::STATUS_UNPROCESSABLE_ENTITY);
}
if (!$this->isAdmin) {
$userId = $this->userSession->getUser()->getUID();
if (!empty($groups)) {
foreach ($groups as $key => $group) {
if (!$this->subAdminFactory->isGroupAccessible($userId, $group)) {
unset($groups[$key]);
}
}
}
if (empty($groups)) {
$groups = $this->subAdminFactory->getSubAdminsOfGroups($userId);
}
}
if ($this->userManager->userExists($username)) {
return new DataResponse(array('message' => (string) $this->l10n->t('A user with that name already exists.')), Http::STATUS_CONFLICT);
}
try {
$user = $this->userManager->createUser($username, $password);
} catch (\Exception $exception) {
return new DataResponse(array('message' => (string) $this->l10n->t('Unable to create user.')), Http::STATUS_FORBIDDEN);
}
if ($user instanceof User) {
if ($groups !== null) {
foreach ($groups as $groupName) {
$group = $this->groupManager->get($groupName);
if (empty($group)) {
$group = $this->groupManager->createGroup($groupName);
}
$group->addUser($user);
}
}
/**
* Send new user mail only if a mail is set
*/
if ($email !== '') {
$this->config->setUserValue($username, 'settings', 'email', $email);
// data for the mail template
$mailData = array('username' => $username, 'url' => $this->urlGenerator->getAbsoluteURL('/'));
$mail = new TemplateResponse('settings', 'email.new_user', $mailData, 'blank');
$mailContent = $mail->render();
$mail = new TemplateResponse('settings', 'email.new_user_plain_text', $mailData, 'blank');
$plainTextMailContent = $mail->render();
$subject = $this->l10n->t('Your %s account was created', [$this->defaults->getName()]);
try {
$this->mail->send($email, $username, $subject, $mailContent, $this->fromMailAddress, $this->defaults->getName(), 1, $plainTextMailContent);
} catch (\Exception $e) {
$this->log->error("Can't send new user mail to {$email}: " . $e->getMessage(), array('app' => 'settings'));
}
}
// fetch users groups
$userGroups = $this->groupManager->getUserGroupIds($user);
return new DataResponse($this->formatUserForIndex($user, $userGroups), Http::STATUS_CREATED);
}
return new DataResponse(array('message' => (string) $this->l10n->t('Unable to create user.')), Http::STATUS_FORBIDDEN);
}
开发者ID:kebenxiaoming,项目名称:owncloudRedis,代码行数:69,代码来源:userscontroller.php
示例17: sendEmailToUser
/**
* Send a notification to one user
*
* @param string $userName Username of the recipient
* @param string $email Email address of the recipient
* @param string $lang Selected language of the recipient
* @param string $timezone Selected timezone of the recipient
* @param int $maxTime
*/
public function sendEmailToUser($userName, $email, $lang, $timezone, $maxTime)
{
$user = $this->userManager->get($userName);
if (!$user instanceof IUser) {
return;
}
list($mailData, $skippedCount) = $this->getItemsForUser($userName, $maxTime);
$l = $this->getLanguage($lang);
$this->dataHelper->setUser($userName);
$this->dataHelper->setL10n($l);
$activityList = array();
foreach ($mailData as $activity) {
$relativeDateTime = $this->dateFormatter->formatDateTimeRelativeDay($activity['amq_timestamp'], 'long', 'medium', new \DateTimeZone($timezone), $l);
$activityList[] = array($this->dataHelper->translation($activity['amq_appid'], $activity['amq_subject'], $this->dataHelper->getParameters($activity['amq_subjectparams'])), $relativeDateTime);
}
$alttext = new Template('activity', 'email.notification', '');
$alttext->assign('username', $user->getDisplayName());
$alttext->assign('activities', $activityList);
$alttext->assign('skippedCount', $skippedCount);
$alttext->assign('owncloud_installation', $this->urlGenerator->getAbsoluteURL('/'));
$alttext->assign('overwriteL10N', $l);
$emailText = $alttext->fetchPage();
$message = $this->mailer->createMessage();
$message->setTo([$email => $user->getDisplayName()]);
$message->setSubject((string) $l->t('Activity notification'));
$message->setPlainBody($emailText);
$message->setFrom([$this->getSenderData('email') => $this->getSenderData('name')]);
$this->mailer->send($message);
}
开发者ID:enoch85,项目名称:owncloud-testserver,代码行数:38,代码来源:mailqueuehandler.php
示例18: testRescanFailedIntegrityCheck
public function testRescanFailedIntegrityCheck()
{
$this->checker->expects($this->once())->method('runInstanceVerification');
$this->urlGenerator->expects($this->once())->method('linkToRoute')->with('settings_admin')->will($this->returnValue('/admin'));
$expected = new RedirectResponse('/admin');
$this->assertEquals($expected, $this->checkSetupController->rescanFailedIntegrityCheck());
}
开发者ID:farukuzun,项目名称:core-1,代码行数:7,代码来源:CheckSetupControllerTest.php
示例19: createPublicUrl
private function createPublicUrl($parameter)
{
$route = 'myapp.author_api.do_something';
$parameters = array('id' => $parameter);
$url = $this->urlGenerator->linkToRoute($route, $parameters);
return new RedirectResponse($url);
}
开发者ID:Werdffelynir,项目名称:owncollab_chart,代码行数:7,代码来源:maincontroller.php
示例20: 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
$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;
}
开发者ID:drognisep,项目名称:Portfolio-Site,代码行数:38,代码来源:Feed.php
注:本文中的OCP\IURLGenerator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论