Пример #1
0
 /**
  * Override the index of the dashboard's settings controller in the to render new statistics.
  *
  * @param SettingsController $sender Instance of the dashboard's settings controller.
  */
 public function settingsController_home_create($sender)
 {
     $statsUrl = $this->AnalyticsServer;
     if (!stringBeginsWith($statsUrl, 'http:') && !stringBeginsWith($statsUrl, 'https:')) {
         $statsUrl = Gdn::request()->scheme() . "://{$statsUrl}";
     }
     Gdn_Theme::section('DashboardHome');
     $sender->setData('IsWidePage', true);
     // Tell the page where to find the Vanilla Analytics provider
     $sender->addDefinition('VanillaStatsUrl', $statsUrl);
     $sender->setData('VanillaStatsUrl', $statsUrl);
     // Load javascript & css, check permissions, and load side menu for this page.
     $sender->addJsFile('settings.js');
     $sender->title(t('Dashboard'));
     $sender->RequiredAdminPermissions = ['Garden.Settings.View', 'Garden.Settings.Manage', 'Garden.Community.Manage'];
     $sender->fireEvent('DefineAdminPermissions');
     $sender->permission($sender->RequiredAdminPermissions, '', false);
     $sender->setHighlightRoute('dashboard/settings');
     if (!Gdn_Statistics::checkIsEnabled() && Gdn_Statistics::checkIsLocalhost()) {
         $sender->render('dashboardlocalhost', '', 'plugins/VanillaStats');
     } else {
         $sender->addCssFile('picker.css', 'plugins/VanillaStats');
         $sender->addCssFile('vendors/c3.min.css', 'plugins/VanillaStats');
         $sender->addJsFile('vanillastats.js', 'plugins/VanillaStats');
         $sender->addJsFile('picker.js', 'plugins/VanillaStats');
         $sender->addJsFile('d3.min.js');
         $sender->addJsFile('c3.min.js');
         $sender->addDefinition('VanillaID', Gdn::installationID());
         $sender->addDefinition('AuthToken', Gdn_Statistics::generateToken());
         $sender->addDefinition('ExpandText', t('more'));
         $sender->addDefinition('CollapseText', t('less'));
         // Render the custom dashboard view
         $sender->render('dashboard', '', 'plugins/VanillaStats');
     }
 }
Пример #2
0
 /**
  * List all tags and allow searching
  *
  * @param SettingsController $Sender
  */
 public function settingsController_tagging_create($Sender, $Search = null, $Type = null, $Page = null)
 {
     $Sender->title('Tagging');
     $Sender->setHighlightRoute('settings/tagging');
     $Sender->addJSFile('tagadmin.js', 'plugins/Tagging');
     $SQL = Gdn::sql();
     // Get all tag types
     $TagModel = TagModel::instance();
     $TagTypes = $TagModel->getTagTypes();
     $Sender->Form->Method = 'get';
     list($Offset, $Limit) = offsetLimit($Page, 100);
     $Sender->setData('_Limit', $Limit);
     if ($Search) {
         $SQL->like('Name', $Search, 'right');
     }
     $queryType = $Type;
     if (strtolower($Type) == 'all' || $Search || $Type === null) {
         $queryType = false;
         $Type = '';
     }
     // This type doesn't actually exist, but it will represent the
     // blank types in the column.
     if (strtolower($Type) == 'tags') {
         $queryType = '';
     }
     if (!$Search && $queryType !== false) {
         $SQL->where('Type', $queryType);
     }
     $TagTypes = array_change_key_case($TagTypes, CASE_LOWER);
     // Store type for view
     $TagType = !empty($Type) ? $Type : 'All';
     $Sender->setData('_TagType', $TagType);
     // Store tag types
     $Sender->setData('_TagTypes', $TagTypes);
     // Determine if new tags can be added for the current type.
     $CanAddTags = !empty($TagTypes[$Type]['addtag']) && $TagTypes[$Type]['addtag'] ? 1 : 0;
     $CanAddTags &= CheckPermission('Plugins.Tagging.Add');
     $Sender->setData('_CanAddTags', $CanAddTags);
     $Data = $SQL->select('t.*')->from('Tag t')->orderBy('t.CountDiscussions', 'desc')->limit($Limit, $Offset)->get()->resultArray();
     $Sender->setData('Tags', $Data);
     if ($Search) {
         $SQL->like('Name', $Search, 'right');
     }
     // Make sure search uses its own search type, so results appear
     // in their own tab.
     $Sender->Form->Action = url('/settings/tagging/?type=' . $TagType);
     // Search results pagination will mess up a bit, so don't provide a type
     // in the count.
     $RecordCountWhere = array('Type' => $queryType);
     if ($queryType === false) {
         $RecordCountWhere = [];
     }
     if ($Search) {
         $RecordCountWhere = array();
     }
     $Sender->setData('RecordCount', $SQL->getCount('Tag', $RecordCountWhere));
     $Sender->render('tagging', '', 'plugins/Tagging');
 }