Changeset 1115

Show
Ignore:
Timestamp:
05/28/07 16:03:55 (2 years ago)
Author:
icewing
Message:

Marcus Povey <marcus@dushka.co.uk>

* File libary contains basic display object. TODO: Make this look nice.

Files:

Legend:

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

    r1114 r1115  
    11<?php 
     2 
     3require_once($CFG->dirroot.'lib/filelib.php'); 
    24 
    35function file_pagesetup() { 
     
    135137        listen_for_event("user","delete","file_user_delete"); 
    136138         
    137   // Addding the file's selector wizard 
     139  // Adding the file's selector wizard 
    138140  $options = array('options'=> 'width=600,height=300,left=20,top=20,scrollbars=yes,resizable=yes', 
    139141                   'name'=> 'mediapopup', 
     
    141143  add_content_tool_button("mediapopup",__gettext("Add File"), "image.png", "f", $options); 
    142144         
     145 
     146        // Register a display object function 
     147        display_set_display_function('file', 'file_displayobject'); 
     148} 
     149 
     150         
     151function 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&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> 
     210END; 
     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&amp;song_title=$filetitle\" /> 
     247                                        <param name=\"quality\" value=\"high\" /> 
     248                                        <embed src=\"" . $CFG->wwwroot . "mod/file/mp3player/musicplayer.swf?song_url=$filepath&amp;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 
    143281} 
    144282 
     
    274412                                                  ) 
    275413                                            ); 
     414                         
     415 
    276416                } 
    277417                 
     
    296436                    $icon = $CFG->wwwroot . "_icon/file/" . $file->ident; 
    297437                    $filepath = $CFG->wwwroot . "$username/files/$folder->ident/$ident/" . urlencode($originalname); 
    298                     require_once($CFG->dirroot.'lib/filelib.php'); 
     438                     
    299439                    $mimetype = mimeinfo('type',$file->originalname); 
    300440                    if ($mimetype == "audio/mpeg" || $mimetype == "audio/mp3") { 
     
    331471                                                  ) 
    332472                                            ); 
     473 
     474$body .= implode('',action('annotate',$ident,'file::file',NULL, 
     475             array('comment_form_type'=>'summary', 'comment_sort'=>'DESC', 'comment_form_text'=>__gettext('Click to add or view comments on this file.')))); 
    333476                } 
    334477                 
     
    353496         
    354497        global $page_owner, $CFG; 
    355 global $messages; 
     498 
    356499        $filemenu = ""; 
    357500        if (run("permissions:check", array("files:edit", $file->owner))  || run("permissions:check", array("files:edit", $file->files_owner))) { 
  • devel/mod/file/lib/files_view.php

    r1081 r1115  
    6363     
    6464    $run_result .= run("files:folder:edit",$folder); 
    65      
     65 
    6666} else { 
    6767     
     
    6969     
    7070} 
     71 
    7172     
    7273?> 
  • devel/mod/file/lib/folder_view.php

    r1114 r1115  
    1616     
    1717    $run_result .= file_folder_view($folder_object); 
     18 
     19 
    1820         
    1921?>