Esempio n. 1
0
 public function testBrandingData()
 {
     $app = $this->getApp();
     $app['config']->set('general/branding/provided_by/0', 'testperson');
     $app['config']->set('general/branding/provided_by/1', 'testemail');
     $app['config']->set('general/branding/provided_link', Html::providerLink(['testperson', 'testemail']));
     $request = Request::create('/', 'GET');
     $response = $app->handle($request);
     $data = new BoltDataCollector($app);
     $data->collect($request, $response);
     $this->assertRegExp('/testperson/', $data->getBranding());
     $this->assertRegExp('/testemail/', $data->getBranding());
 }
Esempio n. 2
0
 public function testProviderLink()
 {
     $this->assertEquals('', Html::providerLink([]));
     $this->assertEquals('', Html::providerLink(false));
     $this->assertEquals('', Html::providerLink("foo"));
     $this->assertEquals('<a href="mailto:supercool@example.org">Supercool Webdesign Co.</a>', Html::providerLink(['*****@*****.**', 'Supercool Webdesign Co.']));
     $this->assertEquals('<a href="mailto:supercool@example.org">Supercool Webdesign Co.</a>', Html::providerLink(['mailto:supercool@example.org', 'Supercool Webdesign Co.']));
     $this->assertEquals('<a href="http://example.org" target="_blank">Supercool Webdesign Co.</a>', Html::providerLink(['example.org', 'Supercool Webdesign Co.']));
     $this->assertEquals('<a href="http://example.org" target="_blank">Supercool Webdesign Co.</a>', Html::providerLink(['http://example.org', 'Supercool Webdesign Co.']));
     $this->assertEquals('<a href="https://www.example.org" target="_blank">Supercool Webdesign Co.</a>', Html::providerLink(['https://www.example.org', 'Supercool Webdesign Co.']));
     $this->assertEquals('<a href="http://example.org" target="_blank">http://example.org</a>', Html::providerLink(['http://example.org']));
     $this->assertEquals('<a href="http://example.org" target="_blank">no html, please!</a>', Html::providerLink(['http://example.org', '<blink>no html, please!</blink>']));
     $this->assertEquals('<a href="http://example.org" target="_blank">http://example.org</a>', Html::providerLink(['http://example.org', '<b malformed HTML']));
 }
Esempio n. 3
0
 /**
  * Read and parse the config.yml and config_local.yml configuration files.
  *
  * @return array
  */
 protected function parseGeneral()
 {
     // Read the config and merge it. (note: We use temp variables to prevent
     // "Only variables should be passed by reference")
     $tempconfig = $this->parseConfigYaml('config.yml');
     $tempconfiglocal = $this->parseConfigYaml('config_local.yml');
     $general = Arr::mergeRecursiveDistinct($tempconfig, $tempconfiglocal);
     // Make sure old settings for 'contentsCss' are still picked up correctly
     if (isset($general['wysiwyg']['ck']['contentsCss'])) {
         $general['wysiwyg']['ck']['contentsCss'] = [1 => $general['wysiwyg']['ck']['contentsCss']];
     }
     // Make sure old settings for 'accept_file_types' are not still picked up. Before 1.5.4 we used to store them
     // as a regex-like string, and we switched to an array. If we find the old style, fall back to the defaults.
     if (isset($general['accept_file_types']) && !is_array($general['accept_file_types'])) {
         unset($general['accept_file_types']);
     }
     // Merge the array with the defaults. Setting the required values that aren't already set.
     $general = Arr::mergeRecursiveDistinct($this->defaultConfig, $general);
     // Make sure the cookie_domain for the sessions is set properly.
     if (empty($general['cookies_domain'])) {
         $request = Request::createFromGlobals();
         if ($request->server->get('HTTP_HOST', false)) {
             $hostSegments = explode(':', $request->server->get('HTTP_HOST'));
             $hostname = reset($hostSegments);
         } elseif ($request->server->get('SERVER_NAME', false)) {
             $hostname = $request->server->get('SERVER_NAME');
         } else {
             $hostname = '';
         }
         // Don't set the domain for a cookie on a "TLD" - like 'localhost', or if the server_name is an IP-address
         if (strpos($hostname, '.') > 0 && preg_match('/[a-z0-9]/i', $hostname)) {
             if (preg_match('/^www[0-9]*./', $hostname)) {
                 $general['cookies_domain'] = '.' . preg_replace('/^www[0-9]*./', '', $hostname);
             } else {
                 $general['cookies_domain'] = '.' . $hostname;
             }
             // Make sure we don't have consecutive '.'-s in the cookies_domain.
             $general['cookies_domain'] = str_replace('..', '.', $general['cookies_domain']);
         } else {
             $general['cookies_domain'] = '';
         }
     }
     // Make sure Bolt's mount point is OK:
     $general['branding']['path'] = '/' . Str::makeSafe($general['branding']['path']);
     // Set the link in branding, if provided_by is set.
     $general['branding']['provided_link'] = Html::providerLink($general['branding']['provided_by']);
     $general['database'] = $this->parseDatabase($general['database']);
     return $general;
 }