function _node_resource_load_node_files in Services 6.3
Same name and namespace in other branches
- 7.3 resources/node_resource.inc \_node_resource_load_node_files()
Generates an array of base64 encoded files attached to a node
Parameters
$nid: Number. Node ID
$include_file_contents: Bool Whether or not to include the base64_encoded version of the file.
Return value
Array. A list of all files from the given node
2 string references to '_node_resource_load_node_files'
- hook_services_resources in ./
services.services.api.php - Implementation of hook_services_resources(). Defines function signatures for resources available to services.
- _node_resource_definition in resources/
node_resource.inc - @file This file will define the resources for dealing directly with nodes
File
- resources/
node_resource.inc, line 458 - This file will define the resources for dealing directly with nodes
Code
function _node_resource_load_node_files($nid, $include_file_contents) {
module_load_include('inc', 'services', 'resources/file_resource');
$node = node_load($nid);
if (!isset($node->files)) {
return services_error(t('There are no files on given node.'));
}
$return = array();
foreach ($node->files as $file) {
// Do not return files that are not listed.
if (!$file->list) {
continue;
}
$return[$file->fid] = _file_resource_retrieve($file->fid, $include_file_contents);
}
return $return;
}