| | 145 | |
|---|
| | 146 | // Register a display object function |
|---|
| | 147 | display_set_display_function('file', 'file_displayobject'); |
|---|
| | 148 | } |
|---|
| | 149 | |
|---|
| | 150 | |
|---|
| | 151 | function file_displayobject($object_id,$object_type) |
|---|
| | 152 | { |
|---|
| | 153 | global $page_owner, $CFG; |
|---|
| | 154 | $owner_username = user_info('username', $page_owner); |
|---|
| | 155 | |
|---|
| | 156 | $return = ""; |
|---|
| | 157 | |
|---|
| | 158 | // Display file. Todo: Break this off into a library or call file lib |
|---|
| | 159 | if ($file = get_record_select('files', "ident=$object_id")) |
|---|
| | 160 | { |
|---|
| | 161 | if (run("users:access_level_check",$file->access) == true || $file->owner == $_SESSION['userid']) |
|---|
| | 162 | { |
|---|
| | 163 | |
|---|
| | 164 | $username = $owner_username; |
|---|
| | 165 | $ident = (int) $file->ident; |
|---|
| | 166 | $folder->ident = $file->folder; |
|---|
| | 167 | $title = get_access_description($file->access); |
|---|
| | 168 | $title .= stripslashes($file->title); |
|---|
| | 169 | $description = nl2br(stripslashes($file->description)); |
|---|
| | 170 | $filetitle = urlencode($title); |
|---|
| | 171 | $originalname = stripslashes($file->originalname); |
|---|
| | 172 | $filemenu = round(($file->size / 1048576),4) . "MB "; |
|---|
| | 173 | $icon = $CFG->wwwroot . "_icon/file/" . $file->ident; |
|---|
| | 174 | $filepath = $CFG->wwwroot . "$username/files/$folder->ident/$ident/" . urlencode($originalname); |
|---|
| | 175 | |
|---|
| | 176 | $mimetype = mimeinfo('type',$file->originalname); |
|---|
| | 177 | |
|---|
| | 178 | if ($mimetype == "audio/mpeg" || $mimetype == "audio/mp3") { |
|---|
| | 179 | $filemenu .= " <object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" |
|---|
| | 180 | codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" |
|---|
| | 181 | width=\"17\" height=\"17\" > |
|---|
| | 182 | <param name=\"allowScriptAccess\" value=\"sameDomain\" /> |
|---|
| | 183 | <param name=\"movie\" value=\"" . $CFG->wwwroot . "mod/file/mp3player/musicplayer.swf?song_url=$filepath&song_title=$filetitle\" /> |
|---|
| | 184 | <param name=\"quality\" value=\"high\" /> |
|---|
| | 185 | <embed src=\"" . $CFG->wwwroot . "mod/file/mp3player/musicplayer.swf?song_url=$filepath&song_title=$filetitle\" |
|---|
| | 186 | quality=\"high\" bgcolor=\"#E6E6E6\" name=\"xspf_player\" allowscriptaccess=\"sameDomain\" |
|---|
| | 187 | type=\"application/x-shockwave-flash\" |
|---|
| | 188 | pluginspage=\"http://www.macromedia.com/go/getflashplayer\" |
|---|
| | 189 | align=\"center\" height=\"17\" width=\"17\" /> |
|---|
| | 190 | </object>"; |
|---|
| | 191 | } |
|---|
| | 192 | |
|---|
| | 193 | |
|---|
| | 194 | $keywords = display_output_field(array("","keywords","file","file",$ident,$file->owner)); |
|---|
| | 195 | if ($keywords) { |
|---|
| | 196 | $keywords = __gettext("Keywords: ") . $keywords; |
|---|
| | 197 | } |
|---|
| | 198 | |
|---|
| | 199 | $return = <<< END |
|---|
| | 200 | <table> |
|---|
| | 201 | <tr> |
|---|
| | 202 | <td><img src="$icon" alt="$originalname" /></td> |
|---|
| | 203 | <td> |
|---|
| | 204 | <p><b>$title</b></p> |
|---|
| | 205 | <p>$description</p> |
|---|
| | 206 | <p>$originalname</p> |
|---|
| | 207 | </td> |
|---|
| | 208 | </tr> |
|---|
| | 209 | </table> |
|---|
| | 210 | END; |
|---|
| | 211 | |
|---|
| | 212 | } |
|---|
| | 213 | } |
|---|
| | 214 | |
|---|
| | 215 | return $return; |
|---|
| | 216 | |
|---|
| | 217 | /* |
|---|
| | 218 | // Display a preview - currently only file types are supported here |
|---|
| | 219 | // TODO: Some sort of clever |
|---|
| | 220 | if ($object_type=="file::file") |
|---|
| | 221 | { |
|---|
| | 222 | // Display file. Todo: Break this off into a library or call file lib |
|---|
| | 223 | if ($file = get_record_select('files', "ident=$object_id")) |
|---|
| | 224 | { |
|---|
| | 225 | if (run("users:access_level_check",$file->access) == true || $file->owner == $_SESSION['userid']) { |
|---|
| | 226 | |
|---|
| | 227 | $username = $owner_username; |
|---|
| | 228 | $ident = (int) $file->ident; |
|---|
| | 229 | $folder->ident = $file->folder; |
|---|
| | 230 | $title = get_access_description($file->access); |
|---|
| | 231 | $title .= stripslashes($file->title); |
|---|
| | 232 | $description = nl2br(stripslashes($file->description)); |
|---|
| | 233 | $filetitle = urlencode($title); |
|---|
| | 234 | $originalname = stripslashes($file->originalname); |
|---|
| | 235 | $filemenu = round(($file->size / 1048576),4) . "MB "; |
|---|
| | 236 | $icon = $CFG->wwwroot . "_icon/file/" . $file->ident; |
|---|
| | 237 | $filepath = $CFG->wwwroot . "$username/files/$folder->ident/$ident/" . urlencode($originalname); |
|---|
| | 238 | require_once($CFG->dirroot.'lib/filelib.php'); |
|---|
| | 239 | $mimetype = mimeinfo('type',$file->originalname); |
|---|
| | 240 | |
|---|
| | 241 | if ($mimetype == "audio/mpeg" || $mimetype == "audio/mp3") { |
|---|
| | 242 | $filemenu .= " <object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" |
|---|
| | 243 | codebase=\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0\" |
|---|
| | 244 | width=\"17\" height=\"17\" > |
|---|
| | 245 | <param name=\"allowScriptAccess\" value=\"sameDomain\" /> |
|---|
| | 246 | <param name=\"movie\" value=\"" . $CFG->wwwroot . "mod/file/mp3player/musicplayer.swf?song_url=$filepath&song_title=$filetitle\" /> |
|---|
| | 247 | <param name=\"quality\" value=\"high\" /> |
|---|
| | 248 | <embed src=\"" . $CFG->wwwroot . "mod/file/mp3player/musicplayer.swf?song_url=$filepath&song_title=$filetitle\" |
|---|
| | 249 | quality=\"high\" bgcolor=\"#E6E6E6\" name=\"xspf_player\" allowscriptaccess=\"sameDomain\" |
|---|
| | 250 | type=\"application/x-shockwave-flash\" |
|---|
| | 251 | pluginspage=\"http://www.macromedia.com/go/getflashplayer\" |
|---|
| | 252 | align=\"center\" height=\"17\" width=\"17\" /> |
|---|
| | 253 | </object>"; |
|---|
| | 254 | } |
|---|
| | 255 | |
|---|
| | 256 | |
|---|
| | 257 | $keywords = display_output_field(array("","keywords","file","file",$ident,$file->owner)); |
|---|
| | 258 | if ($keywords) { |
|---|
| | 259 | $keywords = __gettext("Keywords: ") . $keywords; |
|---|
| | 260 | } |
|---|
| | 261 | $item_details = templates_draw(array( |
|---|
| | 262 | 'context' => 'file', |
|---|
| | 263 | 'username' => $username, |
|---|
| | 264 | 'title' => $title, |
|---|
| | 265 | 'ident' => $ident, |
|---|
| | 266 | 'folder' => $folder->ident, |
|---|
| | 267 | 'description' => $description, |
|---|
| | 268 | 'originalname' => $originalname, |
|---|
| | 269 | 'url' => $filepath, |
|---|
| | 270 | 'menu' => $filemenu, |
|---|
| | 271 | 'icon' => $icon, |
|---|
| | 272 | 'keywords' => $keywords |
|---|
| | 273 | ) |
|---|
| | 274 | ); |
|---|
| | 275 | |
|---|
| | 276 | } |
|---|
| | 277 | } |
|---|
| | 278 | |
|---|
| | 279 | }*/ |
|---|
| | 280 | |
|---|