Drupal 6, Services 3.
Module: services_node_form
Thanks to direct and indirect help from @grzegorzbartman and @entendu.
Drupal 6, Services 3.
Module: services_node_form
Thanks to direct and indirect help from @grzegorzbartman and @entendu.
<?php | |
function _services_node_form_retrieve($content_type) { | |
$form_state = array(); | |
$new_node = new stdClass(); | |
$new_node->type = $content_type; | |
module_load_include('inc', 'node', 'node.pages'); | |
$form = drupal_retrieve_form($content_type.'_node_form', $form_state, $new_node); | |
drupal_prepare_form($content_type.'_node_form', $form, $form_state); | |
//drupad has some interesting functions that might be useful here... | |
//drupad_fix_node_form_admin_order($form); | |
//drupad_convert_form_options_to_strict_array($form); | |
return $form; | |
} | |
function _services_node_form_access(){ | |
if ($op == 'view') { | |
return user_access('view node form', $account); | |
} else { | |
drupal_access_denied(); | |
}; | |
} | |
?> |
name = Services Node Form | |
description = Return Node Form as Services resource. | |
package = Services - resources | |
dependencies[] = services | |
files[] = form_service.inc | |
files[] = form_service.module | |
core = 6.x |
<?php | |
/** | |
* Implementation of hook_perm(). | |
*/ | |
function services_node_form_perm() { | |
return array( | |
'view node form', | |
); | |
} | |
/** | |
* Implementation of hook_services_resources(). | |
*/ | |
function services_node_form_services_resources() { | |
return array( | |
'form' => array( | |
'retrieve' => array( | |
'help' => 'Retrieves a node form', | |
'file' => array('file' => 'inc', 'module' => 'services_node_form'), | |
'callback' => '_services_node_form_retrieve', | |
'access callback' => '_services_node_form_access', | |
'access arguments' => array('view node form'), | |
'access arguments append' => TRUE, | |
'args' => array( | |
array( | |
'name' => 'content_type', | |
'type' => 'string', | |
'description' => 'The content type of the form to get', | |
'source' => array('path' => '0'), | |
'optional' => FALSE, | |
), | |
), | |
), | |
), | |
); | |
} | |
?> |