diff options
author | Heshan Wanigasooriya <heshanmw@gmail.com> | 2011-01-13 02:39:42 +0000 |
---|---|---|
committer | Heshan Wanigasooriya <heshanmw@gmail.com> | 2011-01-13 02:39:42 +0000 |
commit | 7bc9304547b69e97f0bd103b02e75dac485a5da2 (patch) | |
tree | 0ca0e26b026d4c2fe9fde2e9a91b21d9b018b5c8 | |
parent | c7474ecfeb5036e568c940b629accd6a3d038b09 (diff) | |
download | video-7bc9304547b69e97f0bd103b02e75dac485a5da2.tar.gz video-7bc9304547b69e97f0bd103b02e75dac485a5da2.tar.bz2 |
Removing videos types as we are no longer using them and only using video.field.inc for both fields.
-rw-r--r-- | types/.cvsignore | 1 | ||||
-rw-r--r-- | types/videoftp/videoftp.info | 7 | ||||
-rw-r--r-- | types/videoftp/videoftp.install | 25 | ||||
-rw-r--r-- | types/videoftp/videoftp.module | 207 | ||||
-rw-r--r-- | types/videoftp/videoftp.theme.inc | 57 | ||||
-rw-r--r-- | types/videoftp/videoftp_widget.inc | 313 | ||||
-rw-r--r-- | types/videoupload/videoupload.info | 10 | ||||
-rw-r--r-- | types/videoupload/videoupload.install | 27 | ||||
-rw-r--r-- | types/videoupload/videoupload.module | 129 | ||||
-rw-r--r-- | types/videoupload/videoupload.theme.inc | 18 | ||||
-rw-r--r-- | types/videoupload/videoupload_widget.inc | 129 |
11 files changed, 0 insertions, 923 deletions
diff --git a/types/.cvsignore b/types/.cvsignore deleted file mode 100644 index e43b0f9..0000000 --- a/types/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -.DS_Store diff --git a/types/videoftp/videoftp.info b/types/videoftp/videoftp.info deleted file mode 100644 index c14f111..0000000 --- a/types/videoftp/videoftp.info +++ /dev/null @@ -1,7 +0,0 @@ -; $Id$ - -name = Video FTP -description = Allows you to attach videos uploaded through FTP to nodes. -package = Video -core = 7.x -dependencies[] = video
\ No newline at end of file diff --git a/types/videoftp/videoftp.install b/types/videoftp/videoftp.install deleted file mode 100644 index 8349abc..0000000 --- a/types/videoftp/videoftp.install +++ /dev/null @@ -1,25 +0,0 @@ -<?php -// $Id$ - -/** - * Implementation of hook_install(). - */ -function videoftp_install() { - drupal_load('module', 'content'); - content_notify('install', 'videoftp'); -} - -function videoftp_uninstall() { - drupal_load('module', 'content'); - content_notify('uninstall', 'videoftp'); -} - -function videoftp_enable() { - drupal_load('module', 'content'); - content_notify('enable', 'videoftp'); -} - -function videoftp_disable() { - drupal_load('module', 'content'); - content_notify('disable', 'videoftp'); -}
\ No newline at end of file diff --git a/types/videoftp/videoftp.module b/types/videoftp/videoftp.module deleted file mode 100644 index 078d81c..0000000 --- a/types/videoftp/videoftp.module +++ /dev/null @@ -1,207 +0,0 @@ -<?php -// $Id$ - -/** - * @file - * video ftp core hooks and menu callbacks. - */ - -module_load_include('inc', 'videoftp', 'videoftp_widget'); - -/* - * Implementation of hook_menu(). - */ -function videoftp_menu() { - $items = array(); - $items['videoftp/ahah/%/%/%'] = array( - 'page callback' => 'videoftp_js', - 'page arguments' => array(2, 3, 4), - //'access callback' => 'videoftp_edit_access', - 'access arguments' => array('access content'), - 'type' => MENU_CALLBACK, - ); - $items['videoftp/progress'] = array( - 'page callback' => 'videoftp_progress', - 'access arguments' => array('access content'), - 'type' => MENU_CALLBACK, - ); - return $items; -} - -/** - * Implementation of hook_theme(). - */ -function videoftp_theme() { - $theme = array(); - $theme['videoftp_widget'] = array( - 'arguments' => array('element' => NULL), - 'file' => 'videoftp.theme.inc', - ); - $theme['videoftp_widget_item'] = array( - 'arguments' => array('element' => NULL), - 'file' => 'videoftp.theme.inc', - ); - $theme['videoftp_widget_file'] = array( - 'arguments' => array('element' => NULL), - 'file' => 'videoftp.theme.inc', - ); - return $theme; -} - -/** - * Implementation of CCK's hook_widget_info(). - */ -function videoftp_widget_info() { - return array( - 'videoftp_widget' => array( - 'label' => t('Video FTP'), - 'field types' => array('filefield'), - 'multiple values' => CONTENT_HANDLE_CORE, - 'callbacks' => array('default value' => CONTENT_CALLBACK_CUSTOM), - 'description' => t('Widget allows you to select video files uploaded through FTP to be attached to the node.'), - ), - ); -} - -/** - * Implementation of hook_elements(). - */ -function videoftp_elements() { - return array( - 'videoftp_widget' => array( - '#input' => TRUE, - '#columns' => array('fid', 'list', 'data', 'filepath'), - '#process' => array('videoftp_widget_process'), - '#value_callback' => 'videoftp_widget_value', - ), - ); -} - -/** - * Implementation of CCK's hook_widget_settings(). - */ -function videoftp_widget_settings($op, $widget) { - //load up our include file for the widget - module_load_include('inc', 'videoftp', 'videoftp_widget'); - switch ($op) { - case 'form': - return videoftp_widget_settings_form($widget); - case 'validate': - return videoftp_widget_settings_validate($widget); - case 'save': - return videoftp_widget_settings_save($widget); - } -} - -/** - * Implementation of hook_widget(). - */ -function videoftp_widget(&$form, &$form_state, $field, $items, $delta = NULL) { - $item = array('fid' => 0, 'list' => $field['list_default'], 'data' => array('description' => '', 'video_thumb' => '')); - if (isset($items[$delta])) { - $item = array_merge($item, $items[$delta]); - } - $element = array( - '#title' => $field['widget']['label'], - '#type' => $field['widget']['type'], - '#default_value' => $item, - ); - return $element; -} - -/** - * Menu callback; Shared AHAH callback for ftp file attachment and deletions. - * - * This rebuilds the form element for a particular field item. As long as the - * form processing is properly encapsulated in the widget element the form - * should rebuild correctly using FAPI without the need for additional callbacks - * or processing. - */ -function videoftp_js($type_name, $field_name, $delta) { - module_load_include('inc', 'videoftp', 'videoftp_widget'); - $field = content_fields($field_name, $type_name); - - if (empty($field) || empty($_POST['form_build_id'])) { - // Invalid request. - drupal_set_message(t('An unrecoverable error occurred.'), 'error'); - print drupal_to_js(array('data' => theme('status_messages'))); - exit; - } - - // Build the new form. - $form_state = array('submitted' => FALSE); - $form_build_id = $_POST['form_build_id']; - $form = form_get_cache($form_build_id, $form_state); - - if (!$form) { - // Invalid form_build_id. - drupal_set_message(t('An unrecoverable error occurred. This form was missing from the server cache. Try reloading the page and submitting again.'), 'error'); - print drupal_to_js(array('data' => theme('status_messages'))); - exit; - } - - // Build the form. This calls the file field's #value_callback function and - // saves the uploaded file. Since this form is already marked as cached - // (the #cache property is TRUE), the cache is updated automatically and we - // don't need to call form_set_cache(). - $args = $form['#parameters']; - $form_id = array_shift($args); - $form['#post'] = $_POST; - $form = form_builder($form_id, $form, $form_state); - - // Update the cached form with the new element at the right place in the form. - if (module_exists('fieldgroup') && ($group_name = _fieldgroup_field_get_group($type_name, $field_name))) { - if (isset($form['#multigroups']) && isset($form['#multigroups'][$group_name][$field_name])) { - $form_element = $form[$group_name][$delta][$field_name]; - } - else { - $form_element = $form[$group_name][$field_name][$delta]; - } - } - else { - $form_element = $form[$field_name][$delta]; - } - - if (isset($form_element['_weight'])) { - unset($form_element['_weight']); - } - $output = drupal_render($form_element); - // AHAH is not being nice to us and doesn't know the "other" button (that is, - // either "Attach" or "Delete") yet. Which in turn causes it not to attach - // AHAH behaviours after replacing the element. So we need to tell it first. - - // Loop through the JS settings and find the settings needed for our buttons. - $javascript = drupal_add_js(NULL, NULL); - $videoftp_ahah_settings = array(); - if (isset($javascript['setting'])) { - foreach ($javascript['setting'] as $settings) { - if (isset($settings['ahah'])) { - foreach ($settings['ahah'] as $id => $ahah_settings) { - if (strpos($id, 'videoftp-attach') || strpos($id, 'videoftp-remove')) { - $videoftp_ahah_settings[$id] = $ahah_settings; - } - } - } - } - } - - // Add the AHAH settings needed for our new buttons. - if (!empty($videoftp_ahah_settings)) { - $output .= '<script type="text/javascript">jQuery.extend(Drupal.settings.ahah, '. drupal_to_js($videoftp_ahah_settings) .');</script>'; - } - - $output = theme('status_messages') . $output; - - // For some reason, file uploads don't like drupal_json() with its manual - // setting of the text/javascript HTTP header. So use this one instead. - $GLOBALS['devel_shutdown'] = FALSE; - print drupal_to_js(array('status' => TRUE, 'data' => $output)); - exit; -} - -/** - * filefield source support - */ -function videoftp_filefield_sources_widgets() { - return array('videoftp_widget'); -}
\ No newline at end of file diff --git a/types/videoftp/videoftp.theme.inc b/types/videoftp/videoftp.theme.inc deleted file mode 100644 index 42203cb..0000000 --- a/types/videoftp/videoftp.theme.inc +++ /dev/null @@ -1,57 +0,0 @@ -<?php -//$Id$ -/** - * - * @file - * Theme functions for the videoftp module. - */ - -/** - * FormAPI theme function. Theme the output of an video ftp field. - */ -function theme_videoftp_widget($element) { - return theme('form_element', $element, $element['#children']); -} - -function theme_videoftp_widget_item($element) { - // Put the upload button directly after the upload field. - $element['ftpselect']['#field_suffix'] = drupal_render($element['videoftp_attach']); - $element['ftpselect']['#theme'] = 'videoftp_widget_file'; - $output = '<div class="filefield-element clear-block">'; - - if ($element['fid']['#value'] != 0) { - $output .= '<div class="widget-preview">'; - $output .= drupal_render($element['preview']); - $output .= '</div>'; - } - - $output .= '<div class="widget-edit">'; - $output .= drupal_render($element); - $output .= '</div>'; - $output .= '</div>'; - - return $output; -} - -/** - * Custom theme function for VideoFTP upload elements. - * - * This function allows us to put the "Attach" button immediately after the - * select field by respecting the #field_suffix property. - */ -function theme_videoftp_widget_file($element) { - $output .= '<div class="filefield-upload clear-block">'; - if (isset($element['#field_prefix'])) { - $output .= $element['#field_prefix']; - } - $size = $element['#size'] ? ' size="'. $element['#size'] .'"' : ''; - _form_set_class($element, array('form-select')); - $multiple = $element['#multiple']; - $output .= '<select name="'. $element['#name'] .''. ($multiple ? '[]' : '') .'"'. ($multiple ? ' multiple="multiple" ' : '') . drupal_attributes($element['#attributes']) .' id="'. $element['#id'] .'" '. $size .'>'. form_select_options($element) ."</select>\n"; - if (isset($element['#field_suffix'])) { - $output .= $element['#field_suffix']; - } - $output .= '</div>'; - - return theme('form_element', $element, $output); -}
\ No newline at end of file diff --git a/types/videoftp/videoftp_widget.inc b/types/videoftp/videoftp_widget.inc deleted file mode 100644 index cd5de67..0000000 --- a/types/videoftp/videoftp_widget.inc +++ /dev/null @@ -1,313 +0,0 @@ -<?php - -// $Id: - -/** - * @file - * videoftp widget hooks and callbacks. - */ - -/** - * Implementation of CCK's hook_widget_settings($op = 'form'). - */ -function videoftp_widget_settings_form($widget) { - $form = array(); - $form['file_extensions'] = array( - '#type' => 'textfield', - '#title' => t('Permitted upload file extensions.'), - '#default_value' => !empty($widget['file_extensions']) ? $widget['file_extensions'] : 'mp4 mpeg avi mpg wmv flv mov', - '#size' => 64, - '#description' => t('Extensions a user can attach to this field. Separate extensions with a space and do not include the leading dot. Leaving this blank will allow attachment of a file with any extension.'), - '#weight' => 1 - ); - $form['path_settings'] = array( - '#type' => 'fieldset', - '#title' => t('Path settings'), - '#collapsible' => TRUE, - '#collapsed' => TRUE, - '#weight' => 2, - ); - $form['path_settings']['file_path'] = array( - '#type' => 'textfield', - '#size' => 64, - '#title' => t('File path'), - '#default_value' => ltrim(ltrim($widget['file_path'], "videos"), "/"), - '#description' => t('Optional subdirectory within the "<em>files/videos/</em>" directory where files will be moved and stored. Do not include preceding or trailing slashes.'), - '#element_validate' => array('video_widget_settings_file_path_validate', '_filefield_widget_settings_file_path_validate'), - ); - $form['path_settings']['ftp_path'] = array( - '#type' => 'textfield', - '#title' => t('FTP Filepath'), - '#default_value' => !empty($widget['ftp_path']) ? $widget['ftp_path'] : 'ftpvideos', - '#description' => t('The subdirectory within the "<em>files/</em>" directory where you have upload the videos for attachment. Once the video is attached it will be moved from this directory to the main files directory.'), - '#required' => TRUE, - '#weight' => 3, - ); - //default settings - $default = video_default_widget_settings($widget); - $form = $form + $default; - return $form; -} - -/** - * Implementation of CCK's hook_widget_settings($op = 'validate'). - * - * //@todo Integrate this into a universal function to share with uploadfield_widget - */ -function videoftp_widget_settings_validate($widget) { - // Check that only web images are specified in the callback. - if (!video_web_extensions($widget['file_extensions'])) { - form_set_error('file_extensions', t('Only web-standard videos are supported through the videoftp widget. If needing to upload other types of files, change the widget to use a standard file upload.')); - } - // Check for our ftp filepath and try to create it, if not it will throw an error. - $ftp_path = file_default_scheme() . ':/' . $widget['ftp_path']; - file_check_directory($ftp_path, true, 'ftp_path'); -} - -/** - * Implementation of CCK's hook_widget_settings($op = 'save'). - */ -function videoftp_widget_settings_save($widget) { - return array('file_extensions', 'file_path', 'ftp_path', 'autothumbnail', 'autoconversion', 'default_dimensions', 'default_player_dimensions', 'default_video_thumb'); -} - -/** - * The #value_callback for the videoftp_widget type element. - */ -function videoftp_widget_value($element, $edit = FALSE) { - if (!$edit) { - // Creating so we load up our empty values. - $file = field_file_load($element['#default_value']['fid']); - $item = $element['#default_value']; - } else { - // Reset our item array for our data. - $item = array_merge($element['#default_value'], $edit); - $field = content_fields($element['#field_name'], $element['#type_name']); - - // Uploads take priority over value of fid text field. - if ($fid = videoftp_save_upload($element)) { - $item['fid'] = $fid; - $item['data'] = array(); //reset our thumbnail - } - // Check for #videoftp_value_callback values. - // Because FAPI does not allow multiple #value_callback values like it does - // for #element_validate and #process, this fills the missing functionality - // to allow VideoFtp to be extended purely through FAPI. - elseif (isset($element['#videoftp_value_callback'])) { - foreach ($element['#videoftp_value_callback'] as $callback) { - $callback($element, $item); - } - } - - // Load file if the FID has changed so that it can be saved by CCK. - $file = field_file_load($item['fid']); - - // If the file entry doesn't exist, don't save anything. - if (empty($file)) { - $item = array(); - } - - // Checkboxes loose their value when empty. - // If the list field is present make sure its unchecked value is saved. - if (!empty($field['list_field']) && empty($edit['list'])) { - $item['list'] = 0; - } - } - // Merge file and item data so it is available to all widgets. - $item = array_merge($item, $file); - return $item; -} - -/** - * Process an individual element. - */ -function videoftp_widget_process($element, $edit, &$form_state, $form) { - $item = $element['#value']; - $field_name = $element['#field_name']; - $delta = $element['#delta']; - $field = content_fields($element['#field_name'], $element['#type_name']); - $element['#theme'] = 'videoftp_widget_item'; - - if (isset($element['preview']) && $element['#value']['fid'] != 0) { - $element['preview']['#value'] = theme('videoftp_widget_preview', $element['#value']); - } - - // Title is not necessary for each individual field. - if ($field['multiple'] > 0) { - unset($element['#title']); - } - - // Set up the buttons first since we need to check if they were clicked. - $element['videoftp_attach'] = array( - '#type' => 'submit', - '#value' => t('Attach'), - '#submit' => array('node_form_submit_build_node'), - '#ahah' => array(// with JavaScript - 'path' => 'videoftp/ahah/' . $element['#type_name'] . '/' . $element['#field_name'] . '/' . $element['#delta'], - 'wrapper' => $element['#id'] . '-ahah-wrapper', - 'method' => 'replace', - 'effect' => 'fade', - ), - '#field_name' => $element['#field_name'], - '#delta' => $element['#delta'], - '#type_name' => $element['#type_name'], - '#upload_validators' => $element['#upload_validators'], - '#weight' => 100, - '#post' => $element['#post'], - ); - $element['videoftp_remove'] = array( - // With default CCK edit forms, $element['#parents'] is array($element['#field_name'], $element['#delta']). - // However, if some module (for example, flexifield) places our widget deeper in the tree, we want to - // use that information in constructing the button name. - '#name' => implode('_', $element['#parents']) . '_videoftp_remove', - '#type' => 'submit', - '#value' => t('Remove'), - '#submit' => array('node_form_submit_build_node'), - '#ahah' => array(// with JavaScript - 'path' => 'videoftp/ahah/' . $element['#type_name'] . '/' . $element['#field_name'] . '/' . $element['#delta'], - 'wrapper' => $element['#id'] . '-ahah-wrapper', - 'method' => 'replace', - 'effect' => 'fade', - ), - '#field_name' => $element['#field_name'], - '#delta' => $element['#delta'], - '#weight' => 101, - '#post' => $element['#post'], - ); - - // Because the output of this field changes depending on the button clicked, - // we need to ask FAPI immediately if the remove button was clicked. - // It's not good that we call this private function, but - // $form_state['clicked_button'] is only available after this #process - // callback is finished. - if (_form_button_was_clicked($element['videoftp_remove'])) { - // Delete the file if it is currently unused. Note that field_file_delete() - // does a reference check in addition to our basic status check. - if (isset($edit['fid'])) { - $removed_file = field_file_load($edit['fid']); - if ($removed_file['status'] == 0) { - field_file_delete($removed_file); - } - } - $item = array('fid' => 0, 'list' => $field['list_default'], 'data' => array('description' => '', 'video_thumb' => '')); - } - - // Set access on the buttons and select. - $element['videoftp_attach']['#access'] = empty($item['fid']); - $element['videoftp_remove']['#access'] = !empty($item['fid']); - - $options = videoftp_options($field); - $element['ftpselect'] = array( - '#type' => 'select', - '#required' => isset($element['#required']) ? $element['#required'] : $field['required'], - '#options' => $options, - '#access' => empty($item['fid']), - ); - - // Set the FID. - $element['fid'] = array( - '#type' => 'hidden', - '#value' => $item['fid'], - ); - - if ($item['fid'] != 0) { - $element['preview'] = array( - '#type' => 'markup', - '#value' => theme('video_widget_preview', $item), - ); - } - - // placeholder.. will be serialized into the data column. this is a place for widgets - // to put additional data. - $element['data'] = array( - '#tree' => 'true', - '#access' => !empty($item['fid']), - ); - - // Create our thumbnails - if ($field['widget']['autothumbnail']) { - video_thumb_process($element); - } - - // Add our extra fields if in preview mode - if (!empty($item['fid'])) { - video_widget_element_settings($element); - } - - // Set #element_validate in a way that it will not wipe out other - // validation functions already set by other modules. - if (empty($element['#element_validate'])) { - $element['#element_validate'] = array(); - } - array_unshift($element['#element_validate'], 'videoftp_widget_validate'); - - // Make sure field info will be available to the validator which - // does not get the values in $form. - $form_state['#field_info'][$field['field_name']] = $field; - - $element['#attributes']['id'] = $element['#id'] . '-ahah-wrapper'; - $element['#prefix'] = '<div ' . drupal_attributes($element['#attributes']) . '>'; - $element['#suffix'] = '</div>'; - - // Lets use the clicked_button #submit[0] value here instead and see how that works out for now... - if ($form_state['submitted'] == 1) { - video_widget_process($element, $form_state); - } - return $element; -} - -function videoftp_save_upload($element) { - global $user; - $upload_name = $element['#field_name'] . '_' . $element['#delta']; - $delta = $element['#delta']; - $field = content_fields($element['#field_name'], $element['#type_name']); - $video = $element['#post'][$field['field_name']][$delta]['ftpselect']; - $ftp_path = file_default_scheme() . ':/' . $field['widget']['ftp_path']; - - if (empty($video) || !file_exists($ftp_path . '/' . $video)) { - return 0; - } - - $dest = filefield_widget_file_path($field); - if (!field_file_check_directory($dest, FILE_CREATE_DIRECTORY)) { - watchdog('filefield', 'The upload directory %directory for the file field %field (content type %type) could not be created or is not accessible. A newly uploaded file could not be saved in this directory as a consequence, and the upload was canceled.', array('%directory' => $dest, '%field' => $element['#field_name'], '%type' => $element['#type_name'])); - form_set_error($upload_name, t('The file could not be uploaded.')); - return 0; - } - - // Begin building the file object. - $file = new stdClass(); - $file->uid = $user->uid; - $file->filename = file_munge_filename(trim(basename($video), '.'), $field['widget']['file_extensions']); - $file->filepath = $ftp_path . '/' . $video; - $file->filemime = file_get_mimetype($file->filename); - $file->filesize = filesize($file->filepath); - $file->status = FILE_STATUS_TEMPORARY; - $file->timestamp = time(); - - //lets move our file from the ftp folder to the files directory - if (file_move($file, $dest)) { - // Insert new record to the database. - drupal_write_record('files', $file); - } - _field_file_cache($file); // cache the file in order to minimize load queries - return $file->fid; -} - -function videoftp_options($field) { - $options = array(); - $options[] = t('Select Video'); - // Lets setup our ftp_path. - $ftp_path = file_default_scheme() . ':/' . $field['widget']['ftp_path']; - // We are going to scan the directory and pull out the available video types by extension. - $extensions = explode(" ", $field['widget']['file_extensions']); - $video_files = scandir($ftp_path); - foreach ($video_files as $file) { - $ext = pathinfo($file); - if (in_array($ext['extension'], $extensions)) { - //add the file to the options array for selection - $options["$file"] = $file; - } - } - return $options; -}
\ No newline at end of file diff --git a/types/videoupload/videoupload.info b/types/videoupload/videoupload.info deleted file mode 100644 index ebeaeb4..0000000 --- a/types/videoupload/videoupload.info +++ /dev/null @@ -1,10 +0,0 @@ -; $Id$ - -name = Video Upload -description = Handle video upload for video module using fields. -package = Video -core = 7.x -dependencies[] = video -files[] = videoupload.module -files[] = videoupload.field.inc -files[] = videoupload.install
\ No newline at end of file diff --git a/types/videoupload/videoupload.install b/types/videoupload/videoupload.install deleted file mode 100644 index 9f43a6d..0000000 --- a/types/videoupload/videoupload.install +++ /dev/null @@ -1,27 +0,0 @@ -<?php -// $Id$ - -/** - * Implements hook_field_schema(). - */ -function uploadfield_field_schema($field) { - return array( - 'columns' => array( - 'fid' => array( - 'description' => 'The {file_managed}.fid being referenced in this field.', - 'type' => 'int', - 'not null' => FALSE, - 'unsigned' => TRUE, - ), - ), - 'indexes' => array( - 'fid' => array('fid'), - ), - 'foreign keys' => array( - 'fid' => array( - 'table' => 'file_managed', - 'columns' => array('fid' => 'fid'), - ), - ), - ); -}
\ No newline at end of file diff --git a/types/videoupload/videoupload.module b/types/videoupload/videoupload.module deleted file mode 100644 index 3f03204..0000000 --- a/types/videoupload/videoupload.module +++ /dev/null @@ -1,129 +0,0 @@ -<?php -// $Id$ - -/** - * @file - * uploadfield core hooks and menu callbacks. - */ - -/** - * Implementation of hook_perm(). - */ -function videoupload_perm() { - return array('use default thumbnail', 'bypass conversion video'); -} - -/** - * Implementation of hook_theme(). - */ -function videoupload_theme() { - $theme = array(); - $theme['uploadfield_widget'] = array( - 'arguments' => array('element' => NULL), - 'file' => 'videoupload.theme.inc', - ); - $theme['uploadfield_widget_item'] = array( - 'arguments' => array('element' => NULL), - 'file' => 'videoupload.theme.inc', - ); - return $theme; -} - - -/** - * Implementation of hook_elements(). - */ -function videoupload_elements() { - $elements = array(); - // An uploadfield is really just a FileField with extra processing. - $filefield_elements = module_invoke('filefield', 'elements'); - $elements['uploadfield_widget'] = $filefield_elements['filefield_widget']; - $elements['uploadfield_widget']['#process'][] = 'uploadfield_widget_process'; - $elements['uploadfield_widget']['#element_validate'][] = 'uploadfield_widget_validate'; - // uploadfield needs a separate value callback to save its alt and title texts. - $elements['uploadfield_widget']['#value_callback'] = 'uploadfield_widget_value'; - return $elements; -} - -/** - * Implementation of hook_file_download. - */ -function videoupload_file_download($filepath) { - // Return headers for default images. - if (strpos($filepath, 'video_thumbs') !== FALSE) { - $full_path = file_create_path($filepath); - if ($info = getimagesize($full_path)) { - return array( - 'Content-Type: ' . $info['mime'], - 'Content-Length: ' . filesize($full_path) - ); - } - } -} - -/** - * Implementation of CCK's hook_widget_settings(). - */ -function videoupload_widget_settings($op, $widget) { - switch ($op) { - case 'form': - return uploadfield_widget_settings_form($widget); - case 'validate': - return uploadfield_widget_settings_validate($widget); - case 'save': - return uploadfield_widget_settings_save($widget); - } -} - -/** - * Implementation of hook_widget(). - */ -function videoupload_widget(&$form, &$form_state, $field, $items, $delta = NULL) { - $item = array('fid' => 0, 'list' => $field['list_default'], 'data' => array('description' => '', 'video_thumb' => '')); - if (isset($items[$delta])) { - $item = array_merge($item, $items[$delta]); - } - return filefield_widget($form, $form_state, $field, $items, $delta); -} - -/** - * Implementation of CCK's hook_default_value(). - */ -function videoupload_default_value(&$form, &$form_state, $field, $delta) { - return filefield_default_value($form, $form_state, $field, $delta); -} - -/** - * Implementation of hook_form_[form_id]_alter(). - * - * Modify the add new field form to make "Video" the default formatter. - */ -function videoupload_form_content_field_overview_form_alter(&$form, &$form_state) { - $form['#submit'][] = 'uploadfield_form_content_field_overview_submit'; -} - -/** - * Submit handler to set a new field's formatter to "video_plain". - */ -function videoupload_form_content_field_overview_submit(&$form, &$form_state) { - if (isset($form_state['fields_added']['_add_new_field']) && isset($form['#type_name'])) { - $new_field = $form_state['fields_added']['_add_new_field']; - $node_type = $form['#type_name']; - $field = content_fields($new_field, $node_type); - if ($field['widget']['module'] == 'uploadfield') { - foreach ($field['display_settings'] as $display_type => $display_settings) { - if ($field['display_settings'][$display_type]['format'] == 'default') { - $field['display_settings'][$display_type]['format'] = 'video_plain'; - } - } - content_field_instance_update($field); - } - } -} - -/** - * filefield source support - */ -function videoupload_filefield_sources_widgets() { - return array('videoupload_widget'); -}
\ No newline at end of file diff --git a/types/videoupload/videoupload.theme.inc b/types/videoupload/videoupload.theme.inc deleted file mode 100644 index 5a81efd..0000000 --- a/types/videoupload/videoupload.theme.inc +++ /dev/null @@ -1,18 +0,0 @@ -<?php -//$Id$ -/** - * - * @file - * Theme functions for the videoftp module. - */ - -/** - * FormAPI theme function. Theme the output of an video upload field. - */ -function theme_uploadfield_widget($element) { - return theme('form_element', $element, $element['#children']); -} - -function theme_uploadfield_widget_item($element) { - return theme('filefield_widget_item', $element); -}
\ No newline at end of file diff --git a/types/videoupload/videoupload_widget.inc b/types/videoupload/videoupload_widget.inc deleted file mode 100644 index 68e447d..0000000 --- a/types/videoupload/videoupload_widget.inc +++ /dev/null @@ -1,129 +0,0 @@ -<?php -// $Id$ - -/** - * @file - * uploadfield widget hooks and callbacks. - */ - -/** - * Implementation of CCK's hook_widget_settings($op = 'form'). - */ -function uploadfield_widget_settings_form($widget) { - $form = module_invoke('filefield', 'widget_settings', 'form', $widget); - - if ($form['file_extensions']['#default_value'] == 'txt') { - $form['file_extensions']['#default_value'] = 'mp4 mpeg avi mpg wmv flv mov'; - } - //fix our path settings - $form['path_settings']['file_path']['#default_value'] = ltrim(ltrim($form['path_settings']['file_path']['#default_value'], "videos"), "/"); //wierd i had to break this into two ltrims... - $form['path_settings']['file_path']['#description'] = t('Optional subdirectory within the "<em>files/videos/</em>" directory where files will be stored. Do not include preceding or trailing slashes.'); - array_unshift($form['path_settings']['file_path']['#element_validate'], 'video_widget_settings_file_path_validate'); - - //default settings - $default = video_default_widget_settings($widget); - $form = $form + $default; - return $form; -} - -/** - * Implementation of CCK's hook_widget_settings($op = 'validate'). - */ -function uploadfield_widget_settings_validate($widget) { - // Check that only web images are specified in the callback. - if(!video_web_extensions($widget['file_extensions'])) { - form_set_error('file_extensions', t('Only web-standard videos are supported through the videoftp widget. If needing to upload other types of files, change the widget to use a standard file upload.')); - } -} - -/** - * Implementation of CCK's hook_widget_settings($op = 'save'). - */ -function uploadfield_widget_settings_save($widget) { - $filefield_settings = module_invoke('filefield', 'widget_settings', 'save', $widget); - return array_merge($filefield_settings, array('default_video_thumb', 'default_dimensions', 'default_player_dimensions', 'autoconversion', 'autothumbnail')); -} - -/** - * Element #value_callback function. - */ -function uploadfield_widget_value($element, $edit = FALSE) { - //copied from filefield_widget_value with one change to reset our data array - if (!$edit) { - $file = field_file_load($element['#default_value']['fid']); - $item = $element['#default_value']; - } - else { - $item = array_merge($element['#default_value'], $edit); - $field = content_fields($element['#field_name'], $element['#type_name']); - - // Uploads take priority over value of fid text field. - if ($fid = filefield_save_upload($element)) { - $item['fid'] = $fid; - $item['data'] = array(); //reset our data array for thumbnails and values. - } - // Check for #filefield_value_callback values. - // Because FAPI does not allow multiple #value_callback values like it does - // for #element_validate and #process, this fills the missing functionality - // to allow FileField to be extended purely through FAPI. - elseif (isset($element['#filefield_value_callback'])) { - foreach ($element['#filefield_value_callback'] as $callback) { - $callback($element, $item); - } - } - - // Load file if the FID has changed so that it can be saved by CCK. - $file = field_file_load($item['fid']); - - // If the file entry doesn't exist, don't save anything. - if (empty($file)) { - $item = array(); - } - - // Checkboxes loose their value when empty. - // If the list field is present make sure its unchecked value is saved. - if (!empty($field['list_field']) && empty($edit['list'])) { - $item['list'] = 0; - } - } - // Merge file and item data so it is available to all widgets. - $item = array_merge($item, $file); - - return $item; -} - -/** - * Element #process callback function. - */ -function uploadfield_widget_process($element, $edit, &$form_state, $form) { - $item = $element['#value']; - $field_name = $element['#field_name']; - $delta = $element['#delta']; - $field = content_fields($element['#field_name'], $element['#type_name']); - $element['#theme'] = 'uploadfield_widget_item'; - - if (isset($element['preview']) && $element['#value']['fid'] != 0) { - $element['preview']['#value'] = theme('video_widget_preview', $element['#value']); - } - - // Title is not necessary for each individual field. - if ($field['multiple'] > 0) { - unset($element['#title']); - } - - // Create our thumbnails - if($field['widget']['autothumbnail']) { - video_thumb_process($element); - } - - // Add our extra fields if in preview mode - if(!empty($item['fid'])) { - video_widget_element_settings($element); - } - - // Lets use the clicked_button #submit[0] value here instead and see how that works out for now... - if($form_state['submitted'] == 1) { - video_widget_process($element, $form_state); - } - return $element; -}
\ No newline at end of file |