コード例 #1
0
ファイル: FlashMessagePipe.php プロジェクト: kersten/flux
 /**
  * @param array $data
  * @return mixed
  */
 public function conduct($data)
 {
     $queue = new FlashMessageQueue(self::FLASHMESSAGE_QUEUE);
     $flashMessage = new FlashMessage($this->getMessage(), $this->getTitle(), $this->getSeverity(), $this->getStoreInSession());
     $queue->enqueue($flashMessage);
     return $data;
 }
 public function tearDown()
 {
     $this->fixture->__destruct();
     unset($this->fixture);
     \TYPO3\CMS\Core\Messaging\FlashMessageQueue::getAllMessagesAndFlush();
     $_SESSION = $this->sessionBackup;
 }
コード例 #3
0
 /**
  * Example Command Controller
  * @return void
  */
 public function exampleCommand()
 {
     // Do stuff here!
     if (TYPO3_MODE == 'BE') {
         $message = $this->objectManager->get('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', 'Now go make something cool.', 'Awesome', \TYPO3\CMS\Core\Messaging\FlashMessage::OK);
         \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($message);
     }
 }
コード例 #4
0
 /**
  * @test
  */
 public function getAllMessagesAndFlushClearsSessionStack()
 {
     $flashMessage = new \TYPO3\CMS\Core\Messaging\FlashMessage('Transient', 'Title', \TYPO3\CMS\Core\Messaging\FlashMessage::OK, TRUE);
     $this->flashMessageQueue->enqueue($flashMessage);
     $this->flashMessageQueue->getAllMessagesAndFlush();
     /** @var $frontendUser \TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication */
     $frontendUser = $this->flashMessageQueue->_call('getUserByContext');
     $this->assertNull($frontendUser->getSessionData('core.template.flashMessages'));
 }
コード例 #5
0
 public function setUp()
 {
     $this->blobRestProxy = $this->prophesize(BlobRestProxy::class);
     $this->flashMessageQueue = $this->prophesize(FlashMessageQueue::class);
     $this->flashMessageService = $this->prophesize(FlashMessageService::class);
     $this->storageDriver = new BlobStorageDriver(['containerName' => 'mycontainer', 'accountKey' => '123', 'accountName' => 'foo', 'defaultEndpointsProtocol' => 'http']);
     $this->storageDriver->setMessageQueueByIdentifier($this->flashMessageQueue->reveal());
     $this->storageDriver->setFlashMessageService($this->flashMessageService->reveal());
     $this->storageDriver->initialize($this->blobRestProxy->reveal());
     // file stuff
     vfsStreamWrapper::register();
     $root = new vfsStreamDirectory('exampleDir');
     vfsStreamWrapper::setRoot($root);
     $this->testFile = vfsStream::newFile('test.txt')->at($root)->setContent($this->testContent);
     $this->emptyTestFile = vfsStream::newFile('test2.txt')->at($root)->setContent('');
     $this->testFilePath = vfsStream::url('exampleDir/test.txt');
     $this->emptyTestFilePath = vfsStream::url('exampleDir/test2.txt');
 }
コード例 #6
0
 /**
  * @throws \Exception
  * @return boolean
  */
 public function execute()
 {
     $this->init();
     /** @var MigrateRelations $migrateRelationsService */
     $migrateRelationsService = $this->objectManager->get('TYPO3\\CMS\\DamFalmigration\\Service\\MigrateRelations');
     $message = $migrateRelationsService->execute();
     FlashMessageQueue::addMessage($message);
     return $message->getSeverity() === FlashMessage::OK;
 }
コード例 #7
0
 /**
  * @test
  */
 public function getMessagesAndFlushCanAlsoFilterBySeverity()
 {
     $messages = array(0 => new \TYPO3\CMS\Core\Messaging\FlashMessage('This is a test message', 1, \TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE), 1 => new \TYPO3\CMS\Core\Messaging\FlashMessage('This is another test message', 2, \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING));
     $this->flashMessageQueue->enqueue($messages[0]);
     $this->flashMessageQueue->enqueue($messages[1]);
     $filteredFlashMessages = $this->flashMessageQueue->getAllMessagesAndFlush(\TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE);
     $this->assertEquals(count($filteredFlashMessages), 1);
     reset($filteredFlashMessages);
     $flashMessage = current($filteredFlashMessages);
     $this->assertEquals($messages[0], $flashMessage);
     $this->assertEquals(array(), $this->flashMessageQueue->getAllMessages(\TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE));
     $this->assertEquals(array($messages[1]), array_values($this->flashMessageQueue->getAllMessages()));
 }
コード例 #8
0
 /**
  * @return boolean
  * @throws \Exception
  */
 public function execute()
 {
     try {
         $flashMessage = GeneralUtility::makeInstance('t3lib_FlashMessage', 'This Task is created for testing purposes, it creates some test files and log entries in the application log', '', FlashMessage::WARNING, true);
         FlashMessageQueue::addMessage($flashMessage);
         $executeTestFilePath = Files::concatenatePaths(array($this->testPath, 'testTaskExecution.txt'));
         file_put_contents($executeTestFilePath, '1428924570');
         return true;
     } catch (\Exception $e) {
         $this->logger->error(sprintf('%s (%s)', $e->getMessage(), $e->getCode()));
         throw $e;
     }
 }
コード例 #9
0
 /**
  * UserFunc function for rendering field "is_public".
  * There are some edge cases where "is_public" can never be marked as true in the BE,
  * for instance for storage located outside the document root or
  * for storages driven by special driver such as Flickr, ...
  *
  * @param array $propertyArray the array with additional configuration options.
  * @param \TYPO3\CMS\Backend\Form\FormEngine $tceformsObj the TCEforms parent object
  * @return string
  */
 public function renderIsPublic(array $propertyArray, \TYPO3\CMS\Backend\Form\FormEngine $tceformsObj)
 {
     $isPublic = $GLOBALS['TCA']['sys_file_storage']['columns']['is_public']['config']['default'];
     $fileRecord = $propertyArray['row'];
     // Makes sure the storage object can be retrieved which is not the case when new storage.
     if ((int) $propertyArray['row']['uid'] > 0) {
         $storage = ResourceFactory::getInstance()->getStorageObject($fileRecord['uid']);
         $storageRecord = $storage->getStorageRecord();
         $isPublic = $storage->isPublic() && $storageRecord['is_public'];
         // Display a warning to the BE User in case settings is not inline with storage capability.
         if ($storageRecord['is_public'] && !$storage->isPublic()) {
             $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.message.storage_is_no_public'), $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.header.storage_is_no_public'), \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING);
             \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($message);
         }
     }
     return $this->renderFileInformationContent($fileRecord, $isPublic);
 }
コード例 #10
0
ファイル: InstallService.php プロジェクト: woehrlag/Intranet
 /**
  * Creates .htaccess file inside the root directory
  *
  * @param string $htaccessFile Path of .htaccess file
  * @return void
  */
 public function createDefaultHtaccessFile()
 {
     $htaccessFile = GeneralUtility::getFileAbsFileName(".htaccess");
     if (file_exists($htaccessFile)) {
         /**
          * Add Flashmessage that there is already an .htaccess file and we are not going to override this.
          */
         $message = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', 'There is already an Apache .htaccess file in the root directory, please make sure that the url rewritings are set properly.<br>' . 'An example configuration is located at: <strong>typo3conf/ext/bootstrap_package/Configuration/Apache/.htaccess</strong>', 'Apache .htaccess file already exists', FlashMessage::NOTICE, TRUE);
         FlashMessageQueue::addMessage($message);
         return;
     }
     $htaccessContent = GeneralUtility::getUrl(ExtensionManagementUtility::extPath($this->extKey) . '/Configuration/Apache/.htaccess');
     GeneralUtility::writeFile($htaccessFile, $htaccessContent, TRUE);
     /**
      * Add Flashmessage that the example htaccess file was placed in the root directory
      */
     $message = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', 'For RealURL and optimization purposes an example .htaccess file was placed in your root directory. <br>' . ' Please check if the RewriteBase correctly set for your environment. ', 'Apache example .htaccess was placed in the root directory.', FlashMessage::OK, TRUE);
     FlashMessageQueue::addMessage($message);
 }
コード例 #11
0
    /**
     * Creates the listing of records from a single table
     *
     * @param string $table Table name
     * @param integer $id Page id
     * @param string $rowlist List of fields to show in the listing. Pseudo fields will be added including the record header.
     * @return string HTML table with the listing for the record.
     * @todo Define visibility
     */
    public function getTable($table, $id, $rowlist)
    {
        // Loading all TCA details for this table:
        \TYPO3\CMS\Core\Utility\GeneralUtility::loadTCA($table);
        // Init
        $addWhere = '';
        $titleCol = $GLOBALS['TCA'][$table]['ctrl']['label'];
        $thumbsCol = $GLOBALS['TCA'][$table]['ctrl']['thumbnail'];
        $l10nEnabled = $GLOBALS['TCA'][$table]['ctrl']['languageField'] && $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] && !$GLOBALS['TCA'][$table]['ctrl']['transOrigPointerTable'];
        $tableCollapsed = !$this->tablesCollapsed[$table] ? FALSE : TRUE;
        // prepare space icon
        $this->spaceIcon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('empty-empty', array('style' => 'background-position: 0 10px;'));
        // Cleaning rowlist for duplicates and place the $titleCol as the first column always!
        $this->fieldArray = array();
        // title Column
        // Add title column
        $this->fieldArray[] = $titleCol;
        // Control-Panel
        if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList($rowlist, '_CONTROL_')) {
            $this->fieldArray[] = '_CONTROL_';
            $this->fieldArray[] = '_AFTERCONTROL_';
        }
        // Clipboard
        if ($this->showClipboard) {
            $this->fieldArray[] = '_CLIPBOARD_';
        }
        // Ref
        if (!$this->dontShowClipControlPanels) {
            $this->fieldArray[] = '_REF_';
            $this->fieldArray[] = '_AFTERREF_';
        }
        // Path
        if ($this->searchLevels) {
            $this->fieldArray[] = '_PATH_';
        }
        // Localization
        if ($this->localizationView && $l10nEnabled) {
            $this->fieldArray[] = '_LOCALIZATION_';
            $this->fieldArray[] = '_LOCALIZATION_b';
            $addWhere .= ' AND (
				' . $GLOBALS['TCA'][$table]['ctrl']['languageField'] . '<=0
				OR
				' . $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] . ' = 0
			)';
        }
        // Cleaning up:
        $this->fieldArray = array_unique(array_merge($this->fieldArray, \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $rowlist, 1)));
        if ($this->noControlPanels) {
            $tempArray = array_flip($this->fieldArray);
            unset($tempArray['_CONTROL_']);
            unset($tempArray['_CLIPBOARD_']);
            $this->fieldArray = array_keys($tempArray);
        }
        // Creating the list of fields to include in the SQL query:
        $selectFields = $this->fieldArray;
        $selectFields[] = 'uid';
        $selectFields[] = 'pid';
        // adding column for thumbnails
        if ($thumbsCol) {
            $selectFields[] = $thumbsCol;
        }
        if ($table == 'pages') {
            if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms')) {
                $selectFields[] = 'module';
                $selectFields[] = 'extendToSubpages';
                $selectFields[] = 'nav_hide';
            }
            $selectFields[] = 'doktype';
        }
        if (is_array($GLOBALS['TCA'][$table]['ctrl']['enablecolumns'])) {
            $selectFields = array_merge($selectFields, $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']);
        }
        if ($GLOBALS['TCA'][$table]['ctrl']['type']) {
            $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['type'];
        }
        if ($GLOBALS['TCA'][$table]['ctrl']['typeicon_column']) {
            $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['typeicon_column'];
        }
        if ($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
            $selectFields[] = 't3ver_id';
            $selectFields[] = 't3ver_state';
            $selectFields[] = 't3ver_wsid';
        }
        if ($l10nEnabled) {
            $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['languageField'];
            $selectFields[] = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
        }
        if ($GLOBALS['TCA'][$table]['ctrl']['label_alt']) {
            $selectFields = array_merge($selectFields, \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $GLOBALS['TCA'][$table]['ctrl']['label_alt'], 1));
        }
        // Unique list!
        $selectFields = array_unique($selectFields);
        $fieldListFields = $this->makeFieldList($table, 1);
        if (empty($fieldListFields) && $GLOBALS['TYPO3_CONF_VARS']['BE']['debug']) {
            $message = sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.php:missingTcaColumnsMessage', TRUE), $table, $table);
            $messageTitle = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.php:missingTcaColumnsMessageTitle', TRUE);
            $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $message, $messageTitle, \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING, TRUE);
            /** @var \TYPO3\CMS\Core\Messaging\FlashMessage $flashMessage */
            \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($flashMessage);
        }
        // Making sure that the fields in the field-list ARE in the field-list from TCA!
        $selectFields = array_intersect($selectFields, $fieldListFields);
        // Implode it into a list of fields for the SQL-statement.
        $selFieldList = implode(',', $selectFields);
        $this->selFieldList = $selFieldList;
        /**
         * @hook DB-List getTable
         * @date 2007-11-16
         * @request Malte Jansen <*****@*****.**>
         */
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.db_list_extra.inc']['getTable'] as $classData) {
                $hookObject = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classData);
                if (!$hookObject instanceof \TYPO3\CMS\Backend\RecordList\RecordListGetTableHookInterface) {
                    throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Backend\\RecordList\\RecordListGetTableHookInterface', 1195114460);
                }
                $hookObject->getDBlistQuery($table, $id, $addWhere, $selFieldList, $this);
            }
        }
        // Create the SQL query for selecting the elements in the listing:
        // do not do paging when outputting as CSV
        if ($this->csvOutput) {
            $this->iLimit = 0;
        }
        if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
            // Get the two previous rows for sorting if displaying page > 1
            $this->firstElementNumber = $this->firstElementNumber - 2;
            $this->iLimit = $this->iLimit + 2;
            // (API function from class.db_list.inc)
            $queryParts = $this->makeQueryArray($table, $id, $addWhere, $selFieldList);
            $this->firstElementNumber = $this->firstElementNumber + 2;
            $this->iLimit = $this->iLimit - 2;
        } else {
            // (API function from class.db_list.inc)
            $queryParts = $this->makeQueryArray($table, $id, $addWhere, $selFieldList);
        }
        // Finding the total amount of records on the page (API function from class.db_list.inc)
        $this->setTotalItems($queryParts);
        // Init:
        $dbCount = 0;
        $out = '';
        $listOnlyInSingleTableMode = $this->listOnlyInSingleTableMode && !$this->table;
        // If the count query returned any number of records, we perform the real query, selecting records.
        if ($this->totalItems) {
            // Fetch records only if not in single table mode or if in multi table mode and not collapsed
            if ($listOnlyInSingleTableMode || !$this->table && $tableCollapsed) {
                $dbCount = $this->totalItems;
            } else {
                // Set the showLimit to the number of records when outputting as CSV
                if ($this->csvOutput) {
                    $this->showLimit = $this->totalItems;
                    $this->iLimit = $this->totalItems;
                }
                $result = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
                $dbCount = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
            }
        }
        // If any records was selected, render the list:
        if ($dbCount) {
            // Half line is drawn between tables:
            if (!$listOnlyInSingleTableMode) {
                $theData = array();
                if (!$this->table && !$rowlist) {
                    $theData[$titleCol] = '<img src="clear.gif" width="' . ($GLOBALS['SOBE']->MOD_SETTINGS['bigControlPanel'] ? '230' : '350') . '" height="1" alt="" />';
                    if (in_array('_CONTROL_', $this->fieldArray)) {
                        $theData['_CONTROL_'] = '';
                    }
                    if (in_array('_CLIPBOARD_', $this->fieldArray)) {
                        $theData['_CLIPBOARD_'] = '';
                    }
                }
                $out .= $this->addelement(0, '', $theData, 'class="c-table-row-spacer"', $this->leftMargin);
            }
            $tableTitle = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$table]['ctrl']['title'], TRUE);
            if ($tableTitle === '') {
                $tableTitle = $table;
            }
            // Header line is drawn
            $theData = array();
            if ($this->disableSingleTableView) {
                $theData[$titleCol] = '<span class="c-table">' . \TYPO3\CMS\Backend\Utility\BackendUtility::wrapInHelp($table, '', $tableTitle) . '</span> (' . $this->totalItems . ')';
            } else {
                $theData[$titleCol] = $this->linkWrapTable($table, '<span class="c-table">' . $tableTitle . '</span> (' . $this->totalItems . ') ' . ($this->table ? \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-view-table-collapse', array('title' => $GLOBALS['LANG']->getLL('contractView', TRUE))) : \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-view-table-expand', array('title' => $GLOBALS['LANG']->getLL('expandView', TRUE)))));
            }
            if ($listOnlyInSingleTableMode) {
                $out .= '
					<tr>
						<td class="t3-row-header" style="width:95%;">' . \TYPO3\CMS\Backend\Utility\BackendUtility::wrapInHelp($table, '', $theData[$titleCol]) . '</td>
					</tr>';
            } else {
                // Render collapse button if in multi table mode
                $collapseIcon = '';
                if (!$this->table) {
                    $collapseIcon = '<a href="' . htmlspecialchars($this->listURL() . '&collapse[' . $table . ']=' . ($tableCollapsed ? '0' : '1')) . '" title="' . ($tableCollapsed ? $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.expandTable', TRUE) : $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.collapseTable', TRUE)) . '">' . ($tableCollapsed ? \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-view-list-expand', array('class' => 'collapseIcon')) : \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIcon('actions-view-list-collapse', array('class' => 'collapseIcon'))) . '</a>';
                }
                $out .= $this->addElement(1, $collapseIcon, $theData, ' class="t3-row-header"', '');
            }
            // Render table rows only if in multi table view and not collapsed or if in single table view
            if (!$listOnlyInSingleTableMode && (!$tableCollapsed || $this->table)) {
                // Fixing a order table for sortby tables
                $this->currentTable = array();
                $currentIdList = array();
                $doSort = $GLOBALS['TCA'][$table]['ctrl']['sortby'] && !$this->sortField;
                $prevUid = 0;
                $prevPrevUid = 0;
                // Get first two rows and initialize prevPrevUid and prevUid if on page > 1
                if ($this->firstElementNumber > 2 && $this->iLimit > 0) {
                    $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
                    $prevPrevUid = -(int) $row['uid'];
                    $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
                    $prevUid = $row['uid'];
                }
                $accRows = array();
                // Accumulate rows here
                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
                    if (!$this->isRowListingConditionFulfilled($table, $row)) {
                        continue;
                    }
                    // In offline workspace, look for alternative record:
                    \TYPO3\CMS\Backend\Utility\BackendUtility::workspaceOL($table, $row, $GLOBALS['BE_USER']->workspace, TRUE);
                    if (is_array($row)) {
                        $accRows[] = $row;
                        $currentIdList[] = $row['uid'];
                        if ($doSort) {
                            if ($prevUid) {
                                $this->currentTable['prev'][$row['uid']] = $prevPrevUid;
                                $this->currentTable['next'][$prevUid] = '-' . $row['uid'];
                                $this->currentTable['prevUid'][$row['uid']] = $prevUid;
                            }
                            $prevPrevUid = isset($this->currentTable['prev'][$row['uid']]) ? -$prevUid : $row['pid'];
                            $prevUid = $row['uid'];
                        }
                    }
                }
                $GLOBALS['TYPO3_DB']->sql_free_result($result);
                $this->totalRowCount = count($accRows);
                // CSV initiated
                if ($this->csvOutput) {
                    $this->initCSV();
                }
                // Render items:
                $this->CBnames = array();
                $this->duplicateStack = array();
                $this->eCounter = $this->firstElementNumber;
                $iOut = '';
                $cc = 0;
                foreach ($accRows as $row) {
                    // Render item row if counter < limit
                    if ($cc < $this->iLimit) {
                        $cc++;
                        $this->translations = FALSE;
                        $iOut .= $this->renderListRow($table, $row, $cc, $titleCol, $thumbsCol);
                        // If localization view is enabled it means that the selected records are
                        // either default or All language and here we will not select translations
                        // which point to the main record:
                        if ($this->localizationView && $l10nEnabled) {
                            // For each available translation, render the record:
                            if (is_array($this->translations)) {
                                foreach ($this->translations as $lRow) {
                                    // $lRow isn't always what we want - if record was moved we've to work with the
                                    // placeholder records otherwise the list is messed up a bit
                                    if ($row['_MOVE_PLH_uid'] && $row['_MOVE_PLH_pid']) {
                                        $tmpRow = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordRaw($table, 't3ver_move_id="' . intval($lRow['uid']) . '" AND pid="' . $row['_MOVE_PLH_pid'] . '" AND t3ver_wsid=' . $row['t3ver_wsid'] . \t3lib_beFunc::deleteClause($table), $selFieldList);
                                        $lRow = is_array($tmpRow) ? $tmpRow : $lRow;
                                    }
                                    // In offline workspace, look for alternative record:
                                    \TYPO3\CMS\Backend\Utility\BackendUtility::workspaceOL($table, $lRow, $GLOBALS['BE_USER']->workspace, TRUE);
                                    if (is_array($lRow) && $GLOBALS['BE_USER']->checkLanguageAccess($lRow[$GLOBALS['TCA'][$table]['ctrl']['languageField']])) {
                                        $currentIdList[] = $lRow['uid'];
                                        $iOut .= $this->renderListRow($table, $lRow, $cc, $titleCol, $thumbsCol, 18);
                                    }
                                }
                            }
                        }
                    }
                    // Counter of total rows incremented:
                    $this->eCounter++;
                }
                // Record navigation is added to the beginning and end of the table if in single table mode
                if ($this->table) {
                    $iOut = $this->renderListNavigation('top') . $iOut . $this->renderListNavigation('bottom');
                } else {
                    // Show that there are more records than shown
                    if ($this->totalItems > $this->itemsLimitPerTable) {
                        $countOnFirstPage = $this->totalItems > $this->itemsLimitSingleTable ? $this->itemsLimitSingleTable : $this->totalItems;
                        $hasMore = $this->totalItems > $this->itemsLimitSingleTable;
                        $iOut .= '<tr><td colspan="' . count($this->fieldArray) . '" style="padding:5px;">
								<a href="' . htmlspecialchars($this->listURL() . '&table=' . rawurlencode($table)) . '">' . '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($this->backPath, 'gfx/pildown.gif', 'width="14" height="14"') . ' alt="" />' . ' <i>[1 - ' . $countOnFirstPage . ($hasMore ? '+' : '') . ']</i></a>
								</td></tr>';
                    }
                }
                // The header row for the table is now created:
                $out .= $this->renderListHeader($table, $currentIdList);
            }
            // The list of records is added after the header:
            $out .= $iOut;
            unset($iOut);
            // ... and it is all wrapped in a table:
            $out = '



			<!--
				DB listing of elements:	"' . htmlspecialchars($table) . '"
			-->
				<table border="0" cellpadding="0" cellspacing="0" class="typo3-dblist' . ($listOnlyInSingleTableMode ? ' typo3-dblist-overview' : '') . '">
					' . $out . '
				</table>';
            // Output csv if...
            // This ends the page with exit.
            if ($this->csvOutput) {
                $this->outputCSV($table);
            }
        }
        // Return content:
        return $out;
    }
コード例 #12
0
 /**
  * @param LanguageService $languageService
  * @param FlashMessageQueue $messageQueue
  * @param bool $isAjaxCall
  * @internal Only public to be used in tests
  * @return \Closure
  */
 public static function getMessageClosure(LanguageService $languageService, FlashMessageQueue $messageQueue, $isAjaxCall)
 {
     return function () use($languageService, $messageQueue, $isAjaxCall) {
         /** @var \TYPO3\CMS\Core\Messaging\FlashMessage $flashMessage */
         $flashMessage = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessage::class, $languageService->sL('LLL:EXT:lang/locallang_core.xlf:error.formProtection.tokenInvalid'), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, !$isAjaxCall);
         $messageQueue->enqueue($flashMessage);
     };
 }
コード例 #13
0
 /**
  * action show
  *
  * @param \Woehrl\WoehrlFilialsuche\Domain\Model\Filiale $filiale
  * @return void
  */
 public function showAction(\Woehrl\WoehrlFilialsuche\Domain\Model\Filiale $filiale)
 {
     $plz = $filiale->getPlz();
     $radius = $filiale->getRadius();
     if ($plz) {
         //$filiale->modehaeuser = $this->ogdbRadius($filiale->getPlz(), $radius);
         $filiale->modehaeuser = ogdbRadius($filiale->getPlz(), $radius);
         //\TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($filiale, 'filiales');
         $lat_pos = NULL;
         $lon_pos = NULL;
         foreach ($filiale->modehaeuser as $modehaus) {
             if (empty($lat_pos) and empty($lon_pos)) {
                 $lat_pos = $modehaus['lat_pos'];
                 $lon_pos = $modehaus['lon_pos'];
             }
             $distanceArray[] = $modehaus['distance'];
         }
         // \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($distanceArray, 'filiales');
         if ($distanceArray) {
             $distanceDiff = max($distanceArray) - min($distanceArray);
             if ($distanceDiff < 10) {
                 $zoom = 15;
             } elseif ($distanceDiff > 10 and $distanceDiff < 50) {
                 $zoom = 10;
             } else {
                 $zoom = 8;
             }
             $filiale->zoom = $zoom;
             $filiale->lat_pos = $lat_pos;
             $filiale->lon_pos = $lon_pos;
         } else {
             $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', 'Leider wurde keine Filiale zu Ihren Sucheingaben gefunden.', 'Ooops!', \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING, TRUE);
             // $this->flashMessageContainer->add('Leider wurde keine Filiale zu Ihren Sucheingaben gefunden.');
             \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($message);
             $this->view->assign('filiale', $filiale);
             $this->redirect('list');
             //$this->redirect('list', NULL,NULL ,array('notfound'=>1));
         }
     } else {
         $filiale->modehaeuser = 2;
     }
     $this->view->assign('filiale', $filiale);
 }
コード例 #14
0
 /**
  * Deleting files and folders (action=4)
  *
  * @param array $cmds $cmds['data'] is the file/folder to delete
  * @return boolean Returns TRUE upon success
  * @todo Define visibility
  */
 public function func_delete($cmds)
 {
     $result = FALSE;
     if (!$this->isInit) {
         return $result;
     }
     // Example indentifier for $cmds['data'] => "4:mypath/tomyfolder/myfile.jpg"
     // for backwards compatibility: the combined file identifier was the path+filename
     $fileObject = $this->getFileObject($cmds['data']);
     // @todo implement the recycler feature which has been removed from the original implementation
     // checks to delete the file
     if ($fileObject instanceof \TYPO3\CMS\Core\Resource\File) {
         $refIndexRecords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_refindex', 'deleted=0 AND ref_table="sys_file" AND ref_uid=' . intval($fileObject->getUid()));
         // check if the file still has references
         if (count($refIndexRecords) > 0) {
             $shortcutContent = array();
             foreach ($refIndexRecords as $row) {
                 $shortcutRecord = NULL;
                 $shortcutRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($row['tablename'], $row['recuid']);
                 if (is_array($shortcutRecord) && $row['tablename'] !== 'sys_file_reference') {
                     $icon = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($row['tablename'], $shortcutRecord);
                     $onClick = 'showClickmenu("' . $row['tablename'] . '", "' . $row['recuid'] . '", "1", "+info,history,edit,delete", "|", "");return false;';
                     $shortcutContent[] = '<a href="#" oncontextmenu="' . htmlspecialchars($onClick) . '" onclick="' . htmlspecialchars($onClick) . '">' . $icon . '</a>' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($row['tablename'], $shortcutRecord) . '  [' . \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordPath($shortcutRecord['pid'], '', 80) . ']');
                 }
             }
             $out = '<p>The file cannot be deleted since it is still used at the following places:<br />' . implode('<br />', $shortcutContent) . '</p>';
             $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_flashMessage', $out, 'File not deleted', \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING, TRUE);
             \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($flashMessage);
             return;
         } else {
             try {
                 $result = $fileObject->delete();
             } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException $e) {
                 $this->writelog(4, 1, 112, 'You are not allowed to access the file', array($fileObject->getIdentifier()));
             } catch (\TYPO3\CMS\Core\Resource\Exception\NotInMountPointException $e) {
                 $this->writelog(4, 1, 111, 'Target was not within your mountpoints! T="%s"', array($fileObject->getIdentifier()));
             } catch (\RuntimeException $e) {
                 $this->writelog(4, 1, 110, 'Could not delete file "%s". Write-permission problem?', array($fileObject->getIdentifier()));
             }
             // Log success
             $this->writelog(4, 0, 1, 'File "%s" deleted', array($fileObject->getIdentifier()));
         }
     } else {
         try {
             /** @var $fileObject \TYPO3\CMS\Core\Resource\FolderInterface */
             $result = $fileObject->delete(TRUE);
         } catch (\TYPO3\CMS\Core\Resource\Exception\InsufficientFileAccessPermissionsException $e) {
             $this->writelog(4, 1, 123, 'You are not allowed to access the directory', array($fileObject->getIdentifier()));
         } catch (\TYPO3\CMS\Core\Resource\Exception\NotInMountPointException $e) {
             $this->writelog(4, 1, 121, 'Target was not within your mountpoints! T="%s"', array($fileObject->getIdentifier()));
         } catch (\RuntimeException $e) {
             $this->writelog(4, 1, 120, 'Could not delete directory! Write-permission problem? Is directory "%s" empty? (You are not allowed to delete directories recursively).', array($fileObject->getIdentifier()));
         }
         // Log success
         $this->writelog(4, 0, 3, 'Directory "%s" deleted', array($fileObject->getIdentifier()));
     }
     return $result;
 }
コード例 #15
0
 /**
  * @return void
  */
 public function installPiwik()
 {
     try {
         $this->checkUnzip();
         $zipArchivePath = $this->downloadLatestPiwik();
         $this->extractDownloadedPiwik($zipArchivePath);
         $this->patchPiwik();
         $this->configureDownloadedPiwik();
     } catch (\Exception $e) {
         $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $e->getMessage(), 'There was a Problem', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
         \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($flashMessage);
     }
 }
コード例 #16
0
 /**
  * Works through the indexing queue and indexes the queued items into Solr.
  *
  * @return	boolean	Returns TRUE on success, FALSE if no items were indexed or none were found.
  * @see	typo3/sysext/scheduler/tx_scheduler_Task#execute()
  */
 public function execute()
 {
     // Get the extensions's configuration
     $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['moox_social']);
     if ($extConf['debugEmailSenderName'] == "") {
         $extConf['debugEmailSenderName'] = $extConf['debugEmailSenderAddress'];
     }
     if ($this->email == "") {
         $this->email = $extConf['debugEmailReceiverAddress'];
     }
     $executionSucceeded = FALSE;
     if (!$this->pid) {
         $this->pid = 0;
     }
     if ($this->youtubeChannel != "") {
         $execution = $this->getExecution();
         $interval = $execution->getInterval();
         $time = time();
         $to = $time;
         $from = $time - $interval - $this->intervalBuffer;
         try {
             $rawFeed = \TYPO3\MooxSocial\Controller\YoutubeController::youtube($this->youtubeChannel);
             /*print "<pre>"; 
                                           print_r($rawFeed);
                                           print "</pre>"; 
             		exit();*/
             $executionSucceeded = TRUE;
         } catch (\Exception $e) {
             $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->sL('LLL:EXT:moox_social/Resources/Private/Language/locallang_scheduler.xlf:tx_mooxsocial_tasks_youtubegettask.api_execution_error') . " [" . $e->getMessage() . "]", '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, TRUE);
             \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($message);
             if ($this->email && $extConf['debugEmailSenderAddress']) {
                 $lockfile = $_SERVER['DOCUMENT_ROOT'] . "/typo3temp/.lock-email-task-" . md5($this->youtubeChannel);
                 if (file_exists($lockfile)) {
                     $lockfiletime = filemtime($lockfile);
                     if ($lockfiletime < time() - 86400) {
                         unlink($lockfile);
                     }
                 }
                 if (!file_exists($lockfile)) {
                     $message = (new \TYPO3\CMS\Core\Mail\MailMessage())->setFrom(array($extConf['debugEmailSenderAddress'] => $extConf['debugEmailSenderName']))->setTo(array($this->email => $this->email))->setSubject($GLOBALS['LANG']->sL('LLL:EXT:moox_social/Resources/Private/Language/locallang_scheduler.xlf:tx_mooxsocial_tasks_youtubegettask.api_error_mailsubject'))->setBody('ERROR: while requesting [youtube channel: ' . $this->youtubeChannel . "]");
                     $message->send();
                     touch($lockfile);
                 }
             }
         }
         $posts = array();
         $postIds = array();
         foreach ($rawFeed as $item) {
             //if(1 || !in_array($item['type'],array("status"))){
             //if(!in_array($item['id'],$postIds) && $item['status_type']!=""){
             if (!in_array($item['id'], $postIds)) {
                 $postIds[] = $item['id'];
                 $postId = $item['id'];
                 $item['id'] = $postId;
                 $item['youtubeChannel'] = $this->youtubeChannel;
                 $item['pid'] = $this->pid;
                 $post = \TYPO3\MooxSocial\Controller\YoutubeController::youtubePost($item);
                 if (is_array($post)) {
                     $posts[] = $post;
                 }
             }
         }
         if (count($posts)) {
             $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
             $youtubeRepository = $objectManager->get('\\TYPO3\\MooxSocial\\Domain\\Repository\\YoutubeRepository');
             $insertCnt = 0;
             $updateCnt = 0;
             foreach ($posts as $post) {
                 $youtubePost = $youtubeRepository->findOneByApiUid($post['apiUid'], $this->pid);
                 if (!$youtubePost instanceof \TYPO3\MooxSocial\Domain\Model\Youtube) {
                     $youtubePost = new \TYPO3\MooxSocial\Domain\Model\Youtube();
                     $action = "insert";
                 }
                 if ($action == "insert") {
                     $youtubePost->setPid($post['pid']);
                     $youtubePost->setCreated($post['created']);
                 }
                 $youtubePost->setUpdated($post['updated']);
                 $youtubePost->setType($post['type']);
                 $youtubePost->setStatusType($post['statusType']);
                 if ($action == "insert") {
                     $youtubePost->setPage($post['page']);
                     $youtubePost->setModel("youtube");
                 }
                 $youtubePost->setAction($post['action']);
                 $youtubePost->setTitle($post['title']);
                 $youtubePost->setSummary($post['summary']);
                 $youtubePost->setText($post['text']);
                 $youtubePost->setAuthor($post['author']);
                 $youtubePost->setAuthorId($post['authorId']);
                 $youtubePost->setDescription($post['description']);
                 $youtubePost->setCaption($post['caption']);
                 $youtubePost->setUrl($post['url']);
                 $youtubePost->setLinkName($post['linkName']);
                 $youtubePost->setLinkUrl($post['linkUrl']);
                 $youtubePost->setImageUrl($post['imageUrl']);
                 $youtubePost->setImageEmbedcode($post['imageEmbedcode']);
                 $youtubePost->setVideoUrl($post['videoUrl']);
                 $youtubePost->setVideoEmbedcode($post['videoEmbedcode']);
                 $youtubePost->setSharedUrl($post['sharedUrl']);
                 $youtubePost->setSharedTitle($post['sharedTitle']);
                 $youtubePost->setSharedDescription($post['sharedDescription']);
                 $youtubePost->setSharedCaption($post['sharedCaption']);
                 $youtubePost->setLikes($post['likes']);
                 $youtubePost->setShares($post['shares']);
                 $youtubePost->setComments($post['comments']);
                 if ($action == "insert") {
                     $youtubePost->setApiUid($post['apiUid']);
                 }
                 $youtubePost->setApiHash($post['apiHash']);
                 if ($action == "insert") {
                     $youtubeRepository->add($youtubePost);
                     $insertCnt++;
                 } else {
                     $youtubeRepository->update($youtubePost);
                     $updateCnt++;
                 }
             }
             $objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\PersistenceManagerInterface')->persistAll();
             $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $insertCnt . " neue Videos geladen | " . $updateCnt . " bestehende Videos aktualisiert", '', \TYPO3\CMS\Core\Messaging\FlashMessage::OK, TRUE);
             \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($message);
         } else {
             $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', "Keine neuen oder aktualisierten Videos gefunden", '', \TYPO3\CMS\Core\Messaging\FlashMessage::OK, TRUE);
             \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($message);
         }
     }
     return $executionSucceeded;
 }
コード例 #17
0
 /**
  * This method is used to add a message to the internal queue
  *
  * @param string $message The message itself
  * @param integer $severity Message level (according to t3lib_FlashMessage class constants)
  * @return void
  */
 public function addMessage($message, $severity = \TYPO3\CMS\Core\Messaging\FlashMessage::OK)
 {
     $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $message, '', $severity);
     \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($message);
 }
コード例 #18
0
 /**
  * Handles an error.
  * If the error is registered as exceptionalError it will by converted into an exception, to be handled
  * by the configured exceptionhandler. Additionall the error message is written to the configured logs.
  * If TYPO3_MODE is 'BE' the error message is also added to the flashMessageQueue, in FE the error message
  * is displayed in the admin panel (as TsLog message)
  *
  * @param integer $errorLevel The error level - one of the E_* constants
  * @param string $errorMessage The error message
  * @param string $errorFile Name of the file the error occurred in
  * @param integer $errorLine Line number where the error occurred
  * @return void
  * @throws \TYPO3\CMS\Core\Error\Exception with the data passed to this method if the error is registered as exceptionalError
  */
 public function handleError($errorLevel, $errorMessage, $errorFile, $errorLine)
 {
     // Don't do anything if error_reporting is disabled by an @ sign
     if (error_reporting() == 0) {
         return TRUE;
     }
     $errorLevels = array(E_WARNING => 'Warning', E_NOTICE => 'Notice', E_USER_ERROR => 'User Error', E_USER_WARNING => 'User Warning', E_USER_NOTICE => 'User Notice', E_STRICT => 'Runtime Notice', E_RECOVERABLE_ERROR => 'Catchable Fatal Error', E_DEPRECATED => 'Runtime Deprecation Notice');
     $message = 'PHP ' . $errorLevels[$errorLevel] . ': ' . $errorMessage . ' in ' . $errorFile . ' line ' . $errorLine;
     if ($errorLevel & $this->exceptionalErrors) {
         // handle error raised at early parse time
         // autoloader not available & built-in classes not resolvable
         if (!class_exists('stdClass', FALSE)) {
             $message = 'PHP ' . $errorLevels[$errorLevel] . ': ' . $errorMessage . ' in ' . basename($errorFile) . 'line ' . $errorLine;
             die($message);
         }
         // We need to manually require the exception classes in case the autoloader is not available at this point yet.
         // @see http://forge.typo3.org/issues/23444
         if (!class_exists('TYPO3\\CMS\\Core\\Error\\Exception', FALSE)) {
             require_once PATH_t3lib . 'class.t3lib_exception.php';
             require_once PATH_t3lib . 'error/class.t3lib_error_exception.php';
         }
         throw new \TYPO3\CMS\Core\Error\Exception($message, 1);
     } else {
         switch ($errorLevel) {
             case E_USER_ERROR:
             case E_RECOVERABLE_ERROR:
                 $severity = 2;
                 break;
             case E_USER_WARNING:
             case E_WARNING:
                 $severity = 1;
                 break;
             default:
                 $severity = 0;
                 break;
         }
         $logTitle = 'Core: Error handler (' . TYPO3_MODE . ')';
         // Write error message to the configured syslogs,
         // see: $TYPO3_CONF_VARS['SYS']['systemLog']
         if ($errorLevel & $GLOBALS['TYPO3_CONF_VARS']['SYS']['syslogErrorReporting']) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::sysLog($message, $logTitle, $severity);
         }
         // In case an error occurs before a database connection exists, try
         // to connect to the DB to be able to write an entry to devlog/sys_log
         if (is_object($GLOBALS['TYPO3_DB']) && empty($GLOBALS['TYPO3_DB']->link)) {
             try {
                 $GLOBALS['TYPO3_DB']->connectDB();
             } catch (\Exception $e) {
             }
         }
         // Write error message to devlog extension(s),
         // see: $TYPO3_CONF_VARS['SYS']['enable_errorDLOG']
         if (TYPO3_ERROR_DLOG) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::devLog($message, $logTitle, $severity + 1);
         }
         // Write error message to TSlog (admin panel)
         if (is_object($GLOBALS['TT'])) {
             $GLOBALS['TT']->setTSlogMessage($logTitle . ': ' . $message, $severity + 1);
         }
         // Write error message to sys_log table (ext: belog, Tools->Log)
         if ($errorLevel & $GLOBALS['TYPO3_CONF_VARS']['SYS']['belogErrorReporting']) {
             $this->writeLog($logTitle . ': ' . $message, $severity);
         }
         // Add error message to the flashmessageQueue
         if (defined('TYPO3_ERRORHANDLER_MODE') && TYPO3_ERRORHANDLER_MODE == 'debug') {
             $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $message, 'PHP ' . $errorLevels[$errorLevel], $severity);
             \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($flashMessage);
         }
     }
     // Don't execute PHP internal error handler
     return TRUE;
 }
コード例 #19
0
 /**
  * Update translation(s)
  *
  * @param \TYPO3\CMS\Lang\Domain\Model\UpdateTranslationForm $form
  * @return void
  */
 public function updateTranslationAction(\TYPO3\CMS\Lang\Domain\Model\UpdateTranslationForm $form)
 {
     $result = array();
     try {
         if (count($form->getSelectedLanguages())) {
             foreach ($form->getExtensions() as $extension) {
                 $result[$extension] = $this->checkTranslationForExtension($form->getSelectedLanguages(), $extension);
             }
         }
     } catch (\Exception $exception) {
         $flashMessage = $this->objectManager->create('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', htmlspecialchars($exception->getMessage()), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR);
         \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($flashMessage);
     }
     $this->forward('index', NULL, NULL, array('updateResult' => $result));
 }
コード例 #20
0
ファイル: DataHandler.php プロジェクト: noxludo/TYPO3v4-Core
 /**
  * Print log error messages from the operations of this script instance
  *
  * @param string $redirect Redirect URL (for creating link in message)
  * @return void (Will exit on error)
  * @todo Define visibility
  */
 public function printLogErrorMessages($redirect)
 {
     $res_log = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_log', 'type=1 AND userid=' . intval($this->BE_USER->user['uid']) . ' AND tstamp=' . intval($GLOBALS['EXEC_TIME']) . '	AND error<>0');
     while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res_log)) {
         $log_data = unserialize($row['log_data']);
         $msg = $row['error'] . ': ' . sprintf($row['details'], $log_data[0], $log_data[1], $log_data[2], $log_data[3], $log_data[4]);
         $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', htmlspecialchars($msg), '', \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, TRUE);
         \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($flashMessage);
     }
     $GLOBALS['TYPO3_DB']->sql_free_result($res_log);
 }
コード例 #21
0
ファイル: FormEngine.php プロジェクト: noxludo/TYPO3v4-Core
 /**
  * Adds records from a foreign table (for selector boxes)
  *
  * @param array $items The array of items (label,value,icon)
  * @param array $fieldValue The 'columns' array for the field (from TCA)
  * @param array $TSconfig TSconfig for the table/row
  * @param string $field The fieldname
  * @param boolean $pFFlag If set, then we are fetching the 'neg_' foreign tables.
  * @return array The $items array modified.
  * @see addSelectOptionsToItemArray(), t3lib_BEfunc::exec_foreign_table_where_query()
  * @todo Define visibility
  */
 public function foreignTable($items, $fieldValue, $TSconfig, $field, $pFFlag = 0)
 {
     // Init:
     $pF = $pFFlag ? 'neg_' : '';
     $f_table = $fieldValue['config'][$pF . 'foreign_table'];
     $uidPre = $pFFlag ? '-' : '';
     // Exec query:
     $res = \TYPO3\CMS\Backend\Utility\BackendUtility::exec_foreign_table_where_query($fieldValue, $field, $TSconfig, $pF);
     // Perform error test
     if ($GLOBALS['TYPO3_DB']->sql_error()) {
         $msg = htmlspecialchars($GLOBALS['TYPO3_DB']->sql_error());
         $msg .= '<br />' . LF;
         $msg .= $this->sL('LLL:EXT:lang/locallang_core.php:error.database_schema_mismatch');
         $msgTitle = $this->sL('LLL:EXT:lang/locallang_core.php:error.database_schema_mismatch_title');
         /** @var $flashMessage \TYPO3\CMS\Core\Messaging\FlashMessage */
         $flashMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $msg, $msgTitle, \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR, TRUE);
         \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($flashMessage);
         return array();
     }
     // Get label prefix.
     $lPrefix = $this->sL($fieldValue['config'][$pF . 'foreign_table_prefix']);
     // Get icon field + path if any:
     $iField = $GLOBALS['TCA'][$f_table]['ctrl']['selicon_field'];
     $iPath = trim($GLOBALS['TCA'][$f_table]['ctrl']['selicon_field_path']);
     // Traverse the selected rows to add them:
     while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
         \TYPO3\CMS\Backend\Utility\BackendUtility::workspaceOL($f_table, $row);
         if (is_array($row)) {
             // Prepare the icon if available:
             if ($iField && $iPath && $row[$iField]) {
                 $iParts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $row[$iField], 1);
                 $icon = '../' . $iPath . '/' . trim($iParts[0]);
             } elseif (\TYPO3\CMS\Core\Utility\GeneralUtility::inList('singlebox,checkbox', $fieldValue['config']['renderMode'])) {
                 $icon = \TYPO3\CMS\Backend\Utility\IconUtility::mapRecordTypeToSpriteIconName($f_table, $row);
             } else {
                 $icon = '';
             }
             // Add the item:
             $items[] = array($lPrefix . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($f_table, $row)), $uidPre . $row['uid'], $icon);
         }
     }
     $GLOBALS['TYPO3_DB']->sql_free_result($res);
     return $items;
 }
コード例 #22
0
 /**
  * Copy Assets inside the fileadmin template directory
  *
  * @param string $directoryAssets Path of Assets directory
  * @return void
  */
 public function copyAssets($extension = NULL)
 {
     if ($extension == $this->extKey) {
         $directoryAssets = GeneralUtility::getFileAbsFileName("fileadmin/" . $this->extKey . "/Assets");
         if (file_exists($directoryAssets)) {
             /**
              * Add Flashmessage that there is already an Assets directory and we are not going to override this.
              */
             $message = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', 'There is already an Assets directory in the fileadmin ' . $this->extKey . ' directory.', 'Assets directory already exists', FlashMessage::NOTICE, TRUE);
             FlashMessageQueue::addMessage($message);
             return;
         }
         GeneralUtility::mkdir_deep($_SERVER['DOCUMENT_ROOT'] . "/fileadmin/", $this->extKey . "/Assets");
         GeneralUtility::copyDirectory($_SERVER['DOCUMENT_ROOT'] . "/typo3conf/ext/" . $this->extKey . "/Resources/Public/Assets", $_SERVER['DOCUMENT_ROOT'] . "/fileadmin/" . $this->extKey . "/Assets/");
         /**
          * Add Flashmessage that the Assets directory was placed in the fileadmin template directory
          */
         $message = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', 'You can store your assets there.', 'Assets was placed in your fileadmin ' . $this->extKey . ' directory.', FlashMessage::OK, TRUE);
         FlashMessageQueue::addMessage($message);
     }
 }
コード例 #23
0
 /**
  * Main action
  */
 public function mainAction()
 {
     // #################
     // Root page list
     // #################
     $rootPageList = \Metaseo\Metaseo\Utility\BackendUtility::getRootPageList();
     $rootIdList = array_keys($rootPageList);
     $rootPidCondition = NULL;
     if (!empty($rootIdList)) {
         $rootPidCondition = 'p.uid IN (' . implode(',', $rootIdList) . ')';
     } else {
         $rootPidCondition = '1=0';
     }
     // #################
     // Root setting list (w/ automatic creation)
     // #################
     // check which root lages have no root settings
     $query = 'SELECT p.uid
                 FROM pages p
                      LEFT JOIN tx_metaseo_setting_root seosr
                         ON   seosr.pid = p.uid
                          AND seosr.deleted = 0
                 WHERE ' . $rootPidCondition . '
                   AND seosr.uid IS NULL';
     $uidList = DatabaseUtility::getCol($query);
     foreach ($uidList as $tmpUid) {
         $query = 'INSERT INTO tx_metaseo_setting_root (pid, tstamp, crdate, cruser_id)
                         VALUES (' . (int) $tmpUid . ',
                                 ' . (int) time() . ',
                                 ' . (int) time() . ',
                                 ' . (int) $GLOBALS['BE_USER']->user['uid'] . ')';
         DatabaseUtility::execInsert($query);
     }
     $rootSettingList = \Metaseo\Metaseo\Utility\BackendUtility::getRootPageSettingList();
     // #################
     // Domain list
     // ##################
     // Fetch domain name
     $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid, pid, domainName, forced', 'sys_domain', 'hidden = 0', '', 'forced DESC, sorting');
     $domainList = array();
     while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
         $domainList[$row['pid']][$row['uid']] = $row;
     }
     // #################
     // Build root page list
     // #################
     unset($page);
     foreach ($rootPageList as $pageId => &$page) {
         // Domain list
         $page['domainList'] = '';
         if (!empty($domainList[$pageId])) {
             $page['domainList'] = $domainList[$pageId];
         }
         // Settings
         $page['rootSettings'] = array();
         if (!empty($rootSettingList[$pageId])) {
             $page['rootSettings'] = $rootSettingList[$pageId];
         }
         // Settings available
         $page['settingsLink'] = \TYPO3\CMS\Backend\Utility\BackendUtility::editOnClick('&edit[tx_metaseo_setting_root][' . $rootSettingList[$pageId]['uid'] . ']=edit', $this->doc->backPath);
     }
     unset($page);
     // check if there is any root page
     if (empty($rootPageList)) {
         $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $this->_translate('message.warning.noRootPage.message'), $this->_translate('message.warning.noRootPage.title'), \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING);
         \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($message);
     }
     // ############################
     // Page/JS
     // ############################
     // FIXME: do we really need a template engine here?
     $this->template = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
     $pageRenderer = $this->template->getPageRenderer();
     $basePathJs = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('metaseo') . 'Resources/Public/Backend/JavaScript';
     $basePathCss = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('metaseo') . 'Resources/Public/Backend/Css';
     $pageRenderer->addCssFile($basePathCss . '/Default.css');
     $this->view->assign('RootPageList', $rootPageList);
 }
コード例 #24
0
 /**
  * add flashmessage if migration was successful or not.
  *
  * @return void
  */
 protected function addResultMessage()
 {
     if ($this->amountOfMigratedRecords > 0) {
         $headline = LocalizationUtility::translate('migrationSuccessful', 'dam_falmigration');
         $message = LocalizationUtility::translate('migratedFiles', 'dam_falmigration', array(0 => $this->amountOfMigratedRecords));
     } else {
         $headline = LocalizationUtility::translate('migrationNotNecessary', 'dam_falmigration');
         $message = LocalizationUtility::translate('allFilesMigrated', 'dam_falmigration');
     }
     $messageObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $message, $headline);
     // addMessage is a magic method realized by __call()
     FlashMessageQueue::addMessage($messageObject);
 }
コード例 #25
0
 /**
  * action truncate
  *
  * @param string $userId
  * @param integer $storagePid
  * @return void
  */
 public function truncateAction($userId, $storagePid)
 {
     if ($userId != "") {
         $this->slideshareRepository->removeByPageId($userId, $storagePid);
     }
     $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('LLL:EXT:moox_social/Resources/Private/Language/locallang.xlf:overview.slideshare.listing.truncate.success', $this->extensionName), '', \TYPO3\CMS\Core\Messaging\FlashMessage::OK, TRUE);
     \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($message);
     $this->redirect('index');
 }
コード例 #26
0
    /**
     * Rendering the quick-edit view.
     *
     * @return void
     * @todo Define visibility
     */
    public function renderQuickEdit()
    {
        // Alternative template
        $this->doc->setModuleTemplate('templates/db_layout_quickedit.html');
        // Alternative form tag; Quick Edit submits its content to tce_db.php.
        $this->doc->form = '<form action="' . htmlspecialchars($GLOBALS['BACK_PATH'] . 'tce_db.php?&prErr=1&uPT=1') . '" method="post" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '" name="editform" onsubmit="return TBE_EDITOR.checkSubmit(1);">';
        // Setting up the context sensitive menu:
        $this->doc->getContextMenuCode();
        // Set the edit_record value for internal use in this function:
        $edit_record = $this->edit_record;
        // If a command to edit all records in a column is issue, then select all those elements, and redirect to alt_doc.php:
        if (substr($edit_record, 0, 9) == '_EDIT_COL') {
            $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'pid=' . intval($this->id) . ' AND colPos=' . intval(substr($edit_record, 10)) . ' AND sys_language_uid=' . intval($this->current_sys_language) . ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tt_content')) . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tt_content') . \TYPO3\CMS\Backend\Utility\BackendUtility::versioningPlaceholderClause('tt_content'), '', 'sorting');
            $idListA = array();
            while ($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
                $idListA[] = $cRow['uid'];
            }
            $url = $GLOBALS['BACK_PATH'] . 'alt_doc.php?edit[tt_content][' . implode(',', $idListA) . ']=edit&returnUrl=' . rawurlencode($this->local_linkThisScript(array('edit_record' => '')));
            \TYPO3\CMS\Core\Utility\HttpUtility::redirect($url);
        }
        // If the former record edited was the creation of a NEW record, this will look up the created records uid:
        if ($this->new_unique_uid) {
            $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_log', 'userid=' . intval($GLOBALS['BE_USER']->user['uid']) . ' AND NEWid=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->new_unique_uid, 'sys_log'));
            $sys_log_row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
            if (is_array($sys_log_row)) {
                $edit_record = $sys_log_row['tablename'] . ':' . $sys_log_row['recuid'];
            }
        }
        // Creating the selector box, allowing the user to select which element to edit:
        $opt = array();
        $is_selected = 0;
        $languageOverlayRecord = '';
        if ($this->current_sys_language) {
            list($languageOverlayRecord) = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('pages_language_overlay', 'pid', $this->id, 'AND sys_language_uid=' . intval($this->current_sys_language));
        }
        if (is_array($languageOverlayRecord)) {
            $inValue = 'pages_language_overlay:' . $languageOverlayRecord['uid'];
            $is_selected += intval($edit_record == $inValue);
            $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('editLanguageHeader', 1) . ' ]</option>';
        } else {
            $inValue = 'pages:' . $this->id;
            $is_selected += intval($edit_record == $inValue);
            $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('editPageProperties', 1) . ' ]</option>';
        }
        // Selecting all content elements from this language and allowed colPos:
        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_content', 'pid=' . intval($this->id) . ' AND sys_language_uid=' . intval($this->current_sys_language) . ' AND colPos IN (' . $this->colPosList . ')' . ($this->MOD_SETTINGS['tt_content_showHidden'] ? '' : \TYPO3\CMS\Backend\Utility\BackendUtility::BEenableFields('tt_content')) . \TYPO3\CMS\Backend\Utility\BackendUtility::deleteClause('tt_content') . \TYPO3\CMS\Backend\Utility\BackendUtility::versioningPlaceholderClause('tt_content'), '', 'colPos,sorting');
        $colPos = '';
        $first = 1;
        // Page is the pid if no record to put this after.
        $prev = $this->id;
        while ($cRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
            \TYPO3\CMS\Backend\Utility\BackendUtility::workspaceOL('tt_content', $cRow);
            if (is_array($cRow)) {
                if ($first) {
                    if (!$edit_record) {
                        $edit_record = 'tt_content:' . $cRow['uid'];
                    }
                    $first = 0;
                }
                if (strcmp($cRow['colPos'], $colPos)) {
                    $colPos = $cRow['colPos'];
                    $opt[] = '<option value=""></option>';
                    $opt[] = '<option value="_EDIT_COL:' . $colPos . '">__' . $GLOBALS['LANG']->sL(\TYPO3\CMS\Backend\Utility\BackendUtility::getLabelFromItemlist('tt_content', 'colPos', $colPos), 1) . ':__</option>';
                }
                $inValue = 'tt_content:' . $cRow['uid'];
                $is_selected += intval($edit_record == $inValue);
                $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($cRow['header'] ? $cRow['header'] : '[' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.no_title') . '] ' . strip_tags($cRow['bodytext']), $GLOBALS['BE_USER']->uc['titleLen'])) . '</option>';
                $prev = -$cRow['uid'];
            }
        }
        // If edit_record is not set (meaning, no content elements was found for this language) we simply set it to create a new element:
        if (!$edit_record) {
            $edit_record = 'tt_content:new/' . $prev . '/' . $colPos;
            $inValue = 'tt_content:new/' . $prev . '/' . $colPos;
            $is_selected += intval($edit_record == $inValue);
            $opt[] = '<option value="' . $inValue . '"' . ($edit_record == $inValue ? ' selected="selected"' : '') . '>[ ' . $GLOBALS['LANG']->getLL('newLabel', 1) . ' ]</option>';
        }
        // If none is yet selected...
        if (!$is_selected) {
            $opt[] = '<option value=""></option>';
            $opt[] = '<option value="' . $edit_record . '"  selected="selected">[ ' . $GLOBALS['LANG']->getLL('newLabel', 1) . ' ]</option>';
        }
        // Splitting the edit-record cmd value into table/uid:
        $this->eRParts = explode(':', $edit_record);
        // Delete-button flag?
        $this->deleteButton = \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->eRParts[1]) && $edit_record && ($this->eRParts[0] != 'pages' && $this->EDIT_CONTENT || $this->eRParts[0] == 'pages' && $this->CALC_PERMS & 4);
        // If undo-button should be rendered (depends on available items in sys_history)
        $this->undoButton = 0;
        $undoRes = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tstamp', 'sys_history', 'tablename=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($this->eRParts[0], 'sys_history') . ' AND recuid=' . intval($this->eRParts[1]), '', 'tstamp DESC', '1');
        if ($this->undoButtonR = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($undoRes)) {
            $this->undoButton = 1;
        }
        // Setting up the Return URL for coming back to THIS script (if links take the user to another script)
        $R_URL_parts = parse_url(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI'));
        $R_URL_getvars = \TYPO3\CMS\Core\Utility\GeneralUtility::_GET();
        unset($R_URL_getvars['popView']);
        unset($R_URL_getvars['new_unique_uid']);
        $R_URL_getvars['edit_record'] = $edit_record;
        $this->R_URI = $R_URL_parts['path'] . '?' . \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl('', $R_URL_getvars);
        // Setting close url/return url for exiting this script:
        // Goes to 'Columns' view if close is pressed (default)
        $this->closeUrl = $this->local_linkThisScript(array('SET' => array('function' => 1)));
        if ($GLOBALS['BE_USER']->uc['condensedMode']) {
            $this->closeUrl = $GLOBALS['BACK_PATH'] . 'alt_db_navframe.php';
        }
        if ($this->returnUrl) {
            $this->closeUrl = $this->returnUrl;
        }
        // Return-url for JavaScript:
        $retUrlStr = $this->returnUrl ? '+\'&returnUrl=\'+\'' . rawurlencode($this->returnUrl) . '\'' : '';
        // Drawing the edit record selectbox
        $this->editSelect = '<select name="edit_record" onchange="' . htmlspecialchars('jumpToUrl(\'db_layout.php?id=' . $this->id . '&edit_record=\'+escape(this.options[this.selectedIndex].value)' . $retUrlStr . ',this);') . '">' . implode('', $opt) . '</select>';
        // Creating editing form:
        if ($GLOBALS['BE_USER']->check('tables_modify', $this->eRParts[0]) && $edit_record && ($this->eRParts[0] !== 'pages' && $this->EDIT_CONTENT || $this->eRParts[0] === 'pages' && $this->CALC_PERMS & 1)) {
            // Splitting uid parts for special features, if new:
            list($uidVal, $ex_pid, $ex_colPos) = explode('/', $this->eRParts[1]);
            // Convert $uidVal to workspace version if any:
            if ($uidVal != 'new') {
                if ($draftRecord = \TYPO3\CMS\Backend\Utility\BackendUtility::getWorkspaceVersionOfRecord($GLOBALS['BE_USER']->workspace, $this->eRParts[0], $uidVal, 'uid')) {
                    $uidVal = $draftRecord['uid'];
                }
            }
            // Initializing transfer-data object:
            $trData = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\DataPreprocessor');
            $trData->addRawData = TRUE;
            $trData->defVals[$this->eRParts[0]] = array('colPos' => intval($ex_colPos), 'sys_language_uid' => intval($this->current_sys_language));
            $trData->disableRTE = $this->MOD_SETTINGS['disableRTE'];
            $trData->lockRecords = 1;
            // 'new'
            $trData->fetchRecord($this->eRParts[0], $uidVal == 'new' ? $this->id : $uidVal, $uidVal);
            // Getting/Making the record:
            reset($trData->regTableItems_data);
            $rec = current($trData->regTableItems_data);
            if ($uidVal == 'new') {
                $new_unique_uid = uniqid('NEW');
                $rec['uid'] = $new_unique_uid;
                $rec['pid'] = intval($ex_pid) ? intval($ex_pid) : $this->id;
                $recordAccess = TRUE;
            } else {
                $rec['uid'] = $uidVal;
                // Checking internals access:
                $recordAccess = $GLOBALS['BE_USER']->recordEditAccessInternals($this->eRParts[0], $uidVal);
            }
            if (!$recordAccess) {
                // If no edit access, print error message:
                $content .= $this->doc->section($GLOBALS['LANG']->getLL('noAccess'), $GLOBALS['LANG']->getLL('noAccess_msg') . '<br /><br />' . ($GLOBALS['BE_USER']->errorMsg ? 'Reason: ' . $GLOBALS['BE_USER']->errorMsg . '<br /><br />' : ''), 0, 1);
            } elseif (is_array($rec)) {
                // If the record is an array (which it will always be... :-)
                // Create instance of TCEforms, setting defaults:
                $tceforms = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Form\\FormEngine');
                $tceforms->backPath = $GLOBALS['BACK_PATH'];
                $tceforms->initDefaultBEMode();
                $tceforms->fieldOrder = $this->modTSconfig['properties']['tt_content.']['fieldOrder'];
                $tceforms->palettesCollapsed = !$this->MOD_SETTINGS['showPalettes'];
                $tceforms->disableRTE = $this->MOD_SETTINGS['disableRTE'];
                $tceforms->enableClickMenu = TRUE;
                // Clipboard is initialized:
                // Start clipboard
                $tceforms->clipObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Clipboard\\Clipboard');
                // Initialize - reads the clipboard content from the user session
                $tceforms->clipObj->initializeClipboard();
                // Render form, wrap it:
                $panel = '';
                $panel .= $tceforms->getMainFields($this->eRParts[0], $rec);
                $panel = $tceforms->wrapTotal($panel, $rec, $this->eRParts[0]);
                // Add hidden fields:
                $theCode = $panel;
                if ($uidVal == 'new') {
                    $theCode .= '<input type="hidden" name="data[' . $this->eRParts[0] . '][' . $rec['uid'] . '][pid]" value="' . $rec['pid'] . '" />';
                }
                $theCode .= '
					<input type="hidden" name="_serialNumber" value="' . md5(microtime()) . '" />
					<input type="hidden" name="_disableRTE" value="' . $tceforms->disableRTE . '" />
					<input type="hidden" name="edit_record" value="' . $edit_record . '" />
					<input type="hidden" name="redirect" value="' . htmlspecialchars($uidVal == 'new' ? \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('cms') . 'layout/db_layout.php?id=' . $this->id . '&new_unique_uid=' . $new_unique_uid . '&returnUrl=' . rawurlencode($this->returnUrl) : $this->R_URI) . '" />
					' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction');
                // Add JavaScript as needed around the form:
                $theCode = $tceforms->printNeededJSFunctions_top() . $theCode . $tceforms->printNeededJSFunctions();
                // Add warning sign if record was "locked":
                if ($lockInfo = \TYPO3\CMS\Backend\Utility\BackendUtility::isRecordLocked($this->eRParts[0], $rec['uid'])) {
                    $lockedMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', htmlspecialchars($lockInfo['msg']), '', \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING);
                    \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($lockedMessage);
                }
                // Add whole form as a document section:
                $content .= $this->doc->section('', $theCode);
            }
        } else {
            // If no edit access, print error message:
            $content .= $this->doc->section($GLOBALS['LANG']->getLL('noAccess'), $GLOBALS['LANG']->getLL('noAccess_msg') . '<br /><br />', 0, 1);
        }
        // Bottom controls (function menus):
        $q_count = $this->getNumberOfHiddenElements();
        $h_func_b = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->id, 'SET[tt_content_showHidden]', $this->MOD_SETTINGS['tt_content_showHidden'], 'db_layout.php', '', 'id="checkTt_content_showHidden"') . '<label for="checkTt_content_showHidden">' . (!$q_count ? $GLOBALS['TBE_TEMPLATE']->dfw($GLOBALS['LANG']->getLL('hiddenCE', 1)) : $GLOBALS['LANG']->getLL('hiddenCE', 1) . ' (' . $q_count . ')') . '</label>';
        $h_func_b .= '<br />' . \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->id, 'SET[showPalettes]', $this->MOD_SETTINGS['showPalettes'], 'db_layout.php', '', 'id="checkShowPalettes"') . '<label for="checkShowPalettes">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showPalettes', 1) . '</label>';
        if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('context_help')) {
            $h_func_b .= '<br />' . \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->id, 'SET[showDescriptions]', $this->MOD_SETTINGS['showDescriptions'], 'db_layout.php', '', 'id="checkShowDescriptions"') . '<label for="checkShowDescriptions">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.showDescriptions', 1) . '</label>';
        }
        if ($GLOBALS['BE_USER']->isRTE()) {
            $h_func_b .= '<br />' . \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->id, 'SET[disableRTE]', $this->MOD_SETTINGS['disableRTE'], 'db_layout.php', '', 'id="checkDisableRTE"') . '<label for="checkDisableRTE">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.disableRTE', 1) . '</label>';
        }
        // Add the function menus to bottom:
        $content .= $this->doc->section('', $h_func_b, 0, 0);
        $content .= $this->doc->spacer(10);
        // Select element matrix:
        if ($this->eRParts[0] == 'tt_content' && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->eRParts[1])) {
            $posMap = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('ext_posMap');
            $posMap->backPath = $GLOBALS['BACK_PATH'];
            $posMap->cur_sys_language = $this->current_sys_language;
            $HTMLcode = '';
            // CSH:
            $HTMLcode .= \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem($this->descrTable, 'quickEdit_selElement', $GLOBALS['BACK_PATH'], '|<br />');
            $HTMLcode .= $posMap->printContentElementColumns($this->id, $this->eRParts[1], $this->colPosList, $this->MOD_SETTINGS['tt_content_showHidden'], $this->R_URI);
            $content .= $this->doc->spacer(20);
            $content .= $this->doc->section($GLOBALS['LANG']->getLL('CEonThisPage'), $HTMLcode, 0, 1);
            $content .= $this->doc->spacer(20);
        }
        // Finally, if comments were generated in TCEforms object, print these as a HTML comment:
        if (count($tceforms->commentMessages)) {
            $content .= '
	<!-- TCEFORM messages
	' . htmlspecialchars(implode(LF, $tceforms->commentMessages)) . '
	-->
	';
        }
        return $content;
    }
コード例 #27
0
 /**
  * main function, needs to return TRUE or FALSE in order to tell
  * the scheduler whether the task went through smoothly
  *
  * @throws \TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException
  * @throws \Exception
  * @return boolean
  */
 public function execute()
 {
     $this->init();
     if ($this->isTableAvailable('tx_dam')) {
         $rows = $this->getNotMigratedDamRecords();
         foreach ($rows as $damRecord) {
             if ($this->isValidDirectory($damRecord)) {
                 try {
                     $fileObject = $this->storageObject->getFile($this->getFullFileName($damRecord));
                     if ($fileObject instanceof \TYPO3\CMS\Core\Resource\File) {
                         $this->migrateFileFromDamToFal($damRecord, $fileObject);
                         $this->amountOfMigratedRecords++;
                     }
                 } catch (\Exception $e) {
                     // If file is not found
                     $this->amountOfFilesNotFound++;
                     continue;
                 }
             }
         }
         $this->addResultMessage();
         $messageObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', 'Not migrated dam records at start of task: ' . count($rows) . '. Migrated files after task: ' . $this->amountOfMigratedRecords . '. Files not found: ' . $this->amountOfFilesNotFound . '.', 'file analyse');
         FlashMessageQueue::addMessage($messageObject);
         // mark task as successful executed
         return TRUE;
     } else {
         throw new \Exception('Extension tx_dam is not installed. So there is nothing to migrate.');
     }
 }
コード例 #28
0
ファイル: Page.php プロジェクト: kalypso63/ext-solr
 /**
  * Checks whether a Mount Page is properly configured.
  *
  * @param array $mountPage A mount page
  * @return boolean TRUE if the Mount Page is OK, FALSE otherwise
  */
 protected function validateMountPage(array $mountPage)
 {
     $isValidMountPage = true;
     if (empty($mountPage['mountPageSource'])) {
         $isValidMountPage = false;
         $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', 'Property "Mounted page" must not be empty. Invalid Mount Page configuration for page ID ' . $mountPage['uid'] . '.', 'Failed to initialize Mount Page tree. ', FlashMessage::ERROR);
         FlashMessageQueue::addMessage($flashMessage);
     }
     if (!$this->mountedPageExists($mountPage['mountPageSource'])) {
         $isValidMountPage = false;
         $flashMessage = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', 'The mounted page must be accessible in the frontend. ' . 'Invalid Mount Page configuration for page ID ' . $mountPage['uid'] . ', the mounted page with ID ' . $mountPage['mountPageSource'] . ' is not accessible in the frontend.', 'Failed to initialize Mount Page tree. ', FlashMessage::ERROR);
         FlashMessageQueue::addMessage($flashMessage);
     }
     return $isValidMountPage;
 }
コード例 #29
0
    /**
     * Creating form for editing the permissions	($this->edit = TRUE)
     * (Adding content to internal content variable)
     *
     * @return void
     */
    public function doEdit()
    {
        if ($GLOBALS['BE_USER']->workspace != 0) {
            // Adding section with the permission setting matrix:
            $lockedMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', $GLOBALS['LANG']->getLL('WorkspaceWarningText'), $GLOBALS['LANG']->getLL('WorkspaceWarning'), \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING);
            \TYPO3\CMS\Core\Messaging\FlashMessageQueue::addMessage($lockedMessage);
        }
        // Get usernames and groupnames
        $beGroupArray = \TYPO3\CMS\Backend\Utility\BackendUtility::getListGroupNames('title,uid');
        $beGroupKeys = array_keys($beGroupArray);
        $beUserArray = \TYPO3\CMS\Backend\Utility\BackendUtility::getUserNames();
        if (!$GLOBALS['BE_USER']->isAdmin()) {
            $beUserArray = \TYPO3\CMS\Backend\Utility\BackendUtility::blindUserNames($beUserArray, $beGroupKeys, 1);
        }
        $beGroupArray_o = $beGroupArray = \TYPO3\CMS\Backend\Utility\BackendUtility::getGroupNames();
        if (!$GLOBALS['BE_USER']->isAdmin()) {
            $beGroupArray = \TYPO3\CMS\Backend\Utility\BackendUtility::blindGroupNames($beGroupArray_o, $beGroupKeys, 1);
        }
        // data of the first group, the user is member of
        $firstGroup = $beGroupKeys[0] ? $beGroupArray[$beGroupKeys[0]] : '';
        // Owner selector:
        $options = '';
        // flag: is set if the page-userid equals one from the user-list
        $userset = 0;
        foreach ($beUserArray as $uid => $row) {
            if ($uid == $this->pageinfo['perms_userid']) {
                $userset = 1;
                $selected = ' selected="selected"';
            } else {
                $selected = '';
            }
            $options .= '
				<option value="' . $uid . '"' . $selected . '>' . htmlspecialchars($row['username']) . '</option>';
        }
        $options = '
				<option value="0"></option>' . $options;
        $selector = '
			<select name="data[pages][' . $this->id . '][perms_userid]">
				' . $options . '
			</select>';
        $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('Owner') . ':', $selector);
        // Group selector:
        $options = '';
        $userset = 0;
        foreach ($beGroupArray as $uid => $row) {
            if ($uid == $this->pageinfo['perms_groupid']) {
                $userset = 1;
                $selected = ' selected="selected"';
            } else {
                $selected = '';
            }
            $options .= '
				<option value="' . $uid . '"' . $selected . '>' . htmlspecialchars($row['title']) . '</option>';
        }
        // If the group was not set AND there is a group for the page
        if (!$userset && $this->pageinfo['perms_groupid']) {
            $options = '
				<option value="' . $this->pageinfo['perms_groupid'] . '" selected="selected">' . htmlspecialchars($beGroupArray_o[$this->pageinfo['perms_groupid']]['title']) . '</option>' . $options;
        }
        $options = '
				<option value="0"></option>' . $options;
        $selector = '
			<select name="data[pages][' . $this->id . '][perms_groupid]">
				' . $options . '
			</select>';
        $this->content .= $this->doc->divider(5);
        $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('Group') . ':', $selector);
        // Permissions checkbox matrix:
        $code = '
			<table border="0" cellspacing="2" cellpadding="0" id="typo3-permissionMatrix">
				<tr>
					<td></td>
					<td class="bgColor2">' . str_replace(' ', '<br />', $GLOBALS['LANG']->getLL('1', 1)) . '</td>
					<td class="bgColor2">' . str_replace(' ', '<br />', $GLOBALS['LANG']->getLL('16', 1)) . '</td>
					<td class="bgColor2">' . str_replace(' ', '<br />', $GLOBALS['LANG']->getLL('2', 1)) . '</td>
					<td class="bgColor2">' . str_replace(' ', '<br />', $GLOBALS['LANG']->getLL('4', 1)) . '</td>
					<td class="bgColor2">' . str_replace(' ', '<br />', $GLOBALS['LANG']->getLL('8', 1)) . '</td>
				</tr>
				<tr>
					<td align="right" class="bgColor2">' . $GLOBALS['LANG']->getLL('Owner', 1) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_user', 1) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_user', 5) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_user', 2) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_user', 3) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_user', 4) . '</td>
				</tr>
				<tr>
					<td align="right" class="bgColor2">' . $GLOBALS['LANG']->getLL('Group', 1) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_group', 1) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_group', 5) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_group', 2) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_group', 3) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_group', 4) . '</td>
				</tr>
				<tr>
					<td align="right" class="bgColor2">' . $GLOBALS['LANG']->getLL('Everybody', 1) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_everybody', 1) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_everybody', 5) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_everybody', 2) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_everybody', 3) . '</td>
					<td class="bgColor-20">' . $this->printCheckBox('perms_everybody', 4) . '</td>
				</tr>
			</table>
			<br />

			<input type="hidden" name="data[pages][' . $this->id . '][perms_user]" value="' . $this->pageinfo['perms_user'] . '" />
			<input type="hidden" name="data[pages][' . $this->id . '][perms_group]" value="' . $this->pageinfo['perms_group'] . '" />
			<input type="hidden" name="data[pages][' . $this->id . '][perms_everybody]" value="' . $this->pageinfo['perms_everybody'] . '" />
			' . $this->getRecursiveSelect($this->id, $this->perms_clause) . '
			<input type="submit" name="submit" value="' . $GLOBALS['LANG']->getLL('Save', 1) . '" />' . '<input type="submit" value="' . $GLOBALS['LANG']->getLL('Abort', 1) . '" onclick="' . htmlspecialchars('jumpToUrl(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue(\TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_perm') . '&id=' . $this->id, TRUE) . '); return false;') . '" />
			<input type="hidden" name="redirect" value="' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_perm') . '&mode=' . $this->MOD_SETTINGS['mode'] . '&depth=' . $this->MOD_SETTINGS['depth'] . '&id=' . intval($this->return_id) . '&lastEdited=' . $this->id) . '" />
			' . \TYPO3\CMS\Backend\Form\FormEngine::getHiddenTokenField('tceAction');
        // Adding section with the permission setting matrix:
        $this->content .= $this->doc->divider(5);
        $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('permissions') . ':', $code);
        // CSH for permissions setting
        $this->content .= \TYPO3\CMS\Backend\Utility\BackendUtility::cshItem('xMOD_csh_corebe', 'perm_module_setting', $GLOBALS['BACK_PATH'], '<br /><br />');
        // Adding help text:
        if ($GLOBALS['BE_USER']->uc['helpText']) {
            $this->content .= $this->doc->divider(20);
            $legendText = '<strong>' . $GLOBALS['LANG']->getLL('1', 1) . '</strong>: ' . $GLOBALS['LANG']->getLL('1_t', 1);
            $legendText .= '<br /><strong>' . $GLOBALS['LANG']->getLL('16', 1) . '</strong>: ' . $GLOBALS['LANG']->getLL('16_t', 1);
            $legendText .= '<br /><strong>' . $GLOBALS['LANG']->getLL('2', 1) . '</strong>: ' . $GLOBALS['LANG']->getLL('2_t', 1);
            $legendText .= '<br /><strong>' . $GLOBALS['LANG']->getLL('4', 1) . '</strong>: ' . $GLOBALS['LANG']->getLL('4_t', 1);
            $legendText .= '<br /><strong>' . $GLOBALS['LANG']->getLL('8', 1) . '</strong>: ' . $GLOBALS['LANG']->getLL('8_t', 1);
            $code = $legendText . '<br /><br />' . $GLOBALS['LANG']->getLL('def', 1);
            $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('Legend', 1) . ':', $code);
        }
    }
 /**
  * @test
  */
 public function createValidationErrorMessageAddsErrorFlashMessage()
 {
     $GLOBALS['BE_USER'] = $this->createBackendUserSessionStorageStub();
     $this->fixture->createValidationErrorMessage();
     $messages = \TYPO3\CMS\Core\Messaging\FlashMessageQueue::getAllMessagesAndFlush();
     $this->assertNotEmpty($messages);
     $this->assertContains($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:error.formProtection.tokenInvalid'), $messages[0]->render());
 }