Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d0753512a3 | ||
|
|
d0de3821f8 | ||
|
|
0d89eea1af |
1
.phplint-cache
Normal file
1
.phplint-cache
Normal file
File diff suppressed because one or more lines are too long
@@ -16,10 +16,10 @@ $CSS_NAME = 'smart_test.css';
|
||||
$USE_PROTOTYPE = false;
|
||||
$USE_JQUERY = true;
|
||||
if ($USE_PROTOTYPE) {
|
||||
$EDIT_JAVASCRIPT = 'edit.pt.js';
|
||||
$ADMIN_JAVASCRIPT = 'edit.pt.js';
|
||||
$JS_NAME = 'prototype.test.js';
|
||||
} else if ($USE_JQUERY) {
|
||||
$EDIT_JAVASCRIPT = 'edit.jq.js';
|
||||
} elseif ($USE_JQUERY) {
|
||||
$ADMIN_JAVASCRIPT = 'edit.jq.js';
|
||||
$JS_NAME = 'jquery.test.js';
|
||||
}
|
||||
$PAGE_WIDTH = "100%";
|
||||
|
||||
@@ -106,13 +106,15 @@ if (!$AJAX_PAGE) {
|
||||
if (file_exists($cms->javascript.$cms->JS_SPECIAL_TEMPLATE_NAME) && is_file($cms->javascript.$cms->JS_SPECIAL_TEMPLATE_NAME)) {
|
||||
$cms->JS_SPECIAL_INCLUDE = $cms->javascript.$cms->JS_SPECIAL_TEMPLATE_NAME;
|
||||
}
|
||||
// check if template names exist
|
||||
if (!file_exists($smarty->getTemplateDir()[0].DS.$MASTER_TEMPLATE_NAME)) {
|
||||
// abort if master template could not be found
|
||||
exit('MASTER TEMPLATE: '.$MASTER_TEMPLATE_NAME.' could not be found');
|
||||
}
|
||||
if (isset($TEMPLATE_NAME) && !file_exists($smarty->getTemplateDir()[0].DS.$TEMPLATE_NAME)) {
|
||||
exit('INCLUDE TEMPLATE: '.$TEMPLATE_NAME.' could not be found');
|
||||
if ($smarty) {
|
||||
// check if template names exist
|
||||
if (!file_exists($smarty->getTemplateDir()[0].DS.$MASTER_TEMPLATE_NAME)) {
|
||||
// abort if master template could not be found
|
||||
exit('MASTER TEMPLATE: '.$MASTER_TEMPLATE_NAME.' could not be found');
|
||||
}
|
||||
if (isset($TEMPLATE_NAME) && !file_exists($smarty->getTemplateDir()[0].DS.$TEMPLATE_NAME)) {
|
||||
exit('INCLUDE TEMPLATE: '.$TEMPLATE_NAME.' could not be found');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -221,6 +221,38 @@ function getTimestamp()
|
||||
return date.getTime();
|
||||
}
|
||||
|
||||
// METHOD: dec2hex
|
||||
// PARAMS: decimal string
|
||||
// RETURN: string
|
||||
// DESC : dec2hex :: Integer -> String
|
||||
// i.e. 0-255 -> '00'-'ff'
|
||||
function dec2hex(dec)
|
||||
{
|
||||
return ('0' + dec.toString(16)).substr(-2);
|
||||
}
|
||||
|
||||
// METHOD: generateId
|
||||
// PARAMS: lenght in int
|
||||
// RETURN: random string
|
||||
// DESC : generateId :: Integer -> String
|
||||
// only works on mondern browsers
|
||||
function generateId(len)
|
||||
{
|
||||
var arr = new Uint8Array((len || 40) / 2);
|
||||
(window.crypto || window.msCrypto).getRandomValues(arr);
|
||||
return Array.from(arr, dec2hex).join('');
|
||||
}
|
||||
|
||||
// METHOD: randomIdF()
|
||||
// PARAMS: none
|
||||
// RETURN: not true random string
|
||||
// DESC : creates a pseudo random string of 10 characters
|
||||
// after many runs it will create duplicates
|
||||
function randomIdF()
|
||||
{
|
||||
return Math.random().toString(36).substring(2);
|
||||
}
|
||||
|
||||
// METHOD: isObject
|
||||
// PARAMS: possible object
|
||||
// RETURN: true/false if it is an object or not
|
||||
@@ -554,6 +586,8 @@ function phfo(tree)
|
||||
// *** DOM MANAGEMENT FUNCTIONS
|
||||
|
||||
// BLOCK: html wrappers for quickly creating html data blocks
|
||||
|
||||
// NOTE : OLD FORMAT which misses multiple block set
|
||||
// METHOD: html_options
|
||||
// PARAMS: name/id, array for the options, selected item uid
|
||||
// options_only [def false] if this is true, it will not print the select part
|
||||
@@ -563,15 +597,36 @@ function phfo(tree)
|
||||
// DESC : creates an select/options drop down block.
|
||||
// the array needs to be key -> value format. key is for the option id and value is for the data output
|
||||
function html_options(name, data, selected = '', options_only = false, return_string = false, sort = '')
|
||||
{
|
||||
// wrapper to new call
|
||||
return html_options_block(name, data, selected, false, options_only, return_string, sort);
|
||||
}
|
||||
|
||||
// NOTE : USE THIS CALL, the above one is deprecated
|
||||
// METHOD: html_options
|
||||
// PARAMS: name/id, array for the options,
|
||||
// selected item uid
|
||||
// multiple [def false] if this is true, the drop down will be turned into multiple select
|
||||
// options_only [def false] if this is true, it will not print the select part
|
||||
// return_string [def false]: return as string and not as element
|
||||
// sort [def '']: if empty as is, else allowed 'keys', 'values' all others are ignored
|
||||
// RETURN: html with build options block
|
||||
// DESC : creates an select/options drop down block.
|
||||
// the array needs to be key -> value format. key is for the option id and value is for the data output
|
||||
function html_options_block(name, data, selected = '', multiple = false, options_only = false, return_string = false, sort = '')
|
||||
{
|
||||
var content = [];
|
||||
var element_select;
|
||||
var select_options = {};
|
||||
var element_option;
|
||||
var data_list = []; // for sorted output
|
||||
var value;
|
||||
var options;
|
||||
var option;
|
||||
if (multiple === true) {
|
||||
select_options.multiple = '';
|
||||
}
|
||||
// set outside select, gets stripped on return if options only is true
|
||||
element_select = cel('select', name);
|
||||
element_select = cel('select', name, '', [], select_options);
|
||||
// console.log('Call for %s, options: %s', name, options_only);
|
||||
if (sort == 'keys') {
|
||||
data_list = Object.keys(data).sort();
|
||||
|
||||
@@ -299,6 +299,38 @@ function getTimestamp()
|
||||
return date.getTime();
|
||||
}
|
||||
|
||||
// METHOD: dec2hex
|
||||
// PARAMS: decimal string
|
||||
// RETURN: string
|
||||
// DESC : dec2hex :: Integer -> String
|
||||
// i.e. 0-255 -> '00'-'ff'
|
||||
function dec2hex(dec)
|
||||
{
|
||||
return ('0' + dec.toString(16)).substr(-2);
|
||||
}
|
||||
|
||||
// METHOD: generateId
|
||||
// PARAMS: lenght in int
|
||||
// RETURN: random string
|
||||
// DESC : generateId :: Integer -> String
|
||||
// only works on mondern browsers
|
||||
function generateId(len)
|
||||
{
|
||||
var arr = new Uint8Array((len || 40) / 2);
|
||||
(window.crypto || window.msCrypto).getRandomValues(arr);
|
||||
return Array.from(arr, dec2hex).join('');
|
||||
}
|
||||
|
||||
// METHOD: randomIdF()
|
||||
// PARAMS: none
|
||||
// RETURN: not true random string
|
||||
// DESC : creates a pseudo random string of 10 characters
|
||||
// after many runs it will create duplicates
|
||||
function randomIdF()
|
||||
{
|
||||
return Math.random().toString(36).substring(2);
|
||||
}
|
||||
|
||||
// METHOD: isObject
|
||||
// PARAMS: possible object
|
||||
// RETURN: true/false if it is an object or not
|
||||
@@ -632,6 +664,8 @@ function phfo(tree)
|
||||
// *** DOM MANAGEMENT FUNCTIONS
|
||||
|
||||
// BLOCK: html wrappers for quickly creating html data blocks
|
||||
|
||||
// NOTE : OLD FORMAT which misses multiple block set
|
||||
// METHOD: html_options
|
||||
// PARAMS: name/id, array for the options, selected item uid
|
||||
// options_only [def false] if this is true, it will not print the select part
|
||||
@@ -641,15 +675,36 @@ function phfo(tree)
|
||||
// DESC : creates an select/options drop down block.
|
||||
// the array needs to be key -> value format. key is for the option id and value is for the data output
|
||||
function html_options(name, data, selected = '', options_only = false, return_string = false, sort = '')
|
||||
{
|
||||
// wrapper to new call
|
||||
return html_options_block(name, data, selected, false, options_only, return_string, sort);
|
||||
}
|
||||
|
||||
// NOTE : USE THIS CALL, the above one is deprecated
|
||||
// METHOD: html_options
|
||||
// PARAMS: name/id, array for the options,
|
||||
// selected item uid
|
||||
// multiple [def false] if this is true, the drop down will be turned into multiple select
|
||||
// options_only [def false] if this is true, it will not print the select part
|
||||
// return_string [def false]: return as string and not as element
|
||||
// sort [def '']: if empty as is, else allowed 'keys', 'values' all others are ignored
|
||||
// RETURN: html with build options block
|
||||
// DESC : creates an select/options drop down block.
|
||||
// the array needs to be key -> value format. key is for the option id and value is for the data output
|
||||
function html_options_block(name, data, selected = '', multiple = false, options_only = false, return_string = false, sort = '')
|
||||
{
|
||||
var content = [];
|
||||
var element_select;
|
||||
var select_options = {};
|
||||
var element_option;
|
||||
var data_list = []; // for sorted output
|
||||
var value;
|
||||
var options;
|
||||
var option;
|
||||
if (multiple === true) {
|
||||
select_options.multiple = '';
|
||||
}
|
||||
// set outside select, gets stripped on return if options only is true
|
||||
element_select = cel('select', name);
|
||||
element_select = cel('select', name, '', [], select_options);
|
||||
// console.log('Call for %s, options: %s', name, options_only);
|
||||
if (sort == 'keys') {
|
||||
data_list = Object.keys(data).sort();
|
||||
|
||||
@@ -1322,6 +1322,7 @@ class Basic
|
||||
if (preg_match("/(d|h|m|s|ms)/", $timestring)) {
|
||||
// pos for preg match read + multiply factor
|
||||
$timegroups = array (2 => 86400, 4 => 3600, 6 => 60, 8 => 1);
|
||||
$matches = array ();
|
||||
// preg match: 0: full strsing
|
||||
// 2, 4, 6, 8 are the to need values
|
||||
preg_match("/^((\d+)d ?)?((\d+)h ?)?((\d+)m ?)?((\d+)s ?)?((\d+)ms)?$/", $timestring, $matches);
|
||||
@@ -1453,12 +1454,14 @@ class Basic
|
||||
// PARAMS: start date, end date
|
||||
// RETURN: overall days, week days, weekend days as array 0...2 or named
|
||||
// DESC : calculates the days between two dates
|
||||
private function calcDaysInterval($start_date, $end_date, $return_named = false)
|
||||
public static function calcDaysInterval($start_date, $end_date, $return_named = false)
|
||||
{
|
||||
// pos 0 all, pos 1 weekday, pos 2 weekend
|
||||
$days = array ();
|
||||
$start = new \DateTime($start_date);
|
||||
$end = new \DateTime($end_date);
|
||||
// so we include the last day too, we need to add +1 second in the time
|
||||
$end->setTime(0, 0, 1);
|
||||
|
||||
$days[0] = $end->diff($start)->days;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user