public function PluginController_Embed_Create($Sender) { $Sender->Permission('Garden.Settings.Manage'); $Sender->Title('Embed Vanilla'); $Sender->AddCssFile($this->GetResource('design/settings.css', FALSE, FALSE)); $Sender->AddSideMenu('plugin/embed'); $Sender->Form = new Gdn_Form(); $ThemeManager = new Gdn_ThemeManager(); $Sender->SetData('AvailableThemes', $ThemeManager->AvailableThemes()); $Sender->SetData('EnabledThemeFolder', $ThemeManager->EnabledTheme()); $Sender->SetData('EnabledTheme', $ThemeManager->EnabledThemeInfo()); $Sender->SetData('EnabledThemeName', $Sender->Data('EnabledTheme.Name', $Sender->Data('EnabledTheme.Folder'))); $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('Plugins.EmbedVanilla.RemoteUrl', 'Plugins.EmbedVanilla.ForceRemoteUrl', 'Plugins.EmbedVanilla.EmbedDashboard')); $Sender->Form->SetModel($ConfigurationModel); if ($Sender->Form->AuthenticatedPostBack() === FALSE) { // Apply the config settings to the form. $Sender->Form->SetData($ConfigurationModel->Data); } else { // Define some validation rules for the fields being saved $ConfigurationModel->Validation->ApplyRule('Plugins.EmbedVanilla.RemoteUrl', 'WebAddress', 'The remote url you specified could not be validated as a functional url to redirect to.'); if ($Sender->Form->Save() !== FALSE) $Sender->InformMessage(T("Your settings have been saved.")); } // Handle changing the theme to the recommended one $ThemeFolder = GetValue(0, $Sender->RequestArgs); $TransientKey = GetValue(1, $Sender->RequestArgs); $Session = Gdn::Session(); if ($Session->ValidateTransientKey($TransientKey) && $ThemeFolder != '') { try { foreach ($Sender->Data('AvailableThemes') as $ThemeName => $ThemeInfo) { if ($ThemeInfo['Folder'] == $ThemeFolder) $ThemeManager->EnableTheme($ThemeName); } } catch (Exception $Ex) { $Sender->Form->AddError($Ex); } if ($Sender->Form->ErrorCount() == 0) Redirect('/plugin/embed'); } $Sender->Render(PATH_PLUGINS.'/embedvanilla/views/settings.php'); }
public function PreviewTheme($ThemeFolder = '') { $this->Permission('Garden.Themes.Manage'); $ThemeManager = new Gdn_ThemeManager(); $this->AvailableThemes = $ThemeManager->AvailableThemes(); $PreviewThemeName = ''; $PreviewThemeFolder = $ThemeFolder; foreach ($this->AvailableThemes as $ThemeName => $ThemeInfo) { if ($ThemeInfo['Folder'] == $ThemeFolder) { $PreviewThemeName = $ThemeName; } } // If we failed to get the requested theme, default back to the one currently enabled if ($PreviewThemeName == '') { $this->ThemeName = $ThemeManager->EnabledTheme(); foreach ($this->AvailableThemes as $ThemeName => $ThemeInfo) { if ($ThemeName == $PreviewThemeName) { $PreviewThemeFolder = $ThemeInfo['Folder']; } } } Gdn::Session()->SetPreference(array('PreviewThemeName' => $PreviewThemeName, 'PreviewThemeFolder' => $PreviewThemeFolder)); Redirect('/'); }
/** * * * @param bool $Enabled * @return array */ public function getAddons($Enabled = false) { $Addons = array(); // Get the core. self::_AddAddon(array('AddonKey' => 'vanilla', 'AddonType' => 'core', 'Version' => APPLICATION_VERSION, 'Folder' => '/'), $Addons); // Get a list of all of the applications. $ApplicationManager = new Gdn_ApplicationManager(); if ($Enabled) { $Applications = $ApplicationManager->AvailableApplications(); } else { $Applications = $ApplicationManager->EnabledApplications(); } foreach ($Applications as $Key => $Info) { // Exclude core applications. if (in_array(strtolower($Key), array('conversations', 'dashboard', 'skeleton', 'vanilla'))) { continue; } $Addon = array('AddonKey' => $Key, 'AddonType' => 'application', 'Version' => val('Version', $Info, '0.0'), 'Folder' => '/applications/' . GetValue('Folder', $Info, strtolower($Key))); self::_AddAddon($Addon, $Addons); } // Get a list of all of the plugins. $PluginManager = Gdn::pluginManager(); if ($Enabled) { $Plugins = $PluginManager->EnabledPlugins(); } else { $Plugins = $PluginManager->AvailablePlugins(); } foreach ($Plugins as $Key => $Info) { // Exclude core plugins. if (in_array(strtolower($Key), array())) { continue; } $Addon = array('AddonKey' => $Key, 'AddonType' => 'plugin', 'Version' => val('Version', $Info, '0.0'), 'Folder' => '/applications/' . GetValue('Folder', $Info, $Key)); self::_AddAddon($Addon, $Addons); } // Get a list of all the themes. $ThemeManager = new Gdn_ThemeManager(); if ($Enabled) { $Themes = $ThemeManager->EnabledThemeInfo(true); } else { $Themes = $ThemeManager->AvailableThemes(); } foreach ($Themes as $Key => $Info) { // Exclude core themes. if (in_array(strtolower($Key), array('default'))) { continue; } $Addon = array('AddonKey' => $Key, 'AddonType' => 'theme', 'Version' => val('Version', $Info, '0.0'), 'Folder' => '/themes/' . GetValue('Folder', $Info, $Key)); self::_AddAddon($Addon, $Addons); } // Get a list of all locales. $LocaleModel = new LocaleModel(); if ($Enabled) { $Locales = $LocaleModel->EnabledLocalePacks(true); } else { $Locales = $LocaleModel->AvailableLocalePacks(); } foreach ($Locales as $Key => $Info) { // Exclude core themes. if (in_array(strtolower($Key), array('skeleton'))) { continue; } $Addon = array('AddonKey' => $Key, 'AddonType' => 'locale', 'Version' => val('Version', $Info, '0.0'), 'Folder' => '/locales/' . GetValue('Folder', $Info, $Key)); self::_AddAddon($Addon, $Addons); } return $Addons; }
/** * Adds information to the definition list that causes the app to "phone * home" and see if there are upgrades available. * * Currently added to the dashboard only. Nothing renders with this method. * It is public so it can be added by plugins. */ public function AddUpdateCheck() { if (C('Garden.NoUpdateCheck')) { return; } // Check to see if the application needs to phone-home for updates. Doing // this here because this method is always called when admin pages are // loaded regardless of the application loading them. $UpdateCheckDate = Gdn::Config('Garden.UpdateCheckDate', ''); if ($UpdateCheckDate == '' || !IsTimestamp($UpdateCheckDate) || $UpdateCheckDate < strtotime("-1 day")) { $UpdateData = array(); // Grab all of the plugins & versions $Plugins = Gdn::PluginManager()->AvailablePlugins(); foreach ($Plugins as $Plugin => $Info) { $Name = ArrayValue('Name', $Info, $Plugin); $Version = ArrayValue('Version', $Info, ''); if ($Version != '') { $UpdateData[] = array('Name' => $Name, 'Version' => $Version, 'Type' => 'Plugin'); } } // Grab all of the applications & versions $ApplicationManager = Gdn::Factory('ApplicationManager'); $Applications = $ApplicationManager->AvailableApplications(); foreach ($Applications as $Application => $Info) { $Name = ArrayValue('Name', $Info, $Application); $Version = ArrayValue('Version', $Info, ''); if ($Version != '') { $UpdateData[] = array('Name' => $Name, 'Version' => $Version, 'Type' => 'Application'); } } // Grab all of the themes & versions $ThemeManager = new Gdn_ThemeManager(); $Themes = $ThemeManager->AvailableThemes(); foreach ($Themes as $Theme => $Info) { $Name = ArrayValue('Name', $Info, $Theme); $Version = ArrayValue('Version', $Info, ''); if ($Version != '') { $UpdateData[] = array('Name' => $Name, 'Version' => $Version, 'Type' => 'Theme'); } } // Dump the entire set of information into the definition list (jQuery // will pick it up and ping the VanillaForums.org server with this info). $this->AddDefinition('UpdateChecks', Gdn_Format::Serialize($UpdateData)); } }
public function PreviewTheme($ThemeFolder = '') { $this->Permission('Garden.Themes.Manage'); $ThemeManager = new Gdn_ThemeManager(); $this->AvailableThemes = $ThemeManager->AvailableThemes(); $PreviewThemeName = ''; $PreviewThemeFolder = $ThemeFolder; foreach ($this->AvailableThemes as $ThemeName => $ThemeInfo) { if ($ThemeInfo['Folder'] == $ThemeFolder) { $PreviewThemeName = $ThemeName; } } // If we failed to get the requested theme, default back to the one currently enabled if ($PreviewThemeName == '') { $this->ThemeName = $ThemeManager->EnabledTheme(); foreach ($this->AvailableThemes as $ThemeName => $ThemeInfo) { if ($ThemeName == $PreviewThemeName) { $PreviewThemeFolder = $ThemeInfo['Folder']; } } } // Check for errors $Session = Gdn::Session(); $Test = ProxyRequest(Url('/dashboard/settings/testaddon/Theme/' . $ThemeName . '/' . $Session->TransientKey() . '?DeliveryType=JSON', TRUE)); if ($Test != 'Success') { $this->Form->AddError(sprintf(T('The theme could not be previewed because it generated a fatal error: <pre>%s</pre>'), strip_tags($Test))); $this->View = 'themes'; $this->Themes(); } else { $Session->SetPreference(array('PreviewThemeName' => $PreviewThemeName, 'PreviewThemeFolder' => $PreviewThemeFolder)); Redirect('/'); } }
public function PreviewTheme($ThemeFolder = '') { $this->Title(Translate('Theme Preview')); // Clear out all css & js and use the "empty" master view $this->MasterView = 'empty'; $this->_CssFiles = array(); $this->Head->ClearScripts(); // Add jquery, custom css & js $this->AddCssFile('previewtheme.css'); $this->AddJsFile('js/library/jquery.js'); $this->AddJsFile('previewtheme.js'); $this->Permission('Garden.Themes.Manage'); $ThemeManager = new Gdn_ThemeManager(); $this->AvailableThemes = $ThemeManager->AvailableThemes(); $this->ThemeName = ''; $this->ThemeFolder = $ThemeFolder; foreach ($this->AvailableThemes as $ThemeName => $ThemeInfo) { if ($ThemeInfo['Folder'] == $ThemeFolder) { $this->ThemeName = $ThemeName; } } // If we failed to get the requested theme, default back to the one currently enabled if ($this->ThemeName == '') { $this->ThemeName = $ThemeManager->EnabledTheme(); foreach ($this->AvailableThemes as $ThemeName => $ThemeInfo) { if ($ThemeName == $this->ThemeName) { $this->ThemeFolder = $ThemeInfo['Folder']; } } } $Session = Gdn::Session(); $UserModel = Gdn::UserModel(); $UserModel->SavePreference($Session->UserID, 'PreviewTheme', $this->ThemeFolder); $this->Render(); }