Changeset 1120

Show
Ignore:
Timestamp:
05/29/07 09:08:53 (2 years ago)
Author:
icewing
Message:

Marcus Povey <marcus@dushka.co.uk>
* Minor tweaks paving the way for consolidating file rendering into the generic object view api.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • devel/mod/file/lib.php

    r1115 r1120  
    156156        $return = ""; 
    157157 
    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&amp;song_title=$filetitle\" /> 
    184                                 <param name=\"quality\" value=\"high\" /> 
    185                                 <embed src=\"" . $CFG->wwwroot . "mod/file/mp3player/musicplayer.swf?song_url=$filepath&amp;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  
    220158        if ($object_type=="file::file") 
    221159        { 
    222                 // Display file. Todo: Break this off into a library or call file lib 
    223160                if ($file = get_record_select('files', "ident=$object_id")) 
    224161                { 
    225                         if (run("users:access_level_check",$file->access) == true || $file->owner == $_SESSION['userid']) { 
    226  
     162                        if (run("users:access_level_check",$file->access) == true || $file->owner == $_SESSION['userid'])  
     163                        { 
     164         
    227165                                $username = $owner_username; 
    228166                                $ident = (int) $file->ident; 
     
    236174                                $icon = $CFG->wwwroot . "_icon/file/" . $file->ident; 
    237175                                $filepath = $CFG->wwwroot . "$username/files/$folder->ident/$ident/" . urlencode($originalname); 
    238                                 require_once($CFG->dirroot.'lib/filelib.php'); 
     176                                 
    239177                                $mimetype = mimeinfo('type',$file->originalname); 
    240  
     178         
    241179                                if ($mimetype == "audio/mpeg" || $mimetype == "audio/mp3") { 
    242180                                        $filemenu .= " <object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" 
     
    253191                                        </object>"; 
    254192                                } 
    255  
    256  
     193         
     194         
    257195                                $keywords = display_output_field(array("","keywords","file","file",$ident,$file->owner)); 
    258196                                if ($keywords) { 
    259197                                        $keywords = __gettext("Keywords: ") . $keywords; 
    260198                                } 
    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  
     199         
     200                                $return = <<< END 
     201                                        <table> 
     202                                                <tr> 
     203                                                        <td><img src="$icon" alt="$originalname" /></td> 
     204                                                        <td> 
     205                                                                <p><b>$title</b></p> 
     206                                                                <p>$description</p> 
     207                                                                <p>$originalname</p> 
     208                                                        </td> 
     209                                                </tr> 
     210                                        </table> 
     211        END; 
     212         
    276213                        } 
    277214                } 
    278  
    279         }*/ 
     215        } 
     216         
     217         
     218        return $return; 
    280219 
    281220}