示例#1
0
 /**
  * Generates a workspace preview link.
  *
  * @param integer $uid The ID of the record to be linked
  * @return string the full domain including the protocol http:// or https://, but without the trailing '/'
  */
 public function generateWorkspacePreviewLink($uid)
 {
     $ttlHours = intval($GLOBALS['BE_USER']->getTSConfigVal('options.workspaces.previewLinkTTLHours'));
     $ttlHours = ($ttlHours ? $ttlHours : 24 * 2) * 3600;
     $linkParams = array('ADMCMD_prev' => t3lib_BEfunc::compilePreviewKeyword('', $GLOBALS['BE_USER']->user['uid'], $ttlHours, $this->getCurrentWorkspace()), 'id' => $uid);
     return t3lib_BEfunc::getViewDomain($uid) . '/index.php?' . t3lib_div::implodeArrayForUrl('', $linkParams);
 }
 /**
  * Creates URL to page using page id and parameters
  *
  * @param int $pageId
  * @param string $parameters
  * @return	string	Path to page or empty string
  */
 public static function getPagePath($pageId, $parameters = '')
 {
     if (is_array($parameters)) {
         $parameters = t3lib_div::implodeArrayForUrl('', $parameters);
     }
     $data = array('id' => intval($pageId));
     if ($parameters != '' && $parameters[0] == '&') {
         $data['parameters'] = $parameters;
     }
     $siteUrl = self::getSiteUrl($pageId);
     if ($siteUrl) {
         $url = $siteUrl . 'index.php?eID=pagepath&data=' . base64_encode(serialize($data));
         // Send TYPO3 cookies as this may affect path generation
         $headers = array('Cookie: fe_typo_user='******'fe_typo_user']);
         $result = t3lib_div::getURL($url, false, $headers);
         $urlParts = parse_url($result);
         if (!is_array($urlParts)) {
             // filter_var is too strict (for example, underscore characters make it fail). So we use parse_url here for a quick check.
             $result = '';
         } elseif ($result) {
             // See if we need to prepend domain part
             if ($urlParts['host'] == '') {
                 $result = rtrim($siteUrl, '/') . '/' . ltrim($result, '/');
             }
         }
     } else {
         $result = '';
     }
     return $result;
 }
 /**
  * Returns a linked string made from typoLink parameters.
  *
  * This function takes $label as a string, wraps it in a link-tag based on the $params string, which should contain data like that you would normally pass to the popular <LINK>-tag in the TSFE.
  * Optionally you can supply $urlParameters which is an array with key/value pairs that are rawurlencoded and appended to the resulting url.
  *
  * @param	object		cObject
  * @param	string		Text string being wrapped by the link.
  * @param	string		Link parameter; eg. "123" for page id, "*****@*****.**" for email address, "http://...." for URL, "fileadmin/blabla.txt" for file.
  * @param	array		An array with key/value pairs representing URL parameters to set. Values NOT URL-encoded yet.
  * @param	string		Specific target set, if any. (Default is using the current)
  * @param	array		Configuration
  * @return	string		The wrapped $label-text string
  * @see getTypoLink_URL()
  */
 public static function getTypoLink($cObj, $label, $params, $urlParameters = array(), $target = '', $conf = array())
 {
     $result = FALSE;
     if (is_object($cObj)) {
         $conf['parameter'] = $params;
         if ($target) {
             if (!isset($conf['target'])) {
                 $conf['target'] = $target;
             }
             if (!isset($conf['extTarget'])) {
                 $conf['extTarget'] = $target;
             }
         }
         if (is_array($urlParameters)) {
             if (count($urlParameters)) {
                 $conf['additionalParams'] .= t3lib_div::implodeArrayForUrl('', $urlParameters);
             }
         } else {
             $conf['additionalParams'] .= $urlParameters;
         }
         $result = $cObj->typolink($label, $conf);
     } else {
         $out = 'error in call of tx_div2007_alpha5::getTypoLink: parameter $cObj is not an object';
         debug($out, '$out');
         // keep this
     }
     return $result;
 }
 /**
  * Main function
  *
  * @return	void
  */
 function main()
 {
     global $LANG, $TCA, $BACK_PATH;
     $content = '';
     $param = t3lib_div::_GP('edit');
     $table = key($param);
     $uid = (string) key($param[$table]);
     $cmd = $param[$table][$uid];
     if (is_array($TCA[$table]) and $cmd == 'new') {
         $this->defaultPid = tx_dam_db::getPid();
         $getArray['edit'][$table][$this->defaultPid] = 'new';
         $getArray['defVals'] = t3lib_div::_GP('defVals');
         $getArray['defVals'][$table]['pid'] = $this->defaultPid;
         $getArray['returnUrl'] = $this->pObj->returnUrl;
         $getArray['redirect'] = $this->pObj->redirect;
         $getArray = t3lib_div::compileSelectedGetVarsFromArray('returnUrl,redirect,edit,defVals,overrideVals,columnsOnly,disHelp,noView,editRegularContentFromId', $getArray);
         $getUrl = t3lib_div::implodeArrayForUrl('', $getArray);
         header('Location: ' . $BACK_PATH . 'alt_doc.php?id=' . $this->defaultPid . $getUrl);
         exit;
     } else {
         $content .= 'wrong comand!';
     }
     #TODO do it always this way (with if)
     if ($this->pObj->returnUrl) {
         $content .= '<br /><br />' . $this->pObj->btn_back('', $this->pObj->returnUrl);
     }
     // todo csh
     #		$content.= t3lib_BEfunc::cshItem('xMOD_csh_corebe', 'file_rename', $GLOBALS['BACK_PATH'],'<br/>');
     return $content;
 }
 /**
  * Renders entry for one page of the current document.
  *
  * @access	protected
  *
  * @param	integer		$number: The page to render
  * @param	string		$template: Parsed template subpart
  *
  * @return	string		The rendered entry ready for output
  */
 protected function getEntry($number, $template)
 {
     // Set current page if applicable.
     if (!empty($this->piVars['page']) && $this->piVars['page'] == $number) {
         $markerArray['###STATE###'] = 'cur';
     } else {
         $markerArray['###STATE###'] = 'no';
     }
     // Set page number.
     $markerArray['###NUMBER###'] = $number;
     // Set pagination.
     $markerArray['###PAGINATION###'] = $this->doc->physicalPagesInfo[$this->doc->physicalPages[$number]]['label'];
     // Get thumbnail or placeholder.
     if (!empty($this->doc->physicalPagesInfo[$this->doc->physicalPages[$number]]['files'][$this->conf['fileGrpThumbs']])) {
         $thumbnailFile = $this->doc->getFileLocation($this->doc->physicalPagesInfo[$this->doc->physicalPages[$number]]['files'][$this->conf['fileGrpThumbs']]);
     } elseif (!empty($this->conf['placeholder'])) {
         $thumbnailFile = $GLOBALS['TSFE']->tmpl->getFileName($this->conf['placeholder']);
     } else {
         $thumbnailFile = t3lib_extMgm::siteRelPath($this->extKey) . 'plugins/pagegrid/placeholder.jpg';
     }
     $thumbnail = '<img alt="' . $markerArray['###PAGINATION###'] . '" src="' . $thumbnailFile . '" />';
     // Get new plugin variables for typolink.
     $piVars = $this->piVars;
     // Unset no longer needed plugin variables.
     // unset($piVars['pagegrid']) is for DFG Viewer compatibility!
     unset($piVars['pointer'], $piVars['DATA'], $piVars['pagegrid']);
     $piVars['page'] = $number;
     $linkConf = array('useCacheHash' => 1, 'parameter' => $this->conf['targetPid'], 'additionalParams' => t3lib_div::implodeArrayForUrl($this->prefixId, $piVars, '', TRUE, FALSE), 'title' => $markerArray['###PAGINATION###']);
     $markerArray['###THUMBNAIL###'] = $this->cObj->typoLink($thumbnail, $linkConf);
     return $this->cObj->substituteMarkerArray($template, $markerArray);
 }
示例#6
0
 /**
  * Generate a different preview link
  *
  * @param string $status status
  * @param string $table table name
  * @param integer $recordUid id of the record
  * @param array $fields fieldArray
  * @param t3lib_TCEmain $parentObject parent Object
  * @return void
  */
 public function processDatamap_afterDatabaseOperations($status, $table, $recordUid, array $fields, t3lib_TCEmain $parentObject)
 {
     // Clear category cache
     if ($table === 'tx_news_domain_model_category') {
         $cache = t3lib_div::makeInstance('Tx_News_Service_CacheService', 'news_categorycache');
         $cache->flush();
     }
     // Preview link
     if ($table === 'tx_news_domain_model_news') {
         // direct preview
         if (!is_numeric($recordUid)) {
             $recordUid = $parentObject->substNEWwithIDs[$recordUid];
         }
         if (isset($GLOBALS['_POST']['_savedokview_x']) && !$fields['type']) {
             // If "savedokview" has been pressed and current article has "type" 0 (= normal news article)
             $pagesTsConfig = t3lib_BEfunc::getPagesTSconfig($GLOBALS['_POST']['popViewId']);
             if ($pagesTsConfig['tx_news.']['singlePid']) {
                 $record = t3lib_BEfunc::getRecord('tx_news_domain_model_news', $recordUid);
                 $parameters = array('no_cache' => 1, 'tx_news_pi1[controller]' => 'News', 'tx_news_pi1[action]' => 'detail', 'tx_news_pi1[news_preview]' => $record['uid']);
                 if ($record['sys_language_uid'] > 0) {
                     if ($record['l10n_parent'] > 0) {
                         $parameters['tx_news_pi1[news_preview]'] = $record['l10n_parent'];
                     }
                     $parameters['L'] = $record['sys_language_uid'];
                 }
                 $GLOBALS['_POST']['popViewId_addParams'] = t3lib_div::implodeArrayForUrl('', $parameters, '', FALSE, TRUE);
                 $GLOBALS['_POST']['popViewId'] = $pagesTsConfig['tx_news.']['singlePid'];
             }
         }
     }
 }
 /**
  * Creates an isntance of this class.
  *
  * @return void
  */
 public function __construct()
 {
     $urlParameters = tx_realurl::array_merge_recursive_overrule($_GET, $_POST);
     $this->currentPage = max(1, intval($urlParameters['page']));
     unset($urlParameters['page']);
     unset($urlParameters['cmd']);
     $this->baseURL = t3lib_div::getIndpEnv('TYPO3_REQUEST_SCRIPT') . '?' . t3lib_div::implodeArrayForUrl('', $urlParameters);
     $this->resultsPerPage = self::RESULTS_PER_PAGE_DEFAULT;
 }
示例#8
0
function orderParameters($vars)	{

	$all = explode('&',$vars);
	$collect = array();
	foreach($all as $v)	{
		list($p,$val) = explode('=',$v,2);
		if (strlen($val))		$collect[rawurldecode($p)] = rawurldecode($val);
	}

	ksort($collect);
	return t3lib_div::implodeArrayForUrl('', $collect);
}
 /**
  * Creates a link to a given page with a given link text with the current
  * tx_solr parameters appended to the URL
  *
  * @param	array	Array of arguments, [0] is the link text, [1] is the (optional) page Id to link to (otherwise TSFE->id), [2] are additional URL parameters, [3] use cache, defaults to FALSE
  * @return	string	complete anchor tag with URL and link text
  */
 public function execute(array $arguments = array())
 {
     $linkText = $arguments[0];
     $pageId = $arguments[1] ? intval($arguments[1]) : $GLOBALS['TSFE']->id;
     $additionalParameters = $arguments[2] ? $arguments[2] : '';
     $useCache = $arguments[3] ? TRUE : FALSE;
     $query = $this->search->getQuery();
     $prefix = 'tx_solr';
     $getParameters = t3lib_div::_GET($prefix);
     $piVars = is_array($getParameters) ? $getParameters : array();
     $queryParameters = array_merge($piVars, array('q' => $query->getKeywords()));
     $queryParameters = $query->removeUnwantedUrlParameters($queryParameters);
     $linkConfiguration = array('useCacheHash' => $useCache, 'no_cache' => FALSE, 'parameter' => $pageId, 'additionalParams' => t3lib_div::implodeArrayForUrl('', array($prefix => $queryParameters), '', TRUE) . $additionalParameters);
     return $this->contentObject->typoLink($linkText, $linkConfiguration);
 }
 /**
  * The mother of all functions creating links/URLs etc in a TypoScript environment.
  * See the references below.
  * Basically this function takes care of issues such as type,id,alias and Mount Points, URL rewriting (through hooks), M5/B6 encoded parameters etc.
  * It is important to pass all links created through this function since this is the guarantee that globally configured settings for link creating are observed and that your applications will conform to the various/many configuration options in TypoScript Templates regarding this.
  *
  * @param	array		The page record of the page to which we are creating a link. Needed due to fields like uid, alias, target, no_cache, title and sectionIndex_uid.
  * @param	string		Default target string to use IF not $page['target'] is set.
  * @param	boolean		If set, then the "&no_cache=1" parameter is included in the URL.
  * @param	string		Alternative script name if you don't want to use $GLOBALS['TSFE']->config['mainScript'] (normally set to "index.php")
  * @param	array		Array with overriding values for the $page array.
  * @param	string		Additional URL parameters to set in the URL. Syntax is "&foo=bar&foo2=bar2" etc. Also used internally to add parameters if needed.
  * @param	string		If you set this value to something else than a blank string, then the typeNumber used in the link will be forced to this value. Normally the typeNum is based on the target set OR on $GLOBALS['TSFE']->config['config']['forceTypeValue'] if found.
  * @param	string		The target Doamin, if any was detected in typolink
  * @return	array		Contains keys like "totalURL", "url", "sectionIndex", "linkVars", "no_cache", "type", "target" of which "totalURL" is normally the value you would use while the other keys contains various parts that was used to construct "totalURL"
  * @see tslib_frameset::frameParams(), tslib_cObj::typoLink(), tslib_cObj::SEARCHRESULT(), TSpagegen::pagegenInit(), tslib_menu::link()
  */
 function linkData($page, $oTarget, $no_cache, $script, $overrideArray = '', $addParams = '', $typeOverride = '', $targetDomain = '')
 {
     global $TYPO3_CONF_VARS;
     $LD = array();
     // Overriding some fields in the page record and still preserves the values by adding them as parameters. Little strange function.
     if (is_array($overrideArray)) {
         foreach ($overrideArray as $theKey => $theNewVal) {
             $addParams .= '&real_' . $theKey . '=' . rawurlencode($page[$theKey]);
             $page[$theKey] = $theNewVal;
         }
     }
     // Adding Mount Points, "&MP=", parameter for the current page if any is set:
     if (!strstr($addParams, '&MP=')) {
         if (trim($GLOBALS['TSFE']->MP_defaults[$page['uid']])) {
             // Looking for hardcoded defaults:
             $addParams .= '&MP=' . rawurlencode(trim($GLOBALS['TSFE']->MP_defaults[$page['uid']]));
         } elseif ($GLOBALS['TSFE']->config['config']['MP_mapRootPoints']) {
             // Else look in automatically created map:
             $m = $this->getFromMPmap($page['uid']);
             if ($m) {
                 $addParams .= '&MP=' . rawurlencode($m);
             }
         }
     }
     // Setting ID/alias:
     if (!$script) {
         $script = $GLOBALS['TSFE']->config['mainScript'];
     }
     if ($page['alias']) {
         $LD['url'] = $script . '?id=' . rawurlencode($page['alias']);
     } else {
         $LD['url'] = $script . '?id=' . $page['uid'];
     }
     // Setting target
     $LD['target'] = trim($page['target']) ? trim($page['target']) : $oTarget;
     // typeNum
     $typeNum = $this->setup[$LD['target'] . '.']['typeNum'];
     if (!t3lib_div::testInt($typeOverride) && intval($GLOBALS['TSFE']->config['config']['forceTypeValue'])) {
         $typeOverride = intval($GLOBALS['TSFE']->config['config']['forceTypeValue']);
     }
     if (strcmp($typeOverride, '')) {
         $typeNum = $typeOverride;
     }
     // Override...
     if ($typeNum) {
         $LD['type'] = '&type=' . intval($typeNum);
     } else {
         $LD['type'] = '';
     }
     $LD['orig_type'] = $LD['type'];
     // Preserving the type number.
     // noCache
     $LD['no_cache'] = trim($page['no_cache']) || $no_cache ? '&no_cache=1' : '';
     // linkVars
     if ($GLOBALS['TSFE']->config['config']['uniqueLinkVars']) {
         if ($addParams) {
             $LD['linkVars'] = t3lib_div::implodeArrayForUrl('', t3lib_div::explodeUrl2Array($GLOBALS['TSFE']->linkVars . $addParams));
         } else {
             $LD['linkVars'] = $GLOBALS['TSFE']->linkVars;
         }
     } else {
         $LD['linkVars'] = $GLOBALS['TSFE']->linkVars . $addParams;
     }
     // Add absRefPrefix if exists.
     $LD['url'] = $GLOBALS['TSFE']->absRefPrefix . $LD['url'];
     // If the special key 'sectionIndex_uid' (added 'manually' in tslib/menu.php to the page-record) is set, then the link jumps directly to a section on the page.
     $LD['sectionIndex'] = $page['sectionIndex_uid'] ? '#c' . $page['sectionIndex_uid'] : '';
     // Compile the normal total url
     $LD['totalURL'] = $this->removeQueryString($LD['url'] . $LD['type'] . $LD['no_cache'] . $LD['linkVars'] . $GLOBALS['TSFE']->getMethodUrlIdToken) . $LD['sectionIndex'];
     // Call post processing function for link rendering:
     if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['linkData-PostProc'])) {
         $_params = array('LD' => &$LD, 'args' => array('page' => $page, 'oTarget' => $oTarget, 'no_cache' => $no_cache, 'script' => $script, 'overrideArray' => $overrideArray, 'addParams' => $addParams, 'typeOverride' => $typeOverride, 'targetDomain' => $targetDomain), 'typeNum' => $typeNum);
         foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tstemplate.php']['linkData-PostProc'] as $_funcRef) {
             t3lib_div::callUserFunction($_funcRef, $_params, $this);
         }
     }
     // Return the LD-array
     return $LD;
 }
 /**
  * Builds a collection list
  *
  * @access	protected
  *
  * @return	string		The list of collections ready to output
  */
 protected function showCollectionList()
 {
     $additionalWhere = '';
     $orderBy = 'tx_dlf_collections.label';
     // Handle collections set by configuration.
     if ($this->conf['collections']) {
         if (count(explode(',', $this->conf['collections'])) == 1 && empty($this->conf['dont_show_single'])) {
             $this->showSingleCollection(intval(trim($this->conf['collections'], ' ,')));
         }
         $additionalWhere .= ' AND tx_dlf_collections.uid IN (' . $GLOBALS['TYPO3_DB']->cleanIntList($this->conf['collections']) . ')';
         $orderBy = 'FIELD(tx_dlf_collections.uid, ' . $GLOBALS['TYPO3_DB']->cleanIntList($this->conf['collections']) . ')';
     }
     // 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) {
         if (!empty($GLOBALS['TSFE']->fe_user->user['uid'])) {
             $additionalWhere .= ' AND tx_dlf_collections.fe_cruser_id=' . intval($GLOBALS['TSFE']->fe_user->user['uid']);
         } else {
             $additionalWhere .= ' AND NOT tx_dlf_collections.fe_cruser_id=0';
         }
     }
     // Get collections.
     $result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tx_dlf_collections.uid AS uid,tx_dlf_collections.label AS label,tx_dlf_collections.thumbnail AS thumbnail,tx_dlf_collections.description AS description,tx_dlf_collections.priority AS priority,COUNT(tx_dlf_documents.uid) AS titles', 'tx_dlf_documents', 'tx_dlf_relations', 'tx_dlf_collections', 'AND tx_dlf_collections.pid=' . intval($this->conf['pages']) . ' AND tx_dlf_documents.partof=0 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_collections.uid', $orderBy, '');
     $count = $GLOBALS['TYPO3_DB']->sql_num_rows($result);
     $content = '';
     if ($count == 1 && empty($this->conf['dont_show_single'])) {
         $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
         $this->showSingleCollection(intval($resArray['uid']));
     } elseif ($count > 0) {
         // Get number of volumes per collection.
         $resultVolumes = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tx_dlf_collections.uid AS uid,COUNT(tx_dlf_documents.uid) AS volumes', 'tx_dlf_documents', 'tx_dlf_relations', 'tx_dlf_collections', 'AND tx_dlf_collections.pid=' . intval($this->conf['pages']) . ' AND NOT tx_dlf_documents.uid IN (SELECT DISTINCT tx_dlf_documents.partof FROM tx_dlf_documents WHERE NOT tx_dlf_documents.partof=0' . tx_dlf_helper::whereClause('tx_dlf_documents') . ') 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_collections.uid', '', '');
         $volumes = array();
         while ($resArrayVolumes = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($resultVolumes)) {
             $volumes[$resArrayVolumes['uid']] = $resArrayVolumes['volumes'];
         }
         // Process results.
         while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
             // Generate random but unique array key taking priority into account.
             do {
                 $_key = $resArray['priority'] * 1000 + mt_rand(0, 1000);
             } while (!empty($markerArray[$_key]));
             // Merge plugin variables with new set of values.
             $additionalParams = array('collection' => $resArray['uid']);
             if (is_array($this->piVars)) {
                 $piVars = $this->piVars;
                 unset($piVars['DATA']);
                 $additionalParams = tx_dlf_helper::array_merge_recursive_overrule($piVars, $additionalParams);
             }
             // Build typolink configuration array.
             $conf = array('useCacheHash' => 1, 'parameter' => $GLOBALS['TSFE']->id, 'additionalParams' => t3lib_div::implodeArrayForUrl($this->prefixId, $additionalParams, '', TRUE, FALSE));
             // Link collection's title to list view.
             $markerArray[$_key]['###TITLE###'] = $this->cObj->typoLink(htmlspecialchars($resArray['label']), $conf);
             // Add feed link if applicable.
             if (!empty($this->conf['targetFeed'])) {
                 $img = '<img src="' . t3lib_extMgm::siteRelPath($this->extKey) . 'res/icons/txdlffeeds.png" alt="' . $this->pi_getLL('feedAlt', '', TRUE) . '" title="' . $this->pi_getLL('feedTitle', '', TRUE) . '" />';
                 $markerArray[$_key]['###FEED###'] = $this->pi_linkTP($img, array($this->prefixId => array('collection' => $resArray['uid'])), FALSE, $this->conf['targetFeed']);
             } else {
                 $markerArray[$_key]['###FEED###'] = '';
             }
             // Add thumbnail.
             if (!empty($resArray['thumbnail'])) {
                 $markerArray[$_key]['###THUMBNAIL###'] = '<img alt="" title="' . htmlspecialchars($resArray['label']) . '" src="' . $resArray['thumbnail'] . '" />';
             } else {
                 $markerArray[$_key]['###THUMBNAIL###'] = '';
             }
             // Add description.
             $markerArray[$_key]['###DESCRIPTION###'] = $this->pi_RTEcssText($resArray['description']);
             // Build statistic's output.
             $labelTitles = $this->pi_getLL($resArray['titles'] > 1 ? 'titles' : 'title', '', FALSE);
             $markerArray[$_key]['###COUNT_TITLES###'] = htmlspecialchars($resArray['titles'] . $labelTitles);
             $labelVolumes = $this->pi_getLL($volumes[$resArray['uid']] > 1 ? 'volumes' : 'volume', '', FALSE);
             $markerArray[$_key]['###COUNT_VOLUMES###'] = htmlspecialchars($volumes[$resArray['uid']] . $labelVolumes);
         }
         // Randomize sorting?
         if (!empty($this->conf['randomize'])) {
             ksort($markerArray, SORT_NUMERIC);
             // Don't cache the output.
             $this->setCache(FALSE);
         }
         $entry = $this->cObj->getSubpart($this->template, '###ENTRY###');
         foreach ($markerArray as $marker) {
             $content .= $this->cObj->substituteMarkerArray($entry, $marker);
         }
         // Hook for getting custom collection hierarchies/subentries (requested by SBB).
         foreach ($this->hookObjects as $hookObj) {
             if (method_exists($hookObj, 'showCollectionList_getCustomCollectionList')) {
                 $hookObj->showCollectionList_getCustomCollectionList($this, $this->conf['templateFile'], $content, $markerArray);
             }
         }
         return $this->cObj->substituteSubpart($this->template, '###ENTRY###', $content, TRUE);
     }
     return $content;
 }
示例#12
0
    /**
     * Import part of module
     *
     * @param	array		Content of POST VAR tx_impexp[]..
     * @return	void		Setting content in $this->content
     */
    function importData($inData)
    {
        global $TCA, $LANG, $BE_USER;
        $access = is_array($this->pageinfo) ? 1 : 0;
        if ($this->id && $access || $BE_USER->user['admin'] && !$this->id) {
            if ($BE_USER->user['admin'] && !$this->id) {
                $this->pageinfo = array('title' => '[root-level]', 'uid' => 0, 'pid' => 0);
            }
            if ($inData['new_import']) {
                unset($inData['import_mode']);
            }
            $import = t3lib_div::makeInstance('tx_impexp');
            $import->init(0, 'import');
            $import->update = $inData['do_update'];
            $import->import_mode = $inData['import_mode'];
            $import->enableLogging = $inData['enableLogging'];
            $import->global_ignore_pid = $inData['global_ignore_pid'];
            $import->force_all_UIDS = $inData['force_all_UIDS'];
            $import->showDiff = !$inData['notShowDiff'];
            $import->allowPHPScripts = $inData['allowPHPScripts'];
            $import->softrefInputValues = $inData['softrefInputValues'];
            // OUTPUT creation:
            $menuItems = array();
            // Make input selector:
            $path = $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'];
            // must have trailing slash.
            $filesInDir = t3lib_div::getFilesInDir(PATH_site . $path, 't3d,xml', 1, 1);
            $userPath = $this->userSaveFolder();
            //Files from User-Dir
            $filesInUserDir = t3lib_div::getFilesInDir($userPath, 't3d,xml', 1, 1);
            $filesInDir = array_merge($filesInUserDir, $filesInDir);
            if (is_dir(PATH_site . $path . 'export/')) {
                $filesInDir = array_merge($filesInDir, t3lib_div::getFilesInDir(PATH_site . $path . 'export/', 't3d,xml', 1, 1));
            }
            $tempFolder = $this->userTempFolder();
            if ($tempFolder) {
                $temp_filesInDir = t3lib_div::getFilesInDir($tempFolder, 't3d,xml', 1, 1);
                $filesInDir = array_merge($filesInDir, $temp_filesInDir);
            }
            // Configuration
            $row = array();
            $opt = array('');
            foreach ($filesInDir as $file) {
                $opt[$file] = substr($file, strlen(PATH_site));
            }
            $row[] = '<tr class="bgColor5">
					<td colspan="2"><strong>' . $LANG->getLL('importdata_selectFileToImport', 1) . '</strong></td>
				</tr>';
            $row[] = '<tr class="bgColor4">
				<td><strong>' . $LANG->getLL('importdata_file', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'importFile', $GLOBALS['BACK_PATH'], '') . '</td>
				<td>' . $this->renderSelectBox('tx_impexp[file]', $inData['file'], $opt) . '<br />' . sprintf($LANG->getLL('importdata_fromPathS', 1), $path) . (!$import->compress ? '<br /><span class="typo3-red">' . $LANG->getLL('importdata_noteNoDecompressorAvailable', 1) . '</span>' : '') . '</td>
				</tr>';
            $row[] = '<tr class="bgColor5">
					<td colspan="2"><strong>' . $LANG->getLL('importdata_importOptions', 1) . '</strong></td>
				</tr>';
            $row[] = '<tr class="bgColor4">
				<td><strong>' . $LANG->getLL('importdata_update', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'update', $GLOBALS['BACK_PATH'], '') . '</td>
				<td>
					<input type="checkbox" name="tx_impexp[do_update]" id="checkDo_update" value="1"' . ($inData['do_update'] ? ' checked="checked"' : '') . ' />
					<label for="checkDo_update">' . $LANG->getLL('importdata_updateRecords', 1) . '</label><br/>
				<em>(' . $LANG->getLL('importdata_thisOptionRequiresThat', 1) . ')</em>' . ($inData['do_update'] ? '	<hr/>
					<input type="checkbox" name="tx_impexp[global_ignore_pid]" id="checkGlobal_ignore_pid" value="1"' . ($inData['global_ignore_pid'] ? ' checked="checked"' : '') . ' />
					<label for="checkGlobal_ignore_pid">' . $LANG->getLL('importdata_ignorePidDifferencesGlobally', 1) . '</label><br/>
					<em>(' . $LANG->getLL('importdata_ifYouSetThis', 1) . ')</em>
					' : '') . '</td>
				</tr>';
            $row[] = '<tr class="bgColor4">
				<td><strong>' . $LANG->getLL('importdata_options', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'options', $GLOBALS['BACK_PATH'], '') . '</td>
				<td>
					<input type="checkbox" name="tx_impexp[notShowDiff]" id="checkNotShowDiff" value="1"' . ($inData['notShowDiff'] ? ' checked="checked"' : '') . ' />
					<label for="checkNotShowDiff">' . $LANG->getLL('importdata_doNotShowDifferences', 1) . '</label><br/>
					<em>(' . $LANG->getLL('importdata_greenValuesAreFrom', 1) . ')</em>
					<br/><br/>

					' . ($GLOBALS['BE_USER']->isAdmin() ? '
					<input type="checkbox" name="tx_impexp[allowPHPScripts]" id="checkAllowPHPScripts" value="1"' . ($inData['allowPHPScripts'] ? ' checked="checked"' : '') . ' />
					<label for="checkAllowPHPScripts">' . $LANG->getLL('importdata_allowToWriteBanned', 1) . '</label><br/>' : '') . (!$inData['do_update'] && $GLOBALS['BE_USER']->isAdmin() ? '
					<br/>
					<input type="checkbox" name="tx_impexp[force_all_UIDS]" id="checkForce_all_UIDS" value="1"' . ($inData['force_all_UIDS'] ? ' checked="checked"' : '') . ' />
					<label for="checkForce_all_UIDS"><span class="typo3-red">' . $LANG->getLL('importdata_force_all_UIDS', 1) . '</span></label><br/>
					<em>(' . $LANG->getLL('importdata_force_all_UIDS_descr', 1) . ')</em>' : '') . '
				</td>
				</tr>';
            $row[] = '<tr class="bgColor4">
				<td><strong>' . $LANG->getLL('importdata_action', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'action', $GLOBALS['BACK_PATH'], '') . '</td>
				<td>' . (!$inData['import_file'] ? '<input type="submit" value="' . $LANG->getLL('importdata_preview', 1) . '" />' . ($inData['file'] ? ' - <input type="submit" value="' . ($inData['do_update'] ? $LANG->getLL('importdata_update_299e', 1) : $LANG->getLL('importdata_import', 1)) . '" name="tx_impexp[import_file]" onclick="return confirm(\'' . $LANG->getLL('importdata_areYouSure', 1) . '\');" />' : '') : '<input type="submit" name="tx_impexp[new_import]" value="' . $LANG->getLL('importdata_newImport', 1) . '" />') . '
					<input type="hidden" name="tx_impexp[action]" value="import" /></td>
				</tr>';
            $row[] = '<tr class="bgColor4">
				<td><strong>' . $LANG->getLL('importdata_enableLogging', 1) . '</strong>' . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'enableLogging', $GLOBALS['BACK_PATH'], '') . '</td>
				<td>
					<input type="checkbox" name="tx_impexp[enableLogging]" id="checkEnableLogging" value="1"' . ($inData['enableLogging'] ? ' checked="checked"' : '') . ' />
					<label for="checkEnableLogging">' . $LANG->getLL('importdata_writeIndividualDbActions', 1) . '</label><br/>
					<em>(' . $LANG->getLL('importdata_thisIsDisabledBy', 1) . ')</em>
				</td>
				</tr>';
            $menuItems[] = array('label' => $LANG->getLL('importdata_import', 1), 'content' => '
					<table border="0" cellpadding="1" cellspacing="1">
						' . implode('
						', $row) . '
					</table>
				');
            // Upload file:
            $tempFolder = $this->userTempFolder();
            if ($tempFolder) {
                $row = array();
                $row[] = '<tr class="bgColor5">
						<td colspan="2"><strong>' . $LANG->getLL('importdata_uploadFileFromLocal', 1) . '</strong></td>
					</tr>';
                $row[] = '<tr class="bgColor4">
						<td>' . $LANG->getLL('importdata_browse', 1) . t3lib_BEfunc::cshItem('xMOD_tx_impexp', 'upload', $GLOBALS['BACK_PATH'], '') . '</td>
						<td>

								<input type="file" name="upload_1"' . $this->doc->formWidth(35) . ' size="40" />
								<input type="hidden" name="file[upload][1][target]" value="' . htmlspecialchars($tempFolder) . '" />
								<input type="hidden" name="file[upload][1][data]" value="1" /><br />

								<input type="submit" name="_upload" value="' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:file_upload.php.submit', 1) . '" />
								<input type="checkbox" name="overwriteExistingFiles" id="checkOverwriteExistingFiles" value="1" checked="checked" /> <label for="checkOverwriteExistingFiles">' . $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_misc.php:overwriteExistingFiles', 1) . '</label>
						</td>
					</tr>';
                if (t3lib_div::_POST('_upload')) {
                    $row[] = '<tr class="bgColor4">
							<td>' . $LANG->getLL('importdata_uploadStatus', 1) . '</td>
							<td>' . ($this->fileProcessor->internalUploadMap[1] ? $LANG->getLL('importdata_success', 1) . ' ' . substr($this->fileProcessor->internalUploadMap[1], strlen(PATH_site)) : '<span class="typo3-red">' . $LANG->getLL('importdata_failureNoFileUploaded', 1) . '</span>') . '</td>
						</tr>';
                }
                $menuItems[] = array('label' => $LANG->getLL('importdata_upload'), 'content' => '
						<table border="0" cellpadding="1" cellspacing="1">
							' . implode('
							', $row) . '
						</table>
					');
            }
            // Perform import or preview depending:
            $overviewContent = '';
            $extensionInstallationMessage = '';
            $emURL = '';
            $inFile = t3lib_div::getFileAbsFileName($inData['file']);
            if ($inFile && @is_file($inFile)) {
                $trow = array();
                if ($import->loadFile($inFile, 1)) {
                    // Check extension dependencies:
                    $extKeysToInstall = array();
                    if (is_array($import->dat['header']['extensionDependencies'])) {
                        foreach ($import->dat['header']['extensionDependencies'] as $extKey) {
                            if (!t3lib_extMgm::isLoaded($extKey)) {
                                $extKeysToInstall[] = $extKey;
                            }
                        }
                    }
                    if (count($extKeysToInstall)) {
                        $passParams = t3lib_div::_POST('tx_impexp');
                        unset($passParams['import_mode']);
                        unset($passParams['import_file']);
                        $thisScriptUrl = t3lib_div::getIndpEnv('REQUEST_URI') . '?M=xMOD_tximpexp&id=' . $this->id . t3lib_div::implodeArrayForUrl('tx_impexp', $passParams);
                        $emURL = $this->doc->backPath . 'mod/tools/em/index.php?CMD[requestInstallExtensions]=' . implode(',', $extKeysToInstall) . '&returnUrl=' . rawurlencode($thisScriptUrl);
                        $extensionInstallationMessage = 'Before you can install this T3D file you need to install the extensions "' . implode('", "', $extKeysToInstall) . '". Clicking Import will first take you to the Extension Manager so these dependencies can be resolved.';
                    }
                    if ($inData['import_file']) {
                        if (!count($extKeysToInstall)) {
                            $import->importData($this->id);
                            t3lib_BEfunc::setUpdateSignal('updatePageTree');
                        } else {
                            t3lib_utility_Http::redirect($emURL);
                        }
                    }
                    $import->display_import_pid_record = $this->pageinfo;
                    $overviewContent = $import->displayContentOverview();
                }
                // Meta data output:
                $trow[] = '<tr class="bgColor5">
						<td colspan="2"><strong>' . $LANG->getLL('importdata_metaData', 1) . '</strong></td>
					</tr>';
                $opt = array('');
                foreach ($filesInDir as $file) {
                    $opt[$file] = substr($file, strlen(PATH_site));
                }
                $trow[] = '<tr class="bgColor4">
					<td><strong>' . $LANG->getLL('importdata_title', 1) . '</strong></td>
					<td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['title'])) . '</td>
					</tr>';
                $trow[] = '<tr class="bgColor4">
					<td><strong>' . $LANG->getLL('importdata_description', 1) . '</strong></td>
					<td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['description'])) . '</td>
					</tr>';
                $trow[] = '<tr class="bgColor4">
					<td><strong>' . $LANG->getLL('importdata_notes', 1) . '</strong></td>
					<td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['notes'])) . '</td>
					</tr>';
                $trow[] = '<tr class="bgColor4">
					<td><strong>' . $LANG->getLL('importdata_packager', 1) . '</strong></td>
					<td width="95%">' . nl2br(htmlspecialchars($import->dat['header']['meta']['packager_name'] . ' (' . $import->dat['header']['meta']['packager_username'] . ')')) . '<br/>
						' . $LANG->getLL('importdata_email', 1) . ' ' . $import->dat['header']['meta']['packager_email'] . '</td>
					</tr>';
                // Thumbnail icon:
                if (is_array($import->dat['header']['thumbnail'])) {
                    $pI = pathinfo($import->dat['header']['thumbnail']['filename']);
                    if (t3lib_div::inList('gif,jpg,png,jpeg', strtolower($pI['extension']))) {
                        // Construct filename and write it:
                        $fileName = PATH_site . 'typo3temp/importthumb.' . $pI['extension'];
                        t3lib_div::writeFile($fileName, $import->dat['header']['thumbnail']['content']);
                        // Check that the image really is an image and not a malicious PHP script...
                        if (getimagesize($fileName)) {
                            // Create icon tag:
                            $iconTag = '<img src="' . $this->doc->backPath . '../' . substr($fileName, strlen(PATH_site)) . '" ' . $import->dat['header']['thumbnail']['imgInfo'][3] . ' vspace="5" style="border: solid black 1px;" alt="" />';
                            $trow[] = '<tr class="bgColor4">
								<td><strong>' . $LANG->getLL('importdata_icon', 1) . '</strong></td>
								<td>' . $iconTag . '</td>
								</tr>';
                        } else {
                            t3lib_div::unlink_tempfile($fileName);
                        }
                    }
                }
                $menuItems[] = array('label' => $LANG->getLL('importdata_metaData_1387'), 'content' => '
						<table border="0" cellpadding="1" cellspacing="1">
							' . implode('
							', $trow) . '
						</table>
					');
            }
            // Print errors that might be:
            $errors = $import->printErrorLog();
            $menuItems[] = array('label' => $LANG->getLL('importdata_messages'), 'content' => $errors, 'stateIcon' => $errors ? 2 : 0);
            // Output tabs:
            $content = $this->doc->getDynTabMenu($menuItems, 'tx_impexp_import', -1);
            if ($extensionInstallationMessage) {
                $content = '<div style="border: 1px black solid; margin: 10px 10px 10px 10px; padding: 10px 10px 10px 10px;">' . $this->doc->icons(1) . htmlspecialchars($extensionInstallationMessage) . '</div>' . $content;
            }
            $this->content .= $this->doc->section('', $content, 0, 1);
            // Print overview:
            if ($overviewContent) {
                $this->content .= $this->doc->section($inData['import_file'] ? $LANG->getLL('importdata_structureHasBeenImported', 1) : $LANG->getLL('filterpage_structureToBeImported', 1), $overviewContent, 0, 1);
            }
        }
    }
 /**
  * Gets the query arguments and assembles them for URLs.
  * Arguments may be removed or set, depending on configuration.
  *
  * @param	string		Configuration
  * @param	array		Multidimensional key/value pairs that overrule incoming query arguments
  * @param	boolean		If set, key/value pairs not in the query but the overrule array will be set
  * @return	string		The URL query part (starting with a &)
  */
 public function getQueryArguments($conf, $overruleQueryArguments = array(), $forceOverruleArguments = FALSE)
 {
     switch ((string) $conf['method']) {
         case 'GET':
             $currentQueryArray = t3lib_div::_GET();
             break;
         case 'POST':
             $currentQueryArray = t3lib_div::_POST();
             break;
         case 'GET,POST':
             $currentQueryArray = array_merge(t3lib_div::_GET(), t3lib_div::_POST());
             break;
         case 'POST,GET':
             $currentQueryArray = array_merge(t3lib_div::_POST(), t3lib_div::_GET());
             break;
         default:
             $currentQueryArray = t3lib_div::explodeUrl2Array(t3lib_div::getIndpEnv('QUERY_STRING'), TRUE);
     }
     if ($conf['exclude']) {
         $exclude = str_replace(',', '&', $conf['exclude']);
         $exclude = t3lib_div::explodeUrl2Array($exclude, TRUE);
         // never repeat id
         $exclude['id'] = 0;
         $newQueryArray = t3lib_div::arrayDiffAssocRecursive($currentQueryArray, $exclude);
     } else {
         $newQueryArray = $currentQueryArray;
     }
     if ($forceOverruleArguments) {
         $newQueryArray = t3lib_div::array_merge_recursive_overrule($newQueryArray, $overruleQueryArguments);
     } else {
         $newQueryArray = t3lib_div::array_merge_recursive_overrule($newQueryArray, $overruleQueryArguments, TRUE);
     }
     return t3lib_div::implodeArrayForUrl('', $newQueryArray);
 }
    /**
     * The main processing method if this class
     *
     * @return	string		Information of the template status or the taken actions as HTML string
     */
    function main()
    {
        global $SOBE, $BE_USER, $LANG, $BACK_PATH, $TCA_DESCR, $TCA, $CLIENT, $TYPO3_CONF_VARS;
        global $tmpl, $tplRow, $theConstants;
        $edit = $this->pObj->edit;
        $e = $this->pObj->e;
        t3lib_div::loadTCA('sys_template');
        // **************************
        // Checking for more than one template an if, set a menu...
        // **************************
        $manyTemplatesMenu = $this->pObj->templateMenu();
        $template_uid = 0;
        if ($manyTemplatesMenu) {
            $template_uid = $this->pObj->MOD_SETTINGS['templatesOnPage'];
        }
        // **************************
        // Initialize
        // **************************
        $existTemplate = $this->initialize_editor($this->pObj->id, $template_uid);
        // initialize
        if ($existTemplate) {
            $saveId = $tplRow['_ORIG_uid'] ? $tplRow['_ORIG_uid'] : $tplRow['uid'];
        }
        // **************************
        // Create extension template
        // **************************
        $newId = $this->pObj->createTemplate($this->pObj->id, $saveId);
        if ($newId) {
            // switch to new template
            t3lib_utility_Http::redirect('index.php?id=' . $this->pObj->id . '&SET[templatesOnPage]=' . $newId);
        }
        if ($existTemplate) {
            // Update template ?
            $POST = t3lib_div::_POST();
            if ($POST['submit'] || t3lib_div::testInt($POST['submit_x']) && t3lib_div::testInt($POST['submit_y']) || $POST['saveclose'] || t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y'])) {
                // Set the data to be saved
                $recData = array();
                $alternativeFileName = array();
                $resList = $tplRow['resources'];
                $tmp_upload_name = '';
                $tmp_newresource_name = '';
                // Set this to blank
                if (is_array($POST['data'])) {
                    foreach ($POST['data'] as $field => $val) {
                        switch ($field) {
                            case 'constants':
                            case 'config':
                            case 'title':
                            case 'sitetitle':
                            case 'description':
                                $recData['sys_template'][$saveId][$field] = $val;
                                break;
                            case 'resources':
                                $tmp_upload_name = t3lib_div::upload_to_tempfile($_FILES['resources']['tmp_name']);
                                // If there is an uploaded file, move it for the sake of safe_mode.
                                if ($tmp_upload_name) {
                                    if ($tmp_upload_name != 'none' && $_FILES['resources']['name']) {
                                        $alternativeFileName[$tmp_upload_name] = trim($_FILES['resources']['name']);
                                        $resList = $tmp_upload_name . ',' . $resList;
                                    }
                                }
                                break;
                            case 'new_resource':
                                $newName = trim(t3lib_div::_GP('new_resource'));
                                if ($newName) {
                                    $newName .= '.' . t3lib_div::_GP('new_resource_ext');
                                    $tmp_newresource_name = t3lib_div::tempnam('new_resource_');
                                    $alternativeFileName[$tmp_newresource_name] = $newName;
                                    $resList = $tmp_newresource_name . ',' . $resList;
                                }
                                break;
                            case 'makecopy_resource':
                                if (is_array($val)) {
                                    $resList = ',' . $resList . ',';
                                    foreach ($val as $k => $file) {
                                        $tmp_name = PATH_site . $TCA['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $file;
                                        $resList = $tmp_name . ',' . $resList;
                                    }
                                }
                                break;
                            case 'remove_resource':
                                if (is_array($val)) {
                                    $resList = ',' . $resList . ',';
                                    foreach ($val as $k => $file) {
                                        $resList = str_replace(',' . $file . ',', ',', $resList);
                                    }
                                }
                                break;
                            case 'totop_resource':
                                if (is_array($val)) {
                                    $resList = ',' . $resList . ',';
                                    foreach ($val as $k => $file) {
                                        $resList = str_replace(',' . $file . ',', ',', $resList);
                                        $resList = ',' . $file . $resList;
                                    }
                                }
                                break;
                        }
                    }
                }
                $resList = implode(',', t3lib_div::trimExplode(',', $resList, 1));
                if (strcmp($resList, $tplRow['resources'])) {
                    $recData['sys_template'][$saveId]['resources'] = $resList;
                }
                if (count($recData)) {
                    // Create new  tce-object
                    $tce = t3lib_div::makeInstance('t3lib_TCEmain');
                    $tce->stripslashes_values = 0;
                    $tce->alternativeFileName = $alternativeFileName;
                    // Initialize
                    $tce->start($recData, array());
                    // Saved the stuff
                    $tce->process_datamap();
                    // Clear the cache (note: currently only admin-users can clear the cache in tce_main.php)
                    $tce->clear_cacheCmd('all');
                    // tce were processed successfully
                    $this->tce_processed = true;
                    // re-read the template ...
                    $this->initialize_editor($this->pObj->id, $template_uid);
                }
                // Unlink any uploaded/new temp files there was:
                t3lib_div::unlink_tempfile($tmp_upload_name);
                t3lib_div::unlink_tempfile($tmp_newresource_name);
                // If files has been edited:
                if (is_array($edit)) {
                    if ($edit['filename'] && $tplRow['resources'] && t3lib_div::inList($tplRow['resources'], $edit['filename'])) {
                        // Check if there are resources, and that the file is in the resourcelist.
                        $path = PATH_site . $TCA['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $edit['filename'];
                        $fI = t3lib_div::split_fileref($edit['filename']);
                        if (@is_file($path) && t3lib_div::getFileAbsFileName($path) && t3lib_div::inList($this->pObj->textExtensions, $fI['fileext'])) {
                            // checks that have already been done.. Just to make sure
                            // @TODO: Check if the hardcorded value already has a config member, otherwise create one
                            if (filesize($path) < 30720) {
                                // checks that have already been done.. Just to make sure
                                t3lib_div::writeFile($path, $edit['file']);
                                $theOutput .= $this->pObj->doc->spacer(10);
                                $theOutput .= $this->pObj->doc->section('<font color=red>' . $GLOBALS['LANG']->getLL('fileChanged') . '</font>', sprintf($GLOBALS['LANG']->getLL('resourceUpdated'), $edit['filename']), 0, 0, 0, 1);
                                // Clear cache - the file has probably affected the template setup
                                // @TODO: Check if the edited file really had something to do with cached data and prevent this clearing if possible!
                                $tce = t3lib_div::makeInstance('t3lib_TCEmain');
                                $tce->stripslashes_values = 0;
                                $tce->start(array(), array());
                                $tce->clear_cacheCmd('all');
                            }
                        }
                    }
                }
            }
            // hook	Post updating template/TCE processing
            if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'])) {
                $postTCEProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postTCEProcessingHook'];
                if (is_array($postTCEProcessingHook)) {
                    $hookParameters = array('POST' => $POST, 'tce' => $tce);
                    foreach ($postTCEProcessingHook as $hookFunction) {
                        t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
                    }
                }
            }
            $theOutput .= $this->pObj->doc->spacer(5);
            $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('templateInformation'), t3lib_iconWorks::getSpriteIconForRecord('sys_template', $tplRow) . '<strong>' . htmlspecialchars($tplRow['title']) . '</strong>' . htmlspecialchars(trim($tplRow['sitetitle']) ? ' - (' . $tplRow['sitetitle'] . ')' : ''), 0, 1);
            if ($manyTemplatesMenu) {
                $theOutput .= $this->pObj->doc->section('', $manyTemplatesMenu);
                $theOutput .= $this->pObj->doc->divider(5);
            }
            #$numberOfRows= t3lib_div::intInRange($this->pObj->MOD_SETTINGS["ts_template_editor_TArows"],0,150);
            #if (!$numberOfRows)
            $numberOfRows = 35;
            // If abort pressed, nothing should be edited:
            if ($POST['abort'] || t3lib_div::testInt($POST['abort_x']) && t3lib_div::testInt($POST['abort_y']) || $POST['saveclose'] || t3lib_div::testInt($POST['saveclose_x']) && t3lib_div::testInt($POST['saveclose_y'])) {
                unset($e);
            }
            if ($e['title']) {
                $outCode = '<input type="Text" name="data[title]" value="' . htmlspecialchars($tplRow['title']) . '"' . $this->pObj->doc->formWidth() . '>';
                $outCode .= '<input type="Hidden" name="e[title]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('title'), $outCode);
            }
            if ($e['sitetitle']) {
                $outCode = '<input type="Text" name="data[sitetitle]" value="' . htmlspecialchars($tplRow['sitetitle']) . '"' . $this->pObj->doc->formWidth() . '>';
                $outCode .= '<input type="Hidden" name="e[sitetitle]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('sitetitle'), $outCode);
            }
            if ($e['description']) {
                $outCode = '<textarea name="data[description]" rows="5" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, '', '') . '>' . t3lib_div::formatForTextarea($tplRow['description']) . '</textarea>';
                $outCode .= '<input type="Hidden" name="e[description]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('description'), $outCode);
            }
            if ($e['resources']) {
                // Upload
                $outCode = '<input type="File" name="resources"' . $this->pObj->doc->formWidth() . ' size="50">';
                $outCode .= '<input type="Hidden" name="data[resources]" value="1">';
                $outCode .= '<input type="Hidden" name="e[resources]" value="1">';
                $outCode .= '<BR>' . $GLOBALS['LANG']->getLL('allowedExtensions') . ' <strong>' . $TCA['sys_template']['columns']['resources']['config']['allowed'] . '</strong>';
                $outCode .= '<BR>' . $GLOBALS['LANG']->getLL('maxFilesize') . ' <strong>' . t3lib_div::formatSize($TCA['sys_template']['columns']['resources']['config']['max_size'] * 1024) . '</strong>';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('uploadResource'), $outCode);
                // New
                $opt = explode(',', $this->pObj->textExtensions);
                $optTags = '';
                foreach ($opt as $extVal) {
                    $optTags .= '<option value="' . $extVal . '">.' . $extVal . '</option>';
                }
                $outCode = '<input type="text" name="new_resource"' . $this->pObj->doc->formWidth(20) . '>
					<select name="new_resource_ext">' . $optTags . '</select>';
                $outCode .= '<input type="Hidden" name="data[new_resource]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('newTextResource'), $outCode);
                // Make copy
                $rL = $this->resourceListForCopy($this->pObj->id, $template_uid);
                if ($rL) {
                    $theOutput .= $this->pObj->doc->spacer(20);
                    $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('copyResource'), $rL);
                }
                // Update resource list
                $rL = $this->procesResources($tplRow['resources'], 1);
                if ($rL) {
                    $theOutput .= $this->pObj->doc->spacer(20);
                    $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('updateResourceList'), $rL);
                }
            }
            if ($e['constants']) {
                $outCode = '<textarea name="data[constants]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font">' . t3lib_div::formatForTextarea($tplRow['constants']) . '</textarea>';
                $outCode .= '<input type="Hidden" name="e[constants]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('constants'), '');
                $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
            }
            if ($e['file']) {
                $path = PATH_site . $TCA['sys_template']['columns']['resources']['config']['uploadfolder'] . '/' . $e[file];
                $fI = t3lib_div::split_fileref($e[file]);
                if (@is_file($path) && t3lib_div::inList($this->pObj->textExtensions, $fI['fileext'])) {
                    if (filesize($path) < $TCA['sys_template']['columns']['resources']['config']['max_size'] * 1024) {
                        $fileContent = t3lib_div::getUrl($path);
                        $outCode = $GLOBALS['LANG']->getLL('file') . ' <strong>' . $e[file] . '</strong><BR>';
                        $outCode .= '<textarea name="edit[file]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, 'width:98%;height:70%', 'off') . ' class="fixed-font">' . t3lib_div::formatForTextarea($fileContent) . '</textarea>';
                        $outCode .= '<input type="Hidden" name="edit[filename]" value="' . $e[file] . '">';
                        $outCode .= '<input type="Hidden" name="e[file]" value="' . htmlspecialchars($e[file]) . '">';
                        $theOutput .= $this->pObj->doc->spacer(15);
                        $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('editResource'), '');
                        $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
                    } else {
                        $theOutput .= $this->pObj->doc->spacer(15);
                        $fileToBig = sprintf($GLOBALS['LANG']->getLL('filesizeExceeded'), $TCA['sys_template']['columns']['resources']['config']['max_size']);
                        $filesizeNotAllowed = sprintf($GLOBALS['LANG']->getLL('notAllowed'), $TCA['sys_template']['columns']['resources']['config']['max_size']);
                        $theOutput .= $this->pObj->doc->section('<font color=red>' . $fileToBig . '</font>', $filesizeNotAllowed, 0, 0, 0, 1);
                    }
                }
            }
            if ($e['config']) {
                $outCode = '<textarea name="data[config]" rows="' . $numberOfRows . '" wrap="off" class="fixed-font enable-tab"' . $this->pObj->doc->formWidthText(48, "width:98%;height:70%", "off") . ' class="fixed-font">' . t3lib_div::formatForTextarea($tplRow["config"]) . '</textarea>';
                if (t3lib_extMgm::isLoaded('tsconfig_help')) {
                    $url = $BACK_PATH . 'wizard_tsconfig.php?mode=tsref';
                    $params = array('formName' => 'editForm', 'itemName' => 'data[config]');
                    $outCode .= '<a href="#" onClick="vHWin=window.open(\'' . $url . t3lib_div::implodeArrayForUrl('', array('P' => $params)) . '\',\'popUp' . $md5ID . '\',\'height=500,width=780,status=0,menubar=0,scrollbars=1\');vHWin.focus();return false;">' . t3lib_iconWorks::getSpriteIcon('actions-system-typoscript-documentation-open', array('title' => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:tsRef', true))) . '</a>';
                }
                $outCode .= '<input type="Hidden" name="e[config]" value="1">';
                $theOutput .= $this->pObj->doc->spacer(15);
                $theOutput .= $this->pObj->doc->section($GLOBALS['LANG']->getLL('setup'), '');
                $theOutput .= $this->pObj->doc->sectionEnd() . $outCode;
            }
            // Processing:
            $outCode = '';
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('title'), htmlspecialchars($tplRow['title']), 'title');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('sitetitle'), htmlspecialchars($tplRow['sitetitle']), 'sitetitle');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('description'), nl2br(htmlspecialchars($tplRow['description'])), 'description');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('resources'), $this->procesResources($tplRow['resources']), 'resources');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('constants'), sprintf($GLOBALS['LANG']->getLL('editToView'), trim($tplRow[constants]) ? count(explode(LF, $tplRow[constants])) : 0), 'constants');
            $outCode .= $this->tableRow($GLOBALS['LANG']->getLL('setup'), sprintf($GLOBALS['LANG']->getLL('editToView'), trim($tplRow[config]) ? count(explode(LF, $tplRow[config])) : 0), 'config');
            $outCode = '<br /><br /><table class="t3-table-info">' . $outCode . '</table>';
            // Edit all icon:
            $outCode .= '<br /><a href="#" onClick="' . t3lib_BEfunc::editOnClick(rawurlencode('&createExtension=0') . '&amp;edit[sys_template][' . $tplRow['uid'] . ']=edit', $BACK_PATH, '') . '"><strong>' . t3lib_iconWorks::getSpriteIcon('actions-document-open', array('title' => $GLOBALS['LANG']->getLL('editTemplateRecord'))) . $GLOBALS['LANG']->getLL('editTemplateRecord') . '</strong></a>';
            $theOutput .= $this->pObj->doc->section('', $outCode);
            // hook	after compiling the output
            if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'])) {
                $postOutputProcessingHook =& $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/tstemplate_info/class.tx_tstemplateinfo.php']['postOutputProcessingHook'];
                if (is_array($postOutputProcessingHook)) {
                    $hookParameters = array('theOutput' => &$theOutput, 'POST' => $POST, 'e' => $e, 'tplRow' => $tplRow, 'numberOfRows' => $numberOfRows);
                    foreach ($postOutputProcessingHook as $hookFunction) {
                        t3lib_div::callUserFunction($hookFunction, $hookParameters, $this);
                    }
                }
            }
        } else {
            $theOutput .= $this->pObj->noTemplate(1);
        }
        return $theOutput;
    }
 /**
  * @return string
  */
 protected function getFormUrl()
 {
     $urlParams = $this->pObj->MOD_SETTINGS;
     $urlParams['id'] = $this->pObj->id;
     return $this->pObj->doc->scriptID . '?' . t3lib_div::implodeArrayForUrl('', $urlParams);
 }
示例#16
0
 /**
  * Builds a TypoLink configuration array from the current settings
  *
  * @return array typolink configuration array
  * @see TSref/typolink
  */
 protected function buildTypolinkConfiguration()
 {
     $typolinkConfiguration = array();
     $typolinkConfiguration['parameter'] = $this->targetPageUid !== NULL ? $this->targetPageUid : $GLOBALS['TSFE']->id;
     if ($this->targetPageType !== 0) {
         $typolinkConfiguration['parameter'] .= ',' . $this->targetPageType;
     }
     if (count($this->arguments) > 0) {
         $arguments = $this->convertDomainObjectsToIdentityArrays($this->arguments);
         $this->lastArguments = $arguments;
         $typolinkConfiguration['additionalParams'] = t3lib_div::implodeArrayForUrl(NULL, $arguments);
     }
     if ($this->addQueryString === TRUE) {
         $typolinkConfiguration['addQueryString'] = 1;
         if (count($this->argumentsToBeExcludedFromQueryString) > 0) {
             $typolinkConfiguration['addQueryString.'] = array('exclude' => implode(',', $this->argumentsToBeExcludedFromQueryString));
         }
         // TODO: Support for __hmac and addQueryString!
     }
     if ($this->noCache === TRUE) {
         $typolinkConfiguration['no_cache'] = 1;
     } elseif ($this->useCacheHash) {
         $typolinkConfiguration['useCacheHash'] = 1;
     }
     if ($this->section !== '') {
         $typolinkConfiguration['section'] = $this->section;
     }
     if ($this->linkAccessRestrictedPages === TRUE) {
         $typolinkConfiguration['linkAccessRestrictedPages'] = 1;
     }
     return $typolinkConfiguration;
 }
示例#17
0
 /**
  * Checks the array for elements which might contain unallowed default values and will unset them!
  * Looks for the "tt_content_defValues" key in each element and if found it will traverse that array as fieldname / value pairs and check. The values will be added to the "params" key of the array (which should probably be unset or empty by default).
  *
  * @param	array		Wizard items, passed by reference
  * @return	void
  */
 function removeInvalidElements(&$wizardItems)
 {
     global $TCA;
     // Load full table definition:
     t3lib_div::loadTCA('tt_content');
     // Get TCEFORM from TSconfig of current page
     $TCEFORM_TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig('tt_content', array('pid' => $this->id));
     $removeItems = t3lib_div::trimExplode(',', $TCEFORM_TSconfig['CType']['removeItems'], 1);
     $headersUsed = array();
     // Traverse wizard items:
     foreach ($wizardItems as $key => $cfg) {
         // Exploding parameter string, if any (old style)
         if ($wizardItems[$key]['params']) {
             // Explode GET vars recursively
             $tempGetVars = t3lib_div::explodeUrl2Array($wizardItems[$key]['params'], TRUE);
             // If tt_content values are set, merge them into the tt_content_defValues array, unset them from $tempGetVars and re-implode $tempGetVars into the param string (in case remaining parameters are around).
             if (is_array($tempGetVars['defVals']['tt_content'])) {
                 $wizardItems[$key]['tt_content_defValues'] = array_merge(is_array($wizardItems[$key]['tt_content_defValues']) ? $wizardItems[$key]['tt_content_defValues'] : array(), $tempGetVars['defVals']['tt_content']);
                 unset($tempGetVars['defVals']['tt_content']);
                 $wizardItems[$key]['params'] = t3lib_div::implodeArrayForUrl('', $tempGetVars);
             }
         }
         // If tt_content_defValues are defined...:
         if (is_array($wizardItems[$key]['tt_content_defValues'])) {
             // Traverse field values:
             foreach ($wizardItems[$key]['tt_content_defValues'] as $fN => $fV) {
                 if (is_array($TCA['tt_content']['columns'][$fN])) {
                     // Get information about if the field value is OK:
                     $config =& $TCA['tt_content']['columns'][$fN]['config'];
                     $authModeDeny = $config['type'] == 'select' && $config['authMode'] && !$GLOBALS['BE_USER']->checkAuthMode('tt_content', $fN, $fV, $config['authMode']);
                     if ($authModeDeny || in_array($fV, $removeItems)) {
                         // Remove element all together:
                         unset($wizardItems[$key]);
                         break;
                     } else {
                         // Add the parameter:
                         $wizardItems[$key]['params'] .= '&defVals[tt_content][' . $fN . ']=' . rawurlencode($fV);
                         $tmp = explode('_', $key);
                         $headersUsed[$tmp[0]] = $tmp[0];
                     }
                 }
             }
         }
     }
     // Remove headers without elements
     foreach ($wizardItems as $key => $cfg) {
         list($itemCategory, $dummy) = explode('_', $key);
         if (!isset($headersUsed[$itemCategory])) {
             unset($wizardItems[$key]);
         }
     }
 }
示例#18
0
 /**
  * Gets the link to the CSV export.
  *
  * @return string the link to the CSV export
  */
 private function getCsvExportLink()
 {
     return $this->cObj->typoLink($this->translate('label_registrationsAsCsv'), array('parameter' => $GLOBALS['TSFE']->id, 'additionalParams' => t3lib_div::implodeArrayForUrl('', array('type' => tx_seminars_pi2::CSV_TYPE_NUMBER, 'tx_seminars_pi2' => array('table' => 'tx_seminars_attendances', 'eventUid' => $this->seminar->getUid())))));
 }
示例#19
0
 /**
  * Populates the variables $this->storeArray, $this->storeUrl, $this->storeUrlMd5
  *
  * @return	void
  * @see makeDocSel()
  */
 function compileStoreDat()
 {
     $this->storeArray = t3lib_div::compileSelectedGetVarsFromArray('edit,defVals,overrideVals,columnsOnly,disHelp,noView,editRegularContentFromId', $this->R_URL_getvars);
     $this->storeUrl = t3lib_div::implodeArrayForUrl('', $this->storeArray);
     $this->storeUrlMd5 = md5($this->storeUrl);
 }
 /**
  * Create HTML checkbox to enable/disable thumbnail display
  *
  * @return	string HTML code
  */
 function addDisplayOptions()
 {
     global $BE_USER;
     // Getting flag for showing/not showing thumbnails:
     $noThumbs = $BE_USER->getTSConfigVal('options.noThumbsInEB') || $this->mode == 'rte' && $BE_USER->getTSConfigVal('options.noThumbsInRTEimageSelect') || $this->act == 'dragdrop';
     if ($noThumbs) {
         $thumbNailCheckbox = '';
     } else {
         $thumbNailCheckbox = t3lib_BEfunc::getFuncCheck('', 'SET[displayThumbs]', $this->displayThumbs(), $this->thisScript, t3lib_div::implodeArrayForUrl('', $this->addParams));
         $description = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_file_list.xml:displayThumbs', 1);
         $id = 'l' . uniqid('tx_dam_scbase');
         $idAttr = ' id="' . $id . '"';
         $thumbNailCheckbox = str_replace('<input', '<input' . $idAttr, $thumbNailCheckbox);
         $thumbNailCheckbox .= ' <label for="' . $id . '">' . $description . '</label>';
         $this->damSC->addOption('html', 'thumbnailCheckbox', $thumbNailCheckbox);
     }
     $this->damSC->addOption('funcCheck', 'extendedInfo', $GLOBALS['LANG']->getLL('displayExtendedInfo', 1));
 }
示例#21
0
 /**
  * Creates a link to this script, maintaining the values of the displayFile, displayTable, displayUid variables.
  * Primarily used by ->drawDataStructureMap
  *
  * @param	array		Overriding parameters.
  * @return	string		URL, already htmlspecialchars()'ed
  * @see drawDataStructureMap()
  */
 function linkThisScript($array = array())
 {
     $theArray = array('file' => $this->displayFile, 'table' => $this->displayTable, 'uid' => $this->displayUid, 'returnUrl' => $this->returnUrl);
     $p = t3lib_div::implodeArrayForUrl('', array_merge($theArray, $array), '', 1);
     return htmlspecialchars('index.php?' . $p);
 }
 /**
  * Creates a tab menu from an array definition
  *
  * Returns a tab menu for a module
  * Requires the JS function jumpToUrl() to be available
  *
  * @param	mixed		$id is the "&id=" parameter value to be sent to the module, but it can be also a parameter array which will be passed instead of the &id=...
  * @param	string		$elementName it the form elements name, probably something like "SET[...]"
  * @param	string		$currentValue is the value to be selected currently.
  * @param	array		$menuItems is an array with the menu items for the selector box
  * @param	string		$script is the script to send the &id to, if empty it's automatically found
  * @param	string		$addParams is additional parameters to pass to the script.
  * @return	string		HTML code for tab menu
  */
 function getTabMenu($mainParams, $elementName, $currentValue, $menuItems, $script = '', $addparams = '')
 {
     // read page TSconfig
     $useTabs = tx_dam::config_checkValueEnabled('mod.txdamM1_SHARED.useTabs');
     if ($useTabs && is_array($menuItems)) {
         if (!is_array($mainParams)) {
             $mainParams = array('id' => $mainParams);
         }
         $mainParams = t3lib_div::implodeArrayForUrl('', $mainParams);
         if (!$script) {
             $script = basename(PATH_thisScript);
         }
         $menuDef = array();
         foreach ($menuItems as $value => $label) {
             $menuDef[$value]['isActive'] = !strcmp($currentValue, $value);
             $menuDef[$value]['label'] = t3lib_div::deHSCentities(htmlspecialchars($label));
             // original: $menuDef[$value]['url'] = htmlspecialchars($script.'?'.$mainParams.$addparams.'&'.$elementName.'='.$value);
             $menuDef[$value]['url'] = $script . '?' . $mainParams . $addparams . '&' . $elementName . '=' . $value;
         }
         $this->content .= $this->doc->getTabMenuRaw($menuDef);
         return '';
     } else {
         return t3lib_BEfunc::getFuncMenu($this->id, $elementName, $currentValue, $menuItems);
     }
 }
    /**
     * [Describe function...]
     *
     * @param	[type]		$row: ...
     * @param	[type]		$conf: ...
     * @param	[type]		$table: ...
     * @return	[type]		...
     */
    function resultRowDisplay($row, $conf, $table)
    {
        static $even = FALSE;
        $tce = t3lib_div::makeInstance('t3lib_TCEmain');
        $SET = $GLOBALS['SOBE']->MOD_SETTINGS;
        $out = '<tr class="bgColor' . ($even ? '6' : '4') . '">';
        $even = !$even;
        foreach ($row as $fN => $fV) {
            if (t3lib_div::inList($SET['queryFields'], $fN) || !$SET['queryFields'] && $fN != 'pid' && $fN != 'deleted') {
                if ($SET['search_result_labels']) {
                    $fVnew = $this->getProcessedValueExtra($table, $fN, $fV, $conf, '<br />');
                } else {
                    $fVnew = htmlspecialchars($fV);
                }
                $out .= '<td>' . $fVnew . '</td>';
            }
        }
        $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
        $out .= '<td nowrap>';
        if (!$row['deleted']) {
            $out .= '<a href="#" onClick="top.launchView(\'' . $table . '\',' . $row['uid'] . ',\'' . $GLOBALS['BACK_PATH'] . '\');return false;">' . t3lib_iconWorks::getSpriteIcon('status-dialog-information') . '</a>';
            $out .= '<a href="#" onClick="' . t3lib_BEfunc::editOnClick($params, $GLOBALS['BACK_PATH'], t3lib_div::getIndpEnv('REQUEST_URI') . t3lib_div::implodeArrayForUrl('SET', (array) t3lib_div::_POST('SET'))) . '">' . t3lib_iconWorks::getSpriteIcon('actions-document-open') . '</a>';
        } else {
            $out .= '<a href="' . t3lib_div::linkThisUrl($GLOBALS['BACK_PATH'] . 'tce_db.php', array('cmd[' . $table . '][' . $row['uid'] . '][undelete]' => '1', 'redirect' => t3lib_div::linkThisScript(array()))) . t3lib_BEfunc::getUrlToken('tceAction') . '">';
            $out .= t3lib_iconWorks::getSpriteIcon('actions-edit-restore', array('title' => 'undelete only')) . '</a>';
            $out .= '<a href="' . t3lib_div::linkThisUrl($GLOBALS['BACK_PATH'] . 'tce_db.php', array('cmd[' . $table . '][' . $row['uid'] . '][undelete]' => '1', 'redirect' => t3lib_div::linkThisUrl('alt_doc.php', array('edit[' . $table . '][' . $row['uid'] . ']' => 'edit', 'returnUrl' => t3lib_div::linkThisScript(array()))))) . t3lib_BEfunc::getUrlToken('tceAction') . '">';
            $out .= t3lib_iconWorks::getSpriteIcon('actions-edit-restore-edit', array('title' => 'undelete and edit')) . '</a>';
        }
        $_params = array($table => $row);
        if (is_array($this->hookArray['additionalButtons'])) {
            foreach ($this->hookArray['additionalButtons'] as $_funcRef) {
                $out .= t3lib_div::callUserFunction($_funcRef, $_params, $this);
            }
        }
        $out .= '</td>
		</tr>
		';
        return $out;
    }
	/**
	 * Rendering the decode-cache content
	 *
	 * @param	array		The Page tree data
	 * @return	string		HTML for the information table.
	 */
	function decodeView(t3lib_pageTree $tree)	{

			// Delete entries:
		$cmd = t3lib_div::_GP('cmd');
		$subcmd = '';
		if ($cmd === 'deleteDC')	{
			$subcmd = t3lib_div::_GP('entry');
			$this->clearDEncodeCache($subcmd,TRUE);
		}

			// Traverse tree:
		$output = '';
		$cc=0;
		$countDisplayed = 0;
		foreach($tree->tree as $row)	{

				// Select rows:
			$displayRows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*','tx_realurl_urldecodecache','page_id='.intval($row['row']['uid']),'','spurl');

				// Row title:
			$rowTitle = $row['HTML'].t3lib_BEfunc::getRecordTitle('pages',$row['row'],TRUE);

				// Add at least one empty element:
			if (!count($displayRows) || $subcmd==='displayed')	{

					// Add title:
				$tCells = array();
				$tCells[]='<td nowrap="nowrap">'.$rowTitle.'</td>';

					// Empty row:
				$tCells[]='<td colspan="6" align="center">&nbsp;</td>';

					// Compile Row:
				$output.= '
					<tr class="bgColor'.($cc%2 ? '-20':'-10').'">
						'.implode('
						',$tCells).'
					</tr>';
				$cc++;

				if ($subcmd==='displayed') {
					foreach($displayRows as $c => $inf)	{
						$this->clearDEncodeCache('urlhash_'.$inf['url_hash'],TRUE);
					}
				}
			} else {
				foreach($displayRows as $c => $inf)	{

						// Add icon/title and ID:
					$tCells = array();
					if (!$c)	{
						$tCells[]='<td nowrap="nowrap" rowspan="'.count($displayRows).'">'.$rowTitle.'</td>';
						$tCells[]='<td nowrap="nowrap" rowspan="'.count($displayRows).'">'.$row['row']['uid'].'</td>';
						$tCells[]='<td rowspan="'.count($displayRows).'">'.
							'<a href="'.$this->linkSelf('&cmd=deleteDC&entry=page_'.intval($row['row']['uid'])).'">'.
							'<img'.t3lib_iconWorks::skinImg($this->pObj->doc->backPath,'gfx/garbage.gif','width="11" height="12"').' title="Delete entries for page" alt="" />'.
							'</a>'.
						'</td>';
					}

						// Path:
					$tCells[]='<td>'.htmlspecialchars($inf['spurl']).'</td>';

						// Get vars:
					$queryValues = unserialize($inf['content']);
					$queryParams = '?id='.$queryValues['id'].
									(is_array($queryValues['GET_VARS']) ? t3lib_div::implodeArrayForUrl('',$queryValues['GET_VARS']) : '');
					$tCells[]='<td>'.htmlspecialchars($queryParams).'</td>';

						// Delete:
					$tCells[]='<td>'.
							'<a href="'.$this->linkSelf('&cmd=deleteDC&entry=urlhash_'.intval($inf['url_hash'])).'">'.
							'<img'.t3lib_iconWorks::skinImg($this->pObj->doc->backPath,'gfx/garbage.gif','width="11" height="12"').' title="Delete entry" alt="" />'.
							'</a>'.
						'</td>';

						// Timestamp:
					$tCells[]='<td>'.htmlspecialchars(t3lib_BEfunc::datetime($inf['tstamp'])).' / '.htmlspecialchars(t3lib_BEfunc::calcAge(time()-$inf['tstamp'])).'</td>';

						// Compile Row:
					$output.= '
						<tr class="bgColor'.($cc%2 ? '-20':'-10').'">
							'.implode('
							',$tCells).'
						</tr>';
					$cc++;
					$countDisplayed++;
				}
			}
		}

		list($count_allInTable) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('count(*) AS count','tx_realurl_urldecodecache','');

			// Create header:
		$tCells = array();
		$tCells[]='<td>Title:</td>';
		$tCells[]='<td>ID:</td>';
		$tCells[]='<td>&nbsp;</td>';
		$tCells[]='<td>Path:</td>';
		$tCells[]='<td>GET variables:</td>';
		$tCells[]='<td>&nbsp;</td>';
		$tCells[]='<td>Timestamp:</td>';

		$output = '
			<tr class="bgColor5 tableheader">
				'.implode('
				',$tCells).'
			</tr>'.$output;

			// Compile final table and return:
		$output = '<br/><br/>
		Displayed entries: <b>'.$countDisplayed.'</b> '.
			'<a href="'.$this->linkSelf('&cmd=deleteDC&entry=displayed').'">'.
			'<img'.t3lib_iconWorks::skinImg($this->pObj->doc->backPath,'gfx/garbage.gif','width="11" height="12"').' title="Delete displayed entries" alt="" />'.
			'</a>'.
		'<br/>
		Total entries in decode cache: <b>'.$count_allInTable['count'].'</b> '.
			'<a href="'.$this->linkSelf('&cmd=deleteDC&entry=all').'">'.
			'<img'.t3lib_iconWorks::skinImg($this->pObj->doc->backPath,'gfx/garbage.gif','width="11" height="12"').' title="Delete WHOLE decode cache!" alt="" />'.
			'</a>'.
		'<br/>
		<table border="0" cellspacing="1" cellpadding="0" id="tx-realurl-pathcacheTable" class="lrPadding c-list">'.$output.'
		</table>';

		return $output;
	}
示例#25
0
 /**
  * Calculates the cHash value of input GET array (for constructing cHash values if needed)
  *
  * @param	array		Array of GET parameters to encode
  * @return	void
  * @deprecated since TYPO3 4.3, this function will be removed in TYPO3 4.6, use directly t3lib_div::calculateCHash()
  */
 function makeCHash($paramArray)
 {
     t3lib_div::logDeprecatedFunction();
     $addQueryParams = t3lib_div::implodeArrayForUrl('', $paramArray);
     $pA = t3lib_div::cHashParams($addQueryParams);
     return t3lib_div::shortMD5(serialize($pA));
 }
	/**
	 * Will store a record in a cachetable holding the value of the "cHash" parameter in a link, if any.
	 * Background:
	 * The "cHash" parameter is a hash over the values in the Query String of a URL and it "authenticates" the URL to the frontend so we can safely cache page content with that parameter combination.
	 * Technically, there is no problem with the "cHash" parameter - it is like any other parameter something we could encode with Speaking URLs. The problem is: a cHash string is not "speaking" (and never will be!)
	 * So; the only option we are left with if we want to remove the "?cHash=...:" remains in URLs and at the same time do not want to include it in the virtual path is; store it in the database!
	 * This is what this function does: Stores a record in the database which relates the cHash value to a hash id of the URL. This is done ONLY if the "cHash" parameter is the only one left which would make the URL non-speaking. Otherwise it is left behind.
	 * Obviously, this whole thing only works if there is a function in the decode part which will look up the cHash again and include it in the GET parameters resolved from the Speaking URL - but there is of course...
	 *
	 * @param	string		Speaking URL path (being hashed to an integer and cHash value related to this.)
	 * @param	array		Params array, passed by reference. If "cHash" is the only value left it will be put in the cache table and the value is unset in the array.
	 * @return	void
	 * @see decodeSpURL_cHashCache()
	 */
	protected function encodeSpURL_cHashCache($newUrl, &$paramKeyValues) {

		// If "cHash" is the ONLY parameter left...
		// (if there are others our problem is that the cHash probably covers those
		// as well and if we include the cHash anyways we might get duplicates for
		// the same speaking URL in the cache table!)
		if (isset($paramKeyValues['cHash'])) {

			if ($this->rebuildCHash) {
				$cacheHashClassExists = class_exists('t3lib_cacheHash');
				$cacheHash = ($cacheHashClassExists ? t3lib_div::makeInstance('t3lib_cacheHash') : NULL);
				/* @var t3lib_cacheHash $cacheHash */

				$cHashParameters = array_merge($this->cHashParameters, $paramKeyValues);
				unset($cHashParameters['cHash']);
				$cHashParameters = t3lib_div::implodeArrayForUrl('', $cHashParameters);
				if ($cacheHashClassExists) {
					$cHashParameters = $cacheHash->getRelevantParameters($cHashParameters);
				} else {
					$cHashParameters = t3lib_div::cHashParams($cHashParameters);
				}
				unset($cHashParameters['']);
				if (count($cHashParameters) == 1) {
					// No cHash needed.
					unset($paramKeyValues['cHash']);
				}
				elseif (count($cHashParameters) > 1) {
					if ($cacheHashClassExists) {
						$paramKeyValues['cHash'] = $cacheHash->calculateCacheHash($cHashParameters);
					} elseif (method_exists('t3lib_div', 'calculateCHash')) {
						$paramKeyValues['cHash'] = t3lib_div::calculateCHash($cHashParameters);
					} else {
						$paramKeyValues['cHash'] = t3lib_div::shortMD5(serialize($cHashParameters));
					}
				}
				unset($cHashParameters);
			}

			if (count($paramKeyValues) == 1) {

				$stringForHash = $newUrl;
				if (count($this->additionalParametersForChash)) {
					$stringForHash .= '|' . serialize($this->additionalParametersForChash);
				}
				$spUrlHash = md5($stringForHash);
				$spUrlHashQuoted = $GLOBALS['TYPO3_DB']->fullQuoteStr($spUrlHash, 'tx_realurl_chashcache');

				// first, look if a cHash is already there for this SpURL
				list($row) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('chash_string',
					'tx_realurl_chashcache', 'spurl_hash=' . $spUrlHashQuoted);

				if (!is_array($row)) {
					// Nothing found, insert to the cache
					$data = array(
						'spurl_hash' => $spUrlHash,
						'spurl_string' => $this->enableChashUrlDebug ? $stringForHash : null,
						'chash_string' => $paramKeyValues['cHash']
					);
					$GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_realurl_chashcache', $data);
				}
				else {
					// If one found, check if it is different, and if so update:
					if ($row['chash_string'] != $paramKeyValues['cHash']) {
						// If that chash_string is different from the one we want to
						// insert, that might be a bug or mean that encryptionKey was
						// changed so cHash values will be different now
						// In any case we will just silently update the value:
						$data = array(
							'chash_string' => $paramKeyValues['cHash']
						);
						$GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_realurl_chashcache',
							'spurl_hash=' . $spUrlHashQuoted, $data);
					}
				}

				// Unset "cHash" (and array should now be empty!)
				unset($paramKeyValues['cHash']);
			}
		}
	}
示例#27
0
文件: index.php 项目: rod86/t3sandbox
 /**
  * Creates additional parameters which are used for linking to the current page while editing it
  *
  * @return	string		parameters
  * @access public
  */
 function link_getParameters()
 {
     $output = 'id=' . $this->id . (is_array($this->altRoot) ? t3lib_div::implodeArrayForUrl('altRoot', $this->altRoot) : '') . ($this->versionId ? '&amp;versionId=' . rawurlencode($this->versionId) : '');
     return $output;
 }
    /**
     * Constructor:
     * Initializes a lot of variables, setting JavaScript functions in header etc.
     *
     * @return	void
     */
    function init()
    {
        global $BE_USER, $BACK_PATH;
        // Main GPvars:
        $this->pointer = t3lib_div::_GP('pointer');
        $this->bparams = t3lib_div::_GP('bparams');
        $this->P = t3lib_div::_GP('P');
        $this->RTEtsConfigParams = t3lib_div::_GP('RTEtsConfigParams');
        $this->expandPage = t3lib_div::_GP('expandPage');
        $this->expandFolder = t3lib_div::_GP('expandFolder');
        $this->PM = t3lib_div::_GP('PM');
        // Find "mode"
        $this->mode = t3lib_div::_GP('mode');
        if (!$this->mode) {
            $this->mode = 'rte';
        }
        // Creating backend template object:
        $this->doc = t3lib_div::makeInstance('template');
        $this->doc->backPath = $GLOBALS['BACK_PATH'];
        // Load the Prototype library and browse_links.js
        $this->doc->getPageRenderer()->loadPrototype();
        $this->doc->loadJavascriptLib('js/browse_links.js');
        // init hook objects:
        $this->hookObjects = array();
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'] as $classData) {
                $processObject = t3lib_div::getUserObj($classData);
                if (!$processObject instanceof t3lib_browseLinksHook) {
                    throw new UnexpectedValueException('$processObject must implement interface t3lib_browseLinksHook', 1195039394);
                }
                $parameters = array();
                $processObject->init($this, $parameters);
                $this->hookObjects[] = $processObject;
            }
        }
        // Site URL
        $this->siteURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
        // Current site url
        // the script to link to
        $this->thisScript = t3lib_div::getIndpEnv('SCRIPT_NAME');
        // init fileProcessor
        $this->fileProcessor = t3lib_div::makeInstance('t3lib_basicFileFunctions');
        $this->fileProcessor->init($GLOBALS['FILEMOUNTS'], $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']);
        // CurrentUrl - the current link url must be passed around if it exists
        if ($this->mode == 'wizard') {
            $currentLinkParts = t3lib_div::unQuoteFilenames($this->P['currentValue'], TRUE);
            $initialCurUrlArray = array('href' => $currentLinkParts[0], 'target' => $currentLinkParts[1], 'class' => $currentLinkParts[2], 'title' => $currentLinkParts[3]);
            $this->curUrlArray = is_array(t3lib_div::_GP('curUrl')) ? array_merge($initialCurUrlArray, t3lib_div::_GP('curUrl')) : $initialCurUrlArray;
            $this->curUrlInfo = $this->parseCurUrl($this->siteURL . '?id=' . $this->curUrlArray['href'], $this->siteURL);
            if ($this->curUrlInfo['pageid'] == 0 && $this->curUrlArray['href']) {
                // pageid == 0 means that this is not an internal (page) link
                if (file_exists(PATH_site . rawurldecode($this->curUrlArray['href']))) {
                    // check if this is a link to a file
                    if (t3lib_div::isFirstPartOfStr($this->curUrlArray['href'], PATH_site)) {
                        $currentLinkParts[0] = substr($this->curUrlArray['href'], strlen(PATH_site));
                    }
                    $this->curUrlInfo = $this->parseCurUrl($this->siteURL . $this->curUrlArray['href'], $this->siteURL);
                } elseif (strstr($this->curUrlArray['href'], '@')) {
                    // check for email link
                    if (t3lib_div::isFirstPartOfStr($this->curUrlArray['href'], 'mailto:')) {
                        $currentLinkParts[0] = substr($this->curUrlArray['href'], 7);
                    }
                    $this->curUrlInfo = $this->parseCurUrl('mailto:' . $this->curUrlArray['href'], $this->siteURL);
                } else {
                    // nothing of the above. this is an external link
                    if (strpos($this->curUrlArray['href'], '://') === false) {
                        $currentLinkParts[0] = 'http://' . $this->curUrlArray['href'];
                    }
                    $this->curUrlInfo = $this->parseCurUrl($currentLinkParts[0], $this->siteURL);
                }
            } elseif (!$this->curUrlArray['href']) {
                $this->curUrlInfo = array();
                $this->act = 'page';
            } else {
                $this->curUrlInfo = $this->parseCurUrl($this->siteURL . '?id=' . $this->curUrlArray['href'], $this->siteURL);
            }
        } else {
            $this->curUrlArray = t3lib_div::_GP('curUrl');
            if ($this->curUrlArray['all']) {
                $this->curUrlArray = t3lib_div::get_tag_attributes($this->curUrlArray['all']);
            }
            $this->curUrlInfo = $this->parseCurUrl($this->curUrlArray['href'], $this->siteURL);
        }
        // Determine nature of current url:
        $this->act = t3lib_div::_GP('act');
        if (!$this->act) {
            $this->act = $this->curUrlInfo['act'];
        }
        // Rich Text Editor specific configuration:
        $addPassOnParams = '';
        if ((string) $this->mode == 'rte') {
            $RTEtsConfigParts = explode(':', $this->RTEtsConfigParams);
            $addPassOnParams .= '&RTEtsConfigParams=' . rawurlencode($this->RTEtsConfigParams);
            $RTEsetup = $GLOBALS['BE_USER']->getTSConfig('RTE', t3lib_BEfunc::getPagesTSconfig($RTEtsConfigParts[5]));
            $this->thisConfig = t3lib_BEfunc::RTEsetup($RTEsetup['properties'], $RTEtsConfigParts[0], $RTEtsConfigParts[2], $RTEtsConfigParts[4]);
        }
        // Initializing the target value (RTE)
        $this->setTarget = $this->curUrlArray['target'] != '-' ? $this->curUrlArray['target'] : '';
        if ($this->thisConfig['defaultLinkTarget'] && !isset($this->curUrlArray['target'])) {
            $this->setTarget = $this->thisConfig['defaultLinkTarget'];
        }
        // Initializing the class value (RTE)
        $this->setClass = $this->curUrlArray['class'] != '-' ? $this->curUrlArray['class'] : '';
        // Initializing the title value (RTE)
        $this->setTitle = $this->curUrlArray['title'] != '-' ? $this->curUrlArray['title'] : '';
        // BEGIN accumulation of header JavaScript:
        $JScode = '
				// This JavaScript is primarily for RTE/Link. jumpToUrl is used in the other cases as well...
			var add_href="' . ($this->curUrlArray['href'] ? '&curUrl[href]=' . rawurlencode($this->curUrlArray['href']) : '') . '";
			var add_target="' . ($this->setTarget ? '&curUrl[target]=' . rawurlencode($this->setTarget) : '') . '";
			var add_class="' . ($this->setClass ? '&curUrl[class]=' . rawurlencode($this->setClass) : '') . '";
			var add_title="' . ($this->setTitle ? '&curUrl[title]=' . rawurlencode($this->setTitle) : '') . '";
			var add_params="' . ($this->bparams ? '&bparams=' . rawurlencode($this->bparams) : '') . '";

			var cur_href="' . ($this->curUrlArray['href'] ? $this->curUrlArray['href'] : '') . '";
			var cur_target="' . ($this->setTarget ? $this->setTarget : '') . '";
			var cur_class = "' . ($this->setClass ? $this->setClass : '-') . '";
			var cur_title="' . ($this->setTitle ? $this->setTitle : '') . '";

			function browse_links_setTarget(target)	{	//
				cur_target=target;
				add_target="&curUrl[target]="+escape(target);
			}
			function browse_links_setClass(cssClass) {   //
				cur_class = cssClass;
				add_class = "&curUrl[class]=" + escape(cssClass);
			}
			function browse_links_setTitle(title)	{	//
				cur_title=title;
				add_title="&curUrl[title]="+escape(title);
			}
			function browse_links_setValue(value) {	//
				cur_href=value;
				add_href="&curUrl[href]="+value;
			}
		';
        if ($this->mode == 'wizard') {
            // Functions used, if the link selector is in wizard mode (= TCEforms fields)
            unset($this->P['fieldChangeFunc']['alert']);
            $update = '';
            foreach ($this->P['fieldChangeFunc'] as $k => $v) {
                $update .= '
				window.opener.' . $v;
            }
            $P2 = array();
            $P2['itemName'] = $this->P['itemName'];
            $P2['formName'] = $this->P['formName'];
            $P2['fieldChangeFunc'] = $this->P['fieldChangeFunc'];
            $P2['params']['allowedExtensions'] = $this->P['params']['allowedExtensions'];
            $P2['params']['blindLinkOptions'] = $this->P['params']['blindLinkOptions'];
            $addPassOnParams .= t3lib_div::implodeArrayForUrl('P', $P2);
            $JScode .= '
				function link_typo3Page(id,anchor)	{	//
					updateValueInMainForm(id + (anchor ? anchor : ""));
					close();
					return false;
				}
				function link_folder(folder)	{	//
					updateValueInMainForm(folder);
					close();
					return false;
				}
				function link_current()	{	//
					if (cur_href!="http://" && cur_href!="mailto:")	{
						returnBeforeCleaned = cur_href;
						if (returnBeforeCleaned.substr(0, 7) == "http://") {
							returnToMainFormValue = returnBeforeCleaned.substr(7);
						} else if (returnBeforeCleaned.substr(0, 7) == "mailto:") {
							if (returnBeforeCleaned.substr(0, 14) == "mailto:mailto:") {
								returnToMainFormValue = returnBeforeCleaned.substr(14);
							} else {
								returnToMainFormValue = returnBeforeCleaned.substr(7);
							}
						} else {
							returnToMainFormValue = returnBeforeCleaned;
						}
						updateValueInMainForm(returnToMainFormValue);
						close();
					}
					return false;
				}
				function checkReference()	{	//
					if (window.opener && window.opener.document && window.opener.document.' . $this->P['formName'] . ' && window.opener.document.' . $this->P['formName'] . '["' . $this->P['itemName'] . '"] )	{
						return window.opener.document.' . $this->P['formName'] . '["' . $this->P['itemName'] . '"];
					} else {
						close();
					}
				}
				function updateValueInMainForm(input)	{	//
					var field = checkReference();
					if (field)	{
						if (cur_target == "" && (cur_title != "" || cur_class != "-")) {
							cur_target = "-";
						}
						if (cur_title == "" && cur_class == "-") {
							cur_class = "";
						}
						cur_class = cur_class.replace(/[\'\\"]/g, "");
						if (cur_class.indexOf(" ") != -1) {
							cur_class = "\\"" + cur_class + "\\"";
						}
						cur_title = cur_title.replace(/(^\\")|(\\"$)/g, "");
						if (cur_title.indexOf(" ") != -1) {
							cur_title = "\\"" + cur_title + "\\"";
						}
						input = input + " " + cur_target + " " + cur_class + " " + cur_title;
						field.value = input;
						' . $update . '
					}
				}
			';
        } else {
            // Functions used, if the link selector is in RTE mode:
            $JScode .= '
				function link_typo3Page(id,anchor)	{	//
					var theLink = \'' . $this->siteURL . '?id=\'+id+(anchor?anchor:"");
					self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
					return false;
				}
				function link_folder(folder)	{	//
					var theLink = \'' . $this->siteURL . '\'+folder;
					self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
					return false;
				}
				function link_spec(theLink)	{	//
					self.parent.parent.renderPopup_addLink(theLink, cur_target, cur_class, cur_title);
					return false;
				}
				function link_current()	{	//
					if (cur_href!="http://" && cur_href!="mailto:")	{
						self.parent.parent.renderPopup_addLink(cur_href, cur_target, cur_class, cur_title);
					}
					return false;
				}
			';
        }
        // General "jumpToUrl" function:
        $JScode .= '
			function jumpToUrl(URL,anchor)	{	//
				var add_act = URL.indexOf("act=")==-1 ? "&act=' . $this->act . '" : "";
				var add_mode = URL.indexOf("mode=")==-1 ? "&mode=' . $this->mode . '" : "";
				var theLocation = URL + add_act + add_mode + add_href + add_target + add_class + add_title + add_params' . ($addPassOnParams ? '+"' . $addPassOnParams . '"' : '') . '+(anchor?anchor:"");
				window.location.href = theLocation;
				return false;
			}
		';
        /**
         * Splits parts of $this->bparams
         * @see $bparams
         */
        $pArr = explode('|', $this->bparams);
        // This is JavaScript especially for the TBE Element Browser!
        $formFieldName = 'data[' . $pArr[0] . '][' . $pArr[1] . '][' . $pArr[2] . ']';
        // insertElement - Call check function (e.g. for uniqueness handling):
        if ($pArr[4] && $pArr[5]) {
            $JScodeCheck = '
					// Call a check function in the opener window (e.g. for uniqueness handling):
				if (parent.window.opener) {
					var res = parent.window.opener.' . $pArr[5] . '("' . addslashes($pArr[4]) . '",table,uid,type);
					if (!res.passed) {
						if (res.message) alert(res.message);
						performAction = false;
					}
				} else {
					alert("Error - reference to main window is not set properly!");
					parent.close();
				}
			';
        }
        // insertElement - Call helper function:
        if ($pArr[4] && $pArr[6]) {
            $JScodeHelper = '
						// Call helper function to manage data in the opener window:
					if (parent.window.opener) {
						parent.window.opener.' . $pArr[6] . '("' . addslashes($pArr[4]) . '",table,uid,type,"' . addslashes($pArr[0]) . '");
					} else {
						alert("Error - reference to main window is not set properly!");
						parent.close();
					}
			';
        }
        // insertElement - perform action commands:
        if ($pArr[4] && $pArr[7]) {
            // Call user defined action function:
            $JScodeAction = '
					if (parent.window.opener) {
						parent.window.opener.' . $pArr[7] . '("' . addslashes($pArr[4]) . '",table,uid,type);
						focusOpenerAndClose(close);
					} else {
						alert("Error - reference to main window is not set properly!");
						parent.close();
					}
			';
        } else {
            if ($pArr[0] && !$pArr[1] && !$pArr[2]) {
                $JScodeAction = '
					addElement(filename,table+"_"+uid,fp,close);
			';
            } else {
                $JScodeAction = '
					if (setReferences()) {
						parent.window.opener.group_change("add","' . $pArr[0] . '","' . $pArr[1] . '","' . $pArr[2] . '",elRef,targetDoc);
					} else {
						alert("Error - reference to main window is not set properly!");
					}
					focusOpenerAndClose(close);
			';
            }
        }
        $JScode .= '
			var elRef="";
			var targetDoc="";

			function launchView(url)	{	//
				var thePreviewWindow="";
				thePreviewWindow = window.open("' . $BACK_PATH . 'show_item.php?table="+url,"ShowItem","height=300,width=410,status=0,menubar=0,resizable=0,location=0,directories=0,scrollbars=1,toolbar=0");
				if (thePreviewWindow && thePreviewWindow.focus)	{
					thePreviewWindow.focus();
				}
			}
			function setReferences()	{	//
				if (parent.window.opener && parent.window.opener.content && parent.window.opener.content.document.editform && parent.window.opener.content.document.editform["' . $formFieldName . '"]) {
					targetDoc = parent.window.opener.content.document;
					elRef = targetDoc.editform["' . $formFieldName . '"];
					return true;
				} else {
					return false;
				}
			}
			function insertElement(table, uid, type, filename,fp,filetype,imagefile,action, close)	{	//
				var performAction = true;
				' . $JScodeCheck . '
					// Call performing function and finish this action:
				if (performAction) {
						' . $JScodeHelper . $JScodeAction . '
				}
				return false;
			}
			function addElement(elName,elValue,altElValue,close)	{	//
				if (parent.window.opener && parent.window.opener.setFormValueFromBrowseWin)	{
					parent.window.opener.setFormValueFromBrowseWin("' . $pArr[0] . '",altElValue?altElValue:elValue,elName);
					focusOpenerAndClose(close);
				} else {
					alert("Error - reference to main window is not set properly!");
					parent.close();
				}
			}
			function focusOpenerAndClose(close)	{	//
				BrowseLinks.focusOpenerAndClose(close);
			}
		';
        // Finally, add the accumulated JavaScript to the template object:
        $this->doc->JScode .= $this->doc->wrapScriptTags($JScode);
        // Debugging:
        if (FALSE) {
            debug(array('pointer' => $this->pointer, 'act' => $this->act, 'mode' => $this->mode, 'curUrlInfo' => $this->curUrlInfo, 'curUrlArray' => $this->curUrlArray, 'P' => $this->P, 'bparams' => $this->bparams, 'RTEtsConfigParams' => $this->RTEtsConfigParams, 'expandPage' => $this->expandPage, 'expandFolder' => $this->expandFolder, 'PM' => $this->PM), 'Internal variables of Script Class:');
        }
    }
示例#29
0
    /**
     * Find related news records and pages, add links to them and wrap them with stdWraps from TS.
     *
     * @param	integer		$uid of the current news record
     * @return	string		html code for the related news list
     */
    function getRelated($uid)
    {
        $lConf = $this->conf['getRelatedCObject.'];
        $visibleCategories = '';
        $sPidByCat = array();
        if ($this->conf['checkCategoriesOfRelatedNews'] || $this->conf['useSPidFromCategory']) {
            // get visible categories and their singlePids
            $catres = $this->db->exec_SELECTquery('tt_news_cat.uid,tt_news_cat.single_pid', 'tt_news_cat', '1=1' . $this->SPaddWhere . $this->enableCatFields);
            $catTemp = array();
            while ($catrow = $this->db->sql_fetch_assoc($catres)) {
                $sPidByCat[$catrow['uid']] = $catrow['single_pid'];
                $catTemp[] = $catrow['uid'];
            }
            $this->db->sql_free_result($catres);
            if ($this->conf['checkCategoriesOfRelatedNews']) {
                $visibleCategories = implode($catTemp, ',');
            }
        }
        $relPages = FALSE;
        if ($this->conf['usePagesRelations']) {
            $relPages = $this->getRelatedPages($uid);
        }
        //		$select_fields = 'DISTINCT uid, pid, title, short, datetime, archivedate, type, page, ext_url, sys_language_uid, l18n_parent, M.tablenames';
        $select_fields = ' uid, pid, title, short, datetime, archivedate, type, page, ext_url, sys_language_uid, l18n_parent, tt_news_related_mm.tablenames, image, bodytext';
        //		$where = 'tt_news.uid=M.uid_foreign AND M.uid_local=' . $uid . ' AND M.tablenames!=' . $this->db->fullQuoteStr('pages', 'tt_news_related_mm');
        $where = 'tt_news_related_mm.uid_local=' . $uid . '
					AND tt_news.uid=tt_news_related_mm.uid_foreign
					AND tt_news_related_mm.tablenames!=' . $this->db->fullQuoteStr('pages', 'tt_news_related_mm');
        $groupBy = '';
        if ($lConf['groupBy']) {
            $groupBy = trim($lConf['groupBy']);
        }
        $orderBy = '';
        if ($lConf['orderBy']) {
            $orderBy = trim($lConf['orderBy']);
        }
        if ($this->conf['useBidirectionalRelations']) {
            //			$where = '((' . $where . ') OR (tt_news.uid=M.uid_local AND M.uid_foreign=' . $uid . ' AND M.tablenames!=' . $this->db->fullQuoteStr('pages', 'tt_news_related_mm') . '))';
            $where = '((' . $where . ')
					OR (tt_news_related_mm.uid_foreign=' . $uid . '
						AND tt_news.uid=tt_news_related_mm.uid_local
						AND tt_news_related_mm.tablenames!=' . $this->db->fullQuoteStr('pages', 'tt_news_related_mm') . '))';
        }
        //		$from_table = 'tt_news,tt_news_related_mm AS M';
        $from_table = 'tt_news_related_mm, tt_news';
        $res = $this->db->exec_SELECTquery($select_fields, $from_table, $where . $this->enableFields, $groupBy, $orderBy);
        if ($res) {
            $relrows = array();
            while ($relrow = $this->db->sql_fetch_assoc($res)) {
                $currentCats = array();
                if ($this->conf['checkCategoriesOfRelatedNews'] || $this->conf['useSPidFromCategory']) {
                    $currentCats = $this->getCategories($relrow['uid'], true);
                }
                if ($this->conf['checkCategoriesOfRelatedNews']) {
                    if (count($currentCats)) {
                        // record has categories
                        foreach ($currentCats as $cUid) {
                            if (t3lib_div::inList($visibleCategories, $cUid['catid'])) {
                                // if the record has at least one visible category assigned it will be shown
                                $relrows[$relrow['uid']] = $relrow;
                                break;
                            }
                        }
                    } else {
                        // record has NO categories
                        $relrows[$relrow['uid']] = $relrow;
                    }
                } else {
                    $relrows[$relrow['uid']] = $relrow;
                }
                // check if there's a single pid for the first category of a news record and add 'sPidByCat' to the $relrows array.
                if ($this->conf['useSPidFromCategory'] && count($currentCats) && $relrows[$relrow['uid']]) {
                    $firstcat = array_shift($currentCats);
                    if ($firstcat['catid'] && $sPidByCat[$firstcat['catid']]) {
                        $relrows[$relrow['uid']]['sPidByCat'] = $sPidByCat[$firstcat['catid']];
                    }
                }
            }
            //			debug($relrows, '$relrows ('.__CLASS__.'::'.__FUNCTION__.')', __LINE__, __FILE__, 3);
            $this->db->sql_free_result($res);
            if (is_array($relPages[0]) && $this->conf['usePagesRelations']) {
                $relrows = array_merge_recursive($relPages, $relrows);
            }
            $piVarsArray = array('backPid' => $this->conf['dontUseBackPid'] ? null : $this->config['backPid'], 'year' => $this->conf['dontUseBackPid'] ? null : ($this->piVars['year'] ? $this->piVars['year'] : null), 'month' => $this->conf['dontUseBackPid'] ? null : ($this->piVars['month'] ? $this->piVars['month'] : null));
            $veryLocal_cObj = t3lib_div::makeInstance('tslib_cObj');
            // Local cObj.
            $lines = array();
            // save current realUrl state
            $tmpRealUrl = (bool) $this->tsfe->config['config']['tx_realurl_enable'];
            $tmpCoolUri = (bool) $this->tsfe->config['config']['tx_cooluri_enable'];
            foreach ($relrows as $row) {
                if ($this->tsfe->sys_language_content && $row['tablenames'] != 'pages') {
                    $OLmode = $this->sys_language_mode == 'strict' ? 'hideNonTranslated' : '';
                    $row = $this->tsfe->sys_page->getRecordOverlay('tt_news', $row, $this->tsfe->sys_language_content, $OLmode);
                    if (!is_array($row)) {
                        continue;
                    }
                }
                $veryLocal_cObj->start($row, 'tt_news');
                if ($row['type'] != 1 && $row['type'] != 2) {
                    // only normal news
                    $catSPid = false;
                    if ($row['sPidByCat'] && $this->conf['useSPidFromCategory']) {
                        $catSPid = $row['sPidByCat'];
                    }
                    $sPid = $catSPid ? $catSPid : $this->config['singlePid'];
                    // temporary disable realUrl to get raw GETvars from function getSingleViewLink()
                    $this->tsfe->config['config']['tx_realurl_enable'] = 0;
                    $this->tsfe->config['config']['tx_cooluri_enable'] = 0;
                    // special treatment for simulatestatic because it doesn't seem possible to temporarily disable it after tslib_fe is once initialized
                    if ($this->tsfe->config['config']['simulateStaticDocuments']) {
                        /**
                         * TODO: 16.04.2009
                         *
                         * extract parameters from GETvars like it was done in tt_news 2.5.x
                         */
                    }
                    $link = $this->getSingleViewLink($sPid, $row, $piVarsArray, true);
                    $linkArr = t3lib_div::explodeUrl2Array($link, true);
                    $newsAddParams = '';
                    if (is_array($linkArr) && is_array($linkArr['tx_ttnews'])) {
                        $newsAddParams = t3lib_div::implodeArrayForUrl('tx_ttnews', $linkArr['tx_ttnews']);
                    }
                    // load the parameter string into the register 'newsAddParams' to access it from TS
                    $veryLocal_cObj->LOAD_REGISTER(array('newsAddParams' => $newsAddParams, 'newsSinglePid' => $sPid), '');
                    if (!$this->conf['getRelatedCObject.']['10.']['default.']['10.']['typolink.']['parameter'] || $catSPid) {
                        $this->conf['getRelatedCObject.']['10.']['default.']['10.']['typolink.']['parameter'] = $sPid;
                    }
                }
                // re-enable realUrl (if set) to make cObjGetSingle render the related links as realUrls
                $this->tsfe->config['config']['tx_realurl_enable'] = $tmpRealUrl;
                $this->tsfe->config['config']['tx_cooluri_enable'] = $tmpCoolUri;
                $lines[] = $veryLocal_cObj->cObjGetSingle($this->conf['getRelatedCObject'], $this->conf['getRelatedCObject.'], 'getRelatedCObject');
            }
            // make sure that realUrl is set to its previous state
            $this->tsfe->config['config']['tx_realurl_enable'] = $tmpRealUrl;
            $this->tsfe->config['config']['tx_cooluri_enable'] = $tmpCoolUri;
            if ($this->debugTimes) {
                $this->hObj->getParsetime(__METHOD__);
            }
            return implode('', $lines);
        } else {
            return '';
        }
    }
示例#30
0
 /**
  * Creates a tab menu from an array definition
  *
  * Returns a tab menu for a module
  * Requires the JS function jumpToUrl() to be available
  *
  * @param	mixed		$id is the "&id=" parameter value to be sent to the module, but it can be also a parameter array which will be passed instead of the &id=...
  * @param	string		$elementName it the form elements name, probably something like "SET[...]"
  * @param	string		$currentValue is the value to be selected currently.
  * @param	array		$menuItems is an array with the menu items for the selector box
  * @param	string		$script is the script to send the &id to, if empty it's automatically found
  * @param	string		$addParams is additional parameters to pass to the script.
  * @return	string		HTML code for tab menu
  * @author	Rene Fritz <*****@*****.**>
  */
 function getTabMenu($mainParams, $elementName, $currentValue, $menuItems, $script = '', $addparams = '')
 {
     $content = '';
     if (is_array($menuItems)) {
         if (!is_array($mainParams)) {
             $mainParams = array('id' => $mainParams);
         }
         $mainParams = t3lib_div::implodeArrayForUrl('', $mainParams);
         if (!$script) {
             $script = basename(PATH_thisScript);
         }
         $menuDef = array();
         foreach ($menuItems as $value => $label) {
             $menuDef[$value]['isActive'] = !strcmp($currentValue, $value);
             $menuDef[$value]['label'] = t3lib_div::deHSCentities(htmlspecialchars($label));
             $menuDef[$value]['url'] = $script . '?' . $mainParams . $addparams . '&' . $elementName . '=' . $value;
         }
         $content = $this->getTabMenuRaw($menuDef);
     }
     return $content;
 }