public function testSetup() { Object::useCustomClass('Email', 'SMTPEmail'); Email::set_mailer(new SmtpMailer()); SMTPEmail::set_mailer(new SmtpMailer()); $mailer = Email::mailer(); $this->assertEquals('SmtpMailer', get_class($mailer)); $mailer = SMTPEmail::mailer(); $this->assertEquals('SmtpMailer', get_class($mailer)); }
/** * @return void */ public function init() { parent::init(); $access = new IpAccess($this->getRequest()->getIP()); if (!$access->hasAccess()) { $access->respondNoAccess($this); } if (Config::inst()->get('AdminLogin', 'UseTheme') !== true) { // this prevents loading frontend css and javscript files Object::useCustomClass('Page_Controller', 'AdminLoginPage_Controller'); Requirements::css('adminlogin/css/style.css'); } Object::useCustomClass('MemberLoginForm', 'AdminLoginForm'); }
/** * Helper method to initialize the mailer * * @param string $apiKey * @throws Exception */ public static function setAsMailer() { $mandrillMailer = new MandrillMailer(); Email::set_mailer($mandrillMailer); if (defined('MANDRILL_SENDING_DISABLED') && MANDRILL_SENDING_DISABLED) { self::setSendingDisabled(); } if (defined('MANDRILL_ENABLE_LOGGING') && MANDRILL_ENABLE_LOGGING) { self::setEnableLogging(); } // Use custom classes Object::useCustomClass('Member_ChangePasswordEmail', 'Mandrill_ChangePasswordEmail'); Object::useCustomClass('Member_ForgotPasswordEmail', 'Mandrill_ForgotPasswordEmail'); }
public function init() { parent::init(); if (Config::inst()->get('IpAccess', 'enabled')) { $ipAccess = new IpAccess($this->owner->getRequest()->getIP(), Config::inst()->get('IpAccess', 'allowed_ips')); if (!$ipAccess->hasAccess()) { $reponse = ''; if (class_exists('ErrorPage', true)) { $response = ErrorPage::response_for(404); } return $this->owner->httpError(404, $response ? $response : 'The requested page could not be found.'); } } if (Config::inst()->get('AdminLogin', 'UseTheme') !== true) { // this prevents loading frontend css and javscript files Object::useCustomClass('Page_Controller', 'AdminLoginPage_Controller'); Requirements::css('adminlogin/css/style.css'); } Object::useCustomClass('MemberLoginForm', 'AdminLoginForm'); }
<?php define('MARKDOWN_MODULE_BASE', basename(dirname(__FILE__))); MarkdownExtension::ReplaceHTMLFields(); MarkdownEditorField::include_default_js(); if (ClassInfo::exists('CloudinaryUploadField')) { MarkdownEditorField::add_extension('MarkdownCloudinaryUpload'); } Object::useCustomClass('HtmlEditorField_Toolbar', 'MarkdownEditorField_Toolbar', true);
<?php define('SORTABLEGALLERY_DIR', basename(dirname(__FILE__))); //Image::add_extension('GalleryImage'); Object::add_extension('Image', 'GalleryImage'); Object::useCustomClass('UploadField_SelectHandler', 'SortableGalleryUploadField_SelectHandler');
<?php Object::useCustomClass('HtmlEditorField', 'CustomConfigHtmlEditorField');
<?php global $project; $project = 'mysite'; global $databaseConfig; $databaseConfig = array('type' => 'MySQLDatabase', 'server' => '127.0.0.1', 'username' => 'root', 'password' => '311a0oZu', 'database' => 'SS_mysite', 'path' => ''); // Set the site locale i18n::set_locale('en_US'); Object::useCustomClass('Member', 'SSMember');
<?php Object::add_extension('Page', 'VideoEmbedPageExtesion'); Object::add_extension('Oembed_Result', 'Oembed_ResultExtension'); if (class_exists("PhotoAlbum") && class_exists("PhotoAlbumExtension")) { Object::add_extension('PhotoAlbum', 'PhotoAlbumExtension'); } if (class_exists("PhotoGallery_Controller") && class_exists("PhotoGallery_ControllerExtension")) { Object::add_extension('PhotoGallery_Controller', 'PhotoGallery_ControllerExtension'); } if (class_exists("PhotoItem") && class_exists("PhotoItemExtension")) { Object::add_extension('PhotoItem', 'PhotoItemExtension'); Object::add_extension('VideoEmbed', 'VideoEmbedExtension'); } Object::useCustomClass('HtmlEditorField_Toolbar', 'HtmlEditorField_Toolbar_Extension', true); $oembedProviders = Config::inst()->get('Oembed', 'providers'); $categories = Config::inst()->get('File', 'app_categories'); $localProvider = array("http" => Director::absoluteURL('/oembed.json'), "https" => Director::absoluteURL('/oembed.json')); if (isset($categories['audio'])) { foreach ($categories['audio'] as $ext) { $oembedProviders['*' . ASSETS_DIR . '/*.' . $ext] = $localProvider; } } if (isset($categories['mov'])) { foreach ($categories['mov'] as $ext) { $oembedProviders['*' . ASSETS_DIR . '/*.' . $ext] = $localProvider; } } Config::inst()->update('Oembed', 'providers', $oembedProviders); ShortcodeParser::get('default')->register('embed', array('Oembed_Custom', 'handle_shortcode'));
<?php define('FRONTEND_ADMIN_DIR', basename(dirname(__FILE__))); Object::useCustomClass('Boolean', 'FrontEndBoolean', true); Object::useCustomClass('Enum', 'FrontEndEnum', true); //Object::useCustomClass('Image', 'FrontEndImage', true); Object::useCustomClass('HTMLText', 'FrontendEditorHTMLText', true); Object::useCustomClass('Text', 'FrontendEditorText', true); Object::useCustomClass('Varchar', 'FrontendEditorVarchar', true); //Image::add_extension('FrontEndImageExtension'); Object::add_extension('Page_Controller', 'FrontendEditingControllerExtension'); Object::add_extension('Page', 'FrontendAdminPageExtension'); if (class_exists("DynamicCacheExtension")) { Object::add_extension('DynamicCache', 'FrontEndAdminDynamicCacheExtension'); }
<?php // Replace MemberProfilePage with RegisterMemberPage(later change to only Controller) Object::useCustomClass('MemberProfilePage', 'RegisterMemberPage');
SilvercartPlugin::registerPluginProvider('SilvercartContactMessage', 'SilvercartContactMessagePluginProvider'); SilvercartPlugin::registerPluginProvider('SilvercartIncrementPositionQuantityForm', 'SilvercartIncrementPositionQuantityFormPluginProvider'); SilvercartPlugin::registerPluginProvider('SilvercartOrder', 'SilvercartOrderPluginProvider'); SilvercartPlugin::registerPluginProvider('SilvercartOrderPosition', 'SilvercartOrderPositionPluginProvider'); SilvercartPlugin::registerPluginProvider('SilvercartProduct', 'SilvercartProductPluginProvider'); SilvercartPlugin::registerPluginProvider('SilvercartProductAddCartFormDetail', 'SilvercartProductAddCartFormDetailPluginProvider'); SilvercartPlugin::registerPluginProvider('SilvercartProductAddCartFormList', 'SilvercartProductAddCartFormListPluginProvider'); SilvercartPlugin::registerPluginProvider('SilvercartProductAddCartFormTile', 'SilvercartProductAddCartFormTilePluginProvider'); SilvercartPlugin::registerPluginProvider('SilvercartProductAddCartForm', 'SilvercartProductAddCartFormPluginProvider'); SilvercartPlugin::registerPluginProvider('SilvercartProductCsvBulkLoader', 'SilvercartProductCsvBulkLoaderPluginProvider'); SilvercartPlugin::registerPluginProvider('SilvercartProductGroupPage_Controller', 'SilvercartProductGroupPage_ControllerPluginProvider'); SilvercartPlugin::registerPluginProvider('SilvercartRemovePositionForm', 'SilvercartRemovePositionFormPluginProvider'); SilvercartPlugin::registerPluginProvider('SilvercartShoppingCart', 'SilvercartShoppingCartPluginProvider'); SilvercartPlugin::registerPluginProvider('SilvercartShoppingCartPosition', 'SilvercartShoppingCartPositionPluginProvider'); // use custom classes Object::useCustomClass('Member_ForgotPasswordEmail', 'SilvercartCustomer_ForgotPasswordEmail'); // configure WidgetSet WidgetSetWidgetExtension::preventWidgetCreationByClass('SilvercartWidget'); SilvercartGridFieldBatchController::addBatchActionFor('SilvercartOrder', 'SilvercartGridFieldBatchAction_ChangeOrderStatus'); SilvercartGridFieldBatchController::addBatchActionFor('SilvercartOrder', 'SilvercartGridFieldBatchAction_PrintOrders'); SilvercartGridFieldBatchController::addBatchActionFor('SilvercartOrder', 'SilvercartGridFieldBatchAction_MarkAsSeen'); SilvercartGridFieldBatchController::addBatchActionFor('SilvercartOrder', 'SilvercartGridFieldBatchAction_MarkAsNotSeen'); SilvercartGridFieldBatchController::addBatchActionFor('SilvercartProduct', 'SilvercartGridFieldBatchAction_ActivateDataObject'); SilvercartGridFieldBatchController::addBatchActionFor('SilvercartProduct', 'SilvercartGridFieldBatchAction_DeactivateDataObject'); SilvercartGridFieldBatchController::addBatchActionFor('SilvercartProduct', 'SilvercartGridFieldBatchAction_ChangeAvailabilityStatus'); SilvercartGridFieldBatchController::addBatchActionFor('SilvercartProduct', 'SilvercartGridFieldBatchAction_ChangeManufacturer'); SilvercartGridFieldBatchController::addBatchActionFor('SilvercartProduct', 'SilvercartGridFieldBatchAction_ChangeProductGroup'); // ---------------------------------------------------------------------------- // Blacklists for SilvercartRestfulServer // ---------------------------------------------------------------------------- SilvercartRestfulServer::addApiAccessBlackListFields('Group', array('Locked', 'Sort', 'IPRestrictions', 'HtmlEditorConfig'));
<?php Deprecation::notification_version('1.0', 'retinaimages'); define('RETINA_MODULE_DIR', dirname(__FILE__)); Object::useCustomClass('Image', 'RetinaImage'); Object::useCustomClass('Image_Cached', 'RetinaImage_Cached'); // SiteTree uses new HtmlEditorField() instead of HtmlEditorField::create() // as a result if you want retina images in your WYSIWYG editor you'll need to // recreate the HtmlEditorField. Object::useCustomClass('HtmlEditorField', 'RetinaImageHtmlEditorField'); // tinyCMS additional HTML5 elements $wysiwyg = HtmlEditorConfig::get('cms')->getOption('valid_elements'); $wysiwyg .= ',-img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align|data*|srcset]'; HtmlEditorConfig::get('cms')->setOption('valid_elements', $wysiwyg);
<?php /** * * @author Deviate Ltd 2014-2015 http://www.deviate.net.nz * @package silverstripe-advancedassets */ define("SECURED_FILES_MODULE_NAME", "Advanced Assets"); define("SECURED_FILES_MODULE_DIR", "silverstripe-advancedassets"); define("SECURED_FILES_ASSET_SUBDIR", "_securedfiles"); if (!file_exists(BASE_PATH . DIRECTORY_SEPARATOR . SECURED_FILES_MODULE_DIR)) { $msg = "Module directory seems to be named incorrectly." . " The " . SECURED_FILES_MODULE_NAME . " module" . " should be installed into a folder named " . SECURED_FILES_MODULE_DIR; user_error($msg); } // Overload use of default {@link AssetAdmin} with the module's own {@link NonSecuredAssetAdmin}. Object::useCustomClass('AssetAdmin', 'NonSecuredAssetAdmin', true); CMSMenu::remove_menu_item('AssetAdmin'); CMSMenu::remove_menu_item('CMSSecuredFileAddController'); CMSMenu::remove_menu_item('CMSNonSecuredFileAddController'); // "Obliterate" the securedfiles' SecureFileExtension class. if (class_exists('SecureFileExtension')) { File::remove_extension("SecureFileExtension"); }
<?php define('SHOP_DIR', basename(__DIR__)); define('SHOP_PATH', BASE_PATH . DIRECTORY_SEPARATOR . SHOP_DIR); Object::useCustomClass('Currency', 'ShopCurrency', true); if ($checkoutsteps = CheckoutPage::config()->steps) { SteppedCheckout::setupSteps($checkoutsteps); }
/** * Tests that {@link Object::useCustomClass()} correnctly replaces normal and strong objects */ public function testUseCustomClass() { $obj1 = Object::create('ObjectTest_CreateTest'); $this->assertTrue($obj1->is_a('ObjectTest_CreateTest')); Object::useCustomClass('ObjectTest_CreateTest', 'ObjectTest_CreateTest2'); $obj2 = Object::create('ObjectTest_CreateTest'); $this->assertTrue($obj2->is_a('ObjectTest_CreateTest2')); $obj2_2 = Object::strong_create('ObjectTest_CreateTest'); $this->assertTrue($obj2_2->is_a('ObjectTest_CreateTest')); Object::useCustomClass('ObjectTest_CreateTest', 'ObjectTest_CreateTest3', true); $obj3 = Object::create('ObjectTest_CreateTest'); $this->assertTrue($obj3->is_a('ObjectTest_CreateTest3')); $obj3_2 = Object::strong_create('ObjectTest_CreateTest'); $this->assertTrue($obj3_2->is_a('ObjectTest_CreateTest3')); }
<?php // Use old-fashioned way of injecting the custom class // because using the YAML-method does not always work Object::useCustomClass('Date', 'LocalDate'); Object::useCustomClass('SS_Datetime', 'LocalDatetime');
<?php // override ShortcodeParser with the custom element parser Object::useCustomClass('ShortcodeParser', 'CustomElementsParser', true);
<?php Object::useCustomClass('TimeField', 'HTML5TimeField', true); Object::useCustomClass('DateField', 'HTML5DateField', true);
<?php // Define path constant $path = str_replace('\\', '/', __DIR__); $path_fragments = explode('/', $path); $dir_name = $path_fragments[count($path_fragments) - 1]; define('ABC_VENDOR_PATH', $dir_name . '/thirdparty'); define('ABC_PATH', $dir_name . '/src/abc'); // Configure Image Extension AbcImageExtension::$fallback_image = ABC_PATH . '/images/no-image.jpg'; // attach Extensions Image::add_extension('AbcImageExtension'); File::add_extension('AbcFileExtension'); LeftAndMain::add_extension('AbcLeftAndMainExtension'); SiteTree::add_extension('AbcSiteTreeExtension'); Security::add_extension('AbcSecurityExtension'); Controller::add_extension('AbcControllerExtension'); // DatePicker config Object::useCustomClass('DateField_View_JQuery', 'jQueryUIDateField_View');
/** * Tests that {@link Object::useCustomClass()} correnctly replaces normal and strong objects */ public function testUseCustomClass() { $obj1 = ObjectTest_CreateTest::create(); $this->assertTrue($obj1 instanceof ObjectTest_CreateTest); Object::useCustomClass('ObjectTest_CreateTest', 'ObjectTest_CreateTest2'); $obj2 = ObjectTest_CreateTest::create(); $this->assertTrue($obj2 instanceof ObjectTest_CreateTest2); $obj2_2 = Object::strong_create('ObjectTest_CreateTest'); $this->assertTrue($obj2_2 instanceof ObjectTest_CreateTest); Object::useCustomClass('ObjectTest_CreateTest', 'ObjectTest_CreateTest3', true); $obj3 = ObjectTest_CreateTest::create(); $this->assertTrue($obj3 instanceof ObjectTest_CreateTest3); $obj3_2 = Object::strong_create('ObjectTest_CreateTest'); $this->assertTrue($obj3_2 instanceof ObjectTest_CreateTest3); }
<?php global $project; $project = 'cocina'; ini_set('memory_limit', '80M'); ini_set('mysql.connect_timeout', 14400); date_default_timezone_set('Europe/Madrid'); global $database; //LOCAL //$database = 'SS_cocina'; //cocina.COM //$database = 'db562588325'; //HOMECOOKING $database = 'db563848102'; require_once 'conf/ConfigureFromEnv.php'; //Item::add_extension('ItemExtension'); Security::setDefaultAdmin("*****@*****.**", "gelves08"); Object::useCustomClass("MemberLoginForm", "CocinaLoginForm"); /*Object::add_extension("Group", 'GroupExtension'); Object::add_extension("ChefObject", 'Addressable'); Object::add_extension('ChefObject', 'Geocodable');*/ // Set the site locale i18n::set_locale('en_GB'); Translatable::set_default_locale('en_GB');
<?php Object::useCustomClass('ManyManyList', 'SilverStripe\\Auditor\\AuditHookManyManyList', true); Object::useCustomClass('Member_GroupSet', 'SilverStripe\\Auditor\\AuditHookMemberGroupSet', true);
<?php Object::useCustomClass('SS_Transliterator', 'BetterSlug');
<?php Object::useCustomClass('Email', 'SMTPEmail'); Email::set_mailer(new SmtpMailer()); SMTPEmail::set_mailer(new SmtpMailer());
<?php Object::useCustomClass('SS_Transliterator', 'ExtendedTransliterator');
<?php /** * Decorates all of the FormField subclasses that get special * treatment from Foundation */ $dir = basename(dirname(__FILE__)); define('FOUNDATIONFORMS_DIR', $dir); // TODO Opt-in Use Object::useCustomClass('MemberLoginForm', 'FoundationMemberLoginForm'); // TODO Opt-in Use if (class_exists('UserDefinedForm')) { Object::add_extension('UserDefinedForm_Controller', 'FoundationUserDefinedForm_Controller'); } // TODO Opt-in Use if (class_exists('CommentingController')) { Object::add_extension('CommentingController', 'FoundationCommentingController'); } // TODO Decorate Fields //Object::add_extension("FormField", "FoundationFormField"); //Object::add_extension("TextField", "FoundationTextField"); //Object::add_extension("OptionsetField", "FoundationOptionsetField"); //Object::add_extension("FormAction","FoundationFormAction"); //Object::add_extension("TextareaField", "FoundationTextField");
'' => 'RootURLController', 'api/v1' => 'RestfulServer', 'soap/v1' => 'SOAPModelAccess', 'dev' => 'DevelopmentAdmin' )); Director::addRules(1, array( '$URLSegment//$Action/$ID/$OtherID' => 'ModelAsController', )); /** * PHP 5.2 has a namespace conflict with our datetime class, * for legacy support, we use this overload method. * // ENFORCE STRONG_CREATE */ Object::useCustomClass('Datetime','SSDatetime',true); /** * Add pear parser to include path */ $path = Director::baseFolder().'/sapphire/parsers/'; set_include_path(str_replace('.' . PATH_SEPARATOR, '.' . PATH_SEPARATOR . $path . PATH_SEPARATOR, get_include_path())); /** * Define a default language different than english */ //i18n::set_locale('ca_AD'); /** * The root directory of TinyMCE
<?php Object::useCustomClass('SS_Datetime', 'I18nDatetime', true); /// Reset to all default configuration settings. $cfg = Config::inst(); //remove array configs (these get merged, rater than replaced) $cfg->remove("Payment", "allowed_gateways"); $cfg->remove("Order", "modifiers"); $cfg->remove("ProductCatalogAdmin", "managed_models"); $cfg->remove("ProductCategory", "sort_options"); // non-ecommerce $cfg->update('Member', 'unique_identifier_field', 'Email'); $cfg->update('Email', 'admin_email', '*****@*****.**'); $cfg->update('Payment', 'allowed_gateways', array('Dummy', 'Manual')); // i18n $cfg->update('ShopCurrency', 'decimal_delimiter', '.'); $cfg->update('ShopCurrency', 'thousand_delimiter', ''); $cfg->update('ShopCurrency', 'negative_value_format', '-%s'); // products $cfg->update('Product', 'global_allow_purchase', true); $cfg->update('ProductCatalogAdmin', 'managed_models', array("Product", "ProductCategory", "ProductVariation", "ProductAttributeType")); $cfg->update('Product_image', 'thumbnail_width', 140); $cfg->update('Product_image', 'thumbnail_height', 100); $cfg->update('Product_image', 'large_image_width', 200); $cfg->update('ProductCategory', 'include_child_groups', true); $cfg->update('ProductCategory', 'page_length', 10); $cfg->update('ProductCategory', 'must_have_price', true); $cfg->update('ProductCategory', 'sort_options', array('Title' => 'Alphabetical', 'Price' => 'Lowest Price')); // cart, order $cfg->update('Order', 'modifiers', array()); $cfg->update('Order', 'cancel_before_payment', true);
<?php // Use old-fashioned way of injecting the custom class // because using the YAML-method does not always work Object::useCustomClass('Date', 'LocalDate'); Object::useCustomClass('SS_Datetime', 'LocalDatetime'); Object::useCustomClass('Time', 'LocalTime');