-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.php
46 lines (42 loc) · 1.03 KB
/
init.php
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
<?php defined('SYSPATH') or die('No direct script access.');
// Load language conf
$langs = Page::instance()->system_langs();
// Pages route
Route::set('page', '(<lang>/)<page_path>', array(
'lang' => &$langs,
'page_path' => &$static_pages
))
->defaults(array(
'controller' => 'page',
'action' => 'show',
'lang' => NULL,
));
// Load top-level pages
$_pages = Page::instance()->pages_structure(Kohana::$config->load('pages')->multilanguage_in_structure);
$multilang = (strlen($langs) > 4);
$pages = array();
foreach($_pages as $id => $page)
{
if($multilang)
{
foreach($page['childrens'] as $id => $subpage)
{
$pages[$subpage['alias']] = $subpage['alias'];
}
}
else
{
$pages[] = $page['alias'];
}
}
$static_pages = ($pages) ? '(?!error)('.implode('|', $pages).')(.*)' : '(?!error)(.*)';
// Pages route
Route::set('page', '(<lang>)/<page_path>', array(
'lang' => $langs,
'page_path' => $static_pages
))
->defaults(array(
'controller' => 'page',
'action' => 'show',
'lang' => NULL,
));