1<?php
2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project
3//
4// All Rights Reserved. See copyright.txt for details and a complete list of authors.
5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
6// $Id$
7
8if (basename($_SERVER['SCRIPT_NAME']) === basename(__FILE__)) {
9	die('This script may only be included.');
10}
11
12// Wiki pagename regexp
13
14if ($prefs['wiki_page_regex'] == 'strict') {
15	$page_regex = '([A-Za-z0-9_])([\.: A-Za-z0-9_\-])*([A-Za-z0-9_])';
16} elseif ($prefs['wiki_page_regex'] == 'full') {
17	$page_regex = '([A-Za-z0-9_]|[\x80-\xFF])([\.: A-Za-z0-9_\-]|[\x80-\xFF])*([A-Za-z0-9_]|[\x80-\xFF])';
18} else {
19	$page_regex = '([^\n|\(\)])((?!(\)\)|\||\n)).)*?';
20}
21
22// find out the page name if url=tiki-index_x.php (can be needed in module)
23if (strstr($_SERVER['SCRIPT_NAME'], 'tiki-index.php')
24		|| strstr($_SERVER['SCRIPT_NAME'], 'tiki-index_p.php')
25		|| strstr($_SERVER['SCRIPT_NAME'], 'tiki-index_raw.php')
26) {
27	$check = false;
28	if (! isset($_REQUEST['page']) && ! isset($_REQUEST['page_ref_id']) && ! isset($_REQUEST['page_id'])) {
29		$_REQUEST['page'] = $userlib->get_user_default_homepage($user);
30		$check = true;
31	}
32
33	if ($prefs['feature_multilingual'] == 'y'
34			&& (isset($_REQUEST['page']) || isset($_REQUEST['page_ref_id']) || isset($_REQUEST['page_id']))
35	) { // perhaps we have to go to an another page
36		$multilinguallib = TikiLib::lib('multilingual');
37		if ($multilinguallib->useBestLanguage()) {
38			if (empty($_REQUEST['page_id'])) {
39				if (! empty($_REQUEST['page'])) {
40					$info = $tikilib->get_page_info($_REQUEST['page']);
41					$_REQUEST['page_id'] = $info['page_id'];
42				} elseif (! empty($_REQUEST['page_ref_id'])) {
43					$structlib = TikiLib::lib('struct');
44					$info = $structlib->s_get_page_info($_REQUEST['page_ref_id']);
45					$_REQUEST['page_id'] = $info['page_id'];
46				}
47			}
48			if (! empty($_REQUEST['page_id'])) {
49				if ($multilinguallib->useBestLanguage()) {
50					$_REQUEST['page_id'] = $multilinguallib->selectLangObj('wiki page', $_REQUEST['page_id']);
51				}
52				if (! empty($_REQUEST['page_id'])) {
53					$check = false;
54				}
55			}
56		}
57	}
58
59	// If the HomePage does not exist, create it
60	if ($check && ! empty($_REQUEST['page']) && ! $tikilib->page_exists($_REQUEST['page'])) {
61		$homePageLang = $prefs['language'];
62		$profilesLink = 'tiki-admin.php?profile=&categories%5B%5D=21.x&categories%5B%5D=Featured+profiles' .
63										'&repository=http%3a%2f%2fprofiles.tiki.org%2fprofiles&page=profiles&preloadlist=y&list=List#step2';
64
65		// Default HomePage content
66		$homePageContent = '';
67		$is_html = false;
68		if (($prefs['feature_wysiwyg'] === 'y') && $prefs['wysiwyg_htmltowiki'] !== 'y') {
69			$is_html = true;
70
71			// FIXME: Still relies on wiki syntax not parsed, in particular if wysiwyg_wiki_parsed is disabled
72			$homePageContent .= '<h1>' . tr('Congratulations') . "</h1>\n";
73			$homePageContent .= tr('This is the default homepage for your Tiki. If you are seeing this page, your installation was successful.') . "\n\n<br>";
74			$homePageContent .= tr('You can change this page after logging in. Please review the [http://doc.tiki.org/Wiki-syntax|wiki syntax] for editing details.') . "\n\n\n<br>";
75			$homePageContent .= '<h2>' . tr('Get started') . ".</h2>\n";
76			$homePageContent .= tr('To begin configuring your site:') . "\n";
77			$homePageContent .= "<ul>\n";
78			$homePageContent .= "<li>" . tr('1) Log in with your newly created password.') . "</li>\n";
79			$homePageContent .= "<li>" . tr('2) Manually [tiki-admin.php?page=features|Enable specific Tiki features] that you didn\'t enable with the Admin wizard.') . "</li>\n";
80			$homePageContent .= "<li>" . tr('3) Run [tiki-admin.php?page=profiles|Tiki Profiles] to quickly get up and running.') . "</li>\n";
81			$homePageContent .= "</ul>\n\n<br>";
82			$homePageContent .= '<h2>' . tr('Need help?') . "</h2>\n";
83			$homePageContent .= tr('For more information:') . "\n<br>";
84			$homePageContent .= '*' . tr('[https://tiki.org/Introduction|Learn more about Tiki].') . "\n<br>";
85			$homePageContent .= '*' . tr('[https://tiki.org/|Get help], including the [http://doc.tiki.org|official documentation] and [http://tiki.org/forums|support forums].') . "\n<br>";
86			$homePageContent .= '*' . tr('[https://tiki.org/Join|Join the Tiki community].') . "\n<br>";
87		} else {
88			$homePageContent .= '!' . tr('Congratulations') . "\n";
89			$homePageContent .= tr('This is the default homepage for your Tiki. If you are seeing this page, your installation was successful.') . "\n\n";
90			$homePageContent .= tr('You can change this page after logging in. Please review the [http://doc.tiki.org/Wiki-syntax|wiki syntax] for editing details.') . "\n\n\n";
91			$homePageContent .= '!!' . tr('Get started.') . "\n";
92			$homePageContent .= tr('To begin configuring your site:') . "\n";
93			$homePageContent .= "{FANCYLIST()}\n";
94			$homePageContent .= tr('1) Log in with your newly created password.') . "\n";
95			$homePageContent .= tr('2) Manually [tiki-admin.php?page=features|Enable specific Tiki features] that you didn\'t enable with the Admin wizard.') . "\n";
96			$homePageContent .= tr('3) Run [tiki-admin.php?page=profiles|Tiki Profiles] to quickly get up and running.') . "\n";
97			$homePageContent .= "{FANCYLIST}\n\n";
98			$homePageContent .= '!!' . tr('Need help?') . "\n";
99			$homePageContent .= tr('For more information:') . "\n";
100			$homePageContent .= '*' . tr('[https://tiki.org/Introduction|Learn more about Tiki].') . "\n";
101			$homePageContent .= '*' . tr('[https://tiki.org/|Get help], including the [http://doc.tiki.org|official documentation] and [http://tiki.org/forums|support forums].') . "\n";
102			$homePageContent .= '*' . tr('[https://tiki.org/Join|Join the Tiki community].') . "\n";
103		}
104
105		$tikilib->create_page(
106			$_REQUEST['page'],
107			0,
108			$homePageContent,
109			$tikilib->now,
110			'Tiki initialization',
111			'admin',
112			'0.0.0.0',
113			'',
114			$homePageLang,
115			$is_html,	// is_html
116			null,
117			$is_html ? 'y' : 'n',	// wysiwyg,
118			''
119		);
120
121		unset($homePageContent, $homePageLang);
122	}
123}
124