Наследование: extends Module
Пример #1
0
 /**
  *
  *
  * @param string $Sender
  */
 public function __construct($Sender = '')
 {
     parent::__construct($Sender);
     $this->ClientID = '';
     $this->CssClass = 'MorePager Foot';
     $this->Offset = 0;
     $this->Limit = 30;
     $this->TotalRecords = 0;
     $this->Wrapper = '<div %1$s>%2$s</div>';
     $this->PagerEmpty = '';
     $this->MoreCode = 'More';
     $this->LessCode = 'Newer';
     $this->Url = '/controller/action/{Page}/';
     $this->_PropertiesDefined = false;
     $this->_Totalled = false;
     $this->_LastOffset = 0;
 }
Пример #2
0
<?php

if (!defined('APPLICATION')) {
    exit;
}
$Session = Gdn::Session();
include $this->FetchViewLocation('helper_functions', 'discussions', 'vanilla');
WriteFilterTabs($this);
if ($this->DiscussionData->NumRows() > 0 || isset($this->AnnounceData) && is_object($this->AnnounceData) && $this->AnnounceData->NumRows() > 0) {
    ?>
<ul class="DataList Discussions">
   <?php 
    include $this->FetchViewLocation('discussions');
    ?>
</ul>
<?php 
    $PagerOptions = array('RecordCount' => $this->Data('CountDiscussions'), 'CurrentRecords' => $this->Data('Discussions')->NumRows());
    if ($this->Data('_PagerUrl')) {
        $PagerOptions['Url'] = $this->Data('_PagerUrl');
    }
    echo PagerModule::Write($PagerOptions);
} else {
    ?>
   <div class="Empty"><?php 
    echo T('No discussions were found.');
    ?>
</div>
   <?php 
}
Пример #3
0
<?php

if (!defined('APPLICATION')) {
    exit;
}
?>
<div class="SearchForm">
<?php 
$Form = $this->Form;
$Form->InputPrefix = '';
echo $Form->Open(array('action' => Url('/search'), 'method' => 'get')), '<div class="SiteSearch">', $Form->TextBox('Search'), $Form->Button('Search', array('Name' => '')), '</div>', $Form->Errors(), $Form->Close();
?>
</div>
<?php 
if (!is_array($this->SearchResults) || count($this->SearchResults) == 0) {
    echo '<p class="NoResults">', sprintf(T('No results for %s.', 'No results for <b>%s</b>.'), htmlspecialchars($this->SearchTerm)), '</p>';
} else {
    $ViewLocation = $this->FetchViewLocation('results');
    include $ViewLocation;
    echo '<div class="PageControls Bottom">';
    PagerModule::Write();
    echo '</div>';
}
 /**
  * Default single discussion display.
  *
  * @since 2.0.0
  * @access public
  *
  * @param int $DiscussionID Unique discussion ID
  * @param string $DiscussionStub URL-safe title slug
  * @param int $Page The current page of comments
  */
 public function index($DiscussionID = '', $DiscussionStub = '', $Page = '')
 {
     // Setup head
     $Session = Gdn::session();
     $this->addJsFile('jquery.autosize.min.js');
     $this->addJsFile('autosave.js');
     $this->addJsFile('discussion.js');
     Gdn_Theme::section('Discussion');
     // Load the discussion record
     $DiscussionID = is_numeric($DiscussionID) && $DiscussionID > 0 ? $DiscussionID : 0;
     if (!array_key_exists('Discussion', $this->Data)) {
         $this->setData('Discussion', $this->DiscussionModel->getID($DiscussionID), true);
     }
     if (!is_object($this->Discussion)) {
         $this->EventArguments['DiscussionID'] = $DiscussionID;
         $this->fireEvent('DiscussionNotFound');
         throw notFoundException('Discussion');
     }
     // Define the query offset & limit.
     $Limit = c('Vanilla.Comments.PerPage', 30);
     $OffsetProvided = $Page != '';
     list($Offset, $Limit) = offsetLimit($Page, $Limit);
     // Check permissions
     $this->permission('Vanilla.Discussions.View', true, 'Category', $this->Discussion->PermissionCategoryID);
     $this->setData('CategoryID', $this->CategoryID = $this->Discussion->CategoryID, true);
     if (strcasecmp(val('Type', $this->Discussion), 'redirect') === 0) {
         $this->redirectDiscussion($this->Discussion);
     }
     $Category = CategoryModel::categories($this->Discussion->CategoryID);
     $this->setData('Category', $Category);
     if ($CategoryCssClass = val('CssClass', $Category)) {
         Gdn_Theme::section($CategoryCssClass);
     }
     $this->setData('Breadcrumbs', CategoryModel::getAncestors($this->CategoryID));
     // Setup
     $this->title($this->Discussion->Name);
     // Actual number of comments, excluding the discussion itself.
     $ActualResponses = $this->Discussion->CountComments;
     $this->Offset = $Offset;
     if (c('Vanilla.Comments.AutoOffset')) {
         //         if ($this->Discussion->CountCommentWatch > 1 && $OffsetProvided == '')
         //            $this->addDefinition('ScrollTo', 'a[name=Item_'.$this->Discussion->CountCommentWatch.']');
         if (!is_numeric($this->Offset) || $this->Offset < 0 || !$OffsetProvided) {
             // Round down to the appropriate offset based on the user's read comments & comments per page
             $CountCommentWatch = $this->Discussion->CountCommentWatch > 0 ? $this->Discussion->CountCommentWatch : 0;
             if ($CountCommentWatch > $ActualResponses) {
                 $CountCommentWatch = $ActualResponses;
             }
             // (((67 comments / 10 perpage) = 6.7) rounded down = 6) * 10 perpage = offset 60;
             $this->Offset = floor($CountCommentWatch / $Limit) * $Limit;
         }
         if ($ActualResponses <= $Limit) {
             $this->Offset = 0;
         }
         if ($this->Offset == $ActualResponses) {
             $this->Offset -= $Limit;
         }
     } else {
         if ($this->Offset == '') {
             $this->Offset = 0;
         }
     }
     if ($this->Offset < 0) {
         $this->Offset = 0;
     }
     $LatestItem = $this->Discussion->CountCommentWatch;
     if ($LatestItem === null) {
         $LatestItem = 0;
     } elseif ($LatestItem < $this->Discussion->CountComments) {
         $LatestItem += 1;
     }
     $this->setData('_LatestItem', $LatestItem);
     // Set the canonical url to have the proper page title.
     $this->canonicalUrl(discussionUrl($this->Discussion, pageNumber($this->Offset, $Limit, 0, false)));
     //      url(ConcatSep('/', 'discussion/'.$this->Discussion->DiscussionID.'/'. Gdn_Format::url($this->Discussion->Name), PageNumber($this->Offset, $Limit, TRUE, Gdn::session()->UserID != 0)), true), Gdn::session()->UserID == 0);
     // Load the comments
     $this->setData('Comments', $this->CommentModel->get($DiscussionID, $Limit, $this->Offset));
     $PageNumber = PageNumber($this->Offset, $Limit);
     $this->setData('Page', $PageNumber);
     $this->_SetOpenGraph();
     include_once PATH_LIBRARY . '/vendors/simplehtmldom/simple_html_dom.php';
     if ($PageNumber == 1) {
         $this->description(sliceParagraph(Gdn_Format::plainText($this->Discussion->Body, $this->Discussion->Format), 160));
         // Add images to head for open graph
         $Dom = str_get_html(Gdn_Format::to($this->Discussion->Body, $this->Discussion->Format));
     } else {
         $this->Data['Title'] .= sprintf(t(' - Page %s'), PageNumber($this->Offset, $Limit));
         $FirstComment = $this->data('Comments')->firstRow();
         $FirstBody = val('Body', $FirstComment);
         $FirstFormat = val('Format', $FirstComment);
         $this->description(sliceParagraph(Gdn_Format::plainText($FirstBody, $FirstFormat), 160));
         // Add images to head for open graph
         $Dom = str_get_html(Gdn_Format::to($FirstBody, $FirstFormat));
     }
     if ($Dom) {
         foreach ($Dom->find('img') as $img) {
             if (isset($img->src)) {
                 $this->image($img->src);
             }
         }
     }
     // Queue notification.
     if ($this->Request->get('new') && c('Vanilla.QueueNotifications')) {
         $this->addDefinition('NotifyNewDiscussion', 1);
     }
     // Make sure to set the user's discussion watch records if this is not an API request.
     if ($this->deliveryType() !== DELIVERY_TYPE_DATA) {
         $this->CommentModel->SetWatch($this->Discussion, $Limit, $this->Offset, $this->Discussion->CountComments);
     }
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $this->EventArguments['PagerType'] = 'Pager';
     $this->fireEvent('BeforeBuildPager');
     $this->Pager = $PagerFactory->getPager($this->EventArguments['PagerType'], $this);
     $this->Pager->ClientID = 'Pager';
     $this->Pager->configure($this->Offset, $Limit, $ActualResponses, array('DiscussionUrl'));
     $this->Pager->Record = $this->Discussion;
     PagerModule::current($this->Pager);
     $this->fireEvent('AfterBuildPager');
     // Define the form for the comment input
     $this->Form = Gdn::Factory('Form', 'Comment');
     $this->Form->Action = url('/post/comment/');
     $this->DiscussionID = $this->Discussion->DiscussionID;
     $this->Form->addHidden('DiscussionID', $this->DiscussionID);
     $this->Form->addHidden('CommentID', '');
     // Look in the session stash for a comment
     $StashComment = $Session->getPublicStash('CommentForDiscussionID_' . $this->Discussion->DiscussionID);
     if ($StashComment) {
         $this->Form->setValue('Body', $StashComment);
         $this->Form->setFormValue('Body', $StashComment);
     }
     // Retrieve & apply the draft if there is one:
     if (Gdn::session()->UserID) {
         $DraftModel = new DraftModel();
         $Draft = $DraftModel->get($Session->UserID, 0, 1, $this->Discussion->DiscussionID)->firstRow();
         $this->Form->addHidden('DraftID', $Draft ? $Draft->DraftID : '');
         if ($Draft && !$this->Form->isPostBack()) {
             $this->Form->setValue('Body', $Draft->Body);
             $this->Form->setValue('Format', $Draft->Format);
         }
     }
     // Deliver JSON data if necessary
     if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
         $this->setJson('LessRow', $this->Pager->toString('less'));
         $this->setJson('MoreRow', $this->Pager->toString('more'));
         $this->View = 'comments';
     }
     // Inform moderator of checked comments in this discussion
     $CheckedComments = $Session->getAttribute('CheckedComments', array());
     if (count($CheckedComments) > 0) {
         ModerationController::informCheckedComments($this);
     }
     // Add modules
     $this->addModule('DiscussionFilterModule');
     $this->addModule('NewDiscussionModule');
     $this->addModule('CategoriesModule');
     $this->addModule('BookmarkedModule');
     $this->CanEditComments = Gdn::session()->checkPermission('Vanilla.Comments.Edit', true, 'Category', 'any') && c('Vanilla.AdminCheckboxes.Use');
     // Report the discussion id so js can use it.
     $this->addDefinition('DiscussionID', $DiscussionID);
     $this->addDefinition('Category', $this->data('Category.Name'));
     $this->fireEvent('BeforeDiscussionRender');
     $AttachmentModel = AttachmentModel::instance();
     if (AttachmentModel::enabled()) {
         $AttachmentModel->joinAttachments($this->Data['Discussion'], $this->Data['Comments']);
         $this->fireEvent('FetchAttachmentViews');
         if ($this->deliveryMethod() === DELIVERY_METHOD_XHTML) {
             require_once $this->fetchViewLocation('attachment', 'attachments', 'dashboard');
         }
     }
     $this->render();
 }
Пример #5
0
 /**
  *
  *
  * @param array $Options
  * @throws Exception
  */
 public static function write($Options = array())
 {
     static $WriteCount = 0;
     if (!self::$_CurrentPager) {
         if (is_a($Options, 'Gdn_Controller')) {
             self::$_CurrentPager = new PagerModule($Options);
             $Options = array();
         } else {
             self::$_CurrentPager = new PagerModule(val('Sender', $Options, Gdn::controller()));
         }
     }
     $Pager = self::$_CurrentPager;
     $Pager->Wrapper = val('Wrapper', $Options, $Pager->Wrapper);
     $Pager->MoreCode = val('MoreCode', $Options, $Pager->MoreCode);
     $Pager->LessCode = val('LessCode', $Options, $Pager->LessCode);
     $Pager->ClientID = val('ClientID', $Options, $Pager->ClientID);
     $Pager->Limit = val('Limit', $Options, $Pager->Controller()->data('_Limit', $Pager->Limit));
     $Pager->HtmlBefore = val('HtmlBefore', $Options, val('HtmlBefore', $Pager, ''));
     $Pager->CurrentRecords = val('CurrentRecords', $Options, $Pager->Controller()->data('_CurrentRecords', $Pager->CurrentRecords));
     // Try and figure out the offset based on the parameters coming in to the controller.
     if (!$Pager->Offset) {
         $Page = $Pager->Controller()->Request->get('Page', false);
         if (!$Page) {
             $Page = 'p1';
             foreach ($Pager->Controller()->RequestArgs as $Arg) {
                 if (preg_match('`p\\d+`', $Arg)) {
                     $Page = $Arg;
                     break;
                 }
             }
         }
         list($Offset, $Limit) = offsetLimit($Page, $Pager->Limit);
         $TotalRecords = val('RecordCount', $Options, $Pager->Controller()->data('RecordCount', false));
         $Get = $Pager->Controller()->Request->get();
         unset($Get['Page'], $Get['DeliveryType'], $Get['DeliveryMethod']);
         $Url = val('Url', $Options, $Pager->Controller()->SelfUrl . '?Page={Page}&' . http_build_query($Get));
         $Pager->configure($Offset, $Limit, $TotalRecords, $Url);
     } elseif ($Url = val('Url', $Options)) {
         $Pager->Url = $Url;
     }
     echo $Pager->toString($WriteCount > 0 ? 'more' : 'less');
     $WriteCount++;
     //      list($Offset, $Limit) = offsetLimit(GetValue, 20);
     //		$Pager->configure(
     //			$Offset,
     //			$Limit,
     //			$TotalAddons,
     //			"/settings/addons/$Section?Page={Page}"
     //		);
     //		$Sender->setData('_Pager', $Pager);
 }
Пример #6
0
include_once $this->fetchViewLocation('helper_functions');
$this->fireEvent('BeforeStatusForm');
$Session = Gdn::session();
if ($Session->checkPermission('Garden.Profiles.Edit')) {
    echo '<div class="FormWrapper FormWrapper-Condensed">';
    echo $this->Form->open(array('action' => url('/activity/post/' . $this->data('Filter')), 'class' => 'Activity'));
    echo $this->Form->errors();
    echo $this->Form->textBox('Comment', array('MultiLine' => true, 'Wrap' => TRUE));
    echo '<div class="Buttons">';
    echo $this->Form->button('Share', array('class' => 'Button Primary'));
    echo '</div>';
    echo $this->Form->close();
    echo '</div>';
}
echo '</div>';
echo '<ul class="DataList Activities">';
$Activities = $this->data('Activities', array());
if (count($Activities) > 0) {
    include $this->fetchViewLocation('activities', 'activity', 'dashboard');
} else {
    ?>
<li><div class="Empty"><?php 
    echo t('Not much happening here, yet.');
    ?>
</div></li>
   <?php 
}
echo '</ul>';
if (count($Activities) > 0) {
    PagerModule::write(array('CurrentRecords' => count($Activities)));
}
 /**
  * Show all discussions in a particular category.
  *
  * @since 2.0.0
  * @access public
  *
  * @param string $CategoryIdentifier Unique category slug or ID.
  * @param int $Offset Number of discussions to skip.
  */
 public function index($CategoryIdentifier = '', $Page = '0')
 {
     // Figure out which category layout to choose (Defined on "Homepage" settings page).
     $Layout = c('Vanilla.Categories.Layout');
     if ($CategoryIdentifier == '') {
         switch ($Layout) {
             case 'mixed':
                 $this->View = 'discussions';
                 $this->discussions();
                 break;
             case 'table':
                 $this->table();
                 break;
             default:
                 $this->View = 'all';
                 $this->all('', CategoryModel::getRootDisplayAs());
                 break;
         }
         return;
     } else {
         $Category = CategoryModel::categories($CategoryIdentifier);
         if (empty($Category)) {
             throw notFoundException();
         }
         $Category = (object) $Category;
         Gdn_Theme::section($Category->CssClass);
         // Load the breadcrumbs.
         $this->setData('Breadcrumbs', CategoryModel::getAncestors(val('CategoryID', $Category)));
         $this->setData('Category', $Category, true);
         $this->title(htmlspecialchars(val('Name', $Category, '')));
         $this->description(val('Description', $Category), true);
         switch ($Category->DisplayAs) {
             case 'Flat':
             case 'Heading':
             case 'Categories':
                 $stopHeadings = val('Depth', $Category) > CategoryModel::instance()->getNavDepth();
                 CategoryModel::instance()->setStopHeadingsCalculation($stopHeadings);
                 if ($this->SyndicationMethod != SYNDICATION_NONE) {
                     // RSS can't show a category list so just tell it to expand all categories.
                     saveToConfig('Vanilla.ExpandCategories', true, false);
                 } else {
                     // This category is an overview style category and displays as a category list.
                     switch ($Layout) {
                         case 'mixed':
                             $this->View = 'discussions';
                             $this->discussions($CategoryIdentifier);
                             break;
                         case 'table':
                             $this->table($CategoryIdentifier, $Category->DisplayAs);
                             break;
                         default:
                             $this->View = 'all';
                             $this->All($CategoryIdentifier, $Category->DisplayAs);
                             break;
                     }
                     return;
                 }
                 break;
         }
         Gdn_Theme::section('DiscussionList');
         // Figure out which discussions layout to choose (Defined on "Homepage" settings page).
         $Layout = c('Vanilla.Discussions.Layout');
         switch ($Layout) {
             case 'table':
                 if ($this->SyndicationMethod == SYNDICATION_NONE) {
                     $this->View = 'table';
                 }
                 break;
             default:
                 // $this->View = 'index';
                 break;
         }
         $this->setData('CategoryTree', $this->getCategoryTree($CategoryIdentifier, val('DisplayAs', $Category)));
         // Add a backwards-compatibility shim for the old categories.
         $this->categoriesCompatibilityCallback = function () use($CategoryIdentifier) {
             $categories = CategoryModel::getSubtree($CategoryIdentifier, false);
             return $categories;
         };
         // Setup head
         $this->Menu->highlightRoute('/discussions');
         if ($this->Head) {
             $this->addJsFile('discussions.js');
             $this->Head->addRss(categoryUrl($Category) . '/feed.rss', $this->Head->title());
         }
         // Set CategoryID
         $CategoryID = val('CategoryID', $Category);
         $this->setData('CategoryID', $CategoryID, true);
         // Add modules
         $this->addModule('NewDiscussionModule');
         $this->addModule('DiscussionFilterModule');
         $this->addModule('CategoriesModule');
         $this->addModule('BookmarkedModule');
         // Get a DiscussionModel
         $DiscussionModel = new DiscussionModel();
         $DiscussionModel->setSort(Gdn::request()->get());
         $DiscussionModel->setFilters(Gdn::request()->get());
         $this->setData('Sort', $DiscussionModel->getSort());
         $this->setData('Filters', $DiscussionModel->getFilters());
         $CategoryIDs = array($CategoryID);
         if (c('Vanilla.ExpandCategories')) {
             $CategoryIDs = array_merge($CategoryIDs, array_column($this->data('Categories'), 'CategoryID'));
         }
         $Wheres = array('d.CategoryID' => $CategoryIDs);
         $this->setData('_ShowCategoryLink', count($CategoryIDs) > 1);
         // Check permission
         $this->permission('Vanilla.Discussions.View', true, 'Category', val('PermissionCategoryID', $Category));
         // Set discussion meta data.
         $this->EventArguments['PerPage'] = c('Vanilla.Discussions.PerPage', 30);
         $this->fireEvent('BeforeGetDiscussions');
         list($Offset, $Limit) = offsetLimit($Page, $this->EventArguments['PerPage']);
         if (!is_numeric($Offset) || $Offset < 0) {
             $Offset = 0;
         }
         $Page = PageNumber($Offset, $Limit);
         // Allow page manipulation
         $this->EventArguments['Page'] =& $Page;
         $this->EventArguments['Offset'] =& $Offset;
         $this->EventArguments['Limit'] =& $Limit;
         $this->fireEvent('AfterPageCalculation');
         // We want to limit the number of pages on large databases because requesting a super-high page can kill the db.
         $MaxPages = c('Vanilla.Categories.MaxPages');
         if ($MaxPages && $Page > $MaxPages) {
             throw notFoundException();
         }
         $CountDiscussions = $DiscussionModel->getCount($Wheres);
         if ($MaxPages && $MaxPages * $Limit < $CountDiscussions) {
             $CountDiscussions = $MaxPages * $Limit;
         }
         $this->setData('CountDiscussions', $CountDiscussions);
         $this->setData('_Limit', $Limit);
         // We don't wan't child categories in announcements.
         $Wheres['d.CategoryID'] = $CategoryID;
         $AnnounceData = $DiscussionModel->getAnnouncements($Wheres, $Offset, $Limit);
         $this->AnnounceData = $this->setData('Announcements', $AnnounceData);
         $Wheres['d.CategoryID'] = $CategoryIDs;
         // RSS should include announcements.
         if ($this->SyndicationMethod !== SYNDICATION_NONE) {
             $Wheres['Announce'] = 'all';
         }
         $this->DiscussionData = $this->setData('Discussions', $DiscussionModel->getWhereRecent($Wheres, $Limit, $Offset));
         // Build a pager
         $PagerFactory = new Gdn_PagerFactory();
         $url = CategoryUrl($CategoryIdentifier);
         $this->EventArguments['PagerType'] = 'Pager';
         $this->fireEvent('BeforeBuildPager');
         if (!$this->data('_PagerUrl')) {
             $this->setData('_PagerUrl', $url . '/{Page}');
         }
         $queryString = DiscussionModel::getSortFilterQueryString($DiscussionModel->getSort(), $DiscussionModel->getFilters());
         $this->setData('_PagerUrl', $this->data('_PagerUrl') . $queryString);
         $this->Pager = $PagerFactory->GetPager($this->EventArguments['PagerType'], $this);
         $this->Pager->ClientID = 'Pager';
         $this->Pager->configure($Offset, $Limit, $CountDiscussions, $this->data('_PagerUrl'));
         $this->Pager->Record = $Category;
         PagerModule::current($this->Pager);
         $this->setData('_Page', $Page);
         $this->setData('_Limit', $Limit);
         $this->fireEvent('AfterBuildPager');
         // Set the canonical Url.
         $this->canonicalUrl(categoryUrl($Category, pageNumber($Offset, $Limit)));
         // Change the controller name so that it knows to grab the discussion views
         $this->ControllerName = 'DiscussionsController';
         // Pick up the discussions class
         $this->CssClass = 'Discussions Category-' . val('UrlCode', $Category);
         // Deliver JSON data if necessary
         if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
             $this->setJson('LessRow', $this->Pager->toString('less'));
             $this->setJson('MoreRow', $this->Pager->toString('more'));
             $this->View = 'discussions';
         }
         // Render default view.
         $this->fireEvent('BeforeCategoriesRender');
         $this->render();
     }
 }
 /**
  * Default all discussions view: chronological by most recent comment.
  *
  * @since 2.0.0
  * @access public
  *
  * @param int $Page Multiplied by PerPage option to determine offset.
  */
 public function index($Page = false)
 {
     // Figure out which discussions layout to choose (Defined on "Homepage" settings page).
     $Layout = c('Vanilla.Discussions.Layout');
     switch ($Layout) {
         case 'table':
             if ($this->SyndicationMethod == SYNDICATION_NONE) {
                 $this->View = 'table';
             }
             break;
         default:
             // $this->View = 'index';
             break;
     }
     Gdn_Theme::section('DiscussionList');
     // Check for the feed keyword.
     if ($Page === 'feed' && $this->SyndicationMethod != SYNDICATION_NONE) {
         $Page = 'p1';
     }
     // Determine offset from $Page
     list($Offset, $Limit) = offsetLimit($Page, c('Vanilla.Discussions.PerPage', 30), true);
     $Page = PageNumber($Offset, $Limit);
     // Allow page manipulation
     $this->EventArguments['Page'] =& $Page;
     $this->EventArguments['Offset'] =& $Offset;
     $this->EventArguments['Limit'] =& $Limit;
     $this->fireEvent('AfterPageCalculation');
     // Set canonical URL
     $this->canonicalUrl(url(ConcatSep('/', 'discussions', PageNumber($Offset, $Limit, true, false)), true));
     // We want to limit the number of pages on large databases because requesting a super-high page can kill the db.
     $MaxPages = c('Vanilla.Discussions.MaxPages');
     if ($MaxPages && $Page > $MaxPages) {
         throw notFoundException();
     }
     // Setup head.
     if (!$this->data('Title')) {
         $Title = c('Garden.HomepageTitle');
         $DefaultControllerRoute = val('Destination', Gdn::router()->GetRoute('DefaultController'));
         if ($Title && $DefaultControllerRoute == 'discussions') {
             $this->title($Title, '');
         } else {
             $this->title(t('Recent Discussions'));
         }
     }
     if (!$this->Description()) {
         $this->Description(c('Garden.Description', null));
     }
     if ($this->Head) {
         $this->Head->AddRss(url('/discussions/feed.rss', true), $this->Head->title());
     }
     // Add modules
     $this->addModule('DiscussionFilterModule');
     $this->addModule('NewDiscussionModule');
     $this->addModule('CategoriesModule');
     $this->addModule('BookmarkedModule');
     $this->setData('Breadcrumbs', array(array('Name' => t('Recent Discussions'), 'Url' => '/discussions')));
     // Set criteria & get discussions data
     $this->setData('Category', false, true);
     $DiscussionModel = new DiscussionModel();
     // Check for individual categories.
     $categoryIDs = $this->getCategoryIDs();
     $where = array();
     if ($categoryIDs) {
         $where['d.CategoryID'] = CategoryModel::filterCategoryPermissions($categoryIDs);
     } else {
         $DiscussionModel->Watching = true;
     }
     // Get Discussion Count
     $CountDiscussions = $DiscussionModel->getCount($where);
     if ($MaxPages) {
         $CountDiscussions = min($MaxPages * $Limit, $CountDiscussions);
     }
     $this->setData('CountDiscussions', $CountDiscussions);
     // Get Announcements
     $this->AnnounceData = $Offset == 0 ? $DiscussionModel->GetAnnouncements($where) : false;
     $this->setData('Announcements', $this->AnnounceData !== false ? $this->AnnounceData : array(), true);
     // Get Discussions
     $this->DiscussionData = $DiscussionModel->getWhere($where, $Offset, $Limit);
     $this->setData('Discussions', $this->DiscussionData, true);
     $this->setJson('Loading', $Offset . ' to ' . $Limit);
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $this->EventArguments['PagerType'] = 'Pager';
     $this->fireEvent('BeforeBuildPager');
     if (!$this->data('_PagerUrl')) {
         $this->setData('_PagerUrl', 'discussions/{Page}');
     }
     $this->Pager = $PagerFactory->GetPager($this->EventArguments['PagerType'], $this);
     $this->Pager->ClientID = 'Pager';
     $this->Pager->configure($Offset, $Limit, $this->data('CountDiscussions'), $this->data('_PagerUrl'));
     PagerModule::Current($this->Pager);
     $this->setData('_Page', $Page);
     $this->setData('_Limit', $Limit);
     $this->fireEvent('AfterBuildPager');
     // Deliver JSON data if necessary
     if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
         $this->setJson('LessRow', $this->Pager->toString('less'));
         $this->setJson('MoreRow', $this->Pager->toString('more'));
         $this->View = 'discussions';
     }
     $this->render();
 }
Пример #9
0
            <tbody>
            <?php 
    $Alt = '';
    if (property_exists($this, 'AnnounceData') && is_object($this->AnnounceData)) {
        foreach ($this->AnnounceData->result() as $Discussion) {
            $Alt = $Alt == ' Alt' ? '' : ' Alt';
            WriteDiscussionRow($Discussion, $this, $Session, $Alt);
        }
    }
    $Alt = '';
    foreach ($this->DiscussionData->result() as $Discussion) {
        $Alt = $Alt == ' Alt' ? '' : ' Alt';
        WriteDiscussionRow($Discussion, $this, $Session, $Alt);
    }
    ?>
            </tbody>
        </table>
    </div>
    <?php 
    echo '<div class="PageControls Bottom">';
    PagerModule::write($PagerOptions);
    echo Gdn_Theme::Module('NewDiscussionModule', $this->data('_NewDiscussionProperties', array('CssClass' => 'Button Action Primary')));
    echo '</div>';
} else {
    ?>
    <div class="Empty"><?php 
    echo t('No discussions were found.');
    ?>
</div>
<?php 
}
Пример #10
0
<?php

if (!defined('APPLICATION')) {
    exit;
}
if ($this->ActivityData->NumRows() > 0) {
    echo '<ul class="DataList Activities Notifications">';
    include $this->FetchViewLocation('activities', 'activity', 'dashboard');
    echo '</ul>';
    echo PagerModule::Write(array('CurrentRecords' => $this->ActivityData->NumRows()));
} else {
    ?>
<div class="Empty"><?php 
    echo T('You do not have any notifications yet.');
    ?>
</div>
   <?php 
}
 /**
  * Show all discussions in a particular category.
  * 
  * @since 2.0.0
  * @access public
  * 
  * @param string $CategoryIdentifier Unique category slug or ID.
  * @param int $Offset Number of discussions to skip.
  */
 public function Index($CategoryIdentifier = '', $Page = '0')
 {
     if ($CategoryIdentifier == '') {
         // Figure out which category layout to choose (Defined on "Homepage" settings page).
         $Layout = C('Vanilla.Categories.Layout');
         switch ($Layout) {
             case 'mixed':
                 $this->View = 'discussions';
                 $this->Discussions();
                 break;
             case 'table':
                 $this->Table();
                 break;
             default:
                 $this->View = 'all';
                 $this->All();
                 break;
         }
         return;
     } else {
         Gdn_Theme::Section('DiscussionList');
         // Figure out which discussions layout to choose (Defined on "Homepage" settings page).
         $Layout = C('Vanilla.Discussions.Layout');
         switch ($Layout) {
             case 'table':
                 if ($this->SyndicationMethod == SYNDICATION_NONE) {
                     $this->View = 'table';
                 }
                 break;
             default:
                 // $this->View = 'index';
                 break;
         }
         $Category = CategoryModel::Categories($CategoryIdentifier);
         if (empty($Category)) {
             if ($CategoryIdentifier) {
                 throw NotFoundException();
             }
         }
         $Category = (object) $Category;
         Gdn_Theme::Section($Category->CssClass);
         // Load the breadcrumbs.
         $this->SetData('Breadcrumbs', CategoryModel::GetAncestors(GetValue('CategoryID', $Category)));
         $this->SetData('Category', $Category, TRUE);
         // Load the subtree.
         if (C('Vanilla.ExpandCategories')) {
             $Categories = CategoryModel::GetSubtree($CategoryIdentifier);
         } else {
             $Categories = array($Category);
         }
         $this->SetData('Categories', $Categories);
         // Setup head
         $this->AddCssFile('vanilla.css');
         $this->Menu->HighlightRoute('/discussions');
         if ($this->Head) {
             $this->AddJsFile('discussions.js');
             $this->AddJsFile('bookmark.js');
             $this->AddJsFile('options.js');
             $this->Head->AddRss($this->SelfUrl . '/feed.rss', $this->Head->Title());
         }
         $this->Title(GetValue('Name', $Category, ''));
         $this->Description(GetValue('Description', $Category), TRUE);
         // Set CategoryID
         $CategoryID = GetValue('CategoryID', $Category);
         $this->SetData('CategoryID', $CategoryID, TRUE);
         // Add modules
         $this->AddModule('NewDiscussionModule');
         $this->AddModule('DiscussionFilterModule');
         $this->AddModule('CategoriesModule');
         $this->AddModule('BookmarkedModule');
         // Get a DiscussionModel
         $DiscussionModel = new DiscussionModel();
         $CategoryIDs = ConsolidateArrayValuesByKey($this->Data('Categories'), 'CategoryID');
         $Wheres = array('d.CategoryID' => $CategoryIDs);
         $this->SetData('_ShowCategoryLink', count($CategoryIDs) > 1);
         // Check permission
         $this->Permission('Vanilla.Discussions.View', TRUE, 'Category', GetValue('PermissionCategoryID', $Category));
         // Set discussion meta data.
         $this->EventArguments['PerPage'] = C('Vanilla.Discussions.PerPage', 30);
         $this->FireEvent('BeforeGetDiscussions');
         list($Offset, $Limit) = OffsetLimit($Page, $this->EventArguments['PerPage']);
         if (!is_numeric($Offset) || $Offset < 0) {
             $Offset = 0;
         }
         $CountDiscussions = $DiscussionModel->GetCount($Wheres);
         $this->SetData('CountDiscussions', $CountDiscussions);
         $this->SetData('_Limit', $Limit);
         // We don't wan't child categories in announcements.
         $Wheres['d.CategoryID'] = $CategoryID;
         $AnnounceData = $Offset == 0 ? $DiscussionModel->GetAnnouncements($Wheres) : new Gdn_DataSet();
         $this->SetData('AnnounceData', $AnnounceData, TRUE);
         $Wheres['d.CategoryID'] = $CategoryIDs;
         $this->DiscussionData = $this->SetData('Discussions', $DiscussionModel->GetWhere($Wheres, $Offset, $Limit));
         // Build a pager
         $PagerFactory = new Gdn_PagerFactory();
         $this->Pager = $PagerFactory->GetPager('Pager', $this);
         $this->Pager->ClientID = 'Pager';
         $this->Pager->Configure($Offset, $Limit, $CountDiscussions, array('CategoryUrl'));
         $this->Pager->Record = $Category;
         PagerModule::Current($this->Pager);
         $this->SetData('_Page', $Page);
         // Set the canonical Url.
         $this->CanonicalUrl(CategoryUrl($Category, PageNumber($Offset, $Limit)));
         // Change the controller name so that it knows to grab the discussion views
         $this->ControllerName = 'DiscussionsController';
         // Pick up the discussions class
         $this->CssClass = 'Discussions';
         // Deliver JSON data if necessary
         if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
             $this->SetJson('LessRow', $this->Pager->ToString('less'));
             $this->SetJson('MoreRow', $this->Pager->ToString('more'));
             $this->View = 'discussions';
         }
         // Render default view.
         $this->FireEvent('BeforeCategoriesRender');
         $this->Render();
     }
 }
Пример #12
0
    //
    //                  echo "\n<li>".
    //                     anchor($child['Summary'], $child['Url']);
    //                     '</li>';
    //
    //                  if ($i >= 3)
    //                     break;
    //               }
    //               echo '</ul>';
    //            }
    if ($Count > 1) {
        $url = $this->data('SearchUrl') . '&discussionid=' . urlencode($Row['DiscussionID']) . '#search-results';
        echo '<div>' . anchor(Plural($Count, '%s result', '%s results'), $url) . '</div>';
    }
    ?>
                    </div>
                </div>
            </li>
        <?php 
}
?>
    </ol>

<?php 
echo '<div class="PageControls Bottom">';
$RecordCount = $this->data('RecordCount');
if ($RecordCount) {
    echo '<span class="Gloss">' . plural($RecordCount, '%s result', '%s results') . '</span>';
}
PagerModule::write(array('Wrapper' => '<div %1$s>%2$s</div>'));
echo '</div>';
 /**
  * Show all discussions in a particular category.
  *
  * @since 2.0.0
  * @access public
  *
  * @param string $CategoryIdentifier Unique category slug or ID.
  * @param int $Offset Number of discussions to skip.
  */
 public function index($CategoryIdentifier = '', $Page = '0')
 {
     // Figure out which category layout to choose (Defined on "Homepage" settings page).
     $Layout = c('Vanilla.Categories.Layout');
     if ($CategoryIdentifier == '') {
         switch ($Layout) {
             case 'mixed':
                 $this->View = 'discussions';
                 $this->Discussions();
                 break;
             case 'table':
                 $this->table();
                 break;
             default:
                 $this->View = 'all';
                 $this->All();
                 break;
         }
         return;
     } else {
         $Category = CategoryModel::categories($CategoryIdentifier);
         if (empty($Category)) {
             // Try lowercasing before outright failing
             $LowerCategoryIdentifier = strtolower($CategoryIdentifier);
             if ($LowerCategoryIdentifier != $CategoryIdentifier) {
                 $Category = CategoryModel::categories($LowerCategoryIdentifier);
                 if ($Category) {
                     redirect("/categories/{$LowerCategoryIdentifier}", 301);
                 }
             }
             throw notFoundException();
         }
         $Category = (object) $Category;
         Gdn_Theme::section($Category->CssClass);
         // Load the breadcrumbs.
         $this->setData('Breadcrumbs', CategoryModel::GetAncestors(val('CategoryID', $Category)));
         $this->setData('Category', $Category, true);
         $this->title(htmlspecialchars(val('Name', $Category, '')));
         $this->Description(val('Description', $Category), true);
         if ($Category->DisplayAs == 'Categories') {
             if (val('Depth', $Category) > c('Vanilla.Categories.NavDepth', 0)) {
                 // Headings don't make sense if we've cascaded down one level.
                 saveToConfig('Vanilla.Categories.DoHeadings', false, false);
             }
             trace($this->deliveryMethod(), 'delivery method');
             trace($this->deliveryType(), 'delivery type');
             trace($this->SyndicationMethod, 'syndication');
             if ($this->SyndicationMethod != SYNDICATION_NONE) {
                 // RSS can't show a category list so just tell it to expand all categories.
                 saveToConfig('Vanilla.ExpandCategories', true, false);
             } else {
                 // This category is an overview style category and displays as a category list.
                 switch ($Layout) {
                     case 'mixed':
                         $this->View = 'discussions';
                         $this->Discussions($CategoryIdentifier);
                         break;
                     case 'table':
                         $this->table($CategoryIdentifier);
                         break;
                     default:
                         $this->View = 'all';
                         $this->All($CategoryIdentifier);
                         break;
                 }
                 return;
             }
         }
         Gdn_Theme::section('DiscussionList');
         // Figure out which discussions layout to choose (Defined on "Homepage" settings page).
         $Layout = c('Vanilla.Discussions.Layout');
         switch ($Layout) {
             case 'table':
                 if ($this->SyndicationMethod == SYNDICATION_NONE) {
                     $this->View = 'table';
                 }
                 break;
             default:
                 // $this->View = 'index';
                 break;
         }
         // Load the subtree.
         $Categories = CategoryModel::GetSubtree($CategoryIdentifier, false);
         $this->setData('Categories', $Categories);
         // Setup head
         $this->Menu->highlightRoute('/discussions');
         if ($this->Head) {
             $this->addJsFile('discussions.js');
             $this->Head->AddRss($this->SelfUrl . '/feed.rss', $this->Head->title());
         }
         // Set CategoryID
         $CategoryID = val('CategoryID', $Category);
         $this->setData('CategoryID', $CategoryID, true);
         // Add modules
         $this->addModule('NewDiscussionModule');
         $this->addModule('DiscussionFilterModule');
         $this->addModule('CategoriesModule');
         $this->addModule('BookmarkedModule');
         // Get a DiscussionModel
         $DiscussionModel = new DiscussionModel();
         $CategoryIDs = array($CategoryID);
         if (c('Vanilla.ExpandCategories')) {
             $CategoryIDs = array_merge($CategoryIDs, array_column($this->data('Categories'), 'CategoryID'));
         }
         $Wheres = array('d.CategoryID' => $CategoryIDs);
         $this->setData('_ShowCategoryLink', count($CategoryIDs) > 1);
         // Check permission
         $this->permission('Vanilla.Discussions.View', true, 'Category', val('PermissionCategoryID', $Category));
         // Set discussion meta data.
         $this->EventArguments['PerPage'] = c('Vanilla.Discussions.PerPage', 30);
         $this->fireEvent('BeforeGetDiscussions');
         list($Offset, $Limit) = offsetLimit($Page, $this->EventArguments['PerPage']);
         if (!is_numeric($Offset) || $Offset < 0) {
             $Offset = 0;
         }
         $Page = PageNumber($Offset, $Limit);
         // Allow page manipulation
         $this->EventArguments['Page'] =& $Page;
         $this->EventArguments['Offset'] =& $Offset;
         $this->EventArguments['Limit'] =& $Limit;
         $this->fireEvent('AfterPageCalculation');
         // We want to limit the number of pages on large databases because requesting a super-high page can kill the db.
         $MaxPages = c('Vanilla.Categories.MaxPages');
         if ($MaxPages && $Page > $MaxPages) {
             throw notFoundException();
         }
         $CountDiscussions = $DiscussionModel->getCount($Wheres);
         if ($MaxPages && $MaxPages * $Limit < $CountDiscussions) {
             $CountDiscussions = $MaxPages * $Limit;
         }
         $this->setData('CountDiscussions', $CountDiscussions);
         $this->setData('_Limit', $Limit);
         // We don't wan't child categories in announcements.
         $Wheres['d.CategoryID'] = $CategoryID;
         $AnnounceData = $Offset == 0 ? $DiscussionModel->GetAnnouncements($Wheres) : new Gdn_DataSet();
         $this->setData('AnnounceData', $AnnounceData, true);
         $Wheres['d.CategoryID'] = $CategoryIDs;
         $this->DiscussionData = $this->setData('Discussions', $DiscussionModel->getWhere($Wheres, $Offset, $Limit));
         // Build a pager
         $PagerFactory = new Gdn_PagerFactory();
         $this->EventArguments['PagerType'] = 'Pager';
         $this->fireEvent('BeforeBuildPager');
         $this->Pager = $PagerFactory->GetPager($this->EventArguments['PagerType'], $this);
         $this->Pager->ClientID = 'Pager';
         $this->Pager->configure($Offset, $Limit, $CountDiscussions, array('CategoryUrl'));
         $this->Pager->Record = $Category;
         PagerModule::Current($this->Pager);
         $this->setData('_Page', $Page);
         $this->setData('_Limit', $Limit);
         $this->fireEvent('AfterBuildPager');
         // Set the canonical Url.
         $this->canonicalUrl(CategoryUrl($Category, PageNumber($Offset, $Limit)));
         // Change the controller name so that it knows to grab the discussion views
         $this->ControllerName = 'DiscussionsController';
         // Pick up the discussions class
         $this->CssClass = 'Discussions Category-' . GetValue('UrlCode', $Category);
         // Deliver JSON data if necessary
         if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
             $this->setJson('LessRow', $this->Pager->toString('less'));
             $this->setJson('MoreRow', $this->Pager->toString('more'));
             $this->View = 'discussions';
         }
         // Render default view.
         $this->fireEvent('BeforeCategoriesRender');
         $this->render();
     }
 }
 /**
  * Default single discussion display.
  * 
  * @since 2.0.0
  * @access public
  * 
  * @param int $DiscussionID Unique discussion ID
  * @param string $DiscussionStub URL-safe title slug
  * @param int $Page The current page of comments
  */
 public function Index($DiscussionID = '', $DiscussionStub = '', $Page = '')
 {
     // Setup head
     $Session = Gdn::Session();
     $this->AddJsFile('jquery.autogrow.js');
     $this->AddJsFile('options.js');
     $this->AddJsFile('bookmark.js');
     $this->AddJsFile('discussion.js');
     $this->AddJsFile('autosave.js');
     Gdn_Theme::Section('Discussion');
     // Load the discussion record
     $DiscussionID = is_numeric($DiscussionID) && $DiscussionID > 0 ? $DiscussionID : 0;
     if (!array_key_exists('Discussion', $this->Data)) {
         $this->SetData('Discussion', $this->DiscussionModel->GetID($DiscussionID), TRUE);
     }
     if (!is_object($this->Discussion)) {
         throw new Exception(sprintf(T('%s Not Found'), T('Discussion')), 404);
     }
     // Define the query offset & limit.
     $Limit = C('Vanilla.Comments.PerPage', 30);
     $OffsetProvided = $Page != '';
     list($Offset, $Limit) = OffsetLimit($Page, $Limit);
     // Check permissions
     $this->Permission('Vanilla.Discussions.View', TRUE, 'Category', $this->Discussion->PermissionCategoryID);
     $this->SetData('CategoryID', $this->CategoryID = $this->Discussion->CategoryID, TRUE);
     $this->SetData('Breadcrumbs', CategoryModel::GetAncestors($this->CategoryID));
     // Setup
     $this->Title($this->Discussion->Name);
     // Actual number of comments, excluding the discussion itself.
     $ActualResponses = $this->Discussion->CountComments;
     $this->Offset = $Offset;
     if (C('Vanilla.Comments.AutoOffset')) {
         //         if ($this->Discussion->CountCommentWatch > 1 && $OffsetProvided == '')
         //            $this->AddDefinition('ScrollTo', 'a[name=Item_'.$this->Discussion->CountCommentWatch.']');
         if (!is_numeric($this->Offset) || $this->Offset < 0 || !$OffsetProvided) {
             // Round down to the appropriate offset based on the user's read comments & comments per page
             $CountCommentWatch = $this->Discussion->CountCommentWatch > 0 ? $this->Discussion->CountCommentWatch : 0;
             if ($CountCommentWatch > $ActualResponses) {
                 $CountCommentWatch = $ActualResponses;
             }
             // (((67 comments / 10 perpage) = 6.7) rounded down = 6) * 10 perpage = offset 60;
             $this->Offset = floor($CountCommentWatch / $Limit) * $Limit;
         }
         if ($ActualResponses <= $Limit) {
             $this->Offset = 0;
         }
         if ($this->Offset == $ActualResponses) {
             $this->Offset -= $Limit;
         }
     } else {
         if ($this->Offset == '') {
             $this->Offset = 0;
         }
     }
     if ($this->Offset < 0) {
         $this->Offset = 0;
     }
     $LatestItem = $this->Discussion->CountCommentWatch;
     if ($LatestItem === NULL) {
         $LatestItem = 0;
     } elseif ($LatestItem < $this->Discussion->CountComments) {
         $LatestItem += 1;
     }
     $this->SetData('_LatestItem', $LatestItem);
     // Set the canonical url to have the proper page title.
     $this->CanonicalUrl(DiscussionUrl($this->Discussion, PageNumber($this->Offset, $Limit, FALSE)));
     //      Url(ConcatSep('/', 'discussion/'.$this->Discussion->DiscussionID.'/'. Gdn_Format::Url($this->Discussion->Name), PageNumber($this->Offset, $Limit, TRUE, Gdn::Session()->UserID != 0)), TRUE), Gdn::Session()->UserID == 0);
     // Load the comments
     $this->SetData('Comments', $this->CommentModel->Get($DiscussionID, $Limit, $this->Offset));
     $PageNumber = PageNumber($this->Offset, $Limit);
     $this->SetData('Page', $PageNumber);
     $this->_SetOpenGraph();
     include_once PATH_LIBRARY . '/vendors/simplehtmldom/simple_html_dom.php';
     if ($PageNumber == 1) {
         $this->Description(SliceParagraph(Gdn_Format::PlainText($this->Discussion->Body, $this->Discussion->Format), 160));
         // Add images to head for open graph
         $Dom = str_get_html(Gdn_Format::To($this->Discussion->Body, $this->Discussion->Format));
     } else {
         $this->Data['Title'] .= sprintf(T(' - Page %s'), PageNumber($this->Offset, $Limit));
         $FirstComment = $this->Data('Comments')->FirstRow();
         $FirstBody = GetValue('Body', $FirstComment);
         $FirstFormat = GetValue('Format', $FirstComment);
         $this->Description(SliceParagraph(Gdn_Format::PlainText($FirstBody, $FirstFormat), 160));
         // Add images to head for open graph
         $Dom = str_get_html(Gdn_Format::To($FirstBody, $FirstFormat));
     }
     if ($Dom) {
         foreach ($Dom->find('img') as $img) {
             if (isset($img->src)) {
                 $this->Image($img->src);
             }
         }
     }
     // Make sure to set the user's discussion watch records
     $this->CommentModel->SetWatch($this->Discussion, $Limit, $this->Offset, $this->Discussion->CountComments);
     // Build a pager
     $PagerFactory = new Gdn_PagerFactory();
     $this->EventArguments['PagerType'] = 'Pager';
     $this->FireEvent('BeforeBuildPager');
     $this->Pager = $PagerFactory->GetPager($this->EventArguments['PagerType'], $this);
     $this->Pager->ClientID = 'Pager';
     $this->Pager->Configure($this->Offset, $Limit, $ActualResponses, array('DiscussionUrl'));
     $this->Pager->Record = $this->Discussion;
     PagerModule::Current($this->Pager);
     $this->FireEvent('AfterBuildPager');
     // Define the form for the comment input
     $this->Form = Gdn::Factory('Form', 'Comment');
     $this->Form->Action = Url('/vanilla/post/comment/');
     $this->DiscussionID = $this->Discussion->DiscussionID;
     $this->Form->AddHidden('DiscussionID', $this->DiscussionID);
     $this->Form->AddHidden('CommentID', '');
     // Look in the session stash for a comment
     $StashComment = $Session->Stash('CommentForDiscussionID_' . $this->Discussion->DiscussionID, '', FALSE);
     if ($StashComment) {
         $this->Form->SetFormValue('Body', $StashComment);
     }
     // Retrieve & apply the draft if there is one:
     if (Gdn::Session()->UserID) {
         $DraftModel = new DraftModel();
         $Draft = $DraftModel->Get($Session->UserID, 0, 1, $this->Discussion->DiscussionID)->FirstRow();
         $this->Form->AddHidden('DraftID', $Draft ? $Draft->DraftID : '');
         if ($Draft && !$this->Form->IsPostBack()) {
             $this->Form->SetValue('Body', $Draft->Body);
             $this->Form->SetValue('Format', $Draft->Format);
         }
     }
     // Deliver JSON data if necessary
     if ($this->_DeliveryType != DELIVERY_TYPE_ALL) {
         $this->SetJson('LessRow', $this->Pager->ToString('less'));
         $this->SetJson('MoreRow', $this->Pager->ToString('more'));
         $this->View = 'comments';
     }
     // Inform moderator of checked comments in this discussion
     $CheckedComments = $Session->GetAttribute('CheckedComments', array());
     if (count($CheckedComments) > 0) {
         ModerationController::InformCheckedComments($this);
     }
     // Add modules
     $this->AddModule('DiscussionFilterModule');
     $this->AddModule('NewDiscussionModule');
     $this->AddModule('CategoriesModule');
     $this->AddModule('BookmarkedModule');
     $this->CanEditComments = Gdn::Session()->CheckPermission('Vanilla.Comments.Edit', TRUE, 'Category', 'any') && C('Vanilla.AdminCheckboxes.Use');
     // Report the discussion id so js can use it.
     $this->AddDefinition('DiscussionID', $DiscussionID);
     $this->FireEvent('BeforeDiscussionRender');
     $this->Render();
 }
Пример #15
0
        ?>
">
                    <?php 
        $DisplayName = TagFullName($Tag);
        if ($Special) {
            echo htmlspecialchars($DisplayName) . ' ' . Wrap($Tag['CountDiscussions'], 'span', array('class' => 'Count'));
        } else {
            echo anchor(htmlspecialchars($DisplayName) . ' ' . Wrap($Tag['CountDiscussions'], 'span', array('class' => 'Count')), "/settings/tags/edit/{$Tag['TagID']}", 'TagName Tag_' . str_replace(' ', '_', $Tag['Name']));
            echo ' ' . anchor('&times;', "/settings/tags/delete/{$Tag['TagID']}", 'Delete Popup');
        }
        ?>
                </div>
            <?php 
    }
}
?>

        <div class="add-new-tag">

            <?php 
if ($CanAddTags) {
    echo ' ' . anchor('Add Tag', '/settings/tags/add?type=' . $TagType, 'Popup Button');
}
?>

        </div>

    </div>
<?php 
PagerModule::write();
echo $this->Form->close();
Пример #16
0
<?php

if (!defined('APPLICATION')) {
    exit;
}
echo '<h2 class="H">' . T('Notifications') . '</h2>';
if (count($this->Data('Activities'))) {
    echo '<ul class="DataList Activities Notifications">';
    include $this->FetchViewLocation('activities', 'activity', 'dashboard');
    echo '</ul>';
    echo PagerModule::Write(array('CurrentRecords' => count($this->Data('Activities'))));
} else {
    ?>
<div class="Empty"><?php 
    echo T('You do not have any notifications yet.');
    ?>
</div>
   <?php 
}
Пример #17
0
?>
<div class="toolbar">
    <div class="toolbar-main">
        <?php 
$info = '';
$count = $this->data('RecordCount', $this->data('UserCount', null));
if ($count !== null) {
    $info = sprintf(plural($count, '%s user found.', '%s users found.'), $count);
} elseif ($this->data('UserEstimate', null) !== null) {
    $info = sprintf(t('Approximately %s users exist.'), $this->data('UserEstimate'));
}
echo $this->Form->searchForm('Keywords', '/user/browse', [], $info);
?>
    </div>
    <?php 
PagerModule::write(array('Sender' => $this, 'View' => 'pager-dashboard'));
?>
</div>
    <div class="table-wrap">
        <table id="Users" class="table-data js-tj">
            <thead>
            <tr>
                <!--         <th class="CheckboxCell"><input id="SelectAll" type="checkbox" /></th>-->
                <th class="column-lg"><?php 
echo anchor(t('Username'), $this->_OrderUrl('Name'));
?>
</th>
                <th><?php 
echo t('Roles');
?>
</th>
Пример #18
0
                <th><?php 
    echo t('Last IP');
    ?>
</th>
            <?php 
}
?>
            <?php 
$this->fireEvent('UserCell');
?>
            <?php 
if ($EditUser) {
    ?>
                <th><?php 
    echo t('Options');
    ?>
</th>
            <?php 
}
?>
        </tr>
        </thead>
        <tbody>
        <?php 
include $this->fetchViewLocation('users');
?>
        </tbody>
    </table>
<?php 
PagerModule::write(array('Sender' => $this));
echo $this->Form->close();
Пример #19
0
if (!defined('APPLICATION')) {
    exit;
}
?>
    <h1><?php 
echo $this->data('Title');
?>
</h1>
<?php 
helpAsset($this->data('Title'), t('Content flagged as spam is stored here for moderator review.'));
echo '<noscript><div class="Errors"><ul><li>', t('This page requires Javascript.'), '</li></ul></div></noscript>';
echo $this->Form->open();
?>
<div class="toolbar flex-wrap">
    <div class="toolbar-buttons">
        <?php 
echo anchor(t('Spam'), '#', array('class' => 'SpamButton btn btn-primary'));
echo anchor(t('Not Spam'), '#', array('class' => 'NotSpamButton btn btn-primary'));
?>
    </div>
    <?php 
PagerModule::write(['Sender' => $this, 'Limit' => 10, 'View' => 'pager-dashboard']);
?>
</div>
<?php 
echo '<div id="LogTable">';
include dirname(__FILE__) . '/table.php';
echo '</div id="LogTable">';
$this->addDefinition('ExpandText', t('more'));
$this->addDefinition('CollapseText', t('less'));
echo $this->Form->close();
Пример #20
0
<?php

if (!defined('APPLICATION')) {
    exit;
}
?>
<div class="toolbar">
<?php 
PagerModule::write(array('Sender' => $this, 'Limit' => 20, 'CurrentRecords' => count($this->data('Bans')), 'View' => 'pager-dashboard'));
?>
</div>
<div class="table-wrap">
    <table id="Log" class="table-data js-tj">
        <thead>
        <tr>
            <th class="column-lg"><?php 
echo t('Ban Item', 'Item');
?>
</th>
            <th><?php 
echo t('Ban Type', 'Type');
?>
</th>
            <th class="column-sm"><?php 
echo t('User Count', 'Users');
?>
</th>
            <th class="column-sm"><?php 
echo '<span title="' . t('Number of blocked registrations') . '">', t('Blocked'), '</span>';
?>
</th>