-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove dependency on t3jquery and handle assets
The jQuery library now needs to be provided by the site rather than being automatically included by t3jquery. Stylesheet assets can now be included through fluid viewhelpers (similar to vhs assets): ```xml {namespace s=Subugoe\Find\ViewHelpers} <s:page.linkCSS file="{CSSPath}"/> ``` Same for script assets: ```xml <s:page.script name="findJs{idx}" file="EXT:myext/foo/bar.js"/> ``` and ```xml <s:page.script name="myInlineScript"> var foo = 'bar'; </s:page.script> ``` Existing templates have been migrated.
- Loading branch information
1 parent
f479a54
commit 897a6f6
Showing
10 changed files
with
145 additions
and
23 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,106 @@ | ||
<?php | ||
namespace Subugoe\Find\ViewHelpers\Page; | ||
|
||
/******************************************************************************* | ||
* Copyright notice | ||
* Copyright 2013 Sven-S. Porst, Göttingen State and University Library | ||
* <[email protected]> | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
******************************************************************************/ | ||
|
||
use TYPO3\CMS\Core\Page\PageRenderer; | ||
use TYPO3\CMS\Core\TypoScript\TemplateService; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Fluid\Core\Rendering\RenderingContextInterface; | ||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper; | ||
use TYPO3\CMS\Fluid\Core\ViewHelper\Facets\CompilableInterface; | ||
|
||
/** | ||
* View Helper to dynamically add script resources to the output. | ||
* | ||
* Usage examples are available in Private/Partials/Test.html. | ||
*/ | ||
class ScriptViewHelper extends AbstractViewHelper implements CompilableInterface | ||
{ | ||
/** | ||
* @return PageRenderer | ||
*/ | ||
protected static function getPageRenderer() | ||
{ | ||
return GeneralUtility::makeInstance(PageRenderer::class); | ||
} | ||
|
||
/** | ||
* @return TemplateService | ||
*/ | ||
protected static function getTypoScriptTemplateService() | ||
{ | ||
return $GLOBALS['TSFE']->tmpl; | ||
} | ||
|
||
/** | ||
* @return void | ||
*/ | ||
public function initializeArguments() | ||
{ | ||
$this->registerArgument('file', 'string', 'File to append as script'); | ||
$this->registerArgument('name', 'string', 'Name to use', true); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function render() | ||
{ | ||
return self::renderStatic( | ||
[ | ||
'file' => $this->arguments['file'], | ||
'name' => $this->arguments['name'], | ||
], | ||
$this->buildRenderChildrenClosure(), | ||
$this->renderingContext | ||
); | ||
} | ||
|
||
/** | ||
* @param array $arguments | ||
* @param \Closure $renderChildrenClosure | ||
* @param RenderingContextInterface $renderingContext | ||
* | ||
* @return string | ||
*/ | ||
public static function renderStatic( | ||
array $arguments, | ||
\Closure $renderChildrenClosure, | ||
RenderingContextInterface $renderingContext | ||
) { | ||
$scriptPath = static::getTypoScriptTemplateService()->getFileName($arguments['file']); | ||
$name = $arguments['name']; | ||
|
||
$pageRenderer = self::getPageRenderer(); | ||
if ($scriptPath) { | ||
$pageRenderer->addJsFooterLibrary($name, $scriptPath); | ||
|
||
return ''; | ||
} | ||
|
||
$content = $renderChildrenClosure(); | ||
$pageRenderer->addJsFooterInlineCode($name, $content); | ||
|
||
return ''; | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<div class="tx_find" id="{settings.jumpToID}"> | ||
<f:flashMessages/> | ||
<f:render section="main"/> | ||
</div> | ||
</div> |
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
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
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
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
{namespace s=Subugoe\Find\ViewHelpers} | ||
|
||
<f:comment> | ||
Adds the CSS files configured in the CSSPaths settings to the page’s head. | ||
</f:comment> | ||
|
||
<f:for each="{settings.CSSPaths}" as="CSSPath"> | ||
<s:page.linkCSS file="{CSSPath}"/> | ||
</f:for> | ||
</f:for> |
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
{namespace t3jquery=Tx_T3jquery_ViewHelpers} | ||
{namespace s=Subugoe\Find\ViewHelpers} | ||
|
||
<f:comment> | ||
Adds the JavaScript files configured in the CSSPaths settings to the page’s head. | ||
</f:comment> | ||
|
||
<f:for each="{settings.JSPaths}" as="JSPath"> | ||
<t3jquery:addJQueryAndScript jsfile="{JSPath}"/> | ||
</f:for> | ||
<s:page.script name="findJs{idx}" file="{script}"/> | ||
</f:for> |
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 |
---|---|---|
|
@@ -28,7 +28,7 @@ | |
'author' => 'Sven-S. Porst, Ingo Pfennigstorf', | ||
'author_email' => '[email protected]', | ||
'author_company' => 'SUB Göttingen', | ||
'dependencies' => 't3jquery', | ||
'dependencies' => '', | ||
'conflicts' => '', | ||
'constraints' => [ | ||
'depends' => [ | ||
|
This file was deleted.
Oops, something went wrong.