('admin/settings/' . DASH_PLAYER_SYS_NAME), 'title' => t(DASH_PLAYER_NAME . ' Settings'), 'description' => t('Administer the '. DASH_PLAYER_NAME .' on this site.'), 'callback' => 'drupal_get_form', 'callback arguments' => array('dashplayer_settings'), 'access' => user_access('administer ' . DASH_PLAYER_SYS_NAME), 'type' => MENU_NORMAL_ITEM ); } return $items; } /** * 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', '#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.incrementNodeCounter', '#callback' => 'dashplayer_increment_node_counter', '#args' => array( array( '#name' => 'nid', '#type' => 'int', '#description' => t('The node to increment the counter for.')) ), '#return' => 'int', '#help' => t('Increments the node counter for any given node.') ) ); } function dashplayer_nodeapi(&$node, $op, $teaser, $page) { // Only if the node type is enabled. switch ($op) { case 'load': $additions = array(); if (module_exists('statistics') && variable_get('statistics_count_content_views', 0)) { $node_count = db_result(db_query("SELECT totalcount FROM {node_counter} WHERE nid=%d", $node->nid)); $additions['node_counter'] = number_format($node_count); } // Here we need to look for images attached to this node... if( module_exists('image_attach') ) { $image_nodes = db_query("SELECT iid FROM {image_attach} WHERE nid=%d", $node->nid); while($image_node = db_fetch_object($image_nodes)) { $images = db_query("SELECT * FROM {files} WHERE nid=%d AND (filemime='jpg' OR filemime='jpeg' OR filemime='png' OR filemime='gif' OR filemime='image/jpeg' OR filemime='image/jpg' OR filemime='image/png' OR filemime='image/gif')", $image_node->iid); while( $image = db_fetch_object($images)) { $additions['dashplayer_images'][] = $image; } } } return $additions; } } function dashplayer_increment_node_counter( $nid ) { if( $nid && module_exists('statistics') && variable_get('statistics_count_content_views', 0) ) { db_query('UPDATE {node_counter} SET daycount = daycount + 1, totalcount = totalcount + 1, timestamp = %d WHERE nid = %d', time(), $nid); if (!db_affected_rows()) { db_query('INSERT INTO {node_counter} (nid, daycount, totalcount, timestamp) VALUES (%d, 1, 1, %d)', $nid, time()); } return db_result(db_query("SELECT totalcount FROM {node_counter} WHERE nid=%d", $nid)); } else { return 0; } } /** * 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.'); } $result = views_build_view('result', $view, $args, false, 0, 0); $nodes['total_rows'] = $view->num_rows; $result = views_build_view('result', $view, $args, false, $limit, $page); while ($node = db_fetch_object($result['result'])) { $nodes['nodes'][] = services_node_load(node_load(array('nid' => $node->nid)), array()); } return $nodes; } function dashplayer_get_player($params) { print theme('dashplayer_play_flash', $params); } /** * Play videos from in FLV Flash video format * * @param $node * object with node information * * @return * string of content to display */ function theme_dashplayer_play_flash($params) { $flashvars = ''; $width = 460; $height = 525; $player = ''; foreach($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( $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))); } $output .= '' . "\n"; $output .= '' . "\n"; $output .= '' . "\n"; $output .= '' . "\n"; $output .= '' . "\n"; $output .= '' . "\n"; $output .= '' . "\n"; return $output; }