-
Notifications
You must be signed in to change notification settings - Fork 0
/
pdfconverter.services.inc
128 lines (119 loc) · 3.1 KB
/
pdfconverter.services.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/**
* Implementation of hook_ctools_plugin_api().
*/
function pdfconverter_ctools_plugin_api($owner, $api) {
if ($owner == 'services' && $api == 'services') {
return array(
'version' => 3,
'file' => 'pdfconverter.services.inc', // Optional parameter to indicate the file name to load.
'path' => drupal_get_path('module', 'pdfconverter'), // If specifying the file key, path is required.
);
}
}
/**
* Implementation of hook_default_services_endpoint().
*/
function pdfconverter_default_services_endpoint() {
$endpoints = array();
$endpoint = new stdClass;
$endpoint->disabled = FALSE; /* Edit this to true to make a default endpoint disabled initially */
$endpoint->api_version = 3;
$endpoint->name = 'convert';
$endpoint->title = 'Convert';
$endpoint->server = 'rest_server';
$endpoint->path = 'convert';
$endpoint->authentication = array();
$endpoint->server_settings = array(
'rest_server' => array(
'formatters' => array(
'json' => TRUE,
'bencode' => FALSE,
'jsonp' => FALSE,
'php' => FALSE,
'rss' => FALSE,
'xml' => FALSE,
'yaml' => FALSE,
)
),
'parsers' => array(
'application/json' => TRUE,
'application/vnd.php.serialized' => FALSE,
'application/x-www-form-urlencoded' => FALSE,
'application/x-yaml' => FALSE,
'multipart/form-data' => FALSE,
)
);
$endpoint->resources = array(
'convert' => array(
'alias' => '',
'operations' => array(
'create' => array(
'enabled' => 1,
),
),
),
);
$endpoint->debug = 1;
$endpoint->status = 1;
$endpoints[] = $endpoint;
return $endpoints;
}
/**
*
* Implementation of hook_services_resources
*
* @return array
* it returns an array with the url of main file and number of parts
*/
function pdfconverter_services_resources()
{
return array(
/**
* Definition of convert service
*/
'convert' => convert_service_definition(),
);
}
/**
* Function that returns the convert array
* service definition
*/
function convert_service_definition() {
return array(
'create' => array(
'help' => 'Retrieves the converted files data',
'callback' => '_convert_retrieve',
'access callback' => '_convert_access',
'args' => array(
'args' => array(
'name' => 'url',
'type' => 'string',
'description' => 'The url of the file to be converted',
'source' => array('data'),
'optional' => 'false',
),
),
),
);
}
function _convert_retrieve(){
//system_retrieve_file($url, $destination = NULL, $managed = FALSE, $replace = FILE_EXISTS_RENAME)
$result = new stdClass();
$result->main_url = 'here';
$result->parts = 5;
return $result;
}
/**
*
* Access callback for convert service
* @param $opt
* the required access: view
* @param $args
* the arguments passed in the request, the first argument is the category id
*/
function _convert_access()
{
$access = TRUE;
return $access;
}