Feature #16935 » 4911_translation_shortcut_url__v5_for_v4.2.6.diff

Administrator Admin, 2009-05-07 18:28

View differences:

typo3_src/t3lib/config_default.php 2009-05-07 14:02:59.000000000 +0200
248 248
		'get_url_id_token' => '#get_URL_ID_TOK#',	// This is the token, which is substituted in the output code in order to keep a GET-based session going. Normally the GET-session-id is 5 chars ('&ftu=') + hash_length (norm. 10)
249 249
		'content_doktypes' => '1,2,5,7',			// List of pages.doktype values which can contain content (so shortcut pages and external url pages are excluded, but all pages below doktype 199 should be included. doktype=6 is not either (backend users only...). For doktypes going into menus see class.tslib_menu.php, line 494 (search for 'doktype'))
250 250
		'enable_mount_pids' => 1,					// If set to "1", the mount_pid feature allowing 'symlinks' in the page tree (for frontend operation) is allowed.
251
		'pageOverlayFields' => 'uid,title,subtitle,nav_title,media,keywords,description,abstract,author,author_email',				// List of fields from the table "pages_language_overlay" which should be overlaid on page records. See t3lib_page::getPageOverlay()
251
		'pageOverlayFields' => 'uid,title,subtitle,nav_title,media,keywords,description,abstract,author,author_email,url,urltype,shortcut,shortcut_mode',				// List of fields from the table "pages_language_overlay" which should be overlaid on page records. See t3lib_page::getPageOverlay()
252 252
		'hidePagesIfNotTranslatedByDefault' => FALSE,	// If TRUE, pages that has no translation will be hidden by default. Basically this will inverse the effect of the page localization setting "Hide page if no translation for current language exists" to "Show page even if no translation exists"
253 253
		'eID_include' => array(),				// Array of key/value pairs where key is "tx_[ext]_[optional suffix]" and value is relative filename of class to include. Key is used as "?eID=" for index_ts.php to include the code file which renders the page from that point. (Useful for functionality that requires a low initialization footprint, eg. frontend ajax applications)
254 254
		'pageCacheToExternalFiles' => FALSE,	// If set, page cache entries will be stored in typo3temp/cache_pages/ab/ instead of the database. Still, "cache_pages" will be filled in database but the "HTML" field will be empty. When the cache is flushed the files in cache_pages/ab/ will not be flush - you will have to garbage clean manually once in a while.
typo3_src/typo3/class.db_list_extra.inc 2009-05-07 14:38:36.000000000 +0200
808 808

  
809 809
							} else {
810 810
								$params = '&edit['.$table.']['.$this->id.']=new';
811
								if ($table == 'pages_language_overlay') {
812
									$params .= '&overrideVals[pages_language_overlay][doktype]=' . (int) $this->pageRow['doktype'];
813
								}
811 814
								$icon   = '<a href="#" onclick="'.htmlspecialchars(t3lib_BEfunc::editOnClick($params,$this->backPath,-1)).'">'.
812 815
												'<img'.t3lib_iconWorks::skinImg($this->backPath,'gfx/new_'.($table=='pages'?'page':'el').'.gif','width="'.($table=='pages'?13:11).'" height="12"').' title="'.$LANG->getLL('new',1).'" alt="" />'.
813 816
												'</a>';
typo3_src/typo3/db_new.php 2009-05-07 14:17:11.000000000 +0200
479 479
				// Create link to new page after
480 480
			$t = 'pages';
481 481
			$v = $TCA[$t];
482
			$rowContent = $this->linkWrap(
483
					t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'').
484
						$LANG->sL($v['ctrl']['title'],1).' ('.$LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.after',1).')',
482
			$rowContent = '<img'.t3lib_iconWorks::skinImg($BACK_PATH,'gfx/ol/join.gif','width="18" height="16"').' alt="" />'.
483
 				$this->linkWrap(
484
 					t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'').
485
 						$LANG->sL($v['ctrl']['title'],1).' ('.$LANG->sL('LLL:EXT:lang/locallang_core.php:db_new.php.after',1).')',
485 486
					'pages',
486 487
					-$this->id
487 488
				);
......
524 525
	 * Links the string $code to a create-new form for a record in $table created on page $pid
525 526
	 *
526 527
	 * @param	string		Link string
528
	 * @param	string		Link text
527 529
	 * @param	string		Table name (in which to create new record)
528 530
	 * @param	integer		PID value for the "&edit['.$table.']['.$pid.']=new" command (positive/negative)
529 531
	 * @param	boolean		If $addContentTable is set, then a new contentTable record is created together with pages
530 532
	 * @return	string		The link.
531 533
	 */
532
	function linkWrap($code,$table,$pid,$addContentTable=0)	{
533
		$params = '&edit['.$table.']['.$pid.']=new'.
534
			($table=='pages'
535
				&& $GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']
536
				&& isset($GLOBALS['TCA'][$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']])
537
				&& $addContentTable	?
538
				'&edit['.$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable'].'][prev]=new&returnNewPageId=1'	:
539
				''
540
			);
541
		$onClick = t3lib_BEfunc::editOnClick($params,'',$this->returnUrl);
542
		return '<a href="#" onclick="'.htmlspecialchars($onClick).'">'.$code.'</a>';
534
	function linkWrap($linkText, $table, $pid, $addContentTable = false) {
535
		$parameters = '&edit[' . $table . '][' . $pid . ']=new';
536

  
537
		if ($table == 'pages'
538
			&& $GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']
539
			&& isset($GLOBALS['TCA'][$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable']])
540
			&& $addContentTable) {
541
			$parameters .= '&edit['.$GLOBALS['TYPO3_CONF_VARS']['SYS']['contentTable'].'][prev]=new&returnNewPageId=1';
542
		} elseif ($table == 'pages_language_overlay') {
543
			$parameters .= '&overrideVals[pages_language_overlay][doktype]='
544
						. (int) $this->pageinfo['doktype'];
545
		}
546

  
547
		$onClick = t3lib_BEfunc::editOnClick($parameters, '', $this->returnUrl);
548

  
549
		return '<a href="#" onclick="'.htmlspecialchars($onClick).'">' . $linkText . '</a>';
543 550
	}
544 551

  
545 552
	/**
typo3_src/typo3/sysext/cms/ext_tables.php 2009-05-07 14:21:23.000000000 +0200
745 745
// ******************************************************************
746 746
$TCA['pages_language_overlay'] = array (
747 747
	'ctrl' => array (
748
		'label' => 'title',
749
		'tstamp' => 'tstamp',
750
		'title' => 'LLL:EXT:cms/locallang_tca.xml:pages_language_overlay',
751
		'versioningWS' => true,
752
		'versioning_followPages' => true,
753
		'origUid' => 't3_origuid',
754
		'crdate' => 'crdate',
755
		'cruser_id' => 'cruser_id',
756
		'delete' => 'deleted',
757
		'enablecolumns' => array (
758
			'disabled' => 'hidden',
759
			'starttime' => 'starttime',
760
			'endtime' => 'endtime'
748
		'label'                           => 'title',
749
		'tstamp'                          => 'tstamp',
750
		'title'                           => 'LLL:EXT:cms/locallang_tca.xml:pages_language_overlay',
751
		'versioningWS'                    => true,
752
		'versioning_followPages'          => true,
753
		'origUid'                         => 't3_origuid',
754
		'crdate'                          => 'crdate',
755
		'cruser_id'                       => 'cruser_id',
756
		'delete'                          => 'deleted',
757
		'enablecolumns'                   => array (
758
			'disabled'  => 'hidden',
759
 			'starttime' => 'starttime',
760
			'endtime'   => 'endtime'
761 761
		),
762
		'transOrigPointerField' => 'pid',
763
		'transOrigPointerTable' => 'pages',
764
		'transOrigDiffSourceField' => 'l18n_diffsource',
762
		'transOrigPointerField'           => 'pid',
763
		'transOrigPointerTable'           => 'pages',
764
		'transOrigDiffSourceField'        => 'l18n_diffsource',
765 765
		'shadowColumnsForNewPlaceholders' => 'title',
766
		'languageField' => 'sys_language_uid',
767
		'mainpalette' => 1,
768
		'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tbl_cms.php'
766
		'languageField'                   => 'sys_language_uid',
767
		'mainpalette'                     => 1,
768
		'dynamicConfigFile'               => t3lib_extMgm::extPath($_EXTKEY) . 'tbl_cms.php',
769
		'type'                            => 'doktype',
770
		'dividers2tabs'                   => true
769 771
	)
770 772
);
771 773

  
typo3_src/typo3/sysext/cms/ext_tables.sql 2009-05-07 14:29:30.000000000 +0200
167 167
CREATE TABLE pages_language_overlay (
168 168
  uid int(11) NOT NULL auto_increment,
169 169
  pid int(11) DEFAULT '0' NOT NULL,
170
  doktype tinyint(3) unsigned DEFAULT '0' NOT NULL,
170 171
  t3ver_oid int(11) DEFAULT '0' NOT NULL,
171 172
  t3ver_id int(11) DEFAULT '0' NOT NULL,
172 173
  t3ver_wsid int(11) DEFAULT '0' NOT NULL,
......
195 196
  author_email varchar(80) DEFAULT '' NOT NULL,
196 197
  tx_impexp_origuid int(11) DEFAULT '0' NOT NULL,
197 198
  l18n_diffsource mediumblob,
199
  url varchar(255) DEFAULT '' NOT NULL,
200
  urltype tinyint(4) unsigned DEFAULT '0' NOT NULL,
201
  shortcut int(10) unsigned DEFAULT '0' NOT NULL,
202
  shortcut_mode int(10) unsigned DEFAULT '0' NOT NULL,
198 203

  
199 204
  PRIMARY KEY (uid),
200 205
  KEY t3ver_oid (t3ver_oid,t3ver_wsid),
typo3_src/typo3/sysext/cms/layout/class.tx_cms_layout.php 2009-05-07 14:30:57.000000000 +0200
2005 2005

  
2006 2006
				// If any languages are left, make selector:
2007 2007
			if (count($langSelItems)>1)		{
2008
				$onChangeContent = 'window.location.href=\''.$this->backPath.'alt_doc.php?&edit[pages_language_overlay]['.$id.']=new&overrideVals[pages_language_overlay][sys_language_uid]=\'+this.options[this.selectedIndex].value+\'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')).'\'';
2008
				$onChangeContent = 'window.location.href=\''.$this->backPath.'alt_doc.php?&edit[pages_language_overlay]['.$id.']=new&overrideVals[pages_language_overlay][doktype]=' . (int) $this->pageRecord['doktype'] . '&overrideVals[pages_language_overlay][sys_language_uid]=\'+this.options[this.selectedIndex].value+\'&returnUrl='.rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')).'\'';
2009 2009
				return $GLOBALS['LANG']->getLL('new_language',1).': <select name="createNewLanguage" onchange="'.htmlspecialchars($onChangeContent).'">
2010 2010
						'.implode('',$langSelItems).'
2011 2011
					</select><br /><br />';
typo3_src/typo3/sysext/cms/tbl_cms.php 2009-05-07 15:12:59.000000000 +0200
450 450
		'showRecordFieldList' => 'title,hidden,starttime,endtime,keywords,description,abstract'
451 451
	),
452 452
	'columns' => Array (
453
		'doktype' => $TCA['pages']['columns']['doktype'],
453 454
		'hidden' => Array (
454 455
			'exclude' => 1,
455
			'label' => 'LLL:EXT:lang/locallang_general.php:LGL.hidden',
456
			'label' => 'LLL:EXT:cms/locallang_tca.xml:pages.hidden',
456 457
			'config' => Array (
457 458
				'type' => 'check',
458 459
				'default' => '0'
......
581 582
				'minitems' => '0'
582 583
			)
583 584
		),
585
		'url' => array(
586
			'exclude' => 1,
587
			'label' => 'LLL:EXT:cms/locallang_tca.php:pages.url',
588
			'config' => array(
589
				'type' => 'input',
590
				'size' => '25',
591
				'max' => '255',
592
				'eval' => 'trim'
593
			)
594
		),
595
		'urltype' => array(
596
			'exclude' => 1,
597
			'label' => 'LLL:EXT:lang/locallang_general.php:LGL.type',
598
			'config' => array(
599
				'type' => 'select',
600
				'items' => $TCA['pages']['columns']['urltype']['config']['items'],
601
				'default' => '1'
602
			)
603
		),
604
		'shortcut' => array (
605
			'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.shortcut_page',
606
			'config' => array (
607
				'type' => 'group',
608
				'internal_type' => 'db',
609
				'allowed' => 'pages',
610
				'size' => '3',
611
				'maxitems' => '1',
612
				'minitems' => '0',
613
				'show_thumbs' => '1'
614
			)
615
		),
616
		'shortcut_mode' => array (
617
			'exclude' => 1,
618
			'label' => 'LLL:EXT:cms/locallang_tca.xml:pages.shortcut_mode',
619
			'config' => array (
620
				'type' => 'select',
621
				'items' => $TCA['pages']['columns']['shortcut_mode']['config']['items'],
622
				'default' => '0'
623
			)
624
		),
584 625
		'sys_language_uid' => Array (
585 626
			'label' => 'LLL:EXT:lang/locallang_general.php:LGL.language',
586 627
			'config' => Array (
......
604 645
		),
605 646
	),
606 647
	'types' => Array (
607
		'0' => Array('showitem' => 'hidden;;;;1-1-1, sys_language_uid, title;;;;2-2-2, subtitle, nav_title, --div--, abstract;;5;;3-3-3, keywords, description, media;;;;4-4-4')
648
			// Standard
649
		'1'   => array('showitem' => 'doktype;;;;1-1-1, hidden, sys_language_uid, title;;;;2-2-2, subtitle, nav_title,                                                                                              --div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.metadata, --palette--;LLL:EXT:lang/locallang_general.xml:LGL.author;5;;3-3-3, abstract, keywords, description, --div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.files, media;;;;4-4-4, --div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.access, starttime, endtime'),
650

  
651
			// External URL - URL and URL type can be different for the translated page
652
		'3'   => array('showitem' => 'doktype;;;;1-1-1, hidden, sys_language_uid, title;;;;2-2-2, subtitle,            --div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.url, url;;;;3-3-3, urltype,                                                                                                                                                                                 --div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.files, media;;;;4-4-4, --div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.access, starttime, endtime'),
653

  
654
			// Shortcut - shortcut and shortcut mode can be different for the translated page
655
		'4'   => array('showitem' => 'doktype;;;;1-1-1, hidden, sys_language_uid, title;;;;2-2-2, subtitle,            --div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.shortcut, shortcut;;;;3-3-3, shortcut_mode,                                                                                                                                                                 --div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.files, media;;;;4-4-4, --div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.access, starttime, endtime'),
656

  
657
			// Mount Point - mount point options can _NOT_ be different for the translated page
658
		'7'   => array('showitem' => 'doktype;;;;1-1-1, hidden, sys_language_uid, title;;;;2-2-2, subtitle, nav_title,                                                                                                                                                                                                                                                              --div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.files, media;;;;4-4-4, --div--;LLL:EXT:cms/locallang_tca.xml:pages.tabs.access, starttime, endtime'),
659

  
660
			// Separator
661
		'199' => array('showitem' => 'doktype;;;;1-1-1, hidden, sys_language_uid, title;;;;2-2-2'),
662

  
663
			// Sysfolder
664
		'254' => array('showitem' => 'doktype;;;;1-1-1, hidden, sys_language_uid, title;LLL:EXT:lang/locallang_general.xml:LGL.title;;;2-2-2'),
665

  
666
			// Recycler
667
		'255' => array('showitem' => 'doktype;;;;1-1-1, hidden, sys_language_uid, title;;;;2-2-2')
608 668
	),
609 669
	'palettes' => Array (
610
		'1' => Array('showitem' => 'starttime,endtime'),
611
		'5' => Array('showitem' => 'author,author_email')
670
		'5' => array('showitem' => 'author,author_email', 'canNotCollapse' => true)
612 671
	)
613 672
);
614 673

  
typo3_src/typo3/sysext/cms/tslib/class.tslib_fe.php 2009-05-07 14:27:59.000000000 +0200
224 224
	var $rootLine='';					// The rootLine (all the way to tree root, not only the current site!) (array)
225 225
	var $page='';						// The pagerecord (array)
226 226
	var $contentPid=0;					// This will normally point to the same value as id, but can be changed to point to another page from which content will then be displayed instead.
227

  
227
	protected $originalShortcutPage = null;	// gets set when we are processing a page of type shortcut in the early stages opf init.php when we do not know about languages yet, used later in init.php to determine the correct shortcut in case a translation changes the shortcut target (array)
228
	
228 229
	/**
229 230
	 * sys_page-object, pagefunctions
230 231
	 *
......
1040 1041
			// Is the ID a link to another page??
1041 1042
		if ($this->page['doktype']==4)	{
1042 1043
			$this->MP = '';		// We need to clear MP if the page is a shortcut. Reason is if the short cut goes to another page, then we LEAVE the rootline which the MP expects.
1044
			
1045
			// saving the page so that we can check later - when we know
1046
			// about languages - whether we took the correct shortcut or
1047
			// whether a translation of the page overwrites the shortcut
1048
			// target and we need to follow the new target
1049
			$this->originalShortcutPage = $this->page;
1050
			
1043 1051
			$this->page = $this->getPageShortcut($this->page['shortcut'],$this->page['shortcut_mode'],$this->page['uid']);
1044 1052
			$this->id = $this->page['uid'];
1045 1053
		}
......
2238 2246

  
2239 2247
			// If sys_language_uid is set to another language than default:
2240 2248
		if ($this->sys_language_uid>0)	{
2249
		
2250
				// check whether a shortcut is overwritten by a translated page
2251
				// we can only do this now, as this is the place where we get
2252
				// to know about translations
2253
			$this->checkTranslatedShortcut();
2254
		
2241 2255
				// Request the overlay record for the sys_language_uid:
2242 2256
			$olRec = $this->sys_page->getPageOverlay($this->id, $this->sys_language_uid);
2243 2257
			if (!count($olRec))	{
......
2350 2364
			$this->localeCharset = $this->csConvObj->get_locale_charset($this->config['config']['locale_all']);
2351 2365
		}
2352 2366
	}
2367
	
2368
	/**
2369
	 * checks whether a translated shortcut page has a different shortcut
2370
	 * target than the original language page.
2371
	 * If that is the case, things get corrected to follow that alternative
2372
	 * shortcut
2373
	 *
2374
	 * @return	void
2375
	 * @author	Ingo Renner <ingo@typo3.org>
2376
	 */
2377
	protected function checkTranslatedShortcut() {
2378

  
2379
		if (!is_null($this->originalShortcutPage)) {
2380
			$originalShortcutPageOverlay = $this->sys_page->getPageOverlay($this->originalShortcutPage['uid'], $this->sys_language_uid);
2381

  
2382
			if (!empty($originalShortcutPageOverlay['shortcut']) && $originalShortcutPageOverlay['shortcut'] != $this->id) {
2383
					// the translation of the original shortcut page has a different shortcut target!
2384
					// set the correct page and id
2385

  
2386
				$shortcut = $this->getPageShortcut(
2387
					$originalShortcutPageOverlay['shortcut'],
2388
					$originalShortcutPageOverlay['shortcut_mode'],
2389
					$originalShortcutPageOverlay['uid']
2390
				);
2391

  
2392
				$this->id   = $this->contentPid = $shortcut['uid'];
2393
				$this->page = $this->sys_page->getPage($this->id);
2394

  
2395
					// fix various effects on things like menus f.e.
2396
				$this->fetch_the_id();
2397
				$this->tmpl->rootLine = array_reverse($this->rootLine);
2398
			}
2399
		}
2400
	}
2401

  
2353 2402

  
2354 2403
	/**
2355 2404
	 * Checks if any email-submissions or submission via the fe_tce
(7-7/7)