Commit 19990496 authored by Andy Hausmann's avatar Andy Hausmann

Merge branch 'dev-v1.3'

parents 5a393d4a 004b2884
### 1.3.0
* __Feature__: Implemented new LinkViewHelper - external URLs are now working.
* __Feature__: Added Link Wizard in Flexforms.
* __Feature__: StoragePid not needed anymore - in case the records are located on the same page where the plugin is.
* __Feature__: Added Extension Configuration - you can access it via the Extension Manager
* __Feature__: Added Subtitle Transformation to RTE via EXT Conf.
* __Bugfix__: Now it is possible to use the Plugin within TypoScript Libs.
* __Bugfix__: Revised field image - It is now required and only allows max 1 item.
* __Misc__: Extended Fluid Template.
* __Misc__: Updated README in EXT root.
### 1.2.2
* __Bugfix__: Fixed a bug regarding backward compatibility to TYPO3 4.5.x.
* __Misc__: Improved performance.
### 1.2.1
* __Bugfix/Feature__: Running multiple FlexSliders per Page now possible.
* __Misc__: Improved performance.
* __Misc__: Updated README in EXT root.
### 1.2.0
* Initial Release
* Initial TER Upload
\ No newline at end of file
......@@ -64,6 +64,13 @@ class Tx_Flexslider_Controller_FlexSliderController extends Tx_Extbase_MVC_Contr
public function initializeAction()
{
$this->contentObject = $this->configurationManager->getContentObject();
// Fallback to current pid if no storagePid is defined
$configuration = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
if(empty($configuration['persistence']['storagePid'])){
$currentPid['persistence']['storagePid'] = $GLOBALS['TSFE']->id;
$this->configurationManager->setConfiguration(array_merge($configuration, $currentPid));
}
}
/**
......@@ -73,9 +80,10 @@ class Tx_Flexslider_Controller_FlexSliderController extends Tx_Extbase_MVC_Contr
*/
public function listAction() {
$flexSliders = $this->flexSliderRepository->findAll();
$data = $this->contentObject->data;
$tplObj = array(
'data' => $data,
'configuration' => Tx_Flexslider_Utility_EmConfiguration::getConfiguration(),
'data' => $this->contentObject->data,
'flexSliders' => $flexSliders
);
$this->view->assignMultiple($tplObj);
......
......@@ -34,6 +34,49 @@
class Tx_Flexslider_Utility_Div
{
/**
* Better implementation of php's array_combine().
* This wont throw false in case both array haven't an identical size.
*
* @static
* @param array $a Array containing the keys.
* @param array $b Array containing the values.
* @param bool $pad Switch for allowing padding. Fills the combined array with empty values if any array is larger than the other one.
* @return array Combined array.
*/
public static function combineArray($a, $b, $pad = true) {
$acount = count($a);
$bcount = count($b);
// more elements in $a than $b but we don't want to pad either
if (!$pad) {
$size = ($acount > $bcount) ? $bcount : $acount;
$a = array_slice($a, 0, $size);
$b = array_slice($b, 0, $size);
} else {
// more headers than row fields
if ($acount > $bcount) {
$more = $acount - $bcount;
// how many fields are we missing at the end of the second array?
// Add empty strings to ensure arrays $a and $b have same number of elements
$more = $acount - $bcount;
for($i = 0; $i < $more; $i++) {
$b[] = "";
}
// more fields than headers
} else if ($acount < $bcount) {
$more = $bcount - $acount;
// fewer elements in the first array, add extra keys
for($i = 0; $i < $more; $i++) {
$key = 'extra_field_0' . $i;
$a[] = $key;
}
}
}
return array_combine($a, $b);
}
/**
* Returns the reference to a 'resource' in TypoScript.
*
......
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Andy Hausmann <hi@andy-hausmann.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 3 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!
***************************************************************/
/**
* Helper Class which makes various tools and helper available
*
* @author Andy Hausmann <hi@andy-hausmann.de>
* @package flexslider
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*/
class Tx_Flexslider_Utility_EmConfiguration
{
/**
* Extension key to get the EM Config from.
* This will we overwritten later on if a key is given through call.
*
* @var string
*/
static protected $extKey = 'flexslider';
/**
* Returns the Extension key.
*
* @static
* @return string The Extension key.
*/
protected static function getExtKey()
{
return self::$extKey;
}
/**
* Sets the Extension key.
*
* @static
* @param string $extKey The Extension key.
*/
protected static function setExtKey($extKey)
{
self::$extKey = $extKey;
}
/**
* Overrides the Extension key, if one's given.
*
* @static
* @param string $extKey Lower-cased key of the extension to get the EM Config from.
*/
protected static function overrideExtKey($extKey)
{
$extKey = (string) trim($extKey);
if (strlen($extKey)) {
self::setExtKey($extKey);
}
}
/**
* Parses the Extension Configuration and returns it.
*
* @static
* @param string $extensionKey The Extension key.
* @return array The Extension Configuration.
*/
public static function getConfiguration($extensionKey = '')
{
self::overrideExtKey($extensionKey);
return self::parseConfiguration();
}
/**
* Parse settings and return it as array
*
* @return array unserialized extconf settings
*/
protected static function parseConfiguration()
{
$settings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][self::getExtKey()]);
if (!is_array($settings)) {
$settings = array();
}
return $settings;
}
}
\ No newline at end of file
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Andy Hausmann <hi@andy-hausmann.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 3 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!
***************************************************************/
/**
*
* A view helper for dynamic rendering of links.
*
* @author Andy Hausmann <hi@andy-hausmann.de>
* @package flexslider
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
*/
class Tx_Flexslider_ViewHelpers_DynLinkViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractTagBasedViewHelper
{
/**
* @var string
*/
protected $tagName = 'a';
/**
* @var array
*/
protected $paramLabels = array();
/**
* Arguments initialization
*
* @return void
*/
public function initializeArguments()
{
$this->registerUniversalTagAttributes();
$this->registerArgument('arguments', 'array', 'Given arguments by Fluid call as an array.');
$this->registerArgument('href', 'string', 'Link href.');
$this->paramLabels = array('href', 'target', 'class', 'title');
}
/**
* Checks and processes the given link parameters.
*
* @param string $link Output from TYPO3 link wizard.
* @return bool Returns true if it is possible to build a link.
*/
protected function processLinkParams($link)
{
$paramDataArr = explode(' ', $link);
// Combine labels and values into one array
$paramDataArr = Tx_Flexslider_Utility_Div::combineArray($this->paramLabels, $paramDataArr, false);
// Save link data into ViewHelper arguments
$this->setArguments($paramDataArr);
if ($this->hasArgument('href') && !empty($this->arguments['href'])) {
$cObj = t3lib_div::makeInstance('tslib_cObj');
$configuration = array(
'parameter' => $this->arguments['href'],
'returnLast' => true
);
$href = $cObj->typolink('', $configuration);
$this->arguments['href'] = $href;
return true;
} else {
return false;
}
}
/**
* Adds attributes to the tag builder if they're not empty.
*
* @return void
*/
protected function addTagAttributes()
{
foreach ($this->paramLabels as $label) {
if ($this->hasArgument($label)
&& !empty($this->arguments[$label]))
{
$this->tag->addAttribute($label, $this->arguments[$label]);
}
}
}
/**
* ViewHelper Bootstrap.
*
* @return mixed|void
*/
public function render()
{
if ($this->processLinkParams($this->arguments['arguments']['link'])) {
$this->tag->setContent($this->renderChildren());
$this->addTagAttributes();
return $this->tag->render();
} else {
return $this->renderChildren();
}
}
}
?>
\ No newline at end of file
......@@ -3,6 +3,9 @@ if (!defined ('TYPO3_MODE')) {
die ('Access denied.');
}
// Extension manager configuration
$configuration = Tx_Flexslider_Utility_EmConfiguration::getConfiguration();
$pathLL = 'LLL:EXT:flexslider/Resources/Private/Language/locallang_db.xml:';
$TCA['tx_flexslider_domain_model_flexslider'] = array(
......@@ -117,8 +120,9 @@ $TCA['tx_flexslider_domain_model_flexslider'] = array(
'exclude' => 0,
'label' => $pathLL . 'tx_flexslider_domain_model_flexslider.subtitle',
'config' => array(
'type' => 'input',
'size' => 30,
'type' => 'text',
'cols' => 40,
'rows' => 5,
'eval' => 'trim'
),
),
......@@ -130,9 +134,11 @@ $TCA['tx_flexslider_domain_model_flexslider'] = array(
'internal_type' => 'file',
'uploadfolder' => 'uploads/tx_flexslider',
'show_thumbs' => 1,
'size' => 5,
'size' => 1,
'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
'disallowed' => '',
'maxitems' => '1',
'minitems' => '1'
),
),
'link' => array(
......@@ -141,7 +147,17 @@ $TCA['tx_flexslider_domain_model_flexslider'] = array(
'config' => array(
'type' => 'input',
'size' => 30,
'eval' => 'trim'
'eval' => 'trim',
'wizards' => array(
'_PADDING' => 2,
'link' => array(
'type' => 'popup',
'title' => 'Link',
'icon' => 'link_popup.gif',
'script' => 'browse_links.php?mode=wizard',
'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1'
)
)
),
),
'caption' => array(
......@@ -156,4 +172,25 @@ $TCA['tx_flexslider_domain_model_flexslider'] = array(
),
);
/**
* Conditional configuration
*/
// Extend the subtitle field, if the corresponding value in EM Config is set.
if ($configuration['extendSubtitleByRTE']) {
$TCA['tx_flexslider_domain_model_flexslider']['columns']['subtitle']['config']['wizards'] = array(
'RTE' => array(
'icon' => 'wizard_rte2.gif',
'notNewRecords'=> 1,
'RTEonly' => 1,
'script' => 'wizard_rte.php',
'title' => 'LLL:EXT:cms/locallang_ttc.xml:bodytext.W.RTE',
'type' => 'script'
),
);
$TCA['tx_flexslider_domain_model_flexslider']['columns']['subtitle']['defaultExtras'] = 'richtext[]';
}
?>
\ No newline at end of file
/*
* Nearly ready-to-use configuration for usage in TypoScript Libs and such.
*
* Use set persistence.storagePid and let it roll!
*/
temp.flexslider = USER
temp.flexslider {
userFunc = tx_extbase_core_bootstrap->run
pluginName = Pi1
extensionName = Flexslider
controller = FlexSlider
action = list
switchableControllerActions {
FlexSlider {
1 = list
}
}
settings =< plugin.tx_flexslider.settings
persistence =< plugin.tx_flexslider.persistence
//persistence.storagePid = 73
view =< plugin.tx_flexslider.view
}
plugin.tx_flexslider {
view {
templateRootPath = {$plugin.tx_flexslider.view.templateRootPath}
......
# FlexSlider
# EXT: FlexSlider
It simply brings WooThemes awesome fully responsive jQuery Slider Plugin to TYPO3 – as a Frontend Plugin, of course.
## Installation
......@@ -10,7 +15,7 @@ Clone into typo3conf/ext/
git clone git@github.com:andyhausmann/TYPO3_Extension_FlexSlider.git /path/to/project/typo3conf/ext/flexslider/
Install by Extension Manager as usual.
Install via Extension Manager as usual.
### Via TER
......@@ -29,8 +34,6 @@ Install by Extension Manager as usual.
### TypoScript Constants
_This section isn't completed yet._
plugin.tx_flexslider {
settings {
view {
......@@ -61,8 +64,6 @@ _This section isn't completed yet._
### TypoScript Setup
_This section isn't completed yet._
plugin.tx_flexslider {
settings {
# Boolean: Define whether the image caption should be shown or not
......@@ -117,7 +118,7 @@ Use the following TS Setup Object Path to override localizations.
}
### Further stuff
### Miscellaneous
Take a look at
......@@ -127,22 +128,93 @@ Take a look at
to get further infos about settings and language labels.
## Fluid Templating
Hint at the beginning: If you want to use special objects/vars in Partials, you'll need to pass them through as an argument, e.g.
<f:render partial="JavaScript"
arguments="{settings: settings, data: data, configuration: configuration}"/>
### Storing the templates somewhere else
Really? That's easy - just adjust the following lines to fit your needs and put them into the TypoScript Constants.
plugin.tx_flexslider {
view {
# Necessary options, if you plan to manipulate the templates
templateRootPath = fileadmin/res/tpl/ext/flexslider/Templates/
partialRootPath = fileadmin/res/tpl/ext/flexslider/Partials/
layoutRootPath = fileadmin/res/tpl/ext/flexslider/Layouts/
}
}
### Accessing Frontend data
Using the object {data}, you can access everything regarding the Content Element (containing the FlexSlider Plugin):
<table>
<tr>
<th colspan="2">cObject Data Array</th>
</tr>
<tr>
<td>data.uid</td>
<td>The Uid</td>
</tr>
<tr>
<td>data.pid</td>
<td>Page ID containing this Content Element</td>
</tr>
<tr>
<td>data.sys_language_uid</td>
<td>ID of the records language
</tr>
</table>
And, of course, many more. Just use the Debug Viewhelper to get a clue about other variables:
<f:debug>{data}</f:debug>
### Accessing Extension Configuration
Using the object {configuration}, you can access all options from the Extension Configuration, defined through Extension Manager (stored in the localconf.php):
<table>
<tr>
<th colspan="2">Extension Configuration</th>
</tr>
<tr>
<td>extendSubtitleByRTE</td>
<td>Boolean - defines whether the subtitle is an RTE or not; if it is, it can contain HTML</td>
</tr>
</table>
## How to
### … use the Plugin in a Library
… to e.g. refer it to the page template:
lib.example < plugin.tx_flexslider
lib.example < temp.flexslider
lib.example.persistence.storagePid = 73
lib.example.settings.randomize = 1
You just need to adjust the Records Storage Page ID (storagePid) - required!
Of course you can adjust the TypoScript Setup to fit your need via lib.example.settings.
Just dig into /Configuration/Typoscript/setup.txt to get a clue about the possibilities.
## Roadmap and Tasks
Plase take a look at the Github Issue Tracker for this projekt.
Plaese take a look at the Github Issue Tracker for this project.
## Contribute
If you have ideas, feature or bug requests, don't hesitate and report them at the Issue Tracker.
If you have any ideas, features or bug requests, don't hesitate to report them in the Issue Tracker.
Feel also free to fork and pull.
\ No newline at end of file
Feel free to fork and pull.
\ No newline at end of file
......@@ -50,8 +50,8 @@ class flexslider_pi1_wizicon
/**
* Processing the wizard items array
*
* @param array $wizardItems: The wizard items
* @return Modified array with wizard items
* @param array $wizardItems: The wizard items
* @return array Modified array with wizard items
*/
public function proc($wizardItems)
{
......@@ -71,7 +71,7 @@ class flexslider_pi1_wizicon
/**
* Reads the Backend Localization file.
*
* @return The array with language labels
* @return array The array with language labels
*/
protected function includeLocalLang()
{
......
......@@ -16,39 +16,45 @@
<f:for each="{flexSliders}" as="slide">
<li>
<f:if condition="{slide.link}">
<f:then>
<f:link.page pageUid="{slide.link}">
<f:image
src="uploads/tx_flexslider/{slide.image}"
alt="{slide.caption}"
width="{settings.images.width}" height="{settings.images.height}"
minWidth="{settings.images.minWidth}" minHeight="{settings.images.minHeight}"
maxWidth="{settings.images.maxWidth}" maxHeight="{settings.images.maxHeight}" />
</f:link.page>
</f:then>
<f:else>
<f:image
src="uploads/tx_flexslider/{slide.image}"
alt="{slide.caption}"
width="{settings.images.width}" height="{settings.images.height}"
minWidth="{settings.images.minWidth}" minHeight="{settings.images.minHeight}"
maxWidth="{settings.images.maxWidth}" maxHeight="{settings.images.maxHeight}" />
</f:else>
</f:if>
<fs:DynLink arguments="{link: slide.link}">
<f:image
src="uploads/tx_flexslider/{slide.image}"
alt="{slide.caption}"
width="{settings.images.width}" height="{settings.images.height}"
minWidth="{settings.images.minWidth}" minHeight="{settings.images.minHeight}"
maxWidth="{settings.images.maxWidth}" maxHeight="{settings.images.maxHeight}" />
</fs:DynLink>
<f:if condition="{settings.showCaption} > 0">
<p class="flex-caption">
<f:if condition="{slide.title}">
<strong>{slide.title}</strong>
</f:if>
<f:if condition="{slide.subtitle}">
<span>{slide.subtitle}</span>
<f:then>
<f:if condition="{configuration.extendSubtitleByRTE}">
<f:then>
<div class="flex-caption">
<f:if condition="{slide.title}">
<h3>{slide.title}</h3>
</f:if>
<f:if condition="{slide.subtitle}">
<div>
<f:format.html parseFuncTSPath="lib.parseFunc">{slide.subtitle}</f:format.html>
</div>
</f:if>
</div>
</f:then>
<f:else>
<p class="flex-caption">
<f:if condition="{slide.title}">
<strong>{slide.title}</strong>
</f:if>
<f:if condition="{slide.subtitle}">
<span>{slide.subtitle}</span>
</f:if>
</p>
</f:else>
</f:if>
</p>
</f:then>
</f:if>
</li>
</f:for>
</ul>
</div>
......
File added
<?php
$extensionClassesPath = t3lib_extMgm::extPath('flexslider') . 'Classes/';
return array(
'tx_flexslider_utility_emconfiguration' => $extensionClassesPath . 'Utility/EmConfiguration.php',
);
?>
\ No newline at end of file
# cat=basic/enable; type=boolean; label=Extend Subtitle by RTE functionality:
# With this feature you are able to write Rich Text and do fancy stuff.
extendSubtitleByRTE = 0
\ No newline at end of file
This diff is collapsed.
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