- <?php
-  * @file
-  * Provides File module pages for testing purposes.
-  */
- 
-  * Implements hook_menu().
-  */
- function file_module_test_menu() {
-   $items = array();
- 
-   $items['file/test'] = array(
-     'title' => 'Managed file test',
-     'page callback' => 'backdrop_get_form',
-     'page arguments' => array('file_module_test_form'),
-     'access arguments' => array('access content'),
-   );
- 
-   return $items;
- }
- 
-  * Form constructor for testing a 'managed_file' element.
-  *
-  * @see file_module_test_menu()
-  * @see file_module_test_form_submit()
-  * @ingroup forms
-  */
- function file_module_test_form($form, &$form_state, $tree = TRUE, $extended = FALSE, $default_fid = NULL) {
-   $form['#tree'] = (bool) $tree;
- 
-   $form['nested']['file'] = array(
-     '#type' => 'managed_file',
-     '#title' => t('Managed file'),
-     '#upload_location' => 'public://test',
-     '#progress_message' => t('Please wait...'),
-     '#extended' => (bool) $extended,
-     '#size' => 13,
-   );
-   if ($default_fid) {
-     $form['nested']['file']['#default_value'] = $extended ? array('fid' => $default_fid) : $default_fid;
-   }
- 
-   $form['textfield'] = array(
-     '#type' => 'textfield',
-     '#title' => t('Type a value and ensure it stays'),
-   );
- 
-   $form['submit'] = array(
-     '#type' => 'submit',
-     '#value' => t('Save'),
-   );
- 
-   return $form;
- }
- 
-  * Form submission handler for file_module_test_form().
-  */
- function file_module_test_form_submit($form, &$form_state) {
-   if ($form['#tree']) {
-     $fid = $form['nested']['file']['#extended'] ? $form_state['values']['nested']['file']['fid'] : $form_state['values']['nested']['file'];
-   }
-   else {
-     $fid = $form['nested']['file']['#extended'] ? $form_state['values']['file']['fid'] : $form_state['values']['file'];
-   }
-   backdrop_set_message(t('The file id is %fid.', array('%fid' => $fid)));
- }
- 
-  * Implements hook_file_download().
-  */
- function file_module_test_file_download($uri) {
-   if (state_get('file_module_test_grant_download_access')) {
-     
-     
-     return array(
-       'Content-Type' => mime_header_encode(file_get_mimetype($uri)),
-       'Content-Length' => filesize($uri),
-       'Cache-Control' => 'private',
-     );
-   }
- }
- 
-  * Implements hook_file_download_access().
-  */
- function file_module_test_file_download_access($field, $entity_type, $entity) {
-   list(,, $bundle) = entity_extract_ids($entity_type, $entity);
-   $instance = field_info_instance($entity_type, $field['field_name'], $bundle);
-   
-   
-   if (empty($instance)) {
-     return FALSE;
-   }
- }