Commit 40cb76ad authored by Dirk Wildt's avatar Dirk Wildt
Browse files

Initial commit

parents
Pipeline #69 canceled with stages
.git.local/**
.svn/**
nbproject/**
tmp/**
id=20002&tx_xblog_bloglisting[blog]=6&tx_xblog_bloglisting[action]=show&tx_xblog_bloglisting[controller]=Blog
?id=20002&tx_xblog_pi1[uid]=6&tx_xblog_pi1[action]=single&tx_xblog_pi1[controller]=Content
0.0.1
18-11-21
Initial release
Dirk Wildt http://wildt.at.die-netzmacher.de
<?php
namespace Netzmacher\Xblog\Controller;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
/* * *************************************************************
* Copyright notice
*
* (c) 2018 - Dirk Wildt <http://wildt.at.die-netzmacher.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!
* ************************************************************* */
/**
* AbstractController for the xBlog xtension
*
* @package TYPO3
* @subpackage xblog
* @author Dirk Wildt <http://wildt.at.die-netzmacher.de>
* @version 0.0.1
* @since 0.0.1
*/
class AbstractController extends ActionController
{
/**
* @var TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
*/
private $_oCObj;
/**
* @var TYPO3\CMS\Core\Imaging\GraphicalFunctions
*/
private $_oGraphFuncObj;
/**
* @var ContentObjectRenderer
*/
protected $contentObject;
/**
* @var string Extension key
*/
public $extKey = 'xblog';
/**
* @var string path to the lanugage file
*/
public $sLanguageFilePath = '';
/**
* _initLL( ) : Init localisation
*
* @return void
* @access private
* @version 0.0.1
* @since 0.0.1
*/
private function _initLL()
{
$this->_initObjectPlugin();
$pathToLL = 'EXT:' . $this->extKey . '/' . $this->sLanguageFilePath;
switch( TRUE )
{
case($this->_zzT3Version() < 7006000):
$this->_initLL62( $pathToLL );
break;
case($this->_zzT3Version() >= 7006000):
default:
$this->_initLLDefault( $pathToLL );
break;
}
}
/**
* _initLL( ) : Init localisation
*
* @param string Path to the locallanaguage file
* @return void
* @access private
* @version 0.0.1
* @since 0.0.1
*/
private function _initLLDefault( $pathToLL )
{
$this->_oPlugin->pi_loadLL( $pathToLL );
//var_dump(__METHOD__, __LINE__, $this->_oPlugin->LOCAL_LANG);
}
/**
* _initLL( ) : Init localisation
*
* @return void
* @access private
* @version 2.4.1
* @since 2.4.1
* @internal #i0018
*/
private function _initLL62( $pathToLL )
{
$basePath = $pathToLL;
// Read the strings in the required charset (since TYPO3 4.2)
$this->_oPlugin->LOCAL_LANG = GeneralUtility::readLLfile( $basePath, $this->_oPlugin->LLkey, $GLOBALS[ 'TSFE' ]->renderCharset );
$alternativeLanguageKeys = GeneralUtility::trimExplode( ',', $this->_oPlugin->altLLkey, TRUE );
foreach( $alternativeLanguageKeys as $languageKey )
{
$tempLL = GeneralUtility::readLLfile( $basePath, $languageKey );
if( $this->_oPlugin->LLkey !== 'default' && isset( $tempLL[ $languageKey ] ) )
{
$this->_oPlugin->LOCAL_LANG[ $languageKey ] = $tempLL[ $languageKey ];
}
}
// Overlaying labels from TypoScript (including fictitious language keys for non-system languages!):
if( isset( $this->_oPlugin->conf[ '_LOCAL_LANG.' ] ) )
{
// Clear the "unset memory"
$this->_oPlugin->LOCAL_LANG_UNSET = array();
foreach( $this->_oPlugin->conf[ '_LOCAL_LANG.' ] as $languageKey => $languageArray )
{
// Remove the dot after the language key
$languageKey = substr( $languageKey, 0, -1 );
// Don't process label if the language is not loaded
if( is_array( $languageArray ) && isset( $this->_oPlugin->LOCAL_LANG[ $languageKey ] ) )
{
foreach( $languageArray as $labelKey => $labelValue )
{
if( !is_array( $labelValue ) )
{
$this->_oPlugin->LOCAL_LANG[ $languageKey ][ $labelKey ][ 0 ][ 'target' ] = $labelValue;
if( $labelValue === '' )
{
$this->_oPlugin->LOCAL_LANG_UNSET[ $languageKey ][ $labelKey ] = '';
}
$this->_oPlugin->LOCAL_LANG_charset[ $languageKey ][ $labelKey ] = 'utf-8';
}
}
}
}
}
$this->_oPlugin->LOCAL_LANG_loaded = 1;
}
/**
* _initObject( ) :
*
* @return void
* @access private
* @version 0.0.1
* @since 0.0.1
*/
private function _initObject()
{
$this->_initObjectGraphFuncObj();
$this->_initObjectObjectManager();
$this->_initObjectContent();
$this->_initObjectCObj();
$this->_initObjectTypoScriptService();
}
/**
* Initializes this object
*
* @return void
* @codeCoverageIgnore
* @throws InvalidSlotException
* @throws InvalidSlotReturnException
*/
private function _initObjectContent()
{
// @extensionScannerIgnoreLine Seems to be a false positive: getContentObject() is still correct in 9.0
$this->contentObject = $this->configurationManager->getContentObject();
}
/**
* _initObjectCObj( ) :
*
* @return void
* @access private
* @version 0.0.1
* @since 0.0.1
*/
private function _initObjectCObj()
{
$this->_oCObj = $this->_oObjectManager->get( 'TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer' );
$this->_initObjectCObjData();
}
/**
* _initObjectCObjData( ) : Is needed, if in TypoScript is used: data = flexform : pi_flexform:...
* If it isn't set, data will be empty, and data[pi_flexform] too of course.
*
* @return void
* @access private
* @version 0.0.1
* @since 0.0.1
*/
private function _initObjectCObjData()
{
$this->_oCObj->data = $this->contentObject->data;
}
/**
* _initObjectGraphFuncObj( ) :
*
* @return void
* @access private
* @version 0.0.1
* @since 0.0.1
*/
private function _initObjectGraphFuncObj()
{
$this->_oGraphFuncObj = GeneralUtility::makeInstance( \TYPO3\CMS\Core\Imaging\GraphicalFunctions::class );
$this->_oGraphFuncObj->init();
}
/**
* _initObjectObjectManager( ) :
*
* @return void
* @access private
* @version 0.0.1
* @since 0.0.1
*/
private function _initObjectObjectManager()
{
$this->_oObjectManager = GeneralUtility::makeInstance( 'TYPO3\\CMS\\Extbase\\Object\\ObjectManager' );
}
/**
* _initObjectPlugin( ) : Init localisation
*
* @return void
* @access private
* @version 0.0.1
* @since 0.0.1
*/
private function _initObjectPlugin()
{
$this->_oPlugin = GeneralUtility::makeInstance( \TYPO3\CMS\Frontend\Plugin\AbstractPlugin::class );
}
/**
* _initObjectTypoScriptService( ) :
*
* @return void
* @access private
* @version 0.0.1
* @since 0.0.1
*/
private function _initObjectTypoScriptService()
{
$this->_oTypoScriptService = GeneralUtility::makeInstance( 'TYPO3\\CMS\\Extbase\\Service\\TypoScriptService' );
}
/**
* _initTyposcriptRegister( ) :
*
* @return void
* @access private
* @version 0.0.1
* @since 0.0.1
*/
private function _initTyposcriptRegister()
{
$this->cObjGetSingle( $this->settings[ 'general' ][ 'register' ] );
}
/**
* _zzT3Version( ) :
*
* @return integer
* @access private
* @version 0.0.1
* @since 0.0.1
*/
private function _zzT3Version()
{
list( $main, $sub, $bugfix ) = explode( '.', TYPO3_version );
$typo3Version = ( ( int ) $main ) * 1000000;
$typo3Version = $typo3Version + ( ( int ) $sub ) * 1000;
$typo3Version = $typo3Version + ( ( int ) $bugfix ) * 1;
return $typo3Version;
}
/**
* _cObjGetSingle( ) :
*
* @param array $record
* @return string $value
* @access protected
* @version 0.0.1
* @since 0.0.1
*/
protected function cObjGetSingle( $record )
{
if( empty( $record ) )
{
return;
}
$name = $record[ '_typoScriptNodeValue' ];
$conf = $this->_oTypoScriptService->convertPlainArrayToTypoScriptArray( $record );
//var_dump(__METHOD__, __LINE__, $name, $conf);
$value = $this->_oCObj->cObjGetSingle( $name, $conf );
return $value;
}
/**
* debugList( ) :
*
* @return string
* @access private
* @version 0.0.1
* @since 0.0.1
*/
protected function debugList()
{
$debugIsEnabled = $this->settings[ 'flexform' ][ 'pi' ][ 'debug' ][ 'enabled' ];
if( !$debugIsEnabled )
{
return;
}
return $this->cObjGetSingle( $this->settings[ 'list' ][ 'debug' ] );
}
/**
* debugSingle( ) :
*
* @return string
* @access private
* @version 0.0.1
* @since 0.0.1
*/
protected function debugSingle()
{
$debugIsEnabled = $this->settings[ 'flexform' ][ 'pi' ][ 'debug' ][ 'enabled' ];
if( !$debugIsEnabled )
{
return;
}
return $this->cObjGetSingle( $this->settings[ 'single' ][ 'debug' ] );
}
/**
* init( ) :
*
* @return void
* @access private
* @version 0.0.1
* @since 0.0.1
*/
protected function init()
{
$this->_initLL();
$this->_initObject();
//$this->contentObject->data['pi_flexform'] = GeneralUtility::xml2array($this->contentObject->data['pi_flexform']);
$this->_initTyposcriptRegister();
}
/**
* singlePluginRequirement( ) :
*
* @return string
* @access private
* @version 0.0.1
* @since 0.0.1
*/
protected function singlePluginRequirement()
{
$singlePluginAvailable = $this->cObjGetSingle( $this->settings[ 'general' ][ 'rules' ][ 'singlePluginAvailable' ] );
if( $singlePluginAvailable )
{
return true;
}
return false;
}
/**
* urlWiUid( ) :
*
* @return string
* @access private
* @version 0.0.1
* @since 0.0.1
*/
protected function urlWiUid()
{
$args = $this->request->getArguments();
$uid = ( int ) $args[ 'uid' ];
var_dump( __METHOD__, __LINE__, $uid );
if( $uid )
{
return true;
}
return false;
}
}
<?php
namespace Netzmacher\Xblog\Controller;
/* * *************************************************************
* Copyright notice
*
* (c) 2018 - Dirk Wildt <http://wildt.at.die-netzmacher.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!
* ************************************************************* */
/**
* Class for rendering records
*
* @package TYPO3
* @subpackage xblog
* @author Dirk Wildt <http://wildt.at.die-netzmacher.de>
* @version 0.0.1
* @since 0.0.1
*/
class ContentController extends AbstractController
{
/**
* @var string path to the lanugage file
*/
public $sLanguageFilePath = 'Resources/Private/Language/Content.xlf';
/**
* _viewAssignList( ) :
*
* @return void
* @access private
* @version 0.0.1
* @since 0.0.1
*/
private function _viewAssignList()
{
$this->view->assignMultiple(
array(
'tt_content' => $this->contentObject->data
, $this->cObjGetSingle( $this->settings[ 'general' ][ 'register' ] )
, 'content' => $this->cObjGetSingle( $this->settings[ 'list' ][ 'content' ] )
, 'debug' => $this->debugList(),
)
);
}
/**
* _viewAssignSingle( ) :
*
* @return void
* @access private
* @version 0.0.1
* @since 0.0.1
*/
private function _viewAssignSingle()
{
$this->view->assignMultiple(
array(
'tt_content' => $this->contentObject->data
, 'content' => $this->cObjGetSingle( $this->settings[ 'single' ][ 'content' ] )
, 'debug' => $this->debugSingle()
)
);
}
/**
* _viewAssignSingleError( ) :
*
* @return void
* @access private
* @version 0.0.1
* @since 0.0.1
*/
private function _viewAssignSingleError()
{
$this->view->assignMultiple(
array(
'tt_content' => $this->contentObject->data
// , 'content' => $this->cObjGetSingle( $this->settings[ 'single' ][ 'content' ] )
// , 'debug' => $this->debugSingle()
)
);
}
/**
* listAction( ) :
*
* @return void
* @access public
* @version 0.0.1
* @since 0.0.1
*
*/
public function listAction()
{
// if($this->urlWiUid())
// {
// $this->singleAction();
// return;
// }
$this->init();
// var_dump(__METHOD__, __LINE__, $this->settings);
// var_dump(__METHOD__, __LINE__, $this->settings['xblogId']);
// var_dump(__METHOD__, __LINE__, $this->contentObject->data);
// var_dump(__METHOD__, __LINE__, $this->cObjGetSingle( $this->settings['tables']['pages'] ));
$this->_viewAssignList();
}
/**
* singleAction( ) :
*
* @return void
* @access public
* @version 0.0.1
* @since 0.0.1
*
*/
public function singleAction()
{
$this->init();
if(!$this->singlePluginRequirement())
{
$this->_viewAssignSingleError();
return;
}
// var_dump(__METHOD__, __LINE__, $this->settings);
// var_dump(__METHOD__, __LINE__, $this->settings['xblogId']);
// var_dump(__METHOD__, __LINE__, $this->contentObject->data);
// var_dump(__METHOD__, __LINE__, $this->cObjGetSingle( $this->settings['tables']['pages'] ));
$this->_viewAssignSingle();
}
}
<?php
namespace Netzmacher\Xblog\Controller;
/* * *************************************************************
* Copyright notice
*
* (c) 2018 - Dirk Wildt <http://wildt.at.die-netzmacher.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