Beispiel #1
0
 /**
  * Adds 'Discussions' tab to profiles and adds CSS & JS files to their head.
  * 
  * @since 2.0.0
  * @package Vanilla
  * 
  * @param object $Sender ProfileController.
  */
 public function ProfileController_AddProfileTabs_Handler($Sender)
 {
     if (is_object($Sender->User) && $Sender->User->UserID > 0) {
         $UserID = $Sender->User->UserID;
         // Add the discussion tab
         $DiscussionsLabel = Sprite('SpDiscussions') . ' ' . T('Discussions');
         $CommentsLabel = Sprite('SpComments') . ' ' . T('Comments');
         if (C('Vanilla.Profile.ShowCounts', TRUE)) {
             $DiscussionsLabel .= '<span class="Aside">' . CountString(GetValueR('User.CountDiscussions', $Sender, NULL), "/profile/count/discussions?userid={$UserID}") . '</span>';
             $CommentsLabel .= '<span class="Aside">' . CountString(GetValueR('User.CountComments', $Sender, NULL), "/profile/count/comments?userid={$UserID}") . '</span>';
         }
         $Sender->AddProfileTab(T('Discussions'), 'profile/discussions/' . $Sender->User->UserID . '/' . rawurlencode($Sender->User->Name), 'Discussions', $DiscussionsLabel);
         $Sender->AddProfileTab(T('Comments'), 'profile/comments/' . $Sender->User->UserID . '/' . rawurlencode($Sender->User->Name), 'Comments', $CommentsLabel);
         // Add the discussion tab's CSS and Javascript.
         $Sender->AddJsFile('jquery.gardenmorepager.js');
         $Sender->AddJsFile('discussions.js');
     }
 }
Beispiel #2
0
 /**
  * Adds 'Discussions' tab to profiles and adds CSS & JS files to their head.
  * 
  * @since 2.0.0
  * @package Vanilla
  * 
  * @param object $Sender ProfileController.
  */
 public function ProfileController_AddProfileTabs_Handler(&$Sender)
 {
     if (is_object($Sender->User) && $Sender->User->UserID > 0) {
         $UserID = $Sender->User->UserID;
         // Add the discussion tab
         $Sender->AddProfileTab('Discussions', 'profile/discussions/' . $Sender->User->UserID . '/' . rawurlencode($Sender->User->Name), 'Discussions', T('Discussions') . CountString(GetValueR('User.CountDiscussions', $Sender, NULL), "/profile/count/discussions?userid={$UserID}"));
         $Sender->AddProfileTab('Comments', 'profile/comments/' . $Sender->User->UserID . '/' . rawurlencode($Sender->User->Name), 'Comments', T('Comments') . CountString(GetValueR('User.CountComments', $Sender, NULL), "/profile/count/comments?userid={$UserID}"));
         // Add the discussion tab's CSS and Javascript.
         $Sender->AddJsFile('jquery.gardenmorepager.js');
         $Sender->AddJsFile('discussions.js');
     }
 }
    function writeFilterTabs($Sender)
    {
        $Session = Gdn::session();
        $Title = property_exists($Sender, 'Category') ? val('Name', $Sender->Category, '') : '';
        if ($Title == '') {
            $Title = t('All Discussions');
        }
        $Bookmarked = t('My Bookmarks');
        $MyDiscussions = t('My Discussions');
        $MyDrafts = t('My Drafts');
        $CountBookmarks = 0;
        $CountDiscussions = 0;
        $CountDrafts = 0;
        if ($Session->isValid()) {
            $CountBookmarks = $Session->User->CountBookmarks;
            $CountDiscussions = $Session->User->CountDiscussions;
            $CountDrafts = $Session->User->CountDrafts;
        }
        if (c('Vanilla.Discussions.ShowCounts', true)) {
            $Bookmarked .= CountString($CountBookmarks, url('/discussions/UserBookmarkCount'));
            $MyDiscussions .= CountString($CountDiscussions);
            $MyDrafts .= CountString($CountDrafts);
        }
        ?>
        <div class="Tabs DiscussionsTabs">
            <?php 
        if (!property_exists($Sender, 'CanEditDiscussions')) {
            $Sender->CanEditDiscussions = $Session->checkPermission('Vanilla.Discussions.Edit', TRUE, 'Category', 'any') && c('Vanilla.AdminCheckboxes.Use');
        }
        if ($Sender->CanEditDiscussions) {
            ?>
                <span class="Options"><span class="AdminCheck">
      <input type="checkbox" name="Toggle"/>
   </span></span>
            <?php 
        }
        ?>
            <ul>
                <?php 
        $Sender->fireEvent('BeforeDiscussionTabs');
        ?>
                <li<?php 
        echo strtolower($Sender->ControllerName) == 'discussionscontroller' && strtolower($Sender->RequestMethod) == 'index' ? ' class="Active"' : '';
        ?>
><?php 
        echo anchor(t('All Discussions'), 'discussions', 'TabLink');
        ?>
</li>
                <?php 
        $Sender->fireEvent('AfterAllDiscussionsTab');
        ?>

                <?php 
        if (c('Vanilla.Categories.ShowTabs')) {
            $CssClass = '';
            if (strtolower($Sender->ControllerName) == 'categoriescontroller' && strtolower($Sender->RequestMethod) == 'all') {
                $CssClass = 'Active';
            }
            echo " <li class=\"{$CssClass}\">" . anchor(t('Categories'), '/categories/all', 'TabLink') . '</li> ';
        }
        ?>
                <?php 
        if ($CountBookmarks > 0 || $Sender->RequestMethod == 'bookmarked') {
            ?>
                    <li<?php 
            echo $Sender->RequestMethod == 'bookmarked' ? ' class="Active"' : '';
            ?>
><?php 
            echo anchor($Bookmarked, '/discussions/bookmarked', 'MyBookmarks TabLink');
            ?>
</li>
                    <?php 
            $Sender->fireEvent('AfterBookmarksTab');
        }
        if (($CountDiscussions > 0 || $Sender->RequestMethod == 'mine') && c('Vanilla.Discussions.ShowMineTab', true)) {
            ?>
                    <li<?php 
            echo $Sender->RequestMethod == 'mine' ? ' class="Active"' : '';
            ?>
><?php 
            echo anchor($MyDiscussions, '/discussions/mine', 'MyDiscussions TabLink');
            ?>
</li>
                <?php 
        }
        if ($CountDrafts > 0 || $Sender->ControllerName == 'draftscontroller') {
            ?>
                    <li<?php 
            echo $Sender->ControllerName == 'draftscontroller' ? ' class="Active"' : '';
            ?>
><?php 
            echo anchor($MyDrafts, '/drafts', 'MyDrafts TabLink');
            ?>
</li>
                <?php 
        }
        $Sender->fireEvent('AfterDiscussionTabs');
        ?>
            </ul>
        </div>
    <?php 
    }
Beispiel #4
0
 function FilterCountString($Count, $Url = '')
 {
     $Count = CountString($Count, $Url);
     return $Count != '' ? '<span class="Aside">' . $Count . '</span>' : '';
 }