/** * The Index method of the VWP setting page. * * @param SettingsController $sender */ public function Controller_Index($sender) { // Set required permission. $sender->permission('Garden.Settings.Manage'); // Set up the configuration module. $configModule = new ConfigurationModule($sender); $configModule->initialize(array('VWP.Database.User' => array('LabelCode' => 'WordPress Database User', 'Control' => 'TextBox'), 'VWP.Database.Password' => array('LabelCode' => 'WordPress Database Password', 'Control' => 'TextBox'), 'VWP.Database.Name' => array('LabelCode' => 'WordPress Database Name', 'Control' => 'TextBox'), 'VWP.Database.Prefix' => array('LabelCode' => 'WordPress Database Prefix', 'Control' => 'TextBox'))); $sender->ConfigurationModule = $configModule; $sender->title(T('VWP Settings')); $sender->addSideMenu('/settings/vwp'); $sender->View = $sender->fetchViewLocation('vwp', 'settings', 'vwp'); $sender->render(); }
/** * 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->addSideMenu('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'; $Sender->Form->InputPrefix = ''; list($Offset, $Limit) = offsetLimit($Page, 100); $Sender->setData('_Limit', $Limit); if ($Search) { $SQL->like('FullName', $Search, 'right'); } // This type doesn't actually exist, but it will represent the // blank types in the column. if (strtolower($Type) == 'tags') { $Type = ''; } if (!$Search) { if ($Type !== null) { if ($Type === 'null') { $Type = null; } $SQL->where('Type', $Type); } elseif ($Type == '') { $SQL->where('Type', ''); } } else { $Type = 'Search Results'; // This is made up, and exists so search results can be placed in // their own tab. $TagTypes[$Type] = array('key' => $Type); } $TagTypes = array_change_key_case($TagTypes, CASE_LOWER); // Store type for view $TagType = !empty($Type) ? $Type : 'Tags'; $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.FullName', 'asc')->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' => $Type); if ($Type == '') { $RecordCountWhere = array('Type' => ''); } if ($Search) { $RecordCountWhere = array(); } $Sender->setData('RecordCount', $SQL->getCount('Tag', $RecordCountWhere)); $Sender->render('tagging', '', 'plugins/Tagging'); }
/** * 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'); } }