Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
die_coolen_jungs
our_own_cloud_project
Commits
450e2f3b
Commit
450e2f3b
authored
Dec 18, 2015
by
Morris Jobke
Browse files
Move OC_Helper code to OCP\Util for linkToRemote
parent
e42f262d
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/private/helper.php
View file @
450e2f3b
...
...
@@ -53,32 +53,6 @@ use Symfony\Component\Process\ExecutableFinder;
class
OC_Helper
{
private
static
$templateManager
;
/**
* Creates an url for remote use
* @param string $service id
* @return string the url
*
* Returns a url to the given service.
*/
public
static
function
linkToRemoteBase
(
$service
)
{
return
OC
::
$server
->
getURLGenerator
()
->
linkTo
(
''
,
'remote.php'
)
.
'/'
.
$service
;
}
/**
* Creates an absolute url for remote use
* @param string $service id
* @param bool $add_slash
* @return string the url
*
* Returns a absolute url to the given service.
*/
public
static
function
linkToRemote
(
$service
,
$add_slash
=
true
)
{
return
OC
::
$server
->
getURLGenerator
()
->
getAbsoluteURL
(
self
::
linkToRemoteBase
(
$service
)
.
((
$add_slash
&&
$service
[
strlen
(
$service
)
-
1
]
!=
'/'
)
?
'/'
:
''
)
);
}
/**
* Creates an absolute url for public use
* @param string $service id
...
...
lib/public/util.php
View file @
450e2f3b
...
...
@@ -282,7 +282,11 @@ class Util {
* @since 4.0.0
*/
public
static
function
linkToRemote
(
$service
)
{
return
(
\
OC_Helper
::
linkToRemote
(
$service
));
$urlGenerator
=
\
OC
::
$server
->
getURLGenerator
();
$remoteBase
=
$urlGenerator
->
linkTo
(
''
,
'remote.php'
)
.
'/'
.
$service
;
return
$urlGenerator
->
getAbsoluteURL
(
$remoteBase
.
((
$service
[
strlen
(
$service
)
-
1
]
!=
'/'
)
?
'/'
:
''
)
);
}
/**
...
...
tests/lib/helper.php
View file @
450e2f3b
...
...
@@ -243,38 +243,6 @@ class Test_Helper extends \Test\TestCase {
// Url generator methods
/**
* @small
* test linkToRemoteBase URL construction
*/
public
function
testLinkToRemoteBase
()
{
\
OC
::
$WEBROOT
=
''
;
$result
=
\
OC_Helper
::
linkToRemoteBase
(
'webdav'
);
$this
->
assertEquals
(
'/remote.php/webdav'
,
$result
);
\
OC
::
$WEBROOT
=
'/owncloud'
;
$result
=
\
OC_Helper
::
linkToRemoteBase
(
'webdav'
);
$this
->
assertEquals
(
'/owncloud/remote.php/webdav'
,
$result
);
}
/**
* @small
* test linkToRemote URL construction
*/
public
function
testLinkToRemote
()
{
\
OC
::
$WEBROOT
=
''
;
$result
=
\
OC_Helper
::
linkToRemote
(
'webdav'
);
$this
->
assertEquals
(
'http://localhost/remote.php/webdav/'
,
$result
);
$result
=
\
OC_Helper
::
linkToRemote
(
'webdav'
,
false
);
$this
->
assertEquals
(
'http://localhost/remote.php/webdav'
,
$result
);
\
OC
::
$WEBROOT
=
'/owncloud'
;
$result
=
\
OC_Helper
::
linkToRemote
(
'webdav'
);
$this
->
assertEquals
(
'http://localhost/owncloud/remote.php/webdav/'
,
$result
);
$result
=
\
OC_Helper
::
linkToRemote
(
'webdav'
,
false
);
$this
->
assertEquals
(
'http://localhost/owncloud/remote.php/webdav'
,
$result
);
}
/**
* @small
* test linkToPublic URL construction
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment