root/devel/mod/file/lib/function_search_ecl.php

Revision 1539, 3.9 kB (checked in by renato, 1 year ago)

Setting prop svn:eol-style in LOTS of files.

  • Property svn:eol-style set to native
Line 
1 <?php
2 global $CFG;
3 global $search_exclusions;
4
5 if (isset($parameter) && $parameter[0] == "file") {
6     
7     $search_exclusions[] = "folder";
8     $search_exclusions[] = "file";
9     
10     $sitename = sitename;
11     
12     $parameter[1] = trim($parameter[1]);
13     
14     if ($file_refs = get_records_sql('SELECT DISTINCT t.owner,1 FROM '.$CFG->prefix.'tags t
15                                      LEFT JOIN '.$CFG->prefix."files f ON f.ident = t.refs
16                                      WHERE (t.tagtype = ? OR t.tagtype = ?)
17                                      AND t.tag = ? AND t.access = ?
18                                      ORDER BY f.time_uploaded DESC LIMIT 50",
19                                      array('file','folder',$parameter[1],'PUBLIC'))) {
20         foreach($file_refs as $post) {
21             $page_owner = $post->owner;
22                 
23             $run_result .= <<< END
24 <rss version='2.0'   xmlns:dc='http://purl.org/dc/elements/1.1/'>
25 END;
26             if ($info = get_record('users','ident',$page_owner)) {
27                 $name = htmlspecialchars(stripslashes(user_name($info->ident)), ENT_COMPAT, 'utf-8');
28                 $username = htmlspecialchars($info->username, ENT_COMPAT, 'utf-8');
29                 $mainurl = url . $username . "/files/";
30                 $run_result .= <<< END
31     <channel xml:base='$mainurl'>
32         <title>$name : Files</title>
33         <description>Files for $name, hosted on $sitename.</description>
34         <language>en-gb</language>
35         <link>$mainurl</link>
36 END;
37                 $tag = trim(optional_param('tag'));
38                 if (empty($tag)) {
39                     $files = get_records_select('files',"files_owner = $page_owner AND access = 'PUBLIC' ORDER BY time_uploaded DESC LIMIT 10");
40                 } else {
41                     $files = get_records_sql('SELECT f.* from '.$CFG->prefix.'tags t
42                                               LEFT JOIN '.$CFG->prefix.'files f ON f.ident = t.ref
43                                               WHERE t.owner = ? AND f.access = ?
44                                               AND t.tagtype = ? AND t.tag = ?
45                                               ORDER BY f.time_uploaded DESC LIMIT 10',
46                                              array($page_owner,'PUBLIC','file',$tag));
47                 }
48                 if (!empty($files)) {
49                     foreach($files as $file) {
50                         $title = htmlspecialchars(stripslashes($file->title), ENT_COMPAT, 'utf-8');
51                         $link = url . $username . "/files/" . $file->folder . "/" . $file->ident . "/" . htmlspecialchars(urlencode(stripslashes($file->originalname)), ENT_COMPAT, 'utf-8');
52                         $description = htmlspecialchars(stripslashes($file->description), ENT_COMPAT, 'utf-8');
53                         $pubdate = gmdate("D, d M Y H:i:s T", $file->time_uploaded);
54                         $length = (int) $file->size;
55                         require_once($CFG->dirroot.'lib/filelib.php');
56                         $mimetype = mimeinfo('type',$file->location);
57                         $keywordtags = "";
58                         if ($keywords = get_records_select('tags',"tagtype = ? AND ref = ?",array('file',$file->ident))) {
59                             foreach($keywords as $keyword) {
60                                 $keywordtags .= "\n\t\t<dc:subject>".htmlspecialchars(stripslashes($keyword->tag), ENT_COMPAT, 'utf-8') . "</dc:subject>";
61                             }
62                         }
63                         $run_result .= <<< END
64                             
65         <item>
66             <title>$title</title>
67             <link>$link</link>
68             <enclosure url="$link" length="$length" type="$mimetype" />
69             <pubDate>$pubdate</pubDate>$keywordtags
70             <description>$description</description>
71         </item>
72 END;
73                     }
74                 }
75                 $run_result .= <<< END
76                         
77     </channel>
78 </rss>
79 END;
80             }
81         }
82     }
83 }
84
85 ?>
Note: See TracBrowser for help on using the browser.