### Eclipse Workspace Patch 1.0
#P zuiddag
Index: www/sites/all/modules/contrib/video_embed_field/video_embed_field.field.inc
===================================================================
--- www/sites/all/modules/contrib/video_embed_field/video_embed_field.field.inc (revision 207)
+++ www/sites/all/modules/contrib/video_embed_field/video_embed_field.field.inc (working copy)
@@ -28,7 +28,7 @@
*/
function video_embed_field_field_instance_settings_form($field, $instance) {
$settings = $instance['settings'];
-
+
$form['description_field'] = array(
'#type' => 'checkbox',
'#title' => t('Enable Description field'),
@@ -37,7 +37,7 @@
'#parents' => array('instance', 'settings', 'description_field'),
'#weight' => 11,
);
-
+
return $form;
}
@@ -67,20 +67,20 @@
$element += array(
'#type' => 'fieldset'
);
-
+
$element['video_url'] = array(
'#type' => 'textfield',
'#title' => t('Video URL'),
'#attributes' => array('class' => array('video_embed_url')),
- '#attached' => array(
- 'css' => array(
+ '#attached' => array(
+ 'css' => array(
drupal_get_path('module', 'video_embed_field') .'/video_embed_field.form.css'
)
),
'#default_value' => isset($items[$delta]['video_url'])?$items[$delta]['video_url']:'',
'#required' => $element['#required']
);
-
+
// Add the description field if enabled.
if (!empty($instance['settings']['description_field'])) {
$element['description'] = array(
@@ -104,11 +104,11 @@
if (stristr($item['video_url'], '.') && !stristr($item['video_url'], 'http://') && !stristr($item['video_url'], 'https://')) {
$item['video_url'] = 'http://' . $item['video_url'];
}
-
+
$parts = parse_url($item['video_url']);
if (!$parts || !isset($parts['host'])) {
$errors[$field['field_name']][$langcode][$delta][] = array(
- 'error' => t('Invalid Url'),
+ 'error' => t('Invalid Url'),
'message' => t('Video: Invalid Video URL.', array('%name' => $instance['label'])),
);
}
@@ -120,7 +120,7 @@
$domains = _video_embed_field_get_provider_domains();
if (!array_key_exists($host, $domains)) {
$errors[$field['field_name']][$langcode][$delta][] = array(
- 'error' => t('Unsupported Video Provider'),
+ 'error' => t('Unsupported Video Provider'),
'message' => t('%name: This video provider is not currently supported.', array('%name' => $instance['label'])),
);
}
@@ -136,9 +136,9 @@
*/
function video_embed_field_field_presave($entity_type, $entity, $field, $instance, $langcode, &$items) {
foreach($items as $delta => $item){
-
+
$info = video_embed_field_thumbnail_url($item['video_url']);
-
+
if (isset($info['url']) && $info['url']) {
$thumb_url = $info['url'];
@@ -155,13 +155,13 @@
@copy($thumb_url, $local_path);
}
}
-
+
$items[$delta]['thumbnail_path'] = $local_path;
} //couldn't get the thumbnail for whatever reason
else {
- $items[$delta]['thumbnail_path'] = '';
+ $items[$delta]['thumbnail_path'] = '';
}
-
+
}
}
/**
@@ -208,7 +208,7 @@
$display = $instance['display'][$view_mode];
$settings = $display['settings'];
$element = array();
-
+
if ($display['type'] == 'video_embed_field' || $display['type'] == 'video_embed_field_thumbnail_colorbox') {
$video_styles = video_embed_field_video_style_options(FALSE);
$element['video_style'] = array(
@@ -217,7 +217,7 @@
'#default_value' => $settings['video_style'],
'#options' => $video_styles,
);
- }
+ }
if ($display['type'] == 'video_embed_field_thumbnail' || $display['type'] == 'video_embed_field_thumbnail_colorbox') {
$element['image_style'] = array(
'#title' => t('Image style'),
@@ -225,9 +225,9 @@
'#options' => image_style_options(FALSE),
'#default_value' => $settings['image_style'],
'#empty_option' => t('None (original image)'),
- );
+ );
}
-
+
if($display['type'] == 'video_embed_field_thumbnail'){
$link_types = array(
'node' => t('Node'),
@@ -241,7 +241,7 @@
'#options' => $link_types,
);
}
-
+
if ($instance['settings']['description_field']) {
$element['description'] = array(
'#title' => t('Show description'),
@@ -267,12 +267,12 @@
if (isset($video_styles[$settings['video_style']])) {
$summary[] = t('Video style: @style', array('@style' => $video_styles[$settings['video_style']]));
}
- }
+ }
if ($display['type'] == 'video_embed_field_thumbnail' || $display['type'] == 'video_embed_field_thumbnail_colorbox') {
$image_styles = image_style_options(FALSE);
if (isset($image_styles[$settings['image_style']])) {
$summary[] = t('Image style: @style', array('@style' => $image_styles[$settings['image_style']]));
- } //No Image style (original image)
+ } //No Image style (original image)
else {
$summary[] = t('Original Image.');
}
@@ -283,14 +283,14 @@
$summary[] = t('Image link: none');
}
}
-
+
if ($settings['description'] && $instance['settings']['description_field']) {
$summary[] = t('Show description');
}
else{
$summary[] = t('Hide description');
}
-
+
return implode('
', $summary);
}
@@ -299,7 +299,7 @@
*/
function video_embed_field_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display){
$element = array();
-
+
foreach ($items as $delta => $item) {
//create the render array for the description
if (isset($item['description']) && $item['description'] && $display['settings']['description'] && $instance['settings']['description_field']) {
@@ -341,25 +341,23 @@
),
);
}
- if($display['settings']['image_link'] == 'source'){
- $element[$delta]['#prefix'] = '';
+ if ($display['settings']['image_link'] == 'source'){
+ $element[$delta]['#prefix'] = '';
$element[$delta]['#suffix'] = '';
}
- else if($display['settings']['image_link'] == 'node'){
- $nid = $entity->nid;
- $base_path = $GLOBALS['base_path'];
- $element[$delta]['#prefix'] = '';
+ elseif ($display['settings']['image_link'] == 'node'){
+ $element[$delta]['#prefix'] = '';
$element[$delta]['#suffix'] = '';
}
} //incase no thumbnail was downloaded / provider doesn't support thumbnails
else {
$element[$delta] = array(
- );
+ );
}
}
else if ($display['type'] == 'video_embed_field_thumbnail_colorbox') {
if (isset($item['thumbnail_path'])) {
- $element[$delta] = array(
+ $element[$delta] = array(
array(
'#theme' => 'video_embed_field_colorbox_code',
'#image_url' => $item['thumbnail_path'],
@@ -367,17 +365,17 @@
'#video_url' => $item['video_url'],
'#video_style' => $display['settings']['video_style'],
),
- );
+ );
}//incase no thumbnail was downloaded / provider doesn't support thumbnails
else {
$element[$delta] = array(
- );
+ );
}
}
//Get the HTML instead of the array, because we append it to the suffix.
//This way, the thumbnail link wrapper doesn't make the description a link as well.
$description_html = drupal_render($description);
-
+
//No need to check to add, as we set it to blank above if it's set to not display.
//The if/else is so that it doesn't show an error in case there's no suffix.
if(isset($element[$delta]['#suffix'])){
@@ -387,7 +385,7 @@
$element[$delta]['#suffix'] = $description_html;
}
}
-
-
+
+
return $element;
}