/** * Emulate a call to index.php?p=$vanilla_module_path * Much of this ripped out of Vanilla's index.php */ public function view($segments) { // if a static asset, return it outright $asset = $this->is_static_asset($segments); if ($asset) { return \Response::make(\File::get($asset))->header('Content-Type', $this->get_content_type($asset)); } // otherwise, dispatch into vanilla $user = $this->user; $bootstrap = new VanillaBootstrap(); $bootstrap->call(function () use($user, $segments) { // Create the session and stuff the user in \Gdn::Authenticator()->SetIdentity($user->getKey(), false); \Gdn::Session()->Start(false, false); \Gdn::Session()->SetPreference('Authenticator', 'Gdn_Authenticator'); // Create and configure the dispatcher. $Dispatcher = \Gdn::Dispatcher(); $EnabledApplications = \Gdn::ApplicationManager()->EnabledApplicationFolders(); $Dispatcher->EnabledApplicationFolders($EnabledApplications); $Dispatcher->PassProperty('EnabledApplications', $EnabledApplications); // Process the request. $Dispatcher->Start(); $Dispatcher->Dispatch(implode('/', $segments)); }); }
/** * Set user's preferred locale. * * Moved event from AppStart to AfterAnalyzeRequest to allow Embed to set P3P header first. */ public function Gdn_Dispatcher_AfterAnalyzeRequest_Handler($Sender) { // Set user preference if ($TempLocale = $this->GetAlternateLocale()) { Gdn::Locale()->Set($TempLocale, Gdn::ApplicationManager()->EnabledApplicationFolders(), Gdn::PluginManager()->EnabledPluginFolders()); } }
/** * Attach mappings for vanilla extension folders * * @param string $ExtensionType type of extension to map. one of: CONTEXT_THEME, CONTEXT_PLUGIN, CONTEXT_APPLICATION */ public static function Attach($ExtensionType) { switch ($ExtensionType) { case self::CONTEXT_APPLICATION: if (Gdn::ApplicationManager() instanceof Gdn_ApplicationManager) { $EnabledApplications = Gdn::ApplicationManager()->EnabledApplicationFolders(); foreach ($EnabledApplications as $EnabledApplication) { self::AttachApplication($EnabledApplication); } } break; case self::CONTEXT_PLUGIN: if (Gdn::PluginManager() instanceof Gdn_PluginManager) { foreach (Gdn::PluginManager()->SearchPaths() as $SearchPath => $SearchPathName) { if ($SearchPathName === TRUE || $SearchPathName == 1) { $SearchPathName = md5($SearchPath); } // If we have already loaded the plugin manager, use its internal folder list if (Gdn::PluginManager()->Started()) { $Folders = Gdn::PluginManager()->EnabledPluginFolders($SearchPath); foreach ($Folders as $PluginFolder) { $FullPluginPath = CombinePaths(array($SearchPath, $PluginFolder)); self::RegisterMap(self::MAP_LIBRARY, self::CONTEXT_PLUGIN, $FullPluginPath, array('SearchSubfolders' => TRUE, 'Extension' => $SearchPathName, 'Structure' => Gdn_Autoloader_Map::STRUCTURE_SPLIT, 'SplitTopic' => strtolower($PluginFolder))); } } } } break; case self::CONTEXT_THEME: break; } }
/** * Reload the locale system */ public function Refresh() { $LocalName = $this->Current(); $ApplicationWhiteList = Gdn::ApplicationManager()->EnabledApplicationFolders(); $PluginWhiteList = Gdn::PluginManager()->EnabledPluginFolders(); $ForceRemapping = TRUE; $this->Set($LocalName, $ApplicationWhiteList, $PluginWhiteList, $ForceRemapping); }
public function __construct() { parent::__construct(); if (Gdn::PluginManager()->CheckPlugin('Reactions') && C('Plugins.QnA.Reactions', TRUE)) { $this->Reactions = TRUE; } if (Gdn::ApplicationManager()->CheckApplication('Reputation') && C('Plugins.QnA.Badges', TRUE)) { $this->Badges = TRUE; } }
/** * Returns the name of the enabled application based on $ApplicationFolder. * * @param string The application folder related to the application name you want to return. */ public function EnabledApplication($ApplicationFolder = '') { if ($ApplicationFolder == '') { $ApplicationFolder = $this->_ApplicationFolder; } foreach (Gdn::ApplicationManager()->AvailableApplications() as $ApplicationName => $ApplicationInfo) { if (GetValue('Folder', $ApplicationInfo, FALSE) === $ApplicationFolder) { $EnabledApplication = $ApplicationName; $this->EventArguments['EnabledApplication'] = $EnabledApplication; $this->FireEvent('AfterEnabledApplication'); return $EnabledApplication; } } return FALSE; }
$CNotifications = is_numeric($CountNotifications) && $CountNotifications > 0 ? '<span class="Alert">' . $CountNotifications . '</span>' : ''; echo '<span class="ToggleFlyout" rel="/profile/notificationspopin">'; echo Anchor(Sprite('SpNotifications', 'Sprite Sprite16') . Wrap(T('Notifications'), 'em') . $CNotifications, UserUrl($User), 'MeButton FlyoutButton', array('title' => T('Notifications'))); echo Sprite('SpFlyoutHandle', 'Arrow'); echo '<div class="Flyout FlyoutMenu"></div></span>'; // Inbox if (Gdn::ApplicationManager()->CheckApplication('Conversations')) { $CountInbox = GetValue('CountUnreadConversations', Gdn::Session()->User); $CInbox = is_numeric($CountInbox) && $CountInbox > 0 ? ' <span class="Alert">' . $CountInbox . '</span>' : ''; echo '<span class="ToggleFlyout" rel="/messages/popin">'; echo Anchor(Sprite('SpInbox', 'Sprite Sprite16') . Wrap(T('Inbox'), 'em') . $CInbox, '/messages/all', 'MeButton FlyoutButton', array('title' => T('Inbox'))); echo Sprite('SpFlyoutHandle', 'Arrow'); echo '<div class="Flyout FlyoutMenu"></div></span>'; } // Bookmarks if (Gdn::ApplicationManager()->CheckApplication('Vanilla')) { echo '<span class="ToggleFlyout" rel="/discussions/bookmarkedpopin">'; echo Anchor(Sprite('SpBookmarks', 'Sprite Sprite16') . Wrap(T('Bookmarks'), 'em'), '/discussions/bookmarked', 'MeButton FlyoutButton', array('title' => T('Bookmarks'))); echo Sprite('SpFlyoutHandle', 'Arrow'); echo '<div class="Flyout FlyoutMenu"></div></span>'; } // Profile Settings & Logout echo '<span class="ToggleFlyout">'; $CDashboard = $DashboardCount > 0 ? Wrap($DashboardCount, 'span class="Alert"') : ''; echo Anchor(Sprite('SpOptions', 'Sprite Sprite16') . Wrap(T('Account Options'), 'em') . $CDashboard, '/profile/edit', 'MeButton FlyoutButton', array('title' => T('Account Options'))); echo Sprite('SpFlyoutHandle', 'Arrow'); echo '<div class="Flyout MenuItems">'; echo '<ul>'; // echo Wrap(Wrap(T('My Account'), 'strong'), 'li'); // echo Wrap('<hr />', 'li'); echo Wrap(Anchor(Sprite('SpEditProfile') . ' ' . T('Edit Profile'), 'profile/edit'), 'li');
public static function Link($Path, $Text = FALSE, $Format = NULL, $Options = array()) { $Session = Gdn::Session(); $Class = GetValue('class', $Options, ''); $WithDomain = GetValue('WithDomain', $Options); $Target = GetValue('Target', $Options, ''); if ($Target == 'current') { $Target = trim(Url('', TRUE), '/ '); } if (is_null($Format)) { $Format = '<a href="%url" class="%class">%text</a>'; } switch ($Path) { case 'activity': TouchValue('Permissions', $Options, 'Garden.Activity.View'); break; case 'category': $Breadcrumbs = Gdn::Controller()->Data('Breadcrumbs'); if (is_array($Breadcrumbs) && count($Breadcrumbs) > 0) { $Last = array_pop($Breadcrumbs); $Path = GetValue('Url', $Last); $DefaultText = GetValue('Name', $Last, T('Back')); } else { $Path = '/'; $DefaultText = C('Garden.Title', T('Back')); } if (!$Text) { $Text = $DefaultText; } break; case 'dashboard': $Path = 'dashboard/settings'; TouchValue('Permissions', $Options, array('Garden.Settings.Manage', 'Garden.Settings.View')); if (!$Text) { $Text = T('Dashboard'); } break; case 'home': $Path = '/'; if (!$Text) { $Text = T('Home'); } break; case 'inbox': $Path = 'messages/inbox'; TouchValue('Permissions', $Options, 'Garden.SignIn.Allow'); if (!$Text) { $Text = T('Inbox'); } if ($Session->IsValid() && $Session->User->CountUnreadConversations) { $Class = trim($Class . ' HasCount'); $Text .= ' <span class="Alert">' . $Session->User->CountUnreadConversations . '</span>'; } if (!$Session->IsValid() || !Gdn::ApplicationManager()->CheckApplication('Conversations')) { $Text = FALSE; } break; case 'forumroot': $Route = Gdn::Router()->GetDestination('DefaultForumRoot'); if (is_null($Route)) { $Path = '/'; } else { $Path = CombinePaths(array('/', $Route)); } break; case 'profile': TouchValue('Permissions', $Options, 'Garden.SignIn.Allow'); if (!$Text && $Session->IsValid()) { $Text = $Session->User->Name; } if ($Session->IsValid() && $Session->User->CountNotifications) { $Class = trim($Class . ' HasCount'); $Text .= ' <span class="Alert">' . $Session->User->CountNotifications . '</span>'; } break; case 'user': $Path = 'profile'; TouchValue('Permissions', $Options, 'Garden.SignIn.Allow'); if (!$Text && $Session->IsValid()) { $Text = $Session->User->Name; } break; case 'photo': $Path = 'profile'; TouchValue('Permissions', $Options, 'Garden.SignIn.Allow'); if (!$Text && $Session->IsValid()) { $IsFullPath = strtolower(substr($Session->User->Photo, 0, 7)) == 'http://' || strtolower(substr($Session->User->Photo, 0, 8)) == 'https://'; $PhotoUrl = $IsFullPath ? $Session->User->Photo : Gdn_Upload::Url(ChangeBasename($Session->User->Photo, 'n%s')); $Text = Img($PhotoUrl, array('alt' => htmlspecialchars($Session->User->Name))); } break; case 'drafts': TouchValue('Permissions', $Options, 'Garden.SignIn.Allow'); if (!$Text) { $Text = T('My Drafts'); } if ($Session->IsValid() && $Session->User->CountDrafts) { $Class = trim($Class . ' HasCount'); $Text .= ' <span class="Alert">' . $Session->User->CountDrafts . '</span>'; } break; case 'discussions/bookmarked': TouchValue('Permissions', $Options, 'Garden.SignIn.Allow'); if (!$Text) { $Text = T('My Bookmarks'); } if ($Session->IsValid() && $Session->User->CountBookmarks) { $Class = trim($Class . ' HasCount'); $Text .= ' <span class="Count">' . $Session->User->CountBookmarks . '</span>'; } break; case 'discussions/mine': TouchValue('Permissions', $Options, 'Garden.SignIn.Allow'); if (!$Text) { $Text = T('My Discussions'); } if ($Session->IsValid() && $Session->User->CountDiscussions) { $Class = trim($Class . ' HasCount'); $Text .= ' <span class="Count">' . $Session->User->CountDiscussions . '</span>'; } break; case 'register': if (!$Text) { $Text = T('Register'); } $Path = RegisterUrl($Target); break; case 'signin': case 'signinout': // The destination is the signin/signout toggle link. if ($Session->IsValid()) { if (!$Text) { $Text = T('Sign Out'); } $Path = SignOutUrl($Target); $Class = ConcatSep(' ', $Class, 'SignOut'); } else { if (!$Text) { $Text = T('Sign In'); } $Path = SignInUrl($Target); if (SignInPopup() && strpos(Gdn::Request()->Url(), 'entry') === FALSE) { $Class = ConcatSep(' ', $Class, 'SignInPopup'); } } break; } if ($Text == FALSE && strpos($Format, '%text') !== FALSE) { return ''; } if (GetValue('Permissions', $Options) && !$Session->CheckPermission($Options['Permissions'], FALSE)) { return ''; } $Url = Gdn::Request()->Url($Path, $WithDomain); if ($TK = GetValue('TK', $Options)) { if (in_array($TK, array(1, 'true'))) { $TK = 'TransientKey'; } $Url .= (strpos($Url, '?') === FALSE ? '?' : '&') . $TK . '=' . urlencode(Gdn::Session()->TransientKey()); } if (strcasecmp(trim($Path, '/'), Gdn::Request()->Path()) == 0) { $Class = ConcatSep(' ', $Class, 'Selected'); } // Build the final result. $Result = $Format; $Result = str_replace('%url', $Url, $Result); $Result = str_replace('%text', $Text, $Result); $Result = str_replace('%class', $Class, $Result); return $Result; }
/** Generate an e-tag for the application from the versions of all of its enabled applications/plugins. **/ public static function ETag() { $Data = array(); $Data['vanilla-core-' . APPLICATION_VERSION] = TRUE; $Plugins = Gdn::PluginManager()->EnabledPlugins(); foreach ($Plugins as $Info) { $Data[strtolower("{$Info['Index']}-plugin-{$Info['Version']}")] = TRUE; } // echo(Gdn_Upload::FormatFileSize(strlen(serialize($Plugins)))); // decho($Plugins); $Applications = Gdn::ApplicationManager()->EnabledApplications(); foreach ($Applications as $Info) { $Data[strtolower("{$Info['Index']}-app-{$Info['Version']}")] = TRUE; } // Add the desktop theme version. $Info = Gdn::ThemeManager()->GetThemeInfo(Gdn::ThemeManager()->DesktopTheme()); if (!empty($Info)) { $Version = GetValue('Version', $Info, 'v0'); $Data[strtolower("{$Info['Index']}-theme-{$Version}")] = TRUE; if (Gdn::Controller()->Theme && Gdn::Controller()->ThemeOptions) { $Filenames = GetValueR('Styles.Value', Gdn::Controller()->ThemeOptions); $Data[$Filenames] = TRUE; } } // Add the mobile theme version. $Info = Gdn::ThemeManager()->GetThemeInfo(Gdn::ThemeManager()->MobileTheme()); if (!empty($Info)) { $Version = GetValue('Version', $Info, 'v0'); $Data[strtolower("{$Info['Index']}-theme-{$Version}")] = TRUE; } Gdn::PluginManager()->EventArguments['ETagData'] =& $Data; $Suffix = ''; Gdn::PluginManager()->EventArguments['Suffix'] =& $Suffix; Gdn::PluginManager()->FireAs('AssetModel')->FireEvent('GenerateETag'); unset(Gdn::PluginManager()->EventArguments['ETagData']); ksort($Data); $Result = substr(md5(implode(',', array_keys($Data))), 0, 8) . $Suffix; // decho($Data); // die(); return $Result; }
/** * Takes the path to an asset (image, js file, css file, etc) and prepends the webroot. * * @param string $Destination * @param boolean $WithDomain * @param boolean $AddVersion * @param string $Version Forced version, skips auto-lookup. * @return string */ function asset($Destination = '', $WithDomain = false, $AddVersion = false, $Version = null) { $Destination = str_replace('\\', '/', $Destination); if (IsUrl($Destination)) { $Result = $Destination; } else { $Result = Gdn::Request()->UrlDomain($WithDomain) . Gdn::Request()->AssetRoot() . '/' . ltrim($Destination, '/'); } if ($AddVersion) { if (strpos($Result, '?') === false) { $Result .= '?'; } else { $Result .= '&'; } // Figure out which version to put after the asset. if (is_null($Version)) { $Version = APPLICATION_VERSION; if (preg_match('`^/([^/]+)/([^/]+)/`', $Destination, $Matches)) { $Type = $Matches[1]; $Key = $Matches[2]; static $ThemeVersion = null; switch ($Type) { case 'plugins': $PluginInfo = Gdn::PluginManager()->GetPluginInfo($Key); $Version = val('Version', $PluginInfo, $Version); break; case 'applications': $AppInfo = Gdn::ApplicationManager()->GetApplicationInfo(ucfirst($Key)); $Version = val('Version', $AppInfo, $Version); break; case 'themes': if ($ThemeVersion === null) { $ThemeInfo = Gdn::ThemeManager()->GetThemeInfo(Theme()); if ($ThemeInfo !== false) { $ThemeVersion = val('Version', $ThemeInfo, $Version); } else { $ThemeVersion = $Version; } } $Version = $ThemeVersion; break; } } } $Result .= 'v=' . urlencode($Version); } return $Result; }
/** * Attach mappings for vanilla extension folders * * @param string $ExtensionType type of extension to map. one of: CONTEXT_THEME, CONTEXT_PLUGIN, CONTEXT_APPLICATION */ public static function Attach($ExtensionType) { switch ($ExtensionType) { case self::CONTEXT_APPLICATION: if (Gdn::ApplicationManager() instanceof Gdn_ApplicationManager) { $EnabledApplications = Gdn::ApplicationManager()->EnabledApplicationFolders(); foreach ($EnabledApplications as $EnabledApplication) { $ApplicationPath = CombinePaths(array(PATH_APPLICATIONS."/{$EnabledApplication}")); $AppControllers = CombinePaths(array($ApplicationPath."/controllers")); self::RegisterMap(self::MAP_CONTROLLER, self::CONTEXT_APPLICATION, $AppControllers, array( 'SearchSubfolders' => FALSE, 'Extension' => $EnabledApplication )); $AppModels = CombinePaths(array($ApplicationPath."/models")); self::RegisterMap(self::MAP_LIBRARY, self::CONTEXT_APPLICATION, $AppModels, array( 'SearchSubfolders' => FALSE, 'Extension' => $EnabledApplication, 'ClassFilter' => '*model' )); $AppModules = CombinePaths(array($ApplicationPath."/modules")); self::RegisterMap(self::MAP_LIBRARY, self::CONTEXT_APPLICATION, $AppModules, array( 'SearchSubfolders' => FALSE, 'Extension' => $EnabledApplication, 'ClassFilter' => '*module' )); $AppLibrary = CombinePaths(array($ApplicationPath."/library")); self::RegisterMap(self::MAP_LIBRARY, self::CONTEXT_APPLICATION, $AppLibrary, array( 'SearchSubfolders' => FALSE, 'Extension' => $EnabledApplication, 'ClassFilter' => '*' )); } } break; case self::CONTEXT_PLUGIN: if (Gdn::PluginManager() instanceof Gdn_PluginManager) { foreach (Gdn::PluginManager()->SearchPaths() as $SearchPath => $SearchPathName) { if ($SearchPathName === TRUE || $SearchPathName == 1) $SearchPathName = md5($SearchPath); // If we have already loaded the plugin manager, use its internal folder list if (Gdn::PluginManager()->Started()) { $Folders = Gdn::PluginManager()->EnabledPluginFolders($SearchPath); foreach ($Folders as $PluginFolder) { $FullPluginPath = CombinePaths(array($SearchPath, $PluginFolder)); self::RegisterMap(self::MAP_LIBRARY, self::CONTEXT_PLUGIN, $FullPluginPath, array( 'SearchSubfolders' => TRUE, 'Extension' => $SearchPathName )); } } } } break; case self::CONTEXT_THEME: break; } }
// To run queries. $Construct = $Database->Structure(); // To modify and add database tables. $Validation = new Gdn_Validation(); // To validate permissions (if necessary). include_once PATH_APPLICATIONS . '/candy/models/class.sectionmodel.php'; include_once PATH_APPLICATIONS . '/candy/settings/bootstrap.php'; Gdn::Structure()->Table('Chunk')->PrimaryKey('ChunkID', 'usmallint')->Column('Name', 'varchar(80)')->Column('Body', 'text', True)->Column('Format', 'varchar(20)', True)->Column('Url', 'varchar(80)', True)->Column('InsertUserID', 'int', False)->Column('DateInserted', 'datetime')->Column('UpdateUserID', 'int', True)->Column('DateUpdated', 'datetime', True)->Engine('MyISAM')->Set($Explicit, $Drop); Gdn::Structure()->Table('Route')->Column('URI', 'char(80)', False, 'primary')->Column('RequestUri', 'char(120)')->Engine('MyISAM')->Set($Explicit, $Drop); $SectionModel = Gdn::Factory('SectionModel'); $HasRoot = False; Gdn::Structure()->Table($SectionModel->Name)->PrimaryKey('SectionID', 'usmallint')->Column('TreeLeft', 'usmallint', 0)->Column('TreeRight', 'usmallint', 0)->Column('Depth', 'utinyint', 0)->Column('ParentID', 'usmallint', 0)->Column('Name', 'varchar(120)')->Column('InTopMenu', 'tinyint(1)', 0)->Column('Url', 'varchar(80)', True)->Column('URI', 'varchar(80)', True)->Column('RequestUri', 'char(120)', True)->Column('Mask', 'uint', True)->Engine('InnoDB')->Set($Explicit, $Drop); try { $HasRoot = $SQL->GetCount($SectionModel->Name, array('SectionID' => 1)) > 0; } catch (Exception $Ex) { } if (!$HasRoot) { $SQL->Insert($SectionModel->Name, array('SectionID' => 1, 'TreeLeft' => 1, 'TreeRight' => 2, 'Depth' => 0, 'Name' => T('Home'))); } Gdn::Structure()->Table('Page')->PrimaryKey('PageID', 'usmallint')->Column('SectionID', 'usmallint', True, 'index')->Column('Title', 'varchar(200)')->Column('Body', 'text', True)->Column('Format', 'varchar(20)', 'xHtml')->Column('Visible', 'tinyint(1)', 0)->Column('URI', 'varchar(80)', True)->Column('Tags', 'varchar(250)', True)->Column('MasterView', 'varchar(30)', True)->Column('View', 'varchar(30)', True)->Column('Sort', 'smallint', 0)->Column('InsertUserID', 'int')->Column('DateInserted', 'datetime')->Column('UpdateUserID', 'int', True)->Column('DateUpdated', 'datetime', True)->Column('MetaDescription', 'varchar(500)', True)->Column('MetaKeywords', 'varchar(250)', True)->Column('MetaRobots', 'varchar(150)', True)->Column('MetaTitle', 'varchar(255)', True)->Column('CustomCss', 'text', True)->Column('CustomJs', 'text', True)->Engine('MyISAM')->Set($Explicit, $Drop); // Set route if (!Gdn::Router()->GetRoute('map')) { Gdn::Router()->SetRoute('map', 'candy/content/map', 'Internal'); } $PermissionModel = Gdn::PermissionModel(); $PermissionModel->Define(array('Candy.Settings.View', 'Candy.Sections.Edit', 'Candy.Sections.Add', 'Candy.Sections.Delete', 'Candy.Sections.Move', 'Candy.Sections.Swap', 'Candy.Pages.Add', 'Candy.Pages.Edit', 'Candy.Pages.Delete', 'Candy.Pages.Raw', 'Candy.Pages.Meta', 'Candy.Chunks.Edit', 'Candy.Chunks.Delete', 'Candy.Routes.Manage')); $PermissionModel->Save(array('RoleID' => 16, 'Candy.Settings.View' => 1)); if (!isset($CaptureOnly) || $CaptureOnly == False) { $Version = Gdn::ApplicationManager()->GetApplicationInfo('Candy', 'Version'); SaveToConfig('Candy.Version', $Version); }
/** * Application Gateway. * * @copyright 2009-2015 Vanilla Forums Inc. * @license http://www.opensource.org/licenses/gpl-2.0.php GNU GPL v2 * @package Core * @since 2.0 */ if (PHP_VERSION_ID < 50400) { die("Vanilla requires PHP 5.4 or greater."); } define('APPLICATION', 'Vanilla'); define('APPLICATION_VERSION', '2.2.100.8'); // Report and track all errors. error_reporting(E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR); ini_set('display_errors', 0); ini_set('track_errors', 1); ob_start(); // Define the constants we need to get going. define('DS', '/'); define('PATH_ROOT', getcwd()); // Include the bootstrap to configure the framework. require_once PATH_ROOT . '/bootstrap.php'; // Create and configure the dispatcher. $Dispatcher = Gdn::dispatcher(); $EnabledApplications = Gdn::ApplicationManager()->EnabledApplicationFolders(); $Dispatcher->EnabledApplicationFolders($EnabledApplications); $Dispatcher->PassProperty('EnabledApplications', $EnabledApplications); // Process the request. $Dispatcher->start(); $Dispatcher->dispatch();
/** * * * @param null $AddonCode * @param bool $Explicit * @param bool $Drop * @throws Exception */ public function runStructure($AddonCode = null, $Explicit = false, $Drop = false) { // Get the structure files for all of the enabled applications. $ApplicationManager = new Gdn_ApplicationManager(); $Apps = $ApplicationManager->EnabledApplications(); $AppNames = consolidateArrayValuesByKey($Apps, 'Folder'); $Paths = array(); foreach ($Apps as $Key => $AppInfo) { $Path = PATH_APPLICATIONS . "/{$AppInfo['Folder']}/settings/structure.php"; if (file_exists($Path)) { $Paths[] = $Path; } Gdn::ApplicationManager()->RegisterPermissions($Key, $this->Validation); } // Execute the structures. $Database = Gdn::database(); $SQL = Gdn::sql(); $Structure = Gdn::structure(); foreach ($Paths as $Path) { include $Path; } // Execute the structures for all of the plugins. $PluginManager = Gdn::pluginManager(); $Registered = $PluginManager->RegisteredPlugins(); foreach ($Registered as $ClassName => $Enabled) { if (!$Enabled) { continue; } try { $Plugin = $PluginManager->GetPluginInstance($ClassName, Gdn_PluginManager::ACCESS_CLASSNAME); if (method_exists($Plugin, 'Structure')) { trace("{$ClassName}->Structure()"); $Plugin->Structure(); } } catch (Exception $Ex) { // Do nothing, plugin wouldn't load/structure. if (Debug()) { throw $Ex; } } } $this->fireEvent('AfterStructure'); }
unset($Gdn_EnabledApplications); unset($Gdn_Path); unset($Hooks_Path); Gdn::ThemeManager()->Start(); Gdn_Autoloader::Attach(Gdn_Autoloader::CONTEXT_THEME); Gdn::PluginManager()->Start(); Gdn_Autoloader::Attach(Gdn_Autoloader::CONTEXT_PLUGIN); if (!Gdn::FactoryExists(Gdn::AliasLocale)) { $Codeset = Gdn::Config('Garden.LocaleCodeset', 'UTF8'); $CurrentLocale = Gdn::Config('Garden.Locale', 'en-CA'); $SetLocale = str_replace('-', '_', $CurrentLocale).'.'.$Codeset; setlocale(LC_ALL, $SetLocale); $Gdn_Locale = new Gdn_Locale($CurrentLocale, Gdn::ApplicationManager()->EnabledApplicationFolders(), Gdn::PluginManager()->EnabledPluginFolders()); Gdn::FactoryInstall(Gdn::AliasLocale, 'Gdn_Locale', NULL, Gdn::FactorySingleton, $Gdn_Locale); unset($Gdn_Locale); } require_once(PATH_LIBRARY_CORE.'/functions.validation.php'); Gdn::Authenticator()->StartAuthenticator(); // Include a user-defined bootstrap. if (file_exists(PATH_ROOT.'/conf/bootstrap.after.php')) require_once(PATH_ROOT.'/conf/bootstrap.after.php'); // Include "Render" functions now - this way pluggables and custom confs can override them. require_once(PATH_LIBRARY_CORE.'/functions.render.php');
Gdn::request()->fromEnvironment(); /** * Extension Managers * * Now load the Application, Theme and Plugin managers into the Factory, and * process the Application-specific configuration defaults. */ // ApplicationManager Gdn::factoryInstall(Gdn::AliasApplicationManager, 'Gdn_ApplicationManager'); Gdn_Autoloader::attach(Gdn_Autoloader::CONTEXT_APPLICATION); // ThemeManager Gdn::factoryInstall(Gdn::AliasThemeManager, 'Gdn_ThemeManager'); // PluginManager Gdn::factoryInstall(Gdn::AliasPluginManager, 'Gdn_PluginManager'); // Load the configurations for enabled Applications foreach (Gdn::ApplicationManager()->EnabledApplicationFolders() as $ApplicationName => $ApplicationFolder) { Gdn::config()->Load(PATH_APPLICATIONS . "/{$ApplicationFolder}/settings/configuration.php"); } /** * Installer Redirect * * If Garden is not yet installed, force the request to /dashboard/setup and * begin installation. */ if (Gdn::config('Garden.Installed', false) === false && strpos(Gdn_Url::request(), 'setup') === false) { safeHeader('Location: ' . Gdn::request()->Url('dashboard/setup', true)); exit; } // Re-apply loaded user settings Gdn::config()->overlayDynamic(); /**
/** * Returns the name of the enabled application based on $ApplicationFolder. * * @param string The application folder related to the application name you want to return. */ public function EnabledApplication($ApplicationFolder = '') { if ($ApplicationFolder == '') { $ApplicationFolder = $this->_ApplicationFolder; } if (strpos($ApplicationFolder, 'plugins/') === 0) { $Plugin = StringBeginsWith($ApplicationFolder, 'plugins/', FALSE, TRUE); if (array_key_exists($Plugin, Gdn::PluginManager()->AvailablePlugins())) { return $Plugin; } return FALSE; } else { foreach (Gdn::ApplicationManager()->AvailableApplications() as $ApplicationName => $ApplicationInfo) { if (GetValue('Folder', $ApplicationInfo, FALSE) === $ApplicationFolder) { $EnabledApplication = $ApplicationName; $this->EventArguments['EnabledApplication'] = $EnabledApplication; $this->FireEvent('AfterEnabledApplication'); return $EnabledApplication; } } } return FALSE; }
<?php if (!defined('APPLICATION')) { exit; } $Count = array(1, 2, 3, 4, 5, 10, 15, 20, 25, 30); $Time = array(30, 60, 90, 120, 240); $Lock = array(30, 60, 90, 120, 240); $SpamCount = ArrayCombine($Count, $Count); $SpamTime = ArrayCombine($Time, $Time); $SpamLock = ArrayCombine(array(60, 120, 180, 240, 300, 600), array(1, 2, 3, 4, 5, 10)); $ConversationsEnabled = Gdn::ApplicationManager()->IsEnabled('Conversations'); echo $this->Form->open(); echo $this->Form->errors(); ?> <h1><?php echo t('Flood Control'); ?> </h1> <div class="Info"><?php echo t('Prevent spam on your forum by limiting the number of discussions & comments that users can post within a given period of time.'); ?> </div> <table class="AltColumns"> <thead> <tr> <th><?php echo t('Only Allow Each User To Post'); ?> </th>
unset($Gdn_Path); unset($Hooks_Path); // Themes startup Gdn::ThemeManager()->Start(); Gdn_Autoloader::Attach(Gdn_Autoloader::CONTEXT_THEME); // Plugins startup Gdn::PluginManager()->Start(); Gdn_Autoloader::Attach(Gdn_Autoloader::CONTEXT_PLUGIN); /** * Locales * * Install any custom locales provided by applications and plugins, and set up * the locale management system. */ // Load the Garden locale system $Gdn_Locale = new Gdn_Locale(C('Garden.Locale', 'en-CA'), Gdn::ApplicationManager()->EnabledApplicationFolders(), Gdn::PluginManager()->EnabledPluginFolders()); Gdn::FactoryInstall(Gdn::AliasLocale, 'Gdn_Locale', NULL, Gdn::FactorySingleton, $Gdn_Locale); unset($Gdn_Locale); require_once PATH_LIBRARY_CORE . '/functions.validation.php'; // Start Authenticators Gdn::Authenticator()->StartAuthenticator(); /** * Bootstrap After * * After the bootstrap has finished loading, this hook allows developers a last * chance to customize Garden's runtime environment before the actual request * is handled. */ if (file_exists(PATH_ROOT . '/conf/bootstrap.after.php')) { require_once PATH_ROOT . '/conf/bootstrap.after.php'; }
public function EnablePlugin($PluginName, $Validation, $Setup = FALSE, $EnabledPluginValueIndex = 'Folder') { // Check that the plugin is in AvailablePlugins... $PluginInfo = $this->GetPluginInfo($PluginName); // Couldn't load the plugin info. if (!$PluginInfo) { return FALSE; } // Check to see if the plugin is already enabled. if (array_key_exists($PluginName, $this->EnabledPlugins())) { throw new Gdn_UserException(T('The plugin is already enabled.')); } $this->TestPlugin($PluginName, $Validation, $Setup); if (is_object($Validation) && count($Validation->Results()) > 0) { return FALSE; } // Write enabled state to config SaveToConfig("EnabledPlugins.{$PluginName}", TRUE); $this->EnabledPlugins[$PluginName] = TRUE; $PluginClassName = GetValue('ClassName', $PluginInfo); $this->RegisterPlugin($PluginClassName); Gdn::Locale()->Set(Gdn::Locale()->Current(), Gdn::ApplicationManager()->EnabledApplicationFolders(), $this->EnabledPluginFolders(), TRUE); return TRUE; }
ob_start(); // Require the bootstrap for the framework used by Vanilla if (is_dir(PATH_ROOT) && file_exists(PATH_ROOT . '/bootstrap.php')) { require_once PATH_ROOT . '/bootstrap.php'; } // Check if Vanilla installed // If it's not, don't try to include the framework $isVanillaInstalled = true; if (!class_exists('Gdn')) { $isVanillaInstalled = false; ob_end_flush(); return; } // Set up the dispatcher $dispatcher = Gdn::dispatcher(); $enabledApps = Gdn::ApplicationManager()->enabledApplicationFolders(); $dispatcher->enabledApplicationFolders($enabledApps); $dispatcher->passProperty('EnabledApplications', $enabledApps); // Mimic the DiscussionsController() $dispatcher->Start(); $controller = new DiscussionsController(); Gdn::controller($controller); // Stop and send the buffer for the code above. ob_end_flush(); /* * The above code is to include Garden framework used by Vanilla, so you can use its functions. * You can put your code in this file. See the example below. * You can also make a separate file with your code and include this file by a require() above all. */ $session = Gdn::Session(); // Declare an alias for the user session.