[frio] Fix formatting in PHP files

This commit is contained in:
Hypolite Petovan 2018-04-24 20:05:20 -04:00
parent d49df631fb
commit b65c8c55a4
4 changed files with 46 additions and 49 deletions

View file

@ -8,7 +8,8 @@ use Friendica\Core\System;
require_once 'view/theme/frio/php/Image.php'; require_once 'view/theme/frio/php/Image.php';
function theme_post(App $a) { function theme_post(App $a)
{
if (!local_user()) { if (!local_user()) {
return; return;
} }
@ -26,7 +27,8 @@ function theme_post(App $a) {
} }
} }
function theme_admin_post(App $a) { function theme_admin_post(App $a)
{
if (!local_user()) { if (!local_user()) {
return; return;
} }
@ -46,7 +48,8 @@ function theme_admin_post(App $a) {
} }
} }
function theme_content(App $a) { function theme_content(App $a)
{
if (!local_user()) { if (!local_user()) {
return; return;
} }
@ -64,7 +67,8 @@ function theme_content(App $a) {
return frio_form($arr); return frio_form($arr);
} }
function theme_admin(App $a) { function theme_admin(App $a)
{
if (!local_user()) { if (!local_user()) {
return; return;
} }
@ -84,7 +88,8 @@ function theme_admin(App $a) {
return frio_form($arr); return frio_form($arr);
} }
function frio_form($arr) { function frio_form($arr)
{
require_once("view/theme/frio/php/schema.php"); require_once("view/theme/frio/php/schema.php");
$scheme_info = get_schema_info($arr["schema"]); $scheme_info = get_schema_info($arr["schema"]);
@ -106,7 +111,7 @@ function frio_form($arr) {
} }
} }
$background_image_help = "<strong>" . L10n::t("Note"). ": </strong>".L10n::t("Check image permissions if all users are allowed to visit the image"); $background_image_help = "<strong>" . L10n::t("Note") . ": </strong>" . L10n::t("Check image permissions if all users are allowed to visit the image");
$t = get_markup_template('theme_settings.tpl'); $t = get_markup_template('theme_settings.tpl');
$ctx = [ $ctx = [
@ -123,13 +128,13 @@ function frio_form($arr) {
'$bg_image_options' => Image::get_options($arr), '$bg_image_options' => Image::get_options($arr),
]; ];
if (array_key_exists("login_bg_image", $arr) && !array_key_exists("login_bg_image", $disable)) { if (array_key_exists("login_bg_image", $arr) && !array_key_exists("login_bg_image", $disable)) {
$ctx['$login_bg_image'] = ['frio_login_bg_image', L10n::t('Login page background image'), $arr['login_bg_image'], $background_image_help, false]; $ctx['$login_bg_image'] = ['frio_login_bg_image', L10n::t('Login page background image'), $arr['login_bg_image'], $background_image_help, false];
}
if (array_key_exists("login_bg_color", $arr) && !array_key_exists("login_bg_color", $disable)) {
$ctx['$login_bg_color'] = ['frio_login_bg_color', L10n::t('Login page background color'), $arr['login_bg_color'], L10n::t('Leave background image and color empty for theme defaults'), false];
} }
if (array_key_exists("login_bg_color", $arr) && !array_key_exists("login_bg_color", $disable)) {
$ctx['$login_bg_color'] = ['frio_login_bg_color', L10n::t('Login page background color'), $arr['login_bg_color'], L10n::t('Leave background image and color empty for theme defaults'), false];
}
$o = replace_macros($t, $ctx); $o = replace_macros($t, $ctx);

View file

@ -21,14 +21,10 @@ class Image
public static function get_options($arr) public static function get_options($arr)
{ {
$bg_image_options = [ $bg_image_options = [
'repeat' => [ 'repeat' => ['frio_bg_image_option', L10n::t("Repeat the image"), "repeat", L10n::t("Will repeat your image to fill the background."), ($arr["bg_image_option"] == "repeat")],
'frio_bg_image_option', L10n::t("Repeat the image"), "repeat", L10n::t("Will repeat your image to fill the background."), ($arr["bg_image_option"] == "repeat")], 'stretch' => ['frio_bg_image_option', L10n::t("Stretch"), "stretch", L10n::t("Will stretch to width/height of the image."), ($arr["bg_image_option"] == "stretch")],
'stretch' => [ 'cover' => ['frio_bg_image_option', L10n::t("Resize fill and-clip"), "cover", L10n::t("Resize to fill and retain aspect ratio."), ($arr["bg_image_option"] == "cover")],
'frio_bg_image_option', L10n::t("Stretch"), "stretch", L10n::t("Will stretch to width/height of the image."), ($arr["bg_image_option"] == "stretch")], 'contain' => ['frio_bg_image_option', L10n::t("Resize best fit"), "contain", L10n::t("Resize to best fit and retain aspect ratio."), ($arr["bg_image_option"] == "contain")],
'cover' => [
'frio_bg_image_option', L10n::t("Resize fill and-clip"), "cover", L10n::t("Resize to fill and retain aspect ratio."), ($arr["bg_image_option"] == "cover")],
'contain' => [
'frio_bg_image_option', L10n::t("Resize best fit"), "contain", L10n::t("Resize to best fit and retain aspect ratio."), ($arr["bg_image_option"] == "contain")],
]; ];
return $bg_image_options; return $bg_image_options;

View file

@ -1,6 +1,5 @@
<?php <?php
/** /**
* @brief: Get info header of the shema * @brief: Get info header of the shema
* *
@ -18,16 +17,15 @@
* 'version' => Schema version * 'version' => Schema version
* 'overwrites' => Variables which overwriting custom settings * 'overwrites' => Variables which overwriting custom settings
*/ */
use Friendica\Core\PConfig; use Friendica\Core\PConfig;
function get_schema_info($schema){ function get_schema_info($schema)
{
$theme = current_theme(); $theme = current_theme();
$themepath = "view/theme/" . $theme . "/"; $themepath = "view/theme/" . $theme . "/";
$schema = PConfig::get(local_user(),'frio', 'schema'); $schema = PConfig::get(local_user(), 'frio', 'schema');
$info=[ $info = [
'name' => $schema, 'name' => $schema,
'description' => "", 'description' => "",
'author' => [], 'author' => [],
@ -41,34 +39,33 @@ function get_schema_info($schema){
$r = preg_match("|/\*.*\*/|msU", $f, $m); $r = preg_match("|/\*.*\*/|msU", $f, $m);
if ($r){ if ($r) {
$ll = explode("\n", $m[0]); $ll = explode("\n", $m[0]);
foreach( $ll as $l ) { foreach ($ll as $l) {
$l = trim($l,"\t\n\r */"); $l = trim($l, "\t\n\r */");
if ($l!=""){ if ($l != "") {
list($k,$v) = array_map("trim", explode(":",$l,2)); list($k, $v) = array_map("trim", explode(":", $l, 2));
$k= strtolower($k); $k = strtolower($k);
if ($k=="author"){ if ($k == "author") {
$r=preg_match("|([^<]+)<([^>]+)>|", $v, $m); $r = preg_match("|([^<]+)<([^>]+)>|", $v, $m);
if ($r) { if ($r) {
$info['author'][] = ['name'=>$m[1], 'link'=>$m[2]]; $info['author'][] = ['name' => $m[1], 'link' => $m[2]];
} else { } else {
$info['author'][] = ['name'=>$v]; $info['author'][] = ['name' => $v];
} }
} elseif ($k == "overwrites") { } elseif ($k == "overwrites") {
$theme_settings = explode(',',str_replace(' ','', $v)); $theme_settings = explode(',', str_replace(' ', '', $v));
foreach ($theme_settings as $key => $value) { foreach ($theme_settings as $key => $value) {
$info["overwrites"][$value] = true; $info["overwrites"][$value] = true;
} }
} else { } else {
if (array_key_exists($k,$info)){ if (array_key_exists($k, $info)) {
$info[$k]=$v; $info[$k] = $v;
} }
} }
} }
} }
} }
return $info; return $info;
} }

View file

@ -84,7 +84,7 @@ if (($schema) && ($schema != '---')) {
// If we haven't got a schema, load the default. We shouldn't touch this - we // If we haven't got a schema, load the default. We shouldn't touch this - we
// should leave it for admins to define for themselves. // should leave it for admins to define for themselves.
// default.php and default.css MUST be symlinks to existing schema files. // default.php and default.css MUST be symlinks to existing schema files.
if (! $schema) { if (!$schema) {
if (file_exists('view/theme/frio/schema/default.php')) { if (file_exists('view/theme/frio/schema/default.php')) {
$schemefile = 'view/theme/frio/schema/default.php'; $schemefile = 'view/theme/frio/schema/default.php';
require_once $schemefile; require_once $schemefile;
@ -102,15 +102,14 @@ $link_color = (empty($link_color) ? "#6fdbe8" : $link_color);
$bgcolor = (empty($bgcolor) ? "#ededed" : $bgcolor); $bgcolor = (empty($bgcolor) ? "#ededed" : $bgcolor);
// The background image can not be empty. So we use a dummy jpg if no image was set. // The background image can not be empty. So we use a dummy jpg if no image was set.
$background_image = (empty($background_image) ? 'img/none.jpg' : $background_image); $background_image = (empty($background_image) ? 'img/none.jpg' : $background_image);
$modified = (empty($modified) ? time() :$modified); $modified = (empty($modified) ? time() : $modified);
// set a default login bg image if no custom image and no custom bg color are set. // set a default login bg image if no custom image and no custom bg color are set.
if (empty($login_bg_image) && empty($login_bg_color)) { if (empty($login_bg_image) && empty($login_bg_color)) {
$login_bg_image = (empty($login_bg_image) ? 'img/login_bg.jpg' : $login_bg_image); $login_bg_image = 'img/login_bg.jpg';
} }
$login_bg_color = (empty($login_bg_color) ? "#ededed" : $login_bg_color); $login_bg_color = (empty($login_bg_color) ? "#ededed" : $login_bg_color);
$contentbg_transp = ((isset($contentbg_transp) && $contentbg_transp != "") ? $contentbg_transp : 100); $contentbg_transp = ((isset($contentbg_transp) && $contentbg_transp != "") ? $contentbg_transp : 100);
@ -158,7 +157,7 @@ switch ($bg_image_option) {
$background_size_img = "100%"; $background_size_img = "100%";
break; break;
case "cover": case "cover":
$background_size_img ="cover"; $background_size_img = "cover";
break; break;
case "repeat": case "repeat":
$background_size_img = "auto"; $background_size_img = "auto";
@ -175,7 +174,7 @@ switch ($bg_image_option) {
// Convert transparency level from percentage to opacity value. // Convert transparency level from percentage to opacity value.
$contentbg_transp = $contentbg_transp / 100; $contentbg_transp = $contentbg_transp / 100;
$options = [ $options = [
'$nav_bg' => $nav_bg, '$nav_bg' => $nav_bg,
'$nav_icon_color' => $nav_icon_color, '$nav_icon_color' => $nav_icon_color,
'$nav_icon_hover_color' => $nav_icon_hover_color, '$nav_icon_hover_color' => $nav_icon_hover_color,
@ -214,8 +213,8 @@ $etag = md5($css);
// Set a header for caching. // Set a header for caching.
header('Cache-Control: public'); header('Cache-Control: public');
header('ETag: "'.$etag.'"'); header('ETag: "' . $etag . '"');
header('Last-Modified: '.$modified); header('Last-Modified: ' . $modified);
// Only send the CSS file if it was changed. // Only send the CSS file if it was changed.
if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) { if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) || isset($_SERVER['HTTP_IF_NONE_MATCH'])) {