Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
our_own_cloud_project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
die_coolen_jungs
our_own_cloud_project
Commits
7a24f0cd
Commit
7a24f0cd
authored
12 years ago
by
Bart Visscher
Browse files
Options
Downloads
Patches
Plain Diff
Make calling ocs/v1.php/config work
parent
180bd69d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
lib/api.php
+12
-5
12 additions, 5 deletions
lib/api.php
lib/app.php
+1
-1
1 addition, 1 deletion
lib/app.php
lib/ocs.php
+18
-0
18 additions, 0 deletions
lib/ocs.php
ocs/v1.php
+10
-2
10 additions, 2 deletions
ocs/v1.php
with
41 additions
and
8 deletions
lib/api.php
+
12
−
5
View file @
7a24f0cd
...
...
@@ -43,7 +43,8 @@ class OC_API {
$name
=
str_replace
(
array
(
'/'
,
'{'
,
'}'
),
'_'
,
$name
);
if
(
!
isset
(
self
::
$actions
[
$name
])){
OC
::
$router
->
create
(
$name
,
$url
.
'.{_format}'
)
->
defaults
(
array
(
'_format'
=>
'xml'
))
->
defaults
(
array
(
'_format'
=>
'xml'
))
->
requirements
(
array
(
'_format'
=>
'xml|json'
))
->
action
(
'OC_API'
,
'call'
);
self
::
$actions
[
$name
]
=
array
();
}
...
...
@@ -55,7 +56,7 @@ class OC_API {
* @param array $parameters
*/
public
static
function
call
(
$parameters
){
$name
=
$parameters
[
'_
nam
e'
];
$name
=
$parameters
[
'_
rout
e'
];
// Loop through registered actions
foreach
(
self
::
$actions
[
$name
]
as
$action
){
$app
=
$action
[
'app'
];
...
...
@@ -107,8 +108,14 @@ class OC_API {
* @param int|array $response the response
* @param string $format the format xml|json
*/
private
function
respond
(
$response
,
$format
=
'json'
){
// TODO respond in the correct format
private
static
function
respond
(
$response
,
$format
=
'json'
){
if
(
$format
==
'json'
)
{
echo
json_encode
(
$response
);
}
else
if
(
$format
==
'xml'
)
{
// TODO array to xml
}
else
{
var_dump
(
$format
,
$response
);
}
}
}
\ No newline at end of file
}
This diff is collapsed.
Click to expand it.
lib/app.php
+
1
−
1
View file @
7a24f0cd
...
...
@@ -145,7 +145,7 @@ class OC_App{
* @param string $appid the id of the app to check
* @return bool
*/
public
function
isShipped
(
$appid
){
public
static
function
isShipped
(
$appid
){
$info
=
self
::
getAppInfo
(
$appid
);
if
(
isset
(
$info
[
'shipped'
])
&&
$info
[
'shipped'
]
==
'true'
){
return
true
;
...
...
This diff is collapsed.
Click to expand it.
lib/ocs.php
+
18
−
0
View file @
7a24f0cd
...
...
@@ -251,6 +251,24 @@ class OC_OCS {
exit
();
}
public
static
function
notFound
()
{
if
(
$_SERVER
[
'REQUEST_METHOD'
]
==
'GET'
)
{
$method
=
'get'
;
}
elseif
(
$_SERVER
[
'REQUEST_METHOD'
]
==
'PUT'
)
{
$method
=
'put'
;
parse_str
(
file_get_contents
(
"php://input"
),
$put_vars
);
}
elseif
(
$_SERVER
[
'REQUEST_METHOD'
]
==
'POST'
)
{
$method
=
'post'
;
}
else
{
echo
(
'internal server error: method not supported'
);
exit
();
}
$format
=
self
::
readData
(
$method
,
'format'
,
'text'
,
''
);
$txt
=
'Invalid query, please check the syntax. API specifications are here: http://www.freedesktop.org/wiki/Specifications/open-collaboration-services. DEBUG OUTPUT:'
.
"
\n
"
;
$txt
.
=
OC_OCS
::
getDebugOutput
();
echo
(
OC_OCS
::
generateXml
(
$format
,
'failed'
,
999
,
$txt
));
}
/**
* generated some debug information to make it easier to find faild API calls
* @return debug data string
...
...
This diff is collapsed.
Click to expand it.
ocs/v1.php
+
10
−
2
View file @
7a24f0cd
...
...
@@ -22,5 +22,13 @@
*/
require_once
(
'../lib/base.php'
);
@
ob_clean
();
OC_OCS
::
handle
();
use
Symfony\Component\Routing\Exception\ResourceNotFoundException
;
OC
::
$router
->
useCollection
(
'ocs'
);
OC
::
$router
->
loadRoutes
();
try
{
OC
::
$router
->
match
(
$_SERVER
[
'PATH_INFO'
]);
}
catch
(
ResourceNotFoundException
$e
)
{
OC_OCS
::
notFound
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment