Created
July 31, 2014 15:44
-
-
Save keopx/8bf8a3cd9b0886f30e42 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function videodesk_importer_menu() { | |
$items = array(); | |
$items['admin/config/content/videodesk_importer'] = array( | |
'title' => 'Videodesk importer', | |
'description' => 'Configuration for Videodesk importer module', | |
'page callback' => 'drupal_get_form', | |
'page arguments' => array('videodesk_importer_form'), | |
'access arguments' => array('access administration pages'), | |
'type' => MENU_NORMAL_ITEM, | |
); | |
return $items; | |
} | |
function videodesk_importer_form($form) { | |
$form['videodesk_importer_uid'] = array( | |
'#type' => 'textfield', | |
'#title' => t('UID'), | |
'#description' => t('Please enter the given Videodesk UID'), | |
'#default_value' => variable_get('videodesk_importer_uid'), | |
'#required' => TRUE, | |
); | |
$form['videodesk_importer_display'] = array( | |
'#type' => 'radios', | |
'#title' => t('Display'), | |
'#description' => t('Choose if you want the module to be displayed on your site or not'), | |
'#options' => array(0 => 'No', 1 => 'Yes'), | |
'#default_value' => variable_get('videodesk_importer_display'), | |
'#required' => TRUE, | |
); | |
$form['videodesk_importer_language'] = array( | |
'#type' => 'select', | |
'#title' => t('Language'), | |
'#description' => t('Choose the language your want your videodesk chat window to be displayed in'), | |
'#options' => array('en' => 'English', 'fr' => 'French'), | |
'#default_value' => variable_get('videodesk_importer_language'), | |
'#required' => TRUE, | |
); | |
return system_settings_form($form); | |
} | |
/** | |
* Implements hook_block_info(). | |
*/ | |
function videodesk_importer_block_info() { | |
$blocks['videodesk_importer_ui'] = array( | |
'info' => t('Videodesk importer block UI'), | |
); | |
return $blocks; | |
} | |
/** | |
* Implements hook_block_view(). | |
*/ | |
function videodesk_importer_block_view($delta = '') { | |
$block = array(); | |
switch ($delta) { | |
case 'videodesk_importer_ui': | |
$videodesk_uid = variable_get('videodesk_importer_uid'); | |
$videodesk_display = variable_get('videodesk_importer_display'); | |
$videodesk_language = variable_get('videodesk_importer_language'); | |
if ($videodesk_display == 1) { | |
$block['content'] = drupal_add_js(" | |
var _videodesk= _videodesk || {}; | |
_videodesk['firstname'] = '' ; | |
_videodesk['lastname'] = '' ; | |
_videodesk['company'] = '' ; | |
_videodesk['email'] = '' ; | |
_videodesk['phone'] = '' ; | |
_videodesk['customer_lang'] = '' ; | |
_videodesk['customer_id'] = '' ; | |
_videodesk['customer_url'] = '' ; | |
_videodesk['cart_id'] = '' ; | |
_videodesk['cart_url'] = '' ; | |
_videodesk['order_id'] = '' ; | |
_videodesk['order_url'] = '' ; | |
_videodesk['module_url'] = 'awsenv4.videodesk.com'; | |
_videodesk['uid'] = '" . $videodesk_uid . "' ; | |
_videodesk['lang'] = '" . $videodesk_language . "' ; | |
(function() { | |
var videodesk = document.createElement('script'); videodesk.type = 'text/javascript'; videodesk.async = true; | |
videodesk.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'modulefront4.videodesk.com/js/videodesk.js'; | |
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(videodesk, s); | |
})(); | |
", array('type' => 'inline', 'scope' => 'footer')); | |
} | |
break; | |
} | |
return $block; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment