factoryInstall() public static method

Install a class to the factory.
See also: Gdn_Factory::Install()
public static factoryInstall ( string $Alias, string $ClassName, string $Path = '', string $FactoryType = self::FactorySingleton, $Data = null )
$Alias string An alias for the class that will be used to retreive instances of it.
$ClassName string The actual name of the class.
$Path string The path to the class' file. You can prefix the path with ~ to start at the application root.
$FactoryType string The way objects will be instantiated for the class. One of (Gdn::FactoryInstance, Gdn::FactoryPrototype, Gdn::FactorySingleton).
Example #1
0
 /**
  * Register the debug database that captures the queries.
  *
  * This event happens as early as possible so that all queries can be captured.
  *
  * @param Gdn_PluginManager $sender The {@link Gdn_PluginManager} firing the event.
  */
 public function gdn_pluginManager_afterStart_handler($sender)
 {
     $tmp = Gdn::factoryOverwrite(true);
     Gdn::factoryInstall(Gdn::AliasDatabase, 'Gdn_DatabaseDebug', dirname(__FILE__) . DS . 'class.databasedebug.php', Gdn::FactorySingleton, array('Database'));
     Gdn::factoryOverwrite($tmp);
     unset($tmp);
 }
 /**
  * Register mustache view handler
  *
  * @param Gdn_Dispatcher $sender
  */
 public function Gdn_Dispatcher_AppStartup_Handler($sender)
 {
     $pfolder = $this->getPluginFolder(true);
     // Register mustache layer as singleton
     $mustachePath = paths($pfolder, 'library/class.mustache.php');
     Gdn::factoryInstall('Mustache', 'Mustache', $mustachePath, Gdn::FactorySingleton);
     // Register mustache engine
     $enginePath = paths($pfolder, 'library/class.mustache_engine.php');
     Gdn::factoryInstall('Mustache_Engine', 'Mustache_Engine', $enginePath);
     // Register mustache view handler
     Gdn::factoryInstall('ViewHandler.mustache', 'Mustache');
 }
 /**
  * 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;
 }
Example #4
0
        include $bootstrapPath;
    }
}
// Themes startup
Gdn::themeManager()->start();
// Plugins startup
Gdn::pluginManager()->start();
/**
 * Locales
 *
 * Install any custom locales provided by applications and plugins, and set up
 * the locale management system.
 */
// Load the Garden locale system
$gdnLocale = new Gdn_Locale(c('Garden.Locale', 'en'), Gdn::addonManager());
Gdn::factoryInstall(Gdn::AliasLocale, 'Gdn_Locale', null, Gdn::FactorySingleton, $gdnLocale);
unset($gdnLocale);
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

/**
 * HtmLawed Plugin.
 *
 * @copyright 2009-2016 Vanilla Forums Inc.
 * @license http://www.opensource.org/licenses/gpl-2.0.php GNU GPL v2
 * @package HtmLawed
 */
$PluginInfo['HtmLawed'] = ['Description' => 'Adapts HtmLawed to work with Vanilla.', 'Version' => '1.2', 'Author' => 'Todd Burry', 'AuthorEmail' => '*****@*****.**', 'AuthorUrl' => 'http://vanillaforums.com/profile/todd', 'Hidden' => true];
Gdn::factoryInstall('HtmlFormatter', 'HtmLawedPlugin', __FILE__, Gdn::FactorySingleton);
/**
 * Class HTMLawedPlugin
 */
class HtmLawedPlugin extends Gdn_Plugin
{
    /** @var array Classes users may have in their content. */
    protected $allowedClasses = ['AlignCenter', 'AlignLeft', 'AlignRight', 'CodeBlock', 'CodeInline', 'P', 'post-clear-both', 'post-clear-left', 'post-clear-right', 'post-color-aqua', 'post-color-black', 'post-color-blue', 'post-color-fuchsia', 'post-color-gray', 'post-color-green', 'post-color-lime', 'post-color-maroon', 'post-color-navy', 'post-color-olive', 'post-color-orange', 'post-color-purple', 'post-color-red', 'post-color-silver', 'post-color-teal', 'post-color-white', 'post-color-yellow', 'post-float-left', 'post-float-right', 'post-font-size-h1', 'post-font-size-h2', 'post-font-size-large', 'post-font-size-larger', 'post-font-size-medium', 'post-font-size-small', 'post-font-size-smaller', 'post-font-size-x-large', 'post-font-size-x-small', 'post-font-size-xx-large', 'post-font-size-xx-small', 'post-fontfamily-arial', 'post-fontfamily-comicsansms', 'post-fontfamily-couriernew', 'post-fontfamily-default', 'post-fontfamily-georgia', 'post-fontfamily-impact', 'post-fontfamily-timesnewroman', 'post-fontfamily-trebuchetms', 'post-fontfamily-verdana', 'post-highlightcolor-aqua', 'post-highlightcolor-black', 'post-highlightcolor-blue', 'post-highlightcolor-fuchsia', 'post-highlightcolor-gray', 'post-highlightcolor-green', 'post-highlightcolor-lime', 'post-highlightcolor-maroon', 'post-highlightcolor-navy', 'post-highlightcolor-olive', 'post-highlightcolor-orange', 'post-highlightcolor-purple', 'post-highlightcolor-red', 'post-highlightcolor-silver', 'post-highlightcolor-teal', 'post-highlightcolor-white', 'post-highlightcolor-yellow', 'post-text-align-center', 'post-text-align-justify', 'post-text-align-left', 'post-text-align-right', 'post-text-decoration-line-through', 'Quote', 'QuoteAuthor', 'QuoteLink', 'QuoteText', 'Spoiled', 'Spoiler', 'SpoilerText', 'SpoilerTitle', 'UserQuote', 'UserSpoiler'];
    /** @var array HTML elements allowed to have classes in user generated content. */
    protected $classedElements = ['a', 'b', 'blockquote', 'code', 'dd', 'div', 'dl', 'dt', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'i', 'img', 'li', 'ol', 'p', 'pre', 'span', 'strong', 'ul'];
    /**
     * Filter provided HTML through htmlLawed and return the result.
     *
     * @param string $html String of HTML to filter.
     * @return string Returns the filtered HTML.
     */
    public function format($html)
    {
        $attributes = c('Garden.Html.BlockedAttributes', 'on*');
        $config = ['anti_link_spam' => ['`.`', ''], 'balance' => 1, 'cdata' => 3, 'comment' => 1, 'css_expression' => 1, 'deny_attribute' => $attributes, 'direct_list_nest' => 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', 'unique_ids' => 1, 'valid_xhtml' => 0];
        // Turn embedded videos into simple links (legacy workaround)
<?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.1', 'RequiredApplications' => array('Vanilla' => '2.0.18'), 'RequiredPlugins' => false, 'HasLocale' => false, 'Icon' => 'ipb.png', 'Author' => 'Todd Burry', 'AuthorEmail' => '*****@*****.**', 'AuthorUrl' => 'http://vanillaforums.com/profile/todd');
Gdn::factoryInstall('IPBFormatter', 'IPBFormatterPlugin', __FILE__, Gdn::FactorySingleton);
class IPBFormatterPlugin extends Gdn_Plugin
{
    /**
     *
     * @var BBCode
     */
    protected $_NBBC;
    /** @var null  */
    protected $_Media = null;
    /// Methods ///
    /**
     *
     *
     * @param $string
     * @return mixed|string
     */
    public function format($string)
    {
        $string = str_replace(array('&quot;', '&#39;', '&#58;', 'Â'), array('"', "'", ':', ''), $string);
        $string = str_replace('<#EMO_DIR#>', 'default', $string);