http://blog.deconcept.com/swfobject/.'); break; } } /** * Implementation of hook_theme(). */ function swfobject_api_theme() { return array( 'swfobject_api' => array( 'arguments' => array('url' => NULL, 'params' => NULL, 'vars' => NULL), ), ); } /** * Implementation of hook_menu(). */ function swfobject_api_menu() { $items = array(); $items['admin/settings/swfobject_api'] = array( 'title' => 'SWFObject API', '#description' => 'Configure the SWFObject API.', 'page callback' => 'drupal_get_form', 'page arguments' => array('swfobject_api_settings_form'), 'access arguments' => array('administer nodes'), ); return $items; } /** * implementation of drupal's hook_perm */ function swfobject_api_perm(){ return array('administer swfobject_api'); } /** * Menu callback: SWFObject API configuration form. */ function swfobject_api_settings_form() { $form = array(); $form['swfobject_api_settings'] = array( '#type' => 'fieldset', '#title' => t('Settings'), '#tree' => TRUE ); $form['swfobject_api_settings']['swfoa_version'] = array( '#type' => 'textfield', '#title' => t('Default minimum version required'), '#description' => t('This value can be overridden via the theme call.'), '#default_value' => variable_get('swfoa_express', '6'), '#required' => TRUE ); $form['swfobject_api_settings']['swfoa_express'] = array( '#type' => 'checkbox', '#title' => t('Enable express install.'), '#description' => t('Express install allows player upgrades without having to leave the site. Only versions 6.0.65 and above are supported.'), '#default_value' => variable_get('swfoa_express', false), ); $form['submit'] = array('#type' => 'submit', '#value' => t('Save settings')); return system_settings_form($form); } /** * Implementation of theme * @param $url a web accessible url to the flash file * @param $params an associative array of parameters that describe the SWF * @param $vars an associative array of variables to pass through to the SWF flashvars value * @param $id is an id to appened to the so object * @param string $method determins if the object is written or placed in jquery document ready * @return themed html */ function theme_swfobject_api($url, $params = array(), $vars = array(), $id = null, $method = null) { static $id_count; // set the base parameters $base_params = array( 'width' => '100%', 'height' => '100%', 'no_flash' => t('Sorry, you need to install flash to see this content.'), 'version' => variable_get('swfoa_version', '5'), 'type' => 'movie', 'bg_color' => '#FFFFFF' ); $params = array_merge($base_params, $params); // Express install redirect URL: as per the SWFObject docs, this should // actually be xiRedirectUrl; variable name changed for simplicity. if (isset($param['express_redirect'])) { $redirect = $param['express_redirect']; } // create a unique id, use what's passed in, what has been saved locally if ($id) { $id_count = $id; } else { $id_count = $id_count ? $id_count : 1; } // set the name of the swf file $name = form_clean_id(str_replace('.swf', '', basename($url))) .'_'. $id_count; // set the div id to the params if ($params['div_id']) { $div_id = $params['div_id']; unset($params['div_id']); } else { $div_id = 'flashcontent_'. $name; } // build the class if ($params['class']) { $class = ' class="'. $params['class'] .'"'; unset($params['class']); } // build the div structure $html[] = '
'. $params['no_flash'] ."
"; // build the javascript // get the path to thje swf object library $path = base_path() . drupal_get_path('module', 'swfobject_api') .'/swfobject.js'; // we need to add the swfobject library but we need to do this inside the // html because theme functions can be cached $html[] = ''; $html[] = ''; // increment the id count $id_count ++; return implode("\n", $html); }