root/devel-backup/units/weblogs/function_search.php

Revision 244, 4.5 kB (checked in by ben, 3 years ago)

Fix icons in search

  • Property svn:eol-style set to native
Line 
1 <?php
2
3     global $search_exclusions;
4     
5     $weblogPosted = gettext("Weblog posts by"); // gettext variable
6     $inCategory = gettext("in category"); // gettext variable
7     $rssForBlog = gettext("RSS feed for weblog posts by"); // gettext variable
8     $otherUsers = gettext("Other users with weblog posts in category"); // gettext variable
9     $otherUsers2 = gettext("Users with weblog posts in category"); // gettext variable
10
11
12
13
14
15     if (isset($parameter) && $parameter[0] == "weblog" || $parameter[0] == "weblogall") {
16         
17         if ($parameter[0] == "weblog") {
18             $search_exclusions[] = "weblogall";
19             $owner = (int) $_REQUEST['owner'];
20             $searchline = "tagtype = 'weblog' and owner = $owner and tag = '".addslashes($parameter[1])."'";
21             $searchline = "(" . run("users:access_level_sql_where",$_SESSION['userid']) . ") and " . $searchline;
22             $searchline = str_replace("owner","tags.owner",$searchline);
23             $refs = db_query("select ref from tags where $searchline");
24             $searchline = "";
25             if (sizeof($refs) > 0) {
26                 foreach($refs as $ref) {
27                     if ($searchline != "") {
28                         $searchline .= ",";
29                     }
30                     $searchline .= $ref->ref;
31                 }
32                 $searchline = " weblog_posts.ident in (" . $searchline . ")";
33                 
34                 $posts = db_query("select users.name, users.username, weblog_posts.title, weblog_posts.ident, weblog_posts.weblog, weblog_posts.owner, weblog_posts.posted from weblog_posts join users on users.ident = weblog_posts.owner where ($searchline) order by posted desc");
35                 $run_result .= "<h2>$weblogPosted " . stripslashes($posts[0]->name) . " $inCategory '".$parameter[1]."'</h2>\n<ul>";
36                 foreach($posts as $post) {
37                     $run_result .= "<li>";
38                     $weblogusername = run("users:id_to_name",$post->weblog);
39                     $run_result .= "<a href=\"".url . $weblogusername . "/weblog/" . $post->ident . ".html\">" . gmdate("F d, Y",$post->posted) . " - " . stripslashes($post->title) . "</a>\n";
40                     if ($post->owner != $post->weblog) {
41                         $run_result .= " @ " . "<a href=\"" . url . $weblogusername . "/weblog/\">" . $weblogusername . "</a>\n";
42                     }
43                     $run_result .= "</li>";
44                 }
45                 $run_result .= "</ul>";
46                 $run_result .= "<p><small>[ <a href=\"".url.$post->username . "/weblog/rss/" . $parameter[1] . "\">$rssForBlog " . stripslashes($posts[0]->name) . " $inCategory '".$parameter[1]."'</a> ]</small></p>\n";
47             }
48         }
49         $searchline = "tagtype = 'weblog' and tag = '".addslashes($parameter[1])."'";
50         $searchline = "(" . run("users:access_level_sql_where",$_SESSION['userid']) . ") and " . $searchline;
51         $searchline = str_replace("owner","tags.owner",$searchline);
52         $sql = "select distinct users.* from tags join users on users.ident = tags.owner where ($searchline)";
53         if ($parameter[0] == "weblog") {
54             $sql .= " and users.ident != " . $owner;
55         }
56         $users = db_query($sql);
57         
58         if (sizeof($users) > 0) {
59             if ($parameter[0] == "weblog") {
60                 $run_result .= "<h2>$otherUsers '".$parameter[1]."'</h2>\n";
61             } else {
62                 $run_result .= "<h2>$otherUsers2 '".$parameter[1]."'</h2>\n";
63             }
64             $body = "<table><tr>";
65             $i = 1;
66             $icon = "default.png";
67             $defaulticonparams = @getimagesize(path . "_icons/data/default.png");
68                 
69             foreach($users as $key => $info) {
70                 
71                 list($width, $height, $type, $attr) = $defaulticonparams;
72                 // $info = $info[0];
73                 // if ($info->icon != -1) {
74                     $icon = db_query("select filename from icons where ident = " . $info->icon);
75                     if (sizeof($icon) == 1) {
76                         $icon = $icon[0]->filename;
77                         if (!(list($width, $height, $type, $attr) = @getimagesize(path . "_icons/data/" . $icon))) {
78                             $icon = "default.png";
79                             list($width, $height, $type, $attr) = $defaulticonparams;
80                         }
81                     } else {
82                         $icon = "default.png";
83                     }
84                 // }
85                 
86                 if (sizeof($users) > 4) {
87                     $width = round($width / 2);
88                     $height = round($height / 2);
89                 }
90                 
91                 $friends_userid = $info->ident;
92                 $friends_name = htmlentities(stripslashes($info->name));
93                 $friends_menu = run("users:infobox:menu",array($info->ident));
94                 $link_keyword = urlencode($parameter[1]);
95                 $width = round($width / 2);
96                 $height = round($height / 2);
97                 $url = url;
98                 $body .= <<< END
99         <td align="center">
100             <p>
101             <a href="{$url}search/index.php?weblog={$link_keyword}&amp;owner={$friends_userid}">
102             <img src="{$url}_icons/data/{$icon}" width="{$width}" height="{$height}" alt="{$friends_name}" border="0" /></a><br />
103             <span class="userdetails">
104                 {$friends_name}
105                 {$friends_menu}
106             </span>
107             </p>
108         </td>
109 END;
110                 if ($i % 5 == 0) {
111                     $body .= "\n</tr><tr>\n";
112                 }
113                 $i++;
114             }
115             $body .= "</tr></table>";
116             $run_result .= $body;
117         }
118         
119     }
120
121 ?>
Note: See TracBrowser for help on using the browser.