The videos module is used to insert into drupal Quick Time videos as nodes.
"); case "admin/modules#description": return t("Allows QuickTime videos nodes."); case 'node/add#video': return t("Video allow you to insert QuickTime videos as nodes"); break; } } /** * Implementation of hook_menu(). */ function video_menu() { global $user; //if ($may_cache) { $items[] = array( 'path' => 'node/add/video', 'title' => t('video'), 'access' => user_access('create videos')); $items[] = array( 'path' => 'video/goto', 'callback' => '_video_page_goto', 'type' => MENU_CALLBACK, 'callback arguments' => arg(3), 'access' => user_access('access content')); //} if (arg(0) == 'node' && is_numeric(arg(1))) { $node = node_load(array('nid' => arg(1))); if ($node->type == 'video') { $items[] = array('path' => 'node/'. arg(1) .'/play', 'title' => t('play'), 'callback' => 'video_play', 'access' => user_access('access content'), 'weight' => 3, 'type' => MENU_LOCAL_TASK); $items[] = array('path' => 'node/'.arg(1).'/download', 'title' => t('download'), 'callback' => 'video_download', 'access' => user_access('access content'), 'weight' => 5, 'type' => MENU_LOCAL_TASK); } } return $items; } function video_link($type, $node = 0, $main = 0) { $links = array(); // Node links for a video if ($type == 'node' && $node->type == 'video' && $node->vidfile) { $links[] = l(t('play'), "node/$node->nid/play", array('class' => 'outgoing', 'title' => t('play %link', array('%link' => $node->title))))." ". t("or"). " ". l(t('download'), "video/goto/$node->nid", array('class' => 'outgoing', 'title' => t('visit %link', array('%link' => $node->title)))) ." ".$node->title. (user_access("access statistics") ? " ({$node->clicks})" : ""); } return $links; } function video_perm() { return array('create videos'); } function video_settings() { // put something good here } /******************************************************************** * Node Hooks ********************************************************************/ function video_node_name($node) { return t("video"); } function video_access($op, $node) { switch($op) { case 'view': return $node->status; // see book.module for reference case 'create': return user_access("create videos"); } } function video_form(&$node, &$param) { $output .= form_textfield(t("Video File"), "vidfile", $node->vidfile, 60, 65535, t("Put here the video file path. You can use both relative path (something/video.mov) or absolute (http://www.myvideo.com/videos/videos.mov).") . ($error['vidfile'] ? $error['vidfile'] : ''), NULL, TRUE); $output .= form_textfield(t('Video Size x'), 'videox', $node->videox, 4, 4, t("Horizontal video pixel size."), null, true); $output .= form_textfield(t('Video Size y'), 'videoy', $node->videoy, 4, 4, t("Horizontal video pixel size."), null, true); $output .= form_textfield(t('Size'), 'size', $node->size, 10, 30, t("Dimension of your video. Also provide size unit (KB or MB)."), null, true); if (function_exists('taxonomy_node_form')) { $output .= implode('', taxonomy_node_form('video', $node)); } $output .= form_textarea(t("Body"), "body", $node->body, 60, 20, t("Textual description of the video.") . ($error['body'] ? $error['body'] : '')); $output .= filter_form('format', $node->format); return $output; } function video_insert($node) { db_query("INSERT INTO {video} (nid, vidfile, size, videox, videoy) VALUES ('%d', '%s', '%s', '%d', '%d')", $node->nid, $node->vidfile, $node->size, $node->videox, $node->videoy); } function video_update($node) { db_query("UPDATE {video} SET vidfile = '%s', size = '%s', videox = '%d', videoy = '%d' WHERE nid = '%d'", $node->vidfile, $node->size, $node->videox, $node->videoy, $node->nid); } function video_delete(&$node) { db_query("DELETE FROM {video} WHERE nid = '%s'", $node->nid); cache_clear_all("video:blogmarks:block"); } function video_validate(&$node) { $result = db_query("SELECT * from {video} WHERE vidfile = '%s' and nid <> '%d'", $node->vidfile, $node->nid); if (db_num_rows($result) > 0) { $video = db_fetch_object($result); $othernode = node_load(array("nid" => $video->nid)); form_set_error('video', t('A video %link-to-existing using that link already exists', array("%link-to-existing" => l($othernode->title, 'node/' . $othernode->nid . '/edit')))); } } function video_load($node) { return db_fetch_object(db_query("SELECT * FROM {video} WHERE nid = '%d'", $node->nid)); } /******************************************************************** * Block display functions ********************************************************************/ function video_block($op = "list", $delta = 0) { if ($op == "list") { return array( 0 => array('info' => t("Top videos")), 1 => array('info' => t("Latest videos")), ); } elseif ($op == 'view') { switch ($delta) { case 0: return array( 'subject' => t("Top videos"), 'content' => video_block_list('top') ); case 1: return array( 'subject' => t("Latest videos"), 'content' => video_block_list('new') ); } } } function video_block_list($type = 'top') { $orderby = ($type == 'new') ? 'n.created' : 'v.clicks'; return node_title_list(db_query_range(db_rewrite_sql("SELECT DISTINCT (n.nid) , n.title FROM {node} n INNER JOIN {video} v WHERE n.type = 'video' AND n.status = 1 AND n.moderate = 0 ORDER by $orderby DESC"),0, 10)); } function _video_page_goto($id, $type = 'video') { global $base_url; if (in_array($type, array("video", "feed"))) { $result = db_query(db_rewrite_sql("SELECT n.nid, n.vidfile FROM {video} n WHERE n.nid = '%d'"), $id); $wl = db_fetch_object($result); $type = "vidfile"; if ($wl->$type!='') { db_query("UPDATE {video} SET clicks = clicks + 1 where nid = '%d'", $id); // Didn't this use to work? header("HTTP/1.0 301 Moved Permanently"); } header("Location: ".$wl->$type); } } function video_download() { if ($node = node_load(array('nid' => arg(1)))) { _video_page_goto($node->nid); } else { drupal_not_found(); } } /** Implements play callback function from node menu */ function video_play() { if ($node = node_load(array('nid' => arg(1)))) { print theme('video_play', $node, $node->title); } else { drupal_not_found(); } } /** Themeable functions for playing videos. It prints a page with a quicktime player inside linked to the file record of the node. */ function theme_video_play($node, $main = 0) { $output = "\n ';
$output .= t("Problems viewing videos?")."
";
$output .= t("Download latest Quicktime Player")." ";
$output .= ''.t("here").'';
$output .= "