t(DASH_PLAYER_NAME . ' Settings'), 'description' => t('Administer the '. DASH_PLAYER_NAME .' on this site.'), 'page callback' => 'drupal_get_form', 'page arguments' => array('dashplayer_settings'), 'access arguments' => array('administer ' . DASH_PLAYER_SYS_NAME) ); return $items; } /** * Implementation of hook_theme() */ function dashplayer_theme() { return array( 'dashplayer_play_flash' => array( 'template' => 'dashplayer', 'arguments' => array('params' => NULL), ), ); } function template_preprocess_dashplayer_play_flash(&$variables) { // Add the Dash Player Interface JavaScript drupal_add_js(drupal_get_path('module', 'dashplayer') .'/dashPlayer.js'); if( !$variables['params']['id'] ) { $variables['params']['id'] = 'dashplayer'; } if( $variables['params']['connect'] ) { drupal_add_js("dashAddObject( '" . $variables['params']['id'] . "' );", 'inline', 'header'); } $flashvars = ''; $width = 652; $height = 432; $player = ''; $id = 'dashplayer'; foreach($variables['params'] as $param => $value) { $param = strtolower($param); if( $param == 'player' ) { $player = $value; } else if( $param == 'width' ) { $width = $value; } else if( $param == 'height' ) { $height = $value; } else if( $param == 'id' ) { $flashvars .= $param . '=' . $value . '&'; $id = $value; } else { if( $value ) { $flashvars .= $param . '=' . $value . '&'; } } } $flashvars = rtrim($flashvars, '&'); // Creates an absolute path for the player. if( $player !== '' ) { $loader_path = check_url(file_create_url($player)); } else { $loader_path = check_url(variable_get('dashplayer_path', file_create_url(DEFAULT_PLAYER_NAME))); } $variables['flashvars'] = $flashvars; $variables['width'] = $width; $variables['height'] = $height; $variables['player'] = $loader_path; $variables['id'] = $id; drupal_alter( 'dashgetplayer', $variables ); } /** * Callback for 'services/browse' */ function dashplayer_settings() { $form['dashplayer_path'] = array( '#title' => t(DASH_PLAYER_NAME .' Path'), '#type' => 'textfield', '#default_value' => variable_get('dashplayer_path', file_create_url(DEFAULT_PLAYER_NAME)), '#maxlength' => 128, '#description' => t('The path to the ' . DASH_PLAYER_NAME), '#required' => TRUE ); return system_settings_form($form); } /** * Implementation of hook_service() */ function dashplayer_service() { return array( array( '#method' => 'dashplayer.getView', '#callback' => 'dashplayer_get_view', '#key' => FALSE, '#args' => array( array( '#name' => 'view_name', '#type' => 'string', '#description' => t('View name.')), array( '#name' => 'limit', '#type' => 'int', '#optional' => TRUE, '#description' => t('The limit for the view to show.')), array( '#name' => 'page', '#type' => 'int', '#optional' => TRUE, '#description' => t('The page number to show.')), array( '#name' => 'args', '#type' => 'array', '#optional' => TRUE, '#description' => t('An array of arguments to pass to the view.')) ), '#return' => 'array', '#help' => t('Retrieves a view defined in views.module.') ), array( '#method' => 'dashplayer.getDrupalVersion', '#callback' => 'dashplayer_get_drupal_version', '#key' => FALSE, '#return' => 'int', '#help' => t('Returns the correct drupal version.') ) ); } function dashplayer_get_drupal_version() { return 6; } /** * Get a view from the database. */ function dashplayer_get_view($view_name, $limit = 0, $page = 0, $args = array()) { $view = views_get_view($view_name); if (is_null($view)) { return services_error('View does not exist.'); } // Check access if (!views_access($view)) { return services_error('You do not have access to this view.'); } $view->set_use_pager(FALSE); $view->set_items_per_page($limit); $view->set_offset($page*$limit); $view->set_arguments($args); $view->get_total_rows = TRUE; $view->execute(); $nodes = array(); $nodes['nodes'] = array(); foreach ($view->result as $node) { $new_node = new stdClass(); $temp = node_load($node->nid); foreach( $temp as $field => $value ) { if( $field && $value ) { $new_node->{$field} = $value; } } $nodes['nodes'][] = $new_node; } $nodes['total_rows'] = $view->total_rows; drupal_alter( 'dashview', $nodes, $args ); // AMFPHP complains if the array values are not right. $nodes["nodes"] = array_values( $nodes["nodes"] ); return $nodes; } function dashplayer_get_player($params) { print theme('dashplayer_play_flash', $params); }