Example #1
0
 /**
  * Get the uid of the tag, either bei inserting as new or get existing
  *
  * @param array $request ajax request
  * @return integer
  * @throws \Exception
  */
 protected function getTagUid(array $request)
 {
     // Get configuration from EM
     $configuration = EmConfiguration::getSettings();
     $pid = $configuration->getTagPid();
     if ($pid === 0) {
         $pid = $this->getTagPidFromTsConfig($request['newsid']);
     }
     if ($pid === 0) {
         throw new \Exception('error_no-pid-defined');
     }
     $record = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', self::TAG, 'deleted=0 AND pid=' . $pid . ' AND title=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($request['item'], self::TAG));
     if (isset($record['uid'])) {
         $tagUid = $record['uid'];
     } else {
         $tcemainData = array(self::TAG => array('NEW' => array('pid' => $pid, 'title' => $request['item'])));
         /** @var DataHandler $tce */
         $tce = GeneralUtility::makeInstance(DataHandler::class);
         $tce->start($tcemainData, array());
         $tce->process_datamap();
         $tagUid = $tce->substNEWwithIDs['NEW'];
     }
     if ($tagUid == 0) {
         throw new \Exception('error_no-tag-created');
     }
     return $tagUid;
 }
Example #2
0
 /**
  * @param array $result
  * @return array
  */
 public function addData(array $result)
 {
     if ($result['command'] !== 'new' || $result['tableName'] !== 'tx_news_domain_model_news') {
         return $result;
     }
     if ($this->emConfiguration->getDateTimeRequired()) {
         $result['databaseRow']['datetime'] = $GLOBALS['EXEC_TIME'];
     }
     if (is_array($result['pageTsConfig']['tx_news.']) && is_array($result['pageTsConfig']['tx_news.']['predefine.'])) {
         if (isset($result['pageTsConfig']['tx_news.']['predefine.']['author'])) {
             $result['databaseRow']['author'] = $GLOBALS['BE_USER']->user['realName'];
             $result['databaseRow']['author_email'] = $GLOBALS['BE_USER']->user['email'];
         }
         if (isset($result['pageTsConfig']['tx_news.']['predefine.']['archive'])) {
             $calculatedTime = strtotime($result['pageTsConfig']['tx_news.']['predefine.']['archive']);
             if ($calculatedTime !== false) {
                 $result['databaseRow']['archive'] = $calculatedTime;
             }
         }
     }
     return $result;
 }
 /**
  * Check if a user has access to all categories of a news record
  *
  * @param array $newsRecord
  * @return boolean
  */
 public static function userHasCategoryPermissionsForRecord(array $newsRecord)
 {
     if (!EmConfiguration::getSettings()->getCategoryBeGroupTceFormsRestriction()) {
         return true;
     }
     if (self::getBackendUser()->isAdmin()) {
         // an admin may edit all news
         return true;
     }
     // If there are any categories with denied access, the user has no permission
     if (count(self::getAccessDeniedCategories($newsRecord))) {
         return false;
     } else {
         return true;
     }
 }
Example #4
0
 /**
  * Check for correct configuration
  *
  * @return string
  * @throws \Exception
  * @throws \TYPO3\CMS\Core\Resource\Exception\InsufficientFolderAccessPermissionsException
  */
 protected function checkCorrectConfiguration()
 {
     $error = '';
     $settings = EmConfiguration::getSettings();
     try {
         $storageId = (int) $settings->getStorageUidImporter();
         $path = $settings->getResourceFolderImporter();
         if ($storageId === 0) {
             throw new \UnexpectedValueException('import.error.configuration.storageUidImporter');
         }
         if (empty($path)) {
             throw new \UnexpectedValueException('import.error.configuration.resourceFolderImporter');
         }
         $storage = $this->getResourceFactory()->getStorageObject($settings->getStorageUidImporter());
     } catch (FolderDoesNotExistException $e) {
         $error = 'import.error.configuration.resourceFolderImporter.notExist';
     } catch (\UnexpectedValueException $e) {
         $error = $e->getMessage();
     }
     return $error;
 }
Example #5
0
 /**
  * Constructor
  */
 public function __construct()
 {
     $this->emSettings = EmConfiguration::getSettings();
 }
<?php

defined('TYPO3_MODE') or die;
$ll = 'LLL:EXT:news/Resources/Private/Language/locallang_db.xlf:';
// Extension manager configuration
$configuration = \GeorgRinger\News\Utility\EmConfiguration::getSettings();
$tx_news_domain_model_media = ['ctrl' => ['title' => $ll . 'tx_news_domain_model_media', 'descriptionColumn' => 'description', 'label' => 'caption', 'label_alt' => 'type, showinpreview', 'label_alt_force' => 1, 'formattedLabel_userFunc' => \GeorgRinger\News\Hooks\Labels::class . '->getUserLabelMedia', 'tstamp' => 'tstamp', 'crdate' => 'crdate', 'cruser_id' => 'cruser_id', 'type' => 'type', 'languageField' => 'sys_language_uid', 'transOrigPointerField' => 'l10n_parent', 'transOrigDiffSourceField' => 'l10n_diffsource', 'versioningWS' => true, 'origUid' => 't3_origuid', 'dividers2tabs' => true, 'default_sortby' => 'ORDER BY sorting', 'sortby' => 'sorting', 'delete' => 'deleted', 'enablecolumns' => ['disabled' => 'hidden'], 'iconfile' => 'EXT:news/Resources/Public/Icons/news_domain_model_media.gif', 'hideTable' => true], 'interface' => ['showRecordFieldList' => 'sys_language_uid,l10n_parent,l10n_diffsource,hidden,title,media,type,video,showInPreview, width, height, description'], 'columns' => ['pid' => ['label' => 'pid', 'config' => ['type' => 'passthrough']], 'sorting' => ['label' => 'pid', 'config' => ['type' => 'passthrough']], 'crdate' => ['label' => 'crdate', 'config' => ['type' => 'passthrough']], 'tstamp' => ['label' => 'tstamp', 'config' => ['type' => 'passthrough']], 'sys_language_uid' => ['exclude' => 1, 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.language', 'config' => ['type' => 'select', 'renderType' => 'selectSingle', 'special' => 'languages', 'items' => [['LLL:EXT:lang/locallang_general.xlf:LGL.allLanguages', -1, 'flags-multiple']], 'default' => 0]], 'l10n_parent' => ['displayCond' => 'FIELD:sys_language_uid:>:0', 'exclude' => 1, 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.l18n_parent', 'config' => ['type' => 'select', 'renderType' => 'selectSingle', 'items' => [['', 0]], 'foreign_table' => 'tx_news_domain_model_media', 'foreign_table_where' => 'AND tx_news_domain_model_media.pid=###CURRENT_PID### AND tx_news_domain_model_media.sys_language_uid IN (-1,0)']], 'l10n_diffsource' => ['config' => ['type' => 'passthrough', 'default' => '']], 'hidden' => ['exclude' => 1, 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.hidden', 'config' => ['type' => 'check', 'default' => 0]], 'caption' => ['exclude' => 1, 'l10n_mode' => 'noCopy', 'label' => $ll . 'tx_news_domain_model_media.caption', 'config' => ['type' => 'input', 'size' => 30]], 'title' => ['exclude' => 1, 'l10n_mode' => 'noCopy', 'label' => 'LLL:EXT:cms/locallang_ttc.xlf:image_titleText', 'config' => ['type' => 'input', 'size' => 20]], 'alt' => ['exclude' => 1, 'l10n_mode' => 'noCopy', 'label' => 'LLL:EXT:cms/locallang_ttc.xlf:image_altText', 'config' => ['type' => 'input', 'size' => 20]], 'image' => ['exclude' => 0, 'l10n_mode' => 'copy', 'label' => $ll . 'tx_news_domain_model_media.media', 'config' => ['type' => 'group', 'internal_type' => 'file', 'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], 'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'], 'uploadfolder' => 'uploads/tx_news', 'show_thumbs' => 1, 'size' => 1, 'minitems' => 1, 'maxitems' => 1]], 'multimedia' => ['exclude' => 0, 'l10n_mode' => 'copy', 'label' => $ll . 'tx_news_domain_model_media.multimedia', 'config' => ['type' => 'input', 'size' => 30, 'eval' => 'trim,required', 'softref' => 'news_externalurl', 'wizards' => ['_PADDING' => 2, 'link' => ['type' => 'popup', 'title' => 'Link', 'icon' => 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_link.gif', 'module' => ['name' => 'wizard_link_browser'], 'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1']]]], 'showinpreview' => ['exclude' => 1, 'label' => $ll . 'tx_news_domain_model_media.showinpreview', 'config' => ['type' => 'check', 'default' => 0]], 'type' => ['exclude' => 1, 'l10n_mode' => 'mergeIfNotBlank', 'label' => 'LLL:EXT:cms/locallang_ttc.xlf:media.type', 'config' => ['type' => 'select', 'renderType' => 'selectSingle', 'items' => [[$ll . 'tx_news_domain_model_media.type.I.0', '0', \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('news') . 'Resources/Public/Icons/media_type_image.png'], [$ll . 'tx_news_domain_model_media.type.I.1', '1', \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('news') . 'Resources/Public/Icons/media_type_multimedia.png']], 'size' => 1, 'maxitems' => 1]], 'width' => ['exclude' => 1, 'l10n_mode' => 'mergeIfNotBlank', 'label' => 'LLL:EXT:cms/locallang_ttc.xlf:imagewidth_formlabel', 'config' => ['type' => 'input', 'size' => 3, 'eval' => 'int']], 'height' => ['exclude' => 1, 'l10n_mode' => 'mergeIfNotBlank', 'label' => 'LLL:EXT:cms/locallang_ttc.xlf:imageheight_formlabel', 'config' => ['type' => 'input', 'size' => 3, 'eval' => 'int']], 'copyright' => ['exclude' => 1, 'l10n_mode' => 'mergeIfNotBlank', 'label' => $ll . 'tx_news_domain_model_media.copyright', 'config' => ['type' => 'input', 'size' => 20]], 'description' => ['exclude' => 0, 'l10n_mode' => 'noCopy', 'label' => $ll . 'tx_news_domain_model_file.description', 'config' => ['type' => 'text', 'cols' => 30, 'rows' => 5, 'wizards' => ['_PADDING' => 2, 'RTE' => ['notNewRecords' => 1, 'RTEonly' => 1, 'type' => 'script', 'title' => 'Full screen Rich Text Editing', 'icon' => 'EXT:backend/Resources/Public/Images/FormFieldWizard/wizard_rte.gif', 'module' => ['name' => 'wizard_rte']]]]]], 'types' => ['0' => ['showitem' => '--palette--;;paletteCore,image, --palette--;;paletteWidthHeight,caption,title, --palette--;;paletteAlt,copyright,description'], '1' => ['showitem' => '--palette--;;paletteCore,multimedia,caption,copyright,description,']], 'palettes' => ['paletteWidthHeight' => ['showitem' => 'width,height,', 'canNotCollapse' => true], 'paletteCore' => ['showitem' => 'type,showinpreview, hidden,sys_language_uid, l10n_parent, l10n_diffsource,', 'canNotCollapse' => true], 'paletteAlt' => ['showitem' => 'alt', 'canNotCollapse' => false]]];
// Hide image type when FAL + Multimedia is set
if ($configuration->getUseFal() === 3) {
    unset($tx_news_domain_model_media['columns']['type']['config']['items'][0]);
    $tx_news_domain_model_media['columns']['type']['config']['default'] = '1';
}
// Hide RTE description field
if (!$configuration->getShowMediaDescriptionField()) {
    unset($tx_news_domain_model_media['columns']['description']);
}
return $tx_news_domain_model_media;
Example #7
0
 /**
  * Initializes the view before invoking an action method.
  * Override this method to solve assign variables common for all actions
  * or prepare the view in another way before the action is called.
  *
  * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view The view to be initialized
  * @return void
  */
 protected function initializeView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
 {
     $view->assign('contentObjectData', $this->configurationManager->getContentObject()->data);
     $view->assign('emConfiguration', EmConfiguration::getSettings());
     parent::initializeView($view);
 }
Example #8
0
 /**
  * Initializes the view before invoking an action method.
  * Override this method to solve assign variables common for all actions
  * or prepare the view in another way before the action is called.
  *
  * @param \TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view The view to be initialized
  * @return void
  */
 protected function initializeView(\TYPO3\CMS\Extbase\Mvc\View\ViewInterface $view)
 {
     $view->assign('contentObjectData', $this->configurationManager->getContentObject()->data);
     $view->assign('emConfiguration', EmConfiguration::getSettings());
     $view->assign('isVersion7Compatible', GeneralUtility::compat_version('7.0'));
 }
 /**
  * Test if configuration model is correctly returned
  *
  * @test
  * @dataProvider extensionManagerConfigurationIsCorrectlyReturnedDataProvider
  * @return void
  */
 public function extensionManagerConfigurationIsCorrectlyReturned($expectedFields, $expected)
 {
     $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['news'] = $expectedFields;
     $this->assertEquals($expected, EmConfiguration::getSettings());
 }