Example #1
0
if (!defined('TYPO3_MODE')) {
    die('Access denied.');
}
$ll = 'LLL:EXT:moox_news/Resources/Private/Language/locallang_db.xlf:';
/**
 * Add extra fields to the sys_category record
 */
$newSysCategoryColumns = array('pid' => array('label' => 'pid', 'config' => array('type' => 'passthrough')), 'sorting' => array('label' => 'sorting', 'config' => array('type' => 'passthrough')), 'crdate' => array('label' => 'crdate', 'config' => array('type' => 'passthrough')), 'tstamp' => array('label' => 'tstamp', 'config' => array('type' => 'passthrough')), 'fe_group' => array('exclude' => 1, 'label' => 'LLL:EXT:lang/locallang_general.xlf:LGL.fe_group', 'config' => array('type' => 'select', 'size' => 6, 'maxitems' => 99, 'items' => array(array('LLL:EXT:lang/locallang_general.xlf:LGL.hide_at_login', -1), array('LLL:EXT:lang/locallang_general.xlf:LGL.any_login', -2), array('LLL:EXT:lang/locallang_general.xlf:LGL.usergroups', '--div--')), 'exclusiveKeys' => '-1,-2', 'foreign_table' => 'fe_groups', 'foreign_table_where' => 'ORDER BY fe_groups.title')), 'images' => array('exclude' => 1, 'l10n_mode' => 'mergeIfNotBlank', 'label' => $ll . 'tx_mooxnews_domain_model_category.image', 'config' => \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig('images', array('appearance' => array('createNewRelationLinkTitle' => 'LLL:EXT:cms/locallang_ttc.xlf:images.addFileReference'), 'foreign_match_fields' => array('fieldname' => 'images', 'tablenames' => 'sys_category', 'table_local' => 'sys_file')), $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'])), 'single_pid' => array('exclude' => 1, 'l10n_mode' => 'mergeIfNotBlank', 'label' => $ll . 'tx_mooxnews_domain_model_category.single_pid', 'config' => array('type' => 'group', 'internal_type' => 'db', 'allowed' => 'pages', 'size' => 1, 'maxitems' => 1, 'minitems' => 0, 'show_thumbs' => 1, 'wizards' => array('suggest' => array('type' => 'suggest')))), 'preview_pid' => array('exclude' => 1, 'l10n_mode' => 'mergeIfNotBlank', 'label' => $ll . 'tx_mooxnews_domain_model_category.preview_pid', 'config' => array('type' => 'group', 'internal_type' => 'db', 'allowed' => 'pages', 'size' => 1, 'maxitems' => 1, 'minitems' => 0, 'show_thumbs' => 1, 'wizards' => array('suggest' => array('type' => 'suggest')))), 'shortcut' => array('exclude' => 1, 'l10n_mode' => 'mergeIfNotBlank', 'label' => $ll . 'tx_mooxnews_domain_model_category.shortcut', 'config' => array('type' => 'group', 'internal_type' => 'db', 'allowed' => 'pages', 'size' => 1, 'maxitems' => 1, 'minitems' => 0, 'show_thumbs' => 1, 'wizards' => array('suggest' => array('type' => 'suggest')))), 'news_types' => array('exclude' => 1, 'l10n_mode' => 'mergeIfNotBlank', 'label' => $ll . 'tx_mooxnews_domain_model_category.news_types', 'config' => array('type' => 'select', 'size' => 6, 'maxitems' => 999, 'minitems' => 0, 'allowNonIdValues' => 1, 'itemsProcFunc' => 'Tx_MooxNews_Hooks_ItemsProcFunc->user_types', 'default' => '')), 'import_id' => array('label' => $ll . 'tx_mooxnews_domain_model_news.import_id', 'config' => array('type' => 'passthrough')), 'import_source' => array('label' => $ll . 'tx_mooxnews_domain_model_news.import_source', 'config' => array('type' => 'passthrough')));
//$tx_mooxnews_domain_model_news['columns']['categories']['config']['foreign_table_where'] = ' AND pid=###CURRENT_PID### AND (sys_category.sys_language_uid = 0 OR sys_category.l10n_parent = 0) ORDER BY sys_category.sorting';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('sys_category', $newSysCategoryColumns, 1);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('sys_category', '--div--;LLL:EXT:cms/locallang_tca.xls:pages.tabs.options, images', '', 'before:description');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('sys_category', 'single_pid', '', 'after:description');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('sys_category', 'preview_pid', '', 'after:description');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('sys_category', 'shortcut', '', 'after:single_pid');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('sys_category', 'fe_group,news_types');
// add fe_group as enable field
$GLOBALS['TCA']['sys_category']['ctrl']['enablecolumns']['fe_group'] = 'fe_group';
/*$GLOBALS['TCA']['sys_category']['ctrl']['columns']['items']['config']['MM_oppositeUsage'] = array(
        'pages' => array('categories'),
        'sys_file_metadata' => array('categories'),
        'tt_content' => array('categories'),
		'tx_mooxnews_domain_model_news' => array('categories'),
);*/
$GLOBALS['TCA']['sys_category']['ctrl']['columns']['items']['config'] = array('type' => 'passthrough');
$GLOBALS['TCA']['sys_category']['types'][1]['showitem'] = str_replace("--div--;LLL:EXT:lang/locallang_tca.xlf:sys_category.tabs.items,items,", "", $GLOBALS['TCA']['sys_category']['types'][1]['showitem']);
// Extension manager configuration
$configuration = Tx_MooxNews_Utility_EmConfiguration::getSettings();
if ($configuration->getCategoryRestriction() == "current_pid") {
    $GLOBALS['TCA']['sys_category']['columns']['parent']['config']['foreign_table_where'] = ' AND pid=###CURRENT_PID###' . $GLOBALS['TCA']['sys_category']['columns']['parent']['config']['foreign_table_where'];
}
 /**
  * Main action for administration
  *
  * @param Tx_MooxNews_Domain_Model_Dto_AdministrationDemand $demand
  * @param \array $sorting
  * @param \int $parent
  * @dontvalidate  $demand
  * @return void
  */
 public function indexAction(Tx_MooxNews_Domain_Model_Dto_AdministrationDemand $demand = NULL, $sorting = array(), $parent = 0)
 {
     // Extension manager configuration
     $configuration = Tx_MooxNews_Utility_EmConfiguration::getSettings();
     if (count($sorting) && ($sorting['field'] != "" || isset($sorting['mode']))) {
         if ($this->backendSession->get("administrationDemand")) {
             $demand = unserialize($this->backendSession->get("administrationDemand"));
             if (isset($sorting['mode'])) {
                 $demand->setSortingMode($sorting['mode']);
             } else {
                 $demand->setSortingField($sorting['field']);
                 $demand->setSortingDirection($sorting['direction']);
             }
         }
     }
     if (is_null($demand)) {
         if ($this->backendSession->get("administrationDemand")) {
             $demand = unserialize($this->backendSession->get("administrationDemand"));
         } else {
             $demand = $this->objectManager->get('Tx_MooxNews_Domain_Model_Dto_AdministrationDemand');
             // Preselect by TsConfig (e.g. tx_mooxnews.module.preselect.topNewsRestriction = 1)
             if (isset($this->tsConfiguration['preselect.']) && is_array($this->tsConfiguration['preselect.'])) {
                 unset($this->tsConfiguration['preselect.']['orderByAllowed']);
                 foreach ($this->tsConfiguration['preselect.'] as $propertyName => $propertyValue) {
                     \TYPO3\CMS\Extbase\Reflection\ObjectAccess::setProperty($demand, $propertyName, $propertyValue);
                 }
             }
             $this->backendSession->store("administrationDemand", serialize($demand));
         }
     } else {
         $this->backendSession->store("administrationDemand", serialize($demand));
     }
     $demand = $this->createDemandObjectFromSettings($demand);
     $folders = $this->getFolders($demand);
     $this->redirectToFolder($folders, $parent);
     $allowedTypes = array();
     if ($this->getPage() > 0) {
         $pageInfo = $this->pageRepository->getPage($this->getPage());
         if ($pageInfo['news_types'] != "") {
             $allowedTypes = explode(",", $pageInfo['news_types']);
         }
     }
     if (count($allowedTypes) > 0 && !in_array($demand->getType(), $allowedTypes)) {
         $demand->setType($allowedTypes[0]);
     }
     if ($this->settings['list']['paginate']['itemsPerPage'] > 0) {
         $demand->setPerPage($this->settings['list']['paginate']['itemsPerPage']);
     } else {
         $demand->setPerPage(20);
     }
     if (!$demand->getSortingField()) {
         $demand->setSortingField('title');
     }
     if (!$demand->getSortingDirection()) {
         $demand->setSortingDirection('ASC');
     }
     if ($this->getForceYearFilter() && $demand->getYear() < 1970) {
         $demand->setYear(date("Y"));
     }
     if ($demand->getSortingMode()) {
         $demand->setType(NULL);
         $demand->setQuery(NULL);
         $demand->setTopNewsRestriction(NULL);
         $demand->setYear(NULL);
         $demand->setSysLanguageUid(NULL);
         $demand->setOrder("sorting ASC");
     }
     if ($configuration->getCategoryRestriction() == "current_pid") {
         if ($demand->getType() != "") {
             $categories = $this->categoryRepository->findCategoriesByTypeAndPid($this->page, array($demand->getType()), $demand->getSysLanguageUid());
         } else {
             $categoryRoot = $this->getListViewCategoryRoot($demand->getType());
             if ($categoryRoot > 0) {
                 $categories = $this->categoryRepository->findCategoriesByParentAndPid($this->page, $categoryRoot, $demand->getSysLanguageUid());
             } else {
                 $categories = $this->categoryRepository->findParentCategoriesByPid($this->page, $demand->getSysLanguageUid());
             }
         }
     } else {
         if ($demand->getType() != "") {
             $categories = $this->categoryRepository->findAllCategoriesByType(array($demand->getType()), $demand->getSysLanguageUid());
         } else {
             $categoryRoot = $this->getListViewCategoryRoot($demand->getType());
             if ($categoryRoot > 0) {
                 $categories = $this->categoryRepository->findAllCategoriesByParent($categoryRoot, $demand->getSysLanguageUid());
             } else {
                 $categories = $this->categoryRepository->findAllCategories($demand->getSysLanguageUid());
             }
         }
     }
     $selectedCategories = "";
     foreach ($demand->getCategories() as $category) {
         if ($selectedCategories) {
             $selectedCategories .= ", ";
         }
         $selectedCategories .= $this->categoryRepository->findByUid($category)->getTitle();
     }
     $idList = array();
     foreach ($categories as $c) {
         $idList[] = $c->getUid();
     }
     $rootline = $this->pageRepository->getRootLine($this->page);
     foreach ($rootline as $rootlinepage) {
         if ($rootlinepage['is_siteroot']) {
             $rootpage = $rootlinepage;
             break;
         }
     }
     if (!$rootpage) {
         $rootpage = $rootline[0];
     }
     $rootfound = false;
     for ($i = 0; $i < count($rootline); $i++) {
         if ($rootfound) {
             unset($rootline[$i]);
         } else {
             if ($rootline[$i]['is_siteroot']) {
                 $rootfound = true;
             }
         }
     }
     $rootline = array_reverse($rootline);
     if (isset($rootline[count($rootline) - 2])) {
         $pageInfo = $this->pageRepository->getPage((int) $rootline[count($rootline) - 2]['uid']);
         if ($pageInfo['module'] == 'mxnews') {
             $folder = $pageInfo['uid'];
         }
     }
     $languages = $this->getLanguages();
     $years = $this->newsRepository->findAllBackendYears(false);
     $optionYears = array();
     if (!$this->getForceYearFilter()) {
         $optionYears[0] = "Alle Jahre anzeigen";
     }
     foreach ($years as $year) {
         if ($year['year'] > 1970) {
             $optionYears[$year['year']] = $year['year'] . " anzeigen";
         } else {
             $optionYears[1970] = "Artikel ohne Jahr anzeigen";
         }
     }
     if ($this->settings['defaultPreviewPid'] > 0) {
         $previewBaseUrl = self::getBaseUrl($this->settings['defaultPreviewPid']);
     }
     // Get extended fields from external extensions for backend preview
     $extendedBackendPreviewFields = array();
     foreach ($GLOBALS['TCA']['tx_mooxnews_domain_model_news']['columns'] as $fieldname => $field) {
         if ($field['addToMooxNewsBackendPreview']) {
             $field['title'] = $fieldname;
             $field['name'] = \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToLowerCamelCase($fieldname);
             $field['nameEmphasized'] = $fieldname;
             if ($field['addToMooxNewsBackendPreview']['type'] == "") {
                 $field['addToMooxNewsBackendPreview']['type'] = "text";
             }
             $extendedBackendPreviewFields[] = $field;
         }
     }
     // Get special sorting fields
     $specialSortingFields = array();
     foreach ($GLOBALS['TCA']['tx_mooxnews_domain_model_news']['columns'] as $fieldname => $field) {
         $nameParts = explode("_", $fieldname);
         if ($nameParts[count($nameParts) - 1] == "sortfield") {
             if (isset($GLOBALS['TCA']['tx_mooxnews_domain_model_news']['columns'][str_replace("_sortfield", "", $fieldname)])) {
                 $key = \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToLowerCamelCase(str_replace("_sortfield", "", $fieldname));
                 $specialSortingFields[$key] = \TYPO3\CMS\Core\Utility\GeneralUtility::underscoredToLowerCamelCase($fieldname);
             }
         }
     }
     $types = $this->getTypes($demand, $allowedTypes);
     $news = $this->newsRepository->findDemanded($demand, FALSE);
     $count = $news->count();
     if ($demand->getSortingMode()) {
         $sortHelper = array();
         $sortedUids = array();
         $sorting = array();
         for ($pos = 0; $pos < $count; $pos++) {
             $sortedUids[$pos] = $news->offsetGet($pos)->getUid();
         }
         $sortingCnt = 0;
         foreach ($sortedUids as $pos => $uid) {
             if ($sortingCnt == 0) {
                 $sortUp = 0;
             } elseif ($sortingCnt == 1) {
                 $sortUp = $this->page;
             } else {
                 $sortUp = -$sortedUids[$pos - 2];
             }
             if (isset($sortedUids[$pos + 1])) {
                 $sortDown = -$sortedUids[$pos + 1];
             } else {
                 $sortDown = 0;
             }
             $sortHelper["uid" . $uid] = array("up" => $sortUp, "down" => $sortDown);
             $sortingCnt++;
         }
     }
     $multipleFunctions = array();
     $multipleFunctions['delete'] = "Einträge löschen";
     $multipleFunctions['show'] = "Einträge aktivieren";
     $multipleFunctions['hide'] = "Einträge deaktivieren";
     if ($this->mailerActive) {
         $multipleFunctions['mailoff'] = "Markierung für Mailversand entfernen";
         $multipleFunctions['mailsingle'] = "Für Direktversand markieren";
         $multipleFunctions['mailcumulated'] = "Für kumulierten Mailversand markieren";
     }
     $assignedValues = array('page' => $this->page, 'folder' => $folder, 'years' => $optionYears, 'languages' => $languages, 'rootpage' => $rootpage, 'rootline' => $rootline, 'demand' => $demand, 'news' => $news, 'count' => $count, 'categories' => count($idList) || $configuration->getCategoryRestriction() != "current_pid" ? $this->categoryRepository->findTree($idList) : array(), 'selectedCategories' => $selectedCategories, 'dateformat' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy'], 'folders' => count($folders) > 1 ? $folders : false, 'previewBaseUrl' => $previewBaseUrl, 'extendedBackendPreviewFields' => $extendedBackendPreviewFields, 'types' => $types, 'localizeUrl' => $this->getLocalizeUrl(), 'sortingUrl' => $this->getSortingUrl(), 'parent' => $parent, 'conf' => $this->extConf, 'fields' => $this->getListViewFields($demand->getType()), 'fieldsSeparator' => self::$listViewFieldSeparator, 'replacements' => $this->getQueryReplacements($demand->getQuery()), 'allowedTypes' => $allowedTypes, 'sortHelper' => $sortHelper, 'specialSortingFields' => $specialSortingFields, 'multipleFunctions' => $multipleFunctions, 'mailerActive' => $this->mailerActive);
     $this->emitActionSignal('AdministrationController', self::SIGNAL_ADMINISTRATION_INDEX_ACTION, $assignedValues);
     $this->view->assignMultiple($assignedValues);
 }
Example #3
0
 /**
  * Output a list view of news
  *
  * @param array $overwriteDemand
  * @return void
  */
 public function listAction(array $overwriteDemand = NULL)
 {
     // Extension manager configuration
     $configuration = Tx_MooxNews_Utility_EmConfiguration::getSettings();
     $demand = $this->createDemandObjectFromSettings($this->settings);
     // get extended filter
     $extendedFilters = array();
     if (!$this->settings['hideAllFilter']) {
         $extendedFilters = $this->getExtendedFilters($demand, $overwriteDemand);
     }
     $years = array();
     if (!$this->settings['hideAllFilter'] && !$this->settings['hideYearFilter']) {
         $allyears = $this->newsRepository->findAllYears($demand->getStoragePage());
         $latestYear = 0;
         $newsWithoutDatetime = 0;
         foreach ($allyears as $year) {
             if ($year['year'] > 1970) {
                 $years[$year['year']] = $year['year'];
                 if ($year['year'] > $latestYear) {
                     $latestYear = $year['year'];
                 }
             } else {
                 $newsWithoutDatetime = 1;
             }
         }
         if ($newsWithoutDatetime) {
             $years['0'] = "Ohne Jahresangabe";
         }
         if (count($years) > 1 && !$overwriteDemand['year'] && $latestYear > 0) {
             //$overwriteDemand['year'] = $latestYear;
         }
     }
     if (($this->settings['disableOverrideDemand'] != 1 || $this->isAjaxRequest) && $overwriteDemand !== NULL) {
         $resetFields = array("type", "types", "categories", "target", "targets", "years", "year", "tag", "tags", "char");
         foreach ($resetFields as $resetField) {
             if (isset($overwriteDemand[$resetField]) && $overwriteDemand[$resetField] == "all") {
                 unset($overwriteDemand[$resetField]);
             }
         }
         foreach ($extendedFilters as $resetField) {
             if ($resetField['type'] == "select" && isset($overwriteDemand[$resetField['name']]) && $overwriteDemand[$resetField['name']] == "all") {
                 unset($overwriteDemand[$resetField['name']]);
             }
         }
         $demand = $this->overwriteDemandObject($demand, $overwriteDemand);
     }
     if (!$demand->getCategories() && !$overwriteDemand['categories'] && $this->settings['categories']) {
         $demand->setCategories($this->settings['categories']);
     }
     $newsRecords = $this->newsRepository->findDemanded($demand);
     $categories = array();
     if (!$this->settings['hideAllFilter'] && !$this->settings['hideCategoryFilter']) {
         $allcategories = $this->categoryRepository->findAllCategories();
         $selectedCategories = explode(",", $this->settings['categories']);
         foreach ($allcategories as $cat) {
             if ($this->settings['categoryConjunction'] == "") {
                 $categories[$cat->getUid()] = $cat->getTitle();
             } elseif (in_array($this->settings['categoryConjunction'], array("and", "or")) && in_array($cat->getUid(), $selectedCategories)) {
                 $categories[$cat->getUid()] = $cat->getTitle();
             } elseif (in_array($this->settings['categoryConjunction'], array("notand", "notor")) && !in_array($cat->getUid(), $selectedCategories)) {
                 $categories[$cat->getUid()] = $cat->getTitle();
             }
         }
         $idList = array();
         foreach ($allcategories as $c) {
             $idList[] = $c->getUid();
         }
     }
     $tags = array();
     if (!$this->settings['hideAllFilter'] && !$this->settings['hideTagFilter']) {
         $alltags = $this->tagRepository->findAll(FALSE);
         foreach ($alltags as $tag) {
             $tags[$tag->getUid()] = $tag->getTitle();
         }
     }
     $targets = array();
     if (!$this->settings['hideAllFilter'] && !$this->settings['hideTargetFilter']) {
         $alltargets = $this->targetRepository->findAll(FALSE);
         foreach ($alltargets as $target) {
             $targets[$target->getUid()] = $target->getTitle();
         }
     }
     $types = array();
     if (!$this->settings['hideAllFilter'] && !$this->settings['hideTypeFilter']) {
         $types = $this->getTypes();
     }
     if ($this->isAjaxRequest) {
         $allDemand = $demand;
         $allDemand->setLimit(NULL);
         $allDemand->setOffset(NULL);
         $count = $this->newsRepository->findDemanded($allDemand)->count();
         $pages = ceil($count / $this->settings['list']['paginate']['itemsPerPage']);
     } else {
         $count = $newsRecords->count();
         $pages = ceil($count / $this->settings['list']['paginate']['itemsPerPage']);
     }
     $assignedValues = array('news' => $newsRecords, 'count' => $count, 'pages' => $pages, 'years' => count($years) > 1 ? $years : NULL, 'categories' => count($categories) > 1 ? $categories : NULL, 'categoriesTree' => count($idList) || $configuration->getCategoryRestriction() != "current_pid" ? $this->categoryRepository->findTree($idList) : array(), 'tags' => count($tags) > 1 ? $tags : NULL, 'targets' => count($targets) > 1 ? $targets : NULL, 'showFilter' => count($categories) > 1 || count($types) > 1 || count($targets) > 1 || count($years) > 1 ? TRUE : FALSE, 'overwriteDemand' => $overwriteDemand, 'demand' => $demand, 'types' => count($types) > 1 ? $types : NULL, 'charList' => $this->charList, 'extendedFilters' => $extendedFilters, 'extendedFields' => $this->getExtendedFields("list"));
     if ($this->isAjaxRequest) {
         $assignedValues['settings'] = $this->settings;
     }
     $this->emitActionSignal('NewsController', self::SIGNAL_NEWS_LIST_ACTION, $assignedValues);
     $this->view->assignMultiple($assignedValues);
 }
 /**
  * Get the uid of the target, either bei inserting as new or get existing
  *
  * @param array $request ajax request
  * @return integer
  * @throws Exception
  */
 protected function getTargetUid(array $request)
 {
     // Get configuration from EM
     $configuration = Tx_MooxNews_Utility_EmConfiguration::getSettings();
     $pid = $configuration->getTargetPid();
     if ($pid === 0) {
         $pid = $this->getTargetPidFromTsConfig($request['newsid']);
     }
     if ($pid === 0) {
         throw new Exception('error_no-pid-defined');
     }
     $record = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', self::TARGET, 'deleted=0 AND pid=' . $pid . ' AND title=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($request['item'], self::TARGET));
     if (isset($record['uid'])) {
         $targetUid = $record['uid'];
     } else {
         $tcemainData = array(self::TARGET => array('NEW' => array('pid' => $pid, 'title' => $request['item'])));
         /** @var \TYPO3\CMS\Core\DataHandling\DataHandler $tce */
         $tce = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\DataHandling\\DataHandler');
         $tce->start($tcemainData, array());
         $tce->process_datamap();
         $targetUid = $tce->substNEWwithIDs['NEW'];
     }
     if ($targetUid == 0) {
         throw new Exception('error_no-target-created');
     }
     return $targetUid;
 }
 /**
  * Test if configuration model is correctly returned
  *
  * @test
  * @dataProvider extensionManagerConfigurationIsCorrectlyReturnedDataProvider
  * @return void
  */
 public function extensionManagerConfigurationIsCorrectlyReturned($expectedFields, $expected)
 {
     $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['moox_news'] = $expectedFields;
     $this->assertEquals($expected, Tx_MooxNews_Utility_EmConfiguration::getSettings());
 }
 /**
  * Constructor
  */
 public function __construct()
 {
     $this->emSettings = Tx_MooxNews_Utility_EmConfiguration::getSettings();
 }
 /**
  * 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', Tx_MooxNews_Utility_EmConfiguration::getSettings());
 }
Example #8
0
    /**
     * generate category selection form
     *
     * @param array $PA
     * @param array $fobj
     * @return string $tcaForm
     */
    function generateTcaCategoriesField(&$PA, &$fobj)
    {
        $options = array();
        $uids = array();
        $values = explode(",", $PA['itemFormElValue']);
        foreach ($values as $value) {
            $value = explode("|", $value);
            if ($value[1] != "") {
                $options[] = array("value" => $value[0], "label" => $value[1]);
                $uids[] = $value[0];
            }
        }
        $configuration = Tx_MooxNews_Utility_EmConfiguration::getSettings();
        $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
        $categoryRepository = $objectManager->get('Tx_MooxNews_Domain_Repository_CategoryRepository');
        $backendSession = $objectManager->get('DCNGmbH\\MooxNews\\Service\\BackendSessionService');
        $pageUid = $backendSession->get("id");
        $demand = unserialize($backendSession->get("administrationDemand"));
        if (!is_object($demand)) {
            $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
            $demand = $objectManager->get('Tx_MooxNews_Domain_Model_Dto_AdministrationDemand');
            $demand->setType($PA['row']['type']);
        } elseif ($demand->getType() != '' && $demand->getType() != $PA['row']['type']) {
            $demand->setType($PA['row']['type']);
            $backendSession->store("administrationDemand", serialize($demand));
        }
        $demand->setType($PA['row']['type']);
        if ($configuration->getCategoryRestriction() == "current_pid") {
            if ($demand->getType() != "") {
                $categories = $categoryRepository->findCategoriesByTypeAndPid($pageUid, array($demand->getType()), $demand->getSysLanguageUid());
            } else {
                $categories = $categoryRepository->findParentCategoriesByPid($pageUid, $demand->getSysLanguageUid());
            }
        } else {
            if ($demand->getType() != "") {
                $categories = $categoryRepository->findAllCategoriesByType(array($demand->getType()), $demand->getSysLanguageUid());
            } else {
                $categories = $categoryRepository->findAllCategories($demand->getSysLanguageUid());
            }
        }
        $idList = array();
        foreach ($categories as $c) {
            $idList[] = $c->getUid();
        }
        $categories = count($idList) || $configuration->getCategoryRestriction() != "current_pid" ? $categoryRepository->findTree($idList) : array();
        $fobj->additionalCode_pre[] = '
				<link rel="stylesheet" type="text/css" href="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('moox_news') . 'Resources/Public/Css/tca_category.css" />';
        $fobj->additionalCode_pre[] = '
				<script src="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('moox_news') . 'Resources/Public/JavaScript/tca_category.js" type="text/javascript"></script>';
        $code .= '<div class="moox-news-tca">';
        $code .= '<div class="moox-news-tca-category-display-wrapper">';
        $code .= '<div class="moox-news-tca-category-display-header">Kategorie-Sortierung</div>';
        $code .= '<select id="' . md5($PA['itemFormElName']) . '_list" size="10" class="formField tceforms-multiselect moox-news-tca-category-display" multiple="multiple" name="' . $PA['itemFormElName'] . '_list"';
        $code .= ' onchange="' . htmlspecialchars(implode('', $PA['fieldChangeFunc'])) . '"';
        $code .= $PA['onFocus'];
        $code .= '>';
        $optionCnt = 1;
        foreach ($options as $option) {
            if ($optionCnt == 1) {
                $code .= '<option value="' . $option['value'] . '">' . self::getCategoryLabel($option['value']) . ' (Hauptkategorie)</option>';
            } else {
                $code .= '<option value="' . $option['value'] . '">' . self::getCategoryLabel($option['value']) . '</option>';
            }
            $optionCnt++;
        }
        $code .= '</select>';
        $code .= '<input type="hidden" id="moox-news-tca-category-hidden" name="' . $PA['itemFormElName'] . '" value="' . implode(",", $uids) . '">';
        $code .= '<input type="hidden" id="moox-news-tca-category-max" name="moox-news-tca-category-max" value="' . $PA['fieldConf']['config']['maxitems'] . '">';
        if ($PA['fieldConf']['config']['minitems'] > 0) {
            $code .= '<input type="hidden" id="moox-news-tca-category-min" name="moox-news-tca-category-min" value="' . $PA['fieldConf']['config']['minitems'] . '">';
        }
        $code .= '<div class="moox-news-tca-category-display-footer">';
        if ($PA['fieldConf']['config']['maxitems'] > 0) {
            $code .= '(<span id="moox-news-tca-category-cnt">' . count($options) . '</span> von ' . ($PA['fieldConf']['config']['maxitems'] != 9999 ? $PA['fieldConf']['config']['maxitems'] : "unbegrenzt") . ' möglichen Kategorien gewählt)';
        }
        $code .= '</div>';
        $code .= '</div>';
        $code .= '<div class="moox-news-tca-category-actions">';
        $code .= '<div class="moox-news-tca-category-actions-icon"><span onclick="mooxNewsMoveOptionsToTop(\'#' . md5($PA['itemFormElName']) . '\')" class="t3-icon t3-icon-actions t3-icon-actions-move t3-icon-move-to-top t3-btn t3-btn-moveoption-top" title="Ausgewählte Objekte zum Anfang verschieben">&nbsp;</span></div>';
        $code .= '<div class="moox-news-tca-category-actions-icon"><span onclick="mooxNewsMoveOptionsOneUp(\'#' . md5($PA['itemFormElName']) . '\')" class="t3-icon t3-icon-actions t3-icon-actions-move t3-icon-move-up t3-btn t3-btn-moveoption-up" title="Ausgewählte Objekte nach oben verschieben">&nbsp;</span></div>';
        $code .= '<div class="moox-news-tca-category-actions-icon"><span onclick="mooxNewsMoveOptionsOneDown(\'#' . md5($PA['itemFormElName']) . '\')" class="t3-icon t3-icon-actions t3-icon-actions-move t3-icon-move-down t3-btn t3-btn-moveoption-down" title="Ausgewählte Objekte nach unten verschieben">&nbsp;</span></div>';
        $code .= '<div class="moox-news-tca-category-actions-icon"><span onclick="mooxNewsMoveOptionsToBottom(\'#' . md5($PA['itemFormElName']) . '\')" class="t3-icon t3-icon-actions t3-icon-actions-move t3-icon-move-to-bottom t3-btn t3-btn-moveoption-bottom" title="Ausgewählte Objekte zum Ende verschieben">&nbsp;</span></div>';
        $code .= '<div class="moox-news-tca-category-actions-icon"><span onclick="mooxNewsRemoveOptions(\'#' . md5($PA['itemFormElName']) . '\')" class="t3-icon t3-icon-actions t3-icon-actions-selection t3-icon-selection-delete t3-btn t3-btn-removeoption" title="Ausgewähltes Objekt löschen">&nbsp;</span></div>';
        $code .= '<div class="moox-news-tca-category-actions-icon"><span onclick="mooxNewsSetMainCategory(\'#' . md5($PA['itemFormElName']) . '\')" class="t3-icon t3-icon-apps t3-icon-apps-toolbar t3-icon-toolbar-menu-shortcut" title="Ausgewähltes Objekt löschen">&nbsp;</span></div>';
        $code .= '</div>';
        $code .= '<div class="moox-news-tca-category-selector-wrapper">';
        $code .= '<div class="moox-news-tca-category-selector-header">Kategorie-Auswahl</div>';
        $code .= '<div class="moox-news-tca-category-selector">';
        $code .= self::generateCategorySelectionTree(md5($PA['itemFormElName']), $demand, $categories, $uids);
        $code .= '</div>';
        $code .= '<div class="moox-news-tca-category-selector-footer">';
        $code .= '<span onclick="mooxNewsAddAllOptions(\'#' . md5($PA['itemFormElName']) . '\')" class="moox-news-icon icon-select-all">Alle auswählen</span>';
        $code .= '<span onclick="mooxNewsRemoveAllOptions(\'#' . md5($PA['itemFormElName']) . '\')" class="moox-news-icon icon-unselect-all">Alle abwählen</span>';
        $code .= '</div>';
        $code .= '</div>';
        $code .= '</div>';
        return $code;
    }