Ejemplo n.º 1
0
 /**
  * Process add media request
  *
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @return ResponseInterface
  */
 public function mainAction(ServerRequestInterface $request, ResponseInterface $response)
 {
     $files = $request->getParsedBody()['file'];
     $newMedia = [];
     if (isset($files['newMedia'])) {
         $newMedia = (array) $files['newMedia'];
     }
     foreach ($newMedia as $media) {
         if (!empty($media['url']) && !empty($media['target'])) {
             $allowed = !empty($media['allowed']) ? GeneralUtility::trimExplode(',', $media['allowed']) : [];
             $file = $this->addMediaFromUrl($media['url'], $media['target'], $allowed);
             if ($file !== null) {
                 $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $file->getName(), $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:online_media.new_media.added'), FlashMessage::OK, true);
             } else {
                 $flashMessage = GeneralUtility::makeInstance(FlashMessage::class, $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:online_media.error.invalid_url'), $this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:online_media.error.new_media.failed'), FlashMessage::ERROR, true);
             }
             $this->addFlashMessage($flashMessage);
         }
     }
     $redirect = isset($request->getParsedBody()['redirect']) ? $request->getParsedBody()['redirect'] : $request->getQueryParams()['redirect'];
     $redirect = GeneralUtility::sanitizeLocalUrl($redirect);
     if ($redirect) {
         $response = $response->withHeader('Location', GeneralUtility::locationHeaderUrl($redirect))->withStatus(303);
     }
     return $response;
 }
Ejemplo n.º 2
0
 public static function createPublicTempFile($prefix, $suffix)
 {
     $fullname = GeneralUtility::tempnam($prefix, $suffix);
     $urlname = preg_replace('/.*(?=\\/typo3temp)/', '', $fullname);
     $url = GeneralUtility::locationHeaderUrl($urlname);
     return ['name' => $fullname, 'url' => $url];
 }
Ejemplo n.º 3
0
 /**
  * Injects the request object for the current request or subrequest
  * As this controller goes only through the main() method, it is rather simple for now
  * This will be split up in an abstract controller once proper routing/dispatcher is in place.
  *
  * @param ServerRequestInterface $request the current request
  * @param ResponseInterface $response
  * @return ResponseInterface the response with the content
  */
 public function logoutAction(ServerRequestInterface $request, ResponseInterface $response)
 {
     $this->logout();
     $redirectUrl = isset($request->getParsedBody()['redirect']) ? $request->getParsedBody()['redirect'] : $request->getQueryParams()['redirect'];
     $redirectUrl = GeneralUtility::sanitizeLocalUrl($redirectUrl);
     if (empty($redirectUrl)) {
         /** @var \TYPO3\CMS\Backend\Routing\UriBuilder $uriBuilder */
         $uriBuilder = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Routing\UriBuilder::class);
         $redirectUrl = (string) $uriBuilder->buildUriFromRoute('login', array(), $uriBuilder::ABSOLUTE_URL);
     }
     return $response->withStatus(303)->withHeader('Location', GeneralUtility::locationHeaderUrl($redirectUrl));
 }
 /**
  * Handles the existing files of a Fine Uploader form.
  * The values are stored in the GET/POST var at the index "fieldValue".
  *
  * @return string
  */
 public function getExistingFiles()
 {
     $files = array();
     $fieldValue = GeneralUtility::_GP('fieldValue');
     if ($fieldValue != '') {
         $imagePath = GeneralUtility::getFileAbsFileName($fieldValue);
         $imageName = PathUtility::basename($imagePath);
         $imageDirectoryPath = PathUtility::dirname($imagePath);
         $imageDirectoryPath = PathUtility::getRelativePath(PATH_site, $imageDirectoryPath);
         $imageUrl = GeneralUtility::locationHeaderUrl('/' . $imageDirectoryPath . $imageName);
         if (file_exists($imagePath)) {
             $files[] = array('name' => $imageName, 'uuid' => $imageUrl, 'thumbnailUrl' => $imageUrl);
         }
     }
     return json_encode($files);
 }
 /**
  * Gets additional fields to render in the form to add/edit a task
  *
  * @param array $taskInfo Values of the fields from the add/edit task form
  * @param \TYPO3\CMS\Scheduler\Task\AbstractTask $task The task object being edited. Null when adding a task!
  * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule Reference to the scheduler backend module
  * @return array A two dimensional array, array('Identifier' => array('fieldId' => array('code' => '', 'label' => '', 'cshKey' => '', 'cshLabel' => ''))
  */
 public function getAdditionalFields(array &$taskInfo, $task, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $schedulerModule)
 {
     /** @var \DmitryDulepov\DdGooglesitemap\Scheduler\Task $task */
     $additionalFields = array();
     if (!$task) {
         $url = GeneralUtility::locationHeaderUrl('/index.php?eID=dd_googlesitemap');
         $task = GeneralUtility::makeInstance('DmitryDulepov\\DdGooglesitemap\\Scheduler\\Task');
     } else {
         $url = $task->getEIdScriptUrl();
     }
     $indexFilePath = $task->getIndexFilePath();
     $maxUrlsPerSitemap = $task->getMaxUrlsPerSitemap();
     $additionalFields['eIdUrl'] = array('code' => '<textarea style="width:350px;height:200px" name="tx_scheduler[eIdUrl]" wrap="off">' . htmlspecialchars($url) . '</textarea>', 'label' => 'LLL:EXT:dd_googlesitemap/locallang.xml:scheduler.eIDFieldLabel', 'cshKey' => '', 'cshLabel' => '');
     $additionalFields['indexFilePath'] = array('code' => '<input class="wide" type="text" name="tx_scheduler[indexFilePath]" value="' . htmlspecialchars($indexFilePath) . '" />', 'label' => 'LLL:EXT:dd_googlesitemap/locallang.xml:scheduler.indexFieldLabel', 'cshKey' => '', 'cshLabel' => '');
     $additionalFields['maxUrlsPerSitemap'] = array('code' => '<input type="text" name="tx_scheduler[maxUrlsPerSitemap]" value="' . $maxUrlsPerSitemap . '" />', 'label' => 'LLL:EXT:dd_googlesitemap/locallang.xml:scheduler.maxUrlsPerSitemapLabel', 'cshKey' => '', 'cshLabel' => '');
     return $additionalFields;
 }
Ejemplo n.º 6
0
 /**
  * Handles the existing files of a Fine Uploader form.
  * The values are stored in the GET/POST var at the index "fieldValue".
  *
  * @return string
  */
 public function getExistingFiles()
 {
     $files = [];
     $fieldValue = GeneralUtility::_GP('fieldValue');
     if ($fieldValue != '') {
         //            $imagePath = GeneralUtility::getFileAbsFileName($fieldValue);
         $imagePath = str_replace('new:', '', $fieldValue);
         $imageName = PathUtility::basename($imagePath);
         $imageDirectoryPath = PathUtility::dirname($imagePath);
         $imageDirectoryPath = PathUtility::getRelativePath(PATH_site, $imageDirectoryPath);
         $imageUrl = GeneralUtility::locationHeaderUrl('/' . $imageDirectoryPath . $imageName);
         if (file_exists($imagePath)) {
             $files[] = ['name' => $imageName, 'uuid' => $imageUrl, 'thumbnailUrl' => $imageUrl];
         }
     }
     return $files;
 }
Ejemplo n.º 7
0
 /**
  * Generates a hashed link and send it with email
  *
  * @param array $user Contains user data
  * @return string Empty string with success, error message with no success
  */
 protected function generateAndSendHash($user)
 {
     $hours = (int) $this->conf['forgotLinkHashValidTime'] > 0 ? (int) $this->conf['forgotLinkHashValidTime'] : 24;
     $validEnd = time() + 3600 * $hours;
     $validEndString = date($this->conf['dateFormat'], $validEnd);
     $hash = md5(GeneralUtility::generateRandomBytes(64));
     $randHash = $validEnd . '|' . $hash;
     $randHashDB = $validEnd . '|' . md5($hash);
     // Write hash to DB
     $res = $this->databaseConnection->exec_UPDATEquery('fe_users', 'uid=' . $user['uid'], array('felogin_forgotHash' => $randHashDB));
     // Send hashlink to user
     $this->conf['linkPrefix'] = -1;
     $isAbsRefPrefix = !empty($this->frontendController->absRefPrefix);
     $isBaseURL = !empty($this->frontendController->baseUrl);
     $isFeloginBaseURL = !empty($this->conf['feloginBaseURL']);
     $link = $this->pi_getPageLink($this->conf['restorePasswordPageUid'], '', array(rawurlencode('tx_femanager_pi1[forgothash]') => $randHash, 'L' => GeneralUtility::_GET('L')));
     // Prefix link if necessary
     if ($isFeloginBaseURL) {
         // First priority, use specific base URL
         // "absRefPrefix" must be removed first, otherwise URL will be prepended twice
         if ($isAbsRefPrefix) {
             $link = substr($link, strlen($this->frontendController->absRefPrefix));
         }
         $link = $this->conf['feloginBaseURL'] . $link;
     } elseif ($isAbsRefPrefix) {
         // Second priority
         // absRefPrefix must not necessarily contain a hostname and URL scheme, so add it if needed
         $link = GeneralUtility::locationHeaderUrl($link);
     } elseif ($isBaseURL) {
         // Third priority
         // Add the global base URL to the link
         $link = $this->frontendController->baseUrlWrap($link);
     } else {
         // No prefix is set, return the error
         return $this->pi_getLL('ll_change_password_nolinkprefix_message');
     }
     // \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($user);
     $this->sendTemplateEmail([$user['email']], ['*****@*****.**'], 'Test subject', 'emailtemplate', ['name' => 'Mila', 'link' => $link]);
     return '';
 }
Ejemplo n.º 8
0
    /**
     * Helper function for render the main JavaScript libraries,
     * currently: RequireJS, jQuery, ExtJS
     *
     * @return string Content with JavaScript libraries
     */
    protected function renderMainJavaScriptLibraries()
    {
        $out = '';
        // Include RequireJS
        if ($this->addRequireJs) {
            // load the paths of the requireJS configuration
            $out .= GeneralUtility::wrapJS('var require = ' . json_encode($this->requireJsConfig)) . LF;
            // directly after that, include the require.js file
            $out .= '<script src="' . $this->processJsFile($this->backPath . $this->requireJsPath . 'require.js') . '" type="text/javascript"></script>' . LF;
        }
        // Include jQuery Core for each namespace, depending on the version and source
        if (!empty($this->jQueryVersions)) {
            foreach ($this->jQueryVersions as $namespace => $jQueryVersion) {
                $out .= $this->renderJqueryScriptTag($jQueryVersion['version'], $jQueryVersion['source'], $namespace);
            }
        }
        // Include extJS
        if ($this->addExtJS) {
            // Use the base adapter all the time
            $out .= '<script src="' . $this->processJsFile($this->backPath . $this->extJsPath . 'adapter/ext-base' . ($this->enableExtJsDebug ? '-debug' : '') . '.js') . '" type="text/javascript"></script>' . LF;
            $out .= '<script src="' . $this->processJsFile($this->backPath . $this->extJsPath . 'ext-all' . ($this->enableExtJsDebug ? '-debug' : '') . '.js') . '" type="text/javascript"></script>' . LF;
            // Add extJS localization
            // Load standard ISO mapping and modify for use with ExtJS
            $localeMap = $this->locales->getIsoMapping();
            $localeMap[''] = 'en';
            $localeMap['default'] = 'en';
            // Greek
            $localeMap['gr'] = 'el_GR';
            // Norwegian Bokmaal
            $localeMap['no'] = 'no_BO';
            // Swedish
            $localeMap['se'] = 'se_SV';
            $extJsLang = isset($localeMap[$this->lang]) ? $localeMap[$this->lang] : $this->lang;
            // @todo autoconvert file from UTF8 to current BE charset if necessary!!!!
            $extJsLocaleFile = $this->extJsPath . 'locale/ext-lang-' . $extJsLang . '.js';
            if (file_exists(PATH_typo3 . $extJsLocaleFile)) {
                $out .= '<script src="' . $this->processJsFile($this->backPath . $extJsLocaleFile) . '" type="text/javascript" charset="utf-8"></script>' . LF;
            }
            // Remove extjs from JScodeLibArray
            unset($this->jsFiles[$this->backPath . $this->extJsPath . 'ext-all.js'], $this->jsFiles[$this->backPath . $this->extJsPath . 'ext-all-debug.js']);
        }
        $this->loadJavaScriptLanguageStrings();
        if (TYPO3_MODE === 'BE') {
            $this->addAjaxUrlsToInlineSettings();
        }
        $inlineSettings = $this->inlineLanguageLabels ? 'TYPO3.lang = ' . json_encode($this->inlineLanguageLabels) . ';' : '';
        $inlineSettings .= $this->inlineSettings ? 'TYPO3.settings = ' . json_encode($this->inlineSettings) . ';' : '';
        if ($this->addExtJS) {
            // Set clear.gif, move it on top, add handler code
            $code = '';
            if (!empty($this->extOnReadyCode)) {
                foreach ($this->extOnReadyCode as $block) {
                    $code .= $block;
                }
            }
            $out .= $this->inlineJavascriptWrap[0] . '
				Ext.ns("TYPO3");
				Ext.BLANK_IMAGE_URL = "' . htmlspecialchars(GeneralUtility::locationHeaderUrl($this->backPath . 'sysext/t3skin/icons/gfx/clear.gif')) . '";
				Ext.SSL_SECURE_URL = "' . htmlspecialchars(GeneralUtility::locationHeaderUrl($this->backPath . 'sysext/t3skin/icons/gfx/clear.gif')) . '";' . LF . $inlineSettings . 'Ext.onReady(function() {' . $code . ' });' . $this->inlineJavascriptWrap[1];
            $this->extOnReadyCode = array();
            // Include TYPO3.l10n object
            if (TYPO3_MODE === 'BE') {
                $out .= '<script src="' . $this->processJsFile($this->backPath . 'sysext/lang/Resources/Public/JavaScript/Typo3Lang.js') . '" type="text/javascript" charset="utf-8"></script>' . LF;
            }
            if ($this->extJScss) {
                if (isset($GLOBALS['TBE_STYLES']['extJS']['all'])) {
                    $this->addCssLibrary($this->backPath . $GLOBALS['TBE_STYLES']['extJS']['all'], 'stylesheet', 'all', '', true);
                } else {
                    $this->addCssLibrary($this->backPath . $this->extJsPath . 'resources/css/ext-all-notheme.css', 'stylesheet', 'all', '', true);
                }
            }
            if ($this->extJStheme) {
                if (isset($GLOBALS['TBE_STYLES']['extJS']['theme'])) {
                    $this->addCssLibrary($this->backPath . $GLOBALS['TBE_STYLES']['extJS']['theme'], 'stylesheet', 'all', '', true);
                } else {
                    $this->addCssLibrary($this->backPath . $this->extJsPath . 'resources/css/xtheme-blue.css', 'stylesheet', 'all', '', true);
                }
            }
        } else {
            // no extJS loaded, but still inline settings
            if ($inlineSettings !== '') {
                // make sure the global TYPO3 is available
                $inlineSettings = 'var TYPO3 = TYPO3 || {};' . CRLF . $inlineSettings;
                $out .= $this->inlineJavascriptWrap[0] . $inlineSettings . $this->inlineJavascriptWrap[1];
                // Add language module only if also jquery is guaranteed to be there
                if (TYPO3_MODE === 'BE' && !empty($this->jQueryVersions)) {
                    $this->loadRequireJsModule('TYPO3/CMS/Lang/Lang');
                }
            }
        }
        return $out;
    }
Ejemplo n.º 9
0
    /**
     * method that adds JS files within the page renderer
     *
     * @param    array $parameters : An array of available parameters while adding JS to the page renderer
     * @param    \TYPO3\CMS\Core\Page\PageRenderer $pageRenderer : The parent object that triggered this hook
     *
     * @return    void
     */
    protected function addJS($parameters, &$pageRenderer)
    {
        $formprotection = FormProtectionFactory::get();
        if (count($parameters['jsFiles'])) {
            if (method_exists($GLOBALS['SOBE']->doc, 'issueCommand')) {
                /** @var \TYPO3\CMS\Backend\Clipboard\Clipboard $clipObj */
                $clipObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Clipboard\\Clipboard');
                // Start clipboard
                $clipObj->initializeClipboard();
                $clipBoardHasContent = FALSE;
                if (isset($clipObj->clipData['normal']['el']) && strpos(key($clipObj->clipData['normal']['el']), 'tt_content') !== FALSE) {
                    $pasteURL = str_replace('&amp;', '&', $clipObj->pasteUrl('tt_content', 'DD_PASTE_UID', 0));
                    if (isset($clipObj->clipData['normal']['mode'])) {
                        $clipBoardHasContent = 'copy';
                    } else {
                        $clipBoardHasContent = 'move';
                    }
                }
                $moveParams = '&cmd[tt_content][DD_DRAG_UID][move]=DD_DROP_UID';
                $moveURL = str_replace('&amp;', '&', htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($moveParams, 1)));
                $copyParams = '&cmd[tt_content][DD_DRAG_UID][copy]=DD_DROP_UID&DDcopy=1';
                $copyURL = str_replace('&amp;', '&', htmlspecialchars($GLOBALS['SOBE']->doc->issueCommand($copyParams, 1)));
                // add JavaScript library
                $pageRenderer->addJsFile($GLOBALS['BACK_PATH'] . ExtensionManagementUtility::extRelPath('gridelements') . 'Resources/Public/Backend/JavaScript/dbNewContentElWizardFixDTM.js', $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '');
                // add JavaScript library
                $pageRenderer->addJsFile($GLOBALS['BACK_PATH'] . ExtensionManagementUtility::extRelPath('gridelements') . 'Resources/Public/Backend/JavaScript/GridElementsDD.js', $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '');
                // add JavaScript library
                $pageRenderer->addJsFile($GLOBALS['BACK_PATH'] . ExtensionManagementUtility::extRelPath('gridelements') . 'Resources/Public/Backend/JavaScript/GridElementsListView.js', $type = 'text/javascript', $compress = TRUE, $forceOnTop = FALSE, $allWrap = '');
                if (!$pageRenderer->getCharSet()) {
                    $pageRenderer->setCharSet($GLOBALS['LANG']->charSet ? $GLOBALS['LANG']->charSet : 'utf-8');
                }
                if (is_array($clipObj->clipData['normal']['el'])) {
                    $arrCBKeys = array_keys($clipObj->clipData['normal']['el']);
                    $intFirstCBEl = str_replace('tt_content|', '', $arrCBKeys[0]);
                }
                // pull locallang_db.xml to JS side - only the tx_gridelements_js-prefixed keys
                $pageRenderer->addInlineLanguageLabelFile('EXT:gridelements/Resources/Private/Language/locallang_db.xml', 'tx_gridelements_js');
                $pRaddExtOnReadyCode = '
					TYPO3.l10n = {
						localize: function(langKey){
							return TYPO3.lang[langKey];
						}
					}
				';
                $allowedCTypesAndGridTypesClassesByColPos = array();
                $layoutSetup = GeneralUtility::callUserFunction('TYPO3\\CMS\\Backend\\View\\BackendLayoutView->getSelectedBackendLayout', intval(GeneralUtility::_GP('id')), $this);
                if (is_array($layoutSetup) && !empty($layoutSetup['__config']['backend_layout.']['rows.'])) {
                    foreach ($layoutSetup['__config']['backend_layout.']['rows.'] as $rows) {
                        foreach ($rows as $row) {
                            if (!empty($layoutSetup['__config']['backend_layout.']['rows.'])) {
                                foreach ($row as $col) {
                                    $classes = '';
                                    if ($col['allowed']) {
                                        $allowed = explode(',', $col['allowed']);
                                        foreach ($allowed as $ctypes) {
                                            $ctypes = trim($ctypes);
                                            if ($ctypes === '*') {
                                                $classes = 't3-allow-all';
                                                break;
                                            } else {
                                                $ctypes = explode(',', $ctypes);
                                                foreach ($ctypes as $ctype) {
                                                    $classes .= 't3-allow-' . $ctype . ' ';
                                                }
                                            }
                                        }
                                    } else {
                                        $classes = 't3-allow-all';
                                    }
                                    if ($col['allowedGridTypes']) {
                                        $allowedGridTypes = explode(',', $col['allowedGridTypes']);
                                        $classes .= 't3-allow-gridelements_pi1 ';
                                        foreach ($allowedGridTypes as $gridTypes) {
                                            $gridTypes = trim($gridTypes);
                                            if ($gridTypes !== '*') {
                                                $gridTypes = explode(',', $gridTypes);
                                                foreach ($gridTypes as $gridType) {
                                                    $classes .= 't3-allow-gridtype-' . $gridType . ' ';
                                                }
                                            }
                                        }
                                    } else {
                                        if ($classes !== 't3-allow-all') {
                                            $classes .= 't3-allow-gridelements_pi1 ';
                                        }
                                    }
                                    $allowedCTypesAndGridTypesClassesByColPos[] = $col['colPos'] . ':' . trim($classes);
                                }
                            }
                        }
                    }
                }
                // add Ext.onReady() code from file
                $modTSconfig = BackendUtility::getModTSconfig((int) GeneralUtility::_GP('id'), 'mod.web_layout');
                $pageRenderer->addExtOnReadyCode($pRaddExtOnReadyCode . "\n\t\t\t\t\t\ttop.pageColumnsAllowedCTypes = '" . join('|', $allowedCTypesAndGridTypesClassesByColPos) . "';\n\t\t\t\t\t\ttop.pasteURL = '" . $pasteURL . "';\n\t\t\t\t\t\ttop.moveURL = '" . $moveURL . "';\n\t\t\t\t\t\ttop.copyURL = '" . $copyURL . "';\n\t\t\t\t\t\ttop.pasteTpl = '" . str_replace('&redirect=1', '', str_replace('DDcopy=1', 'DDcopy=1&reference=DD_REFYN', $copyURL)) . "';\n\t\t\t\t\t\ttop.DDtceActionToken = '" . $formprotection->generateToken('tceAction') . "';\n\t\t\t\t\t\ttop.DDtoken = '" . $formprotection->generateToken('editRecord') . "';\n\t\t\t\t\t\ttop.DDpid = '" . (int) GeneralUtility::_GP('id') . "';\n\t\t\t\t\t\ttop.DDclipboardfilled = '" . ($clipBoardHasContent ? $clipBoardHasContent : 'false') . "';\n\t\t\t\t\t\ttop.pasteReferenceAllowed = '" . ($GLOBALS['BE_USER']->checkAuthMode('tt_content', 'CType', 11, 'explicitAllow') ? 'true' : 'false') . "';\n\t\t\t\t\t\ttop.newElementWizard = '" . ($modTSconfig['properties']['disableNewContentElementWizard'] ? 'false' : 'true') . "';\n\t\t\t\t\t\ttop.DDclipboardElId = '" . $intFirstCBEl . "';\n\t\t\t\t\t" . str_replace(array('top.skipDraggableDetails = 0;', 'insert_ext_baseurl_here', 'insert_server_time_here', 'top.geSprites = {};', "top.backPath = '';"), array($GLOBALS['BE_USER']->uc['dragAndDropHideNewElementWizardInfoOverlay'] ? 'top.skipDraggableDetails = true;' : 'top.skipDraggableDetails = false;', GeneralUtility::locationHeaderUrl('/' . ExtensionManagementUtility::siteRelPath('gridelements')), time() . '000', "top.geSprites = {\n\t\t\t\t\t\t\tcopyfrompage: '" . IconUtility::getSpriteIconClasses('extensions-gridelements-copyfrompage') . "',\n\t\t\t\t\t\t\t\tpastecopy: '" . IconUtility::getSpriteIconClasses('extensions-gridelements-pastecopy') . "',\n\t\t\t\t\t\t\t\tpasteref: '" . IconUtility::getSpriteIconClasses('extensions-gridelements-pasteref') . "'\n\t\t\t\t\t\t\t};", "top.backPath = '" . $GLOBALS['BACK_PATH'] . "';"), file_get_contents(ExtensionManagementUtility::extPath('gridelements') . 'Resources/Public/Backend/JavaScript/GridElementsDD_onReady.js')), TRUE);
            }
        }
    }
Ejemplo n.º 10
0
    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][] = '&ApacheSolrForTypo3\\Solr\\GarbageCollector';
    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = '&ApacheSolrForTypo3\\Solr\\GarbageCollector';
    // hooking into TCE Main to monitor record updates that may require reindexing by the index queue
    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][] = 'ApacheSolrForTypo3\\Solr\\IndexQueue\\RecordMonitor';
    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'ApacheSolrForTypo3\\Solr\\IndexQueue\\RecordMonitor';
}
# ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- #
// register click menu item to initialize the Solr connections for a single site
// visible for admin users only
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig('
[adminUser = 1]
options.contextMenu.table.pages.items.850 = ITEM
options.contextMenu.table.pages.items.850 {
	name = Tx_Solr_initializeSolrConnections
	label = Initialize Solr Connections
	icon = ' . \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl($iconPath . 'InitSolrConnections.png') . '
	displayCondition = getRecord|is_siteroot = 1
	callbackAction = initializeSolrConnections
}

options.contextMenu.table.pages.items.851 = DIVIDER
[global]
');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.Solr.ContextMenuActionController', 'ApacheSolrForTypo3\\Solr\\ContextMenuActionController', 'web', 'admin');
// include JS in backend
$GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems']['Solr.ContextMenuInitializeSolrConnectionsAction'] = $GLOBALS['PATH_solr'] . 'Classes/BackendItem/ContextMenuActionJavascriptRegistration.php';
# ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- #
// replace the built-in search content element
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('*', 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/Results.xml', 'search');
$TCA['tt_content']['types']['search']['showitem'] = '--palette--;LLL:EXT:cms/locallang_ttc.xml:palette.general;general,
	--palette--;LLL:EXT:cms/locallang_ttc.xml:palette.header;header,
Ejemplo n.º 11
0
 /**
  * Handles non-existing postVarSet according to configuration.
  *
  * @param int $pageId
  * @param string $postVarSetKey
  * @param array $pathSegments
  */
 protected function handleNonExistingPostVarSet($pageId, $postVarSetKey, array &$pathSegments)
 {
     $failureMode = $this->configuration->get('init/postVarSet_failureMode');
     if ($failureMode == 'redirect_goodUpperDir') {
         $nonProcessedArray = array($postVarSetKey) + $pathSegments;
         $badPathPart = implode('/', $nonProcessedArray);
         $badPathPartPos = strpos($this->originalPath, $badPathPart);
         $badPathPartLength = strlen($badPathPart);
         if ($badPathPartPos > 0) {
             // We also want to get rid of one slash
             $badPathPartPos--;
             $badPathPartLength++;
         }
         $goodPath = substr($this->originalPath, 0, $badPathPartPos) . substr($this->originalPath, $badPathPartPos + $badPathPartLength);
         @ob_end_clean();
         header(self::REDIRECT_STATUS_HEADER);
         header(self::REDIRECT_INFO_HEADER . ': postVarSet_failureMode redirect for ' . $postVarSetKey);
         header('Location: ' . GeneralUtility::locationHeaderUrl($goodPath));
         exit;
     } elseif ($failureMode == 'ignore') {
         $pathSegments = array();
     } else {
         $this->throw404('Segment "' . $postVarSetKey . '" was not a keyword for a postVarSet as expected on page with id=' . $pageId . '.');
     }
 }
Ejemplo n.º 12
0
function fix_links_callback($matches)
{
    return $matches[1] . \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl($matches[2]) . $matches[3];
}
Ejemplo n.º 13
0
 /**
  * Return a JS array for special anchor classes
  *
  * @return string classesAnchor array definition
  */
 public function buildJSClassesAnchorArray()
 {
     $JSClassesAnchorArray = 'HTMLArea.classesAnchorSetup = [ ' . LF;
     $classesAnchorIndex = 0;
     foreach ($this->configuration['RTEsetup']['properties']['classesAnchor.'] as $label => $conf) {
         if (is_array($conf) && $conf['class']) {
             $JSClassesAnchorArray .= ($classesAnchorIndex++ ? ',' : '') . ' { ' . LF;
             $index = 0;
             $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'name : "' . str_replace('"', '', str_replace('\'', '', $conf['class'])) . '"' . LF;
             if ($conf['type']) {
                 $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'type : "' . str_replace('"', '', str_replace('\'', '', $conf['type'])) . '"' . LF;
             }
             if (trim(str_replace('\'', '', str_replace('"', '', $conf['image'])))) {
                 $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'image : "' . GeneralUtility::locationHeaderUrl(PathUtility::getAbsoluteWebPath(GeneralUtility::getFileAbsFileName(trim(str_replace('\'', '', str_replace('"', '', $conf['image'])))))) . '"' . LF;
             }
             $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'addIconAfterLink : ' . ($conf['addIconAfterLink'] ? 'true' : 'false') . LF;
             if (trim($conf['altText'])) {
                 $string = GeneralUtility::quoteJSvalue($this->getLanguageService()->sL(trim($conf['altText'])));
                 $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'altText : ' . str_replace('"', '\\"', str_replace('\\\'', '\'', $string)) . LF;
             }
             if (trim($conf['titleText'])) {
                 $string = GeneralUtility::quoteJSvalue($this->getLanguageService()->sL(trim($conf['titleText'])));
                 $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'titleText : ' . str_replace('"', '\\"', str_replace('\\\'', '\'', $string)) . LF;
             }
             if (trim($conf['target'])) {
                 $JSClassesAnchorArray .= ($index++ ? ',' : '') . 'target : "' . trim($conf['target']) . '"' . LF;
             }
             $JSClassesAnchorArray .= '}' . LF;
         }
     }
     $JSClassesAnchorArray .= '];' . LF;
     return $JSClassesAnchorArray;
 }
 /**
  * Returns the URL, depending on the type of redirect
  *
  * @return null|string
  */
 public function getUrl()
 {
     $url = null;
     switch ($this->type) {
         // Internal page
         case 0:
             $url = $this->constructUrlForInternalPage();
             break;
             // External URL
         // External URL
         case 1:
             $url = $this->constructUrlForExternal();
             break;
             // Internal file
         // Internal file
         case 2:
             $url = GeneralUtility::locationHeaderUrl($this->internalFile);
             break;
     }
     return $url;
 }
Ejemplo n.º 15
0
 /**
  * Generates a hashed link and send it with email
  *
  * @param array $user Contains user data
  * @return string Empty string with success, error message with no success
  */
 protected function generateAndSendHash($user)
 {
     $hours = (int) $this->conf['forgotLinkHashValidTime'] > 0 ? (int) $this->conf['forgotLinkHashValidTime'] : 24;
     $validEnd = time() + 3600 * $hours;
     $validEndString = date($this->conf['dateFormat'], $validEnd);
     $hash = md5(GeneralUtility::generateRandomBytes(64));
     $randHash = $validEnd . '|' . $hash;
     $randHashDB = $validEnd . '|' . md5($hash);
     // Write hash to DB
     $res = $this->databaseConnection->exec_UPDATEquery('fe_users', 'uid=' . $user['uid'], array('felogin_forgotHash' => $randHashDB));
     // Send hashlink to user
     $this->conf['linkPrefix'] = -1;
     $isAbsRelPrefix = !empty($this->frontendController->absRefPrefix);
     $isBaseURL = !empty($this->frontendController->baseUrl);
     $isFeloginBaseURL = !empty($this->conf['feloginBaseURL']);
     $link = $this->pi_getPageLink($this->frontendController->id, '', array(rawurlencode($this->prefixId . '[user]') => $user['uid'], rawurlencode($this->prefixId . '[forgothash]') => $randHash));
     // Prefix link if necessary
     if ($isFeloginBaseURL) {
         // First priority, use specific base URL
         // "absRefPrefix" must be removed first, otherwise URL will be prepended twice
         if (!empty($this->frontendController->absRefPrefix)) {
             $link = substr($link, strlen($this->frontendController->absRefPrefix));
         }
         $link = $this->conf['feloginBaseURL'] . $link;
     } elseif ($isAbsRelPrefix) {
         // Second priority
         // absRefPrefix must not necessarily contain a hostname and URL scheme, so add it if needed
         $link = GeneralUtility::locationHeaderUrl($link);
     } elseif ($isBaseURL) {
         // Third priority
         // Add the global base URL to the link
         $link = $this->frontendController->baseUrlWrap($link);
     } else {
         // No prefix is set, return the error
         return $this->pi_getLL('ll_change_password_nolinkprefix_message');
     }
     $msg = sprintf($this->pi_getLL('ll_forgot_validate_reset_password'), $user['username'], $link, $validEndString);
     // Add hook for extra processing of mail message
     if (isset($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['forgotPasswordMail']) && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['forgotPasswordMail'])) {
         $params = array('message' => &$msg, 'user' => &$user);
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['felogin']['forgotPasswordMail'] as $reference) {
             if ($reference) {
                 GeneralUtility::callUserFunction($reference, $params, $this);
             }
         }
     }
     if ($user['email']) {
         $this->cObj->sendNotifyEmail($msg, $user['email'], '', $this->conf['email_from'], $this->conf['email_fromName'], $this->conf['replyTo']);
     }
     return '';
 }
 /**
  * Creates a link to a single page
  *
  * @param	array	$pageId	Page ID
  * @return	string	Full URL of the page including host name (escaped)
  */
 protected function getPageLink($pageId)
 {
     $conf = array('parameter' => $pageId, 'returnLast' => 'url');
     $link = htmlspecialchars($this->cObj->typoLink('', $conf));
     return GeneralUtility::locationHeaderUrl($link);
 }
Ejemplo n.º 17
0
 /**
  * Adds the base uri if not already in place.
  *
  * @param string $uri The URI
  * @return string
  */
 protected function addBaseUriIfNecessary($uri)
 {
     return \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl((string) $uri);
 }
Ejemplo n.º 18
0
 /**
  * Creates return URL for the OpenID server. When a user is authenticated by
  * the OpenID server, the user will be sent to this URL to complete
  * authentication process with the current site. We send it to our script.
  *
  * @param string $claimedIdentifier The OpenID identifier for discovery and auth request
  * @return string Return URL
  */
 protected function getReturnURL($claimedIdentifier)
 {
     if ($this->authenticationInformation['loginType'] === 'FE') {
         // We will use eID to send user back, create session data and
         // return to the calling page.
         // Notice: 'pid' and 'logintype' parameter names cannot be changed!
         // They are essential for FE user authentication.
         $returnURL = 'index.php?eID=tx_openid&' . 'pid=' . $this->authenticationInformation['db_user']['checkPidList'] . '&' . 'logintype=login&';
     } else {
         // In the Backend we will use dedicated script to create session.
         // It is much easier for the Backend to manage users.
         // Notice: 'login_status' parameter name cannot be changed!
         // It is essential for BE user authentication.
         $absoluteSiteURL = substr(GeneralUtility::getIndpEnv('TYPO3_SITE_URL'), strlen(GeneralUtility::getIndpEnv('TYPO3_REQUEST_HOST')));
         $returnURL = $absoluteSiteURL . TYPO3_mainDir . 'sysext/' . $this->extKey . '/class.tx_openid_return.php?login_status=login&';
     }
     if (GeneralUtility::_GP('tx_openid_mode') === 'finish') {
         $requestURL = GeneralUtility::_GP('tx_openid_location');
     } else {
         $requestURL = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL');
     }
     $returnURL .= 'tx_openid_location=' . rawurlencode($requestURL) . '&tx_openid_location_signature=' . $this->getSignature($requestURL) . '&tx_openid_mode=finish&tx_openid_claimed=' . rawurlencode($claimedIdentifier) . '&tx_openid_signature=' . $this->getSignature($claimedIdentifier);
     return GeneralUtility::locationHeaderUrl($returnURL);
 }
Ejemplo n.º 19
0
 /**
  * Main method. Starts the magic...
  *
  * @param string $content Content of this plugin
  * @param array $conf TS configuration for this plugin
  *
  * @return string Compiled content
  */
 public function main($content, array $conf = array())
 {
     $this->init($conf);
     if (!$GLOBALS['TSFE']->loginUser) {
         return $this->noUser();
     }
     if (isset($this->piVars['check'])) {
         $formValid = $this->checkAddressForm();
     } else {
         $formValid = FALSE;
     }
     if ($formValid && isset($this->piVars['check']) && (int) $this->piVars['backpid'] != $GLOBALS['TSFE']->id) {
         unset($this->piVars['check']);
         header('Location: ' . \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl($this->pi_getPageLink((int) $this->piVars['backpid'], '', array('tx_commerce_pi3[addressType]' => (int) $this->piVars['addressType'], $this->prefixId . '[addressid]' => (int) $this->piVars['addressid']))));
     }
     switch (strtolower($this->piVars['action'])) {
         case 'new':
             if ($formValid) {
                 $this->sysMessage = $this->pi_getLL('message_address_new');
                 $this->saveAddressData(TRUE, (int) $this->piVars['addressType']);
                 $content .= $this->getListing();
                 break;
             }
             $content .= $this->getAddressForm('new', (int) $this->piVars['addressid'], $this->conf);
             break;
         case 'delete':
             $addresses = $this->getAddresses((int) $this->user['uid'], (int) $this->addresses[$this->piVars['addressid']]['tx_commerce_address_type_id']);
             if (count($addresses) <= $this->conf['minAddressCount']) {
                 $this->sysMessage = $this->pi_getLL('message_cant_delete');
                 $content .= $this->getListing();
                 break;
             }
             if ($this->piVars['confirmed'] == 'yes') {
                 $this->deleteAddress();
                 $content .= $this->getListing();
                 break;
             }
             $content .= $this->deleteAddressQuestion();
             break;
         case 'edit':
             if ($formValid) {
                 $this->sysMessage = $this->pi_getLL('message_address_changed');
                 $content .= $this->getListing();
                 break;
             }
             $content .= $this->getAddressForm('edit', (int) $this->piVars['addressid'], $this->conf);
             break;
         case 'listing':
         default:
             if ($formValid) {
                 $this->saveAddressData(FALSE, (int) $this->piVars['addressType']);
             }
             $content .= $this->getListing();
     }
     // add removal of remaining empty markers
     $content = $this->cObj->substituteMarkerArray($content, array(), '', TRUE, TRUE);
     return $this->pi_wrapInBaseClass($content);
 }
Ejemplo n.º 20
0
 /**
  * Get public url of image depending on the environment
  *
  * @param FileInterface $image
  * @param bool|FALSE $absolute Force absolute URL
  * @return string
  * @api
  */
 public function getImageUri(FileInterface $image, $absolute = false)
 {
     $imageUrl = $image->getPublicUrl();
     $parsedUrl = parse_url($imageUrl);
     // no prefix in case of an already fully qualified URL
     if (isset($parsedUrl['host'])) {
         $uriPrefix = '';
     } elseif ($this->environmentService->isEnvironmentInFrontendMode()) {
         $uriPrefix = $GLOBALS['TSFE']->absRefPrefix;
     } else {
         $uriPrefix = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH');
     }
     if ($absolute) {
         // If full URL has no scheme we add the same scheme as used by the site
         // so we have an absolute URL also usable outside of browser scope (e.g. in an email message)
         if (isset($parsedUrl['host']) && !isset($parsedUrl['scheme'])) {
             $uriPrefix = (GeneralUtility::getIndpEnv('TYPO3_SSL') ? 'https:' : 'http:') . $uriPrefix;
         }
         return GeneralUtility::locationHeaderUrl($uriPrefix . $imageUrl);
     } else {
         return $uriPrefix . $imageUrl;
     }
 }
 /**
  * The main method of the PlugIn
  *
  * @access	public
  *
  * @param	string		$content: The PlugIn content
  * @param	array		$conf: The PlugIn configuration
  *
  * @return	string		The content that is displayed on the website
  */
 public function main($content, $conf)
 {
     $this->init($conf);
     // Disable caching for this plugin.
     $this->setCache(FALSE);
     // Quit without doing anything if required variables are not set.
     if (empty($this->conf['solrcore'])) {
         if (TYPO3_DLOG) {
             \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_search->main(' . $content . ', [data])] Incomplete plugin configuration', $this->extKey, SYSLOG_SEVERITY_WARNING, $conf);
         }
         return $content;
     }
     if (!isset($this->piVars['query']) && empty($this->piVars['extQuery'])) {
         // Add javascript for search suggestions if enabled and jQuery autocompletion is available.
         if (!empty($this->conf['suggest'])) {
             $this->addAutocompleteJS();
         }
         // Load template file.
         if (!empty($this->conf['templateFile'])) {
             $this->template = $this->cObj->getSubpart($this->cObj->fileResource($this->conf['templateFile']), '###TEMPLATE###');
         } else {
             $this->template = $this->cObj->getSubpart($this->cObj->fileResource('EXT:dlf/plugins/search/template.tmpl'), '###TEMPLATE###');
         }
         // Configure @action URL for form.
         $linkConf = array('parameter' => $GLOBALS['TSFE']->id, 'forceAbsoluteUrl' => 1);
         // Fill markers.
         $markerArray = array('###ACTION_URL###' => $this->cObj->typoLink_URL($linkConf), '###LABEL_QUERY###' => $this->pi_getLL('label.query'), '###LABEL_SUBMIT###' => $this->pi_getLL('label.submit'), '###FIELD_QUERY###' => $this->prefixId . '[query]', '###QUERY###' => '', '###FULLTEXTSWITCH###' => $this->addFulltextSwitch(), '###FIELD_DOC###' => $this->conf['searchIn'] == 'document' || $this->conf['searchIn'] == 'all' ? $this->addCurrentDocument() : '', '###FIELD_COLL###' => $this->conf['searchIn'] == 'collection' || $this->conf['searchIn'] == 'all' ? $this->addCurrentCollection() : '', '###ADDITIONAL_INPUTS###' => $this->addEncryptedCoreName(), '###FACETS_MENU###' => $this->addFacetsMenu());
         // Get additional fields for extended search.
         $extendedSearch = $this->addExtendedSearch();
         // Display search form.
         $content .= $this->cObj->substituteSubpart($this->cObj->substituteMarkerArray($this->template, $markerArray), '###EXT_SEARCH_ENTRY###', $extendedSearch);
         return $this->pi_wrapInBaseClass($content);
     } else {
         // Instantiate search object.
         $solr = tx_dlf_solr::getInstance($this->conf['solrcore']);
         if (!$solr->ready) {
             if (TYPO3_DLOG) {
                 \TYPO3\CMS\Core\Utility\GeneralUtility::devLog('[tx_dlf_search->main(' . $content . ', [data])] Apache Solr not available', $this->extKey, SYSLOG_SEVERITY_ERROR, $conf);
             }
             return $content;
         }
         // Build label for result list.
         $label = $this->pi_getLL('search', '', TRUE);
         if (!empty($this->piVars['query'])) {
             $label .= htmlspecialchars(sprintf($this->pi_getLL('for', ''), $this->piVars['query']));
         }
         // Prepare query parameters.
         $params = array();
         // Set search query.
         if (!empty($this->conf['fulltext']) && !empty($this->piVars['fulltext'])) {
             // Search in fulltext field if applicable.
             $query = 'fulltext:(' . tx_dlf_solr::escapeQuery($this->piVars['query']) . ')';
             // Add highlighting for fulltext.
             $params['hl'] = 'true';
             $params['hl.fl'] = 'fulltext';
         } else {
             // Retain given search field if valid.
             $query = tx_dlf_solr::escapeQueryKeepField($this->piVars['query'], $this->conf['pages']);
         }
         // Add extended search query.
         if (!empty($this->piVars['extQuery']) && is_array($this->piVars['extQuery'])) {
             $allowedOperators = array('AND', 'OR', 'NOT');
             $allowedFields = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $this->conf['extendedFields'], TRUE);
             for ($i = 0; $i < count($this->piVars['extQuery']); $i++) {
                 if (!empty($this->piVars['extQuery'][$i])) {
                     if (in_array($this->piVars['extOperator'][$i], $allowedOperators) && in_array($this->piVars['extField'][$i], $allowedFields)) {
                         if (!empty($query)) {
                             $query .= ' ' . $this->piVars['extOperator'][$i] . ' ';
                         }
                         $query .= tx_dlf_indexing::getIndexFieldName($this->piVars['extField'][$i], $this->conf['pages']) . ':(' . tx_dlf_solr::escapeQuery($this->piVars['extQuery'][$i]) . ')';
                     }
                 }
             }
         }
         // Add filter query for faceting.
         if (!empty($this->piVars['fq'])) {
             $params['fq'] = $this->piVars['fq'];
         }
         // Add filter query for in-document searching.
         if ($this->conf['searchIn'] == 'document' || $this->conf['searchIn'] == 'all') {
             if (!empty($this->piVars['id']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->piVars['id'])) {
                 $params['fq'][] = 'uid:(' . $this->piVars['id'] . ') OR partof:(' . $this->piVars['id'] . ')';
                 $label .= htmlspecialchars(sprintf($this->pi_getLL('in', ''), tx_dlf_document::getTitle($this->piVars['id'])));
             }
         }
         // Add filter query for in-collection searching.
         if ($this->conf['searchIn'] == 'collection' || $this->conf['searchIn'] == 'all') {
             if (!empty($this->piVars['collection']) && \TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($this->piVars['collection'])) {
                 $index_name = tx_dlf_helper::getIndexName($this->piVars['collection'], 'tx_dlf_collections', $this->conf['pages']);
                 $params['fq'][] = 'collection_faceting:("' . tx_dlf_solr::escapeQuery($index_name) . '")';
                 $label .= sprintf($this->pi_getLL('in', '', TRUE), tx_dlf_helper::translate($index_name, 'tx_dlf_collections', $this->conf['pages']));
             }
         }
         // Add filter query for collection restrictions.
         if ($this->conf['collections']) {
             $collIds = explode(',', $this->conf['collections']);
             $collIndexNames = array();
             foreach ($collIds as $collId) {
                 $collIndexNames[] = tx_dlf_solr::escapeQuery(tx_dlf_helper::getIndexName(intval($collId), 'tx_dlf_collections', $this->conf['pages']));
             }
             // Last value is fake and used for distinction in $this->addCurrentCollection()
             $params['fq'][] = 'collection_faceting:("' . implode('" OR "', $collIndexNames) . '" OR "FakeValueForDistinction")';
         }
         // Set search parameters.
         $solr->limit = max(intval($this->conf['limit']), 1);
         $solr->cPid = $this->conf['pages'];
         $solr->params = $params;
         // Perform search.
         $results = $solr->search($query);
         $results->metadata = array('label' => $label, 'description' => '<p class="tx-dlf-search-numHits">' . htmlspecialchars(sprintf($this->pi_getLL('hits', ''), $solr->numberOfHits, count($results))) . '</p>', 'thumbnail' => '', 'options' => $results->metadata['options']);
         $results->save();
         // Clean output buffer.
         \TYPO3\CMS\Core\Utility\GeneralUtility::cleanOutputBuffers();
         // Keep some plugin variables.
         $linkConf['parameter'] = $this->conf['targetPid'];
         if (!empty($this->piVars['order'])) {
             $linkConf['additionalParams'] = \TYPO3\CMS\Core\Utility\GeneralUtility::implodeArrayForUrl($this->prefixId, array('order' => $this->piVars['order'], 'asc' => !empty($this->piVars['asc']) ? '1' : '0'), '', TRUE, FALSE);
         }
         // Send headers.
         header('Location: ' . \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl($this->cObj->typoLink_URL($linkConf)));
         // Flush output buffer and end script processing.
         ob_end_flush();
         exit;
     }
 }
Ejemplo n.º 22
0
    /**
     * Helper function for render the main JavaScript libraries,
     * currently: RequireJS, jQuery, PrototypeJS, Scriptaculous, SVG, ExtJs
     *
     * @return string Content with JavaScript libraries
     */
    protected function renderMainJavaScriptLibraries()
    {
        $out = '';
        // Include RequireJS
        if ($this->addRequireJs) {
            // load the paths of the requireJS configuration
            $out .= GeneralUtility::wrapJS('var require = ' . json_encode($this->requireJsConfig)) . LF;
            // directly after that, include the require.js file
            $out .= '<script src="' . $this->processJsFile($this->backPath . $this->requireJsPath . 'require.js') . '" type="text/javascript"></script>' . LF;
        }
        if ($this->addSvg) {
            $out .= '<script src="' . $this->processJsFile($this->backPath . $this->svgPath . 'svg.js') . '" data-path="' . $this->backPath . $this->svgPath . '"' . ($this->enableSvgDebug ? ' data-debug="true"' : '') . '></script>' . LF;
        }
        // Include jQuery Core for each namespace, depending on the version and source
        if (!empty($this->jQueryVersions)) {
            foreach ($this->jQueryVersions as $namespace => $jQueryVersion) {
                $out .= $this->renderJqueryScriptTag($jQueryVersion['version'], $jQueryVersion['source'], $namespace);
            }
        }
        if ($this->addPrototype) {
            $out .= '<script src="' . $this->processJsFile($this->backPath . $this->prototypePath . 'prototype.js') . '" type="text/javascript"></script>' . LF;
            unset($this->jsFiles[$this->backPath . $this->prototypePath . 'prototype.js']);
        }
        if ($this->addScriptaculous) {
            $mods = array();
            foreach ($this->addScriptaculousModules as $key => $value) {
                if ($this->addScriptaculousModules[$key]) {
                    $mods[] = $key;
                }
            }
            // Resolve dependencies
            if (in_array('dragdrop', $mods) || in_array('controls', $mods)) {
                $mods = array_merge(array('effects'), $mods);
            }
            if (count($mods)) {
                foreach ($mods as $module) {
                    $out .= '<script src="' . $this->processJsFile($this->backPath . $this->scriptaculousPath . $module . '.js') . '" type="text/javascript"></script>' . LF;
                    unset($this->jsFiles[$this->backPath . $this->scriptaculousPath . $module . '.js']);
                }
            }
            $out .= '<script src="' . $this->processJsFile($this->backPath . $this->scriptaculousPath . 'scriptaculous.js') . '" type="text/javascript"></script>' . LF;
            unset($this->jsFiles[$this->backPath . $this->scriptaculousPath . 'scriptaculous.js']);
        }
        // Include extCore, but only if ExtJS is not included
        if ($this->addExtCore && !$this->addExtJS) {
            $out .= '<script src="' . $this->processJsFile($this->backPath . $this->extCorePath . 'ext-core' . ($this->enableExtCoreDebug ? '-debug' : '') . '.js') . '" type="text/javascript"></script>' . LF;
            unset($this->jsFiles[$this->backPath . $this->extCorePath . 'ext-core' . ($this->enableExtCoreDebug ? '-debug' : '') . '.js']);
        }
        // Include extJS
        if ($this->addExtJS) {
            // Use the base adapter all the time
            $out .= '<script src="' . $this->processJsFile($this->backPath . $this->extJsPath . 'adapter/' . ($this->enableExtJsDebug ? str_replace('.js', '-debug.js', $this->extJSadapter) : $this->extJSadapter)) . '" type="text/javascript"></script>' . LF;
            $out .= '<script src="' . $this->processJsFile($this->backPath . $this->extJsPath . 'ext-all' . ($this->enableExtJsDebug ? '-debug' : '') . '.js') . '" type="text/javascript"></script>' . LF;
            // Add extJS localization
            // Load standard ISO mapping and modify for use with ExtJS
            $localeMap = $this->locales->getIsoMapping();
            $localeMap[''] = 'en';
            $localeMap['default'] = 'en';
            // Greek
            $localeMap['gr'] = 'el_GR';
            // Norwegian Bokmaal
            $localeMap['no'] = 'no_BO';
            // Swedish
            $localeMap['se'] = 'se_SV';
            $extJsLang = isset($localeMap[$this->lang]) ? $localeMap[$this->lang] : $this->lang;
            // TODO autoconvert file from UTF8 to current BE charset if necessary!!!!
            $extJsLocaleFile = $this->extJsPath . 'locale/ext-lang-' . $extJsLang . '.js';
            if (file_exists(PATH_typo3 . $extJsLocaleFile)) {
                $out .= '<script src="' . $this->processJsFile($this->backPath . $extJsLocaleFile) . '" type="text/javascript" charset="utf-8"></script>' . LF;
            }
            // Remove extjs from JScodeLibArray
            unset($this->jsFiles[$this->backPath . $this->extJsPath . 'ext-all.js'], $this->jsFiles[$this->backPath . $this->extJsPath . 'ext-all-debug.js']);
        }
        if (count($this->inlineLanguageLabelFiles)) {
            foreach ($this->inlineLanguageLabelFiles as $languageLabelFile) {
                $this->includeLanguageFileForInline($languageLabelFile['fileRef'], $languageLabelFile['selectionPrefix'], $languageLabelFile['stripFromSelectionName'], $languageLabelFile['$errorMode']);
            }
        }
        $this->inlineLanguageLabelFiles = array();
        // Convert labels/settings back to UTF-8 since json_encode() only works with UTF-8:
        if ($this->getCharSet() !== 'utf-8') {
            if ($this->inlineLanguageLabels) {
                $this->csConvObj->convArray($this->inlineLanguageLabels, $this->getCharSet(), 'utf-8');
            }
            if ($this->inlineSettings) {
                $this->csConvObj->convArray($this->inlineSettings, $this->getCharSet(), 'utf-8');
            }
        }
        if (TYPO3_MODE === 'BE') {
            $this->addAjaxUrlsToInlineSettings();
        }
        $inlineSettings = $this->inlineLanguageLabels ? 'TYPO3.lang = ' . json_encode($this->inlineLanguageLabels) . ';' : '';
        $inlineSettings .= $this->inlineSettings ? 'TYPO3.settings = ' . json_encode($this->inlineSettings) . ';' : '';
        if ($this->addExtCore || $this->addExtJS) {
            // Set clear.gif, move it on top, add handler code
            $code = '';
            if (count($this->extOnReadyCode)) {
                foreach ($this->extOnReadyCode as $block) {
                    $code .= $block;
                }
            }
            $out .= $this->inlineJavascriptWrap[0] . '
				Ext.ns("TYPO3");
				Ext.BLANK_IMAGE_URL = "' . htmlspecialchars(GeneralUtility::locationHeaderUrl($this->backPath . 'gfx/clear.gif')) . '";' . LF . $inlineSettings . 'Ext.onReady(function() {' . ($this->enableExtJSQuickTips ? 'Ext.QuickTips.init();' . LF : '') . $code . ' });' . $this->inlineJavascriptWrap[1];
            $this->extOnReadyCode = array();
            // Include TYPO3.l10n object
            if (TYPO3_MODE === 'BE') {
                $out .= '<script src="' . $this->processJsFile($this->backPath . 'sysext/lang/Resources/Public/JavaScript/Typo3Lang.js') . '" type="text/javascript" charset="utf-8"></script>' . LF;
            }
            if ($this->extJScss) {
                if (isset($GLOBALS['TBE_STYLES']['extJS']['all'])) {
                    $this->addCssLibrary($this->backPath . $GLOBALS['TBE_STYLES']['extJS']['all'], 'stylesheet', 'all', '', TRUE);
                } else {
                    $this->addCssLibrary($this->backPath . $this->extJsPath . 'resources/css/ext-all-notheme.css', 'stylesheet', 'all', '', TRUE);
                }
            }
            if ($this->extJStheme) {
                if (isset($GLOBALS['TBE_STYLES']['extJS']['theme'])) {
                    $this->addCssLibrary($this->backPath . $GLOBALS['TBE_STYLES']['extJS']['theme'], 'stylesheet', 'all', '', TRUE);
                } else {
                    $this->addCssLibrary($this->backPath . $this->extJsPath . 'resources/css/xtheme-blue.css', 'stylesheet', 'all', '', TRUE);
                }
            }
        } else {
            // no extJS loaded, but still inline settings
            if ($inlineSettings !== '') {
                // make sure the global TYPO3 is available
                $inlineSettings = 'var TYPO3 = TYPO3 || {};' . CRLF . $inlineSettings;
                $out .= $this->inlineJavascriptWrap[0] . $inlineSettings . $this->inlineJavascriptWrap[1];
            }
        }
        return $out;
    }
Ejemplo n.º 23
0
 /**
  * Redirects to a specified page or URL.
  *
  * @param mixed $redirect Page id or URL to redirect to
  * @param boolean $correctRedirectUrl replace &amp; with & in URL
  * @return void
  */
 public function doRedirect($redirect, $correctRedirectUrl, $additionalParams = [], $headerStatusCode = '')
 {
     // these parameters have to be added to the redirect url
     $addParams = [];
     if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('L')) {
         $addParams['L'] = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('L');
     }
     if (is_array($additionalParams)) {
         foreach ($additionalParams as $param => $value) {
             if (FALSE === strpos($param, '.')) {
                 if (is_array($additionalParams[$param . '.'])) {
                     $value = $this->getSingle($additionalParams, $param);
                 }
                 $addParams[$param] = $value;
             }
         }
     }
     $url = $this->globals->getCObj()->getTypoLink_URL($redirect, $addParams);
     //correct the URL by replacing &amp;
     if ($correctRedirectUrl) {
         $url = str_replace('&amp;', '&', $url);
     }
     if ($url) {
         if (!$this->globals->isAjaxMode()) {
             $status = '303 See Other';
             if ($headerStatusCode) {
                 $status = $headerStatusCode;
             }
             header('Status: ' . $status);
             header('Location: ' . \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl($url));
         } else {
             print '{' . json_encode('redirect') . ':' . json_encode(\TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl($url)) . '}';
             exit;
         }
     }
 }
 /**
  * @param $path
  * @return mixed
  * @seee t3lib_div::locationHeaderUrl()
  */
 public function locationHeaderUrl($path)
 {
     return GeneralUtility::locationHeaderUrl($path);
 }
Ejemplo n.º 25
0
    /**
     * Creates and returns the HTML code for the Admin Panel in the TSFE frontend.
     *
     * @throws \UnexpectedValueException
     * @return string HTML for the Admin Panel
     */
    public function display()
    {
        $this->getLanguageService()->includeLLFile('EXT:lang/locallang_tsfe.xlf');
        $moduleContent = $updateButton = '';
        if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_top']) {
            if ($this->isAdminModuleEnabled('preview')) {
                $moduleContent .= $this->getPreviewModule();
            }
            if ($this->isAdminModuleEnabled('cache')) {
                $moduleContent .= $this->getCacheModule();
            }
            if ($this->isAdminModuleEnabled('edit')) {
                $moduleContent .= $this->getEditModule();
            }
            if ($this->isAdminModuleEnabled('tsdebug')) {
                $moduleContent .= $this->getTSDebugModule();
            }
            if ($this->isAdminModuleEnabled('info')) {
                $moduleContent .= $this->getInfoModule();
            }
        }
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_adminpanel.php']['extendAdminPanel'] as $classRef) {
                $hookObject = GeneralUtility::getUserObj($classRef);
                if (!$hookObject instanceof AdminPanelViewHookInterface) {
                    throw new \UnexpectedValueException('$hookObject must implement interface TYPO3\\CMS\\Frontend\\View\\AdminPanelViewHookInterface', 1311942539);
                }
                $moduleContent .= $hookObject->extendAdminPanel($moduleContent, $this);
            }
        }
        $row = $this->extGetLL('adminPanelTitle') . ': <span class="typo3-adminPanel-beuser">' . htmlspecialchars($this->getBackendUser()->user['username']) . '</span>';
        $isVisible = $this->getBackendUser()->uc['TSFE_adminConfig']['display_top'];
        $cssClassName = 'typo3-adminPanel-panel-' . ($isVisible ? 'open' : 'closed');
        $header = '<div class="typo3-adminPanel-header">' . '<div id="typo3-adminPanel-header" class="' . $cssClassName . '">' . '<span class="typo3-adminPanel-header-title">' . $row . '</span>' . $this->linkSectionHeader('top', '<span class="typo3-adminPanel-header-button fa"></span>', 'typo3-adminPanel-header-buttonWrapper') . '<input type="hidden" name="TSFE_ADMIN_PANEL[display_top]" value="' . $this->getBackendUser()->uc['TSFE_adminConfig']['display_top'] . '" /></div>' . '</div>';
        if ($moduleContent && $this->extNeedUpdate) {
            $updateButton = '<div class="typo3-adminPanel-itemRow updatebutton"><div class="typo3-adminPanel-section-content">
							<input class="btn btn-default" type="submit" value="' . $this->extGetLL('update') . '" />
					</div></div>';
        }
        $query = !GeneralUtility::_GET('id') ? '<input type="hidden" name="id" value="' . $this->getTypoScriptFrontendController()->id . '" />' : '';
        // The dummy field is needed for Firefox: to force a page reload on submit
        // which must change the form value with JavaScript (see "onsubmit" attribute of the "form" element")
        $query .= '<input type="hidden" name="TSFE_ADMIN_PANEL[DUMMY]" value="" />';
        foreach (GeneralUtility::_GET() as $key => $value) {
            if ($key != 'TSFE_ADMIN_PANEL') {
                if (is_array($value)) {
                    $query .= $this->getHiddenFields($key, $value);
                } else {
                    $query .= '<input type="hidden" name="' . htmlspecialchars($key) . '" value="' . htmlspecialchars($value) . '" />';
                }
            }
        }
        $out = '
<!--
	TYPO3 Admin panel start
-->
<a id="TSFE_ADMIN_PANEL"></a>
<form id="TSFE_ADMIN_PANEL_FORM" name="TSFE_ADMIN_PANEL_FORM" action="' . htmlspecialchars(GeneralUtility::getIndpEnv('TYPO3_REQUEST_SCRIPT')) . '#TSFE_ADMIN_PANEL" method="get" onsubmit="document.forms.TSFE_ADMIN_PANEL_FORM[\'TSFE_ADMIN_PANEL[DUMMY]\'].value=Math.random().toString().substring(2,8)">' . $query . '<div class="typo3-adminPanel">' . $header . $updateButton . $moduleContent . '</div></form>';
        if ($this->getBackendUser()->uc['TSFE_adminConfig']['display_top']) {
            $out .= '<script type="text/javascript" src="' . htmlspecialchars($this->getTypoScriptFrontendController()->absRefPrefix) . ExtensionManagementUtility::siteRelPath('backend') . 'Resources/Public/JavaScript/jsfunc.evalfield.js"></script>';
            $out .= '<script type="text/javascript">/*<![CDATA[*/' . GeneralUtility::minifyJavaScript('
				var evalFunc = new evalFunc();
					// TSFEtypo3FormFieldSet()
				function TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue) {	//
					var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
					var theValue = document.TSFE_ADMIN_PANEL_FORM[theField].value;
					if (checkbox && theValue==checkboxValue) {
						document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value="";
						alert(theField);
						document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "";
					} else {
						document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value = evalFunc.outputObjValue(theFObj, theValue);
						if (document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"]) {
							document.TSFE_ADMIN_PANEL_FORM[theField+"_cb"].checked = "on";
						}
					}
				}
					// TSFEtypo3FormFieldGet()
				function TSFEtypo3FormFieldGet(theField, evallist, is_in, checkbox, checkboxValue, checkbox_off) {	//
					var theFObj = new evalFunc_dummy (evallist,is_in, checkbox, checkboxValue);
					if (checkbox_off) {
						document.TSFE_ADMIN_PANEL_FORM[theField].value=checkboxValue;
					}else{
						document.TSFE_ADMIN_PANEL_FORM[theField].value = evalFunc.evalObjValue(theFObj, document.TSFE_ADMIN_PANEL_FORM[theField+"_hr"].value);
					}
					TSFEtypo3FormFieldSet(theField, evallist, is_in, checkbox, checkboxValue);
				}') . '/*]]>*/</script><script language="javascript" type="text/javascript">' . $this->extJSCODE . '</script>';
        }
        $cssPath = htmlspecialchars($this->getTypoScriptFrontendController()->absRefPrefix . ExtensionManagementUtility::siteRelPath('frontend')) . 'Resources/Public/Css/admin_panel.css';
        $out .= '<script src="' . GeneralUtility::locationHeaderUrl(ExtensionManagementUtility::siteRelPath('frontend') . 'Resources/Public/JavaScript/AdminPanel.js') . '" type="text/javascript"></script><script type="text/javascript">/*<![CDATA[*/' . 'typo3AdminPanel = new TYPO3AdminPanel();typo3AdminPanel.init("typo3-adminPanel-header", "TSFE_ADMIN_PANEL_FORM");' . '/*]]>*/</script>
<link type="text/css" rel="stylesheet" href="' . $cssPath . '" media="all" />
<!--
	TYPO3 admin panel end
-->
';
        return $out;
    }
Ejemplo n.º 26
0
 /**
  * Sends a redirect header response and exits. Additionally the URL is
  * checked and if needed corrected to match the format required for a
  * Location redirect header. By default the HTTP status code sent is
  * a 'HTTP/1.1 303 See Other'.
  *
  * @param string $url The target URL to redirect to
  * @param string $httpStatus An optional HTTP status header. Default is 'HTTP/1.1 303 See Other'
  */
 public static function redirect($url, $httpStatus = self::HTTP_STATUS_303)
 {
     self::setResponseCode($httpStatus);
     header('Location: ' . \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl($url));
     die;
 }
Ejemplo n.º 27
0
 /**
  * Update the pageTS
  * No return value: sent header to the same page
  *
  * @return void
  */
 public function updatePageTS()
 {
     if ($GLOBALS["BE_USER"]->doesUserHaveAccess(BackendUtility::getRecord('pages', $this->id), 2)) {
         $pageTypoScript = GeneralUtility::_GP('pageTS');
         if (is_array($pageTypoScript)) {
             DirectMailUtility::updatePagesTSconfig($this->id, $pageTypoScript, $this->TSconfPrefix);
             header('Location: ' . GeneralUtility::locationHeaderUrl(GeneralUtility::getIndpEnv('REQUEST_URI')));
         }
     }
 }
Ejemplo n.º 28
0
 /**
  * function includeJavascript
  */
 public function addHeaderParts()
 {
     // build target URL if not result page
     unset($linkconf);
     $linkconf['parameter'] = $this->conf['resultPage'];
     $linkconf['additionalParams'] = '';
     $linkconf['useCacheHash'] = false;
     $targetUrl = GeneralUtility::locationHeaderUrl($this->cObj->typoLink_URL($linkconf));
     $content = $this->cObj->getSubpart($this->templateCode, '###JS_SEARCH_ALL###');
     if ($this->conf['renderMethod'] != 'static') {
         $content .= $this->cObj->getSubpart($this->templateCode, '###JS_SEARCH_NON_STATIC###');
     }
     // include js for "ajax after page reload" mode
     if ($this->conf['renderMethod'] == 'ajax_after_reload') {
         $content .= $this->cObj->getSubpart($this->templateCode, '###JS_SEARCH_AJAX_RELOAD###');
     }
     // loop through LL and fill $markerArray
     array_key_exists($this->LLkey, $this->LOCAL_LANG) ? $langKey = $this->LLkey : ($langKey = 'default');
     foreach ($this->LOCAL_LANG[$langKey] as $key => $value) {
         $markerArray['###' . strtoupper($key) . '###'] = $value;
     }
     // define some additional markers
     $markerArray['###SITE_REL_PATH###'] = ExtensionManagementUtility::siteRelPath($this->extKey);
     $markerArray['###TARGET_URL###'] = $targetUrl;
     $markerArray['###PREFIX_ID###'] = $this->prefixId;
     $markerArray['###SEARCHBOX_DEFAULT_VALUE###'] = $this->pi_getLL('searchbox_default_value');
     $markerArray['###DOMREADYACTION###'] = $this->onDomReady;
     $content = $this->cObj->substituteMarkerArray($content, $markerArray);
     // add JS to page header
     $GLOBALS['TSFE']->getPageRenderer()->addHeaderData($content);
 }
Ejemplo n.º 29
0
    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][] = '&Tx_Solr_GarbageCollector';
    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = '&Tx_Solr_GarbageCollector';
    // hooking into TCE Main to monitor record updates that may require reindexing by the index queue
    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processCmdmapClass'][] = 'Tx_Solr_IndexQueue_RecordMonitor';
    $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tcemain.php']['processDatamapClass'][] = 'Tx_Solr_IndexQueue_RecordMonitor';
}
# ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- #
// register click menu item to initialize the Solr connections for a single site
// visible for admin users only
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addUserTSConfig('
[adminUser = 1]
options.contextMenu.table.pages.items.850 = ITEM
options.contextMenu.table.pages.items.850 {
	name = Tx_Solr_initializeSolrConnections
	label = Initialize Solr Connections
	icon = ' . \TYPO3\CMS\Core\Utility\GeneralUtility::locationHeaderUrl($GLOBALS['PATHrel_solr'] . 'Resources/Images/cache-init-solr-connections.png') . '
	displayCondition = getRecord|is_siteroot = 1
	callbackAction = initializeSolrConnections
}

options.contextMenu.table.pages.items.851 = DIVIDER
[global]
');
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::registerExtDirectComponent('TYPO3.Solr.ContextMenuActionController', $GLOBALS['PATHrel_solr'] . 'Classes/ContextMenuActionController.php:Tx_Solr_ContextMenuActionController', 'web', 'admin');
// include JS in backend
$GLOBALS['TYPO3_CONF_VARS']['typo3/backend.php']['additionalBackendItems']['Solr.ContextMenuInitializeSolrConnectionsAction'] = $GLOBALS['PATH_solr'] . 'Classes/BackendItem/ContextMenuActionJavascriptRegistration.php';
# ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- #
// replace the built-in search content element
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPiFlexFormValue('*', 'FILE:EXT:' . $_EXTKEY . '/Configuration/FlexForms/Results.xml', 'search');
$TCA['tt_content']['types']['search']['showitem'] = '--palette--;LLL:EXT:cms/locallang_ttc.xml:palette.general;general,
	--palette--;LLL:EXT:cms/locallang_ttc.xml:palette.header;header,
Ejemplo n.º 30
0
    /**
     * Convert a page path to an ID.
     *
     * @param array $pathParts Array of segments from virtual path
     * @return integer Page ID
     * @see decodeSpURL_idFromPath()
     */
    protected function pagePathtoID(&$pathParts)
    {
        $row = $postVar = false;
        $copy_pathParts = array();
        // If pagePath cache is not disabled, look for entry
        if (!$this->conf['disablePathCache']) {
            // Work from outside-in to look up path in cache
            $postVar = false;
            $copy_pathParts = $pathParts;
            $charset = $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] ? $GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] : $GLOBALS['TSFE']->defaultCharSet;
            foreach ($copy_pathParts as $key => $value) {
                $copy_pathParts[$key] = $GLOBALS['TSFE']->csConvObj->conv_case($charset, $value, 'toLower');
            }
            while (count($copy_pathParts)) {
                // Using pathq1 index!
                /** @noinspection PhpUndefinedMethodInspection */
                list($row) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('tx_realurl_pathcache.*', 'tx_realurl_pathcache,pages', 'tx_realurl_pathcache.page_id=pages.uid AND pages.deleted=0' . ' AND rootpage_id=' . intval($this->conf['rootpage_id']) . ' AND pagepath=' . $GLOBALS['TYPO3_DB']->fullQuoteStr(implode('/', $copy_pathParts), 'tx_realurl_pathcache'), '', 'expire', '1');
                // This lookup does not include language and MP var since those are supposed to be fully reflected in the built url!
                if (is_array($row)) {
                    break;
                }
                // If no row was found, we simply pop off one element of the path and try again until there are no more elements in the array - which means we didn't find a match!
                $postVar = array_pop($copy_pathParts);
            }
        }
        // It could be that entry point to a page but it is not in the cache. If we popped
        // any items from path parts, we need to check if they are defined as postSetVars or
        // fixedPostVars on this page. This does not guarantie 100% success. For example,
        // if path to page is /hello/world/how/are/you and hello/world found in cache and
        // there is a postVar 'how' on this page, the check below will not work. But it is still
        // better than nothing.
        if ($row && $postVar) {
            $postVars = $this->pObj->getPostVarSetConfig($row['page_id'], 'postVarSets');
            if (!is_array($postVars) || !isset($postVars[$postVar])) {
                // Check fixed
                $postVars = $this->pObj->getPostVarSetConfig($row['page_id'], 'fixedPostVars');
                if (!is_array($postVars) || !isset($postVars[$postVar])) {
                    // Not a postVar, so page most likely in not in cache. Clear row.
                    // TODO It would be great to update cache in this case but usually TYPO3 is not
                    // complitely initialized at this place. So we do not do it...
                    $row = false;
                }
            }
        }
        // Process row if found
        if ($row) {
            // We found it in the cache
            // Check for expiration. We can get one of three
            //   1. expire = 0
            //   2. expire <= time()
            //   3. expire > time()
            // 1 is permanent, we do not process it. 2 is expired, we look for permanent or non-expired
            // (in this order!) entry for the same page od and redirect to corresponding path. 3 - same as
            // 1 but means that entry is going to expire eventually, nothing to do for us yet.
            if ($row['expire'] > 0) {
                $this->pObj->devLog('pagePathToId found row', $row);
                // 'expire' in the query is only for logging
                // Using pathq2 index!
                /** @noinspection PhpUndefinedMethodInspection */
                list($newEntry) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('pagepath,expire', 'tx_realurl_pathcache', 'page_id=' . intval($row['page_id']) . '
						AND language_id=' . intval($row['language_id']) . '
						AND (expire=0 OR expire>' . $row['expire'] . ')', '', 'expire', '1');
                $this->pObj->devLog('pagePathToId searched for new entry', $newEntry);
                // Redirect to new path immediately if it is found
                if ($newEntry) {
                    // Replace path-segments with new ones
                    $originalDirs = $this->pObj->dirParts;
                    // All original
                    $cp_pathParts = $pathParts;
                    // Popping of pages of original dirs (as many as are remaining in $pathParts)
                    for ($a = 0; $a < count($pathParts); $a++) {
                        array_pop($originalDirs);
                        // Finding all preVars here
                    }
                    for ($a = 0; $a < count($copy_pathParts); $a++) {
                        array_shift($cp_pathParts);
                        // Finding all postVars here
                    }
                    $newPathSegments = explode('/', $newEntry['pagepath']);
                    // Split new pagepath into segments.
                    $newUrlSegments = array_merge($originalDirs, $newPathSegments, $cp_pathParts);
                    // Merge those segments.
                    $this->pObj->appendFilePart($newUrlSegments);
                    $redirectUrl = implode('/', $newUrlSegments);
                    header('HTTP/1.1 301 TYPO3 RealURL Redirect A' . __LINE__);
                    header('Location: ' . GeneralUtility::locationHeaderUrl($redirectUrl));
                    exit;
                }
                $this->pObj->disableDecodeCache = true;
                // Do not cache this!
            }
            // Unshift the number of segments that must have defined the page
            $cc = count($copy_pathParts);
            for ($a = 0; $a < $cc; $a++) {
                array_shift($pathParts);
            }
            // Assume we can use this info at first
            $id = $row['page_id'];
            $GET_VARS = $row['mpvar'] ? array('MP' => $row['mpvar']) : '';
        } else {
            // Find it
            list($id, $GET_VARS) = $this->findIDByURL($pathParts);
        }
        // Return found ID
        return array($id, $GET_VARS);
    }