slitaz-forge diff forum/vanilla/themes/slitaz-2/views/discussions/helper_functions.php @ rev 2
move vanilla-config & themes in vanilla directory
author | Eric Joseph-Alexandre <erjo@slitaz.org> |
---|---|
date | Wed Dec 22 10:41:18 2010 +0100 (2010-12-22) |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/forum/vanilla/themes/slitaz-2/views/discussions/helper_functions.php Wed Dec 22 10:41:18 2010 +0100 1.3 @@ -0,0 +1,186 @@ 1.4 +<?php 1.5 +if (!defined('APPLICATION')) exit(); 1.6 + 1.7 +function WriteDiscussion($Discussion, &$Sender, &$Session, $Alt) { 1.8 + $CssClass = 'Item'; 1.9 + $CssClass .= $Discussion->Bookmarked == '1' ? ' Bookmarked' : ''; 1.10 + $CssClass .= $Discussion->Closed == '1' ? ' Closed' : ''; 1.11 + $CssClass .= $Alt.' '; 1.12 + $CssClass .= $Discussion->Announce == '1' ? ' Announcement' : ''; 1.13 + $CssClass .= $Discussion->Dismissed == '1' ? ' Dismissed' : ''; 1.14 + $CssClass .= $Discussion->InsertUserID == $Session->UserID ? ' Mine' : ''; 1.15 + $CssClass .= ($Discussion->CountUnreadComments > 0 && $Session->IsValid()) ? ' New' : ''; 1.16 + $Sender->EventArguments['Discussion'] = &$Discussion; 1.17 + $First = UserBuilder($Discussion, 'First'); 1.18 + $Last = UserBuilder($Discussion, 'Last'); 1.19 + 1.20 + $Sender->FireEvent('BeforeDiscussionName'); 1.21 + 1.22 + $DiscussionName = Gdn_Format::Text($Discussion->Name); 1.23 + if ($DiscussionName == '') 1.24 + $DiscussionName = T('Blank Discussion Topic'); 1.25 + 1.26 + static $FirstDiscussion = TRUE; 1.27 + if (!$FirstDiscussion) 1.28 + $Sender->FireEvent('BetweenDiscussion'); 1.29 + else 1.30 + $FirstDiscussion = FALSE; 1.31 +?> 1.32 +<li class="<?php echo $CssClass; ?> "> 1.33 + <?php 1.34 + $Sender->FireEvent('BeforeDiscussionContent'); 1.35 + WriteOptions($Discussion, $Sender, $Session); 1.36 + ?> 1.37 + <div class="ItemContent Discussion"> 1.38 + <?php echo Anchor($DiscussionName, '/discussion/'.$Discussion->DiscussionID.'/'.Gdn_Format::Url($Discussion->Name).($Discussion->CountCommentWatch > 0 && C('Vanilla.Comments.AutoOffset') ? '/#Item_'.$Discussion->CountCommentWatch : ''), 'Title'); ?> 1.39 + <?php $Sender->FireEvent('AfterDiscussionTitle'); ?> 1.40 + <div class="Meta"> 1.41 + <?php if ($Discussion->Announce == '1') { ?> 1.42 + <span class="Announcement"><?php echo T('Announcement'); ?></span> 1.43 + <?php } ?> 1.44 + <?php if ($Discussion->Closed == '1') { ?> 1.45 + <span class="Closed"><?php echo T('Closed'); ?></span> 1.46 + <?php } ?> 1.47 + <span class="CommentCount"><?php printf(Plural($Discussion->CountComments, '%s comment', '%s comments'), $Discussion->CountComments); ?></span> 1.48 + <?php 1.49 + if ($Session->IsValid() && $Discussion->CountUnreadComments > 0) 1.50 + echo '<strong>'.Plural($Discussion->CountUnreadComments, '%s New', '%s New Plural').'</strong>'; 1.51 + 1.52 + if ($Discussion->LastCommentID != '') { 1.53 + echo '<span class="LastCommentBy">'.sprintf(T('Most recent by %1$s'), UserAnchor($Last)).'</span>'; 1.54 + echo '<span class="LastCommentDate">'.Gdn_Format::Date($Discussion->LastDate).'</span>'; 1.55 + } else { 1.56 + echo '<span class="LastCommentBy">'.sprintf(T('Started by %1$s'), UserAnchor($First)).'</span>'; 1.57 + echo '<span class="LastCommentDate">'.Gdn_Format::Date($Discussion->FirstDate).'</span>'; 1.58 + } 1.59 + 1.60 + if (C('Vanilla.Categories.Use')) 1.61 + echo Wrap(Anchor($Discussion->Category, '/categories/'.$Discussion->CategoryUrlCode, 'Category')); 1.62 + 1.63 + $Sender->FireEvent('DiscussionMeta'); 1.64 + ?> 1.65 + </div> 1.66 + </div> 1.67 +</li> 1.68 +<?php 1.69 +} 1.70 + 1.71 +function WriteFilterTabs(&$Sender) { 1.72 + $Session = Gdn::Session(); 1.73 + $Title = property_exists($Sender, 'Category') && is_object($Sender->Category) ? $Sender->Category->Name : T('All Discussions'); 1.74 + $Bookmarked = T('My Bookmarks'); 1.75 + $MyDiscussions = T('My Discussions'); 1.76 + $MyDrafts = T('My Drafts'); 1.77 + $CountBookmarks = 0; 1.78 + $CountDiscussions = 0; 1.79 + $CountDrafts = 0; 1.80 + if ($Session->IsValid()) { 1.81 + $CountBookmarks = $Session->User->CountBookmarks; 1.82 + $CountDiscussions = $Session->User->CountDiscussions; 1.83 + $CountDrafts = $Session->User->CountDrafts; 1.84 + } 1.85 + if (is_numeric($CountBookmarks) && $CountBookmarks > 0) 1.86 + $Bookmarked .= '<span>'.$CountBookmarks.'</span>'; 1.87 + 1.88 + if (is_numeric($CountDiscussions) && $CountDiscussions > 0) 1.89 + $MyDiscussions .= '<span>'.$CountDiscussions.'</span>'; 1.90 + 1.91 + if (is_numeric($CountDrafts) && $CountDrafts > 0) 1.92 + $MyDrafts .= '<span>'.$CountDrafts.'</span>'; 1.93 + 1.94 + ?> 1.95 +<div class="Tabs DiscussionsTabs"> 1.96 + <ul> 1.97 + <?php $Sender->FireEvent('BeforeDiscussionTabs'); ?> 1.98 + <li<?php echo strtolower($Sender->ControllerName) == 'discussionscontroller' && strtolower($Sender->RequestMethod) == 'index' ? ' class="Active"' : ''; ?>><?php echo Anchor(T('All Discussions'), 'discussions'); ?></li> 1.99 + <?php $Sender->FireEvent('AfterAllDiscussionsTab'); ?> 1.100 + <?php if ($CountBookmarks > 0 || $Sender->RequestMethod == 'bookmarked') { ?> 1.101 + <li<?php echo $Sender->RequestMethod == 'bookmarked' ? ' class="Active"' : ''; ?>><?php echo Anchor($Bookmarked, '/discussions/bookmarked', 'MyBookmarks'); ?></li> 1.102 + <?php 1.103 + $Sender->FireEvent('AfterBookmarksTab'); 1.104 + } 1.105 + if ($CountDiscussions > 0 || $Sender->RequestMethod == 'mine') { 1.106 + ?> 1.107 + <li<?php echo $Sender->RequestMethod == 'mine' ? ' class="Active"' : ''; ?>><?php echo Anchor($MyDiscussions, '/discussions/mine', 'MyDiscussions'); ?></li> 1.108 + <?php 1.109 + } 1.110 + if ($CountDrafts > 0 || $Sender->ControllerName == 'draftscontroller') { 1.111 + ?> 1.112 + <li<?php echo $Sender->ControllerName == 'draftscontroller' ? ' class="Active"' : ''; ?>><?php echo Anchor($MyDrafts, '/drafts', 'MyDrafts'); ?></li> 1.113 + <?php 1.114 + } 1.115 + $Sender->FireEvent('AfterDiscussionTabs'); 1.116 + ?> 1.117 + </ul> 1.118 + <?php 1.119 + if (property_exists($Sender, 'Category') && is_object($Sender->Category)) { 1.120 + ?> 1.121 + <div class="SubTab">↳ <?php echo $Sender->Category->Name; ?></div> 1.122 + <?php 1.123 + } 1.124 + ?> 1.125 +</div> 1.126 + <?php 1.127 +} 1.128 + 1.129 +/** 1.130 + * Render options that the user has for this discussion. 1.131 + */ 1.132 +function WriteOptions($Discussion, &$Sender, &$Session) { 1.133 + if ($Session->IsValid() && $Sender->ShowOptions) { 1.134 + echo '<div class="Options">'; 1.135 + // Bookmark link 1.136 + $Title = T($Discussion->Bookmarked == '1' ? 'Unbookmark' : 'Bookmark'); 1.137 + echo Anchor( 1.138 + '<span class="Star">' 1.139 + .Img('applications/dashboard/design/images/pixel.png', array('alt' => $Title)) 1.140 + .'</span>', 1.141 + '/vanilla/discussion/bookmark/'.$Discussion->DiscussionID.'/'.$Session->TransientKey().'?Target='.urlencode($Sender->SelfUrl), 1.142 + 'Bookmark' . ($Discussion->Bookmarked == '1' ? ' Bookmarked' : ''), 1.143 + array('title' => $Title) 1.144 + ); 1.145 + 1.146 + $Sender->Options = ''; 1.147 + 1.148 + // Dismiss an announcement 1.149 + if (C('Vanilla.Discussions.Dismiss', 1) && $Discussion->Announce == '1' && $Discussion->Dismissed != '1') 1.150 + $Sender->Options .= '<li>'.Anchor(T('Dismiss'), 'vanilla/discussion/dismissannouncement/'.$Discussion->DiscussionID.'/'.$Session->TransientKey(), 'DismissAnnouncement') . '</li>'; 1.151 + 1.152 + // Edit discussion 1.153 + if ($Discussion->FirstUserID == $Session->UserID || $Session->CheckPermission('Vanilla.Discussions.Edit', TRUE, 'Category', $Discussion->CategoryID)) 1.154 + $Sender->Options .= '<li>'.Anchor(T('Edit'), 'vanilla/post/editdiscussion/'.$Discussion->DiscussionID, 'EditDiscussion') . '</li>'; 1.155 + 1.156 + // Announce discussion 1.157 + if ($Session->CheckPermission('Vanilla.Discussions.Announce', TRUE, 'Category', $Discussion->CategoryID)) 1.158 + $Sender->Options .= '<li>'.Anchor(T($Discussion->Announce == '1' ? 'Unannounce' : 'Announce'), 'vanilla/discussion/announce/'.$Discussion->DiscussionID.'/'.$Session->TransientKey(), 'AnnounceDiscussion') . '</li>'; 1.159 + 1.160 + // Sink discussion 1.161 + if ($Session->CheckPermission('Vanilla.Discussions.Sink', TRUE, 'Category', $Discussion->CategoryID)) 1.162 + $Sender->Options .= '<li>'.Anchor(T($Discussion->Sink == '1' ? 'Unsink' : 'Sink'), 'vanilla/discussion/sink/'.$Discussion->DiscussionID.'/'.$Session->TransientKey().'?Target='.urlencode($Sender->SelfUrl), 'SinkDiscussion') . '</li>'; 1.163 + 1.164 + // Close discussion 1.165 + if ($Session->CheckPermission('Vanilla.Discussions.Close', TRUE, 'Category', $Discussion->CategoryID)) 1.166 + $Sender->Options .= '<li>'.Anchor(T($Discussion->Closed == '1' ? 'Reopen' : 'Close'), 'vanilla/discussion/close/'.$Discussion->DiscussionID.'/'.$Session->TransientKey().'?Target='.urlencode($Sender->SelfUrl), 'CloseDiscussion') . '</li>'; 1.167 + 1.168 + // Delete discussion 1.169 + if ($Session->CheckPermission('Vanilla.Discussions.Delete', TRUE, 'Category', $Discussion->CategoryID)) 1.170 + $Sender->Options .= '<li>'.Anchor(T('Delete'), 'vanilla/discussion/delete/'.$Discussion->DiscussionID.'/'.$Session->TransientKey().'?Target='.urlencode($Sender->SelfUrl), 'DeleteDiscussion') . '</li>'; 1.171 + 1.172 + // Allow plugins to add options 1.173 + $Sender->FireEvent('DiscussionOptions'); 1.174 + 1.175 + if ($Sender->Options != '') { 1.176 + ?> 1.177 + <ul class="Options"> 1.178 + <li> 1.179 + <strong><?php echo T('Options'); ?></strong> 1.180 + <ul> 1.181 + <?php echo $Sender->Options; ?> 1.182 + </ul> 1.183 + </li> 1.184 + </ul> 1.185 + <?php 1.186 + } 1.187 + echo '</div>'; 1.188 + } 1.189 +} 1.190 \ No newline at end of file