Skip to content

Commit

Permalink
[TASK] Rewritten file structure to drop fluidcontent requirement
Browse files Browse the repository at this point in the history
  • Loading branch information
dohomi committed May 22, 2013
1 parent 65f9491 commit a006aea
Show file tree
Hide file tree
Showing 40 changed files with 1,468 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Classes/Controller/GalleriaController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
namespace DMF\FluxGalleria\Controller;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;

/***************************************************************
* Copyright notice
*
* (c) 2012
* 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!
***************************************************************/
class GalleriaController extends ActionController {
/**
* @return void
*/
public function initializeAction() {

}

/**
* @return void
*/
public function indexAction() {

}
}

?>
49 changes: 49 additions & 0 deletions Classes/Provider/PluginConfigurationProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
namespace DMF\FluxGalleria\Provider;

/**
* Class PluginConfigurationProvider
*
* @package DMF\Intranet\Provider\Configuration
*/
class PluginConfigurationProvider extends \Tx_Flux_Provider_AbstractPluginConfigurationProvider
implements \Tx_Flux_Provider_PluginConfigurationProviderInterface {

/**
* @var string
*/
public $extensionKey = 'flux_galleria';

/**
* @var string
*/
public $listType = 'fluxgalleria_frontend';

/**
* @var array
*/
public $templateVariables = array();

/**
* @var array
*/
public $templatePaths = array(
'templateRootPath' => 'EXT:flux_galleria/Resources/Private/Templates/',
'partialRootPath' => 'EXT:flux_galleria/Resources/Private/Partials/',
'layoutRootPath' => 'EXT:flux_galleria/Resources/Private/Layouts/',
);

/**
* @var string
*/
public $configurationSectionName = 'Configuration';



/**
* @var string
*/
public $templatePathAndFilename = 'EXT:flux_galleria/Resources/Private/Templates/Galleria/Index.html';

}
?>
114 changes: 114 additions & 0 deletions Classes/ViewHelpers/FetchFilesViewHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Dominic Garms <[email protected]>, DMFmedia GmbH
*
* 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!
***************************************************************/

/**
* @author Dominic Garms, DMFmedia GmbH
* @package dmf_template
* @subpackage ViewHelpers/PageRenderer
*/

class Tx_FluxGalleria_ViewHelpers_FetchFilesViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractTagBasedViewHelper {


/**
* Initialize
*/
public function initializeArguments() {
$this->registerArgument('dir', 'string', 'Directory from where to fetch files', TRUE, FALSE);
$this->registerArgument('extension', 'mixed', 'Comma separated list of file extensions which are allowed', TRUE, FALSE);

}

/**
*
*/
public function render() {

$files = $this->getFilenamesOfType($this->arguments['dir']);

// add here the backup variables for the container
$backupVars = array('files');
$backups = array();
foreach ($backupVars as $var) {
if ($this->templateVariableContainer->exists($var)) {
$backups[$var] = $this->templateVariableContainer->get($var);
$this->templateVariableContainer->remove($var);
}
}

$this->templateVariableContainer->add('files', $files);
$content = $this->renderChildren();
$this->templateVariableContainer->remove('files');

if (count($backups) > 0) {
foreach ($backups as $var => $value) {
$this->templateVariableContainer->add($var, $value);
}
}

return $content;


}

/**
* Get an array of all with extension $extension in $dir
*
*
* @param string $dir
* @return array
*/
protected function getFilenamesOfType($dir) {
$allowedExtension = t3lib_div::trimExplode(',', $this->arguments['extension']);
$relative = $dir;
if (substr($dir, 0, 1) != '/') {
$dir = PATH_site . $dir;
}
$files = scandir($dir);
if (is_array($files)) {


foreach ($files as $k => $file) {
$pathinfo = pathinfo($dir . $file);
if ($pathinfo['extension'] == '') {
unset($files[$k]);
} elseif (is_dir($dir . $file)) {
unset($files[$k]);
} elseif ($allowedExtension && !in_array($pathinfo['extension'], $allowedExtension)) {
unset($files[$k]);
} else {
$files[$k] = $relative . '/' . $file;
}
}
sort($files);

return $files;
}

return false;

}

}
95 changes: 95 additions & 0 deletions Classes/ViewHelpers/PageRenderer/IncludeFileViewHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Dominic Garms <[email protected]>, DMFmedia GmbH
*
* 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!
***************************************************************/

/**
* @author Dominic Garms, DMFmedia GmbH
* @package dmf_template
* @subpackage ViewHelpers/PageRenderer
*/

class Tx_FluxGalleria_ViewHelpers_PageRenderer_IncludeFileViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractTagBasedViewHelper {

/**
* Initialize
*/
public function initializeArguments() {
$this->registerArgument('type', 'string', 'Type argument - see PageRenderer documentation', FALSE, 'text/javascript');
$this->registerArgument('compress', 'boolean', 'Compress argument - see PageRenderer documentation', FALSE, TRUE);
$this->registerArgument('forceOnTop', 'boolean', 'ForceOnTop argument - see PageRenderer documentation', FALSE, FALSE);
$this->registerArgument('allWrap', 'string', 'AllWrap argument - see PageRenderer documentation', FALSE, '');
$this->registerArgument('excludeFromConcatenation', 'string', 'ExcludeFromConcatenation argument - see PageRenderer documentation', FALSE, FALSE);
$this->registerArgument('rel', 'string', 'Rel tag (css only)', FALSE, 'stylesheet');
$this->registerArgument('media', 'string', 'Media tag (css only)', FALSE, 'all');
$this->registerArgument('title', 'string', 'Title for css (css only)', FALSE, '');
$this->registerArgument('footer', 'boolean', 'Include file into Footer (js only)', FALSE, FALSE);
$this->registerArgument('library', 'boolean', 'Include file as JS library (js only', FALSE, FALSE);
$this->registerArgument('file', 'string', 'css or js file', TRUE, NULL);


}

public function render() {
$file = $GLOBALS['TSFE']->tmpl->getFileName($this->arguments['file']);
$includeFunctionName = 'add';

if ($file) {
$funcArgumentList = array(
$this->arguments['compress'],
$this->arguments['forceOnTop'],
$this->arguments['allWrap'],
$this->arguments['excludeFromConcatenation']
);

// JS
if (strtolower(substr($file, -3)) === '.js') {
$includeFunctionName .= 'Js';
array_unshift($funcArgumentList, $this->arguments['type']);
array_unshift($funcArgumentList, $file);
if ($this->arguments['footer']) {
$includeFunctionName .= 'Footer';
}
if ($this->arguments['library']) {
$includeFunctionName .= 'Library';
array_unshift($funcArgumentList, $file);
} else {
$includeFunctionName .= 'File';
}
}
// CSS
elseif (strtolower(substr($file, -4)) === '.css') {
$includeFunctionName .= 'CssFile';
array_unshift($funcArgumentList, $this->arguments['title']);
array_unshift($funcArgumentList, $this->arguments['media']);
array_unshift($funcArgumentList, $this->arguments['rel']);
array_unshift($funcArgumentList, $file);

}

call_user_func_array(array($GLOBALS['TSFE']->getPageRenderer(), $includeFunctionName), $funcArgumentList);
}

}

}
84 changes: 84 additions & 0 deletions Classes/ViewHelpers/PageRenderer/IncludeInlineViewHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?php
/***************************************************************
* Copyright notice
*
* (c) 2012 Dominic Garms <[email protected]>, DMFmedia GmbH
*
* 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!
***************************************************************/

/**
* @author Dominic Garms, DMFmedia GmbH
* @package dmf_template
* @subpackage ViewHelpers/PageRenderer
*/

class Tx_FluxGalleria_ViewHelpers_PageRenderer_IncludeInlineViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractTagBasedViewHelper {


/**
* Initialize
*/
public function initializeArguments() {
$this->registerArgument('type', 'string', 'Type of inline block: css or js', TRUE, FALSE);
$this->registerArgument('name', 'string', 'Name of inline block', TRUE, FALSE);
$this->registerArgument('block', 'string', 'Inline code if not use of template children', FALSE, FALSE);
$this->registerArgument('compress', 'boolean', 'Compress argument - see PageRenderer documentation', FALSE, TRUE);
$this->registerArgument('forceOnTop', 'boolean', 'ForceOnTop argument - see PageRenderer documentation', FALSE, FALSE);
$this->registerArgument('footer', 'boolean', 'Include file into Footer (js only)', FALSE, FALSE);


}

public function render() {
$type = $this->arguments['type'];
$block = $this->arguments['block'];
if (!$block) {
$block = $this->renderChildren();
}
$funcArgumentList = array(
$this->arguments['name'],
$block,
$this->arguments['compress'],
$this->arguments['forceOnTop']
);
$includeFunctionName = 'add';


// js
if ($block) {
if ($type === 'js') {
$includeFunctionName .= 'Js';
if ($this->arguments['footer']) {
$includeFunctionName .= 'Footer';
}
$includeFunctionName .= 'InlineCode';

} // css
elseif ($type === 'css') {
$includeFunctionName .= 'CssInlineBlock';
}
call_user_func_array(array($GLOBALS['TSFE']->getPageRenderer(), $includeFunctionName), $funcArgumentList);
}


}


}
Loading

0 comments on commit a006aea

Please sign in to comment.