/**
  * Set up constraints via _config.php
  */
 public static function set_up_constraints()
 {
     $constraints = Config::inst()->forClass("Discount")->constraints;
     foreach ($constraints as $constraint) {
         Object::add_extension("Discount", $constraint);
     }
 }
 function setUp()
 {
     parent::setUp();
     Object::add_extension("SiteTree", "FilesystemPublisher('assets/FilesystemPublisherTest-static-folder/')");
     $this->orig['domain_based_caching'] = FilesystemPublisher::$domain_based_caching;
     FilesystemPublisher::$domain_based_caching = false;
 }
 function setUp()
 {
     parent::setUp();
     Object::add_extension("SiteTree", "FilesystemPublisher('assets/HomepageForDomainTest-static-folder/')");
     HomepageForDomainExtension::$write_homepage_map = false;
     $this->orig['domain_based_caching'] = FilesystemPublisher::$domain_based_caching;
     FilesystemPublisher::$domain_based_caching = false;
 }
 public function tearDown()
 {
     // TODO This shouldn't need all arguments included
     if ($this->orig['File_searchable']) {
         Object::add_extension('File', 'FulltextSearchable(\'"Filename","Title","Content"\')');
     }
     parent::tearDown();
 }
 public static function add_weight($weight)
 {
     self::$weights[] = $weight;
     $class = "NewsWeight{$weight}";
     if (ClassInfo::exists($class)) {
         Object::add_extension('NewsHolder', $class);
     }
 }
 /**
  * Adds commenting to a {@link DataObject}
  *
  * @param string classname to add commenting to
  * @param array $setting Settings. See {@link self::$default_config} for
  *			available settings
  * 
  * @throws InvalidArgumentException
  */
 public static function add($class, $settings = false)
 {
     if ($settings && !is_array($settings)) {
         throw new InvalidArgumentException('$settings needs to be an array or null', E_USER_ERROR);
     }
     self::$enabled_classes[$class] = $settings;
     Object::add_extension($class, 'CommentsExtension');
 }
 function tearDown()
 {
     // TODO This shouldn't need all arguments included
     if ($this->orig['File_searchable']) {
         Object::add_extension('File', 'FulltextSearchable(\'Filename,Title,Content\')');
     }
     if ($this->orig['SiteTree_searchable']) {
         Object::add_extension('SiteTree', 'FulltextSearchable(\'Title,MenuTitle,Content,MetaTitle,MetaDescription,MetaKeywords\')');
     }
     parent::tearDown();
 }
 static function tear_down_once()
 {
     if (self::$origTranslatableSettings['has_extension']) {
         Object::add_extension('SiteTree', 'Translatable');
         Object::add_extension('SiteConfig', 'Translatable');
     }
     Translatable::set_default_locale(self::$origTranslatableSettings['default_locale']);
     Translatable::set_current_locale(self::$origTranslatableSettings['default_locale']);
     self::kill_temp_db();
     self::create_temp_db();
     parent::tear_down_once();
 }
 /**
  * Enable the default configuration of MySQL full-text searching on the given data classes.
  */
 static function enable($searchableClasses = array('SiteTree', 'File'))
 {
     $defaultColumns = array('SiteTree' => 'Title,MenuTitle,Content,MetaTitle,MetaDescription,MetaKeywords', 'File' => 'Filename,Title,Content');
     if (!is_array($searchableClasses)) {
         $searchableClasses = array($searchableClasses);
     }
     foreach ($searchableClasses as $class) {
         if (isset($defaultColumns[$class])) {
             Object::add_extension($class, "FulltextSearchable('{$defaultColumns[$class]}')");
         } else {
             throw new Exception("FulltextSearchable::enable() I don't know the default search columns for class '{$class}'");
         }
     }
     Object::add_extension("ContentController", "ContentControllerSearchExtension");
 }
 /**
  * Set up CheckoutPage_Controller decorators for managing steps
  */
 public static function setupSteps($steps = null)
 {
     if (!is_array($steps)) {
         //default steps
         $steps = array('membership' => 'CheckoutStep_Membership', 'contactdetails' => 'CheckoutStep_ContactDetails', 'shippingaddress' => 'CheckoutStep_Address', 'billingaddress' => 'CheckoutStep_Address', 'paymentmethod' => 'CheckoutStep_PaymentMethod', 'summary' => 'CheckoutStep_Summary');
     }
     CheckoutPage::config()->steps = $steps;
     if (!CheckoutPage::config()->first_step) {
         reset($steps);
         CheckoutPage::config()->first_step = key($steps);
     }
     //initiate extensions
     Object::add_extension("CheckoutPage_Controller", "SteppedCheckout");
     foreach ($steps as $action => $classname) {
         Object::add_extension("CheckoutPage_Controller", $classname);
     }
 }
 public function testExtraFieldsViaExtension()
 {
     // This extends ManyManyListTest_Secondary with the secondary extension that adds the relationship back
     // to the primary. The instance from the fixture is ManyManyListTest_SecondarySub, deliberately a sub-class of
     // the extended class.
     Object::add_extension('ManyManyListTest_Secondary', 'ManyManyListTest_IndirectSecondaryExtension');
     // Test from the primary (not extended) to the secondary (which is extended)
     $primary = $this->objFromFixture('ManyManyListTest_IndirectPrimary', 'manymany_extra_primary');
     $secondaries = $primary->Secondary();
     $extraFields = $secondaries->getExtraFields();
     $this->assertTrue(count($extraFields) > 0, 'has extra fields');
     $this->assertTrue(isset($extraFields['DocumentSort']), 'has DocumentSort');
     // Test from the secondary (which is extended) to the primary (not extended)
     $secondary = $this->objFromFixture('ManyManyListTest_SecondarySub', 'manymany_extra_secondary');
     $primaries = $secondary->Primary();
     $extraFields = $primaries->getExtraFields();
     $this->assertTrue(count($extraFields) > 0, 'has extra fields');
     $this->assertTrue(isset($extraFields['DocumentSort']), 'has DocumentSort');
 }
Exemple #12
0
 /**
  * Test {@link Object::add_extension()} has loaded DataExtension statics correctly.
  */
 function testAddExtensionLoadsStatics()
 {
     // Object::add_extension() will load DOD statics directly, so let's try adding a extension on the fly
     Object::add_extension('DataExtensionTest_Player', 'DataExtensionTest_PlayerExtension');
     // Now that we've just added the extension, we need to rebuild the database
     $this->resetDBSchema(true);
     // Create a test record with extended fields, writing to the DB
     $player = new DataExtensionTest_Player();
     $player->setField('Name', 'Joe');
     $player->setField('DateBirth', '1990-5-10');
     $player->Address = '123 somewhere street';
     $player->write();
     unset($player);
     // Pull the record out of the DB and examine the extended fields
     $player = DataObject::get_one('DataExtensionTest_Player', "\"Name\" = 'Joe'");
     $this->assertEquals($player->DateBirth, '1990-05-10');
     $this->assertEquals($player->Address, '123 somewhere street');
     $this->assertEquals($player->Status, 'Goalie');
 }
 static function set_up_once()
 {
     // needs to recreate the database schema with language properties
     self::kill_temp_db();
     // store old defaults
     self::$origTranslatableSettings['has_extension'] = singleton('SiteTree')->hasExtension('Translatable');
     self::$origTranslatableSettings['default_locale'] = Translatable::default_locale();
     // overwrite locale
     Translatable::set_default_locale("en_US");
     // refresh the decorated statics - different fields in $db with Translatable enabled
     if (!self::$origTranslatableSettings['has_extension']) {
         Object::add_extension('SiteTree', 'Translatable');
     }
     Object::add_extension('TranslatableTest_DataObject', 'Translatable');
     // clear singletons, they're caching old extension info which is used in DatabaseAdmin->doBuild()
     global $_SINGLETONS;
     $_SINGLETONS = array();
     // recreate database with new settings
     $dbname = self::create_temp_db();
     DB::set_alternative_database_name($dbname);
     parent::set_up_once();
 }
 /**
  * Enable the default configuration of MySQL full-text searching on the given data classes.
  * It can be used to limit the searched classes, but not to add your own classes.
  * For this purpose, please use {@link Object::add_extension()} directly:
  * <code>
  * Object::add_extension('MyObject', "FulltextSearchable('MySearchableField,'MyOtherField')");
  * </code>
  * 
  * Caution: This is a wrapper method that should only be used in _config.php,
  * and only be called once in your code.
  * 
  * @param Array $searchableClasses The extension will be applied to all DataObject subclasses
  *  listed here. Default: {@link SiteTree} and {@link File}.
  */
 static function enable($searchableClasses = array('SiteTree', 'File'))
 {
     $defaultColumns = array('SiteTree' => 'Title,MenuTitle,Content,MetaTitle,MetaDescription,MetaKeywords', 'File' => 'Filename,Title,Content');
     if (!is_array($searchableClasses)) {
         $searchableClasses = array($searchableClasses);
     }
     foreach ($searchableClasses as $class) {
         if (!class_exists($class)) {
             continue;
         }
         if (isset($defaultColumns[$class])) {
             Config::inst()->update($class, 'create_table_options', array('MySQLDatabase' => 'ENGINE=MyISAM'));
             Object::add_extension($class, "FulltextSearchable('{$defaultColumns[$class]}')");
         } else {
             throw new Exception("FulltextSearchable::enable() I don't know the default search columns for class '{$class}'");
         }
     }
     self::$searchable_classes = $searchableClasses;
     if (class_exists("ContentController")) {
         Object::add_extension("ContentController", "ContentControllerSearchExtension");
     }
 }
 /**
  * Enable the default configuration of Zend Search Lucene searching on the 
  * given data classes.
  * 
  * @param   Array   $searchableClasses  An array of classnames to scan.  Can 
  *                                      choose from SiteTree and/or File.
  *                                      To not scan any classes, for example
  *                                      if we will define custom fields to scan,
  *                                      pass in an empty array.
  *                                      Defaults to scan SiteTree and File.
  */
 public static function enable($searchableClasses = array('SiteTree', 'File'))
 {
     // We can't enable the search engine if we don't have QueuedJobs installed.
     if (!ClassInfo::exists('QueuedJobService')) {
         die('<strong>' . _t('ZendSearchLucene.ERROR', 'Error') . '</strong>: ' . _t('ZendSearchLucene.QueuedJobsRequired', 'Lucene requires the Queued jobs module.  See ' . '<a href="http://www.silverstripe.org/queued-jobs-module/">' . 'http://www.silverstripe.org/queued-jobs-module/</a>.'));
     }
     if (!is_array($searchableClasses)) {
         $searchableClasses = array($searchableClasses);
     }
     foreach ($searchableClasses as $class) {
         if (isset(self::$defaultColumns[$class])) {
             Object::add_extension($class, "ZendSearchLuceneSearchable('" . self::$defaultColumns[$class] . "')");
         } else {
             user_error("I don't know the default search columns for class '{$class}'");
             return;
         }
     }
     Object::add_extension('ContentController', 'ZendSearchLuceneContentController');
     DataObject::add_extension('SiteConfig', 'ZendSearchLuceneSiteConfig');
     Object::add_extension('LeftAndMain', 'ZendSearchLuceneCMSDecorator');
     Object::add_extension('StringField', 'ZendSearchLuceneTextHighlightDecorator');
     // Set up default encoding and analyzer
     Zend_Search_Lucene_Search_QueryParser::setDefaultEncoding(ZendSearchLuceneSearchable::$encoding);
     Zend_Search_Lucene_Analysis_Analyzer::setDefault(new StandardAnalyzer_Analyzer_Standard_English());
 }
<?php

Object::add_extension('Page', 'SOPageExtension');
<?php

/**
 * @package silverstripe-eventlocations
 */
if (!class_exists('Addressable')) {
    throw new Exception('The Event Locations module requires the Addressable module.');
}
Object::add_extension('CalendarDateTime', 'LocationDateTimeExtension');
Object::add_extension('EventTimeDetailsController', 'LocationDetailsExtension');
 /**
  * tearDown method that's called once per test class rather once per test method.
  */
 function tearDownOnce()
 {
     // If we have made changes to the extensions present, then migrate the database schema.
     if ($this->extensionsToReapply || $this->extensionsToRemove) {
         // Remove extensions added for testing
         foreach ($this->extensionsToRemove as $class => $extensions) {
             foreach ($extensions as $extension) {
                 Object::remove_extension($class, $extension);
             }
         }
         // Reapply ones removed
         foreach ($this->extensionsToReapply as $class => $extensions) {
             foreach ($extensions as $extension) {
                 Object::add_extension($class, $extension);
             }
         }
     }
     if ($this->extensionsToReapply || $this->extensionsToRemove || $this->extraDataObjects) {
         $this->resetDBSchema();
     }
 }
Exemple #19
0
<?php

DataObject::add_extension("Order", "OrderNumberSoldDecorator");
Object::add_extension("Product", "BuyableNumberSoldDecorator");
Object::add_extension("ProductVariation", "BuyableNumberSoldDecorator");
<?php

if (($RESTRICTED_OBJECTS_DIR = basename(dirname(__FILE__))) != 'restrictedobjects') {
    die("The restricted objects module must be installed in /restrictedobjects, not {$RESTRICTED_OBJECTS_DIR}");
}
if (!class_exists('MultiValueField')) {
    die('The restricted objects module requires the multivaluefield module from http://github.com/nyeholt/silverstripe-multivaluefield');
}
Director::addRules(100, array('Security/logout' => 'RestrictedSecurityController'));
Object::add_extension('Member', 'RestrictedMember');
// if we're in Dev, and have set "no initial checks", which is common during testing, disable perms
if ((Director::isDev() || Director::is_cli()) && isset($_GET['disable_perms'])) {
    Restrictable::set_enabled(false);
}
SS_Cache::set_cache_lifetime('restricted_perms', 3600);
<?php

Object::add_extension("Member", "SocialMemberDecorator");
<?php

Member::add_extension('Member', 'BusinessMember');
DataObject::add_extension('SiteTree', 'BrowseBusinessDecorator');
Object::add_extension('ContentController', 'BrowseBusinessDecorator_Controller');
//=============================== START business_directory =====================================
//BrowseBusinessDecorator::get_classes_that_can_have_businesses_as_children(array("BusinessListingPage"));
//=============================== END business_directory =====================================
<?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");
<?php

Director::addRules(50, array('createecommercevariations/$Action/$ProductID' => 'CreateEcommerceVariations', 'createecommercevariationsbatch/$Action' => 'CreateEcommerceVariations_Batch'));
Buyable::add_class("ProductVariation");
Object::add_extension("Product", "ProductWithVariationDecorator");
Object::add_extension("Product_Controller", "ProductWithVariationDecorator_Controller");
Object::add_extension("ProductBulkLoader", "ProductVariationBulkLoader");
Product_Controller::$allowed_actions[] = 'VariationForm';
Product_Controller::$allowed_actions[] = 'addvariation';
LeftAndMain::require_javascript(THIRDPARTY_DIR . "/jquery/jquery.js");
LeftAndMain::require_javascript(THIRDPARTY_DIR . "/jquery-livequery/jquery.livequery.js");
LeftAndMain::require_javascript("ecommerce_product_variation/javascript/CreateEcommerceVariationsField.js");
LeftAndMain::require_themed_css("CreateEcommerceVariationsField");
ProductsAndGroupsModelAdmin::$model_importers['ProductVariation'] = null;
//copy the lines between the START AND END line to your /mysite/_config.php file and choose the right settings
// __________________________________ START ECOMMERCE PRODUCT VARIATIONS MODULE CONFIG __________________________________
//____________HIGHLY RECOMMENDED
//ProductsAndGroupsModelAdmin::add_managed_model("ProductAttributeValue");
//ProductsAndGroupsModelAdmin::add_managed_model("ProductAttributeType");
//ProductsAndGroupsModelAdmin::add_managed_model("ProductVariation");
//____________ADD TO CART FORM INTERACTION
//ProductWithVariationDecorator_Controller::set_use_js_validation(false);
//ProductWithVariationDecorator_Controller::set_alternative_validator_class_name("MyValidatorClass");
//____________EASY SORTING - REQUIRES: http://sunny.svnrepository.com/svn/sunny-side-up-general/dataobjectsorter
//Object::add_extension('ProductAttributeValue', 'DataObjectSorterDOD');
//Object::add_extension('ProductAttributeType', 'DataObjectSorterDOD');
//DataObjectSorterDOD::set_also_update_sort_field(true);
//DataObjectSorterDOD::set_do_not_add_alternative_sort_field(true);
//____________CUSTOMISED CMS INTERACTION
//LeftAndMain::require_javascript("mysite/javascript/MyCreateEcommerceVariationsField.js");
//____________COLOUR OPTIONS
<?php

Object::add_extension('SiteTree', 'GaTracker');
/*
 * In order to use Google Analytics you first need to:
 * define('GaTrackingCode', 'UA-xxxxxx'); in your config
 * then add $GoogleAnalytics or $GoogleAnalyticsInline to your template(s)
 */
global $databaseConfig;
$databaseConfig = array("type" => 'MySQLDatabase', "server" => 'localhost', "username" => 'root', "password" => 'omega', "database" => 'vp', "path" => '');
MySQLDatabase::set_connection_charset('utf8');
// Set the current theme. More themes can be downloaded from
// http://www.silverstripe.org/themes/
SSViewer::set_theme('simple');
// Set the site locale
i18n::set_locale('en_US');
FulltextSearchable::enable();
// Enable nested URLs for this site (e.g. page/sub-page/)
if (class_exists('SiteTree')) {
    SiteTree::enable_nested_urls();
}
Director::set_environment_type("dev");
// add a button to remove formatting
HtmlEditorConfig::get('cms')->insertButtonsBefore('styleselect', 'removeformat');
// tell the button which tags it may remove
HtmlEditorConfig::get('cms')->setOption('removeformat_selector', 'b,strong,em,i,span,ins');
//remove font->span conversion
HtmlEditorConfig::get('cms')->setOption('convert_fonts_to_spans', 'false,');
HtmlEditorConfig::get('cms')->setOptions(array('valid_elements' => "@[id|class|style|title],#a[id|rel|rev|dir|tabindex|accesskey|type|name|href|target|title|class],-strong/-b[class],-em/-i[class],-strike[class],-u[class],#p[id|dir|class|align|style],-ol[class],-ul[class],-li[class],br,img[id|dir|longdesc|usemap|class|src|border|alt=|title|width|height|align],-sub[class],-sup[class],-blockquote[dir|class],-table[border=0|cellspacing|cellpadding|width|height|class|align|summary|dir|id|style],-tr[id|dir|class|rowspan|width|height|align|valign|bgcolor|background|bordercolor|style],tbody[id|class|style],thead[id|class|style],tfoot[id|class|style],#td[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],-th[id|dir|class|colspan|rowspan|width|height|align|valign|scope|style],caption[id|dir|class],-h1[id|dir|class|align|style],-h2[id|dir|class|align|style],-h3[id|dir|class|align|style],-h4[id|dir|class|align|style],-h5[id|dir|class|align|style],-h6[id|dir|class|align|style],hr[class],dd[id|class|title|dir],dl[id|class|title|dir],dt[id|class|title|dir],@[id,style,class],small", 'extended_valid_elements' => "img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|usemap],#iframe[src|name|width|height|align|frameborder|marginwidth|marginheight|scrolling],object[width|height|data|type],param[name|value],map[class|name|id],area[shape|coords|href|target|alt]"));
// TinyMCE cleanup on paste
HtmlEditorConfig::get('cms')->setOption('paste_auto_cleanup_on_paste', 'true');
HtmlEditorConfig::get('cms')->setOption('paste_remove_styles', 'true');
HtmlEditorConfig::get('cms')->setOption('paste_remove_styles_if_webkit', 'true');
HtmlEditorConfig::get('cms')->setOption('paste_strip_class_attributes', 'true');
GD::set_default_quality(80);
ShortcodeParser::get()->register('blogfeed', array('Page_Controller', 'BlogFeedHandler'));
ShortcodeParser::get()->register('spotlight', array('Page_Controller', 'StaffSpotlightHandler'));
Object::add_extension("BlogEntry", "BlogFieldExtension");
<?php

Object::add_extension('SiteConfig', 'SLSiteConfig');

Director::addRules(100,
	array(
		'leg//$Action/$Query' => 'SLCongressController'
	)
);
<?php

Object::add_extension('Image', 'GalleryPage_ImageExtension');
<?php

Object::add_extension('Controller', 'VBulletinAuthExtension');
Object::add_extension('Member', 'VBulletinRole');
<?php

/**
 * Decorates all of the FormField subclasses that get special
 * treatment from Bootstrap
 */
$dir = basename(dirname(__FILE__));
if ($dir != "bootstrap_forms") {
    user_error("The bootstrap_forms module must be in a directory named 'bootstrap_forms'", E_USER_ERROR);
}
if (!class_exists("GridField")) {
    user_error("The bootstrap_forms module requires SilverStripe 3.0 or greater.", E_USER_ERROR);
}
Object::add_extension("FormField", "BootstrapFormField");
Object::add_extension("TextField", "BootstrapTextField");
Object::add_extension("OptionsetField", "BootstrapOptionsetField");
Object::add_extension("FormAction", "BootstrapFormAction");
Object::add_extension("TextareaField", "BootstrapTextField");