summaryrefslogtreecommitdiff
path: root/www/contao29/patches/patch-aa
blob: 682be000e655d58f41ed5058481f9de90d33ebc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
$NetBSD: patch-aa,v 1.1 2010/07/28 16:28:51 taca Exp $

Fix preview problem when URL rewriting is enabled from repository, r513.

--- contao/main.php.orig	2010-06-04 11:45:49.000000000 +0000
+++ contao/main.php
@@ -235,53 +235,57 @@ class Main extends Backend
 		$this->Template->be27 = !$GLOBALS['TL_CONFIG']['oldBeTheme'];
 		$this->Template->home = $GLOBALS['TL_LANG']['MSC']['home'];
 		$this->Template->backToTop = $GLOBALS['TL_LANG']['MSC']['backToTop'];
+		$this->Template->frontendFile = $GLOBALS['TL_CONFIG']['rewriteURL'] ? '' : 'index.php';
 
-		$this->Template->frontendFile = 'index.php';
-
-		// Preview pages
-		if ($this->Input->get('do') == 'page' && strlen(CURRENT_ID))
+		// Front end preview links
+		if (CURRENT_ID != '')
 		{
-			$objPreview = $this->Database->prepare("SELECT id, alias FROM tl_page WHERE id=?")
-										 ->limit(1)
-										 ->execute(CURRENT_ID);
-
-			if ($objPreview->numRows)
+			// Pages
+			if ($this->Input->get('do') == 'page')
 			{
-				if ($GLOBALS['TL_CONFIG']['disableAlias'])
-				{
-					$this->Template->frontendFile = 'index.php?id=' . $objPreview->id;
-				}
-				else
+				$objPreview = $this->Database->prepare("SELECT id, alias FROM tl_page WHERE id=?")
+											 ->limit(1)
+											 ->execute(CURRENT_ID);
+
+				if ($objPreview->numRows)
 				{
-					$this->Template->frontendFile = 'index.php/' . (strlen($objPreview->alias) ? $objPreview->alias : $objPreview->id) . $GLOBALS['TL_CONFIG']['urlSuffix'];
+					if ($GLOBALS['TL_CONFIG']['disableAlias'])
+					{
+						$this->Template->frontendFile .= '?id=' . $objPreview->id;
+					}
+					else
+					{
+						$this->Template->frontendFile .= ($GLOBALS['TL_CONFIG']['rewriteURL'] ? '' : '/') . (($objPreview->alias != '') ? $objPreview->alias : $objPreview->id) . $GLOBALS['TL_CONFIG']['urlSuffix'];
+					}
 				}
 			}
-		}
-
-		// Preview article
-		if ($this->Input->get('do') == 'article' && strlen(CURRENT_ID))
-		{
-			$objPreview = $this->Database->prepare("SELECT p.id AS pid, p.alias AS palias, a.id AS aid, a.alias AS aalias, a.inColumn AS acolumn FROM tl_article a, tl_page p WHERE a.id=? AND a.pid=p.id")
-										 ->limit(1)
-										 ->execute(CURRENT_ID);
-
-			if ($objPreview->numRows)
+			// Articles
+			elseif ($this->Input->get('do') == 'article')
 			{
-				$strColumn = '';
+				$objPreview = $this->Database->prepare("SELECT p.id AS pid, p.alias AS palias, a.id AS aid, a.alias AS aalias, a.inColumn AS acolumn FROM tl_article a, tl_page p WHERE a.id=? AND a.pid=p.id")
+											 ->limit(1)
+											 ->execute(CURRENT_ID);
 
-				if ($objPreview->acolumn != 'main')
+				if ($objPreview->numRows)
 				{
-					$strColumn = $objPreview->acolumn . ':';
-				}
+					$strColumn = '';
 
-				if ($GLOBALS['TL_CONFIG']['disableAlias'])
-				{
-					$this->Template->frontendFile = 'index.php?id=' . $objPreview->pid . '&articles=' . $strColumn . $objPreview->aid;
-				}
-				else
-				{
-					$this->Template->frontendFile = 'index.php/' . (strlen($objPreview->palias) ? $objPreview->palias : $objPreview->pid) . '/articles/' . $strColumn . (strlen($objPreview->aalias) ? $objPreview->aalias : $objPreview->aid) . $GLOBALS['TL_CONFIG']['urlSuffix'];
+					if ($objPreview->acolumn != 'main')
+					{
+						$strColumn = $objPreview->acolumn . ':';
+					}
+
+					if ($GLOBALS['TL_CONFIG']['disableAlias'])
+					{
+						$this->Template->frontendFile .= '?id=' . $objPreview->pid . '&articles=' . $strColumn . $objPreview->aid;
+					}
+					else
+					{
+						$this->Template->frontendFile .= ($GLOBALS['TL_CONFIG']['rewriteURL'] ? '' : '/') . (($objPreview->palias != '') ? $objPreview->palias : $objPreview->pid) . '/articles/' . $strColumn . (($objPreview->aalias != '') ? $objPreview->aalias : $objPreview->aid) . $GLOBALS['TL_CONFIG']['urlSuffix'];
+					}
 				}
+		
+			$this->Template->frontendFile = str_replace(array('?', '&', '='), array('%3F', '%26', '%3D'), $this->Template->frontendFile);
 			}
 		}