Пример #1
0
 /**
  * @param SiteLinkMenuModule $sender
  */
 public function siteNavModule_profile_handler($sender)
 {
     $user = Gdn::controller()->data('Profile');
     if (!$user) {
         return;
     }
     $user_id = val('UserID', $user);
     $sender->addGroup('posts', array('text' => t('Posts')));
     $sender->addLink('posts.discussions', array('text' => t('Discussions'), 'url' => userUrl($user, '', 'discussions'), 'icon' => icon('discussion'), 'badge' => countString(val('CountDiscussions', $user), "/profile/count/discussions?userid={$user_id}")));
     $sender->addLink('posts.comments', array('text' => t('Comments'), 'url' => userUrl($user, '', 'comments'), 'icon' => icon('comment'), 'badge' => countString(val('CountComments', $user), "/profile/count/comments?userid={$user_id}")));
 }
Пример #2
0
    /**
     *
     *
     * @param $Sender
     */
    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 
    }
Пример #3
0
 /**
  *
  *
  * @param SiteNavModule $sender
  */
 public function siteNavModule_default_handler($sender)
 {
     if (Gdn::session()->isValid()) {
         $sender->addLink('main.profile', array('text' => t('Profile'), 'url' => '/profile', 'icon' => icon('user'), 'sort' => 10));
     }
     if (Gdn::session()->checkPermission('Garden.Activity.View')) {
         $sender->addLink('main.activity', array('text' => t('Activity'), 'url' => '/activity', 'icon' => icon('time'), 'sort' => 10));
     }
     // Add the moderation items.
     $sender->addGroup('moderation', array('text' => t('Moderation'), 'sort' => 90));
     if (Gdn::session()->checkPermission('Garden.Users.Approve')) {
         $RoleModel = new RoleModel();
         $applicant_count = (int) $RoleModel->getApplicantCount();
         if ($applicant_count > 0 || true) {
             $sender->addLink('moderation.applicants', array('text' => t('Applicants'), 'url' => '/user/applicants', 'icon' => icon('user'), 'badge' => countString($applicant_count)));
         }
     }
     if (Gdn::session()->checkPermission('Garden.Modertion.Manage')) {
         $sender->addLink('moderation.spam', array('text' => 'Spam Queue', 'url' => '/log/spam', 'icon' => icon('spam')));
         //         $sender->addLink('moderation.queue', array('text' => 'Moderaton Queue', 'url' => '/log/moderation', 'icon' => icon('report')));
     }
     if (Gdn::session()->checkPermission('Garden.Settings.Manage')) {
         $sender->addLink('etc.dashboard', array('text' => t('Dashboard'), 'url' => '/settings', 'icon' => icon('dashboard')));
     }
 }
Пример #4
0
    $countArray['num_string'] = 0;
    $countArray['num_bool'] = 0;
    foreach ($explodeString as $item) {
        if ($item == "false" || $item == "true") {
            $countArray['num_bool'] += 1;
        } elseif (intval($item)) {
            //using intval rather than is_numeric because is_numeric returned 7 rather than 8
            $countArray['num_numeric'] += 1;
        } elseif (is_string($item)) {
            $countArray['num_string'] += 1;
        }
    }
    echo "</br>";
    echo 'Number count: ' . $countArray['num_numeric'];
    echo "</br>";
    echo 'String count: ' . $countArray['num_string'];
    echo "</br>";
    echo 'Bool count: ' . $countArray['num_bool'];
    echo "</br>";
    /** @var array $countArray Result array that contains the counts. You will populate this array with appropriate numbers */
    $countArray = array($countArray['num_numeric'], $countArray['num_string'], $countArray['num_bool']);
    echo "<pre>";
    var_dump($countArray);
    //    /** @var array $wordArray Array of every word in the input string */
    //    $wordArray = explode(" ", $inputString);
    echo "</br>";
}
echo countString($inputString);
?>