function bynder_add in Bynder 7
Create a form to add media from Bynder.
2 string references to 'bynder_add'
- BynderMediaBrowser::view in includes/
BynderMediaBrowser.inc - Implements MediaBrowserPlugin::view().
- bynder_menu in ./
bynder.module - Implements hook_menu().
File
- includes/
bynder.browser.inc, line 13 - Manages the Bynder media browser functionality
Code
function bynder_add($form, &$form_state = array()) {
$bynderApi = BynderMediaApi::getBynderApi();
$tokens = $bynderApi
->hasAccessToken();
if (!$bynderApi
->hasSettings()) {
$form['message'] = [
'#markup' => t('You haven\'t set up the <a href="' . url('admin/config/media/bynder', array(
'absolute' => true,
)) . '" class="oauth-link" target="_blank">Bynder settings</a> properly, please do so before importing assets.'),
'#prefix' => '<p>',
'#suffix' => '</p>',
];
}
elseif (!$tokens || isset($tokens['isRequestToken'])) {
$form['message'] = [
'#markup' => t('You need to <a href="' . url('bynder-oauth', array(
'absolute' => true,
)) . '" class="oauth-link" target="_blank">log into Bynder</a> before importing assets.'),
'#prefix' => '<p>',
'#suffix' => '</p>',
];
$form['reload'] = [
'#type' => 'button',
'#value' => 'Reload after submit',
'#attached' => [
'library' => [
'bynder/oauth',
],
],
'#attributes' => [
'class' => [
'oauth-reload',
'visually-hidden',
],
],
];
}
else {
$form['bynder_search'] = bynder_generate_search($form_state);
$form['submit'] = array(
'#type' => 'submit',
'#value' => 'Submit',
);
$form['#attached']['library'][] = array(
'bynder',
'bynder_administration',
);
$form['#attached']['css'][] = array(
'type' => 'external',
'data' => '//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.css',
);
}
return $form;
}