|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of the bootstrap-bundle package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) 2018 WEBEWEB |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace WBW\Bundle\BootstrapBundle\Controller; |
|
13
|
|
|
|
|
14
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
15
|
|
|
use Symfony\Component\HttpFoundation\Response; |
|
16
|
|
|
use WBW\Bundle\CoreBundle\Model\WikiView; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Wiki controller. |
|
20
|
|
|
* |
|
21
|
|
|
* @author webeweb <https://github.com/webeweb/> |
|
22
|
|
|
* @package WBW\Bundle\BootstrapBundle\Controller |
|
23
|
|
|
*/ |
|
24
|
|
|
class WikiController extends AbstractWikiController { |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Get the wiki views. |
|
28
|
|
|
* |
|
29
|
|
|
* @return WikiView[] Returns the wiki views. |
|
30
|
|
|
*/ |
|
31
|
|
|
public static function getWikiViews() { |
|
32
|
|
|
|
|
33
|
|
|
// Initialize the table of contents. |
|
34
|
|
|
$tableContents = []; |
|
35
|
|
|
|
|
36
|
|
|
// Twig extensions > CSS |
|
37
|
|
|
$tableContents[] = new WikiView("Twig-extension", "CSS", "button", "Button"); |
|
38
|
|
|
$tableContents[] = new WikiView("twig-extension", "CSS", "code", "Code"); |
|
39
|
|
|
$tableContents[] = new WikiView("Twig-extension", "CSS", "grid", "Grid"); |
|
40
|
|
|
$tableContents[] = new WikiView("Twig-extension", "CSS", "image", "Image"); |
|
41
|
|
|
$tableContents[] = new WikiView("Twig-extension", "CSS", "typography", "Typography"); |
|
42
|
|
|
|
|
43
|
|
|
// Twig extensions > Component |
|
44
|
|
|
$tableContents[] = new WikiView("Twig-extension", "Component", "alert", "Alert"); |
|
45
|
|
|
$tableContents[] = new WikiView("Twig-extension", "Component", "badge", "Badge"); |
|
46
|
|
|
$tableContents[] = new WikiView("Twig-extension", "Component", "glyphicon", "Glyphicon"); |
|
47
|
|
|
$tableContents[] = new WikiView("Twig-extension", "Component", "label", "Label"); |
|
48
|
|
|
$tableContents[] = new WikiView("Twig-extension", "Component", "progress-bar", "Progress bar"); |
|
49
|
|
|
|
|
50
|
|
|
// Twig extensions > Utility |
|
51
|
|
|
$tableContents[] = new WikiView("Twig-extension", "Utility", "form-button", "Form button"); |
|
52
|
|
|
$tableContents[] = new WikiView("Twig-extension", "Utility", "role-label", "Role label"); |
|
53
|
|
|
$tableContents[] = new WikiView("Twig-extension", "Utility", "table-button", "Table button"); |
|
54
|
|
|
|
|
55
|
|
|
// Twig extensions > Plugin |
|
56
|
|
|
$tableContents[] = new WikiView("Twig-extension", "Plugin", "font-awesome", "Font Awesome"); |
|
57
|
|
|
$tableContents[] = new WikiView("Twig-extension", "Plugin", "jquery-inputmask", "jQuery InputMask"); |
|
58
|
|
|
$tableContents[] = new WikiView("Twig-extension", "Plugin", "material-design-iconic-font", "Material Design Iconic Font"); |
|
59
|
|
|
$tableContents[] = new WikiView("Twig-extension", "Plugin", "meteocons", "Meteocons"); |
|
60
|
|
|
|
|
61
|
|
|
// Handle each wiki view. |
|
62
|
|
|
foreach ($tableContents as $current) { |
|
63
|
|
|
$current->setBundle("Bootstrap"); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
// Return the table of contents. |
|
67
|
|
|
return $tableContents; |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Displays a wiki page. |
|
72
|
|
|
* |
|
73
|
|
|
* @param Request $request The request. |
|
74
|
|
|
* @param string $category The category. |
|
75
|
|
|
* @param string $package The parent. |
|
76
|
|
|
* @param string $page The page. |
|
77
|
|
|
* @return Response Returns the response. |
|
78
|
|
|
*/ |
|
79
|
|
|
public function indexAction(Request $request, $category, $package, $page) { |
|
80
|
|
|
|
|
81
|
|
|
// Initialize. |
|
82
|
|
|
$wikiViews = self::getWikiViews(); |
|
83
|
|
|
$wikiView = null; |
|
84
|
|
|
|
|
85
|
|
|
// Find the wiki page. |
|
86
|
|
|
foreach ($wikiViews as $current) { |
|
87
|
|
|
if ($category === $current->getCategory() && $package === $current->getPackage() && $page === $current->getPage()) { |
|
88
|
|
|
$wikiView = $current; |
|
89
|
|
|
break; |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
// Check if the wiki page exists. |
|
94
|
|
|
if (null === $wikiView) { |
|
95
|
|
|
|
|
96
|
|
|
// Set the default wiki page. |
|
97
|
|
|
$wikiView = $wikiViews[0]; |
|
98
|
|
|
|
|
99
|
|
|
// Notify the user. |
|
100
|
|
|
$this->notifyDanger("The requested page was not found"); |
|
101
|
|
|
$this->notifyInfo("You have been redirected to homepage"); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
// Set the template. |
|
105
|
|
|
$template = [ |
|
106
|
|
|
"@", |
|
107
|
|
|
$wikiView->getBundle(), |
|
108
|
|
|
"/Wiki/", |
|
109
|
|
|
strtolower($wikiView->getCategory()), |
|
110
|
|
|
"/", |
|
111
|
|
|
strtolower($wikiView->getPackage()), |
|
112
|
|
|
"/", |
|
113
|
|
|
$wikiView->getPage(), |
|
114
|
|
|
".html.twig", |
|
115
|
|
|
]; |
|
116
|
|
|
|
|
117
|
|
|
// Returns the response. |
|
118
|
|
|
return $this->render(implode("", $template), [ |
|
119
|
|
|
"wikiViews" => $wikiViews, |
|
120
|
|
|
"wikiView" => $wikiView, |
|
121
|
|
|
"syntaxHighlighterConfig" => $this->getSyntaxHighlighterConfig(), |
|
122
|
|
|
"syntaxHighlighterDefaults" => $this->getSyntaxHighlighterDefaults(), |
|
123
|
|
|
"user" => $this->getSampleUser(), |
|
124
|
|
|
"userRoleColors" => $this->getSampleUserRoleColors(), |
|
125
|
|
|
"userRoleTranslations" => $this->getSampleUserRoleTranslations(), |
|
126
|
|
|
]); |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
} |
|
130
|
|
|
|