function testCustomSearchFormClassesToTest() { FulltextSearchable::enable('File'); $page = new Page(); $controller = new ContentController($page); $form = $controller->SearchForm(); $this->assertEquals(array('File'), $form->getClassesToSearch()); }
public function testList() { $c = new ContentController(); $model = $c->getModel('helloworlds'); $worlds = $model->getItems(); var_dump($worlds); $this->assertNotEmpty($worlds); }
/** * Handles input, by calling according controller, * an sets view depending on url. * @return void */ public function handleInput() { //Create database, get content catalog $db = new Database(); $contentDAL = new contentDAL($db); $Catalog = new contentCatalog(); $contentController = new ContentController($contentDAL, $Catalog); $contentCatalog = $contentController->getContent(); //Handle login if ($this->navigationView->wantsToLogin()) { $login = new LoginController($this->users, $this->navigationView); $this->IsLoggedIn = $login->doLogin(); if ($this->IsLoggedIn) { $this->navigationView->redirToAdmin(); } else { $this->view = $login->getOutPut(); } } else { if ($this->navigationView->wantsToUpload() && isset($_SESSION['user'])) { $this->view = new AdminView(); $uploadController = new uploadController($this->view, $contentDAL, $this->users); $uploadController->doUpload(); } else { if ($this->navigationView->wantsToReg()) { $model = new RegFacade($this->userDAL); $this->view = new RegView($this->navigationView); $regControl = new RegisterController($model, $this->view); $regControl->addUser(); $this->view = new RegView($this->navigationView); } else { if ($this->navigationView->wantsToViewImage()) { $this->view = new ImageView(); $imgController = new ImageController($this->view, $contentCatalog); $imgController->getImage(); } else { if ($this->navigationView->wantsToViewContent()) { $commentView = new commentView(); $this->view = new ContentView($commentView); $id = $this->view->getID(); $commentDAL = new commentDAL($db); $commentController = new CommentController($commentView, $commentDAL); $comments = $commentController->doComment($id); $content = $contentController->getContentByID($id); $this->view->createHTML($content, $comments); } else { $this->view = new galleryView(); $galController = new GalleryController($this->view); $galController->doGallery($contentCatalog); } } } } } }
function testHasmethodBehaviour() { /* SiteTree should have all of the methods that Versioned has, because Versioned is listed in SiteTree's * extensions */ $st = new SiteTree(); $cc = new ContentController($st); $this->assertTrue($st->hasMethod('publish'), "Test SiteTree has publish"); $this->assertTrue($st->hasMethod('migrateVersion'), "Test SiteTree has migrateVersion"); /* This relationship should be case-insensitive, too */ $this->assertTrue($st->hasMethod('PuBliSh'), "Test SiteTree has PuBliSh"); $this->assertTrue($st->hasMethod('MiGratEVersIOn'), "Test SiteTree has MiGratEVersIOn"); /* In a similar manner, all of SiteTree's methods should be available on ContentController, because $failover is set */ $this->assertTrue($cc->hasMethod('canView'), "Test ContentController has canView"); $this->assertTrue($cc->hasMethod('linkorcurrent'), "Test ContentController has linkorcurrent"); /* This 'method copying' is transitive, so all of Versioned's methods should be available on ContentControler. * Once again, this is case-insensitive */ $this->assertTrue($cc->hasMethod('MiGratEVersIOn'), "Test ContentController has MiGratEVersIOn"); /* The above examples make use of SiteTree, Versioned and ContentController. Let's test defineMethods() more * directly, with some sample objects */ $objs = array(); $objs[] = new ObjectTest_T2(); $objs[] = new ObjectTest_T2(); $objs[] = new ObjectTest_T2(); // All these methods should exist and return true $trueMethods = array('testMethod','otherMethod','someMethod','t1cMethod','normalMethod'); foreach($objs as $i => $obj) { foreach($trueMethods as $method) { $methodU = strtoupper($method); $methodL = strtoupper($method); $this->assertTrue($obj->hasMethod($method), "Test that obj#$i has method $method"); $this->assertTrue($obj->hasMethod($methodU), "Test that obj#$i has method $methodU"); $this->assertTrue($obj->hasMethod($methodL), "Test that obj#$i has method $methodL"); $this->assertTrue($obj->$method(), "Test that obj#$i can call method $method"); $this->assertTrue($obj->$methodU(), "Test that obj#$i can call method $methodU"); $this->assertTrue($obj->$methodL(), "Test that obj#$i can call method $methodL"); } $this->assertTrue($obj->hasMethod('Wrapping'), "Test that obj#$i has method Wrapping"); $this->assertTrue($obj->hasMethod('WRAPPING'), "Test that obj#$i has method WRAPPING"); $this->assertTrue($obj->hasMethod('wrapping'), "Test that obj#$i has method wrapping"); $this->assertEquals("Wrapping", $obj->Wrapping(), "Test that obj#$i can call method Wrapping"); $this->assertEquals("Wrapping", $obj->WRAPPING(), "Test that obj#$i can call method WRAPPIGN"); $this->assertEquals("Wrapping", $obj->wrapping(), "Test that obj#$i can call method wrapping"); } }
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()); }
public function init() { parent::init(); // Import jquery and bootstrap js Requirements::javascript($this->ThemeDir() . "/js/libs/jquery.min.js"); Requirements::javascript($this->ThemeDir() . "/js/libs/bootstrap.min.js"); }
public function init() { parent::init(); Requirements::themedCSS('reset'); Requirements::themedCSS('layout'); Requirements::themedCSS('form'); Requirements::themedCSS('typography'); Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::css('mysite/css/demo.css'); Requirements::css('mysite/css/moduleSupport.css'); Requirements::customScript(<<<JS (function(i,s,o,g,r,a,m){ i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-84547-17', 'auto', { 'allowLinker': true }); ga('require', 'linker'); ga('linker:autoLink', [ \t'www.silverstripe.com', \t'www.silverstripe.org', \t'addons.silverstripe.org', \t'api.silverstripe.org', \t'docs.silverstripe.org', \t'userhelp.silverstripe.org', \t'demo.silverstripe.org' ]); ga('send', 'pageview'); JS ); }
public function init() { parent::init(); // Note: you should use SS template require tags inside your templates // instead of putting Requirements calls here. However these are // included so that our older themes still work Requirements::themedCSS('layout'); Requirements::themedCSS('comments'); Requirements::themedCSS('typography'); Requirements::themedCSS('form'); Requirements::themedCSS('slick'); if (!Cookie::get($StoryModeCookie)) { Cookie::set($StoryModeCookie, 'Normal'); } if (!Cookie::get($StorySizeCookie)) { Cookie::set($StorySizeCookie, 'Normal'); } // Increment page view counter $pagecounter = DataObject::get_one("PageCounter", "PageID='{$this->ID}'"); if (!$pagecounter) { $pagecounter = new PageCounter(); $pagecounter->PageID = $this->ID; } $pagecounter->Counter = $pagecounter->Counter + 1; $pagecounter->write(); }
public function init() { parent::init(); // You can include any CSS or JS required by your project here. // See: http://doc.silverstripe.org/framework/en/reference/requirements Requirements::css("https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css"); }
function init() { parent::init(); Requirements::themedCSS("layout"); Requirements::themedCSS("typography"); Requirements::themedCSS("form"); }
public function init() { parent::init(); Requirements::themedCSS('reset'); Requirements::themedCSS('layout'); Requirements::themedCSS('form'); Requirements::themedCSS('typography'); Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::css('mysite/css/demo.css'); Requirements::css('mysite/css/moduleSupport.css'); Requirements::customScript(<<<JS var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-84547-11']); _gaq.push(['_setDomainName', 'none']); _gaq.push(['_setAllowLinker', true]); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); JS ); }
public function init() { parent::init(); if (!$this->config()->service) { $this->httpError(404); } $this->setService($this->config()->service); $this->pageService = new StyleGuide\PageService($this); // redirect to the first action route if (!$this->request->param('Action')) { $page = $this->pageService->getPages()->first(); $this->redirect($page->Link); } // if no template set on the action route then redirect to the first child if (!$this->request->param('ChildAction') && !$this->pageService->getTemplate()) { $page = $this->pageService->getActivePage(); if (isset($page->Children)) { $childPage = $page->Children->first(); $this->redirect($childPage->Link); } } // set the service $this->setRequirements(); // load the fixture file $this->loadFixture(); }
public function init() { parent::init(); // Note: you should use SS template require tags inside your templates // instead of putting Requirements calls here. However these are // included so that our older themes still work Requirements::css('themes/simple/css/homepage.css'); Requirements::customScript(' $("a.scroll-arrow").mousedown( function(e) { e.preventDefault(); var container = $(this).parent().attr("id"); var direction = $(this).is("#scroll-right") ? "+=" : "-="; var totalWidth = -$(".row__inner").width(); $(".row__inner .tile").each(function() { totalWidth += $(this).outerWidth(true); }); $("#"+ container + " .row__inner").animate({ scrollLeft: direction + Math.min(totalWidth, 3000) },{ duration: 2500, easing: "swing", queue: false } ); }).mouseup(function(e) { $(".row__inner").stop(); });'); }
/** * Fake a Page_Controller by using that class as a failover */ public function __construct($dataRecord = null) { if (class_exists('Page_Controller')) { $dataRecord = new Page_Controller($dataRecord); } parent::__construct($dataRecord); }
public static function enable($searchableClasses = array('SiteTree')) { // Chris Bolt, removed file // Chris Bolt add site tree extension SiteTree::add_extension('BoltSearchIndexedSiteTree'); $defaultColumns = array('SiteTree' => '"Title","MenuTitle","Content","MetaDescription","SearchIndex"'); 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"); } }
public function init() { parent::init(); // Concatenate CSS Requirements::combine_files('style.css', array('mysite/css/layout.css', 'mysite/css/userstyles.css')); // Concatenate JavaScript Requirements::combine_files('scripts.js', array('mysite/javascript/lib/top-nav.js', 'mysite/javascript/vanilla.js')); // Google Analytics $config = SiteConfig::current_site_config(); $google = $config->GACode; $gaJS = <<<JS (function(i, s, o, g, r, a, m) { i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function() { (i[r].q = i[r].q || []).push(arguments) }, i[r].l = 1 * new Date(); a = s.createElement(o), m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m) })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga'); ga('create', '{$google}', 'auto'); ga('send', 'pageview'); JS; Requirements::customScript($gaJS); }
public function __construct() { parent::__construct(); $this->notification_repository = new SapphireFoundationMemberRevocationNotificationRepository(); $this->notification_manager = new RevocationNotificationManager(new SapphireFoundationMemberRepository(), new SapphireFoundationMemberRevocationNotificationRepository(), new SapphireElectionRepository(), new RevocationNotificationFactory(), SapphireTransactionManager::getInstance()); Requirements::css('elections/css/revocation.action.page.css'); }
public function init() { parent::init(); // Note: you should use SS template require tags inside your templates // instead of putting Requirements calls here. However these are // included so that our older themes still work }
public static function module_controller_for_request(ContentController $contentController, SS_HTTPRequest $request, $relationship = 'ContentModules') { $moduleURLSegment = $request->shift(); if ($module = $contentController->data()->{$relationship}()->filter('URLSegment', $moduleURLSegment)->first()) { $controller = self::controller_for($module, $contentController); //backwards compatibility support for modules handling actions directly //should move to using controllers to handle actions if ($controller instanceof ModuleController) { return $controller->handleRequest($request, new DataModel()); } else { $action = $request->shift(); if ($controller->hasMethod($action)) { return $controller->{$action}($request); } } } }
public function init() { parent::init(); Requirements::block('bootstrap-forms/css/bootstrap.css'); Requirements::block('bootstrap-forms/javascript/bootstrap_forms.js'); Requirements::block('framework/thirdparty/jquery/jquery.js'); Requirements::block('userforms/css/UserForm.css'); }
public function init() { parent::init(); Requirements::javascript("https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"); Requirements::javascript("pocket-watch/js/bootstrap.min.js"); Requirements::javascript("pocket-watch/js/jquery.mixitup.min.js"); Requirements::javascript("pocket-watch/js/call.mixitup.js"); }
public function __get($name) { if ($name == 'dic') { return $this->dic = new TwigContainer(); } else { return parent::__get($name); } }
public function init() { parent::init(); $this->loadCSS(); $this->loadFonts(); $this->customJQueryScripts(); $this->loadJS(); }
/** * Get search form * * @return Form */ public function SearchForm() { $form = parent::SearchForm(); $form->addExtraClass('navbar-form search')->setAttribute('role', 'search'); $fields = $form->Fields(); $fields->dataFieldByName('Search')->addExtraClass('form-control')->setAttribute('placeholder', 'Search')->setValue(''); return $form; }
/** * Tests {@link ContentController::ChildrenOf()} */ public function testChildrenOf() { $controller = new ContentController(); SiteTree::enable_nested_urls(); $this->assertEquals(1, $controller->ChildrenOf('/')->Count()); $this->assertEquals(1, $controller->ChildrenOf('/home/')->Count()); $this->assertEquals(2, $controller->ChildrenOf('/home/second-level/')->Count()); $this->assertEquals(0, $controller->ChildrenOf('/home/second-level/third-level/')->Count()); SiteTree::disable_nested_urls(); $this->assertEquals(1, $controller->ChildrenOf('/')->Count()); $this->assertEquals(1, $controller->ChildrenOf('/home/')->Count()); $this->assertEquals(2, $controller->ChildrenOf('/second-level/')->Count()); $this->assertEquals(0, $controller->ChildrenOf('/third-level/')->Count()); }
/** * Tests {@link ContentController::ChildrenOf()} */ public function testChildrenOf() { $controller = new ContentController(); Config::inst()->update('SiteTree', 'nested_urls', true); $this->assertEquals(1, $controller->ChildrenOf('/')->Count()); $this->assertEquals(1, $controller->ChildrenOf('/home/')->Count()); $this->assertEquals(2, $controller->ChildrenOf('/home/second-level/')->Count()); $this->assertEquals(0, $controller->ChildrenOf('/home/second-level/third-level/')->Count()); SiteTree::config()->nested_urls = false; $this->assertEquals(1, $controller->ChildrenOf('/')->Count()); $this->assertEquals(1, $controller->ChildrenOf('/home/')->Count()); $this->assertEquals(2, $controller->ChildrenOf('/second-level/')->Count()); $this->assertEquals(0, $controller->ChildrenOf('/third-level/')->Count()); }
public function init() { Requirements::set_backend(new BetterRequirements_Backend()); parent::init(); Requirements::set_combined_files_folder(project() . '/_combinedfiles'); Requirements::set_force_js_to_bottom(true); $this->requireJS(); $this->requireCSS(); }
public function init() { parent::init(); // Note: you should use <% require %> tags inside your templates instead of putting Requirements calls here. However // these are included so that our older themes still work Requirements::themedCSS("layout"); Requirements::themedCSS("typography"); Requirements::themedCSS("form"); }
/** * Tests for {@link SSViewer::current_theme()} for different behaviour * of user defined themes via {@link SiteConfig} and default theme * when no user themes are defined. */ function testCurrentTheme() { $config = SiteConfig::current_site_config(); $oldTheme = $config->Theme; $config->Theme = ''; $config->write(); SSViewer::set_theme('mytheme'); $this->assertEquals('mytheme', SSViewer::current_theme(), 'Current theme is the default - user has not defined one'); $config->Theme = 'myusertheme'; $config->write(); // Pretent to load the page $c = new ContentController(); $c->init(); $this->assertEquals('myusertheme', SSViewer::current_theme(), 'Current theme is a user defined one'); // Set the theme back to the original $config->Theme = $oldTheme; $config->write(); }
function init() { parent::init(); Requirements::themedCSS("layout"); Requirements::themedCSS("typography"); Requirements::themedCSS("form"); Requirements::javascript('mysite/javascript/extjs.js'); Requirements::javascript('themes/belmarkhomes/javascript/Page.js'); }