Theme: Integrate ability to use Google Fonts.

This commit is contained in:
reliberate
2016-05-05 12:57:08 -06:00
parent f9e5ac74a6
commit df22a29ed4
12 changed files with 605 additions and 5 deletions

View File

@@ -113,6 +113,20 @@ $text['message-copy_failed']['sv-se'] = "Ingen inställning markerad eller ogilt
$text['message-copy_failed']['uk'] = "";
$text['message-copy_failed']['de-at'] = "Keine Einstellungen ausgewählt oder ungültige Domain";
$text['label-web_fonts']['en-us'] = "Web Fonts";
$text['label-web_fonts']['es-cl'] = "Fuentes web";
$text['label-web_fonts']['pt-pt'] = "Fontes da web";
$text['label-web_fonts']['fr-fr'] = "Polices Web";
$text['label-web_fonts']['pt-br'] = "Polices Web";
$text['label-web_fonts']['pl'] = "Czcionki sieci";
$text['label-web_fonts']['he'] = "גופני אינטרנט";
$text['label-web_fonts']['uk'] = "веб-шрифти";
$text['label-web_fonts']['sv-se'] = "web teckensnitt";
$text['label-web_fonts']['de-at'] = "Web Fonts";
$text['label-web_fonts']['ro'] = "Fonturi web";
$text['label-web_fonts']['fa'] = "";
$text['label-web_fonts']['ar-eg'] = "الخطوط على شبكة الإنترنت";
$text['label-top']['en-us'] = "Top";
$text['label-top']['es-cl'] = "encima";
$text['label-top']['pt-pt'] = "Topo";
@@ -166,6 +180,20 @@ $text['label-static']['ro'] = "Static";
$text['label-static']['fa'] = "";
$text['label-static']['ar-eg'] = "ساكن";
$text['label-reference']['en-us'] = "See";
$text['label-reference']['es-cl'] = "Referencia";
$text['label-reference']['pt-pt'] = "Referência";
$text['label-reference']['fr-fr'] = "Référence";
$text['label-reference']['pt-br'] = "Referência";
$text['label-reference']['pl'] = "Odniesienie";
$text['label-reference']['he'] = "התייחסות";
$text['label-reference']['uk'] = "посилання";
$text['label-reference']['sv-se'] = "Referens";
$text['label-reference']['de-at'] = "Referenz";
$text['label-reference']['ro'] = "Referinţă";
$text['label-reference']['fa'] = "";
$text['label-reference']['ar-eg'] = "مرجع";
$text['label-right']['en-us'] = "Right";
$text['label-right']['es-cl'] = "Derecha";
$text['label-right']['pt-pt'] = "Certo";
@@ -180,6 +208,17 @@ $text['label-right']['ro'] = "Dreapta";
$text['label-right']['fa'] = "";
$text['label-right']['ar-eg'] = "حق";
$text['label-other']['en-us'] = "Other";
$text['label-other']['es-cl'] = "Otro";
$text['label-other']['pt-pt'] = "Outro";
$text['label-other']['fr-fr'] = "Autre";
$text['label-other']['pt-br'] = "Outro";
$text['label-other']['pl'] = "Inne";
$text['label-other']['uk'] = "";
$text['label-other']['sv-se'] = "Annat";
$text['label-other']['de-at'] = "Andere";
$text['label-other']['he'] = "אחר";
$text['label-normal']['en-us'] = "Normal";
$text['label-normal']['es-cl'] = "Normal";
$text['label-normal']['pt-pt'] = "Normal";

View File

@@ -448,6 +448,33 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
elseif ($category == "theme" && substr_count($subcategory, "_color") > 0 && ($name == "text" || $name == 'array')) {
echo " <input type='text' class='formfld colorpicker' id='default_setting_value' name='default_setting_value' value=\"".$default_setting_value."\">\n";
}
elseif ($category == "theme" && substr_count($subcategory, "_font") > 0 && $name == "text") {
$default_setting_value = str_replace('"', "'", $default_setting_value);
if ($fonts = get_available_fonts('alpha')) {
echo " <select class='formfld' id='sel_default_setting_value' onchange=\"if (this.selectedIndex == $('select#sel_default_setting_value option').length - 1) { $('#txt_default_setting_value').val('').fadeIn('fast'); $('#txt_default_setting_value').focus(); } else { $('#txt_default_setting_value').fadeOut('fast', function(){ $('#txt_default_setting_value').val($('#sel_default_setting_value').val()) }); } \">\n";
echo " <option value=''></option>\n";
echo " <optgroup label='".$text['label-web_fonts']."'>\n";
$option_found = false;
foreach ($fonts as $n => $font) {
if ($default_setting_value == $font) {
$selected = 'selected';
$option_found = true;
}
else {
unset($selected);
}
echo " <option value='".$font."' ".$selected.">".$font."</option>\n";
}
echo " </optgroup>\n";
echo " <option value='' disabled='disabled'></option>\n";
echo " <option value='' ".(($default_setting_value != '' && $option_found == false) ? 'selected' : null).">".$text['label-other']."...</option>\n";
echo " </select>";
echo " <input type='text' class='formfld' ".(($default_setting_value == '' || $option_found) ? "style='display: none;'" : null)." id='txt_default_setting_value' name='default_setting_value' value=\"".$default_setting_value."\">\n";
}
else {
echo " <input type='text' class='formfld' id='default_setting_value' name='default_setting_value' value=\"".$default_setting_value."\">\n";
}
}
elseif ($category == "fax" && $subcategory == "page_size" && $name == "text" ) {
echo " <select class='formfld' id='default_setting_value' name='default_setting_value' style=''>\n";
echo " <option value='letter' ".(($default_setting_value == 'letter') ? 'selected' : null).">Letter</option>";
@@ -531,6 +558,9 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
}
echo "<br />\n";
echo $text['description-value']."\n";
if ($category == "theme" && substr_count($subcategory, "_font") > 0 && $name == "text") {
echo "&nbsp;&nbsp;".$text['label-reference'].": <a href='https://www.google.com/fonts' target='_blank'>".$text['label-web_fonts']."</a>\n";
}
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";

View File

@@ -60,6 +60,20 @@ $text['message-delete_failed']['sv-se'] = "Ingen Inställning Markerad";
$text['message-delete_failed']['uk'] = "Налаштування не вказано";
$text['message-delete_failed']['de-at'] = "Keine Einstellungen ausgewählt";
$text['label-web_fonts']['en-us'] = "Web Fonts";
$text['label-web_fonts']['es-cl'] = "Fuentes web";
$text['label-web_fonts']['pt-pt'] = "Fontes da web";
$text['label-web_fonts']['fr-fr'] = "Polices Web";
$text['label-web_fonts']['pt-br'] = "Polices Web";
$text['label-web_fonts']['pl'] = "Czcionki sieci";
$text['label-web_fonts']['he'] = "גופני אינטרנט";
$text['label-web_fonts']['uk'] = "веб-шрифти";
$text['label-web_fonts']['sv-se'] = "web teckensnitt";
$text['label-web_fonts']['de-at'] = "Web Fonts";
$text['label-web_fonts']['ro'] = "Fonturi web";
$text['label-web_fonts']['fa'] = "";
$text['label-web_fonts']['ar-eg'] = "الخطوط على شبكة الإنترنت";
$text['label-top']['en-us'] = "Top";
$text['label-top']['es-cl'] = "encima";
$text['label-top']['pt-pt'] = "Topo";
@@ -126,6 +140,20 @@ $text['label-right']['ro'] = "Dreapta";
$text['label-right']['fa'] = "";
$text['label-right']['ar-eg'] = "حق";
$text['label-reference']['en-us'] = "See";
$text['label-reference']['es-cl'] = "Referencia";
$text['label-reference']['pt-pt'] = "Referência";
$text['label-reference']['fr-fr'] = "Référence";
$text['label-reference']['pt-br'] = "Referência";
$text['label-reference']['pl'] = "Odniesienie";
$text['label-reference']['he'] = "התייחסות";
$text['label-reference']['uk'] = "посилання";
$text['label-reference']['sv-se'] = "Referens";
$text['label-reference']['de-at'] = "Referenz";
$text['label-reference']['ro'] = "Referinţă";
$text['label-reference']['fa'] = "";
$text['label-reference']['ar-eg'] = "مرجع";
$text['label-parent_domain']['en-us'] = "Parent Domain";
$text['label-parent_domain']['es-cl'] = "Dominio de los Padres";
$text['label-parent_domain']['pt-pt'] = "Domínio Parent";
@@ -136,6 +164,17 @@ $text['label-parent_domain']['sv-se'] = "Överordnad Domän";
$text['label-parent_domain']['uk'] = "Батьківський домен";
$text['label-parent_domain']['de-at'] = "Übergeordnete Domain";
$text['label-other']['en-us'] = "Other";
$text['label-other']['es-cl'] = "Otro";
$text['label-other']['pt-pt'] = "Outro";
$text['label-other']['fr-fr'] = "Autre";
$text['label-other']['pt-br'] = "Outro";
$text['label-other']['pl'] = "Inne";
$text['label-other']['uk'] = "";
$text['label-other']['sv-se'] = "Annat";
$text['label-other']['de-at'] = "Andere";
$text['label-other']['he'] = "אחר";
$text['label-none']['en-us'] = "None";
$text['label-none']['es-cl'] = "Ninguna";
$text['label-none']['pt-pt'] = "Nenhum";

View File

@@ -545,6 +545,33 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
elseif ($category == "theme" && substr_count($subcategory, "_color") > 0 && ($name == "text" || $name == 'array')) {
echo " <input type='text' class='formfld colorpicker' id='domain_setting_value' name='domain_setting_value' value=\"".$row['domain_setting_value']."\">\n";
}
elseif ($category == "theme" && substr_count($subcategory, "_font") > 0 && $name == "text") {
$row['domain_setting_value'] = str_replace('"', "'", $row['domain_setting_value']);
if ($fonts = get_available_fonts('alpha')) {
echo " <select class='formfld' id='sel_domain_setting_value' onchange=\"if (this.selectedIndex == $('select#sel_domain_setting_value option').length - 1) { $('#txt_domain_setting_value').val('').fadeIn('fast'); $('#txt_domain_setting_value').focus(); } else { $('#txt_domain_setting_value').fadeOut('fast', function(){ $('#txt_domain_setting_value').val($('#sel_domain_setting_value').val()) }); } \">\n";
echo " <option value=''></option>\n";
echo " <optgroup label='".$text['label-web_fonts']."'>\n";
$option_found = false;
foreach ($fonts as $n => $font) {
if ($row['domain_setting_value'] == $font) {
$selected = 'selected';
$option_found = true;
}
else {
unset($selected);
}
echo " <option value='".$font."' ".$selected.">".$font."</option>\n";
}
echo " </optgroup>\n";
echo " <option value='' disabled='disabled'></option>\n";
echo " <option value='' ".(($row['domain_setting_value'] != '' && $option_found == false) ? 'selected' : null).">".$text['label-other']."...</option>\n";
echo " </select>";
echo " <input type='text' class='formfld' ".(($row['domain_setting_value'] == '' || $option_found) ? "style='display: none;'" : null)." id='txt_domain_setting_value' name='domain_setting_value' value=\"".$row['domain_setting_value']."\">\n";
}
else {
echo " <input type='text' class='formfld' id='domain_setting_value' name='domain_setting_value' value=\"".$row['domain_setting_value']."\">\n";
}
}
elseif ($category == "fax" && $subcategory == "page_size" && $name == "text" ) {
echo " <select class='formfld' id='domain_setting_value' name='domain_setting_value' style=''>\n";
echo " <option value='letter' ".(($row['domain_setting_value'] == 'letter') ? 'selected' : null).">Letter</option>";
@@ -612,6 +639,9 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
}
echo "<br />\n";
echo $text['description-value']."\n";
if ($category == "theme" && substr_count($subcategory, "_font") > 0 && $name == "text") {
echo "&nbsp;&nbsp;".$text['label-reference'].": <a href='https://www.google.com/fonts' target='_blank'>".$text['label-web_fonts']."</a>\n";
}
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";

View File

@@ -296,6 +296,20 @@ $text['message-cannot_delete_own_account']['ro'] = "";
$text['message-cannot_delete_own_account']['de-at'] = "Sie können nicht ihren eigenen Benutzer löschen. Bitte melden Sie sich mit einem anderen Benutzer an und versuchen Sie es erneut.";
$text['message-cannot_delete_own_account']['he'] = "";
$text['label-web_fonts']['en-us'] = "Web Fonts";
$text['label-web_fonts']['es-cl'] = "Fuentes web";
$text['label-web_fonts']['pt-pt'] = "Fontes da web";
$text['label-web_fonts']['fr-fr'] = "Polices Web";
$text['label-web_fonts']['pt-br'] = "Polices Web";
$text['label-web_fonts']['pl'] = "Czcionki sieci";
$text['label-web_fonts']['he'] = "גופני אינטרנט";
$text['label-web_fonts']['uk'] = "веб-шрифти";
$text['label-web_fonts']['sv-se'] = "web teckensnitt";
$text['label-web_fonts']['de-at'] = "Web Fonts";
$text['label-web_fonts']['ro'] = "Fonturi web";
$text['label-web_fonts']['fa'] = "";
$text['label-web_fonts']['ar-eg'] = "الخطوط على شبكة الإنترنت";
$text['label-username']['en-us'] = "Username";
$text['label-username']['es-cl'] = "Nombre de usuario";
$text['label-username']['pt-pt'] = "Nome de Utilizador";
@@ -407,6 +421,20 @@ $text['label-right']['ro'] = "Dreapta";
$text['label-right']['fa'] = "";
$text['label-right']['ar-eg'] = "حق";
$text['label-reference']['en-us'] = "See";
$text['label-reference']['es-cl'] = "Referencia";
$text['label-reference']['pt-pt'] = "Referência";
$text['label-reference']['fr-fr'] = "Référence";
$text['label-reference']['pt-br'] = "Referência";
$text['label-reference']['pl'] = "Odniesienie";
$text['label-reference']['he'] = "התייחסות";
$text['label-reference']['uk'] = "посилання";
$text['label-reference']['sv-se'] = "Referens";
$text['label-reference']['de-at'] = "Referenz";
$text['label-reference']['ro'] = "Referinţă";
$text['label-reference']['fa'] = "";
$text['label-reference']['ar-eg'] = "مرجع";
$text['label-permission_permissions']['en-us'] = "Permissions";
$text['label-permission_permissions']['es-cl'] = "Permisos";
$text['label-permission_permissions']['pt-pt'] = "Permissões";
@@ -440,6 +468,17 @@ $text['label-password']['ro'] = "Parolă";
$text['label-password']['de-at'] = "Passwort";
$text['label-password']['he'] = "סיסמה";
$text['label-other']['en-us'] = "Other";
$text['label-other']['es-cl'] = "Otro";
$text['label-other']['pt-pt'] = "Outro";
$text['label-other']['fr-fr'] = "Autre";
$text['label-other']['pt-br'] = "Outro";
$text['label-other']['pl'] = "Inne";
$text['label-other']['uk'] = "";
$text['label-other']['sv-se'] = "Annat";
$text['label-other']['de-at'] = "Andere";
$text['label-other']['he'] = "אחר";
$text['label-none']['en-us'] = "None";
$text['label-none']['es-cl'] = "Ninguna";
$text['label-none']['pt-pt'] = "Nenhum";

View File

@@ -547,6 +547,33 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
elseif ($category == "theme" && substr_count($subcategory, "_color") > 0 && ($name == "text" || $name == 'array')) {
echo " <input type='text' class='formfld colorpicker' id='user_setting_value' name='user_setting_value' value=\"".$row['user_setting_value']."\">\n";
}
elseif ($category == "theme" && substr_count($subcategory, "_font") > 0 && $name == "text") {
$row['user_setting_value'] = str_replace('"', "'", $row['user_setting_value']);
if ($fonts = get_available_fonts('alpha')) {
echo " <select class='formfld' id='sel_user_setting_value' onchange=\"if (this.selectedIndex == $('select#sel_user_setting_value option').length - 1) { $('#txt_user_setting_value').val('').fadeIn('fast'); $('#txt_user_setting_value').focus(); } else { $('#txt_user_setting_value').fadeOut('fast', function(){ $('#txt_user_setting_value').val($('#sel_user_setting_value').val()) }); } \">\n";
echo " <option value=''></option>\n";
echo " <optgroup label='".$text['label-web_fonts']."'>\n";
$option_found = false;
foreach ($fonts as $n => $font) {
if ($row['user_setting_value'] == $font) {
$selected = 'selected';
$option_found = true;
}
else {
unset($selected);
}
echo " <option value='".$font."' ".$selected.">".$font."</option>\n";
}
echo " </optgroup>\n";
echo " <option value='' disabled='disabled'></option>\n";
echo " <option value='' ".(($row['user_setting_value'] != '' && $option_found == false) ? 'selected' : null).">".$text['label-other']."...</option>\n";
echo " </select>";
echo " <input type='text' class='formfld' ".(($row['user_setting_value'] == '' || $option_found) ? "style='display: none;'" : null)." id='txt_user_setting_value' name='user_setting_value' value=\"".$row['user_setting_value']."\">\n";
}
else {
echo " <input type='text' class='formfld' id='user_setting_value' name='user_setting_value' value=\"".$row['user_setting_value']."\">\n";
}
}
elseif ($category == "fax" && $subcategory == "page_size" && $name == "text" ) {
echo " <select class='formfld' id='user_setting_value' name='user_setting_value' style=''>\n";
echo " <option value='letter' ".(($row['user_setting_value'] == 'letter') ? 'selected' : null).">Letter</option>";
@@ -614,6 +641,9 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
}
echo "<br />\n";
echo $text['description-value']."\n";
if ($category == "theme" && substr_count($subcategory, "_font") > 0 && $name == "text") {
echo "&nbsp;&nbsp;".$text['label-reference'].": <a href='https://www.google.com/fonts' target='_blank'>".$text['label-web_fonts']."</a>\n";
}
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";

90
resources/fonts/root.php Normal file
View File

@@ -0,0 +1,90 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
// make sure the PATH_SEPARATOR is defined
umask(2);
if (!defined("PATH_SEPARATOR")) {
if (strpos($_ENV["OS"], "Win") !== false) {
define("PATH_SEPARATOR", ";");
} else {
define("PATH_SEPARATOR", ":");
}
}
if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
// make sure the document_root is set
$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
if(PHP_SAPI == 'cli'){
chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
if (file_exists('/project_root.php')) {
$path = '/';
} else {
$i = 1;
$path = '';
while ($i < count($dirs)) {
$path .= '/' . $dirs[$i];
if (file_exists($path. '/project_root.php')) {
break;
}
$i++;
}
}
$_SERVER["DOCUMENT_ROOT"] = $path;
}else{
$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
}
$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
// try to detect if a project path is being used
if (!defined('PROJECT_PATH')) {
if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) {
define('PROJECT_PATH', '/fusionpbx');
} elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) {
define('PROJECT_PATH', '');
} else {
$dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME)));
$i = 1;
$path = $_SERVER["DOCUMENT_ROOT"];
while ($i < count($dirs)) {
$path .= '/' . $dirs[$i];
if (file_exists($path. '/project_root.php')) {
break;
}
$i++;
}
if(!file_exists($path. '/project_root.php')){
die("Failed to locate the Project Root by searching for project_root.php please contact support for assistance");
}
$project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path);
define('PROJECT_PATH', $project_path);
}
$_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH);
set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]);
}
?>

View File

@@ -0,0 +1,106 @@
<?php
include "root.php";
require_once "resources/require.php";
$font_loader_version = ($_GET['v'] != '') ? $_GET['v'] : 1;
header("Content-type: text/javascript; charset: UTF-8");
//web font loader
if ($_SESSION['theme']['font_loader']['text'] == 'true') {
//parse font names
if (is_array($_SESSION['theme']) && sizeof($_SESSION['theme']) > 0) {
foreach ($_SESSION['theme'] as $subcategory => $type) {
if (substr_count($subcategory, '_font') > 0) {
$font_string = $type['text'];
if ($font_string != '') {
if (substr_count($font_string, ',') > 0) {
$tmp_array = explode(',', $font_string);
}
else {
$tmp_array[] = $font_string;
}
foreach ($tmp_array as $font_name) {
$font_name = trim($font_name, "'");
$font_name = trim($font_name, '"');
$font_name = trim($font_name);
$fonts[] = $font_name;
}
}
}
unset($fonts, $tmp_array);
}
}
//optimize fonts array
$fonts = array_unique($fonts);
$common_fonts = 'arial,arial black,arial narrow,calibri,'.
'candara,apple gothic,geneva,tahoma,microsoft sans serif,'.
'lucidia,lucidia console,monaco,lucidia sans unicode,'.
'lucidiagrande,consolas,menlo,trebuchet,trebuchet ms,'.
'helvetica,times,times new roman,courier,courier new,'.
'impact,comic sans,comic sans ms,georgia,palatino,'.
'palatino linotype,verdana,franklin gothic,'.
'franklin gothic medium,gill sans,gill sans mt,'.
'brush script,corbel';
$common_fonts = array(explode(',', $common_fonts));
foreach ($fonts as $index => $font) {
if (in_array(strtolower($font), $common_fonts)) {
unset($fonts[$index]);
}
}
//load fonts
if (is_array($fonts) && sizeof($fonts) > 0) {
if ($_SESSION['theme']['font_retrieval']['text'] == 'asynchronous') {
?>
WebFontConfig = {
google: {
families: ['<?php echo implode("','", $fonts); ?>']
}
};
(function(d) {
var wf = d.createElement('script'), s = d.scripts[0];
wf.src = '//ajax.googleapis.com/ajax/libs/webfont/<?php echo $font_loader_version; ?>/webfont.js';
s.parentNode.insertBefore(wf, s);
})(document);
<?php
}
else { //synchronous
?>
WebFont.load({
google: {
families: ['<?php echo implode("','", $fonts); ?>']
}
});
<?php
}
}
}
?>

View File

@@ -1776,4 +1776,136 @@ function number_pad($number,$n) {
//$string = "2089068227)$"; echo $string." ".string_to_regex($string)."\n";
}
//dynamically load available web fonts
if (!function_exists('get_available_fonts')) {
function get_available_fonts($sort = 'alpha') {
if ($_SESSION['theme']['font_source_key']['text'] != '') {
if (!is_array($_SESSION['fonts_available']) || sizeof($_SESSION['fonts_available']) == 0) {
/*
sort options:
alpha - alphabetically
date - by date added (most recent font added or updated first)
popularity - by popularity (most popular family first)
style - by number of styles available (family with most styles first)
trending - by families seeing growth in usage (family seeing the most growth first)
*/
$google_api_url = 'https://www.googleapis.com/webfonts/v1/webfonts?key='.$_SESSION['theme']['font_source_key']['text'].'&sort='.$sort;
$response = file_get_contents($google_api_url);
if ($response != '') {
$data = json_decode($response, true);
$items = $data['items'];
foreach ($items as $item) {
$fonts[] = $item['family'];
}
//echo "<pre>".print_r($font_list, true)."</pre>";
}
$_SESSION['fonts_available'] = $fonts;
unset($fonts);
}
return (is_array($_SESSION['fonts_available']) && sizeof($_SESSION['fonts_available']) > 0) ? $_SESSION['fonts_available'] : array();
}
else {
return false;
}
}
}
//dynamically import web fonts (by reading static css file)
if (!function_exists('import_fonts')) {
function import_fonts($file_to_parse, $line_styles_begin = null) {
/*
This function reads the contents of $file_to_parse, beginning at $line_styles_begin (if set),
and attempts to parse the specified google fonts used. The assumption is that each curly brace
will be on its own line, each CSS style (attribute: value;) will be on its own line, a single
Google Fonts name will be used per selector, and that it will be surrounded by SINGLE quotes,
as shown in the example below:
.class_name {
font-family: 'Google Font';
font-weight: 300;
font-style: italic;
}
If the CSS styles are formatted as described, the necessary @import string should be generated
correctly.
*/
$file = file_get_contents($_SERVER["DOCUMENT_ROOT"].$file_to_parse);
$lines = explode("\n", $file);
$style_counter = 0;
foreach ($lines as $line_number => $line) {
if ($line_styles_begin != '' && $line_number < $line_styles_begin - 1) { continue; }
if (substr_count($line, "{") > 0) {
$style_lines[$style_counter]['begins'] = $line_number;
}
if (substr_count($line, "}") > 0) {
$style_lines[$style_counter]['ends'] = $line_number;
$style_counter++;
}
}
//echo "\n\n".print_r($style_lines, true)."\n\n";
if (is_array($style_lines) && sizeof($style_lines) > 0) {
foreach ($style_lines as $index => $style_line) {
for ($l = $style_line['begins']+1; $l < $style_line['ends']; $l++) {
$tmp[] = $lines[$l];
}
$style_groups[] = $tmp;
unset($tmp);
}
//echo "\n\n".print_r($style_groups, true)."\n\n";
if (is_array($style_groups) && sizeof($style_groups) > 0) {
foreach ($style_groups as $style_group_index => $style_group) {
foreach ($style_group as $style_index => $style) {
$tmp = explode(':', $style);
$attribute = trim($tmp[0]);
$value = trim(trim($tmp[1]),';');
$style_array[$attribute] = $value;
}
$style_groups[$style_group_index] = $style_array;
unset($style_array);
}
//echo "\n\n".print_r($style_groups, true)."\n\n";
foreach ($style_groups as $style_group_index => $style_group) {
$style_value = $style_group['font-family'];
if (substr_count($style_value, "'") > 0) {
//determine font
$font_begin = strpos($style_value, "'")+1;
$font_end = strpos($style_value, "'", $font_begin);
$font_name = substr($style_value, $font_begin, $font_end - $font_begin);
//determine modifiers
$weight = (is_numeric($style_group['font-weight']) || strtolower($style_group['font-weight']) == 'bold') ? strtolower($style_group['font-weight']) : null;
$italic = (strtolower($style_group['font-style']) == 'italic') ? 'italic' : null;
//add font to array
$fonts[$font_name][] = $weight.$italic;
}
}
//echo "\n\n/*".print_r($fonts, true)."*/\n\n";
if (is_array($fonts)) {
foreach ($fonts as $font_name => $modifiers) {
$modifiers = array_unique($modifiers);
$import_font_string = str_replace(' ', '+', $font_name);
if (is_array($modifiers) && sizeof($modifiers) > 0) {
$import_font_string .= ':'.implode(',', $modifiers);
}
$import_fonts[] = $import_font_string;
}
//echo "\n\n/*".print_r($import_fonts, true)."*/\n\n";
$import_string = "@import url(//fonts.googleapis.com/css?family=".implode('|', $import_fonts).");";
echo $import_string."\n";
}
}
}
}
}
?>

View File

@@ -591,7 +591,7 @@ if ($domains_processed == 1) {
$array[$x]['default_setting_category'] = 'theme';
$array[$x]['default_setting_subcategory'] = 'dashboard_heading_text_font';
$array[$x]['default_setting_name'] = 'text';
$array[$x]['default_setting_value'] = 'Calibri, Candara, Segoe, "Segoe UI", Optima, Arial, sans-serif';
$array[$x]['default_setting_value'] = "Calibri, Candara, Segoe, 'Segoe UI', Optima, Arial, sans-serif";
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = 'Set the font of the Dashboard block heading text.';
$x++;
@@ -647,7 +647,7 @@ if ($domains_processed == 1) {
$array[$x]['default_setting_category'] = 'theme';
$array[$x]['default_setting_subcategory'] = 'dashboard_number_text_font';
$array[$x]['default_setting_name'] = 'text';
$array[$x]['default_setting_value'] = 'Calibri, Candara, Segoe, "Segoe UI", Optima, Arial, sans-serif';
$array[$x]['default_setting_value'] = "Calibri, Candara, Segoe, 'Segoe UI', Optima, Arial, sans-serif";
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = 'Set the font of the Dashboard block number.';
$x++;
@@ -682,7 +682,7 @@ if ($domains_processed == 1) {
$array[$x]['default_setting_category'] = 'theme';
$array[$x]['default_setting_subcategory'] = 'dashboard_number_title_text_font';
$array[$x]['default_setting_name'] = 'text';
$array[$x]['default_setting_value'] = 'Calibri, Candara, Segoe, "Segoe UI", Optima, Arial, sans-serif';
$array[$x]['default_setting_value'] = "Calibri, Candara, Segoe, 'Segoe UI', Optima, Arial, sans-serif";
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = 'Set the font of the Dashboard block number title.';
$x++;
@@ -1079,7 +1079,7 @@ if ($domains_processed == 1) {
$array[$x]['default_setting_category'] = 'theme';
$array[$x]['default_setting_subcategory'] = 'button_text_font';
$array[$x]['default_setting_name'] = 'text';
$array[$x]['default_setting_value'] = 'Candara, Calibri, Segoe, "Segoe UI", Optima, Arial, sans-serif';
$array[$x]['default_setting_value'] = "Candara, Calibri, Segoe, 'Segoe UI', Optima, Arial, sans-serif";
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = 'Set the font of button text.';
$x++;
@@ -1316,6 +1316,35 @@ if ($domains_processed == 1) {
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = 'Set the color (and opacity) of input placeholder text on the login box.';
$x++;
$array[$x]['default_setting_category'] = 'theme';
$array[$x]['default_setting_subcategory'] = 'font_loader';
$array[$x]['default_setting_name'] = 'text';
$array[$x]['default_setting_value'] = 'true';
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = 'Enables the dynamic loading of web fonts (requires an Internet connection).';
$x++;
$array[$x]['default_setting_category'] = 'theme';
$array[$x]['default_setting_subcategory'] = 'font_loader_version';
$array[$x]['default_setting_name'] = 'text';
$array[$x]['default_setting_value'] = '1.6.16';
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = "Set the web font loader version to use - specific (e.g. '1.6.16') or latest in branch (e.g. '1').";
$x++;
$array[$x]['default_setting_category'] = 'theme';
$array[$x]['default_setting_subcategory'] = 'font_retrieval';
$array[$x]['default_setting_name'] = 'text';
$array[$x]['default_setting_value'] = 'asynchronous';
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = 'Set the retrieval method for the web font loader (default: synchronous).';
$x++;
$array[$x]['default_setting_category'] = 'theme';
$array[$x]['default_setting_subcategory'] = 'font_source_key';
$array[$x]['default_setting_name'] = 'text';
$array[$x]['default_setting_value'] = '';
$array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = "API key that allows access to the available fonts list.";
$x++;
//get an array of the default settings
$sql = "select * from v_default_settings ";
@@ -1367,7 +1396,7 @@ if ($domains_processed == 1) {
$sql .= "'".check_str($row['default_setting_enabled'])."', ";
$sql .= "'".check_str($row['default_setting_description'])."' ";
$sql .= ")";
if ($missing_count != $i) {
if ($missing_count != $i) {
$sql .= ",\n";
}
$i++;

View File

@@ -6,6 +6,32 @@ header("Content-type: text/css; charset: UTF-8");
$default_login = ($_REQUEST['login'] == 'default') ? true : false;
//parse fonts (add surrounding single quotes to each font name)
if (is_array($_SESSION['theme']) && sizeof($_SESSION['theme']) > 0) {
foreach ($_SESSION['theme'] as $subcategory => $type) {
if (substr_count($subcategory, '_font') > 0) {
$font_string = $type['text'];
if ($font_string != '') {
if (substr_count($font_string, ',') > 0) {
$tmp_array = explode(',', $font_string);
}
else {
$tmp_array[] = $font_string;
}
foreach ($tmp_array as $font_name) {
$font_name = trim($font_name, "'");
$font_name = trim($font_name, '"');
$font_name = trim($font_name);
$fonts[] = $font_name;
}
if (sizeof($fonts) == 1 && strtolower($fonts[0]) != 'arial') { $fonts[] = 'Arial'; } //fall back font
$_SESSION['theme'][$subcategory]['text'] = "'".implode("','", $fonts)."'";
}
}
unset($fonts, $tmp_array);
}
}
//determine which background image/color settings to use (login or standard)
$background_images_enabled = false;
if ($default_login) {

View File

@@ -51,6 +51,16 @@
<script language="JavaScript" type="text/javascript" src="<!--{project_path}-->/resources/bootstrap/js/bootstrap.min.js"></script>
<script language="JavaScript" type="text/javascript" src="<!--{project_path}-->/resources/bootstrap/js/bootstrap-datetimepicker.min.js"></script>
<script language="JavaScript" type="text/javascript" src="<!--{project_path}-->/resources/bootstrap/js/bootstrap-colorpicker.js"></script>
<?php
//web font loader
if ($_SESSION['theme']['font_loader']['text'] == 'true') {
if ($_SESSION['theme']['font_retrieval']['text'] != 'asynchronous') {
$font_loader_version = ($_SESSION['theme']['font_loader_version']['text'] != '') ? $_SESSION['theme']['font_loader_version']['text'] : 1;
echo "<script language='JavaScript' type='text/javascript' src='//ajax.googleapis.com/ajax/libs/webfont/".$font_loader_version."/webfont.js'></script>\n";
}
echo "<script language='JavaScript' type='text/javascript' src='<!--{project_path}-->/resources/fonts/web_font_loader.php?v=".$font_loader_version."'></script>\n";
}
?>
<script language="JavaScript" type="text/javascript">
//display message bar via js