/** Add a formatter and create a chain in the Gdn factory. * This is a conveinience method for chaining formatters without having to deal with the object creation logic. * * @param string $Type The type of formatter. * @param object $Formatter The formatter to install. * @param int $Priority The priority of the formatter in the chain. High priorities come first. * @return Gdn_FormatterChain The chain object that was created. */ public static function Chain($Type, $Formatter, $Priority = Gdn_FormatterChain::PRIORITY_DEFAULT) { // Grab the existing formatter from the factory. $Formatter = Gdn::Factory($Type . 'Formatter'); if ($Formatter === NULL) { $Chain = new Gdn_FormatterChain(); Gdn::FactoryInstall($Type . 'Formatter', 'Gdn_FormatterChain', __FILE__, Gdn::FactorySingleton, $Chain); } elseif (is_a($Formatter, 'Gdn_FormatterChain')) { $Chain = $Formatter; } else { Gdn::FactoryUninstall($Type . 'Formatter'); // Look for a priority on the existing object. if (property_exists($Formatter, 'Priority')) { $Priority = $Formatter->Priority; } else { $Priority = self::PRIORITY_DEFAULT; } $Chain = new Gdn_FormatterChain(); $Chain->Add($Formatter, $Priority); Gdn::FactoryInstall($Type . 'Formatter', 'Gdn_FormatterChain', __FILE__, Gdn::FactorySingleton, $Chain); } $Chain->Add($Formatter, $Priority); return $Chain; }
include_once $Gdn_Path; } // Include the application's hooks. $Hooks_Path = PATH_APPLICATIONS . DS . $ApplicationFolder . DS . 'settings' . DS . 'class.hooks.php'; if (file_exists($Hooks_Path)) { include_once $Hooks_Path; } } unset($Gdn_EnabledApplications); unset($Gdn_Path); unset($Hooks_Path); // If there is a hooks file in the theme folder, include it. $ThemeName = C('Garden.Theme', 'default'); $ThemeHooks = PATH_THEMES . DS . $ThemeName . DS . 'class.' . strtolower($ThemeName) . 'themehooks.php'; if (file_exists($ThemeHooks)) { include_once $ThemeHooks; } // Set up the plugin manager (doing this early so it has fewer classes to // examine to determine if they are plugins). Gdn::FactoryInstall(Gdn::AliasPluginManager, 'Gdn_PluginManager', PATH_LIBRARY . DS . 'core' . DS . 'class.pluginmanager.php', Gdn::FactorySingleton); Gdn::PluginManager()->IncludePlugins(); Gdn::PluginManager()->RegisterPlugins(); Gdn::FactoryOverwrite($FactoryOverwriteBak); unset($FactoryOverwriteBak); Gdn::Authenticator()->StartAuthenticator(); /// Include a user-defined bootstrap. if (file_exists(PATH_ROOT . DS . 'conf' . DS . 'bootstrap.after.php')) { require_once PATH_ROOT . DS . 'conf' . DS . 'bootstrap.after.php'; } // Include "Render" functions now - this way pluggables and custom confs can override them. require_once PATH_LIBRARY_CORE . DS . 'functions.render.php';
<?php if (!defined('APPLICATION')) { exit; } /* Copyright 2008, 2009 Vanilla Forums Inc. This file is part of Garden. Garden is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Garden is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Garden. If not, see <http://www.gnu.org/licenses/>. Contact Vanilla Forums Inc. at support [at] vanillaforums [dot] com */ $PluginInfo['NBBC'] = array('Description' => 'Adapts The New BBCode Parser to work with Vanilla.', 'Version' => '1.1.0', 'RequiredApplications' => array('Vanilla' => '2.0.2'), 'RequiredTheme' => FALSE, 'RequiredPlugins' => FALSE, 'HasLocale' => FALSE, 'Author' => "Todd Burry", 'AuthorEmail' => '*****@*****.**', 'AuthorUrl' => 'http://vanillaforums.com/profile/todd'); Gdn::FactoryInstall('BBCodeFormatter', 'NBBCPlugin', __FILE__, Gdn::FactorySingleton); class NBBCPlugin extends Gdn_Plugin { public $Class = 'BBCode'; /// CONSTRUCTOR /// public function __construct($Class = 'BBCode') { parent::__construct(); $this->Class = $Class; } /// PROPERTIES /// /// METHODS /// public function DoAttachment($bbcode, $action, $name, $default, $params, $content) { $Medias = $this->Media(); $MediaID = $content; if (isset($Medias[$MediaID])) {
<?php if (!defined('APPLICATION')) { exit; } // User. Gdn::FactoryInstall(Gdn::AliasUserModel, 'UserModel'); // Permissions. Gdn::FactoryInstall(Gdn::AliasPermissionModel, 'PermissionModel'); // Roles. Gdn::FactoryInstall('RoleModel', 'RoleModel'); // Head. Gdn::FactoryInstall('Head', 'HeadModule'); // Menu. Gdn::FactoryInstall('Menu', 'MenuModule'); Gdn::dispatcher()->PassProperty('Menu', Gdn::Factory('Menu'));
if (!defined('APPLICATION')) { exit; } /********************************************************************************** * This program is free software; you may redistribute it and/or modify it under * * the terms of the provided license as published by Simple Machines LLC. * * * * This program is distributed in the hope that it is and will be useful, but * * WITHOUT ANY WARRANTIES; without even any implied warranty of MERCHANTABILITY * * or FITNESS FOR A PARTICULAR PURPOSE. * * * * See the "license.txt" file for details of the Simple Machines license. * **********************************************************************************/ $PluginInfo['SMFCompatibility'] = array('Name' => 'SMF Compatibility', 'Description' => 'Adds some compatibility functionality for forums imported from SMF.', 'Version' => '1.1', 'RequiredApplications' => array('Vanilla' => '2.0.18'), 'RequiredTheme' => FALSE, 'RequiredPlugins' => FALSE, 'HasLocale' => FALSE, 'Author' => "Todd Burry", 'AuthorEmail' => '*****@*****.**', 'AuthorUrl' => 'http://vanillaforums.com/profile/todd', 'License' => 'Simple Machines license'); Gdn::FactoryInstall('BBCodeFormatter', 'SMFCompatibilityPlugin', __FILE__, Gdn::FactorySingleton); class SMFCompatibilityPlugin extends Gdn_Plugin { /// CONSTRUCTOR /// public function __construct() { require_once dirname(__FILE__) . '/functions.smf.php'; } /// PROPERTIES /// /// METHODS /// public function Base_BeforeDispatch_Handler($Sender) { $Request = Gdn::Request(); $Folder = ltrim($Request->RequestFolder(), '/'); $Uri = ltrim($_SERVER['REQUEST_URI'], '/'); // Fix the url in the request for routing.
<?php if (!defined('APPLICATION')) { exit; } Gdn::FactoryInstall('SectionModel', 'SectionModel', PATH_APPLICATIONS . '/candy/models/class.sectionmodel.php', Gdn::FactorySingleton); if (!function_exists('SetMetaTags')) { function SetMetaTags($Page, $Controller = Null) { if (!$Controller) { $Controller = Gdn::Controller(); } if ($Page->MetaDescription) { $Controller->Head->AddTag('meta', array('name' => 'description', 'content' => $Page->MetaDescription, '_sort' => 0)); } if ($Page->MetaKeywords) { $Controller->Head->AddTag('meta', array('name' => 'keywords', 'content' => $Page->MetaKeywords, '_sort' => 0)); } if ($Page->MetaRobots) { $Controller->Head->AddTag('meta', array('name' => 'robots', 'content' => $Page->MetaRobots, '_sort' => 0)); } if ($Page->MetaTitle) { $Controller->Head->Title($Page->MetaTitle); } $Controller->Head->AddTag('meta', array('http-equiv' => 'content-language', 'content' => Gdn::Locale()->Current())); $Controller->Head->AddTag('meta', array('http-equiv' => 'content-type', 'content' => 'text/html; charset=utf-8')); } } if (!function_exists('ValidateUrlPath')) { function ValidateUrlPath($Value, $Field = '') {
<?php // User. Gdn::FactoryInstall(Gdn::AliasUserModel, 'Gdn_UserModel', PATH_APPLICATIONS . DS . 'garden' . DS . 'models' . DS . 'class.usermodel.php', Gdn::FactorySingleton); // Permissions. Gdn::FactoryInstall(Gdn::AliasPermissionModel, 'Gdn_PermissionModel', PATH_APPLICATIONS . DS . 'garden' . DS . 'models' . DS . 'class.permissionmodel.php', Gdn::FactorySingleton); // Roles. Gdn::FactoryInstall('RoleModel', 'Gdn_RoleModel', PATH_APPLICATIONS . DS . 'garden' . DS . 'models' . DS . 'class.rolemodel.php', Gdn::FactorySingleton); // Head. Gdn::FactoryInstall('Head', 'Gdn_HeadModule', PATH_APPLICATIONS . DS . 'garden' . DS . 'modules' . DS . 'class.headmodule.php', Gdn::FactorySingleton); // Menu. Gdn::FactoryInstall('Menu', 'Gdn_MenuModule', PATH_APPLICATIONS . DS . 'garden' . DS . 'modules' . DS . 'class.menumodule.php', Gdn::FactorySingleton); Gdn::Dispatcher()->PassProperty('Menu', Gdn::Factory('Menu')); // Search. Gdn::FactoryInstall('SearchModel', 'Gdn_SearchModel', PATH_APPLICATIONS . DS . 'garden' . DS . 'models' . DS . 'class.searchmodel.php', Gdn::FactorySingleton);
<?php if (!defined('APPLICATION')) { exit; } /* Copyright 2008, 2009 Vanilla Forums Inc. This file is part of Garden. Garden is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Garden is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Garden. If not, see <http://www.gnu.org/licenses/>. Contact Vanilla Forums Inc. at support [at] vanillaforums [dot] com */ $PluginInfo['HtmLawed'] = array('Description' => 'Adapts HtmLawed to work with Vanilla.', 'Version' => '1.0.1', 'RequiredApplications' => NULL, 'RequiredTheme' => FALSE, 'RequiredPlugins' => FALSE, 'HasLocale' => FALSE, 'Author' => "Todd Burry", 'AuthorEmail' => '*****@*****.**', 'AuthorUrl' => 'http://vanillaforums.com/profile/todd', 'Hidden' => TRUE); Gdn::FactoryInstall('HtmlFormatter', 'HTMLawedPlugin', __FILE__, Gdn::FactorySingleton); class HTMLawedPlugin extends Gdn_Plugin { /// CONSTRUCTOR /// public function __construct() { require_once dirname(__FILE__) . '/htmLawed/htmLawed.php'; $this->SafeStyles = C('Garden.Html.SafeStyles'); } /// PROPERTIES /// public $SafeStyles = TRUE; /// METHODS /// public function Format($Html) { $Attributes = C('Garden.Html.BlockedAttributes', 'on*'); $Config = array('anti_link_spam' => array('`.`', ''), 'comment' => 1, 'cdata' => 3, 'css_expression' => 1, 'deny_attribute' => $Attributes, 'unique_ids' => 1, 'elements' => '*-applet-form-input-textarea-iframe-script-style-embed-object-select-option-button-fieldset-optgroup-legend', 'keep_bad' => 0, 'schemes' => 'classid:clsid; href: aim, feed, file, ftp, gopher, http, https, irc, mailto, news, nntp, sftp, ssh, telnet; style: nil; *:file, http, https', 'valid_xhtml' => 0, 'direct_list_nest' => 1, 'balance' => 1); // Turn embedded videos into simple links (legacy workaround)
$FileUndefinedTranslation =& $UndefinedTranslation[$DefinitionsFile]; if (!is_array($FileUndefinedTranslation)) { $FileUndefinedTranslation = array(); } $Index = count($FileUndefinedTranslation); $FileUndefinedTranslation[$Index]['Path'] = $Path; $FileUndefinedTranslation[$Index]['Codes'] = $Codes; ++$Count; if ($MaxScanFiles > 0 && $Count >= $MaxScanFiles) { break; } } if ($SkipTranslated) { $T = Gdn::FactoryOverwrite(True); $DefaultLocale = new Gdn_Locale(C('Garden.Locale'), $Applications, array()); Gdn::FactoryInstall(Gdn::AliasLocale, 'Gdn_Locale', PATH_LIBRARY_CORE . '/class.locale.php', Gdn::FactorySingleton, $DefaultLocale); Gdn::FactoryOverwrite($T); } // save it foreach ($UndefinedTranslation as $File => $FileUndefinedTranslation) { $Directory = dirname($File); if (!is_dir($Directory)) { mkdir($Directory, 0777, True); } $FileContent = ''; foreach ($FileUndefinedTranslation as $Index => $InfoArray) { $Codes = $InfoArray['Codes']; if (count($Codes) == 0) { continue; } $RelativePath = $InfoArray['Path'];
} /* Copyright 2008, 2009 Vanilla Forums Inc. This file is part of Garden. Garden is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Garden is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Garden. If not, see <http://www.gnu.org/licenses/>. Contact Vanilla Forums Inc. at support [at] vanillaforums [dot] com */ // Define the plugin: $PluginInfo['LocaleDeveloper'] = array('Name' => 'Locale Developer', 'Description' => 'Contains useful functions for locale developers. When you enable this plugin go to its settings page to change your options. This plugin is maintained at http://github.com/vanillaforums/Addons', 'Version' => '1.0', 'Author' => "Todd Burry", 'AuthorEmail' => '*****@*****.**', 'AuthorUrl' => 'http://vanillaforums.org/profile/todd', 'RequiredApplications' => array('Vanilla' => '2.0.11'), 'SettingsUrl' => '/dashboard/settings/localedeveloper', 'SettingsPermission' => 'Garden.Site.Manage'); if (C('Plugins.LocaleDeveloper.CaptureDefinitions')) { // Install the developer locale. $_Locale = new DeveloperLocale(Gdn::Locale()->Current(), C('EnabledApplications'), C('EnabledPlugins')); $tmp = Gdn::FactoryOverwrite(TRUE); Gdn::FactoryInstall(Gdn::AliasLocale, 'DeveloperLocale', dirname(__FILE__) . DS . 'class.developerlocale.php', Gdn::FactorySingleton, $_Locale); Gdn::FactoryOverwrite($tmp); unset($tmp); } class LocaleDeveloperPlugin extends Gdn_Plugin { public $LocalePath; /** * @var Gdn_Form Form */ protected $Form; public function __construct() { $this->LocalePath = PATH_UPLOADS . '/LocaleDeveloper'; $this->Form = new Gdn_Form(); parent::__construct();
/** * Allows the configuration of basic setup information in Garden. This * should not be functional after the application has been set up. */ public function Configure($RedirectUrl = '') { $Config = Gdn::Factory(Gdn::AliasConfig); $ConfigFile = PATH_CONF . DS . 'config.php'; // Create a model to save configuration settings $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel('Configuration', $ConfigFile, $Validation); $ConfigurationModel->SetField(array('Garden.Locale', 'Garden.Title', 'Garden.RewriteUrls', 'Garden.WebRoot', 'Garden.Cookie.Salt', 'Garden.Cookie.Domain', 'Database.Name', 'Database.Host', 'Database.User', 'Database.Password')); // Set the models on the forms. $this->Form->SetModel($ConfigurationModel); // Load the locales for the locale dropdown // $Locale = Gdn::Locale(); // $AvailableLocales = $Locale->GetAvailableLocaleSources(); // $this->LocaleData = array_combine($AvailableLocales, $AvailableLocales); // If seeing the form for the first time... if (!$this->Form->IsPostback()) { // Force the webroot using our best guesstimates $ConfigurationModel->Data['Database.Host'] = 'localhost'; $this->Form->SetData($ConfigurationModel->Data); } else { // Define some validation rules for the fields being saved $ConfigurationModel->Validation->AddRule('Connection', 'function:ValidateConnection'); $ConfigurationModel->Validation->ApplyRule('Database.Name', 'Connection'); $ConfigurationModel->Validation->ApplyRule('Garden.Title', 'Required'); $ConfigurationFormValues = $this->Form->FormValues(); if ($ConfigurationModel->Validate($ConfigurationFormValues) !== TRUE) { // Apply the validation results to the form(s) $this->Form->SetValidationResults($ConfigurationModel->ValidationResults()); } else { $Host = Gdn_Url::Host(); $Domain = Gdn_Url::Domain(); // Set up cookies now so that the user can be signed in. $ConfigurationFormValues['Garden.Cookie.Salt'] = RandomString(10); $ConfigurationFormValues['Garden.Cookie.Domain'] = strpos($Host, '.') === FALSE ? '' : $Host; // Don't assign the domain if it is a non .com domain as that will break cookies. $ConfigurationModel->Save($ConfigurationFormValues); // If changing locale, redefine locale sources: $NewLocale = 'en-CA'; // $this->Form->GetFormValue('Garden.Locale', FALSE); if ($NewLocale !== FALSE && Gdn::Config('Garden.Locale') != $NewLocale) { $ApplicationManager = new Gdn_ApplicationManager(); $PluginManager = Gdn::Factory('PluginManager'); $Locale = Gdn::Locale(); $Locale->Set($NewLocale, $ApplicationManager->EnabledApplicationFolders(), $PluginManager->EnabledPluginFolders(), TRUE); } // Set the instantiated config object's db params and make the database use them (otherwise it will use the default values from conf/config-defaults.php). $Config->Set('Database.Host', $ConfigurationFormValues['Database.Host']); $Config->Set('Database.Name', $ConfigurationFormValues['Database.Name']); $Config->Set('Database.User', $ConfigurationFormValues['Database.User']); $Config->Set('Database.Password', $ConfigurationFormValues['Database.Password']); $Config->ClearSaveData(); Gdn::FactoryInstall(Gdn::AliasDatabase, 'Gdn_Database', PATH_LIBRARY . DS . 'database' . DS . 'class.database.php', Gdn::FactorySingleton, array(Gdn::Config('Database'))); // Install db structure & basic data. $Database = Gdn::Database(); $Drop = FALSE; // Gdn::Config('Garden.Version') === FALSE ? TRUE : FALSE; $Explicit = FALSE; try { include PATH_APPLICATIONS . DS . 'garden' . DS . 'settings' . DS . 'structure.php'; } catch (Exception $ex) { $this->Form->AddError(strip_tags($ex->getMessage())); } if ($this->Form->ErrorCount() > 0) { return FALSE; } // Create the administrative user $UserModel = Gdn::UserModel(); $UserModel->DefineSchema(); $UserModel->Validation->ApplyRule('Name', 'Username', 'Admin username can only contain letters, numbers, and underscores.'); $UserModel->Validation->ApplyRule('Password', 'Required'); $UserModel->Validation->ApplyRule('Password', 'Match'); if (!$UserModel->SaveAdminUser($ConfigurationFormValues)) { $this->Form->SetValidationResults($UserModel->ValidationResults()); } else { // The user has been created successfully, so sign in now $Authenticator = Gdn::Authenticator(); $AuthUserID = $Authenticator->Authenticate(array('Name' => $this->Form->GetValue('Name'), 'Password' => $this->Form->GetValue('Password'), 'RememberMe' => TRUE)); } if ($this->Form->ErrorCount() > 0) { return FALSE; } // Assign some extra settings to the configuration file if everything succeeded. $ApplicationInfo = array(); include CombinePaths(array(PATH_APPLICATIONS . DS . 'garden' . DS . 'settings' . DS . 'about.php')); $Config->Load($ConfigFile, 'Save'); $Config->Set('Garden.Version', ArrayValue('Version', ArrayValue('Garden', $ApplicationInfo, array()), 'Undefined')); $Config->Set('Garden.WebRoot', Gdn_Url::WebRoot()); $Config->Set('Garden.RewriteUrls', function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules()) ? TRUE : FALSE); $Config->Set('Garden.Domain', $Domain); $Config->Set('Garden.CanProcessImages', function_exists('gd_info')); $Config->Set('Garden.Messages.Cache', 'arr:["Garden\\/Settings\\/Index"]'); // Make sure that the "welcome" message is cached for viewing $Config->Set('EnabledPlugins.HTMLPurifier', 'HtmlPurifier'); // Make sure html purifier is enabled so html has a default way of being safely parsed $Config->Save(); } } return $this->Form->ErrorCount() == 0 ? TRUE : FALSE; }
* - type:standard to list non extended fields (order how want) other params than name are ignored * - requiredwith (field that a reliant on other fields) * - params (passed to link/label vsprintf) * - labeldefault (locale like vsprintf format string can be overridden by locale MyMeta.Field.Label * v0.1.5b:Thu Mar 29 16:04:47 BST 2012 * - more amicable link/label default * v0.1.6b:Sun Apr 8 22:29:46 BST 2012 * - formatting for label default * v0.1.7b:Sun Apr 8 22:29:46 BST 2012 * - strftime rather than Gnd_Format::Date * - Date.DefaultFormat * v0.1.9b:Thu Jun 7 23:57:34 BST 2012 * - view permissions fix */ $PluginInfo['MyProfile'] = array('Name' => 'MyProfile', 'Description' => 'Adds an extended and extensible user profile. Uses a simple Yaml Meta Spec to model the desired profile.', 'Version' => '0.1.9b', 'Author' => "Paul Thomas", 'AuthorEmail' => 'dt01pqt_pt@yahoo.com ', 'AuthorUrl' => 'http://vanillaforums.org/profile/x00'); Gdn::FactoryInstall('sfYaml', 'sfYaml', dirname(__FILE__) . DS . 'sfYaml' . DS . 'lib' . DS . 'sfYaml.php', Gdn::FactorySingleton); class MyProfile extends Gdn_Plugin { public function ProfileController_AddProfileTabs_handler($Sender) { $Sender->AddProfileTab('MyProfile', "/profile/myprofile/" . $Sender->User->UserID . "/" . Gdn_Format::Url($Sender->User->Name), 'MyProfile', sprintf(T('About %s'), $Sender->User->Name)); } public function ProfileController_AfterAddSideMenu_Handler($Sender) { if (!Gdn::Session()->CheckPermission('Garden.Users.Edit') && $Sender->User->UserID !== Gdn::Session()->UserID) { return; } $SideMenu = $Sender->EventArguments['SideMenu']; $SessionUserID = Gdn::Session()->UserID; if ($Sender->User->UserID == $SessionUserID) { $SideMenu->AddLink('Options', T('My Profile Edit'), '/profile/myprofileedit/' . $Sender->User->UserID . '/' . Gdn_Format::Url($Sender->User->Name), FALSE, array('class' => 'Popup'));
return $Result; } return array(); } public static function FormatMentions($Mixed) { if (C('Garden.Format.Mentions')) { $Mixed = preg_replace('/@([\\d\\w_\\x{0800}-\\x{9fa5}]+)/iu', Anchor('@\\1', '/profile/\\1'), $Mixed); } if (C('Garden.Format.Hashtags')) { $Mixed = preg_replace('/(^|[\\s,\\.])\\#([\\S]{1,30}?)#/i', '\\1' . Anchor('#\\2#', '/search?Search=%23\\2%23&Mode=like') . '\\3', $Mixed); } return $Mixed; } } Gdn::FactoryInstall('MentionsFormatter', 'Chn_MentionsFormatter', NULL, Gdn::FactoryInstance); function CountString($Number, $Url = '', $Options = array()) { if (is_string($Options)) { $Options = array('cssclass' => $Options); } $Options = array_change_key_case($Options); $CssClass = GetValue('cssclass', $Options, ''); if ($Number === NULL) { $Number = 0; } if ($Number) { $Result = " <span class=\"Count\">{$Number}</span>"; } else { $Result = ''; }
<?php if (!defined('APPLICATION')) { die; } # … $PluginInfo['UsefulFunctions'] = array('Name' => 'Useful Functions', 'Description' => 'Useful functions for plugin and application developers (ex- PluginUtils).', 'RequiredApplications' => array('Dashboard' => '>=2.0.13'), 'Version' => '3.7.0', 'Date' => 'Winter 2010', 'Updated' => 'Autumn 2011', 'Author' => 'Vanilla Fan'); define('USEFULFUNCTIONS_LIBRARY', dirname(__FILE__) . '/library'); define('USEFULFUNCTIONS_VENDORS', dirname(__FILE__) . '/vendors'); if (class_exists('Gdn', False)) { Gdn::FactoryInstall('Snoopy', 'Snoopy', USEFULFUNCTIONS_VENDORS . '/Snoopy.class.php', Gdn::FactorySingleton); Gdn::FactoryInstall('Mailbox', 'ImapMailbox', USEFULFUNCTIONS_LIBRARY . '/class.imapmailbox.php', Gdn::FactorySingleton); Gdn::FactoryInstall('CssSpriteMap', 'CssSpriteMap', USEFULFUNCTIONS_VENDORS . '/CssSprite.php', Gdn::FactorySingleton); class UsefulFunctionsPlugin implements Gdn_IPlugin { public function Base_Render_Before($Sender) { if ($Sender->DeliveryType() != DELIVERY_TYPE_ALL) { return; } $Sender->Head->AddScript('plugins/UsefulFunctions/js/noindex.js', 'text/javascript', array('path' => 'plugins/UsefulFunctions/js/noindex.js', 'sort' => 9999)); } public function Setup() { } } } require USEFULFUNCTIONS_LIBRARY . '/functions.render.php'; require USEFULFUNCTIONS_LIBRARY . '/functions.sql.php'; require USEFULFUNCTIONS_LIBRARY . '/functions.image.php'; require USEFULFUNCTIONS_LIBRARY . '/functions.time.php';
public function Translate($Code, $Default = False) { $this->EventArguments['Code'] = $Code; $this->FireEvent('BeforeTranslate'); $Result = parent::Translate($Code, $Default); return $Result; } } $TcLocale = Gdn::Locale(); if (is_null($TcLocale)) { $CurrentLocale = C('Garden.Locale', 'en-CA'); $EnabledApplicationFolders = Gdn::ApplicationManager()->EnabledApplicationFolders(); $EnabledPluginFolders = Gdn::PluginManager()->EnabledPluginFolders(); $TcLocale = new TranslationCollectorLocale($CurrentLocale, $EnabledApplicationFolders, $EnabledPluginFolders); $Overwrite = Gdn::FactoryOverwrite(True); Gdn::FactoryInstall(Gdn::AliasLocale, 'TranslationCollectorLocale', Null, Gdn::FactorySingleton, $TcLocale); Gdn::FactoryOverwrite($Overwrite); } } class TranslationCollectorPlugin implements Gdn_IPlugin { private $_Definition = array(); private $_EnabledApplication = 'Dashboard'; private $_SkipApplications = array(); public function __construct() { $this->_Definition = self::GetLocaleDefinitions(); $this->_SkipApplications = C('Plugins.TranslationCollector.SkipApplications', array()); } public static function GetLocaleDefinitions() {
/** * Allows the configuration of basic setup information in Garden. This * should not be functional after the application has been set up. */ public function Configure($RedirectUrl = '') { $Config = Gdn::Factory(Gdn::AliasConfig); // Create a model to save configuration settings $Validation = new Gdn_Validation(); $ConfigurationModel = new Gdn_ConfigurationModel($Validation); $ConfigurationModel->SetField(array('Garden.Locale', 'Garden.Title', 'Garden.RewriteUrls', 'Garden.WebRoot', 'Garden.Cookie.Salt', 'Garden.Cookie.Domain', 'Database.Name', 'Database.Host', 'Database.User', 'Database.Password')); // Set the models on the forms. $this->Form->SetModel($ConfigurationModel); // Load the locales for the locale dropdown // $Locale = Gdn::Locale(); // $AvailableLocales = $Locale->GetAvailableLocaleSources(); // $this->LocaleData = array_combine($AvailableLocales, $AvailableLocales); // If seeing the form for the first time... if (!$this->Form->IsPostback()) { // Force the webroot using our best guesstimates $ConfigurationModel->Data['Database.Host'] = 'localhost'; $this->Form->SetData($ConfigurationModel->Data); } else { // Define some validation rules for the fields being saved $ConfigurationModel->Validation->ApplyRule('Database.Name', 'Required', 'You must specify the name of the database in which you want to set up Vanilla.'); // Let's make some user-friendly custom errors for database problems $DatabaseHost = $this->Form->GetFormValue('Database.Host', '~~Invalid~~'); $DatabaseName = $this->Form->GetFormValue('Database.Name', '~~Invalid~~'); $DatabaseUser = $this->Form->GetFormValue('Database.User', '~~Invalid~~'); $DatabasePassword = $this->Form->GetFormValue('Database.Password', '~~Invalid~~'); $ConnectionString = GetConnectionString($DatabaseName, $DatabaseHost); try { $Connection = new PDO($ConnectionString, $DatabaseUser, $DatabasePassword); } catch (PDOException $Exception) { switch ($Exception->getCode()) { case 1044: $this->Form->AddError(T('The database user you specified does not have permission to access the database. Have you created the database yet? The database reported: <code>%s</code>'), strip_tags($Exception->getMessage())); break; case 1045: $this->Form->AddError(T('Failed to connect to the database with the username and password you entered. Did you mistype them? The database reported: <code>%s</code>'), strip_tags($Exception->getMessage())); break; case 1049: $this->Form->AddError(T('It appears as though the database you specified does not exist yet. Have you created it yet? Did you mistype the name? The database reported: <code>%s</code>'), strip_tags($Exception->getMessage())); break; case 2005: $this->Form->AddError(T("Are you sure you've entered the correct database host name? Maybe you mistyped it? The database reported: <code>%s</code>"), strip_tags($Exception->getMessage())); break; default: $this->Form->AddError(sprintf(T('ValidateConnection'), strip_tags($Exception->getMessage()))); break; } } $ConfigurationModel->Validation->ApplyRule('Garden.Title', 'Required'); $ConfigurationFormValues = $this->Form->FormValues(); if ($ConfigurationModel->Validate($ConfigurationFormValues) !== TRUE || $this->Form->ErrorCount() > 0) { // Apply the validation results to the form(s) $this->Form->SetValidationResults($ConfigurationModel->ValidationResults()); } else { $Host = array_shift(explode(':', Gdn::Request()->RequestHost())); $Domain = Gdn::Request()->Domain(); // Set up cookies now so that the user can be signed in. $ConfigurationFormValues['Garden.Cookie.Salt'] = RandomString(10); $ConfigurationFormValues['Garden.Cookie.Domain'] = strpos($Host, '.') === FALSE ? '' : $Host; // Don't assign the domain if it is a non .com domain as that will break cookies. $ConfigurationModel->Save($ConfigurationFormValues); // If changing locale, redefine locale sources: $NewLocale = 'en-CA'; // $this->Form->GetFormValue('Garden.Locale', FALSE); if ($NewLocale !== FALSE && Gdn::Config('Garden.Locale') != $NewLocale) { $ApplicationManager = new Gdn_ApplicationManager(); $PluginManager = Gdn::Factory('PluginManager'); $Locale = Gdn::Locale(); $Locale->Set($NewLocale, $ApplicationManager->EnabledApplicationFolders(), $PluginManager->EnabledPluginFolders(), TRUE); } // Set the instantiated config object's db params and make the database use them (otherwise it will use the default values from conf/config-defaults.php). $Config->Set('Database.Host', $ConfigurationFormValues['Database.Host']); $Config->Set('Database.Name', $ConfigurationFormValues['Database.Name']); $Config->Set('Database.User', $ConfigurationFormValues['Database.User']); $Config->Set('Database.Password', $ConfigurationFormValues['Database.Password']); $Config->ClearSaveData(); Gdn::FactoryInstall(Gdn::AliasDatabase, 'Gdn_Database', PATH_LIBRARY . DS . 'database' . DS . 'class.database.php', Gdn::FactorySingleton, array(Gdn::Config('Database'))); // Install db structure & basic data. $Database = Gdn::Database(); $Drop = FALSE; // Gdn::Config('Garden.Version') === FALSE ? TRUE : FALSE; $Explicit = FALSE; try { include PATH_APPLICATIONS . DS . 'dashboard' . DS . 'settings' . DS . 'structure.php'; } catch (Exception $ex) { $this->Form->AddError($ex); } if ($this->Form->ErrorCount() > 0) { return FALSE; } // Create the administrative user $UserModel = Gdn::UserModel(); $UserModel->DefineSchema(); $UserModel->Validation->ApplyRule('Name', 'Username', self::UsernameError); $UserModel->Validation->ApplyRule('Name', 'Required', T('You must specify an admin username.')); $UserModel->Validation->ApplyRule('Password', 'Required', T('You must specify an admin password.')); $UserModel->Validation->ApplyRule('Password', 'Match'); $UserModel->Validation->ApplyRule('Email', 'Email'); if (!$UserModel->SaveAdminUser($ConfigurationFormValues)) { $this->Form->SetValidationResults($UserModel->ValidationResults()); } else { // The user has been created successfully, so sign in now $Authenticator = Gdn::Authenticator()->AuthenticateWith('password'); $Authenticator->FetchData($this->Form); $AuthUserID = $Authenticator->Authenticate(); } if ($this->Form->ErrorCount() > 0) { return FALSE; } // Assign some extra settings to the configuration file if everything succeeded. $ApplicationInfo = array(); include CombinePaths(array(PATH_APPLICATIONS . DS . 'dashboard' . DS . 'settings' . DS . 'about.php')); // Detect rewrite abilities try { $Query = Gdn::Request()->Url("entry", TRUE); $Results = ProxyHead($Query, array(), 1); $CanRewrite = FALSE; if (in_array(ArrayValue('StatusCode', $Results, 404), array(200, 302)) && ArrayValue('X-Garden-Version', $Results, 'None') != 'None') { $CanRewrite = TRUE; } } catch (Exception $e) { // cURL and fsockopen arent supported... guess? $CanRewrite = function_exists('apache_get_modules') && in_array('mod_rewrite', apache_get_modules()) ? TRUE : FALSE; } SaveToConfig(array('Garden.Version' => ArrayValue('Version', GetValue('Dashboard', $ApplicationInfo, array()), 'Undefined'), 'Garden.RewriteUrls' => $CanRewrite, 'Garden.CanProcessImages' => function_exists('gd_info'), 'EnabledPlugins.GettingStarted' => 'GettingStarted', 'EnabledPlugins.HTMLPurifier' => 'HtmlPurifier')); } } return $this->Form->ErrorCount() == 0 ? TRUE : FALSE; }
// Dispatcher. Gdn::factoryInstall(Gdn::AliasRouter, 'Gdn_Router'); Gdn::factoryInstall(Gdn::AliasDispatcher, 'Gdn_Dispatcher', '', Gdn::FactorySingleton, [Gdn::addonManager()]); // Smarty Templating Engine Gdn::factoryInstall('Smarty', 'Smarty'); Gdn::factoryInstall('ViewHandler.tpl', 'Gdn_Smarty'); // Slice handler Gdn::factoryInstall(Gdn::AliasSlice, 'Gdn_Slice'); // Remote Statistics Gdn::factoryInstall('Statistics', 'Gdn_Statistics', null, Gdn::FactorySingleton); Gdn::statistics(); // Regarding Gdn::factoryInstall('Regarding', 'Gdn_Regarding', null, Gdn::FactorySingleton); Gdn::regarding(); // Other objects. Gdn::FactoryInstall('BBCodeFormatter', 'BBCode', null, Gdn::FactorySingleton); Gdn::factoryInstall('Dummy', 'Gdn_Dummy'); /** * Extension Startup * * Allow installed addons to execute startup and bootstrap procedures that they may have, here. */ // Bootstrapping. foreach (Gdn::addonManager()->getEnabled() as $addon) { /* @var Addon $addon */ if ($bootstrapPath = $addon->getSpecial('bootstrap')) { $bootstrapPath = $addon->path($bootstrapPath); include $bootstrapPath; } } // Themes startup
public function Gdn_Dispatcher_BeforeDispatch_Handler($Sender) { if (C('Plugins.LocaleDeveloper.CaptureDefinitions')) { // Install the developer locale. $_Locale = new DeveloperLocale(Gdn::Locale()->Current(), C('EnabledApplications'), C('EnabledPlugins')); $tmp = Gdn::FactoryOverwrite(TRUE); Gdn::FactoryInstall(Gdn::AliasLocale, 'Gdn_Locale', NULL, Gdn::FactorySingleton, $_Locale); Gdn::FactoryOverwrite($tmp); unset($tmp); } }
<?php if (!defined('APPLICATION')) { exit; } /* Copyright 2008, 2009 Vanilla Forums Inc. This file is part of Garden. Garden is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Garden is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Garden. If not, see <http://www.gnu.org/licenses/>. Contact Vanilla Forums Inc. at support [at] vanillaforums [dot] com */ // Define the plugin: $PluginInfo['VanillaCommentReplies'] = array('Name' => 'Vanilla Replies', 'Description' => "DEPRECATED. Adds one-level-deep replies to comments in Vanilla discussions.", 'Version' => '1.0.1', 'Author' => "Mark O'Sullivan", 'AuthorEmail' => '*****@*****.**', 'AuthorUrl' => 'http://markosullivan.ca', 'RegisterPermissions' => FALSE, 'SettingsPermission' => FALSE); Gdn::FactoryInstall('ReplyModel', 'ReplyModel', PATH_PLUGINS . DS . 'VanillaCommentReplies' . DS . 'class.replymodel.php', Gdn::FactoryInstance, NULL, FALSE); class VanillaCommentRepliesPlugin extends Gdn_Plugin { public $ReplyModel; public function DiscussionController_BeforeCommentRender_Handler(&$Sender) { $this->DiscussionController_BeforeDiscussionRender_Handler($Sender); } public function DiscussionController_BeforeDiscussionRender_Handler(&$Sender) { $Sender->AddJsFile('replies.js', 'plugins/VanillaCommentReplies'); $Sender->AddCssFile('style.css', 'plugins/VanillaCommentReplies'); $this->ReplyModel = Gdn::Factory('ReplyModel'); $RequestMethod = strtolower($Sender->RequestMethod); if (in_array($RequestMethod, array('index', 'comment'))) { // Load the replies
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'; } // Include "Render" functions now - this way pluggables and custom confs can override them.
<?php if (!defined('APPLICATION')) { exit; } /** * @copyright Copyright 2008, 2009 Vanilla Forums Inc. * @license Proprietary */ $PluginInfo['IPBFormatter'] = array('Name' => 'IPB Formatter', 'Description' => 'Formats posts imported from Invision Power Board.', 'Version' => '1.0', 'RequiredApplications' => array('Vanilla' => '2.0.18'), 'RequiredPlugins' => FALSE, 'HasLocale' => FALSE, 'Author' => "Todd Burry", 'AuthorEmail' => '*****@*****.**', 'AuthorUrl' => 'http://vanillaforums.com/profile/todd'); Gdn::FactoryInstall('IPBFormatter', 'IPBFormatterPlugin', __FILE__, Gdn::FactorySingleton); class IPBFormatterPlugin extends Gdn_Plugin { /// Methods /// public function Format($String) { $String = str_replace(array('"', ''', ':', 'Â'), array('"', "'", ':', ''), $String); $String = str_replace('<#EMO_DIR#>', 'default', $String); $String = str_replace('<{POST_SNAPBACK}>', '<span class="SnapBack">»</span>', $String); // There is an issue with using uppercase code blocks, so they're forced to lowercase here $String = str_replace(array('[CODE]', '[/CODE]'), array('[code]', '[/code]'), $String); /** * IPB inserts line break markup tags at line breaks. They need to be removed in code blocks. * The original newline/line break should be left intact, so whitespace will be preserved in the pre tag. */ $String = preg_replace_callback('/\\[code\\].*?\\[\\/code\\]/is', function ($CodeBlocks) { return str_replace(array('<br />'), array(''), $CodeBlocks[0]); }, $String); /** * IPB formats some quotes as HTML. They're converted here for the sake of uniformity in presentation. * Attribute order seems to be standard. Spacing between the opening of the tag and the first attribute is variable.
if (!defined('APPLICATION')) { exit; } /* Copyright 2008, 2009 Mark O'Sullivan This file is part of Garden. Garden is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Garden is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Garden. If not, see <http://www.gnu.org/licenses/>. Contact Mark O'Sullivan at mark [at] lussumo [dot] com */ // Define the plugin: $PluginInfo['CssThemes'] = array('Description' => 'The Css Theme plugin caches css files and allows the colors to be themed in the application.', 'Version' => '1.0', 'RequiredApplications' => FALSE, 'RequiredTheme' => FALSE, 'RequiredPlugins' => FALSE, 'HasLocale' => TRUE, 'RegisterPermissions' => FALSE, 'SettingsUrl' => '/garden/plugin/cssthemes', 'SettingsPermission' => 'Garden.Themes.Manage', 'Author' => "Todd Burry", 'AuthorEmail' => '*****@*****.**', 'AuthorUrl' => 'http://toddburry.com'); $tmp = Gdn::FactoryOverwrite(TRUE); Gdn::FactoryInstall('CssCacher', 'Gdn_CssThemes', __FILE__); Gdn::FactoryOverwrite($tmp); unset($tmp); class Gdn_CssThemes implements Gdn_IPlugin { /// Constants /// /** * The Regex to capture themeable colors. * * This will capture a css color in four groups: * (Color)(CommentStart)(Name)(CommentEnd) * * @var string */ const RegEx = '/(#[0-9a-fA-F]{3,6})(\\s*\\/\\*\\s*)([^\\*]*?)(\\s*\\*\\/)/'; const UrlRegEx = '/(url\\s*\\([\'"]?)([\\w\\.]+?)(\\.\\w+)([\'"]?\\s*\\)\\s*)(\\/\\*\\s*NoFollow\\s*\\*\\/\\s*)?/';
if (!defined('APPLICATION')) { exit; } /* Copyright 2008, 2009 Vanilla Forums Inc. This file is part of Garden. Garden is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Garden is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Garden. If not, see <http://www.gnu.org/licenses/>. Contact Vanilla Forums Inc. at support [at] vanillaforums [dot] com */ // Define the plugin: $PluginInfo['Debugger'] = array('Description' => 'The debugger plugin displays database queries, their benchmarks, and page processing benchmarks at the bottom of each screen of the application.', 'Version' => '1.0', 'RequiredApplications' => FALSE, 'RequiredTheme' => FALSE, 'RequiredPlugins' => FALSE, 'HasLocale' => FALSE, 'RegisterPermissions' => array('Plugins.Debugger.View', 'Plugins.Debugger.Manage'), 'PluginUrl' => 'http://vanillaforums.org/addons/debugger', 'Author' => "Mark O'Sullivan", 'AuthorEmail' => '*****@*****.**', 'AuthorUrl' => 'http://markosullivan.ca'); // Install the debugger database. $tmp = Gdn::FactoryOverwrite(TRUE); Gdn::FactoryInstall(Gdn::AliasDatabase, 'Gdn_DatabaseDebug', dirname(__FILE__) . DS . 'class.database.debug.php', Gdn::FactorySingleton, array('Database')); Gdn::FactoryOverwrite($tmp); unset($tmp); class DebuggerPlugin extends Gdn_Plugin { // Specifying "Base" as the class name allows us to make the method get called for every // class that implements a base class's method. For example, Base_Render_After // would allow all controllers that call Controller.Render() to have that method // be called. It saves you from having to go: // Table_Render_After, Row_Render_After, Item_Render_After, // SignIn_Render_After, etc. and it essentially *_Render_After public function Base_Render_Before($Sender) { $Sender->AddCssFile('/plugins/Debugger/style.css'); } public function Base_AfterBody_Handler($Sender)
/** * Hook ourselves into Vanilla's Smarty. * PS: Smarty sux ;) */ public function adapt_smarty() { \Gdn::FactoryInstall('ViewHandler.tpl', '\\BishopB\\Forum\\GardenSmarty'); }