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) { //print_r($_FILES); //print("FUCK"); //file_save_upload($_FILES['edit']['tmp_name'], '/home/fabio/public_html/adrenalinteam.it/videos/'. $_FILES['userfile']['name'], true); //move_uploaded_file ($_FILES['edit']['tmp_name'], ); //print_r(file_check_upload($node)); //die(); 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) { //print_r($node);// die(); //printf("UPDATE {video} (nid, rider, image, vidfile, spot, move, size, videox, videoy) VALUES (%d, '%s', '%s','%s','%s','%s','%s', %d, %d)", //$node->nid, $node->rider, $node->image, $node->vidfile, $node->spot, $node->move, $node->size, $node->videox, $node->videoy); die(); //printf("UPDATE {video} SET rider = '%s', image = '%s', vidfile = '%s', spot = '%s', move = '%s', size = '%d', videox = '%d', videoy = '%d' WHERE nid = '%d'", $node->rider, $node->image, $node->vidfile, $node->spot, $node->move, $node->size, $node->videox, $node->videoy, $node->nid); die(); 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 n.nid, n.title FROM {node} n, {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"))) { // DRUPAL 4.5 --> $result = db_query("SELECT n.nid, n.vidfile FROM {video} n ". node_access_join_sql() ." WHERE n.nid = '%d' AND ". node_access_where_sql(), $id); $result = db_query(db_rewrite_sql("SELECT n.nid, n.vidfile FROM {video} n WHERE n.nid = '%d'"), $id); //printf("SELECT n.nid, n.vidfile FROM {video} n ". node_access_join_sql() ." WHERE n.nid = '%d' AND ". node_access_where_sql(), $id); //print("SELECT n.nid, n.vidfile FROM {video} n ". node_access_join_sql() ." WHERE n.nid = '%d' AND ". node_access_where_sql()); $wl = db_fetch_object($result); //print_r($wl); $type = "vidfile"; if ($wl->$type!='') { db_query("UPDATE {video} SET clicks = clicks + 1 where nid = '%d'", $id); //printf("UPDATE {video} SET clicks = clicks + 1 where nid = '%d'", $id); // Didn't this use to work? header("HTTP/1.0 301 Moved Permanently"); } //print($base_url."/".$wl->$type); header("Location: " . $base_url."/".$wl->$type); //drupal_goto($wl->$type); print("ciao"); } } 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); //theme('page', $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) { //print_r($node); //print(url("video/goto/$node->nid")); die(); $output = "\n
\n"; $output .= ' nid").'" /> nid").'" width="'.$node->videox.'" height="'.$node->videoy.'" scale="tofit" autoplay="true" kioskmode="false" pluginspage="http://www.apple.com/quicktime/download/">

'; $output .= t("Problems viewing videos?")."
"; $output .= t("Download latest Quicktime Player")." "; $output .= ''.t("here").''; //l($text, $path, $attributes = array(), $query = NULL, $fragment = NULL, $absolute = FALSE) $output .= "

\n
\n"; //node_prepare($node, $main); //$node->body = $output; //return node_prepare($node, $main); //print $output; return theme("page", $output, t("Playing")." ".$node->title); } function theme_video_content($node, $main = 0) { $output = "
\n"; $output .= theme_video_node_short($node); $output .= "
\n"; $node->body = $output; return $node; } ?>