mirror of
https://github.com/silverstripe/silverstripe-iframe
synced 2024-10-22 11:05:51 +02:00
This merge will upgrade silverstripe iframe module for compatibility with SS4
Implement namespacing Update unit tests
This commit is contained in:
parent
454cee84df
commit
5b8e0ba0b1
47
.travis.yml
47
.travis.yml
@ -1,53 +1,34 @@
|
|||||||
# See https://github.com/silverstripe/silverstripe-travis-support for setup details
|
# See https://github.com/silverstripe/silverstripe-travis-support for setup details
|
||||||
|
language: php
|
||||||
|
|
||||||
sudo: false
|
sudo: false
|
||||||
|
|
||||||
language: php
|
|
||||||
|
|
||||||
php:
|
|
||||||
- 5.6
|
|
||||||
|
|
||||||
env:
|
env:
|
||||||
global:
|
global:
|
||||||
- DB=MYSQL CORE_RELEASE=3
|
- COMPOSER_ROOT_VERSION=1.0.x-dev
|
||||||
|
- CORE_RELEASE=4
|
||||||
|
# The path of the module when installed by composer
|
||||||
- MODULE_PATH=iframe
|
- MODULE_PATH=iframe
|
||||||
- COVERAGE=0
|
|
||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
|
fast_finish: true
|
||||||
include:
|
include:
|
||||||
- php: 5.6
|
- php: 5.6
|
||||||
env: DB=MYSQL CORE_RELEASE=3.5
|
env: DB=MYSQL
|
||||||
- php: 5.6
|
- php: 7.0
|
||||||
env: DB=PGSQL CORE_RELEASE=3.5
|
env: DB=MYSQL
|
||||||
- php: 7.1
|
- php: 7.1
|
||||||
env: DB=MYSQL CORE_RELEASE=3.6
|
env: DB=MYSQL
|
||||||
# Allowed to fail, meaning delayed code coverage reports
|
|
||||||
- php: 5.5.9
|
|
||||||
env: DB=MYSQL CORE_RELEASE=3 COVERAGE=1
|
|
||||||
allow_failures:
|
|
||||||
- php: 5.5.9
|
|
||||||
fast_finish: true
|
|
||||||
|
|
||||||
before_install:
|
|
||||||
- pip install --user codecov
|
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- composer self-update || true
|
- composer self-update || true
|
||||||
|
- phpenv rehash
|
||||||
|
- phpenv config-rm xdebug.ini
|
||||||
|
- composer validate
|
||||||
- git clone git://github.com/silverstripe/silverstripe-travis-support.git ~/travis-support
|
- git clone git://github.com/silverstripe/silverstripe-travis-support.git ~/travis-support
|
||||||
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
|
- php ~/travis-support/travis_setup.php --source `pwd` --target ~/builds/ss
|
||||||
- cd ~/builds/ss
|
- cd ~/builds/ss
|
||||||
- composer install
|
- composer install --prefer-dist
|
||||||
|
|
||||||
script:
|
script:
|
||||||
# Execute tests with no coverage. This is the fastest option
|
- vendor/bin/phpunit $MODULE_PATH/tests
|
||||||
- "if [ \"$COVERAGE\" = \"0\" ]; then vendor/bin/phpunit $MODULE_PATH/tests/; fi"
|
|
||||||
|
|
||||||
# Execute tests with coverage. Do this for a small
|
|
||||||
- "if [ \"$COVERAGE\" = \"1\" ]; then vendor/bin/phpunit --coverage-clover=coverage.clover $MODULE_PATH/tests/; fi"
|
|
||||||
|
|
||||||
after_script:
|
|
||||||
- "if [ \"$COVERAGE\" = \"1\" ]; then mv coverage.clover ~/build/$TRAVIS_REPO_SLUG/; fi"
|
|
||||||
- cd ~/build/$TRAVIS_REPO_SLUG
|
|
||||||
- wget https://scrutinizer-ci.com/ocular.phar
|
|
||||||
- "if [ \"$COVERAGE\" = \"1\" ]; then travis_retry codecov && travis_retry php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi"
|
|
||||||
|
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
namespace SilverStripe\IFrame;
|
||||||
|
|
||||||
|
use Page;
|
||||||
|
use SilverStripe\Forms\TextField;
|
||||||
|
use SilverStripe\Forms\DropdownField;
|
||||||
|
use SilverStripe\Forms\CheckboxField;
|
||||||
|
use SilverStripe\Forms\NumericField;
|
||||||
|
use SilverStripe\Forms\HTMLEditor\HtmlEditorField;
|
||||||
/**
|
/**
|
||||||
* Iframe page type embeds an iframe of URL of choice into the page.
|
* Iframe page type embeds an iframe of URL of choice into the page.
|
||||||
* CMS editor can choose width, height, or set it to attempt automatic size configuration.
|
* CMS editor can choose width, height, or set it to attempt automatic size configuration.
|
||||||
@ -6,7 +14,7 @@
|
|||||||
|
|
||||||
class IFramePage extends Page
|
class IFramePage extends Page
|
||||||
{
|
{
|
||||||
public static $db = array(
|
private static $db = array(
|
||||||
'IFrameURL' => 'Text',
|
'IFrameURL' => 'Text',
|
||||||
'AutoHeight' => 'Boolean(1)',
|
'AutoHeight' => 'Boolean(1)',
|
||||||
'AutoWidth' => 'Boolean(1)',
|
'AutoWidth' => 'Boolean(1)',
|
||||||
@ -17,14 +25,14 @@ class IFramePage extends Page
|
|||||||
'ForceProtocol' => 'Varchar',
|
'ForceProtocol' => 'Varchar',
|
||||||
);
|
);
|
||||||
|
|
||||||
public static $defaults = array(
|
private static $defaults = array(
|
||||||
'AutoHeight' => '1',
|
'AutoHeight' => '1',
|
||||||
'AutoWidth' => '1',
|
'AutoWidth' => '1',
|
||||||
'FixedHeight' => '500',
|
'FixedHeight' => '500',
|
||||||
'FixedWidth' => '0'
|
'FixedWidth' => '0'
|
||||||
);
|
);
|
||||||
|
|
||||||
public static $description = 'Embeds an iframe into the body of the page.';
|
private static $description = 'Embeds an iframe into the body of the page.';
|
||||||
|
|
||||||
public function getCMSFields()
|
public function getCMSFields()
|
||||||
{
|
{
|
||||||
@ -113,30 +121,10 @@ class IFramePage extends Page
|
|||||||
$allowed_schemes = array('http', 'https');
|
$allowed_schemes = array('http', 'https');
|
||||||
if ($matches = parse_url($this->IFrameURL)) {
|
if ($matches = parse_url($this->IFrameURL)) {
|
||||||
if (isset($matches['scheme']) && !in_array($matches['scheme'], $allowed_schemes)) {
|
if (isset($matches['scheme']) && !in_array($matches['scheme'], $allowed_schemes)) {
|
||||||
$result->error(_t('IFramePage.VALIDATION.BANNEDURLSCHEME', "This URL scheme is not allowed."));
|
$result->addError(_t('IFramePage.VALIDATION_BANNEDURLSCHEME', "This URL scheme is not allowed."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class IFramePage_Controller extends Page_Controller
|
|
||||||
{
|
|
||||||
public function init()
|
|
||||||
{
|
|
||||||
parent::init();
|
|
||||||
|
|
||||||
if ($this->ForceProtocol) {
|
|
||||||
if ($this->ForceProtocol == 'http://' && Director::protocol() != 'http://') {
|
|
||||||
return $this->redirect(preg_replace('#https://#', 'http://', $this->AbsoluteLink()));
|
|
||||||
} elseif ($this->ForceProtocol == 'https://' && Director::protocol() != 'https://') {
|
|
||||||
return $this->redirect(preg_replace('#http://#', 'https://', $this->AbsoluteLink()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->IFrameURL) {
|
|
||||||
Requirements::javascript('iframe/javascript/iframe_page.js');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
27
code/IFramePageController.php
Normal file
27
code/IFramePageController.php
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\IFrame;
|
||||||
|
|
||||||
|
use SilverStripe\CMS\Controllers\ContentController;
|
||||||
|
use SilverStripe\Control\Director;
|
||||||
|
use SilverStripe\View\Requirements;
|
||||||
|
|
||||||
|
class IFramePageController extends ContentController
|
||||||
|
{
|
||||||
|
protected function init()
|
||||||
|
{
|
||||||
|
parent::init();
|
||||||
|
|
||||||
|
if ($this->ForceProtocol) {
|
||||||
|
if ($this->ForceProtocol == 'http://' && Director::protocol() != 'http://') {
|
||||||
|
return $this->redirect(preg_replace('#https://#', 'http://', $this->AbsoluteLink()));
|
||||||
|
} elseif ($this->ForceProtocol == 'https://' && Director::protocol() != 'https://') {
|
||||||
|
return $this->redirect(preg_replace('#http://#', 'https://', $this->AbsoluteLink()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->IFrameURL) {
|
||||||
|
Requirements::javascript('iframe/javascript/iframe_page.js');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -11,12 +11,23 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"silverstripe/framework": "3.*",
|
"silverstripe/framework": "^4@dev",
|
||||||
"silverstripe/cms": "3.*"
|
"silverstripe/cms": "^4@dev"
|
||||||
},
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/PHPUnit": "^5.7"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"SilverStripe\\IFrame\\": "code/",
|
||||||
|
"SilverStripe\\IFrame\\Tests\\": "tests/"
|
||||||
|
}
|
||||||
|
},
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "1.0.x-dev"
|
"dev-master": "2.0.x-dev"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"prefer-stable": true
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,5 @@ ar:
|
|||||||
DESCRIPTION: 'يقوم بتضمين آى فريم بداخل جسم الصفحة.'
|
DESCRIPTION: 'يقوم بتضمين آى فريم بداخل جسم الصفحة.'
|
||||||
PLURALNAME: 'الصفحات الرئيسية'
|
PLURALNAME: 'الصفحات الرئيسية'
|
||||||
SINGULARNAME: 'صفحة الإطار'
|
SINGULARNAME: 'صفحة الإطار'
|
||||||
IframePage:
|
|
||||||
ExternalNote: 'من فضلك لاحظ قطاع المحتوى القادم و الذى من المحتمل أن يكون مستلم من مصدر خارجى (آى فريم فى صيغة اتش تى إم إل), و يمكن أن يقوم بتصرفات غير معتادة لقراء الشاشة.'
|
ExternalNote: 'من فضلك لاحظ قطاع المحتوى القادم و الذى من المحتمل أن يكون مستلم من مصدر خارجى (آى فريم فى صيغة اتش تى إم إل), و يمكن أن يقوم بتصرفات غير معتادة لقراء الشاشة.'
|
||||||
Loading: 'تحميل المحتوى'
|
Loading: 'تحميل المحتوى'
|
||||||
SiteTree:
|
|
||||||
PLURALNAME: صفحات
|
|
||||||
SINGULARNAME: صفحة
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
cs:
|
cs:
|
||||||
IFramePage:
|
IFramePage:
|
||||||
PLURALNAME: 'Základní stránky'
|
PLURALNAME: 'Základní stránky'
|
||||||
SiteTree:
|
|
||||||
PLURALNAME: Stránky
|
|
||||||
|
@ -3,11 +3,6 @@ de:
|
|||||||
DESCRIPTION: 'Bettet eine andere Seite mittels Iframe ein.'
|
DESCRIPTION: 'Bettet eine andere Seite mittels Iframe ein.'
|
||||||
PLURALNAME: 'Iframe Seiten'
|
PLURALNAME: 'Iframe Seiten'
|
||||||
SINGULARNAME: 'Iframe Seite'
|
SINGULARNAME: 'Iframe Seite'
|
||||||
VALIDATION:
|
VALIDATION_BANNEDURLSCHEME: 'Dieses URL-Schema ist nicht erlaubt.'
|
||||||
BANNEDURLSCHEME: 'Dieses URL-Schema ist nicht erlaubt.'
|
|
||||||
IframePage:
|
|
||||||
ExternalNote: 'Bitte beachten Sie, dass der folgende Inhalt von einer anderen Quelle eingebunden wird (mittels IFRAME) und dadurch evtl. Probleme bei Screenreadern auftreten können.'
|
ExternalNote: 'Bitte beachten Sie, dass der folgende Inhalt von einer anderen Quelle eingebunden wird (mittels IFRAME) und dadurch evtl. Probleme bei Screenreadern auftreten können.'
|
||||||
Loading: 'Lade Inhalt...'
|
Loading: 'Lade Inhalt...'
|
||||||
SiteTree:
|
|
||||||
PLURALNAME: Seiten
|
|
||||||
SINGULARNAME: Seite
|
|
||||||
|
@ -3,11 +3,6 @@ en:
|
|||||||
DESCRIPTION: 'Embeds an iframe into the body of the page.'
|
DESCRIPTION: 'Embeds an iframe into the body of the page.'
|
||||||
PLURALNAME: 'Base Pages'
|
PLURALNAME: 'Base Pages'
|
||||||
SINGULARNAME: 'I Frame Page'
|
SINGULARNAME: 'I Frame Page'
|
||||||
VALIDATION:
|
VALIDATION_BANNEDURLSCHEME: 'This URL scheme is not allowed.'
|
||||||
BANNEDURLSCHEME: 'This URL scheme is not allowed.'
|
|
||||||
IframePage:
|
|
||||||
ExternalNote: 'Please note the following section of content is possibly being delivered from an external source (IFRAME in HTML terms), and may present unusual experiences for screen readers.'
|
ExternalNote: 'Please note the following section of content is possibly being delivered from an external source (IFRAME in HTML terms), and may present unusual experiences for screen readers.'
|
||||||
Loading: 'Loading content...'
|
Loading: 'Loading content...'
|
||||||
SiteTree:
|
|
||||||
PLURALNAME: Pages
|
|
||||||
SINGULARNAME: Page
|
|
||||||
|
@ -3,11 +3,6 @@ eo:
|
|||||||
DESCRIPTION: 'Enkorpigas je iframe (kadro) en la korpon de la paĝo.'
|
DESCRIPTION: 'Enkorpigas je iframe (kadro) en la korpon de la paĝo.'
|
||||||
PLURALNAME: 'Bazaj paĝoj'
|
PLURALNAME: 'Bazaj paĝoj'
|
||||||
SINGULARNAME: 'Paĝo de iframe (kadro)'
|
SINGULARNAME: 'Paĝo de iframe (kadro)'
|
||||||
VALIDATION:
|
VALIDATION_BANNEDURLSCHEME: 'Tiu URL-skemo be estas permesita.'
|
||||||
BANNEDURLSCHEME: 'Tiu URL-skemo be estas permesita.'
|
|
||||||
IframePage:
|
|
||||||
ExternalNote: 'Bonvole notu ke la sekva sekcio de enhavo eble liveriĝas el ekstera fonto (IFRAME en HTML-termoj), kaj eble prezentos nekutimajn spertojn por ekranlegantoj.'
|
ExternalNote: 'Bonvole notu ke la sekva sekcio de enhavo eble liveriĝas el ekstera fonto (IFRAME en HTML-termoj), kaj eble prezentos nekutimajn spertojn por ekranlegantoj.'
|
||||||
Loading: 'Ŝargas enhavon...'
|
Loading: 'Ŝargas enhavon...'
|
||||||
SiteTree:
|
|
||||||
PLURALNAME: Paĝoj
|
|
||||||
SINGULARNAME: Paĝo
|
|
||||||
|
@ -2,6 +2,3 @@ fa_IR:
|
|||||||
IFramePage:
|
IFramePage:
|
||||||
PLURALNAME: 'صفحه اصلی'
|
PLURALNAME: 'صفحه اصلی'
|
||||||
SINGULARNAME: 'صفحه I Frame'
|
SINGULARNAME: 'صفحه I Frame'
|
||||||
SiteTree:
|
|
||||||
PLURALNAME: صفحات
|
|
||||||
SINGULARNAME: صفحه
|
|
||||||
|
@ -3,9 +3,5 @@ fi:
|
|||||||
DESCRIPTION: 'Upottaa iframen sivulle.'
|
DESCRIPTION: 'Upottaa iframen sivulle.'
|
||||||
PLURALNAME: 'Pohjasivut'
|
PLURALNAME: 'Pohjasivut'
|
||||||
SINGULARNAME: 'I Frame sivu'
|
SINGULARNAME: 'I Frame sivu'
|
||||||
IframePage:
|
|
||||||
ExternalNote: 'Huomioithan, että seuraava sisältöosio on upotettu ulkopuolisesta lähteestä (HTML-kielen IFRAME-käskyllä) ja saattaa aiheuttaa odottamattoman käyttökokemuksen selaimessa.'
|
ExternalNote: 'Huomioithan, että seuraava sisältöosio on upotettu ulkopuolisesta lähteestä (HTML-kielen IFRAME-käskyllä) ja saattaa aiheuttaa odottamattoman käyttökokemuksen selaimessa.'
|
||||||
Loading: 'Ladataan sisältöä...'
|
Loading: 'Ladataan sisältöä...'
|
||||||
SiteTree:
|
|
||||||
PLURALNAME: Sivut
|
|
||||||
SINGULARNAME: Sivu
|
|
||||||
|
@ -1,4 +1 @@
|
|||||||
id:
|
id:
|
||||||
SiteTree:
|
|
||||||
PLURALNAME: Halaman
|
|
||||||
SINGULARNAME: Halaman
|
|
||||||
|
@ -1,4 +1 @@
|
|||||||
it:
|
it:
|
||||||
SiteTree:
|
|
||||||
PLURALNAME: Pagine
|
|
||||||
SINGULARNAME: Pagina
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
lt:
|
lt:
|
||||||
IFramePage:
|
IFramePage:
|
||||||
PLURALNAME: 'Baziniai puslapiai'
|
PLURALNAME: 'Baziniai puslapiai'
|
||||||
SiteTree:
|
|
||||||
PLURALNAME: Puslapiai
|
|
||||||
SINGULARNAME: Puslapis
|
|
||||||
|
@ -3,11 +3,6 @@ lt_LT:
|
|||||||
DESCRIPTION: 'Įtraukia iframe į puslapio body dalį'
|
DESCRIPTION: 'Įtraukia iframe į puslapio body dalį'
|
||||||
PLURALNAME: 'Baziniai puslapiai'
|
PLURALNAME: 'Baziniai puslapiai'
|
||||||
SINGULARNAME: 'Iframe puslapis'
|
SINGULARNAME: 'Iframe puslapis'
|
||||||
VALIDATION:
|
VALIDATION_BANNEDURLSCHEME: 'Tokia URL schema neleidžiama'
|
||||||
BANNEDURLSCHEME: 'Tokia URL schema neleidžiama'
|
|
||||||
IframePage:
|
|
||||||
ExternalNote: 'Prašome atkreipti dėmesį, jog šis turinys galimai yra iš išorinių šaltinių (IFRAME žyma HTML dokumente), tad jis gali sukeiti nepatogumų vartotojams su ekrano skaitytuvais.'
|
ExternalNote: 'Prašome atkreipti dėmesį, jog šis turinys galimai yra iš išorinių šaltinių (IFRAME žyma HTML dokumente), tad jis gali sukeiti nepatogumų vartotojams su ekrano skaitytuvais.'
|
||||||
Loading: 'Turinys siunčiamas...'
|
Loading: 'Turinys siunčiamas...'
|
||||||
SiteTree:
|
|
||||||
PLURALNAME: Puslapiai
|
|
||||||
SINGULARNAME: Puslapis
|
|
||||||
|
@ -3,9 +3,5 @@ mi:
|
|||||||
DESCRIPTION: 'Ka tāmau i tētahi ī-tāpare ki roto i te tinana o te whārangi.'
|
DESCRIPTION: 'Ka tāmau i tētahi ī-tāpare ki roto i te tinana o te whārangi.'
|
||||||
PLURALNAME: 'Ngā Whārangi Pūtake'
|
PLURALNAME: 'Ngā Whārangi Pūtake'
|
||||||
SINGULARNAME: 'Whārangi Ī-Tāpare'
|
SINGULARNAME: 'Whārangi Ī-Tāpare'
|
||||||
IframePage:
|
|
||||||
ExternalNote: 'Me mōhio ka tukuna pea te wāhanga ihirangi e whai nei i tētahi pūtake ā-waho (he Ī-TĀPARE e pā ana ki te HTML), ā, ka whakarato pea i ngā wheako rerekē mō ngā pūpānui mata.'
|
ExternalNote: 'Me mōhio ka tukuna pea te wāhanga ihirangi e whai nei i tētahi pūtake ā-waho (he Ī-TĀPARE e pā ana ki te HTML), ā, ka whakarato pea i ngā wheako rerekē mō ngā pūpānui mata.'
|
||||||
Loading: 'Uta ihirangi ana...'
|
Loading: 'Uta ihirangi ana...'
|
||||||
SiteTree:
|
|
||||||
PLURALNAME: Ngā Whārangi
|
|
||||||
SINGULARNAME: Whārangi
|
|
||||||
|
@ -1,3 +1 @@
|
|||||||
pl:
|
pl:
|
||||||
SiteTree:
|
|
||||||
PLURALNAME: Strony
|
|
||||||
|
@ -1,3 +1 @@
|
|||||||
pt_BR:
|
pt_BR:
|
||||||
SiteTree:
|
|
||||||
PLURALNAME: Páginas
|
|
||||||
|
@ -3,11 +3,6 @@ ru:
|
|||||||
DESCRIPTION: 'Вставка элемента iframe в основную область страницы.'
|
DESCRIPTION: 'Вставка элемента iframe в основную область страницы.'
|
||||||
PLURALNAME: 'Страницы iframe'
|
PLURALNAME: 'Страницы iframe'
|
||||||
SINGULARNAME: 'Страница iframe'
|
SINGULARNAME: 'Страница iframe'
|
||||||
VALIDATION:
|
VALIDATION_BANNEDURLSCHEME: 'Данный тип ссылки запрещён.'
|
||||||
BANNEDURLSCHEME: 'Данный тип ссылки запрещён.'
|
|
||||||
IframePage:
|
|
||||||
ExternalNote: 'Примечание: содержимое в разделе ниже может быть получено из внешнего источника (HTML-элемент IFRAME) и может воспроизводиться программами для чтения экрана некорректно.'
|
ExternalNote: 'Примечание: содержимое в разделе ниже может быть получено из внешнего источника (HTML-элемент IFRAME) и может воспроизводиться программами для чтения экрана некорректно.'
|
||||||
Loading: 'Идет загрузка...'
|
Loading: 'Идет загрузка...'
|
||||||
SiteTree:
|
|
||||||
PLURALNAME: Страницы
|
|
||||||
SINGULARNAME: Страница
|
|
||||||
|
@ -1,6 +1,3 @@
|
|||||||
sk:
|
sk:
|
||||||
IFramePage:
|
IFramePage:
|
||||||
PLURALNAME: 'Základné stránky'
|
PLURALNAME: 'Základné stránky'
|
||||||
SiteTree:
|
|
||||||
PLURALNAME: Stránky
|
|
||||||
SINGULARNAME: Stránka
|
|
||||||
|
@ -3,9 +3,5 @@ zh:
|
|||||||
DESCRIPTION: '将 iframe 嵌入页面主体'
|
DESCRIPTION: '将 iframe 嵌入页面主体'
|
||||||
PLURALNAME: '基页'
|
PLURALNAME: '基页'
|
||||||
SINGULARNAME: 'IFRAME 页面'
|
SINGULARNAME: 'IFRAME 页面'
|
||||||
IframePage:
|
|
||||||
ExternalNote: '请注意,下列内容可能来自外部来源(HTML 中的 IFRAME 框架),在屏幕上阅读时可能会产生不一致的体验。'
|
ExternalNote: '请注意,下列内容可能来自外部来源(HTML 中的 IFRAME 框架),在屏幕上阅读时可能会产生不一致的体验。'
|
||||||
Loading: '正在加载内容……'
|
Loading: '正在加载内容……'
|
||||||
SiteTree:
|
|
||||||
PLURALNAME: 页面
|
|
||||||
SINGULARNAME: 页面
|
|
||||||
|
@ -1,9 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
namespace SilverStripe\IFrame\Tests;
|
||||||
|
|
||||||
|
use SilverStripe\Core\Config\Config;
|
||||||
|
use SilverStripe\Control\Director;
|
||||||
|
use SilverStripe\ORM\ValidationException;
|
||||||
|
use SilverStripe\Dev\SapphireTest;
|
||||||
|
use SilverStripe\IFrame\IFramePage;
|
||||||
|
use SilverStripe\IFrame\IFramePageController;
|
||||||
|
|
||||||
class IFramePageTest extends SapphireTest
|
class IFramePageTest extends SapphireTest
|
||||||
{
|
{
|
||||||
protected $usesDatabase = true;
|
protected $usesDatabase = true;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
@ -88,7 +96,7 @@ class IFramePageTest extends SapphireTest
|
|||||||
|
|
||||||
foreach ($tests['banned'] as $url) {
|
foreach ($tests['banned'] as $url) {
|
||||||
$iframe->IFrameURL = $url;
|
$iframe->IFrameURL = $url;
|
||||||
$this->setExpectedException('ValidationException');
|
$this->setExpectedException(ValidationException::class);
|
||||||
$iframe->write();
|
$iframe->write();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,39 +109,44 @@ class IFramePageTest extends SapphireTest
|
|||||||
$page->URLSegment = 'iframe';
|
$page->URLSegment = 'iframe';
|
||||||
$page->IFrameURL = 'http://target.com';
|
$page->IFrameURL = 'http://target.com';
|
||||||
|
|
||||||
Config::inst()->update('Director', 'alternate_protocol', 'http');
|
Config::inst()->update(Director::class, 'alternate_protocol', 'http');
|
||||||
Config::inst()->update('Director', 'alternate_base_url', 'http://host.com');
|
Config::inst()->update(Director::class, 'alternate_base_url', 'http://host.com');
|
||||||
$page->ForceProtocol = '';
|
$page->ForceProtocol = '';
|
||||||
$controller = new IFramePage_Controller($page);
|
$controller = new IFramePageController($page);
|
||||||
$response = $controller->init();
|
$controller->doInit();
|
||||||
$this->assertNull($response);
|
$response = $controller->getResponse();
|
||||||
|
$this->assertNull($response->getHeader('Location'));
|
||||||
|
|
||||||
Config::inst()->update('Director', 'alternate_protocol', 'https');
|
Config::inst()->update(Director::class, 'alternate_protocol', 'https');
|
||||||
Config::inst()->update('Director', 'alternate_base_url', 'https://host.com');
|
Config::inst()->update(Director::class, 'alternate_base_url', 'https://host.com');
|
||||||
$page->ForceProtocol = '';
|
$page->ForceProtocol = '';
|
||||||
$controller = new IFramePage_Controller($page);
|
$controller = new IFramePageController($page);
|
||||||
$response = $controller->init();
|
$controller->doInit();
|
||||||
$this->assertNull($response);
|
$response = $controller->getResponse();
|
||||||
|
$this->assertNull($response->getHeader('Location'));
|
||||||
|
|
||||||
Config::inst()->update('Director', 'alternate_protocol', 'http');
|
Config::inst()->update(Director::class, 'alternate_protocol', 'http');
|
||||||
Config::inst()->update('Director', 'alternate_base_url', 'http://host.com');
|
Config::inst()->update(Director::class, 'alternate_base_url', 'http://host.com');
|
||||||
$page->ForceProtocol = 'http://';
|
$page->ForceProtocol = 'http://';
|
||||||
$controller = new IFramePage_Controller($page);
|
$controller = new IFramePageController($page);
|
||||||
$response = $controller->init();
|
$controller->doInit();
|
||||||
$this->assertNull($response);
|
$response = $controller->getResponse();
|
||||||
|
$this->assertNull($response->getHeader('Location'));
|
||||||
|
|
||||||
Config::inst()->update('Director', 'alternate_protocol', 'http');
|
Config::inst()->update(Director::class, 'alternate_protocol', 'http');
|
||||||
Config::inst()->update('Director', 'alternate_base_url', 'http://host.com');
|
Config::inst()->update(Director::class, 'alternate_base_url', 'http://host.com');
|
||||||
$page->ForceProtocol = 'https://';
|
$page->ForceProtocol = 'https://';
|
||||||
$controller = new IFramePage_Controller($page);
|
$controller = new IFramePageController($page);
|
||||||
$response = $controller->init();
|
$controller->doInit();
|
||||||
|
$response = $controller->getResponse();
|
||||||
$this->assertEquals($response->getHeader('Location'), 'https://host.com/iframe/');
|
$this->assertEquals($response->getHeader('Location'), 'https://host.com/iframe/');
|
||||||
|
|
||||||
Config::inst()->update('Director', 'alternate_protocol', 'https');
|
Config::inst()->update(Director::class, 'alternate_protocol', 'https');
|
||||||
Config::inst()->update('Director', 'alternate_base_url', 'https://host.com');
|
Config::inst()->update(Director::class, 'alternate_base_url', 'https://host.com');
|
||||||
$page->ForceProtocol = 'http://';
|
$page->ForceProtocol = 'http://';
|
||||||
$controller = new IFramePage_Controller($page);
|
$controller = new IFramePageController($page);
|
||||||
$response = $controller->init();
|
$controller->doInit();
|
||||||
|
$response = $controller->getResponse();
|
||||||
$this->assertEquals($response->getHeader('Location'), 'http://host.com/iframe/');
|
$this->assertEquals($response->getHeader('Location'), 'http://host.com/iframe/');
|
||||||
|
|
||||||
$_SERVER = $origServer;
|
$_SERVER = $origServer;
|
||||||
|
Loading…
Reference in New Issue
Block a user