/** * Create Sitemap * * @return string Text Sitemap */ protected function createSitemap() { $ret = array(); foreach ($this->sitemapPages as $sitemapPage) { if (empty($this->pages[$sitemapPage['page_uid']])) { // invalid page continue; } $page = $this->pages[$sitemapPage['page_uid']]; $ret[] = t3lib_div::locationHeaderUrl($sitemapPage['page_url']); } return implode("\n", $ret); }
/** * The main method of the PlugIn * * @param string $content: The PlugIn content * @param array $conf: The PlugIn configuration * @return The content that is displayed on the website */ function main($content, $conf) { /* -------------------------------------------------- Detect Startpage -------------------------------------------------- */ $startpage = false; // is_siteroot if ($conf['startpage']) { if ($GLOBALS['TSFE']->page['is_siteroot']) { $startpage = true; } else { // shortcut from is_siteroot foreach ($GLOBALS['TSFE']->rootLine as $page) { if ($page['is_siteroot'] && $page['doktype'] == 4 && $page['shortcut'] == $GLOBALS['TSFE']->id) { $startpage = true; break; } } } // Multilingual startpage if ($startpage) { $startlinks = explode(';', $conf['startpage']); if (sizeof($startlinks) > 1) { $startlink = $startlinks[intval($_GET['L'])]; } else { $startlink = $startlinks[0]; } } } $additionalParams = array_diff_key($_GET, array('id' => 0, 'L' => 0, 'type' => 0)); $conf['typolink.']['additionalParams'] .= '&' . http_build_query($additionalParams); $url = t3lib_div::locationHeaderUrl($startpage ? $startlink : $this->cObj->typolink('', $conf['typolink.'])); /* -------------------------------------------------- Redirect -------------------------------------------------- */ if ($conf['redirect'] && !$GLOBALS['BE_USER']) { $request_url = parse_url($_SERVER['REQUEST_URI']); if ($request_url['path'] != parse_url($url, PHP_URL_PATH)) { header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . $url . ($request_url['query'] ? '?' . $request_url['query'] : '')); header('X-Note: Redirect by ods_seo'); exit; } } /* -------------------------------------------------- Canonical -------------------------------------------------- */ if ($conf['canonical']) { $GLOBALS['TSFE']->additionalHeaderData[$this->prefixId] = '<link rel="canonical" href="' . htmlentities($url) . '" />'; } }
/** * Cette methode permet de verifier si l'utilisateur * du portail poss�de d�j� une authentification SSO sur le * serveur CAS. * Si ce dernier ne poss�de pas d'authetification, le plugin redirige l'utilisateur sur * une page d'authentification CAS dans une iframe. */ function main($content, $conf) { session_start(); //$idPageAuth = '3434'; $idPageAuth = '3682'; $this->typeExecution = "prod"; $urlCas = "none"; $portCas = "none"; if ($this->typeExecution == "dev") { $urlCas = "xinf-devlinux.intranet.haras-nationaux.fr"; $portCas = 7777; } else { if ($this->typeExecution == "prod") { $urlCas = "cerbere.haras-nationaux.fr"; $portCas = 443; } } //debug($_SESSION); if ($GLOBALS["TSFE"]->page["tx_dlcube04CAS_auth_cas_required"] == 1) { phpCAS::client(CAS_VERSION_2_0, $urlCas, $portCas, 'cas', 'true'); $auth = phpCAS::checkAuthentication(); if (!$auth) { $_SESSION["service_id_auth"] = $GLOBALS["TSFE"]->id; header('Location: ' . t3lib_div::locationHeaderUrl($this->pi_getPageLink($idPageAuth, "", array("action" => "auth")))); exit; } else { $_SESSION["portalId"] = phpCAS::getUser(); } } if (isset($_GET["action_cas"]) && $_GET["action_cas"] == "logout") { unset($_SESSION["portalId"]); header('Location: ' . t3lib_div::locationHeaderUrl($this->pi_getPageLink("3683", "", array("action" => "disconnect")))); } /** * Gestion des langues pour le cookie */ if (isset($_GET["lang"])) { if ($_GET["lang"] == "fr") { $this->cookie_fr(); } if ($_GET["lang"] == "en") { $this->cookie_en(); } } }
/** * The main method of the PlugIn * * @param string $content The PlugIn content * @param array $conf The PlugIn configuration * @return The content that is displayed on the website */ function main($content, $conf) { $this->conf = $conf; // Configuring so caching is not expected. This value means that no cHash params are ever set. We do this, because it's a USER_INT object! $this->pi_USER_INT_obj = 1; if ($this->cObj->data['pages']) { $destination = $this->getLink($this->cObj->data['pages'], $GLOBALS['TSFE']->sys_language_uid); // Redirect if ($redirect['has_moved']) { header('HTTP/1.1 301 Moved Permanently'); } else { header('HTTP/1.1 302 Moved Temporarily'); } header('Location: ' . t3lib_div::locationHeaderUrl($destination)); header('Connection: close'); exit; } }
/** * Handles incoming trackback requests * * @return void */ public function main() { header('Content-type: text/plain; charset=iso-8859-1'); if ($this->pageId) { $this->createTSFE(); $cObj = t3lib_div::makeInstance('tslib_cObj'); /* @var $cObj tslib_cObj */ $typolinkConf = array('parameter' => $this->pageId, 'useCacheHash' => $this->parameters != ''); if ($this->parameters) { $typolinkConf['additionalParams'] = $this->parameters; } $url = $cObj->typoLink_URL($typolinkConf); if ($url == '') { $url = '/'; } $parts = parse_url($url); if ($parts['host'] == '') { $url = t3lib_div::locationHeaderUrl($url); } echo $url; } }
/** * Redirects to the current URL. * * @return void */ protected function redirectToCurrentUrl() { $currentUrl = t3lib_div::locationHeaderUrl(t3lib_div::getIndpEnv('REQUEST_URI')); tx_oelib_headerProxyFactory::getInstance()->getHeaderProxy()->addHeader('Location: ' . $currentUrl); }
/** * helper function for render the javascript libraries * * @return string content with javascript libraries */ protected function renderJsLibraries() { $out = ''; if ($this->addPrototype) { $out .= '<script src="' . $this->processJsFile($this->backPath . 'contrib/prototype/prototype.js') . '" type="text/javascript"></script>' . LF; unset($this->jsFiles[$this->backPath . 'contrib/prototype/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 . 'contrib/scriptaculous/' . $module . '.js') . '" type="text/javascript"></script>' . LF; unset($this->jsFiles[$this->backPath . 'contrib/scriptaculous/' . $module . '.js']); } } $out .= '<script src="' . $this->processJsFile($this->backPath . 'contrib/scriptaculous/scriptaculous.js') . '" type="text/javascript"></script>' . LF; unset($this->jsFiles[$this->backPath . 'contrib/scriptaculous/scriptaculous.js']); } // include extCore if ($this->addExtCore) { $out .= '<script src="' . $this->processJsFile($this->backPath . 'contrib/extjs/ext-core' . ($this->enableExtCoreDebug ? '-debug' : '') . '.js') . '" type="text/javascript"></script>' . LF; unset($this->jsFiles[$this->backPath . 'contrib/extjs/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 . 'contrib/extjs/adapter/' . ($this->enableExtJsDebug ? str_replace('.js', '-debug.js', $this->extJSadapter) : $this->extJSadapter)) . '" type="text/javascript"></script>' . LF; $out .= '<script src="' . $this->processJsFile($this->backPath . 'contrib/extjs/ext-all' . ($this->enableExtJsDebug ? '-debug' : '') . '.js') . '" type="text/javascript"></script>' . LF; // add extJS localization $localeMap = $this->csConvObj->isoArray; // load standard ISO mapping and modify for use with ExtJS $localeMap[''] = 'en'; $localeMap['default'] = 'en'; $localeMap['gr'] = 'el_GR'; // Greek $localeMap['no'] = 'no_BO'; // Norwegian Bokmaal $localeMap['se'] = 'se_SV'; // Swedish $extJsLang = isset($localeMap[$this->lang]) ? $localeMap[$this->lang] : $this->lang; // TODO autoconvert file from UTF8 to current BE charset if necessary!!!! $extJsLocaleFile = 'contrib/extjs/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 . 'contrib/extjs/ext-all.js'], $this->jsFiles[$this->backPath . 'contrib/extjs/ext-all-debug.js']); } // 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'); } } $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(t3lib_div::locationHeaderUrl($this->backPath . 'gfx/clear.gif')) . '";' . LF . $inlineSettings . 'Ext.onReady(function() {' . ($this->enableExtJSQuickTips ? 'Ext.QuickTips.init();' . LF : '') . $code . ' });' . $this->inlineJavascriptWrap[1]; unset($this->extOnReadyCode); if ($this->extJStheme) { if (isset($GLOBALS['TBE_STYLES']['extJS']['theme'])) { $this->addCssFile($this->backPath . $GLOBALS['TBE_STYLES']['extJS']['theme'], 'stylesheet', 'all', '', TRUE, TRUE); } else { $this->addCssFile($this->backPath . 'contrib/extjs/resources/css/xtheme-blue.css', 'stylesheet', 'all', '', TRUE, TRUE); } } if ($this->extJScss) { if (isset($GLOBALS['TBE_STYLES']['extJS']['all'])) { $this->addCssFile($this->backPath . $GLOBALS['TBE_STYLES']['extJS']['all'], 'stylesheet', 'all', '', TRUE, TRUE); } else { $this->addCssFile($this->backPath . 'contrib/extjs/resources/css/ext-all-notheme.css', 'stylesheet', 'all', '', TRUE, TRUE); } } } else { if ($inlineSettings) { $out .= $this->inlineJavascriptWrap[0] . $inlineSettings . $this->inlineJavascriptWrap[1]; } } return $out; }
/** * Generates a XML sitemap from the page structure * * @param string the content to be filled, usually empty * @param array additional configuration parameters * @return string the XML sitemap ready to render */ public function renderXMLSitemap($content, $conf) { $this->conf = $conf; $id = intval($GLOBALS['TSFE']->id); $depth = 50; $additionalFields = 'uid,pid,doktype,shortcut,crdate,SYS_LASTCHANGED'; $baseURL = $this->getBaseUrl(); $baseURLParts = parse_url($baseURL); $currentHostname = $baseURLParts['host']; // -- do a 301 redirect to the "main" sitemap.xml if not already there if ($this->conf['redirectToMainSitemap'] && $baseURL) { $sitemapURL = $baseURL . 'sitemap.xml'; $requestURL = t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'); if ($requestURL != $sitemapURL && strpos($requestURL, 'sitemap.xml')) { header('Location: ' . t3lib_div::locationHeaderUrl($sitemapURL), true, 301); } } // Initializing the tree object $treeStartingRecord = $GLOBALS['TSFE']->sys_page->getRawRecord('pages', $id, $additionalFields); // now we need to see if this page is a redirect from the parent page // and loop while parentid is not null and the parent is still a redirect $parentId = $treeStartingRecord['pid']; while ($parentId > 0) { $parentRecord = $GLOBALS['TSFE']->sys_page->getRawRecord('pages', $parentId, $additionalFields); // check for shortcuts if ($this->conf['resolveMainShortcut'] == 1) { if ($parentRecord['doktype'] == 4 && ($parentRecord['shortcut'] == $id || $parentRecord['shortcut_mode'] > 0)) { $treeStartingRecord = $parentRecord; $id = $parentId = $parentRecord['pid']; } else { break; } } else { // just traverse the rootline up $treeStartingRecord = $parentRecord; $id = $parentId = $parentRecord['pid']; } } $tree = t3lib_div::makeInstance('t3lib_pageTree'); $tree->addField('SYS_LASTCHANGED', 1); $tree->addField('crdate', 1); $tree->addField('no_search', 1); $tree->addField('doktype', 1); $tree->addField('nav_hide', 1); // disable recycler and everything below $tree->init('AND doktype!=255' . $GLOBALS['TSFE']->sys_page->enableFields('pages')); // create the tree from starting point $tree->getTree($id, $depth, ''); $treeRecords = $tree->tree; array_unshift($treeRecords, array('row' => $treeStartingRecord)); foreach ($treeRecords as $row) { $item = $row['row']; // don't render spacers, sysfolders etc, and the ones that have the // "no_search" checkbox if ($item['doktype'] >= 199 || intval($item['no_search']) == 1) { continue; } // remove "hide-in-menu" items if ($this->conf['renderHideInMenu'] == 0 && intval($item['nav_hide']) == 1) { continue; } $conf = array('parameter' => $item['uid']); // also allow different languages if (!empty($GLOBALS['TSFE']->sys_language_uid)) { $conf['additionalParams'] = '&L=' . $GLOBALS['TSFE']->sys_language_uid; } // create the final URL $url = $GLOBALS['TSFE']->cObj->typoLink_URL($conf); $urlParts = parse_url($url); if (!$urlParts['host']) { $url = $baseURL . ltrim($url, '/'); } $url = htmlspecialchars($url); if (isset($this->usedUrls[$url])) { continue; } $lastmod = $item['SYS_LASTCHANGED'] ? $item['SYS_LASTCHANGED'] : $item['crdate']; // format date, see http://www.w3.org/TR/NOTE-datetime for possible formats $lastmod = date('c', $lastmod); $this->usedUrls[$url] = array('url' => $url, 'lastmod' => $lastmod); } // check for additional pages $additionalPages = trim($this->conf['scrapeLinksFromPages']); if ($additionalPages) { $additionalPages = t3lib_div::trimExplode(',', $additionalPages, TRUE); if (count($additionalPages)) { $additionalSubpagesOfPages = $this->conf['scrapeLinksFromPages.']['includingSubpages']; $additionalSubpagesOfPages = t3lib_div::trimExplode(',', $additionalSubpagesOfPages); $this->fetchAdditionalUrls($additionalPages, $additionalSubpagesOfPages); } } // creating the XML output $content = ''; // create the content foreach ($this->usedUrls as $urlData) { // skip pages that are not on the same domain if (stripos($urlData['url'], $currentHostname) === FALSE) { continue; } if ($urlData['lastmod']) { $lastmod = ' <lastmod>' . htmlspecialchars($urlData['lastmod']) . '</lastmod>'; } else { $lastmod = ''; } $content .= ' <url> <loc>' . htmlspecialchars($urlData['url']) . '</loc>' . $lastmod . ' </url>'; } // hook for adding additional urls if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['seo_basics']['sitemap']['additionalUrlsHook'])) { $_params = array('content' => &$content, 'usedUrls' => &$this->usedUrls); foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['seo_basics']['sitemap']['additionalUrlsHook'] as $_funcRef) { t3lib_div::callUserFunction($_funcRef, $_params, $this); } } // see https://www.google.com/webmasters/tools/docs/en/protocol.html for complete format $content = '<?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">' . $content . ' </urlset>'; return $content; }
/** * 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 = intval($this->conf['forgotLinkHashValidTime']) > 0 ? intval($this->conf['forgotLinkHashValidTime']) : 24; $validEnd = time() + 3600 * $hours; $validEndString = date($this->conf['dateFormat'], $validEnd); $hash = md5(t3lib_div::generateRandomBytes(64)); $randHash = $validEnd . '|' . $hash; $randHashDB = $validEnd . '|' . md5($hash); //write hash to DB $res = $GLOBALS['TYPO3_DB']->exec_UPDATEquery('fe_users', 'uid=' . $user['uid'], array('felogin_forgotHash' => $randHashDB)); // send hashlink to user $this->conf['linkPrefix'] = -1; $isAbsRelPrefix = !empty($GLOBALS['TSFE']->absRefPrefix); $isBaseURL = !empty($GLOBALS['TSFE']->baseUrl); $isFeloginBaseURL = !empty($this->conf['feloginBaseURL']); $link = $this->pi_getPageLink($GLOBALS['TSFE']->id, '', array($this->prefixId . '[user]' => $user['uid'], $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($GLOBALS['TSFE']->absRefPrefix)) { $link = substr($link, strlen($GLOBALS['TSFE']->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 = t3lib_div::locationHeaderUrl($link); } elseif ($isBaseURL) { // Third priority // Add the global base URL to the link $link = $GLOBALS['TSFE']->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', '', 0), $user['username'], $link, $validEndString); // no RDCT - Links for security reasons $oldSetting = $GLOBALS['TSFE']->config['config']['notification_email_urlmode']; $GLOBALS['TSFE']->config['config']['notification_email_urlmode'] = 0; // send the email $this->cObj->sendNotifyEmail($msg, $user['email'], '', $this->conf['email_from'], $this->conf['email_fromName'], $this->conf['replyTo']); // restore settings $GLOBALS['TSFE']->config['config']['notification_email_urlmode'] = $oldSetting; return ''; }
/** * Builds a collection's list * * @access protected * * @param integer $id: The collection's UID * * @return void */ protected function showSingleCollection($id) { // Should user-defined collections be shown? if (empty($this->conf['show_userdefined'])) { $additionalWhere = ' AND tx_dlf_collections.fe_cruser_id=0'; } elseif ($this->conf['show_userdefined'] > 0) { $additionalWhere = ' AND NOT tx_dlf_collections.fe_cruser_id=0'; } // Get all documents in collection. $result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tx_dlf_collections.index_name AS index_name,tx_dlf_collections.label AS collLabel,tx_dlf_collections.description AS collDesc,tx_dlf_collections.thumbnail AS collThumb,tx_dlf_collections.fe_cruser_id AS userid,tx_dlf_documents.uid AS uid,tx_dlf_documents.metadata_sorting AS metadata_sorting,tx_dlf_documents.volume_sorting AS volume_sorting,tx_dlf_documents.partof AS partof', 'tx_dlf_documents', 'tx_dlf_relations', 'tx_dlf_collections', 'AND tx_dlf_collections.uid=' . intval($id) . ' AND tx_dlf_collections.pid=' . intval($this->conf['pages']) . ' AND tx_dlf_relations.ident=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations') . $additionalWhere . tx_dlf_helper::whereClause('tx_dlf_documents') . tx_dlf_helper::whereClause('tx_dlf_collections'), '', 'tx_dlf_documents.title_sorting ASC', ''); $toplevel = array(); $subparts = array(); $listMetadata = array(); // Process results. while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) { if (empty($listMetadata)) { $listMetadata = array('label' => htmlspecialchars($resArray['collLabel']), 'description' => $this->pi_RTEcssText($resArray['collDesc']), 'thumbnail' => htmlspecialchars($resArray['collThumb']), 'options' => array('source' => 'collection', 'select' => $id, 'userid' => $resArray['userid'], 'params' => array('fq' => array('collection_faceting:"' . $resArray['index_name'] . '"')), 'core' => '', 'pid' => $this->conf['pages'], 'order' => 'title', 'order.asc' => TRUE)); } // Split toplevel documents from volumes. if ($resArray['partof'] == 0) { // Prepare document's metadata for sorting. $sorting = unserialize($resArray['metadata_sorting']); if (!empty($sorting['type']) && tx_dlf_helper::testInt($sorting['type'])) { $sorting['type'] = tx_dlf_helper::getIndexName($sorting['type'], 'tx_dlf_structures', $this->conf['pages']); } if (!empty($sorting['owner']) && tx_dlf_helper::testInt($sorting['owner'])) { $sorting['owner'] = tx_dlf_helper::getIndexName($sorting['owner'], 'tx_dlf_libraries', $this->conf['pages']); } if (!empty($sorting['collection']) && tx_dlf_helper::testInt($sorting['collection'])) { $sorting['collection'] = tx_dlf_helper::getIndexName($sorting['collection'], 'tx_dlf_collections', $this->conf['pages']); } $toplevel[$resArray['uid']] = array('u' => $resArray['uid'], 's' => $sorting, 'p' => array()); } else { $subparts[$resArray['partof']][$resArray['volume_sorting']] = $resArray['uid']; } } // Add volumes to the corresponding toplevel documents. foreach ($subparts as $partof => $parts) { if (!empty($toplevel[$partof])) { ksort($parts); $toplevel[$partof]['p'] = array_values($parts); } } // Save list of documents. $list = t3lib_div::makeInstance('tx_dlf_list'); $list->reset(); $list->add(array_values($toplevel)); $list->metadata = $listMetadata; $list->save(); // Clean output buffer. t3lib_div::cleanOutputBuffers(); // Send headers. header('Location: ' . t3lib_div::locationHeaderUrl($this->cObj->typoLink_URL(array('parameter' => $this->conf['targetPid'])))); // Flush output buffer and end script processing. ob_end_flush(); exit; }
/** * Substitutes default markers in $this->template. * * @return void */ protected function fillDefaultMarkers() { $parameters = t3lib_div::_GET(); if (isset($parameters['id'])) { unset($parameters['id']); } $path = $this->pi_getPageLink($GLOBALS['TSFE']->id, '', $parameters); $path = htmlspecialchars($path); $markers = array(); $markers['###REL_URL###'] = $path; $markers['###TIMESTAMP###'] = time(); $markers['###RANDOM_ID###'] = $this->gp['randomID']; $markers['###ABS_URL###'] = t3lib_div::locationHeaderUrl('') . $path; $markers['###rel_url###'] = $markers['###REL_URL###']; $markers['###timestamp###'] = $markers['###TIMESTAMP###']; $markers['###abs_url###'] = $markers['###ABS_URL###']; $name = 'submitted'; if (Tx_Formhandler_Globals::$formValuesPrefix) { $name = Tx_Formhandler_Globals::$formValuesPrefix . '[submitted]'; } $markers['###HIDDEN_FIELDS###'] = ' <input type="hidden" name="id" value="' . $GLOBALS['TSFE']->id . '" /> <input type="hidden" name="' . $name . '" value="1" /> '; $name = 'randomID'; if (Tx_Formhandler_Globals::$formValuesPrefix) { $name = Tx_Formhandler_Globals::$formValuesPrefix . '[randomID]'; } $markers['###HIDDEN_FIELDS###'] .= ' <input type="hidden" name="' . $name . '" value="' . $this->gp['randomID'] . '" /> '; $name = 'removeFile'; if (Tx_Formhandler_Globals::$formValuesPrefix) { $name = Tx_Formhandler_Globals::$formValuesPrefix . '[removeFile]'; } $markers['###HIDDEN_FIELDS###'] .= ' <input type="hidden" id="removeFile-' . $this->gp['randomID'] . '" name="' . $name . '" value="" /> '; $name = 'removeFileField'; if (Tx_Formhandler_Globals::$formValuesPrefix) { $name = Tx_Formhandler_Globals::$formValuesPrefix . '[removeFileField]'; } $markers['###HIDDEN_FIELDS###'] .= ' <input type="hidden" id="removeFileField-' . $this->gp['randomID'] . '" name="' . $name . '" value="" /> '; $name = 'submitField'; if (Tx_Formhandler_Globals::$formValuesPrefix) { $name = Tx_Formhandler_Globals::$formValuesPrefix . '[submitField]'; } $markers['###HIDDEN_FIELDS###'] .= ' <input type="hidden" id="submitField-' . $this->gp['randomID'] . '" name="' . $name . '" value="" /> '; $markers['###formValuesPrefix###'] = Tx_Formhandler_Globals::$formValuesPrefix; if ($this->gp['generated_authCode']) { $markers['###auth_code###'] = $this->gp['generated_authCode']; } $markers['###ip###'] = t3lib_div::getIndpEnv('REMOTE_ADDR'); $markers['###IP###'] = $markers['###ip###']; $markers['###submission_date###'] = date('d.m.Y H:i:s', time()); $markers['###pid###'] = $GLOBALS['TSFE']->id; $markers['###PID###'] = $markers['###pid###']; // current step $currentStepFromSession = Tx_Formhandler_Globals::$session->get('currentStep'); $markers['###curStep###'] = $currentStepFromSession; // maximum step/number of steps $markers['###maxStep###'] = Tx_Formhandler_Globals::$session->get('totalSteps'); // the last step shown $markers['###lastStep###'] = Tx_Formhandler_Globals::$session->get('lastStep'); $name = 'step-'; $prefix = Tx_Formhandler_Globals::$formValuesPrefix; if ($prefix) { $name = $prefix . '[' . $name . '#step#-#action#]'; } else { $name = $name . '#step#-#action#'; } // submit name for next page $nextName = ' name="' . str_replace('#action#', 'next', $name) . '" '; $nextName = str_replace('#step#', $currentStepFromSession + 1, $nextName); $markers['###submit_nextStep###'] = $nextName; // submit name for previous page $prevName = ' name="' . str_replace('#action#', 'prev', $name) . '" '; $prevName = str_replace('#step#', $currentStepFromSession - 1, $prevName); $markers['###submit_prevStep###'] = $prevName; // submits for next/prev steps with template suffix preg_match_all('/###submit_nextStep_[^#]+?###/Ssm', $this->template, $allNextSubmits); foreach ($allNextSubmits[0] as $nextSubmitSuffix) { $nextSubmitSuffix = substr($nextSubmitSuffix, 19, -3); $nextName = ' name="' . str_replace('#action#', 'next', $name) . '[' . $nextSubmitSuffix . ']" '; $nextName = str_replace('#step#', $currentStepFromSession + 1, $nextName); $markers['###submit_nextStep_' . $nextSubmitSuffix . '###'] = $nextName; } preg_match_all('/###submit_prevStep_[^#]+?###/Ssm', $this->template, $allPrevSubmits); foreach ($allPrevSubmits[0] as $prevSubmitSuffix) { $prevSubmitSuffix = substr($prevSubmitSuffix, 19, -3); $prevName = ' name="' . str_replace('#action#', 'prev', $name) . '[' . $prevSubmitSuffix . ']" '; $prevName = str_replace('#step#', $currentStepFromSession + 1, $prevName); $markers['###submit_prevStep_' . $prevSubmitSuffix . '###'] = $prevName; } // submit name for reloading the same page/step $reloadName = ' name="' . str_replace('#action#', 'reload', $name) . '" '; $reloadName = str_replace('#step#', $currentStepFromSession, $reloadName); $markers['###submit_reload###'] = $reloadName; // step bar $prevName = str_replace('#action#', 'prev', $name); $prevName = str_replace('#step#', $currentStepFromSession - 1, $prevName); $nextName = str_replace('#action#', 'next', $name); $nextName = str_replace('#step#', $currentStepFromSession + 1, $nextName); $markers['###step_bar###'] = $this->createStepBar($currentStepFromSession, Tx_Formhandler_Globals::$session->get('totalSteps'), $prevName, $nextName); $this->fillCaptchaMarkers($markers); $this->fillFEUserMarkers($markers); $this->fillFileMarkers($markers); if (!strstr($this->template, '###HIDDEN_FIELDS###')) { $this->template = str_replace('</form>', '<fieldset style="display: none;">' . $markers['###HIDDEN_FIELDS###'] . '</fieldset></form>', $this->template); } $this->template = $this->cObj->substituteMarkerArray($this->template, $markers); }
/** * @param $path * @return mixed * @seee t3lib_div::locationHeaderUrl() */ public function locationHeaderUrl($path) { /** @noinspection PhpDeprecationInspection PhpUndefinedClassInspection */ return t3lib_div::locationHeaderUrl($path); }
/** * Perform user login and redirect to configured url, if any * * @param array $row: incoming setfixed parameters * @param boolen $redirect: whether to redirect after login or not * @return boolean TRUE, if login was successful, FALSE otherwise */ public function login($conf, $langObj, $controlData, array $row, $redirect = TRUE) { $result = TRUE; // Log the user in $loginData = array('uname' => $row['username'], 'uident' => $row['password'], 'uident_text' => $row['password'], 'status' => 'login'); // Check against configured pid (defaulting to current page) $GLOBALS['TSFE']->fe_user->checkPid = TRUE; $GLOBALS['TSFE']->fe_user->checkPid_value = $controlData->getPid(); // Get authentication info array $authInfo = $GLOBALS['TSFE']->fe_user->getAuthInfoArray(); // Get user info $user = $GLOBALS['TSFE']->fe_user->fetchUserRecord($authInfo['db_user'], $loginData['uname']); if (is_array($user)) { // Get the appropriate authentication service $authServiceObj = t3lib_div::makeInstanceService('auth', 'authUserFE'); // Check authentication if (is_object($authServiceObj)) { $ok = $authServiceObj->compareUident($user, $loginData); if ($ok) { // Login successfull: create user session $GLOBALS['TSFE']->fe_user->createUserSession($user); $GLOBALS['TSFE']->initUserGroups(); $GLOBALS['TSFE']->fe_user->user = $GLOBALS['TSFE']->fe_user->fetchUserSession(); $GLOBALS['TSFE']->loginUser = 1; // Delete regHash if ($controlData->getValidRegHash()) { $regHash = $controlData->getRegHash(); $controlData->deleteShortUrl($regHash); } if ($redirect) { // Redirect to configured page, if any $redirectUrl = $controlData->readRedirectUrl(); if (!$redirectUrl) { $redirectUrl = trim($conf['autoLoginRedirect_url']); } if (!$redirectUrl) { if ($conf['loginPID']) { $redirectUrl = $this->urlObj->get('', $conf['loginPID']); } else { $redirectUrl = $controlData->getSiteUrl(); } } header('Location: ' . t3lib_div::locationHeaderUrl($redirectUrl)); } } else { // Login failed... $controlData->clearSessionData(FALSE); $result = FALSE; } } else { // Required authentication service not available $message = $langObj->getLL('internal_required_authentication_service_not_available'); t3lib_div::sysLog($message, $controlData->getExtKey(), t3lib_div::SYSLOG_SEVERITY_ERROR); $controlData->clearSessionData(FALSE); $result = FALSE; } } else { // No enabled user of the given name $controlData->clearSessionData(FALSE); $result = FALSE; } return $result; }
/** * Process editing of a TO for renderTO() function * * @param array Data Structure. Passed by reference; The sheets found inside will be resolved if found! * @param array TO record row * @param string Template file path (absolute) * @param integer Process the headerPart instead of the bodyPart * @return array Array with two keys (0/1) with a) content and b) currentMappingInfo which is retrieved inside (currentMappingInfo will be different based on whether "head" or "body" content is "mapped") * @see renderTO() */ function renderTO_editProcessing(&$dataStruct,$row,$theFile, $headerPart = 0) { $msg = array(); // Converting GPvars into a "cmd" value: $cmd = ''; if (t3lib_div::_GP('_reload_from')) { // Reverting to old values in TO $cmd = 'reload_from'; } elseif (t3lib_div::_GP('_clear')) { // Resetting mapping $cmd = 'clear'; } elseif (t3lib_div::_GP('_save_data_mapping')) { // Saving to Session $cmd = 'save_data_mapping'; } elseif (t3lib_div::_GP('_save_to') || t3lib_div::_GP('_save_to_return')) { // Saving to Template Object $cmd = 'save_to'; } // Getting data from tmplobj $templatemapping = unserialize($row['templatemapping']); if (!is_array($templatemapping)) $templatemapping=array(); // If that array contains sheets, then traverse them: if (is_array($dataStruct['sheets'])) { $dSheets = t3lib_div::resolveAllSheetsInDS($dataStruct); $dataStruct=array( 'ROOT' => array ( 'tx_templavoila' => array ( 'title' => $GLOBALS['LANG']->getLL('rootMultiTemplate_title'), 'description' => $GLOBALS['LANG']->getLL('rootMultiTemplate_description'), ), 'type' => 'array', 'el' => array() ) ); foreach($dSheets['sheets'] as $nKey => $lDS) { if (is_array($lDS['ROOT'])) { $dataStruct['ROOT']['el'][$nKey] = $lDS['ROOT']; } } } // Get session data: $sesDat = $GLOBALS['BE_USER']->getSessionData($this->sessionKey); // Set current mapping info arrays: $currentMappingInfo_head = is_array($sesDat['currentMappingInfo_head']) ? $sesDat['currentMappingInfo_head'] : array(); $currentMappingInfo = is_array($sesDat['currentMappingInfo']) ? $sesDat['currentMappingInfo'] : array(); $this->cleanUpMappingInfoAccordingToDS($currentMappingInfo,$dataStruct); // Perform processing for head // GPvars, incoming data $checkboxElement = t3lib_div::_GP('checkboxElement',1); $addBodyTag = t3lib_div::_GP('addBodyTag'); // Update session data: if ($cmd=='reload_from' || $cmd=='clear') { $currentMappingInfo_head = is_array($templatemapping['MappingInfo_head'])&&$cmd!='clear' ? $templatemapping['MappingInfo_head'] : array(); $sesDat['currentMappingInfo_head'] = $currentMappingInfo_head; $GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat); } else { if ($cmd=='save_data_mapping' || $cmd=='save_to') { $sesDat['currentMappingInfo_head'] = $currentMappingInfo_head = array( 'headElementPaths' => $checkboxElement, 'addBodyTag' => $addBodyTag?1:0 ); $GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat); } } // Perform processing for body // GPvars, incoming data $inputData = t3lib_div::_GP('dataMappingForm',1); // Update session data: if ($cmd=='reload_from' || $cmd=='clear') { $currentMappingInfo = is_array($templatemapping['MappingInfo'])&&$cmd!='clear' ? $templatemapping['MappingInfo'] : array(); $this->cleanUpMappingInfoAccordingToDS($currentMappingInfo,$dataStruct); $sesDat['currentMappingInfo'] = $currentMappingInfo; $sesDat['dataStruct'] = $dataStruct; $GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat); } else { if ($cmd=='save_data_mapping' && is_array($inputData)) { $sesDat['currentMappingInfo'] = $currentMappingInfo = $this->array_merge_recursive_overrule($currentMappingInfo,$inputData); $sesDat['dataStruct'] = $dataStruct; // Adding data structure to session data so that the PREVIEW window can access the DS easily... $GLOBALS['BE_USER']->setAndSaveSessionData($this->sessionKey, $sesDat); } } // SAVE to template object if ($cmd=='save_to') { $dataArr=array(); // Set content, either for header or body: $templatemapping['MappingInfo_head'] = $currentMappingInfo_head; $templatemapping['MappingInfo'] = $currentMappingInfo; // Getting cached data: reset($dataStruct); // Init; read file, init objects: $fileContent = t3lib_div::getUrl($theFile); $htmlParse = t3lib_div::makeInstance('t3lib_parsehtml'); $this->markupObj = t3lib_div::makeInstance('tx_templavoila_htmlmarkup'); // Fix relative paths in source: $relPathFix=dirname(substr($theFile,strlen(PATH_site))).'/'; $uniqueMarker = uniqid('###') . '###'; $fileContent = $htmlParse->prefixResourcePath($relPathFix,$fileContent, array('A' => $uniqueMarker)); $fileContent = $this->fixPrefixForLinks($relPathFix, $fileContent, $uniqueMarker); // Get BODY content for caching: $contentSplittedByMapping=$this->markupObj->splitContentToMappingInfo($fileContent,$currentMappingInfo); $templatemapping['MappingData_cached'] = $contentSplittedByMapping['sub']['ROOT']; // Get HEAD content for caching: list($html_header) = $this->markupObj->htmlParse->getAllParts($htmlParse->splitIntoBlock('head',$fileContent),1,0); $this->markupObj->tags = $this->head_markUpTags; // Set up the markupObject to process only header-section tags: $h_currentMappingInfo=array(); if (is_array($currentMappingInfo_head['headElementPaths'])) { foreach($currentMappingInfo_head['headElementPaths'] as $kk => $vv) { $h_currentMappingInfo['el_'.$kk]['MAP_EL'] = $vv; } } $contentSplittedByMapping = $this->markupObj->splitContentToMappingInfo($html_header,$h_currentMappingInfo); $templatemapping['MappingData_head_cached'] = $contentSplittedByMapping; // Get <body> tag: $reg=''; preg_match('/<body[^>]*>/i',$fileContent,$reg); $templatemapping['BodyTag_cached'] = $currentMappingInfo_head['addBodyTag'] ? $reg[0] : ''; $TOuid = t3lib_BEfunc::wsMapId('tx_templavoila_tmplobj',$row['uid']); $dataArr['tx_templavoila_tmplobj'][$TOuid]['templatemapping'] = serialize($templatemapping); $dataArr['tx_templavoila_tmplobj'][$TOuid]['fileref_mtime'] = @filemtime($theFile); $dataArr['tx_templavoila_tmplobj'][$TOuid]['fileref_md5'] = @md5_file($theFile); $tce = t3lib_div::makeInstance('t3lib_TCEmain'); $tce->stripslashes_values=0; $tce->start($dataArr,array()); $tce->process_datamap(); unset($tce); $flashMessage = t3lib_div::makeInstance( 't3lib_FlashMessage', $GLOBALS['LANG']->getLL('msgMappingSaved'), '', t3lib_FlashMessage::OK ); $msg[] .= $flashMessage->render(); $row = t3lib_BEfunc::getRecordWSOL('tx_templavoila_tmplobj',$this->displayUid); $templatemapping = unserialize($row['templatemapping']); if (t3lib_div::_GP('_save_to_return')) { header('Location: '.t3lib_div::locationHeaderUrl($this->returnUrl)); exit; } } // Making the menu $menuItems=array(); $menuItems[]='<input type="submit" name="_clear" value="' . $GLOBALS['LANG']->getLL('buttonClearAll') . '" title="' . $GLOBALS['LANG']->getLL('buttonClearAllMappingTitle') . '" />'; // Make either "Preview" button (body) or "Set" button (header) if ($headerPart) { // Header: $menuItems[] = '<input type="submit" name="_save_data_mapping" value="' . $GLOBALS['LANG']->getLL('buttonSet') . '" title="' . $GLOBALS['LANG']->getLL('buttonSetTitle') . '" />'; } else { // Body: $menuItems[] = '<input type="submit" name="_preview" value="' . $GLOBALS['LANG']->getLL('buttonPreview') . '" title="' . $GLOBALS['LANG']->getLL('buttonPreviewMappingTitle') . '" />'; } $menuItems[]='<input type="submit" name="_save_to" value="' . $GLOBALS['LANG']->getLL('buttonSave') . '" title="' . $GLOBALS['LANG']->getLL('buttonSaveTOTitle') . '" />'; if ($this->returnUrl) { $menuItems[]='<input type="submit" name="_save_to_return" value="' . $GLOBALS['LANG']->getLL('buttonSaveAndReturn') . '" title="' . $GLOBALS['LANG']->getLL('buttonSaveAndReturnTitle') . '" />'; } // If a difference is detected...: if ( (serialize($templatemapping['MappingInfo_head']) != serialize($currentMappingInfo_head)) || (serialize($templatemapping['MappingInfo']) != serialize($currentMappingInfo)) ) { $menuItems[]='<input type="submit" name="_reload_from" value="' . $GLOBALS['LANG']->getLL('buttonRevert') . '" title="'.sprintf($GLOBALS['LANG']->getLL('buttonRevertTitle'), $headerPart ? 'HEAD' : 'BODY') . '" />'; $flashMessage = t3lib_div::makeInstance( 't3lib_FlashMessage', $GLOBALS['LANG']->getLL('msgMappingIsDifferent'), '', t3lib_FlashMessage::INFO ); $msg[] .= $flashMessage->render(); } $content = ' <!-- Menu for saving Template Objects --> <table border="0" cellpadding="2" cellspacing="2" id="c-toMenu"> <tr class="bgColor5"> <td>'.implode('</td> <td>',$menuItems).'</td> </tr> </table> '; // @todo - replace with FlashMessage Queue $content .= implode('', $msg); return array($content, $headerPart ? $currentMappingInfo_head : $currentMappingInfo); }
/** * handleSubmittedForm * * handles the submitted values of a ticket form * * @access public * @return void */ public function handleSubmittedForm() { /*{{{*/ // set some values for NEW tickets // and UPDATED tickets if ($this->piVars['newticket']) { // set the crdate $this->insertFields['crdate'] = time(); // use the first pid of the pid list or, if not set, the current page if ($this->conf['pidList']) { $pidListArray = explode(',', $this->conf['pidList']); $this->insertFields['pid'] = $pidListArray[0]; } else { $this->insertFields['pid'] = $GLOBALS['TSFE']->id; } // set the owner to the current user // if no user is logged in, set it to an empty value if ($GLOBALS['TSFE']->loginUser) { $this->insertFields['owner_feuser'] = $GLOBALS['TSFE']->fe_user->user['uid']; } else { $this->insertFields['owner_feuser'] = ''; } } else { // We need to initalize the "file" type fields, because they get combined from // the different upload fields in the form foreach ($this->conf['formFieldList.'] as $fieldConf) { if ($fieldConf['type'] == 'files' && strlen($this->internal['currentRow'][$fieldConf['name']])) { $this->insertFields[$fieldConf['name']] = $this->internal['currentRow'][$fieldConf['name']]; } } } // handle each of the submitted fields as defined in the typoscript setup foreach ($this->conf['formFieldList.'] as $fieldConf) { // ignore fields: // - the submit-field // - internal fields if the current user is not an internal user // - fields that are configured as "doNotSaveInDB = 1" // - fields the user does not have access to if ($fieldConf['type'] != 'submit' && (!$fieldConf['internal'] || $this->isCurrentUserInternalUser()) && !$fieldConf['doNotSaveInDB'] && $this->fieldIsWritableForCurrentUser($fieldConf)) { // required-check if ($fieldConf['required'] && empty($this->piVars[$fieldConf['name']])) { $this->formErrors[] = $this->pi_getLL('formerror_required_start') . '"' . $this->pi_getLL('LABEL_' . strtoupper(trim($fieldConf['name']))) . '"' . $this->pi_getLL('formerror_required_end'); } // validate if ($fieldConf['validate'] && !empty($this->piVars[$fieldConf['name']])) { $validationParams = t3lib_div::trimExplode(':', $fieldConf['validate']); switch ($validationParams[0]) { case 'float': // replace dot with comma in order to check // for a correct float value $value = str_replace(',', '.', $this->piVars[$fieldConf['name']]); if (filter_var($value, FILTER_VALIDATE_FLOAT) === FALSE) { $this->formErrors[] = $this->pi_getLL('formerror_float_begin') . '"' . $this->pi_getLL('LABEL_' . strtoupper(trim($fieldConf['name']))) . '"' . $this->pi_getLL('formerror_float_end'); } break; case 'notAllowedWhenClosing': if (stristr($this->piVars['status'], CONST_STATUS_CLOSED) && $this->piVars[$fieldConf['name']] == $validationParams[1]) { $this->formErrors[] = $this->pi_getLL('formerror_not_allowed_on_close_begin') . '"' . $this->pi_getLL('LABEL_' . strtoupper(trim($fieldConf['name']))) . '"' . $this->pi_getLL('formerror_not_allowed_on_close_end'); } break; } } // check the "requiredForInternalUsersOnClose" property // This means: If the current user is an "internal" user and // the current field has the // requiredForInternalUsersOnClose-Flag set, he has to fill the // field in case he want's to close the ticket // This is useful for the "time used"-field. if ($fieldConf['requiredForInternalUsersOnClose'] && stristr($this->piVars['status'], CONST_STATUS_CLOSED) && empty($this->piVars[$fieldConf['name']]) && $this->isCurrentUserInternalUser()) { $this->formErrors[] = $this->pi_getLL('formerror_required_start') . '"' . $this->pi_getLL('LABEL_' . strtoupper(trim($fieldConf['name']))) . '"' . $this->pi_getLL('formerror_required_end'); } // generate the db-insert values // combine the "file" type fields // use the already set value as default value, since files must be // deletedy by clicking on the "delete"-icon, not by submitting // an empty "files"-field if ($fieldConf['type'] == 'files') { if (strlen($this->insertFields[$fieldConf['name']])) { $defaultValue = $this->insertFields[$fieldConf['name']]; } else { $defaultValue = ''; } } else { $defaultValue = ''; } // parse and clean up the submitted value $this->insertFields[$fieldConf['name']] = $this->generateDBInsertValue($fieldConf, $defaultValue); } } // if there are errors, delete the uploaded files // don't delete when UPDATING a ticket if (!$this->piVars['updateUid']) { if (count($this->formErrors) && strlen($this->insertFields['files'])) { $this->deleteFiles($this->insertFields['files']); $this->insertFields['files'] = ''; $this->formErrors[] = $this->pi_getLL('formerror_upload_again'); } } // the "project leader function": If a user is the responsible user of // a ticket and delegates that ticket to another user, automatically add // the former responsible user to the list of observers. That only happens // if the responsible user himself changes the responsibility. if ($this->piVars['updateUid'] && $this->conf['addResponsibleUserAsObserverAfterDelegation'] && $this->internal['currentRow']['responsible_feuser'] == $GLOBALS['TSFE']->fe_user->user['uid'] && $this->insertFields['responsible_feuser'] != $GLOBALS['TSFE']->fe_user->user['uid'] && !t3lib_div::inList($GLOBALS['TSFE']->fe_user->user['uid'], $this->insertFields['observers_feuser'])) { $this->insertFields['observers_feuser'] = $this->addToCommaList($this->insertFields['observers_feuser'], $GLOBALS['TSFE']->fe_user->user['uid']); } // if everything is OK, insert the ticket into the database or update it if (!count($this->formErrors)) { if (!$this->piVars['updateUid']) { // new ticket // set the "close_time" field, if the ticket is directy // set to "closed" the moment it's created. if (stristr($this->insertFields['status'], CONST_STATUS_CLOSED)) { $this->insertFields['close_time'] = time(); } $saveFieldsStatus = $GLOBALS['TYPO3_DB']->exec_INSERTquery($this->tablename, $this->insertFields) ? true : false; $new_uid = $GLOBALS['TYPO3_DB']->sql_insert_id(); // hook: after inserting a new ticket if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_troubletickets']['afterNewTicketInsert'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_troubletickets']['afterNewTicketInsert'] as $_classRef) { $_procObj =& t3lib_div::getUserObj($_classRef); $_procObj->afterNewTicketInsert($new_uid, $this); } } $this->addHistoryEntry(array('ticket_uid' => $new_uid, 'databasefield' => '', 'value_old' => '', 'value_new' => $this->pi_getLL('history_new_ticket', 'new'))); // send the notification emails $this->checkChangesAndSendNotificationEmails($new_uid, CONST_NEWTICKET); // status message after saving new ticket if ($saveFieldsStatus) { $this->markerArray['STATUS_CSS_CLASS'] = 'status_ok'; $this->markerArray['STATUS_MESSAGE_TEXT'] = $this->pi_getLL('status_new_ticket'); } // process comment form if allowed for new tickets and data available if ($this->conf['allowCommentsInNewTicketForm'] && !empty($this->piVars['content'])) { $this->handleSubmittedCommentForm(); } } else { // update ticket // go through the form fields and check what has changend // add a history entry for every change $changedFields = ''; $changedInternalFields = ''; foreach ($this->conf['formFieldList.'] as $fieldConf) { $value_old = $this->internal['currentRow'][$fieldConf['name']]; $value_new = $this->insertFields[$fieldConf['name']]; if (!empty($value_new) && $value_old != $value_new) { $this->addHistoryEntry(array('ticket_uid' => $this->internal['currentRow']['uid'], 'databasefield' => $fieldConf['name'], 'value_old' => $value_old, 'value_new' => $value_new)); // update the "close_time" field, if the ticket is // now closed and was NEVER closed before // That means, the close_time is always the time // the ticket has been closed for the first time. if ($fieldConf['name'] == 'status' && stristr($value_new, CONST_STATUS_CLOSED) && !$this->internal['currentRow']['close_time']) { $this->insertFields['close_time'] = time(); } // Remember the fields that have changed for the notification mail. // Do this only for fields that are not internal! if (empty($fieldConf['internal'])) { if (strlen($changedFields)) { $changedFields .= ','; } $changedFields .= $fieldConf['name']; } // Remember the internal fields that have changed if (!empty($fieldConf['internal'])) { if (strlen($changedInternalFields)) { $changedInternalFields .= ','; } $changedInternalFields .= $fieldConf['name']; } } } // If a comment has been submitted, process it now. // Comments are not normal fields but have an own table, so we // cannot process them like the ticket fields. // Remember the fields that have changed for the notification mail. if (isset($this->piVars['content']) && !empty($this->piVars['content'])) { $saveCommentStatus = $this->handleSubmittedCommentForm(); // if the ticket currently is closed, re-open it. if (stristr($this->internal['currentRow']['status'], CONST_STATUS_CLOSED)) { // change the status $this->insertFields['status'] = CONST_STATUS_OPEN; // add the information to changedFields list $changedFields = $this->addToCommaList($changedFields, CONST_REOPENANDCOMMENT); // add a history entry $this->addHistoryEntry(array('ticket_uid' => $this->internal['currentRow']['uid'], 'databasefield' => 'status', 'value_old' => $this->internal['currentRow']['status'], 'value_new' => CONST_STATUS_OPEN)); } else { // if the status is currentyl "wait", set the status to the value // defined in typoscript // only do so if the status has not been changed by the user. if ($this->conf['changeWaitStatusOnNewComment'] && $this->internal['currentRow']['status'] == CONST_STATUS_WAIT && $this->insertFields['status'] == $this->internal['currentRow']['status'] && t3lib_div::inList($this->conf['statusList'], $this->conf['changeWaitStatusOnNewComment'])) { // change the status $this->insertFields['status'] = $this->conf['changeWaitStatusOnNewComment']; // add the information to changedFields list $changedFields = $this->addToCommaList($changedFields, 'status'); // add a history entry $this->addHistoryEntry(array('ticket_uid' => $this->internal['currentRow']['uid'], 'databasefield' => 'status', 'value_old' => $this->internal['currentRow']['status'], 'value_new' => $this->conf['changeWaitStatusOnNewComment'])); } $changedFields = $this->addToCommaList($changedFields, CONST_NEWCOMMENT); } } // get ticket progress $newStatus = $this->insertFields['status']; if ($newStatus == CONST_STATUS_CLOSED || $newStatus == CONST_STATUS_CLOSED_LOCKED) { $this->insertFields['progress'] = 100; } else { $this->insertFields['progress'] = $this->lib->getTicketProgressFromToDo($this->internal['currentRow']['uid']); } if ($this->insertFields['progress'] != $this->internal['currentRow']['progress']) { $changedFields = $this->addToCommaList($changedFields, 'progress'); } // exec update database query $saveFieldsStatus = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($this->tablename, 'uid=' . $this->internal['currentRow']['uid'], $this->insertFields) ? true : false; // hook: after updating a ticket if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_troubletickets']['afterTicketUpdate'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_troubletickets']['afterTicketUpdate'] as $_classRef) { $_procObj =& t3lib_div::getUserObj($_classRef); $_procObj->afterTicketUpdate($this->internal['currentRow']['uid'], $this); } } // send the notification emails $this->checkChangesAndSendNotificationEmails($this->internal['currentRow']['uid'], $changedFields, $changedInternalFields); // check if saving of fields and comments went fine // and set status texts // fields changed and new comment if (!empty($changedFields) && strstr($changedFields, CONST_NEWCOMMENT) && trim($changedFields) != CONST_NEWCOMMENT || !empty($changedInternalFields) && strstr($changedFields, CONST_NEWCOMMENT)) { if ($saveFieldsStatus && $saveCommentStatus) { $this->markerArray['STATUS_CSS_CLASS'] = 'status_ok'; $this->markerArray['STATUS_MESSAGE_TEXT'] = $this->pi_getLL('status_fields_and_comment'); } } else { if (empty($changedInternalFields) && trim($changedFields) == CONST_NEWCOMMENT) { if ($saveCommentStatus) { $this->markerArray['STATUS_CSS_CLASS'] = 'status_ok'; $this->markerArray['STATUS_MESSAGE_TEXT'] = $this->pi_getLL('status_comment_only'); } } else { if (!empty($changedFields) && !strstr($changedFields, CONST_NEWCOMMENT) || !empty($changedInternalFields)) { if ($saveFieldsStatus) { $this->markerArray['STATUS_CSS_CLASS'] = 'status_ok'; $this->markerArray['STATUS_MESSAGE_TEXT'] = $this->pi_getLL('status_fields_only'); } } } } } // process redirect if activated and back pid set // AK, 13.08.2010 if ($this->conf['listView.']['backPidRedirect.']['activated'] && $this->piVars['backPid']) { // extend the status message with redirection notice $this->markerArray['STATUS_MESSAGE_TEXT'] .= ' ' . sprintf($this->pi_getLL('status_additional_redirect'), $this->conf['listView.']['backPidRedirect.']['wait']); // generate redirect link unset($linkconf); $linkconf['parameter'] = $this->piVars['backPid']; $linkconf['useCacheHash'] = false; $redirectLink = $this->cObj->typoLink_URL($linkconf); // generate location header url $redirectUrl = t3lib_div::locationHeaderUrl($redirectLink); // process redirect header("Refresh: " . $this->conf['listView.']['backPidRedirect.']['wait'] . "; " . $redirectUrl); } } }
/** * Sends a redirect header response and exits. Additionaly 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 The target URL to redirect to * @param string An optional HTTP status header. Default is 'HTTP/1.1 303 See Other' */ public static function redirect($url, $httpStatus = self::HTTP_STATUS_303) { header($httpStatus); header('Location: ' . t3lib_div::locationHeaderUrl($url)); exit; }
/** * Creates a link to the news item * * @param int $newsId News item uid * * @return string */ protected function getVariousItemUrl($showUid, $currentSetup) { $languageParam = is_int($currentSetup['languageUid']) ? '&L=' . $currentSetup['languageUid'] : ''; $conf = array('parameter' => $currentSetup['singlePid'], 'additionalParams' => '&' . $currentSetup['linkParams'] . '=' . $showUid . $languageParam, 'returnLast' => 'url', 'useCacheHash' => TRUE); $link = htmlspecialchars($this->cObj->typoLink('', $conf)); return t3lib_div::locationHeaderUrl($link); }
function fix_links_callback($matches) { return $matches[1] . t3lib_div::locationHeaderUrl($matches[2]) . $matches[3]; }
/** * 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. * * @return string Return URL */ protected function getReturnURL() { 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(t3lib_div::getIndpEnv('TYPO3_SITE_URL'), strlen(t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST'))); $returnURL = $absoluteSiteURL . TYPO3_mainDir . 'sysext/' . $this->extKey . '/class.tx_openid_return.php?login_status=login&'; } if (t3lib_div::_GP('tx_openid_mode') == 'finish') { $requestURL = t3lib_div::_GP('tx_openid_location'); $claimedIdentifier = t3lib_div::_GP('tx_openid_claimed'); } else { $requestURL = t3lib_div::getIndpEnv('TYPO3_REQUEST_URL'); $claimedIdentifier = $this->loginData['uname']; } $returnURL .= 'tx_openid_location=' . rawurlencode($requestURL) . '&' . 'tx_openid_mode=finish&' . 'tx_openid_claimed=' . rawurlencode($claimedIdentifier) . '&' . 'tx_openid_signature=' . $this->getSignature($claimedIdentifier); return t3lib_div::locationHeaderUrl($returnURL); }
/** * Returns the convenient path for the routing Urls based on the TYPO3 mode. * * @param string $namespace * @return string */ public function getRoutingUrl($namespace) { $url = ''; if (TYPO3_MODE === 'FE') { $url = t3lib_div::locationHeaderUrl('?eID=ExtDirect&action=route&namespace='); } else { $url = t3lib_div::locationHeaderUrl(t3lib_div::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir . 'ajax.php?ajaxID=ExtDirect::route&namespace='); } $url .= rawurlencode($namespace); return $url; }
/** * Generates the API that is configured inside the ExtDirect configuration * array "$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect']". * * @param string $filerNamespace namespace that should be loaded like TYPO3.Backend * @return array javascript API configuration */ protected function generateAPI($filterNamespace) { $javascriptNamespaces = array(); if (is_array($this->settings)) { foreach ($this->settings as $javascriptName => $className) { $splittedJavascriptName = explode('.', $javascriptName); $javascriptObjectName = array_pop($splittedJavascriptName); $javascriptNamespace = implode('.', $splittedJavascriptName); // only items inside the wanted namespace if (strpos($javascriptNamespace, $filterNamespace) !== 0) { continue; } if (!isset($javascriptNamespaces[$javascriptNamespace])) { $javascriptNamespaces[$javascriptNamespace] = array('url' => t3lib_div::locationHeaderUrl('ajax.php?ajaxID=ExtDirect::route&namespace=') . rawurlencode($javascriptNamespace), 'type' => 'remoting', 'actions' => array(), 'namespace' => $javascriptNamespace); } $serverObject = t3lib_div::getUserObj($className, FALSE); $javascriptNamespaces[$javascriptNamespace]['actions'][$javascriptObjectName] = array(); foreach (get_class_methods($serverObject) as $methodName) { $reflectionMethod = new ReflectionMethod($serverObject, $methodName); $numberOfParameters = $reflectionMethod->getNumberOfParameters(); $docHeader = $reflectionMethod->getDocComment(); $formHandler = strpos($docHeader, '@formHandler') !== FALSE; $javascriptNamespaces[$javascriptNamespace]['actions'][$javascriptObjectName][] = array('name' => $methodName, 'len' => $numberOfParameters, 'formHandler' => $formHandler); } } } return $javascriptNamespaces; }
/** * Set redirect URL * * Sets Location header and response code. Forces replacement of any prior * redirects. * * @param string $url * @param int $code * @return Zend_Controller_Response_Abstract */ public function setRedirect($url, $code = 302) { // set last URL for the _isUrlInternal workaround if ($url == Mage::app()->getStore()->getBaseUrl() && $this->lastUrl) { $url = $this->lastUrl; } $this->canSendHeaders(true); #$this->setHeader ( 'Location', t3lib_div::locationHeaderUrl ( $url ), true )->setHttpResponseCode ( $code ); $this->sendHeaders(); $this->_isRedirect = true; header('Location: ' . t3lib_div::locationHeaderUrl($url)); exit; return $this; }
/** * Convert a page path to an ID. * * @param array Array of segments from virtual path * @return integer Page ID * @see decodeSpURL_idFromPath() */ function pagePathtoID(&$pathParts) { // Init: $GET_VARS = ''; // If pagePath cache is not disabled, look for entry: if (!$this->conf['disablePathCache']) { if (!isset($this->conf['firstHitPathCache'])) { $this->conf['firstHitPathCache'] = ((!isset($this->pObj->extConf['postVarSets']) || count($this->pObj->extConf['postVarSets']) == 0) && (!isset($this->pObj->extConf['fixedPostVars']) || count($this->pObj->extConf['fixedPostVars']) == 0)); } // 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! $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('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 (false !== ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result))) { break; } $GLOBALS['TYPO3_DB']->sql_free_result($result); if ($this->conf['firstHitPathCache']) { 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); } } else { $row = false; } // 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['pid'], 'postVarSets'); if (!is_array($postVars) || !isset($postVars[$postVar])) { // Check fixed $postVars = $this->pObj->getPostVarSetConfig($row['pid'], '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) { if ($this->pObj->enableDevLog) { t3lib_div::devLog('pagePathToId found row', 'realurl', 0, $row); } // 'expire' in the query is only for logging // Using pathq2 index! 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'); if ($this->pObj->enableDevLog) { t3lib_div::devLog('pagePathToId searched for new entry', 'realurl', 0, $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. $newUrlSegments[] = $this->pObj->filePart; // Add any filename as well $redirectUrl = implode('/', $newUrlSegments); // Create redirect URL: if ($this->pObj->extConf['fileName']['defaultToHTMLsuffixOnPrev'] && strlen($redirectUrl) > 1) { if (substr($redirectUrl, -1, 1) == '/') { $redirectUrl = substr($redirectUrl, 0, -1); } if (!t3lib_div::testInt($this->pObj->extConf['fileName']['defaultToHTMLsuffixOnPrev'])) { $redirectUrl .= $this->pObj->extConf['fileName']['defaultToHTMLsuffixOnPrev']; } else { $redirectUrl .= '.html'; } } header('HTTP/1.1 301 Moved Permanently'); header('Location: ' . t3lib_div::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($info, $GET_VARS) = $this->findIDByURL($pathParts); // Setting id: $id = ($info['id'] ? $info['id'] : 0); } // Return found ID: return array($id, $GET_VARS); }
/** * Process editing of a TO for renderTO() function * * @param array Data Structure. Passed by reference; The sheets found inside will be resolved if found! * @param array TO record row * @param string Template file path (absolute) * @param integer Process the headerPart instead of the bodyPart * @return array Array with two keys (0/1) with a) content and b) currentMappingInfo which is retrieved inside (currentMappingInfo will be different based on whether "head" or "body" content is "mapped") * @see renderTO() */ function renderTO_editProcessing(&$dataStruct, $row, $theFile, $headerPart = 0) { $msg = array(); // Converting GPvars into a "cmd" value: $cmd = ''; if (t3lib_div::GPvar('_reload_from')) { // Reverting to old values in TO $cmd = 'reload_from'; } elseif (t3lib_div::GPvar('_clear')) { // Resetting mapping $cmd = 'clear'; } elseif (t3lib_div::GPvar('_save_data_mapping')) { // Saving to Session $cmd = 'save_data_mapping'; } elseif (t3lib_div::GPvar('_save_to') || t3lib_div::GPvar('_save_to_return')) { // Saving to Template Object $cmd = 'save_to'; } // Getting data from tmplobj $templatemapping = unserialize($row['templatemapping']); if (!is_array($templatemapping)) { $templatemapping = array(); } // If that array contains sheets, then traverse them: if (is_array($dataStruct['sheets'])) { $dSheets = t3lib_div::resolveAllSheetsInDS($dataStruct); $dataStruct = array('ROOT' => array('tx_templavoila' => array('title' => 'ROOT of MultiTemplate', 'description' => 'Select the ROOT container for this template project. Probably just select a body-tag or some other HTML element which encapsulates ALL sub templates!'), 'type' => 'array', 'el' => array())); foreach ($dSheets['sheets'] as $nKey => $lDS) { if (is_array($lDS['ROOT'])) { $dataStruct['ROOT']['el'][$nKey] = $lDS['ROOT']; } } } // Get session data: $sesDat = $GLOBALS['BE_USER']->getSessionData($this->MCONF['name'] . '_mappingInfo'); // Set current mapping info arrays: $currentMappingInfo_head = is_array($sesDat['currentMappingInfo_head']) ? $sesDat['currentMappingInfo_head'] : array(); $currentMappingInfo = is_array($sesDat['currentMappingInfo']) ? $sesDat['currentMappingInfo'] : array(); $this->cleanUpMappingInfoAccordingToDS($currentMappingInfo, $dataStruct); // Perform processing for head // GPvars, incoming data $checkboxElement = t3lib_div::GPvar('checkboxElement', 1); $addBodyTag = t3lib_div::GPvar('addBodyTag'); // Update session data: if ($cmd == 'reload_from' || $cmd == 'clear') { $currentMappingInfo_head = is_array($templatemapping['MappingInfo_head']) && $cmd != 'clear' ? $templatemapping['MappingInfo_head'] : array(); $sesDat['currentMappingInfo_head'] = $currentMappingInfo_head; $GLOBALS['BE_USER']->setAndSaveSessionData($this->MCONF['name'] . '_mappingInfo', $sesDat); } else { if ($cmd == 'save_data_mapping' || $cmd == 'save_to') { $sesDat['currentMappingInfo_head'] = $currentMappingInfo_head = array('headElementPaths' => $checkboxElement, 'addBodyTag' => $addBodyTag ? 1 : 0); $GLOBALS['BE_USER']->setAndSaveSessionData($this->MCONF['name'] . '_mappingInfo', $sesDat); } } // Perform processing for body // GPvars, incoming data $inputData = t3lib_div::GPvar('dataMappingForm', 1); // Update session data: if ($cmd == 'reload_from' || $cmd == 'clear') { $currentMappingInfo = is_array($templatemapping['MappingInfo']) && $cmd != 'clear' ? $templatemapping['MappingInfo'] : array(); $this->cleanUpMappingInfoAccordingToDS($currentMappingInfo, $dataStruct); $sesDat['currentMappingInfo'] = $currentMappingInfo; $sesDat['dataStruct'] = $dataStruct; $GLOBALS['BE_USER']->setAndSaveSessionData($this->MCONF['name'] . '_mappingInfo', $sesDat); } else { if ($cmd == 'save_data_mapping' && is_array($inputData)) { $sesDat['currentMappingInfo'] = $currentMappingInfo = t3lib_div::array_merge_recursive_overrule($currentMappingInfo, $inputData); $sesDat['dataStruct'] = $dataStruct; // Adding data structure to session data so that the PREVIEW window can access the DS easily... $GLOBALS['BE_USER']->setAndSaveSessionData($this->MCONF['name'] . '_mappingInfo', $sesDat); } } // SAVE to template object if ($cmd == 'save_to') { $dataArr = array(); // Set content, either for header or body: $templatemapping['MappingInfo_head'] = $currentMappingInfo_head; $templatemapping['MappingInfo'] = $currentMappingInfo; // Getting cached data: reset($dataStruct); // Init; read file, init objects: $fileContent = t3lib_div::getUrl($theFile); $htmlParse = t3lib_div::makeInstance('t3lib_parsehtml'); $this->markupObj = t3lib_div::makeInstance('tx_templavoila_htmlmarkup'); // Fix relative paths in source: $relPathFix = dirname(substr($theFile, strlen(PATH_site))) . '/'; $uniqueMarker = uniqid('###') . '###'; $fileContent = $htmlParse->prefixResourcePath($relPathFix, $fileContent, array('A' => $uniqueMarker)); $fileContent = $this->fixPrefixForLinks($relPathFix, $fileContent, $uniqueMarker); // Get BODY content for caching: $contentSplittedByMapping = $this->markupObj->splitContentToMappingInfo($fileContent, $currentMappingInfo); $templatemapping['MappingData_cached'] = $contentSplittedByMapping['sub']['ROOT']; // Get HEAD content for caching: list($html_header) = $this->markupObj->htmlParse->getAllParts($htmlParse->splitIntoBlock('head', $fileContent), 1, 0); $this->markupObj->tags = $this->head_markUpTags; // Set up the markupObject to process only header-section tags: $h_currentMappingInfo = array(); if (is_array($currentMappingInfo_head['headElementPaths'])) { foreach ($currentMappingInfo_head['headElementPaths'] as $kk => $vv) { $h_currentMappingInfo['el_' . $kk]['MAP_EL'] = $vv; } } $contentSplittedByMapping = $this->markupObj->splitContentToMappingInfo($html_header, $h_currentMappingInfo); $templatemapping['MappingData_head_cached'] = $contentSplittedByMapping; // Get <body> tag: $reg = ''; //# //### Mansoor Ahmad - change because of PHP5.3 //# //eregi('<body[^>]*>',$fileContent,$reg); preg_match('/<body[^>]*>/i', $fileContent, $reg); $templatemapping['BodyTag_cached'] = $currentMappingInfo_head['addBodyTag'] ? $reg[0] : ''; $TOuid = t3lib_BEfunc::wsMapId('tx_templavoila_tmplobj', $row['uid']); $dataArr['tx_templavoila_tmplobj'][$TOuid]['templatemapping'] = serialize($templatemapping); $dataArr['tx_templavoila_tmplobj'][$TOuid]['fileref_mtime'] = @filemtime($theFile); $dataArr['tx_templavoila_tmplobj'][$TOuid]['fileref_md5'] = @md5_file($theFile); $tce = t3lib_div::makeInstance('t3lib_TCEmain'); $tce->stripslashes_values = 0; $tce->start($dataArr, array()); $tce->process_datamap(); unset($tce); $msg[] = $GLOBALS['LANG']->getLL('msgMappingSaved'); $row = t3lib_BEfunc::getRecordWSOL('tx_templavoila_tmplobj', $this->displayUid); $templatemapping = unserialize($row['templatemapping']); if (t3lib_div::GPvar('_save_to_return')) { header('Location: ' . t3lib_div::locationHeaderUrl($this->returnUrl)); exit; } } // Making the menu $menuItems = array(); $menuItems[] = '<input type="submit" name="_clear" value="Clear all" title="Clears all mapping information currently set." />'; // Make either "Preview" button (body) or "Set" button (header) if ($headerPart) { // Header: $menuItems[] = '<input type="submit" name="_save_data_mapping" value="Set" title="Will update session data with current settings." />'; } else { // Body: $menuItems[] = '<input type="submit" name="_preview" value="Preview" title="Will merge sample content into the template according to the current mapping information." />'; } $menuItems[] = '<input type="submit" name="_save_to" value="Save" title="Saving all mapping data into the Template Object." />'; if ($this->returnUrl) { $menuItems[] = '<input type="submit" name="_save_to_return" value="Save and Return" title="Saving all mapping data into the Template Object and return." />'; } // If a difference is detected...: if (serialize($templatemapping['MappingInfo_head']) != serialize($currentMappingInfo_head) || serialize($templatemapping['MappingInfo']) != serialize($currentMappingInfo)) { $menuItems[] = '<input type="submit" name="_reload_from" value="Revert" title="' . sprintf('Reverting %s mapping data to original data in the Template Object.', $headerPart ? 'HEAD' : 'BODY') . '" />'; $msg[] = 'The current mapping information is different from the mapping information in the Template Object'; } $content = ' <!-- Menu for saving Template Objects --> <table border="0" cellpadding="2" cellspacing="2" id="c-toMenu"> <tr class="bgColor5"> <td>' . implode('</td> <td>', $menuItems) . '</td> </tr> </table> '; // Making messages: foreach ($msg as $msgStr) { $content .= ' <p><img src="' . $GLOBALS['BACK_PATH'] . 'gfx/icon_note.gif" width="18" height="16" border="0" align="top" class="absmiddle" alt="" /><strong>' . htmlspecialchars($msgStr) . '</strong></p>'; } return array($content, $headerPart ? $currentMappingInfo_head : $currentMappingInfo); }
/** * does a redirect to a URL specified in the parameter and exits the request * @param mixed the URL to redirect to, if this is a numeric, it's supposed to be a * page ID, we should substitute this process at some point with the typoLink function * @param array Parameters for the link */ function redirectUrl($url, $addParams) { if (is_numeric($url)) { // these parameters have to be added to the redirect url: $addParams = array(); if (t3lib_div::_GP('L')) { // ob das noetig ist? $addParams['L'] = t3lib_div::_GP('L'); } $url = $this->pi_getPageLink($url, '', $addParams); } if ($this->conf['correctRedirectUrl']) { // ob das Sinn macht? $url = str_replace('&', '&', $url); } header('Location: ' . t3lib_div::locationHeaderUrl($url)); exit; }
/** * Checks various GET / POST parameters for submitted commands and handles them accordingly. * All commands will trigger a redirect by sending a location header after they work is done. * * Currently supported commands: 'createNewRecord', 'unlinkRecord', 'deleteRecord','pasteRecord', * 'makeLocalRecord', 'localizeElement', 'createNewPageTranslation' and 'editPageLanguageOverlay' * * @return void * @access protected */ function handleIncomingCommands() { $possibleCommands = array('createNewRecord', 'unlinkRecord', 'deleteRecord', 'pasteRecord', 'makeLocalRecord', 'localizeElement', 'createNewPageTranslation', 'editPageLanguageOverlay'); $hooks = $this->hooks_prepareObjectsArray('handleIncomingCommands'); foreach ($possibleCommands as $command) { if (($commandParameters = t3lib_div::_GP($command)) != '') { $redirectLocation = 'index.php?' . $this->link_getParameters(); $skipCurrentCommand = false; foreach ($hooks as $hookObj) { if (method_exists($hookObj, 'handleIncomingCommands_preProcess')) { $skipCurrentCommand = $skipCurrentCommand || $hookObj->handleIncomingCommands_preProcess($command, $redirectLocation, $this); } } if ($skipCurrentCommand) { continue; } switch ($command) { case 'createNewRecord': // Historically "defVals" has been used for submitting the preset row data for the new element, so we still support it here: $defVals = t3lib_div::_GP('defVals'); $newRow = is_array($defVals['tt_content']) ? $defVals['tt_content'] : array(); // Create new record and open it for editing $destinationPointer = $this->apiObj->flexform_getPointerFromString($commandParameters); $newUid = $this->apiObj->insertElement($destinationPointer, $newRow); if ($this->editingOfNewElementIsEnabled($newRow['tx_templavoila_ds'], $newRow['tx_templavoila_to'])) { // TODO If $newUid==0, than we could create new element. Need to handle it... $redirectLocation = $GLOBALS['BACK_PATH'] . 'alt_doc.php?edit[tt_content][' . $newUid . ']=edit&returnUrl=' . rawurlencode(t3lib_extMgm::extRelPath('templavoila') . 'mod1/index.php?' . $this->link_getParameters()); } break; case 'unlinkRecord': $unlinkDestinationPointer = $this->apiObj->flexform_getPointerFromString($commandParameters); $this->apiObj->unlinkElement($unlinkDestinationPointer); break; case 'deleteRecord': $deleteDestinationPointer = $this->apiObj->flexform_getPointerFromString($commandParameters); $this->apiObj->deleteElement($deleteDestinationPointer); break; case 'pasteRecord': $sourcePointer = $this->apiObj->flexform_getPointerFromString(t3lib_div::_GP('source')); $destinationPointer = $this->apiObj->flexform_getPointerFromString(t3lib_div::_GP('destination')); switch ($commandParameters) { case 'copy': $this->apiObj->copyElement($sourcePointer, $destinationPointer); break; case 'copyref': $this->apiObj->copyElement($sourcePointer, $destinationPointer, FALSE); break; case 'cut': $this->apiObj->moveElement($sourcePointer, $destinationPointer); break; case 'ref': list(, $uid) = explode(':', t3lib_div::_GP('source')); $this->apiObj->referenceElementByUid($uid, $destinationPointer); break; } break; case 'makeLocalRecord': $sourcePointer = $this->apiObj->flexform_getPointerFromString($commandParameters); $this->apiObj->copyElement($sourcePointer, $sourcePointer); $this->apiObj->unlinkElement($sourcePointer); break; case 'localizeElement': $sourcePointer = $this->apiObj->flexform_getPointerFromString(t3lib_div::_GP('source')); $this->apiObj->localizeElement($sourcePointer, $commandParameters); break; case 'createNewPageTranslation': // Create parameters and finally run the classic page module for creating a new page translation $params = '&edit[pages_language_overlay][' . intval(t3lib_div::_GP('pid')) . ']=new&overrideVals[pages_language_overlay][doktype]=' . intval(t3lib_div::_GP('doktype')) . '&overrideVals[pages_language_overlay][sys_language_uid]=' . intval($commandParameters); $returnUrl = '&returnUrl=' . rawurlencode(t3lib_extMgm::extRelPath('templavoila') . 'mod1/index.php?' . $this->link_getParameters()); $redirectLocation = $GLOBALS['BACK_PATH'] . 'alt_doc.php?' . $params . $returnUrl; break; case 'editPageLanguageOverlay': // Look for pages language overlay record for language: $sys_language_uid = intval($commandParameters); $params = ''; if ($sys_language_uid != 0) { // Edit overlay record list($pLOrecord) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'pages_language_overlay', 'pid=' . intval($this->id) . ' AND sys_language_uid=' . $sys_language_uid . t3lib_BEfunc::deleteClause('pages_language_overlay') . t3lib_BEfunc::versioningPlaceholderClause('pages_language_overlay')); if ($pLOrecord) { t3lib_beFunc::workspaceOL('pages_language_overlay', $pLOrecord); if (is_array($pLOrecord)) { $params = '&edit[pages_language_overlay][' . $pLOrecord['uid'] . ']=edit'; } } } else { // Edit default language (page properties) // No workspace overlay because we already on this page $params = '&edit[pages][' . intval($this->id) . ']=edit'; } if ($params) { $returnUrl = '&returnUrl=' . rawurlencode(t3lib_extMgm::extRelPath('templavoila') . 'mod1/index.php?' . $this->link_getParameters()); $redirectLocation = $GLOBALS['BACK_PATH'] . 'alt_doc.php?' . $params . $returnUrl; //.'&localizationMode=text'; } break; } foreach ($hooks as $hookObj) { if (method_exists($hookObj, 'handleIncomingCommands_postProcess')) { $hookObj->handleIncomingCommands_postProcess($command, $redirectLocation, $this); } } } } if (isset($redirectLocation)) { header('Location: ' . t3lib_div::locationHeaderUrl($redirectLocation)); } }
$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'; // hooking into TCE Main to monitor record updates that may require deleting documents from the index $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'; } # ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- # ----- # // register click menu item to initialize the Solr connections for a single site // visible for admin users only t3lib_extMgm::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 = ' . t3lib_div::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] '); t3lib_extMgm::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 t3lib_extMgm::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,
/** * Creates the module's content * * This function creates the module's content. * * @return Void * @see updateData * @see makeLinks * @see getConfigArray * @see showTemplate */ function moduleContent() { // DEBUG ONLY - Show template //t3lib_div::debug($conf); // Object has been selected? if ($id = t3lib_div::_GP('tsobj')) { // Update flexform data $this->updateData($id); // Return to TCE form header('Location: ' . t3lib_div::locationHeaderUrl($this->P["returnUrl"])); } else { // Start section $this->content .= $this->doc->sectionBegin(); // Description $this->content .= '<div style="padding: 5px; border: dashed 1px #666666;">' . $GLOBALS['LANG']->getLL('description') . '<br /><strong>' . $GLOBALS['LANG']->getLL('instructions') . '</strong></div>'; // Spacer $this->content .= $this->doc->spacer(5); // Create links $this->content .= $this->makeLinks(); // Get TypoScript template for current page $conf = $this->getConfigArray(); // Show TS template hierarchy $this->content .= $this->showTemplate($conf); // Create links $this->content .= $this->makeLinks(); // End section $this->content .= $this->doc->sectionEnd(); } }
/** * Plugin Main Method * * @param string $content: The content of the PlugIn * @param array $conf: The PlugIn Configuration * @return The content that should be displayed on the website */ public function main($content, $conf) { /*{{{*/ $this->pi_setPiVarDefaults(); $this->pi_loadLL(); // path to this extension $this->extPath = t3lib_extMgm::siteRelPath($this->extKey); // create instance of the extension library $this->lib = t3lib_div::makeInstance('tx_ketroubletickets_lib'); // Configuring so caching is not expected. This value means that no // cHash params are ever set. We do this, because it's a USER_INT // object! $this->pi_USER_INT_obj = 1; // get the pidList and the recursive flag from the content object // if this plugin has been inserted into a content column (and has not // been included via typoscript) if (strstr($this->cObj->currentRecord, 'tt_content')) { $conf['pidList'] = $this->cObj->data['pages'] ? $this->cObj->data['pages'] : $conf['pidList']; $conf['recursive'] = $this->cObj->data['recursive'] ? $this->cObj->data['recursive'] : $conf['recursive']; } // make the configurationen class-wide available $this->conf = $conf; // a local content object (with clear configuration) $lcObj = t3lib_div::makeInstance('tslib_cObj'); // start with empty content $content = ''; // get the template $templateFile = $this->conf['templateFile'] ? $this->conf['templateFile'] : $this->extPath . 'res/template/ke_troubletickets_pi2.tmpl.htm'; $this->templateCode = $lcObj->fileResource($templateFile); if (!$this->templateCode) { return '<p class="error">' . $this->pi_getLL('error_no_template') . '</p>'; } // General permission check: This plugin only makes sense if a user is logged in if (!$GLOBALS['TSFE']->loginUser) { return $this->pi_wrapInBaseClass($this->pi_getLL('error_not_logged_in', 'Please log in.')); } /****************************************** * Actions *****************************************/ // show single view if searchword is ticket UID if ($this->isValidTicketUid($this->piVars['sword'])) { $this->piVars['showUid'] = intval($this->piVars['sword']); $this->piVars['sword'] = ''; // get ticket data $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,pid,category', $this->tablename, 'uid=' . $this->piVars['showUid'] . $lcObj->enableFields($this->tablename)); if ($GLOBALS['TYPO3_DB']->sql_num_rows($res) > 0) { $ticket = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); } // get the category data $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('singleviewpage', $this->categoryTablename, 'uid="' . $ticket['category'] . '" ' . $lcObj->enableFields($this->categoryTablename)); if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) { $categoryData = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res); } // find out the singleview pid // the singleviewpage must be set in the category // If the category of the current ticket contains a single view page, // use that. Otherwise use the current page. if (is_array($categoryData) && !empty($categoryData['singleviewpage'])) { $singleViewPage = $categoryData['singleviewpage']; // render the link $linkToTicketURL = $this->pi_getPageLink($singleViewPage, '_blank', array('tx_ketroubletickets_pi1[showUid]' => $ticket['uid'])); // do the redirect header('Location:' . t3lib_div::locationHeaderUrl($linkToTicketURL)); } else { $content .= '<p class="error">' . $this->pi_getLL('error_no_singleviewpage') . '</p>'; } } if ($this->piVars['sword']) { $content .= '<p class="error">' . $this->pi_getLL('error_not_found') . '</p>'; } $content .= $this->renderForm(); return $this->pi_wrapInBaseClass($content); }
/** * Will exit after redirect to backend (with "&edit=...") if $this->decode_editInBackend is set * * @param integer Page id. * @return void */ protected function decodeSpURL_jumpAdmin_goBackend($pageId) { if ($this->decode_editInBackend) { $editUrl = t3lib_div::getIndpEnv('TYPO3_SITE_URL') . TYPO3_mainDir . 'alt_main.php?edit=' . intval($pageId); header('Location: ' . t3lib_div::locationHeaderUrl($editUrl)); exit(); } }