2016-03-28 10:29:05 -04:00
|
|
|
<?php
|
|
|
|
/**
|
2022-01-02 02:27:47 -05:00
|
|
|
* @copyright Copyright (C) 2010-2022, the Friendica project
|
2020-02-09 10:18:46 -05:00
|
|
|
*
|
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2017-01-09 07:06:08 -05:00
|
|
|
*
|
2020-01-19 01:05:23 -05:00
|
|
|
* This file contains functions for page construction
|
2017-01-09 07:06:08 -05:00
|
|
|
*
|
2016-03-28 10:29:05 -04:00
|
|
|
*/
|
|
|
|
|
2017-04-30 00:07:00 -04:00
|
|
|
use Friendica\App;
|
2019-12-30 14:02:09 -05:00
|
|
|
use Friendica\DI;
|
2016-03-28 10:29:05 -04:00
|
|
|
|
|
|
|
/**
|
2020-01-19 01:05:23 -05:00
|
|
|
* Load page template in dependence of the template mode
|
2017-01-09 07:06:08 -05:00
|
|
|
*
|
2016-03-28 10:29:05 -04:00
|
|
|
* @todo Check if this is really needed.
|
|
|
|
*/
|
2018-04-28 18:33:52 -04:00
|
|
|
function load_page(App $a)
|
|
|
|
{
|
|
|
|
if (isset($_GET['mode']) && ($_GET['mode'] == 'minimal')) {
|
|
|
|
require 'view/theme/frio/minimal.php';
|
|
|
|
} elseif ((isset($_GET['mode']) && ($_GET['mode'] == 'none'))) {
|
|
|
|
require 'view/theme/frio/none.php';
|
2016-03-28 10:29:05 -04:00
|
|
|
} else {
|
2018-04-28 18:37:04 -04:00
|
|
|
$template = 'view/theme/' . $a->getCurrentTheme() . '/'
|
2019-12-30 14:02:09 -05:00
|
|
|
. ((DI::page()['template'] ?? '') ?: 'default' ) . '.php';
|
2018-04-28 18:33:52 -04:00
|
|
|
if (file_exists($template)) {
|
|
|
|
require_once $template;
|
|
|
|
} else {
|
2018-04-28 18:37:04 -04:00
|
|
|
require_once str_replace('theme/' . $a->getCurrentTheme() . '/', '', $template);
|
2018-04-28 18:33:52 -04:00
|
|
|
}
|
2016-03-28 10:29:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-01-19 01:05:23 -05:00
|
|
|
* Check if page is a modal page
|
2017-01-09 07:06:08 -05:00
|
|
|
*
|
2016-03-28 10:29:05 -04:00
|
|
|
* This function checks if $_REQUEST['pagename'] is
|
|
|
|
* a defined in a $modalpages
|
2017-01-09 07:06:08 -05:00
|
|
|
*
|
2016-03-28 10:29:05 -04:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
function is_modal() {
|
|
|
|
$is_modal = false;
|
|
|
|
$modalpages = get_modalpage_list();
|
|
|
|
|
|
|
|
foreach ($modalpages as $r => $value) {
|
|
|
|
if(strpos($_REQUEST['pagename'],$value) !== false) {
|
|
|
|
$is_modal = true;
|
|
|
|
}
|
|
|
|
}
|
2017-01-09 07:06:08 -05:00
|
|
|
|
2016-03-28 10:29:05 -04:00
|
|
|
return $is_modal;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2022-08-09 13:21:42 -04:00
|
|
|
* Array with modal pages
|
2017-01-09 07:06:08 -05:00
|
|
|
*
|
2016-03-28 10:29:05 -04:00
|
|
|
* The array contains the page names of the pages
|
|
|
|
* which should displayed as modals
|
2017-01-09 07:06:08 -05:00
|
|
|
*
|
2022-08-09 13:21:42 -04:00
|
|
|
* @return array Page names as path
|
2016-03-28 10:29:05 -04:00
|
|
|
*/
|
|
|
|
function get_modalpage_list() {
|
2022-08-09 13:21:42 -04:00
|
|
|
//Array of pages which getting bootstrap modal dialogs
|
|
|
|
$modalpages = [
|
|
|
|
'message/new',
|
|
|
|
'settings/oauth/add',
|
|
|
|
'events/new',
|
|
|
|
// 'fbrowser/image/'
|
2018-01-15 08:05:12 -05:00
|
|
|
];
|
2016-03-28 10:29:05 -04:00
|
|
|
|
|
|
|
return $modalpages;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-01-19 01:05:23 -05:00
|
|
|
* Array with standard pages
|
2017-01-09 07:06:08 -05:00
|
|
|
*
|
2016-03-28 10:29:05 -04:00
|
|
|
* The array contains the page names of the pages
|
|
|
|
* which should displayed as standard-page
|
2017-01-09 07:06:08 -05:00
|
|
|
*
|
2016-03-28 10:29:05 -04:00
|
|
|
* @return array Pagenames as path
|
|
|
|
*/
|
|
|
|
function get_standard_page_list() {
|
|
|
|
//Arry of pages wich getting the standard page template
|
2018-01-15 08:05:12 -05:00
|
|
|
$standardpages = [//'profile',
|
2016-03-28 10:29:05 -04:00
|
|
|
// 'fbrowser/image/'
|
2018-01-15 08:05:12 -05:00
|
|
|
];
|
2016-03-28 10:29:05 -04:00
|
|
|
|
|
|
|
return $standardpages;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-01-19 01:05:23 -05:00
|
|
|
* Check if page is standard page
|
2017-01-09 07:06:08 -05:00
|
|
|
*
|
2016-03-28 10:29:05 -04:00
|
|
|
* This function checks if $_REQUEST['pagename'] is
|
|
|
|
* a defined $standardpages
|
2017-01-09 07:06:08 -05:00
|
|
|
*
|
2016-03-28 10:29:05 -04:00
|
|
|
* @param string $pagetitle Title of the actual page
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
function is_standard_page($pagetitle) {
|
|
|
|
$is_standard_page = false;
|
|
|
|
$standardpages = get_standard_page_list();
|
|
|
|
|
|
|
|
foreach ($standardpages as $r => $value) {
|
|
|
|
if(strpos($pagetitle,$value) !== false) {
|
|
|
|
$is_standard_page = true;
|
|
|
|
}
|
|
|
|
}
|
2017-01-09 07:06:08 -05:00
|
|
|
|
2016-03-28 10:29:05 -04:00
|
|
|
return $is_standard_page;
|
|
|
|
}
|
|
|
|
/**
|
2020-01-19 01:05:23 -05:00
|
|
|
* Get the typ of the page
|
2017-01-09 07:06:08 -05:00
|
|
|
*
|
2016-03-28 10:29:05 -04:00
|
|
|
* @param type $pagetitle
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
function get_page_type($pagetitle) {
|
|
|
|
$page_type = "";
|
|
|
|
|
|
|
|
if(is_modal())
|
|
|
|
$page_type = "modal";
|
|
|
|
|
|
|
|
if(is_standard_page($pagetitle))
|
|
|
|
$page_type = "standard_page";
|
|
|
|
|
|
|
|
if($page_type)
|
|
|
|
return $page_type;
|
|
|
|
|
|
|
|
}
|