Commit 99ae2ad4 authored by speedprogs_de's avatar speedprogs_de

created one view helper for plain URLs and one for datetime formating,...

created one view helper for plain URLs and one for datetime formating, implemented them in rss templates

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/terfe/branches/ter_fe2@45168 735d13b6-9817-0410-8766-e36946ffe9aa
parent 0ea58419
<?php
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.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!
******************************************************************/
/**
* Date Time View Helper
*
* @version $Id$
* @copyright Copyright belongs to the respective authors
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*/
class Tx_TerFe2_ViewHelpers_DateTimeViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
/**
* Renders an extension icon of given extension and version
*
* @param mixed $dateTime Time to format
* @param string $format Format of the resulting time
* @return string Formated time
*/
public function render($dateTime = NULL, $format = 'Y-m-d h-i-s') {
if ($dateTime === NULL) {
$dateTime = $this->renderChildren();
}
if (empty($dateTime)) {
$dateTime = new DateTime;
}
if (is_int($dateTime) || is_string($dateTime)) {
return date($format, (int) $dateTime);
}
if ($dateTime instanceof DateTime) {
return $dateTime->format($format);
}
return '';
}
}
?>
\ No newline at end of file
<?php
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.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!
******************************************************************/
/**
* URL View Helper
*
* @version $Id$
* @copyright Copyright belongs to the respective authors
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*/
class Tx_TerFe2_ViewHelpers_UrlViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
/**
* Renders a URL to given controller and action with params
* @param string $action Target action
* @param array $arguments Arguments
* @param string $controller Target controller. If NULL current controllerName is used
* @param string $extensionName Target Extension Name (without "tx_" prefix and no underscores). If NULL the current extension name is used
* @param string $pluginName Target plugin. If empty, the current plugin name is used
* @param integer $pageUid target page. See TypoLink destination
* @param integer $pageType type of the target page. See typolink.parameter
* @param boolean $noCache set this to disable caching for the target page. You should not need this.
* @param boolean $noCacheHash set this to supress the cHash query parameter created by TypoLink. You should not need this.
* @param string $section the anchor to be added to the URI
* @param string $format The requested format, e.g. ".html"
* @param boolean $linkAccessRestrictedPages If set, links pointing to access restricted pages will still link to the page even though the page cannot be accessed.
* @param array $additionalParams additional query parameters that won't be prefixed like $arguments (overrule $arguments)
* @param boolean $absolute If set, the URI of the rendered link is absolute
* @param boolean $addQueryString If set, the current query parameters will be kept in the URI
* @param array $argumentsToBeExcludedFromQueryString arguments to be removed from the URI. Only active if $addQueryString = TRUE
* @param boolean $addHost Add host to URL
* @return string Rendered link
* @see Tx_Fluid_ViewHelpers_Link_ActionViewHelper::render
*/
public function render($action = NULL, array $arguments = array(), $controller = NULL, $extensionName = NULL, $pluginName = NULL, $pageUid = NULL, $pageType = 0, $noCache = FALSE, $noCacheHash = FALSE, $section = '', $format = '', $linkAccessRestrictedPages = FALSE, array $additionalParams = array(), $absolute = FALSE, $addQueryString = FALSE, array $argumentsToBeExcludedFromQueryString = array(), $addHost = FALSE) {
$uriBuilder = $this->controllerContext->getUriBuilder();
$uri = $uriBuilder
->reset()
->setTargetPageUid($pageUid)
->setTargetPageType($pageType)
->setNoCache($noCache)
->setUseCacheHash(!$noCacheHash)
->setSection($section)
->setFormat($format)
->setLinkAccessRestrictedPages($linkAccessRestrictedPages)
->setArguments($additionalParams)
->setCreateAbsoluteUri($absolute)
->setAddQueryString($addQueryString)
->setArgumentsToBeExcludedFromQueryString($argumentsToBeExcludedFromQueryString)
->uriFor($action, $arguments, $controller, $extensionName, $pluginName);
return ($addHost ? t3lib_div::locationHeaderUrl($uri) : $uri);
}
}
?>
\ No newline at end of file
......@@ -31,4 +31,7 @@ plugin.tx_terfe2.rssOutput {
# cat=TER Frontend - RSS/rss/190; type=string; label=Webmaster email address
webmaster =
# cat=TER Frontend - RSS/rss/200; type=string; label=Date format
dateFormat = D, j M Y H:i:s O
}
\ No newline at end of file
......@@ -12,6 +12,7 @@ plugin.tx_terfe2.settings.rssOutput {
imageHeight = {$plugin.tx_terfe2.rssOutput.imageHeight}
docs = {$plugin.tx_terfe2.rssOutput.docs}
webmaster = {$plugin.tx_terfe2.rssOutput.webmaster}
dateFormat = {$plugin.tx_terfe2.rssOutput.dateFormat}
}
rssOutput = PAGE
......
{namespace terfe2=Tx_TerFe2_ViewHelpers}
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
......@@ -16,16 +17,16 @@
<generator>TYPO3</generator>
<docs>{settings.rssOutput.docs}</docs>
<webMaster>{settings.rssOutput.webmaster}</webMaster>
<lastBuildDate>Wed, 19 May 2010 16:42:00 +0200</lastBuildDate>
<lastBuildDate><terfe2:dateTime format="{settings.rssOutput.dateFormat}"></terfe2:dateTime></lastBuildDate>
<f:for each="{extensions}" as="extension">
<item>
<title>{extension.lastVersion.title}</title>
<link><f:link.action action="show" arguments="{extension : extension}"><!-- REPLACE WITH OWN VIEW HELPER FOR URL ONLY --></f:link.action></link>
<guid><f:link.action action="download" arguments="{extension : extension, version : extension.lastVersion}"><!-- REPLACE WITH OWN VIEW HELPER FOR URL ONLY --></f:link.action></guid>
<link><terfe2:url action="show" arguments="{extension : extension}" addHost="1"></terfe2:url></link>
<guid><terfe2:url action="download" arguments="{extension : extension, version : extension.lastVersion}" addHost="1"></terfe2:url></guid>
<description>{extension.lastVersion.description}</description>
<content:encoded><![CDATA[]]></content:encoded>
<pubDate>{extension.lastVersion.uploadDate} <!-- ADD VIEW HELPER FOR RSS LIKE DATE FORMAT --></pubDate>
<pubDate><terfe2:dateTime format="{settings.rssOutput.dateFormat}">{extension.lastVersion.uploadDate}</terfe2:dateTime></pubDate>
</item>
</f:for>
......
{namespace terfe2=Tx_TerFe2_ViewHelpers}
<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
......@@ -16,16 +17,16 @@
<generator>TYPO3</generator>
<docs>{settings.rssOutput.docs}</docs>
<webMaster>{settings.rssOutput.webmaster}</webMaster>
<lastBuildDate>Wed, 19 May 2010 16:42:00 +0200</lastBuildDate>
<lastBuildDate><terfe2:dateTime format="{settings.rssOutput.dateFormat}"></terfe2:dateTime></lastBuildDate>
<f:for each="{extensions}" as="extension">
<item>
<title>{extension.lastVersion.title}</title>
<link><f:link.action action="show" arguments="{extension : extension}"><!-- REPLACE WITH OWN VIEW HELPER FOR URL ONLY --></f:link.action></link>
<guid><f:link.action action="download" arguments="{extension : extension, version : extension.lastVersion}"><!-- REPLACE WITH OWN VIEW HELPER FOR URL ONLY --></f:link.action></guid>
<link><terfe2:url action="show" arguments="{extension : extension}" addHost="1"></terfe2:url></link>
<guid><terfe2:url action="download" arguments="{extension : extension, version : extension.lastVersion}" addHost="1"></terfe2:url></guid>
<description>{extension.lastVersion.description}</description>
<content:encoded><![CDATA[]]></content:encoded>
<pubDate>{extension.lastVersion.uploadDate} <!-- ADD VIEW HELPER FOR RSS LIKE DATE FORMAT --></pubDate>
<pubDate><terfe2:dateTime format="{settings.rssOutput.dateFormat}">{extension.lastVersion.uploadDate}</terfe2:dateTime></pubDate>
</item>
</f:for>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment