Initial commit
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\ViewHelpers\Uri;
|
||||
|
||||
/*
|
||||
* 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\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Extbase\Reflection\ObjectAccess;
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* Renders Gravatar URI
|
||||
*
|
||||
* @author Juan Manuel Vergés Solanas <juanmanuel@vergessolanas.es>
|
||||
* @package Vhs
|
||||
* @subpackage ViewHelpers\Uri
|
||||
*/
|
||||
class GravatarViewHelper extends AbstractViewHelper {
|
||||
|
||||
/**
|
||||
* Base url
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const GRAVATAR_BASEURL = 'http://www.gravatar.com/avatar/';
|
||||
|
||||
/**
|
||||
* Base secure url
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const GRAVATAR_SECURE_BASEURL = 'https://secure.gravatar.com/avatar/';
|
||||
|
||||
/**
|
||||
* Initialize arguments.
|
||||
* Size argument has no default value to prevent the creation of an unnecessary URI parameter.
|
||||
*
|
||||
* @return void
|
||||
* @api
|
||||
*/
|
||||
public function initializeArguments() {
|
||||
$this->registerArgument('email', 'string', 'Email address', TRUE);
|
||||
$this->registerArgument('size', 'integer', 'Size in pixels, defaults to 80px [ 1 - 2048 ]', FALSE);
|
||||
$this->registerArgument('imageSet', 'string', 'Default image set to use. Possible values [ 404 | mm | identicon | monsterid | wavatar ] ', FALSE);
|
||||
$this->registerArgument('maximumRating', 'string', 'Maximum rating (inclusive) [ g | pg | r | x ]', FALSE);
|
||||
$this->registerArgument('secure', 'boolean', 'If it is FALSE will return the un secure Gravatar domain (www.gravatar.com)', FALSE, TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render() {
|
||||
$email = $this->arguments['email'];
|
||||
$size = $this->checkArgument('size');
|
||||
$imageSet = $this->checkArgument('imageSet');
|
||||
$maximumRating = $this->checkArgument('maximumRating');
|
||||
$secure = (boolean) $this->arguments['secure'];
|
||||
|
||||
$url = (TRUE === $secure ? self::GRAVATAR_SECURE_BASEURL : self::GRAVATAR_BASEURL);
|
||||
$url .= md5(strtolower(trim($email)));
|
||||
$query = http_build_query(array('s' => $size, 'd' => $imageSet, 'r' => $maximumRating));
|
||||
$url .= (FALSE === empty($query) ? '?' . $query : '');
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if an argument is passed
|
||||
*
|
||||
* @param $argument
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function checkArgument($argument) {
|
||||
return TRUE === isset($this->arguments[$argument]) ? $this->arguments[$argument] : NULL;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\ViewHelpers\Uri;
|
||||
|
||||
/*
|
||||
* 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 FluidTYPO3\Vhs\ViewHelpers\Media\Image\AbstractImageViewHelper;
|
||||
|
||||
/**
|
||||
* ### Uri: Image
|
||||
*
|
||||
* Returns the relative or absolute URI for the image resource
|
||||
* or it's derivate if differing dimesions are provided.
|
||||
*
|
||||
* @author Björn Fromme <fromme@dreipunktnull.com>, dreipunktnull
|
||||
* @package Vhs
|
||||
* @subpackage ViewHelpers\Uri
|
||||
*/
|
||||
class ImageViewHelper extends AbstractImageViewHelper {
|
||||
|
||||
/**
|
||||
* Render method
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function render() {
|
||||
$this->preprocessImage();
|
||||
$src = $this->preprocessSourceUri($this->mediaSource);
|
||||
return $src;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\ViewHelpers\Uri;
|
||||
|
||||
/*
|
||||
* 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\Core\Utility\GeneralUtility;
|
||||
use TYPO3\CMS\Fluid\Core\ViewHelper\AbstractViewHelper;
|
||||
|
||||
/**
|
||||
* ### Uri: Request
|
||||
*
|
||||
* Returns the Uri of the requested page (site_url + all the GET params)
|
||||
* \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL')
|
||||
*
|
||||
* @author Claus Due <claus@namelesscoder.net>
|
||||
* @package Vhs
|
||||
* @subpackage ViewHelpers\Uri
|
||||
*/
|
||||
class RequestViewHelper extends AbstractViewHelper {
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render() {
|
||||
$url = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL');
|
||||
return $url;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace FluidTYPO3\Vhs\ViewHelpers\Uri;
|
||||
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* ### TypolinkViewhelper
|
||||
*
|
||||
* Renders a uri with the TypoLink function.
|
||||
* Can be used with the LinkWizard
|
||||
*
|
||||
* For more info on the typolink function, please consult the offical core-documentation:
|
||||
* http://docs.typo3.org/typo3cms/TyposcriptIn45MinutesTutorial/TypoScriptFunctions/Typolink/Index.html
|
||||
*
|
||||
* ### Examples
|
||||
*
|
||||
* <!-- tag -->
|
||||
* <v:uri.typolink configuration="{typoLinkConfiguration}" />
|
||||
* <v:uri.typolink configuration="{object}">My LinkText</v:uri.typolink>
|
||||
* <!-- with a {parameter} variable containing the PID -->
|
||||
* <v:uri.typolink configuration="{parameter: parameter}" />
|
||||
* <!-- with a {fields.link} variable from the LinkWizard (incl. 'class', 'target' etc.) inside a flux form -->
|
||||
* <v:uri.typolink configuration="{parameter: fields.link}" />
|
||||
* <!-- same with a {page} variable from fluidpages -->
|
||||
* <v:uri.typolink configuration="{parameter: page.uid}" />
|
||||
* <!-- With extensive configuration -->
|
||||
* <v:uri.typolink configuration="{parameter: page.uid, additionalParams: '&print=1', title: 'Follow the link'}">Click Me!</v:uri.typolink>
|
||||
*
|
||||
* @author Cedric Ziel <cedric@cedric-ziel.com>, Cedric Ziel - Internetdienstleistungen & EDV
|
||||
* @package Vhs
|
||||
* @subpackage ViewHelpers
|
||||
*/
|
||||
class TypolinkViewHelper extends AbstractViewHelper {
|
||||
|
||||
/**
|
||||
* Initializes the arguments for the ViewHelper
|
||||
*/
|
||||
public function initializeArguments() {
|
||||
$this->registerArgument('configuration', 'array', 'The typoLink configuration', TRUE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function render() {
|
||||
return $GLOBALS['TSFE']->cObj->typoLink_URL($this->arguments['configuration']);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user