Initial commit
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\ViewHelpers\System;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* ### System: DateTime
|
||||
*
|
||||
* Returns the current system UNIX timestamp as DateTime.
|
||||
*
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
* @subpackage ViewHelpers\System
|
||||
*/
|
||||
class DateTimeViewHelper extends AbstractViewHelper {
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function render() {
|
||||
return \DateTime::createFromFormat('U', $this->getTimestamp());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
protected function getTimestamp() {
|
||||
return time();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\ViewHelpers\System;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* ### System: UNIX Timestamp
|
||||
*
|
||||
* Returns the current system UNIX timestamp as integer.
|
||||
* Useful combined with the Math group of ViewHelpers:
|
||||
*
|
||||
* <!-- adds exactly one hour to a DateTime and formats it -->
|
||||
* <f:format.date format="H:i">{dateTime.timestamp -> v:math.sum(b: 3600)}</f:format.date>
|
||||
*
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
* @subpackage ViewHelpers\System
|
||||
*/
|
||||
class TimestampViewHelper extends AbstractViewHelper {
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
public function render() {
|
||||
return $this->getTimestamp();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
protected function getTimestamp() {
|
||||
return time();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\ViewHelpers\System;
|
||||
|
||||
/*
|
||||
* This file is part of the FluidTYPO3/Vhs project under GPLv2 or later.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.md file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* ### System: Unique ID
|
||||
*
|
||||
* Returns a unique ID based on PHP's uniqid-function.
|
||||
*
|
||||
* Comes in useful when handling/generating html-element-IDs
|
||||
* for usage with JavaScript.
|
||||
*
|
||||
* @author Cedric Ziel, <cedric@cedric-ziel.com>
|
||||
* @package Vhs
|
||||
* @subpackage ViewHelpers\System
|
||||
*/
|
||||
class UniqIdViewHelper extends AbstractViewHelper {
|
||||
|
||||
/**
|
||||
* @param string $prefix An optional prefix for making sure it's unique across environments
|
||||
* @param boolean $moreEntropy Add some pseudo random strings. Refer to uniqid()'s Reference.
|
||||
* @return string
|
||||
*/
|
||||
public function render($prefix = '', $moreEntropy = FALSE) {
|
||||
$uniqueId = uniqid($prefix, $moreEntropy);
|
||||
return $uniqueId;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user