|
|
|
@ -2,7 +2,7 @@
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* @file |
|
|
|
|
* Contains entity_embed_attribution.module. |
|
|
|
|
* Contains media_attribution.module. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
use Drupal\Core\Routing\RouteMatchInterface; |
|
|
|
@ -17,10 +17,10 @@ use Drupal\Component\Serialization\Yaml;
|
|
|
|
|
/** |
|
|
|
|
* Implements hook_help(). |
|
|
|
|
*/ |
|
|
|
|
function entity_embed_attribution_help($route_name, RouteMatchInterface $route_match) { |
|
|
|
|
function media_attribution_help($route_name, RouteMatchInterface $route_match) { |
|
|
|
|
switch ($route_name) { |
|
|
|
|
// Main module help for the entity_embed_attribution module. |
|
|
|
|
case 'help.page.entity_embed_attribution': |
|
|
|
|
// Main module help for the media_attribution module. |
|
|
|
|
case 'help.page.media_attribution': |
|
|
|
|
$output = ''; |
|
|
|
|
$output .= '<h3>' . t('About') . '</h3>'; |
|
|
|
|
$output .= '<p>' . t('Attach an attribution and license info to embedded media') . '</p>'; |
|
|
|
@ -35,7 +35,7 @@ function entity_embed_attribution_help($route_name, RouteMatchInterface $route_m
|
|
|
|
|
* |
|
|
|
|
* Add attribution form to media embed forms and view displays. |
|
|
|
|
*/ |
|
|
|
|
function entity_embed_attribution_modules_installed($modules) { |
|
|
|
|
function media_attribution_modules_installed($modules) { |
|
|
|
|
|
|
|
|
|
foreach (['default', 'media_browser'] as $form_variant) { |
|
|
|
|
$form_entity = EntityFormDisplay::load("media.image.$form_variant"); |
|
|
|
@ -74,7 +74,7 @@ function entity_embed_attribution_modules_installed($modules) {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// Load default license terms from the module config. |
|
|
|
|
entity_embed_attribution_load_default_licenses(); |
|
|
|
|
media_attribution_load_default_licenses(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -82,7 +82,7 @@ function entity_embed_attribution_modules_installed($modules) {
|
|
|
|
|
* |
|
|
|
|
* @param $variables |
|
|
|
|
*/ |
|
|
|
|
function entity_embed_attribution_preprocess_entity_embed_container(&$variables) { |
|
|
|
|
function media_attribution_preprocess_entity_embed_container(&$variables) { |
|
|
|
|
|
|
|
|
|
if ($attributions = $variables['element']['#entity']->get('field_image_attribution') |
|
|
|
|
->referencedEntities()) { |
|
|
|
@ -134,18 +134,18 @@ function entity_embed_attribution_preprocess_entity_embed_container(&$variables)
|
|
|
|
|
/** |
|
|
|
|
* Read the list of pre-defined Creative Commons licenses and create corresponding taxonomy terms. |
|
|
|
|
*/ |
|
|
|
|
function entity_embed_attribution_load_default_licenses() { |
|
|
|
|
$file_path = drupal_get_path('module', 'entity_embed_attribution') . '/entity_embed_attribution.default.licenses.yml'; |
|
|
|
|
function media_attribution_load_default_licenses() { |
|
|
|
|
$file_path = drupal_get_path('module', 'media_attribution') . '/media_attribution.default.licenses.yml'; |
|
|
|
|
$file_contents = file_get_contents($file_path); |
|
|
|
|
$license_data = Yaml::decode($file_contents); |
|
|
|
|
|
|
|
|
|
foreach ($license_data as $license_item) { |
|
|
|
|
entity_embed_attribution_create_license_term($license_item['title'],$license_item['short_label'], $license_item['icon_file'], $license_item['url']); |
|
|
|
|
media_attribution_create_license_term($license_item['title'],$license_item['short_label'], $license_item['icon_file'], $license_item['url']); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function entity_embed_attribution_create_license_term($term_title, $term_short_label, $icon_filename, $license_url) { |
|
|
|
|
$icon_file_uri = drupal_get_path('module', 'entity_embed_attribution') . "/images/$icon_filename"; |
|
|
|
|
function media_attribution_create_license_term($term_title, $term_short_label, $icon_filename, $license_url) { |
|
|
|
|
$icon_file_uri = drupal_get_path('module', 'media_attribution') . "/images/$icon_filename"; |
|
|
|
|
|
|
|
|
|
// Just in case the file has already been created. |
|
|
|
|
$icon_files = \Drupal::entityTypeManager() |