public function printable() { $form = $this->getEditForm($this->currentPageID()); if (!$form) { return false; } $form->transform(new PrintableTransformation()); $form->setActions(null); Requirements::clear(); Requirements::css(FRAMEWORK_ADMIN_DIR . '/dist/css/LeftAndMain_printable.css'); return array("PrintForm" => $form); }
public function setUp() { //nest config and injector for each test so they are effectively sandboxed per test Config::nest(); Injector::nest(); $this->originalReadingMode = Versioned::get_reading_mode(); // We cannot run the tests on this abstract class. if (get_class($this) == __CLASS__) { $this->markTestSkipped(sprintf('Skipping %s ', get_class($this))); return; } // Mark test as being run $this->originalIsRunningTest = self::$is_running_test; self::$is_running_test = true; // i18n needs to be set to the defaults or tests fail i18n::set_locale(i18n::config()->get('default_locale')); i18n::config()->date_format = null; i18n::config()->time_format = null; // Set default timezone consistently to avoid NZ-specific dependencies date_default_timezone_set('UTC'); // Remove password validation $this->originalMemberPasswordValidator = Member::password_validator(); $this->originalRequirements = Requirements::backend(); Member::set_password_validator(null); Cookie::config()->update('report_errors', false); if (class_exists('SilverStripe\\CMS\\Controllers\\RootURLController')) { RootURLController::reset(); } if (class_exists('Translatable')) { Translatable::reset(); } Versioned::reset(); DataObject::reset(); if (class_exists('SilverStripe\\CMS\\Model\\SiteTree')) { SiteTree::reset(); } Hierarchy::reset(); if (Controller::has_curr()) { Controller::curr()->setSession(Session::create(array())); } Security::$database_is_ready = null; // Add controller-name auto-routing // @todo Fix to work with namespaced controllers Director::config()->update('rules', array('$Controller//$Action/$ID/$OtherID' => '*')); $fixtureFiles = $this->getFixturePaths(); // Todo: this could be a special test model $this->model = DataModel::inst(); // Set up fixture if ($fixtureFiles || $this->usesDatabase) { if (!self::using_temp_db()) { self::create_temp_db(); } DataObject::singleton()->flushCache(); self::empty_temp_db(); foreach ($this->requireDefaultRecordsFrom as $className) { $instance = singleton($className); if (method_exists($instance, 'requireDefaultRecords')) { $instance->requireDefaultRecords(); } if (method_exists($instance, 'augmentDefaultRecords')) { $instance->augmentDefaultRecords(); } } foreach ($fixtureFiles as $fixtureFilePath) { $fixture = YamlFixture::create($fixtureFilePath); $fixture->writeInto($this->getFixtureFactory()); } $this->logInWithPermission("ADMIN"); } // Preserve memory settings $this->originalMemoryLimit = ini_get('memory_limit'); // turn off template debugging SSViewer::config()->update('source_file_comments', false); // Clear requirements Requirements::clear(); // Set up email $this->mailer = new TestMailer(); Injector::inst()->registerService($this->mailer, 'SilverStripe\\Control\\Email\\Mailer'); Email::config()->remove('send_all_emails_to'); }
public function groupimport() { Requirements::clear(); Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/client/dist/js/vendor.js'); Requirements::javascript(ltrim(FRAMEWORK_ADMIN_DIR . '/client/dist/js/MemberImportForm.js', '/')); Requirements::css(ltrim(FRAMEWORK_ADMIN_DIR . '/client/dist/styles/bundle.css', '/')); return $this->renderWith('BlankPage', array('Content' => ' ', 'Form' => $this->GroupImportForm()->forTemplate())); }
/** * Handle the print, for both the action button and the URL * * @param GridField $gridField * @param HTTPRequest $request * @return DBHTMLText */ public function handlePrint($gridField, $request = null) { set_time_limit(60); Requirements::clear(); Requirements::css(ltrim(FRAMEWORK_DIR . '/admin/client/dist/styles/GridField_print.css', '/')); if ($data = $this->generatePrintData($gridField)) { return $data->renderWith(get_class($gridField) . "_print"); } return null; }
/** * Send an email with HTML content. * * @see sendPlain() for sending plaintext emails only. * @uses Mailer->sendHTML() * * @param string $messageID Optional message ID so the message can be identified in bounces etc. * @return mixed Success of the sending operation from an MTA perspective. Doesn't actually give any indication if * the mail has been delivered to the recipient properly). See Mailer->sendPlain() for return type details. */ public function send($messageID = null) { Requirements::clear(); $this->parseVariables(); if (empty($this->from)) { $this->from = Email::config()->admin_email; } $headers = $this->customHeaders; if ($messageID) { $headers['X-SilverStripeMessageID'] = project() . '.' . $messageID; } if (project()) { $headers['X-SilverStripeSite'] = project(); } $to = $this->to; $from = $this->from; $subject = $this->subject; if ($sendAllTo = $this->config()->send_all_emails_to) { $subject .= " [addressed to {$to}"; $to = $sendAllTo; if ($this->cc) { $subject .= ", cc to {$this->cc}"; } if ($this->bcc) { $subject .= ", bcc to {$this->bcc}"; } $subject .= ']'; unset($headers['Cc']); unset($headers['Bcc']); } else { if ($this->cc) { $headers['Cc'] = $this->cc; } if ($this->bcc) { $headers['Bcc'] = $this->bcc; } } if ($ccAllTo = $this->config()->cc_all_emails_to) { if (!empty($headers['Cc']) && trim($headers['Cc'])) { $headers['Cc'] .= ', ' . $ccAllTo; } else { $headers['Cc'] = $ccAllTo; } } if ($bccAllTo = $this->config()->bcc_all_emails_to) { if (!empty($headers['Bcc']) && trim($headers['Bcc'])) { $headers['Bcc'] .= ', ' . $bccAllTo; } else { $headers['Bcc'] = $bccAllTo; } } if ($sendAllfrom = $this->config()->send_all_emails_from) { if ($from) { $subject .= " [from {$from}]"; } $from = $sendAllfrom; } Requirements::restore(); return self::mailer()->sendHTML($to, $from, $subject, $this->body, $this->attachments, $headers, $this->plaintext_body); }