CMS  Version 3.9
ForumSearchResultsView Class Reference

Public Member Functions

 __construct ($messages, $searchText, $id="forum_search_results")
 
 writeScript ()
 
 drawView ()
 
 formatAttachment ($icon, $attachment)
 

Public Attributes

 $messages
 
 $searchText
 

Detailed Description

Definition at line 39 of file forum_search_results_view.inc.

Constructor & Destructor Documentation

◆ __construct()

ForumSearchResultsView::__construct (   $messages,
  $searchText,
  $id = "forum_search_results" 
)

Definition at line 44 of file forum_search_results_view.inc.

45  {
46  $this->messages = $messages;
47  $this->searchText = $searchText;
48  }

Member Function Documentation

◆ drawView()

ForumSearchResultsView::drawView ( )

Definition at line 54 of file forum_search_results_view.inc.

55  {
56  global $user; // User Credentials from session
57 
58  $first = true;
59  $alt = false;
60 
61  $forum_id = checkNumeric($_GET["forum_id"]);
62  $forum = new Forum($forum_id);
63 
64 ?>
65 <p><label>Search Results for</label> <?echo htmlSafe($this->searchText)?>
66 <a class='button' style='float: right' href='<?echo $forum->identifier?>'>&laquo; Back to Forum</a>
67 </p>
68 <?
69  if (count($this->messages) > 0)
70  {
71  foreach($this->messages as $message)
72  {
73  $author = $message->Author();
74 
75  $userProfile = ForumManager::formatUserProfile($author);
76  $class = $alt ? "message alt" : "message"
77  ?>
78  <a name="message<?echo $message->message_id?>"></a>
79  <div id="message<?echo $message->message_id?>" class="<?echo $class?>">
80  <div class="title">
81 
82  <a class="button" style='float: right' href='forum_topic?forum_id=<?echo $message->forum_id?>&topic_id=<? echo $message->topic_id ?>'> View this topic </a>
83 
84  <strong><?echo $message->title?></strong><br/>
85  <span class="small">Posted by <?echo $userProfile?> at <?echo $message->date_posted?></span>
86  </div>
87  <div class="message_content">
88  <?echo $message->message?>
89  </div>
90  <?
91  $attachments = $message->Attachments();
92  $userMgr = new UserManager();
93  $cl = $userMgr->getUserClass();
94  $u = new $cl;
95  $pk = $u->getPrimaryKey();
96 
97  if (count($attachments) > 0)
98  {
99  echo "<h4 style='margin-bottom: 4px'>Attachments</h4>";
100 
101  foreach($attachments as $attachment)
102  {
103  $icon = DocumentHandler::getDocIcon($attachment->filename);
104 
105  echo $this->formatAttachment($icon, $attachment);
106 
107  if ($author && $user && ($author->get($pk) == $user->get($pk)) || checkRole("admin,data"))
108  {
109  ?>
110  &nbsp;&nbsp;<a style="font-size: 10px" href="/action/forum/attachment_delete?forum_id=<?echo $this->topic->forum_id?>&message_id=<?echo $message->message_id?>&attachment_id=<?echo $attachment->attachment_id?>" onclick="return confirm('Are you sure you want to delete <?echo $attachment->filename?>?');">Delete this attachment</a>
111  <?
112  }
113  ?>
114  <br/>
115  <?
116  }
117  }
118 
119  $controls = array();
120  if ($user && $author->get($pk) == $user->get($pk) || checkRole("admin,data,moderator"))
121  {
122  $controls[] = "<a href=\"forum_message_form?forum_id={$this->topic->forum_id}&topic_id={$this->topic->topic_id}&message_id={$message->message_id}\">Edit</a>";
123  }
124 
125  if ($user && $author->get($pk) == $user->get($pk) || checkRole("admin,data,moderator"))
126  {
127  $controls[] = "<a href=\"/action/forum/message_delete?forum_id={$this->topic->forum_id}&topic_id={$this->topic->topic_id}&message_id={$message->message_id}\" onclick=\"return confirm('Are you sure you want to delete this message?');\">Delete</a>";
128  }
129 
130  if ($user)
131  {
132  $controls[] = "<a href=\"forum_message_form?forum_id={$this->topic->forum_id}&topic_id={$this->topic->topic_id}&parent_id={$message->message_id}\">Reply</a>";
133  }
134 
135  ?>
136  <div class="message_controls"><? echo implode("&nbsp;|&nbsp;", $controls);?></div>
137  </div>
138  <?
139  $first = false;
140  $alt = !$alt;
141  }
142  }
143  else
144  {
145  ?>
146  <p><em>No messages have been posted for this topic.</em></p>
147  <?
148  }
149  }
& nbsp
Definition: index.inc:49
$forum_id
Definition: forum_form.inc:39
$helpTree style
Definition: tree.inc:46
if(! $attachment_id) $attachment
Definition: delete.inc:42
$icon
Definition: upload.inc:92
Definition: forum.inc:42
static formatUserProfile($u)
formatAttachment($icon, $attachment)
Provides the interface to the user model for the application.
global $user
$forumRequest to
$message
Definition: mail_to.inc:49

◆ formatAttachment()

ForumSearchResultsView::formatAttachment (   $icon,
  $attachment 
)

Definition at line 151 of file forum_search_results_view.inc.

152  {
153  global $config;
154  $dir = $config["uploaddir"];
155 
156  $link = "<img src=\"{$icon}\" alt=\"Icon\" style=\"display:inline-block;vertical-align:middle\"/>&nbsp;";
157  $link .= "<a href='/action/attachment/download?attachment_id={$attachment->attachment_id}'>{$attachment->filename}
158  </a>&nbsp;({$attachment->file_size})\n";
159 
160  return $link;
161  }
$dir
Definition: delete.inc:44
global $config
Definition: import.inc:4

◆ writeScript()

ForumSearchResultsView::writeScript ( )

Definition at line 50 of file forum_search_results_view.inc.

51  {
52  }

Member Data Documentation

◆ $messages

ForumSearchResultsView::$messages

Definition at line 41 of file forum_search_results_view.inc.

◆ $searchText

ForumSearchResultsView::$searchText

Definition at line 42 of file forum_search_results_view.inc.


The documentation for this class was generated from the following file: