Commit 3cb408eb authored by xurizaemon's avatar xurizaemon Committed by joseph.olstad

Issue #2910372 by xurizaemon: Coding standards for Media WYSIWYG

parent 9e3d0da2
......@@ -42,7 +42,7 @@ function media_wysiwyg_features_export_options() {
}
// Add default option.
$options[$file_type . '_default_restrict_wysiwyg'] =
t('@file_type view mode restriction: Default', array(
t('@file_type view mode restriction: Default', array(
'@file_type' => $file_type_label,
));
}
......@@ -91,7 +91,7 @@ function media_wysiwyg_features_export_render($module_name = '', $data, $export
$mode_data_key = $file_type . '_wysiwyg_view_mode';
if (array_key_exists($mode_data_key, $data) || in_array($mode_data_key, $data, TRUE)) {
$view_mode = _media_wysiwyg_get_wysiwyg_mode($file_type);
$view_mode_export = (!empty($view_mode) ? features_var_export($view_mode) : "'none'");
$view_mode_export = (!empty($view_mode) ? features_var_export($view_mode) : "'none'");
$code[] = " // WYSIWYG view mode for $file_type files.";
$code[] = " \$media_wysiwyg['{$mode_data_key}'] = {$view_mode_export};";
$code[] = "";
......
......@@ -59,7 +59,7 @@ function _media_wysiwyg_filter_add_file_usage_from_fields($entity_type, $entity)
unset($entity_files[$fid]);
}
// There are the same number of files, nothing to do
elseif ($entity_files[$fid] == $old_file_count) {
elseif ($entity_files[$fid] == $old_file_count) {
unset($entity_files[$fid]);
}
// There are more files now, adjust the difference for the greater number.
......@@ -121,8 +121,8 @@ function media_wysiwyg_filter_parse_from_fields($entity_type, $entity) {
/**
* Utility function to get the file count in this entity
*
* @param type $entity
* @param type $entity_type
* @param string or int or object... $entity
* @param string or int or object... $entity_type
* @return int
*/
function media_wysiwyg_entity_field_count_files($entity_type, $entity) {
......@@ -154,15 +154,15 @@ function media_wysiwyg_entity_delete($entity, $type) {
/**
* Implements hook_field_attach_delete_revision().
*
* @param type $entity_type
* @param type $entity
* @param string or int or object... $entity_type
* @param string or int or object... $entity
*/
function media_wysiwyg_field_attach_delete_revision($entity_type, $entity) {
list($entity_id) = entity_extract_ids($entity_type, $entity);
$files = media_wysiwyg_entity_field_count_files($entity_type, $entity);
foreach ($files as $fid => $count) {
if ($file = file_load($fid)) {
file_usage_delete($file, 'media', $entity_type , $entity_id, $count);
file_usage_delete($file, 'media', $entity_type, $entity_id, $count);
}
}
}
......
......@@ -80,7 +80,7 @@ function media_wysiwyg_format_form($form, &$form_state, $file) {
'#default_value' => $default_view_mode,
'#description' => t('Choose the type of display you would like for this
file. Please be aware that files may display differently than they do when
they are inserted into an editor.')
they are inserted into an editor.'),
);
// If necessary, display the alignment widget.
......@@ -112,8 +112,8 @@ function media_wysiwyg_format_form($form, &$form_state, $file) {
// Get the external url from the fid array.
$external_url = empty($query_fields['external_url']) ? NULL : $query_fields['external_url'];
// Field to attach external url's to files for linking.
if(variable_get('media_wysiwyg_external_link', FALSE)) {
if($file->type == 'image') {
if (variable_get('media_wysiwyg_external_link', FALSE)) {
if ($file->type == 'image') {
$form['options']['external_url'] = array(
'#type' => 'textfield',
'#title' => t('Link Image'),
......@@ -155,9 +155,9 @@ function media_wysiwyg_format_form($form, &$form_state, $file) {
/**
* Add ajax preview when selecting view mode in wysiwyg editor.
*/
function media_wysiwyg_format_form_view_mode(&$form, $form_state, $file) {
function media_wysiwyg_format_form_view_mode(&$form, $form_state, $file) {
// Check to see if a view mode ("format") has already been specified for
// this media item. First, check for a standard form-submitted value.
// this media item. First, check for a standard form-submitted value.
if (!empty($form_state['values']['format'])) {
$view_mode = $form_state['values']['format'];
}
......@@ -169,15 +169,15 @@ function media_wysiwyg_format_form_view_mode(&$form, $form_state, $file) {
}
}
// If we were unable to determine a view mode, or we found a view mode
// that does not exist in the list of format options presented on this
// form, use the default view mode.
// that does not exist in the list of format options presented on this
// form, use the default view mode.
if (!isset($view_mode) || !array_key_exists($view_mode, $form['options']['format']['#options'])) {
$view_mode = variable_get('media_wysiwyg_wysiwyg_default_view_mode', 'full');
}
$form['preview'] = array();
$form['preview']['#prefix'] = '<div class="media-preview-group"><div class="media-item"><div class="media-thumbnail">';
$form['preview']['#suffix'] = '</div><div class="label-wrapper"><label class="media-filename">' . check_plain($file->filename) . '</label></div></div><div class="edit-file-link">' . l(t('Edit file'), 'file/'.$file->fid.'/edit', array('attributes' => array('class' => 'button', 'title' => t('Use for replace file or edit file fields.')))) . '</div></div>';
$form['preview']['#suffix'] = '</div><div class="label-wrapper"><label class="media-filename">' . check_plain($file->filename) . '</label></div></div><div class="edit-file-link">' . l(t('Edit file'), 'file/' . $file->fid . '/edit', array('attributes' => array('class' => 'button', 'title' => t('Use for replace file or edit file fields.')))) . '</div></div>';
$form['preview']['thumbnail'] = file_view_file($file, $view_mode);
$form['preview']['thumbnail']['#prefix'] = '<div id="media-preview">';
$form['preview']['thumbnail']['#suffix'] = '</div>';
......@@ -212,7 +212,7 @@ function media_wysiwyg_format_form_view_mode(&$form, $form_state, $file) {
}
/**
* AJAX callback to select the portion of the format form to be updated with a preview.
* AJAX callback to select portion of format form to be updated with a preview.
*
* @param array $form
* An associative array containing the structure of the form.
......
......@@ -20,8 +20,8 @@ function media_wysiwyg_variable_group_info() {
}
/**
* Implements hook_variable_info().
*/
* Implements hook_variable_info().
*/
function media_wysiwyg_variable_info($options) {
$variables['media_wysiwyg_wysiwyg_title'] = array(
'type' => 'string',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment