Commit 7b63fbe2 authored by joseph.olstad's avatar joseph.olstad Committed by joseph.olstad

Issue #3064895 by joseph.olstad: Code standards improvements 2x 3x 4x branches only

parent fae2628a
...@@ -19,7 +19,7 @@ function media_wysiwyg_entity_insert($entity, $entity_type) { ...@@ -19,7 +19,7 @@ function media_wysiwyg_entity_insert($entity, $entity_type) {
/** /**
* Implements hook_field_attach_update(). * Implements hook_field_attach_update().
* *
* @see media_field_attach_insert(). * @see media_field_attach_insert()
*/ */
function media_wysiwyg_entity_update($entity, $entity_type) { function media_wysiwyg_entity_update($entity, $entity_type) {
_media_wysiwyg_filter_add_file_usage_from_fields($entity_type, $entity); _media_wysiwyg_filter_add_file_usage_from_fields($entity_type, $entity);
...@@ -41,7 +41,7 @@ function _media_wysiwyg_filter_add_file_usage_from_fields($entity_type, $entity) ...@@ -41,7 +41,7 @@ function _media_wysiwyg_filter_add_file_usage_from_fields($entity_type, $entity)
// id. This code may assume some things about entities that are only true for // id. This code may assume some things about entities that are only true for
// node objects. This should be reviewed. // node objects. This should be reviewed.
// @TODO this conditional can probably be condensed // @TODO this conditional can probably be condensed
if (empty($entity->revision) && empty($entity->old_vid) && empty($entity->is_new) && ! empty($entity->original)) { if (empty($entity->revision) && empty($entity->old_vid) && empty($entity->is_new) && !empty($entity->original)) {
$old_files = media_wysiwyg_entity_field_count_files($entity_type, $entity->original); $old_files = media_wysiwyg_entity_field_count_files($entity_type, $entity->original);
foreach ($old_files as $fid => $old_file_count) { foreach ($old_files as $fid => $old_file_count) {
// Were there more files on the node just prior to saving? // Were there more files on the node just prior to saving?
...@@ -50,15 +50,15 @@ function _media_wysiwyg_filter_add_file_usage_from_fields($entity_type, $entity) ...@@ -50,15 +50,15 @@ function _media_wysiwyg_filter_add_file_usage_from_fields($entity_type, $entity)
} }
if ($old_file_count > $entity_files[$fid]) { if ($old_file_count > $entity_files[$fid]) {
$deprecate = $old_file_count - $entity_files[$fid]; $deprecate = $old_file_count - $entity_files[$fid];
// Now deprecate this usage // Now deprecate this usage.
$file = file_load($fid); $file = file_load($fid);
if ($file) { if ($file) {
file_usage_delete($file, 'media', $entity_type, $entity_id, $deprecate); file_usage_delete($file, 'media', $entity_type, $entity_id, $deprecate);
} }
// Usage is deleted, nothing more to do with this file // Usage is deleted, nothing more to do with this file.
unset($entity_files[$fid]); unset($entity_files[$fid]);
} }
// There are the same number of files, nothing to do // 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]); unset($entity_files[$fid]);
} }
...@@ -84,7 +84,7 @@ function _media_wysiwyg_filter_add_file_usage_from_fields($entity_type, $entity) ...@@ -84,7 +84,7 @@ function _media_wysiwyg_filter_add_file_usage_from_fields($entity_type, $entity)
} }
/** /**
* Parse file references from an entity's text fields and return them as an array. * Parse file references from an entity's text fields and return as an array.
*/ */
function media_wysiwyg_filter_parse_from_fields($entity_type, $entity) { function media_wysiwyg_filter_parse_from_fields($entity_type, $entity) {
$file_references = array(); $file_references = array();
......
...@@ -22,23 +22,23 @@ abstract class MediaWYSIWYGTestHelper extends DrupalWebTestCase { ...@@ -22,23 +22,23 @@ abstract class MediaWYSIWYGTestHelper extends DrupalWebTestCase {
parent::setUp($modules); parent::setUp($modules);
} }
/** /**
* Generates markup to be inserted for a file. * Generates markup to be inserted for a file.
* *
* This is a PHP version of InsertMedia.insert() from js/wysiwyg-media.js. * This is a PHP version of InsertMedia.insert() from js/wysiwyg-media.js.
* *
* @param int $fid * @param int $fid
* Drupal file id * Drupal file id.
* @param int $count * @param int $count
* Quantity of markup to insert * Quantity of markup to insert.
* @param array $attributes * @param array $attributes
* Extra attributes to insert. * Extra attributes to insert.
* @param array $fields * @param array $fields
* Extra field values to insert. * Extra field values to insert.
* *
* @return string * @return string
* Filter markup. * Filter markup.
*/ */
protected function generateJsonTokenMarkup($fid, $count = 1, array $attributes = array(), array $fields = array()) { protected function generateJsonTokenMarkup($fid, $count = 1, array $attributes = array(), array $fields = array()) {
$markup = ''; $markup = '';
// Merge default atttributes. // Merge default atttributes.
...@@ -72,17 +72,17 @@ abstract class MediaWYSIWYGTestHelper extends DrupalWebTestCase { ...@@ -72,17 +72,17 @@ abstract class MediaWYSIWYGTestHelper extends DrupalWebTestCase {
* *
* @param int $fid * @param int $fid
* Create the node with media markup in the body field * Create the node with media markup in the body field
* @param array $attributes * @param array $attributes
* Extra attributes to insert to the file. * Extra attributes to insert to the file.
* @param array $fields * @param array $fields
* Extra field values to insert. * Extra field values to insert.
* *
* @return int * @return int
* Returns the node id * Returns the node id
*/ */
protected function createNode($fid = FALSE, array $attributes = array(), array $fields = array()) { protected function createNode($fid = FALSE, array $attributes = array(), array $fields = array()) {
$markup = ''; $markup = '';
if (! empty($fid)) { if (!empty($fid)) {
$markup = $this->generateJsonTokenMarkup($fid, 1, $attributes, $fields); $markup = $this->generateJsonTokenMarkup($fid, 1, $attributes, $fields);
} }
...@@ -112,6 +112,7 @@ class MediaWYSIWYGViewModeTestHelper extends MediaWYSIWYGTestHelper { ...@@ -112,6 +112,7 @@ class MediaWYSIWYGViewModeTestHelper extends MediaWYSIWYGTestHelper {
$web_user = $this->drupalCreateUser(array('access administration pages', 'administer file types', 'view files', 'use media wysiwyg')); $web_user = $this->drupalCreateUser(array('access administration pages', 'administer file types', 'view files', 'use media wysiwyg'));
$this->drupalLogin($web_user); $this->drupalLogin($web_user);
} }
} }
/** /**
......
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