public function testEnableWithCustomClasses()
 {
     FulltextSearchable::enable(array('File'));
     $this->assertTrue(File::has_extension('FulltextSearchable'));
     File::remove_extension('FulltextSearchable');
     $this->assertFalse(File::has_extension('FulltextSearchable'));
 }
 public function testEnableWithCustomClasses()
 {
     FulltextSearchable::enable(array('File'));
     $this->assertTrue(Object::has_extension('File', 'FulltextSearchable'));
     // TODO This shouldn't need all arguments included
     Object::remove_extension('File', 'FulltextSearchable(\'"Filename","Title","Content"\')');
     $this->assertFalse(Object::has_extension('File', 'FulltextSearchable'));
 }
 function testCustomSearchFormClassesToTest()
 {
     FulltextSearchable::enable('File');
     $page = new Page();
     $controller = new ContentController($page);
     $form = $controller->SearchForm();
     $this->assertEquals(array('File'), $form->getClassesToSearch());
 }
	function setUpOnce() {
		// HACK Postgres doesn't refresh TSearch indexes when the schema changes after CREATE TABLE
		// MySQL will need a different table type
		self::kill_temp_db();
		FulltextSearchable::enable();
		self::create_temp_db();
		$this->resetDBSchema(true);
		parent::setUpOnce();
	}
 /**
  * Site search form
  */
 public function SearchForm()
 {
     $searchText = _t('SearchForm.SEARCH', 'Search');
     if ($this->owner->request && $this->owner->request->getVar('Search')) {
         $searchText = $this->owner->request->getVar('Search');
     }
     $fields = new FieldList(new TextField('Search', false, $searchText));
     $actions = new FieldList(new FormAction('results', _t('SearchForm.GO', 'Go')));
     $form = SearchForm::create($this->owner, 'SearchForm', $fields, $actions);
     $form->classesToSearch(FulltextSearchable::get_searchable_classes());
     return $form;
 }
	function testCustomSearchFormClassesToTest() {
		FulltextSearchable::enable('File');
		
		$page = new Page();
		$page->URLSegment = 'whatever';
		$page->Content = 'oh really?';
		$page->write();
		$page->publish('Stage', 'Live'); 
		$controller = new ContentController($page);
		$form = $controller->SearchForm(); 
		
		if (get_class($form) == 'SearchForm') $this->assertEquals(array('File'), $form->getClassesToSearch());
	}
 /**
  * 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 (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}'");
         }
     }
     self::$searchable_classes = $searchableClasses;
     Object::add_extension("ContentController", "ContentControllerSearchExtension");
 }
 /**
  * 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>
  * MyObject::add_extension("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}.
  */
 public static function enable($searchableClasses = array('SiteTree', 'File'))
 {
     $defaultColumns = array('SiteTree' => '"Title","MenuTitle","Content","MetaDescription"', 'File' => '"Name","Title"');
     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(MySQLSchemaManager::ID => 'ENGINE=MyISAM'));
             $class::add_extension("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")) {
         ContentController::add_extension("ContentControllerSearchExtension");
     }
 }
Example #9
0
 /**
  * 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");
     }
 }
Example #10
0
<?php

global $project;
$project = 'mysite';
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);
Example #11
0
<?php

global $project;
$project = 'mysite';
/** Use the _ss_environment.php file for configuration */
require_once 'conf/ConfigureFromEnv.php';
/** Set default language */
i18n::set_locale('en_US');
/** Uncomment to control SSL and www  */
if (!Director::is_cli() && Director::isLive()) {
    //    Director::forceWWW();
    //    Director::forceSSL();
}
define('PROJECT_THIRDPARTY_DIR', project() . '/thirdparty');
define('PROJECT_THIRDPARTY_PATH', project() . '/' . PROJECT_THIRDPARTY_DIR);
FulltextSearchable::enable(array('SiteTree'));
/**
 * it is suggested to set SS_ERROR_LOG in _ss_environment.php to enable logging,
 * alternatively you can use the line below for your custom logging settings
 * SS_Log::add_writer(new SS_LogFileWriter('../silverstripe-errors.log'), SS_Log::ERR);
 */
if (!Director::isLive()) {
    /**
     * set settings that should only be in dev and test
     */
} else {
    /**
     * we are in live mode, send errors per email
     */
    SS_Log::add_writer(new SS_LogEmailWriter('*****@*****.**'), SS_Log::ERR);
}
 public function setUpOnce()
 {
     parent::setUpOnce();
     FulltextSearchable::enable('File');
 }
 /**
  * Site search form.
  *
  * Similar to ContentControllerSearchExtension::SearchForm() but
  * redirecting to a suitable page to avoid invalid URLs such as
  * 'adg/AdgEntity.html/SearchForm'
  *
  * The default redirection is to '/home/SearchForm' but can be
  * changed with GtkdocControllerSearcExtension::setSearchAction().
  */
 public function SearchForm()
 {
     if ($this->owner->request && $this->owner->request->getVar('Search')) {
         $searchText = $this->owner->request->getVar('Search');
     } else {
         $searchText = _t('SearchForm.SEARCH', 'Search');
     }
     $fields = new FieldList(new TextField('Search', false, $searchText));
     $actions = new FieldList(new FormAction('results', _t('SearchForm.GO', 'Go')));
     $form = new SearchForm($this->owner, 'SearchForm', $fields, $actions);
     $form->classesToSearch(FulltextSearchable::get_searchable_classes());
     // The following line is the reason of this overriding: we must
     // redirect to a suitable page to avoid invalid URLs such as
     // 'adg/AdgEntity.html/SearchForm'
     $form->setFormAction(self::$search_action);
     return $form;
 }
<?php

global $project;
$project = 'mysite';
global $database;
$database = 'silverstripe_webdevelopment_com';
require_once "conf/ConfigureFromEnv.php";
//===================---------------- START php MODULE ----------------===================
date_default_timezone_set('Pacific/Auckland');
//===================---------------- END php MODULE ----------------===================
//===================---------------- START sapphire MODULE ----------------===================
FulltextSearchable::enable(array("SiteTree"));
if (Director::isLive()) {
    Director::forceWWW();
    SS_Log::add_writer(new SS_LogEmailWriter('*****@*****.**'), SS_Log::ERR);
} else {
    //BasicAuth::protect_entire_site(); see config.yml
}
//===================---------------- END sapphire MODULE ----------------===================