]> git.mxchange.org Git - friendica.git/blob - view/theme/frio/php/frio_boot.php
Merge pull request #8365 from nupplaphil/bug/mail_fix_text
[friendica.git] / view / theme / frio / php / frio_boot.php
1 <?php
2 /**
3  * @copyright Copyright (C) 2020, Friendica
4  *
5  * @license GNU AGPL version 3 or any later version
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Affero General Public License for more details.
16  *
17  * You should have received a copy of the GNU Affero General Public License
18  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
19  *
20  * This file contains functions for page construction
21  *
22  */
23
24 use Friendica\App;
25 use Friendica\DI;
26
27 /**
28  * Load page template in dependence of the template mode
29  *
30  * @todo Check if this is really needed.
31  */
32 function load_page(App $a)
33 {
34         if (isset($_GET['mode']) && ($_GET['mode'] == 'minimal')) {
35                 require 'view/theme/frio/minimal.php';
36         } elseif ((isset($_GET['mode']) && ($_GET['mode'] == 'none'))) {
37                 require 'view/theme/frio/none.php';
38         } else {
39                 $template = 'view/theme/' . $a->getCurrentTheme() . '/'
40                         . ((DI::page()['template'] ?? '') ?: 'default' ) . '.php';
41                 if (file_exists($template)) {
42                         require_once $template;
43                 } else {
44                         require_once str_replace('theme/' . $a->getCurrentTheme() . '/', '', $template);
45                 }
46         }
47 }
48
49 /**
50  * Check if page is a modal page
51  *
52  * This function checks if $_REQUEST['pagename'] is
53  * a defined in a $modalpages
54  *
55  * @return bool
56  */
57 function is_modal() {
58         $is_modal = false;
59         $modalpages = get_modalpage_list();
60
61         foreach ($modalpages as $r => $value) {
62                 if(strpos($_REQUEST['pagename'],$value) !== false) {
63                         $is_modal = true;
64                 }
65         }
66
67         return $is_modal;
68 }
69
70 /**
71  * Array with modalpages
72  *
73  * The array contains the page names of the pages
74  * which should displayed as modals
75  *
76  * @return array Pagenames as path
77  */
78 function get_modalpage_list() {
79         //Arry of pages wich getting bootstrap modal dialogs
80         $modalpages = ['poke/',
81                         'message/new',
82                         'settings/oauth/add',
83                         'events/new',
84 //                      'fbrowser/image/'
85         ];
86
87         return $modalpages;
88 }
89
90 /**
91  * Array with standard pages
92  *
93  * The array contains the page names of the pages
94  * which should displayed as standard-page
95  *
96  * @return array Pagenames as path
97  */
98 function get_standard_page_list() {
99         //Arry of pages wich getting the standard page template
100         $standardpages = [//'profile',
101 //                      'fbrowser/image/'
102         ];
103
104         return $standardpages;
105 }
106
107 /**
108  * Check if page is standard page
109  *
110  * This function checks if $_REQUEST['pagename'] is
111  * a defined $standardpages
112  *
113  * @param string $pagetitle Title of the actual page
114  * @return bool
115  */
116 function is_standard_page($pagetitle) {
117         $is_standard_page = false;
118         $standardpages = get_standard_page_list();
119
120         foreach ($standardpages as $r => $value) {
121                 if(strpos($pagetitle,$value) !== false) {
122                         $is_standard_page = true;
123                 }
124         }
125
126         return $is_standard_page;
127 }
128 /**
129  * Get the typ of the page
130  *
131  * @param type $pagetitle
132  * @return string
133  */
134 function get_page_type($pagetitle) {
135         $page_type = "";
136
137         if(is_modal())
138                 $page_type = "modal";
139
140         if(is_standard_page($pagetitle))
141                 $page_type = "standard_page";
142
143         if($page_type)
144                 return $page_type;
145
146 }