| 1 |
<?php
|
| 2 |
// $Id: evoca.module,v 1.1 2007/05/22 02:41:56 draco2002 Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Enables managing an Evoca Browser Mic block and Evoca Comment player input filter.
|
| 7 |
* Module URI: http://evoca.com/
|
| 8 |
* Author: Dan Rowe
|
| 9 |
* Author URI: http://redfinsolutions.com/
|
| 10 |
*/
|
| 11 |
|
| 12 |
/**
|
| 13 |
* Implementation of hook_help().
|
| 14 |
*/
|
| 15 |
function evoca_help($section) {
|
| 16 |
switch ($section) {
|
| 17 |
case 'admin/help#evoca':
|
| 18 |
$output = '<p>'. t('The evoca module.') .'</p>';
|
| 19 |
return $output;
|
| 20 |
}
|
| 21 |
}
|
| 22 |
|
| 23 |
/**
|
| 24 |
* Implementation of hook_perm().
|
| 25 |
*/
|
| 26 |
function evoca_perm() {
|
| 27 |
return array('submit evoca comment');
|
| 28 |
}
|
| 29 |
|
| 30 |
/**
|
| 31 |
* Implementation of hook_menu
|
| 32 |
*/
|
| 33 |
function evoca_menu($may_cache) {
|
| 34 |
$items = array();
|
| 35 |
|
| 36 |
if (!$may_cache) {
|
| 37 |
$items[] = array(
|
| 38 |
'path' => 'admin/settings/evoca', 'title' => t('Evoca settings'),
|
| 39 |
'callback' => 'drupal_get_form',
|
| 40 |
'callback arguments' => array('evoca_admin_settings'),
|
| 41 |
'access' => user_access('administer site configuration'),
|
| 42 |
'type' => MENU_NORMAL_ITEM,
|
| 43 |
'description' => t('Change settings for the evoca module.'),
|
| 44 |
);
|
| 45 |
}
|
| 46 |
return $items;
|
| 47 |
}
|
| 48 |
|
| 49 |
/**
|
| 50 |
* Implementation of hook_block.
|
| 51 |
*
|
| 52 |
* Offers a block with the option for vertical or horizontal player
|
| 53 |
*/
|
| 54 |
function evoca_block($op = 'list', $delta = 0, $edit = array()) {
|
| 55 |
switch ($op) {
|
| 56 |
case 'list':
|
| 57 |
$blocks[0]['info'] = t('Evoca recorder');
|
| 58 |
return $blocks;
|
| 59 |
|
| 60 |
case 'configure':
|
| 61 |
$form['evoca_block_comments'] = array(
|
| 62 |
'#type' => 'radios',
|
| 63 |
'#title' => t('Show Number of comments?'),
|
| 64 |
'#default_value' => variable_get('evoca_block_comments', 0),
|
| 65 |
'#options' => array(0 => "Yes", 1 => "No"),
|
| 66 |
);
|
| 67 |
$form['evoca_block_direction'] = array(
|
| 68 |
'#type' => 'radios',
|
| 69 |
'#title' => t('Show block horizontal or vertical?'),
|
| 70 |
'#options' => array(0 => "Horizontal", 1 => "Vertical"),
|
| 71 |
'#default_value' => variable_get('evoca_block_direction', 1),
|
| 72 |
);
|
| 73 |
return $form;
|
| 74 |
case 'save':
|
| 75 |
variable_set('evoca_block_comments',
|
| 76 |
(int) $edit['evoca_block_comments']);
|
| 77 |
variable_set('evoca_block_direction',
|
| 78 |
(int) $edit['evoca_block_direction']);
|
| 79 |
break;
|
| 80 |
case 'view':
|
| 81 |
if (user_access('submit evoca comment')) {
|
| 82 |
switch ($delta) {
|
| 83 |
case 0:
|
| 84 |
$block['subject'] = t('Evoca Recorder');
|
| 85 |
$contents = theme('evoca_recorder');
|
| 86 |
if (!$contents && user_access('administer blocks')) {
|
| 87 |
$contents = 'Please update your owner id '. l('here', 'admin/settings/evoca');
|
| 88 |
}
|
| 89 |
$block['content'] = $contents;
|
| 90 |
break;
|
| 91 |
}
|
| 92 |
return $block;
|
| 93 |
}
|
| 94 |
}
|
| 95 |
}
|
| 96 |
|
| 97 |
/**
|
| 98 |
* Implementation of hook_filter(). Contains a basic set of essential filters.
|
| 99 |
* - Evoca Comments:
|
| 100 |
* Validates user-supplied HTML, transforming it as necessary.
|
| 101 |
*/
|
| 102 |
function evoca_filter($op, $delta = 0, $format = -1, $text = '') {
|
| 103 |
switch ($op) {
|
| 104 |
case 'list':
|
| 105 |
return array(0 => t('Evoca Comments'));
|
| 106 |
|
| 107 |
case 'description':
|
| 108 |
switch ($delta) {
|
| 109 |
case 0:
|
| 110 |
return t('Allows you to display Evoca Comments in your nodes by entering the comment ids <<evoca:098098>> into the body.');
|
| 111 |
default:
|
| 112 |
return;
|
| 113 |
}
|
| 114 |
|
| 115 |
case 'process':
|
| 116 |
switch ($delta) {
|
| 117 |
case 0:
|
| 118 |
return _filter_evoca_comment($text);
|
| 119 |
default:
|
| 120 |
return $text;
|
| 121 |
}
|
| 122 |
|
| 123 |
case 'settings':
|
| 124 |
switch ($delta) {
|
| 125 |
default:
|
| 126 |
return;
|
| 127 |
}
|
| 128 |
|
| 129 |
default:
|
| 130 |
return $text;
|
| 131 |
}
|
| 132 |
}
|
| 133 |
|
| 134 |
/**
|
| 135 |
* Implementation of hook_filter_tips().
|
| 136 |
*/
|
| 137 |
function evoca_filter_tips($delta, $format, $long = FALSE) {
|
| 138 |
return t('Syntax: [evoca id] Example: [evoca 999000]');
|
| 139 |
}
|
| 140 |
|
| 141 |
function _filter_evoca_comment($text) {
|
| 142 |
$pattern = "/\[evoca (.*)\]/";
|
| 143 |
if (preg_match_all($pattern, $text, $match)) {
|
| 144 |
foreach ($match[1] as $key => $value) {
|
| 145 |
$tmp = explode(' ', $value);
|
| 146 |
$repl[] = theme('evoca_comment', $value);
|
| 147 |
$mtch[] = $match[0][$key];
|
| 148 |
}
|
| 149 |
return str_replace($mtch, $repl, $text);
|
| 150 |
}
|
| 151 |
return $text;
|
| 152 |
}
|
| 153 |
|
| 154 |
function theme_evoca_recorder() {
|
| 155 |
$ownerid = variable_get('evoca_owner_id', FALSE);
|
| 156 |
if (!$ownerid ) {
|
| 157 |
drupal_set_message('false');
|
| 158 |
return FALSE;
|
| 159 |
}
|
| 160 |
if (variable_get('evoca_block_direction', 1)) {
|
| 161 |
$direction = 'v';
|
| 162 |
$size = 'width="220" height="270"';
|
| 163 |
}
|
| 164 |
else {
|
| 165 |
$direction = 'h';
|
| 166 |
$size = 'width="347" height="180"';
|
| 167 |
}
|
| 168 |
$comments = (variable_get('evoca_block_comments', 0) ? 'true' : 'false');
|
| 169 |
$html = '<div id="evoca_inBlogRecorder_horiz"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" '. $size .'>'.
|
| 170 |
'<param name="movie" value="http://www.evoca.com/evocaRecorder/inBlogRecorder_'. $direction .'.swf" />'.
|
| 171 |
'<param name="quality" value="high" />'.
|
| 172 |
'<param name="wmode" value="transparent" /><param name="FlashVars" value="ownerid='. $ownerid .'&teu=http://www.evoca.com/&hideCommentCount=true" />'.
|
| 173 |
'<embed src="http://www.evoca.com/evocaRecorder/inBlogRecorder_'. $direction .'.swf" FlashVars="ownerid='. $ownerid .'&teu=http://www.evoca.com/&hideCommentCount='. $comments .'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" '. $size .' wmode="transparent" ></embed>'.
|
| 174 |
'</object></div>';
|
| 175 |
return $html;
|
| 176 |
}
|
| 177 |
|
| 178 |
function theme_evoca_comment($rid) {
|
| 179 |
if (is_numeric($rid)) {
|
| 180 |
//$html = '<iframe allowtransparency="true" background-color="transparent" marginwidth="0" marginheight="0" src="http://www.evoca.com/myrecordings/recBlogForIFrame.jsp?rid='. $rid .'&teu=http://www.evoca.com/&recType=c" frameborder="0" width="100" height="100" scrolling="no"></iframe>';
|
| 181 |
$html = '<embed src="http://www.evoca.com/evocaPlayer/evocaPlayer.swf?id='. $rid .'&teu=http://www.evoca.com/" wmode="transparent" allowscriptaccess="never" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" height="85" width="90">';
|
| 182 |
return $html;
|
| 183 |
}
|
| 184 |
else {
|
| 185 |
return;
|
| 186 |
}
|
| 187 |
}
|
| 188 |
|
| 189 |
/**
|
| 190 |
* Implementation of hook_settings
|
| 191 |
*/
|
| 192 |
function evoca_admin_settings() {
|
| 193 |
$form['evoca_owner_id'] = array(
|
| 194 |
'#type' => 'textfield',
|
| 195 |
'#title' => t('Evoca Owner ID'),
|
| 196 |
'#maxlength' => 128,
|
| 197 |
'#default_value' => variable_get('evoca_owner_id', FALSE),
|
| 198 |
'#description' => t('You must provide your Evoca Owner ID. If you already have an Evoca account, you can find your Evoca Owner ID by clicking ') . l('here', 'http://www.evoca.com/plugins/wordpress/index.jsp?enterpriseID=ENT_DRUPAL') .' Don\'t have an Evoca account yet? Sign up '. l('here', 'http://www.evoca.com/signup/signup.jsp?enterpriseID=ENT_DRUPAL'),
|
| 199 |
);
|
| 200 |
|
| 201 |
// Define a validation function.
|
| 202 |
$form['#validate'] = array(
|
| 203 |
'evoca_admin_settings_validate' => array()
|
| 204 |
);
|
| 205 |
return system_settings_form($form);
|
| 206 |
}
|
| 207 |
|
| 208 |
// Validate the settings form.
|
| 209 |
function evoca_admin_settings_validate($form_id, $form_values) {
|
| 210 |
if (!is_numeric($form_values['evoca_owner_id'])) {
|
| 211 |
form_set_error('evoca_owner_id', t('Please enter a number.'));
|
| 212 |
}
|
| 213 |
}
|
| 214 |
|