-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e5aa4d0
commit 2f1afde
Showing
4 changed files
with
241 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
namespace FluidTYPO3\Vhs\ViewHelpers\Context; | ||
|
||
/*************************************************************** | ||
* Copyright notice | ||
* (c) 2014 Benjamin Beck <beck@beckdigitalemedien.de> | ||
* All rights reserved | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
* free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* The GNU General Public License can be found at | ||
* http://www.gnu.org/copyleft/gpl.html. | ||
* This script is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* This copyright notice MUST APPEAR in all copies of the script! | ||
* ************************************************************* */ | ||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
/** | ||
* ### Context: Get | ||
* | ||
* Returns the full application context which may include possible sub-contexts. | ||
* If no application context has been set, then the default context is production. | ||
* | ||
* #### Note about how to set the application context | ||
* | ||
* The context TYPO3 CMS runs in is specified through the environment variable TYPO3_CONTEXT. | ||
* It can be set by .htaccess or in the server configuration | ||
* | ||
* See: http://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Bootstrapping/Index.html#bootstrapping-context | ||
* | ||
* @author Benjamin Beck <beck@beckdigitalemedien.de> | ||
* @package Vhs | ||
* @subpackage ViewHelpers\Context | ||
*/ | ||
class GetViewHelper extends AbstractViewHelper { | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function render () { | ||
return (string) GeneralUtility::getApplicationContext(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
namespace FluidTYPO3\Vhs\ViewHelpers\Context; | ||
|
||
/*************************************************************** | ||
* Copyright notice | ||
* (c) 2014 Benjamin Beck <beck@beckdigitalemedien.de> | ||
* All rights reserved | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
* free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* The GNU General Public License can be found at | ||
* http://www.gnu.org/copyleft/gpl.html. | ||
* This script is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* This copyright notice MUST APPEAR in all copies of the script! | ||
* ************************************************************* */ | ||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
/** | ||
* ### Context: IsDevelopment | ||
* | ||
* Returns true if current root application context is development otherwise false. | ||
* If no application context has been set, then the default context is production. | ||
* | ||
* #### Note about how to set the application context | ||
* | ||
* The context TYPO3 CMS runs in is specified through the environment variable TYPO3_CONTEXT. | ||
* It can be set by .htaccess or in the server configuration | ||
* | ||
* See: http://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Bootstrapping/Index.html#bootstrapping-context | ||
* | ||
* @author Benjamin Beck <beck@beckdigitalemedien.de> | ||
* @package Vhs | ||
* @subpackage ViewHelpers\Context | ||
*/ | ||
class IsDevelopmentViewHelper extends AbstractConditionViewHelper { | ||
|
||
/** | ||
* Render method | ||
* | ||
* @return string | ||
*/ | ||
public function render () { | ||
if ( TRUE === $this->isDevelopmentContext() ) { | ||
return $this->renderThenChild(); | ||
} | ||
|
||
return $this->renderElseChild(); | ||
} | ||
|
||
|
||
/** | ||
* @return boolean | ||
*/ | ||
protected function isDevelopmentContext () { | ||
return GeneralUtility::getApplicationContext()->isDevelopment(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
namespace FluidTYPO3\Vhs\ViewHelpers\Context; | ||
|
||
/*************************************************************** | ||
* Copyright notice | ||
* (c) 2014 Benjamin Beck <beck@beckdigitalemedien.de> | ||
* All rights reserved | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
* free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* The GNU General Public License can be found at | ||
* http://www.gnu.org/copyleft/gpl.html. | ||
* This script is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* This copyright notice MUST APPEAR in all copies of the script! | ||
* ************************************************************* */ | ||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
/** | ||
* ### Context: IsProduction | ||
* | ||
* Returns true if current root application context is production otherwise false. | ||
* If no application context has been set, then this is the default context. | ||
* | ||
* #### Note about how to set the application context | ||
* | ||
* The context TYPO3 CMS runs in is specified through the environment variable TYPO3_CONTEXT. | ||
* It can be set by .htaccess or in the server configuration | ||
* | ||
* See: http://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Bootstrapping/Index.html#bootstrapping-context | ||
* | ||
* @author Benjamin Beck <beck@beckdigitalemedien.de> | ||
* @package Vhs | ||
* @subpackage ViewHelpers\Context | ||
*/ | ||
class IsProductionViewHelper extends AbstractConditionViewHelper { | ||
|
||
/** | ||
* Render method | ||
* | ||
* @return string | ||
*/ | ||
public function render () { | ||
if ( TRUE === $this->isProductionContext() ) { | ||
return $this->renderThenChild(); | ||
} | ||
|
||
return $this->renderElseChild(); | ||
} | ||
|
||
|
||
/** | ||
* @return boolean | ||
*/ | ||
protected function isProductionContext () { | ||
return GeneralUtility::getApplicationContext()->isProduction(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
namespace FluidTYPO3\Vhs\ViewHelpers\Context; | ||
|
||
/*************************************************************** | ||
* Copyright notice | ||
* (c) 2014 Benjamin Beck <beck@beckdigitalemedien.de> | ||
* All rights reserved | ||
* This script is part of the TYPO3 project. The TYPO3 project is | ||
* free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* The GNU General Public License can be found at | ||
* http://www.gnu.org/copyleft/gpl.html. | ||
* This script is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* This copyright notice MUST APPEAR in all copies of the script! | ||
* ************************************************************* */ | ||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractConditionViewHelper; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
|
||
/** | ||
* ### Context: IsProduction | ||
* | ||
* Returns true if current root application context is testing otherwise false. | ||
* If no application context has been set, then the default context is production. | ||
* | ||
* #### Note about how to set the application context | ||
* | ||
* The context TYPO3 CMS runs in is specified through the environment variable TYPO3_CONTEXT. | ||
* It can be set by .htaccess or in the server configuration | ||
* | ||
* See: http://docs.typo3.org/typo3cms/CoreApiReference/ApiOverview/Bootstrapping/Index.html#bootstrapping-context | ||
* | ||
* @author Benjamin Beck <beck@beckdigitalemedien.de> | ||
* @package Vhs | ||
* @subpackage ViewHelpers\Context | ||
*/ | ||
class IsTestingViewHelper extends AbstractConditionViewHelper { | ||
|
||
/** | ||
* Render method | ||
* | ||
* @return string | ||
*/ | ||
public function render () { | ||
if ( TRUE === $this->isTestingContext() ) { | ||
return $this->renderThenChild(); | ||
} | ||
|
||
return $this->renderElseChild(); | ||
} | ||
|
||
|
||
/** | ||
* @return boolean | ||
*/ | ||
protected function isTestingContext () { | ||
return GeneralUtility::getApplicationContext()->isTesting(); | ||
} | ||
|
||
} |