Merge pull request #9 from FOSSBilling/rename-templates

Rename templates to native Twig extension by @andpavlenko
This commit is contained in:
Yağızhan authored and GitHub committed 2022-05-20 11:03:52 +03:00
commit a5b79c8ce5
561 files changed
+33604 -23715

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
{
"presets": [
["env", {
"targets": {
"node": "6"
},
"useBuiltIns": true
}]
],
"plugins": [
["transform-object-rest-spread", {
"useBuiltIns": true
}]
]
}
View File
File renamed without changes.
+2 -5
View File
@@ -38,9 +38,6 @@ jobs:
run: composer validate
working-directory: ./src
- name: Install Grunt-CLI
run: npm install -g grunt-cli
- name: Installing NPM dependencies
run: npm install
@@ -57,8 +54,8 @@ jobs:
cp LICENSE ./build/source/
cp CHANGELOG.md ./build/source/
- name: Running Grunt
run: grunt
- name: Building assets
run: gulp build
working-directory: ./build/source
- name: Installing Composer dependencies
+2 -1
View File
@@ -1,4 +1,5 @@
.idea
.vscode
._*
.DS_Store
.vagrant*
@@ -30,4 +31,4 @@ npm-debug.log
### friendsofphp/php-cs-fixer ###
src/.php-cs-fixer.cache
.vscode
.vscode
+53
View File
@@ -0,0 +1,53 @@
<?php
/**
* BoxBilling.
*
* @copyright BoxBilling, Inc (https://www.boxbilling.org)
* @license Apache-2.0
*
* Copyright BoxBilling, Inc
* This source file is subject to the Apache-2.0 License that is bundled
* with this source code in the file LICENSE
*/
if (!file_exists(__DIR__ . '/src')) {
exit(0);
}
$fileHeaderComment = <<<'EOF'
BoxBilling.
@copyright BoxBilling, Inc (https://www.boxbilling.org)
@license Apache-2.0
Copyright BoxBilling, Inc
This source file is subject to the Apache-2.0 License that is bundled
with this source code in the file LICENSE
EOF;
return (new PhpCsFixer\Config())
->setRules([
'@PHP74Migration' => true,
'@Symfony' => true,
'header_comment' => ['header' => $fileHeaderComment, 'comment_type' => 'PHPDoc'],
'concat_space' => ['spacing' => 'one'],
'protected_to_private' => false,
'nullable_type_declaration_for_default_null_value' => ['use_nullable_type_declaration' => false],
])
->setRiskyAllowed(false)
->setFinder(
(new PhpCsFixer\Finder())
->in(__DIR__ . '/src')
->exclude([
'bb-data',
'bb-library',
'bb-locale',
'bb-themes',
'bb-vendor',
'install',
'bb-modules/Wysiwyg',
])
->notPath('rb.php')
)
;
+2
View File
@@ -2,6 +2,8 @@ Master
------------------------------------------------------------------------------
**General:**
* Rafactoring admin template with Tabler.io
* Templates extensions .phtml ranamed to .html.twig
* Updated bb-themes/bootstrap to Bootstrap 5
Release 4.22-beta.1.1
-124
View File
@@ -1,124 +0,0 @@
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
sprite: {
dark_icons: {
src: 'src/bb-themes/admin_default/images/icons/dark/*.png',
dest: 'src/bb-themes/admin_default/sprites/dark-icons-sprite.png',
destCss: 'src/bb-themes/admin_default/css/dark-icons-sprite.css',
cssOpts: {
cssSelector: function (item) {
return '.sprite-' + item.name;
}
}
},
topnav: {
src: 'src/bb-themes/admin_default/images/icons/topnav/*.png',
dest: 'src/bb-themes/admin_default/sprites/topnav-sprite.png',
destCss: 'src/bb-themes/admin_default/css/topnav-sprite.css',
cssOpts: {
cssSelector: function (item) {
return '.sprite-topnav-' + item.name;
}
}
},
middleNav: {
src: 'src/bb-themes/admin_default/images/icons/middlenav/used/*.png',
dest: 'src/bb-themes/admin_default/sprites/dark-icons-23-sprite.png',
destCss: 'src/bb-themes/admin_default/css/dark-icons-23-sprite.css',
cssOpts: {
cssSelector: function (item) {
return '.sprite-23-' + item.name;
}
}
}
},
clean: {
css: {
src: [
"src/bb-themes/admin_default/css/min-temp.css"
]
},
js: {
src: [
"src/bb-themes/admin_default/js/boxbilling.js"
]
}
},
concat_css: {
style: {
src: [
'src/bb-themes/admin_default/css/dark-icons-sprite.css',
'src/bb-themes/admin_default/css/dark-icons-23-sprite.css',
'src/bb-themes/admin_default/css/topnav-sprite.css',
'src/bb-themes/admin_default/css/jquery-ui.css',
'src/bb-themes/admin_default/css/bb.css',
'src/bb-themes/admin_default/css/reset.css',
'src/bb-themes/admin_default/css/dataTable.css',
'src/bb-themes/admin_default/css/ui_custom.css',
'src/bb-themes/admin_default/css/icons.css.css',
'src/bb-themes/admin_default/css/main.css'
],
dest: "src/bb-themes/admin_default/css/min-temp.css"
}
},
cssmin: {
target: {
files: [
{
'src/bb-themes/admin_default/css/min.css': ['src/bb-themes/admin_default/css/min-temp.css']
}
]
}
},
concat: {
default: {
src: [
'src/bb-themes/admin_default/js/jquery.min.js',
'src/bb-themes/admin_default/js/ui/jquery.alerts.js',
'src/bb-themes/admin_default/js/ui/jquery.tipsy.js',
'src/bb-themes/admin_default/js/jquery.collapsible.min.js',
'src/bb-themes/admin_default/js/forms/forms.js',
'src/bb-themes/admin_default/js/jquery.ToTop.js',
'src/bb-themes/admin_default/js/jquery.scrollTo-min.js',
'src/bb-themes/admin_default/js/jquery-ui.js',
],
dest: 'src/bb-themes/admin_default/js/boxbilling.js'
},
},
uglify: {
js: {
files: {
'src/bb-themes/admin_default/js/boxbilling.min.js': ['src/bb-themes/admin_default/js/boxbilling.js'],
}
}
},
});
// Load packages
grunt.loadNpmTasks('grunt-spritesmith');
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.loadNpmTasks('grunt-concat-css');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-uglify');
// Grunt task(s).
grunt.registerTask('default', ['create-sprites', 'css', 'js']);
grunt.registerTask('create-sprites', ['sprite']);
grunt.registerTask('css', ['concat_css', 'cssmin', 'clean:css']);
grunt.registerTask('js', ['concat:default','uglify', 'clean:js']);
};
+52 -53
View File
@@ -6,44 +6,44 @@ DOCKER_DB_CONTAINER_EXEC = $(DOCKER_COMPOSE) exec database
DOCKER_PHP_EXECUTABLE_CMD = php -dmemory_limit=1G
help: ## Show this help
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//'
all: start-recreate reinstall
start: ## Start app
$(DOCKER_COMPOSE) up -d
$(DOCKER_COMPOSE) up -d
ifeq (,$(wildcard ./src/bb-config.php))
cp ./src/bb-config-sample.php ./src/bb-config.php
$(DOCKER_PHP_CONTAINER_EXEC) $(DOCKER_PHP_EXECUTABLE_CMD) ./bin/prepare.php
cp ./src/bb-config-sample.php ./src/bb-config.php
$(DOCKER_PHP_CONTAINER_EXEC) $(DOCKER_PHP_EXECUTABLE_CMD) ./bin/prepare.php
endif
start-recreate: ## Start app with full rebuild
$(DOCKER_COMPOSE) up -d --build --force-recreate --remove-orphans
$(DOCKER_COMPOSE) up -d --build --force-recreate --remove-orphans
stop: ## Stop app
$(DOCKER_COMPOSE) stop
$(DOCKER_COMPOSE) stop
remove: stop ## Stop and remove app
$(DOCKER_COMPOSE) rm -f
$(DOCKER_COMPOSE) rm -f
logs: ## Show app logs
$(DOCKER_COMPOSE) logs -ft --tail=50
$(DOCKER_COMPOSE) logs -ft --tail=50
exec-php: ## Enter PHP container shell
$(DOCKER_PHP_CONTAINER_EXEC) bash
$(DOCKER_PHP_CONTAINER_EXEC) bash
cache-flush: ## Flush Twig cache
$(DOCKER_PHP_CONTAINER_EXEC) rm -fr src/bb-data/cache/*
$(DOCKER_PHP_CONTAINER_EXEC) rm -fr src/bb-data/cache/*
exec-db: ## Enter DB container shell
$(DOCKER_DB_CONTAINER_EXEC) bash
$(DOCKER_DB_CONTAINER_EXEC) bash
install: start ## Install app after start
$(DOCKER_PHP_CONTAINER_EXEC) composer install --working-dir=src --no-progress --no-suggest --prefer-dist --no-dev
$(DOCKER_PHP_CONTAINER_EXEC) composer install --working-dir=src --no-progress --no-suggest --prefer-dist --no-dev
reinstall: ## Reinstall app
rm -rf ./src/bb-config.php
make install
rm -rf ./src/bb-config.php
make install
test: start ## Run app tests
echo "Running unit tests"
@@ -54,52 +54,51 @@ test: start ## Run app tests
$(DOCKER_PHP_CONTAINER_EXEC) ./src/vendor/bin/phpunit --dont-report-useless-tests ./tests/bb-modules/
build: ## Build App with Docker CI image
docker run --rm \
--mount type=bind,source=$(PWD),target=/opt -w /opt \
-e TRAVIS_TAG \
fordnox/docker-builder-ci \
make release
docker run --rm \
--mount type=bind,source=$(PWD),target=/opt -w /opt \
-e TRAVIS_TAG \
fordnox/docker-builder-ci \
make release
release: ## App release
echo "TRAVIS_BUILD_NUMBER:" $(TRAVIS_BUILD_NUMBER)
echo "TRAVIS_TAG:" $(TRAVIS_TAG)
npm install -g grunt-cli
npm install
grunt
ant release
echo "TRAVIS_BUILD_NUMBER:" $(TRAVIS_BUILD_NUMBER)
echo "TRAVIS_TAG:" $(TRAVIS_TAG)
npm install
gulp build
ant release
revbump:
set -e ;\
git tag --sort=v:refname | tail -1
NEW_VERSION=$$( git tag --sort=v:refname | tail -1 | awk 'BEGIN{FS=OFS="."}{print $$1,$$2,$$3+1}' ) ;\
echo "unstable release $$NEW_VERSION" ;\
git tag $$NEW_VERSION
git push --tags
set -e ;\
git tag --sort=v:refname | tail -1
NEW_VERSION=$$( git tag --sort=v:refname | tail -1 | awk 'BEGIN{FS=OFS="."}{print $$1,$$2,$$3+1}' ) ;\
echo "unstable release $$NEW_VERSION" ;\
git tag $$NEW_VERSION
git push --tags
minorbump:
set -e ;\
git tag --sort=v:refname | tail -1
NEW_VERSION=$$( git tag --sort=v:refname | tail -1 | awk 'BEGIN{FS=OFS="."}{print $$1,$$2+1,0}' ) ;\
echo "unstable release $$NEW_VERSION" ;\
git tag $$NEW_VERSION
git push --tags
set -e ;\
git tag --sort=v:refname | tail -1
NEW_VERSION=$$( git tag --sort=v:refname | tail -1 | awk 'BEGIN{FS=OFS="."}{print $$1,$$2+1,0}' ) ;\
echo "unstable release $$NEW_VERSION" ;\
git tag $$NEW_VERSION
git push --tags
majorbump:
set -e ;\
git tag --sort=v:refname | tail -1
NEW_VERSION=$$( git tag --sort=v:refname | tail -1 | awk 'BEGIN{FS=OFS="."}{print $$1+1,0,0}' ) ;\
echo "release $$NEW_VERSION" ;\
git tag $$NEW_VERSION
git push --tags
set -e ;\
git tag --sort=v:refname | tail -1
NEW_VERSION=$$( git tag --sort=v:refname | tail -1 | awk 'BEGIN{FS=OFS="."}{print $$1+1,0,0}' ) ;\
echo "release $$NEW_VERSION" ;\
git tag $$NEW_VERSION
git push --tags
build-run: ## Run app in LAMP container after build
# used to test app after build
# run `make build` before running this target
# mysql user: admin pass: admin
# access phpmyadmin http://localhost/phpmyadmin/
docker container stop boxbilling &>/dev/null || true
docker container rm -f boxbilling &>/dev/null || true
docker run -i -t --name boxbilling -p "80:80" \
-v ${PWD}/build/source:/app \
-e MYSQL_ADMIN_PASS=admin \
mattrayner/lamp:latest
# used to test app after build
# run `make build` before running this target
# mysql user: admin pass: admin
# access phpmyadmin http://localhost/phpmyadmin/
docker container stop boxbilling &>/dev/null || true
docker container rm -f boxbilling &>/dev/null || true
docker run -i -t --name boxbilling -p "80:80" \
-v ${PWD}/build/source:/app \
-e MYSQL_ADMIN_PASS=admin \
mattrayner/lamp:latest
+40
View File
@@ -0,0 +1,40 @@
'use strict';
import gulp from 'gulp';
import chug from 'gulp-chug';
import yargs from 'yargs';
const { argv } = yargs
.options({
nodeModulesPath: {
'description': '<path> path to node_modules directory',
type: 'string',
requiresArgs: true,
required: false,
}
});
const config = [
'--node-modules-path',
argv.nodeModulesPath || '../../../node_modules',
];
export const buildThemeAdmin = function buildThemeAdmin() {
return gulp.src('src/bb-themes/admin_default/gulpfile.babel.js', { read: false })
.pipe(chug({ args: config, tasks: 'build' }));
}
buildThemeAdmin.description = 'Build theme Admin assets.';
export const buildThemeBootstrap = function buildThemeBootstrap() {
return gulp.src('src/bb-themes/bootstrap/gulpfile.babel.js', { read: false })
.pipe(chug({ args: config, tasks: 'build' }));
}
buildThemeBootstrap.description = 'Build theme Bootstrap assets.';
export const build = gulp.parallel(buildThemeAdmin, buildThemeBootstrap);
build.description = 'Build assets.';
gulp.task('bootstrap', buildThemeAdmin);
gulp.task('bootstrap', buildThemeBootstrap);
export default build;
+10583 -1097
View File
File diff suppressed because it is too large. Load diff
+30 -7
View File
@@ -11,13 +11,36 @@
"issues": {
"url" : "https://github.com/FOSSBilling/FOSSBilling/issues"
},
"dependencies": {
"@tabler/core": "^1.0.0-beta9",
"autoprefixer": "^10.4.6",
"postcss": "^8.4.13",
"sass": "^1.51.0"
},
"devDependencies": {
"grunt": "^1.5.2",
"grunt-concat-css": "*",
"grunt-contrib-clean": "*",
"grunt-contrib-concat": "*",
"grunt-contrib-cssmin": "^4.0.0",
"grunt-contrib-uglify": "^5.2.1",
"grunt-spritesmith": "^6.10.0"
"@fortawesome/fontawesome-free": "^6.1.1",
"apexcharts": "^3.35.2",
"babel-core": "^6.26.3",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-register": "^6.26.0",
"bootstrap": "^5.1.3",
"bootstrap-markdown": "^2.10.0",
"gulp": "^4.0.2",
"gulp-autoprefixer": "^8.0.0",
"gulp-chug": "^0.5.1",
"gulp-concat": "^2.6.1",
"gulp-postcss": "^9.0.1",
"gulp-sass": "^5.1.0",
"gulp-uglify": "^3.0.2",
"gulp-uglifycss": "^1.1.0",
"gulp.spritesmith": "^6.12.1",
"jquery": "^3.6.0",
"upath": "^2.0.1",
"yargs": "^17.4.1"
},
"scripts": {
"build": "gulp build",
"watch": "gulp watch"
}
}
+123 -101
View File
@@ -1,6 +1,7 @@
<?php
/**
* BoxBilling
* BoxBilling.
*
* @copyright BoxBilling, Inc (https://www.boxbilling.org)
* @license Apache-2.0
@@ -10,24 +11,23 @@
* with this source code in the file LICENSE
*/
use Box\InjectionAwareInterface;
class Box_App {
protected $mappings = array();
protected $before_filters = array();
protected $after_filters = array();
protected $shared = array();
class Box_App
{
protected $mappings = [];
protected $before_filters = [];
protected $after_filters = [];
protected $shared = [];
protected $options;
protected $di = NULL;
protected $ext = 'phtml';
protected $mod = 'index';
protected $url = '/';
protected $di = null;
protected $ext = 'html.twig';
protected $mod = 'index';
protected $url = '/';
public $uri = NULL;
public $uri = null;
public function __construct($options=array())
public function __construct($options = [])
{
$this->options = new ArrayObject($options);
}
@@ -44,20 +44,20 @@ class Box_App {
protected function registerModule()
{
//bind module urls and process
//determine module and bind urls
// bind module urls and process
// determine module and bind urls
$requestUri = $this->url;
if(empty($requestUri)) {
if (empty($requestUri)) {
$requestUri = '/';
}
if($requestUri == '/') {
if ('/' == $requestUri) {
$mod = 'index';
} else {
$requestUri = trim($requestUri, '/');
if(strpos($requestUri, '/') === false) {
if (false === strpos($requestUri, '/')) {
$mod = $requestUri;
} else {
list($mod) = explode('/',$requestUri);
[$mod] = explode('/', $requestUri);
}
}
$mod = filter_var($mod, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_HIGH);
@@ -66,12 +66,16 @@ class Box_App {
$this->uri = $requestUri;
}
protected function init(){}
protected function init()
{
}
public function show404(Exception $e) {
public function show404(Exception $e)
{
error_log($e->getMessage());
header("HTTP/1.0 404 Not Found");
return $this->render('404', array('exception'=>$e));
header('HTTP/1.0 404 Not Found');
return $this->render('404', ['exception' => $e]);
}
/**
@@ -79,8 +83,9 @@ class Box_App {
* @param string $methodName
* @param string $class
*/
public function get($url, $methodName, $conditions = array(), $class = null) {
$this->event('get', $url, $methodName, $conditions, $class);
public function get($url, $methodName, $conditions = [], $class = null)
{
$this->event('get', $url, $methodName, $conditions, $class);
}
/**
@@ -88,48 +93,55 @@ class Box_App {
* @param string $methodName
* @param string $class
*/
public function post($url, $methodName, $conditions = array(), $class = null) {
$this->event('post', $url, $methodName, $conditions, $class);
public function post($url, $methodName, $conditions = [], $class = null)
{
$this->event('post', $url, $methodName, $conditions, $class);
}
public function put($url, $methodName, $conditions = array(), $class = null) {
$this->event('put', $url, $methodName, $conditions, $class);
public function put($url, $methodName, $conditions = [], $class = null)
{
$this->event('put', $url, $methodName, $conditions, $class);
}
public function delete($url, $methodName, $conditions = array(), $class = null) {
$this->event('delete', $url, $methodName, $conditions, $class);
public function delete($url, $methodName, $conditions = [], $class = null)
{
$this->event('delete', $url, $methodName, $conditions, $class);
}
public function before($methodName, $filterName) {
public function before($methodName, $filterName)
{
$this->push_filter($this->before_filters, $methodName, $filterName);
}
public function after($methodName, $filterName) {
public function after($methodName, $filterName)
{
$this->push_filter($this->after_filters, $methodName, $filterName);
}
protected function push_filter(&$arr_filter, $methodName, $filterName) {
protected function push_filter(&$arr_filter, $methodName, $filterName)
{
if (!is_array($methodName)) {
$methodName = explode('|', $methodName);
}
$counted = count($methodName);
for ($i = 0; $i < $counted; $i++) {
for ($i = 0; $i < $counted; ++$i) {
$method = $methodName[$i];
if (!isset($arr_filter[$method])) {
$arr_filter[$method] = array();
$arr_filter[$method] = [];
}
array_push($arr_filter[$method], $filterName);
}
}
protected function run_filter($arr_filter, $methodName) {
if(isset($arr_filter[$methodName])) {
protected function run_filter($arr_filter, $methodName)
{
if (isset($arr_filter[$methodName])) {
$counted = count($arr_filter[$methodName]);
for ($i=0; $i < $counted; $i++) {
$return = call_user_func(array($this, $arr_filter[$methodName][$i]));
for ($i = 0; $i < $counted; ++$i) {
$return = call_user_func([$this, $arr_filter[$methodName][$i]]);
if(!is_null($return)) {
if (!is_null($return)) {
return $return;
}
}
@@ -140,6 +152,7 @@ class Box_App {
{
$this->registerModule();
$this->init();
return $this->processRequest();
}
@@ -156,42 +169,45 @@ class Box_App {
/**
* @param string $fileName
*/
public function render($fileName, $variableArray = array())
public function render($fileName, $variableArray = [])
{
print 'Rendering '.$fileName;
echo 'Rendering ' . $fileName;
}
public function sendFile($filename, $contentType, $path) {
public function sendFile($filename, $contentType, $path)
{
header("Content-type: $contentType");
header("Content-Disposition: attachment; filename=$filename");
return readfile($path);
}
public function sendDownload($filename, $path) {
header("Content-Type: application/force-download");
header("Content-Type: application/octet-stream");
header("Content-Type: application/download");
header("Content-Description: File Transfer");
header("Content-Disposition: attachment; filename=$filename".";");
header("Content-Transfer-Encoding: binary");
public function sendDownload($filename, $path)
{
header('Content-Type: application/force-download');
header('Content-Type: application/octet-stream');
header('Content-Type: application/download');
header('Content-Description: File Transfer');
header("Content-Disposition: attachment; filename=$filename" . ';');
header('Content-Transfer-Encoding: binary');
return readfile($path);
}
protected function executeShared($classname, $methodName, $params)
{
$class = new $classname();
if($class instanceof InjectionAwareInterface) {
if ($class instanceof InjectionAwareInterface) {
$class->setDi($this->di);
}
$reflection = new ReflectionMethod(get_class($class), $methodName);
$args = array();
$args = [];
$args[] = $this; // first param always app instance
foreach($reflection->getParameters() as $param) {
if(isset($params[$param->name])) {
foreach ($reflection->getParameters() as $param) {
if (isset($params[$param->name])) {
$args[$param->name] = $params[$param->name];
}
else if($param->isDefaultValueAvailable()) {
} elseif ($param->isDefaultValueAvailable()) {
$args[$param->name] = $param->getDefaultValue();
}
}
@@ -199,20 +215,20 @@ class Box_App {
return $reflection->invokeArgs($class, $args);
}
protected function execute($methodName, $params, $classname = null) {
protected function execute($methodName, $params, $classname = null)
{
$return = $this->run_filter($this->before_filters, $methodName);
if (!is_null($return)) {
return $return;
return $return;
}
$reflection = new ReflectionMethod(get_class($this), $methodName);
$args = array();
$args = [];
foreach($reflection->getParameters() as $param) {
if(isset($params[$param->name])) {
foreach ($reflection->getParameters() as $param) {
if (isset($params[$param->name])) {
$args[$param->name] = $params[$param->name];
}
else if($param->isDefaultValueAvailable()) {
} elseif ($param->isDefaultValueAvailable()) {
$args[$param->name] = $param->getDefaultValue();
}
}
@@ -221,7 +237,7 @@ class Box_App {
$return = $this->run_filter($this->after_filters, $methodName);
if (!is_null($return)) {
return $return;
return $return;
}
return $response;
@@ -230,18 +246,19 @@ class Box_App {
/**
* @param string $httpMethod
*/
protected function event($httpMethod, $url, $methodName, $conditions=array(), $classname = null) {
protected function event($httpMethod, $url, $methodName, $conditions = [], $classname = null)
{
if (method_exists($this, $methodName)) {
array_push($this->mappings, array($httpMethod, $url, $methodName, $conditions));
array_push($this->mappings, [$httpMethod, $url, $methodName, $conditions]);
}
if (null !== $classname) {
array_push($this->shared, array($httpMethod, $url, $methodName, $conditions, $classname));
array_push($this->shared, [$httpMethod, $url, $methodName, $conditions, $classname]);
}
}
/**
* Check if the requested URL is in the allowlist.
*
*
* @since 4.22.0
*/
protected function checkAllowedURLs()
@@ -249,54 +266,57 @@ class Box_App {
$REQUEST_URI = $this->di['request']->getServer('REQUEST_URI');
$allowedURLs = $this->di['config']['maintenance_mode']['allowed_urls'];
$rootUrl = $this->di['config']['url'];
// Allow access to the staff panel all the time
$adminApiPrefixes = [
"/api/guest/staff/login",
"/api/admin",
'/api/guest/staff/login',
'/api/admin',
];
foreach ($adminApiPrefixes as $adminApiPrefix){
$realAdminApiUrl = $rootUrl [-1] === '/' ? substr($rootUrl, 0 ,-1).$adminApiPrefix : $rootUrl.$adminApiPrefix;
foreach ($adminApiPrefixes as $adminApiPrefix) {
$realAdminApiUrl = '/' === $rootUrl[-1] ? substr($rootUrl, 0, -1) . $adminApiPrefix : $rootUrl . $adminApiPrefix;
$allowedURLs[] = parse_url($realAdminApiUrl)['path'];
}
foreach ($allowedURLs as $url){
if (preg_match('/^'.str_replace('/','\/', $url).'(.*)/', $REQUEST_URI) !== 0){
foreach ($allowedURLs as $url) {
if (0 !== preg_match('/^' . str_replace('/', '\/', $url) . '(.*)/', $REQUEST_URI)) {
return false;
}
}
return true;
}
/**
* Check if the visitor IP is in the allowlist.
*
*
* @since 4.22.0
*/
protected function checkAllowedIPs()
{
$allowedIPs = $this->di['config']['maintenance_mode']['allowed_ips'];
$allowedIPs = $this->di['config']['maintenance_mode']['allowed_ips'];
$visitorIP = $this->di['request']->getClientAddress();
// Check if the visitor is in using of the allowed IPs/networks
foreach ($allowedIPs as $network)
{
if(strpos($network, '/') == false){$network .= '/32';}
list($network, $netmask) = explode('/', $network, 2);
foreach ($allowedIPs as $network) {
if (false == strpos($network, '/')) {
$network .= '/32';
}
[$network, $netmask] = explode('/', $network, 2);
$network_decimal = ip2long($network);
$ip_decimal = ip2long($visitorIP);
$wildcard_decimal = pow(2, (32 - $netmask)) - 1;
$netmask_decimal = ~ $wildcard_decimal;
if(($ip_decimal & $netmask_decimal) == ($network_decimal & $netmask_decimal)){
$netmask_decimal = ~$wildcard_decimal;
if (($ip_decimal & $netmask_decimal) == ($network_decimal & $netmask_decimal)) {
return false;
}
}
return true;
}
/**
* Check if the requested URL is a part of the admin area.
*
*
* @since 4.22.0
*/
protected function checkAdminPrefix()
@@ -305,12 +325,13 @@ class Box_App {
$adminPrefix = $this->di['config']['admin_area_prefix'];
$rootUrl = $this->di['config']['url'];
$realAdminUrl = $rootUrl[-1] === '/' ? substr($rootUrl, 0 ,-1).$adminPrefix : $rootUrl.$adminPrefix;
$realAdminUrl = '/' === $rootUrl[-1] ? substr($rootUrl, 0, -1) . $adminPrefix : $rootUrl . $adminPrefix;
$realAdminPath = parse_url($realAdminUrl)['path'];
if (preg_match('/^'.str_replace('/','\/', $realAdminPath).'(.*)/', $REQUEST_URI) !== 0) {
if (0 !== preg_match('/^' . str_replace('/', '\/', $realAdminPath) . '(.*)/', $REQUEST_URI)) {
return false;
}
return true;
}
@@ -319,18 +340,18 @@ class Box_App {
/**
* Block requests if the system is undergoing maintenance.
* It will respect any URL/IP whitelisting under the configuration file.
*
*
* @since 4.22.0
*/
if($this->di['config']['maintenance_mode']['enabled'] === true)
{
if (true === $this->di['config']['maintenance_mode']['enabled']) {
// Check the allowlists
if($this->checkAdminPrefix() && $this->checkAllowedURLs() && $this->checkAllowedIPs()) {
if ($this->checkAdminPrefix() && $this->checkAllowedURLs() && $this->checkAllowedIPs()) {
// Set response code to 503.
header("HTTP/1.0 503 Service Unavailable");
header('HTTP/1.0 503 Service Unavailable');
if($this->mod == "api") {
if ('api' == $this->mod) {
$exc = new \Box_Exception('The system is undergoing maintenance. Please try again later.', [], 503);
return (new \Box\Mod\Api\Controller\Client())->renderJson(null, $exc);
} else {
return $this->render('mod_system_maintenance');
@@ -339,25 +360,26 @@ class Box_App {
}
$sharedCount = count($this->shared);
for($i = 0; $i < $sharedCount; $i++) {
for ($i = 0; $i < $sharedCount; ++$i) {
$mapping = $this->shared[$i];
$url = new Box_UrlHelper($mapping[0], $mapping[1], $mapping[3], $this->url);
if($url->match) {
if ($url->match) {
return $this->executeShared($mapping[4], $mapping[2], $url->params);
}
}
// this class mappings
$mappingsCount = count($this->mappings);
for($i = 0; $i < $mappingsCount; $i++) {
for ($i = 0; $i < $mappingsCount; ++$i) {
$mapping = $this->mappings[$i];
$url = new Box_UrlHelper($mapping[0], $mapping[1], $mapping[3], $this->url);
if($url->match) {
if ($url->match) {
return $this->execute($mapping[2], $url->params);
}
}
$e = new \Box_Exception('Page :url not found', array(':url'=>$this->url), 404);
$e = new \Box_Exception('Page :url not found', [':url' => $this->url], 404);
return $this->show404($e);
}
@@ -384,4 +406,4 @@ class Box_App {
{
return $this->di['api_guest'];
}
}
}
+12 -11
View File
@@ -1,6 +1,7 @@
<?php
/**
* BoxBilling
* BoxBilling.
*
* @copyright BoxBilling, Inc (https://www.boxbilling.org)
* @license Apache-2.0
@@ -10,7 +11,6 @@
* with this source code in the file LICENSE
*/
class Box_AppAdmin extends Box_App
{
public function init()
@@ -20,9 +20,10 @@ class Box_AppAdmin extends Box_App
$controller->register($this);
}
public function render($fileName, $variableArray = array())
public function render($fileName, $variableArray = [])
{
$template = $this->getTwig()->load($fileName.'.phtml');
$template = $this->getTwig()->load($fileName . '.html.twig');
return $template->render($variableArray);
}
@@ -38,11 +39,11 @@ class Box_AppAdmin extends Box_App
$service = $this->di['mod_service']('theme');
$theme = $service->getCurrentAdminAreaTheme();
$loader = new Box_TwigLoader(array(
"mods" => BB_PATH_MODS,
"theme" => BB_PATH_THEMES . DIRECTORY_SEPARATOR . $theme['code'],
"type" => "admin"
)
$loader = new Box_TwigLoader([
'mods' => BB_PATH_MODS,
'theme' => BB_PATH_THEMES . DIRECTORY_SEPARATOR . $theme['code'],
'type' => 'admin',
]
);
$twig = $this->di['twig'];
@@ -50,10 +51,10 @@ class Box_AppAdmin extends Box_App
$twig->addGlobal('theme', $theme);
if($this->di['auth']->isAdminLoggedIn()) {
if ($this->di['auth']->isAdminLoggedIn()) {
$twig->addGlobal('admin', $this->di['api_admin']);
}
return $twig;
}
}
}
+32 -31
View File
@@ -1,6 +1,7 @@
<?php
/**
* BoxBilling
* BoxBilling.
*
* @copyright BoxBilling, Inc (https://www.boxbilling.org)
* @license Apache-2.0
@@ -10,7 +11,6 @@
* with this source code in the file LICENSE
*/
class Box_AppClient extends Box_App
{
protected function init()
@@ -18,8 +18,8 @@ class Box_AppClient extends Box_App
$m = $this->di['mod']($this->mod);
$m->registerClientRoutes($this);
if($this->mod == 'api') {
define ('BB_MODE_API', TRUE);
if ('api' == $this->mod) {
define('BB_MODE_API', true);
} else {
$extensionService = $this->di['mod_service']('extension');
if ($extensionService->isExtensionActive('mod', 'redirect')) {
@@ -27,14 +27,13 @@ class Box_AppClient extends Box_App
$m->registerClientRoutes($this);
}
//init index module manually
// init index module manually
$this->get('', 'get_index');
$this->get('/', 'get_index');
//init custom methods for undefined pages
$this->get('/:page', 'get_custom_page', array('page' => '[a-z0-9-/.//]+'));
$this->post('/:page', 'get_custom_page', array('page' => '[a-z0-9-/.//]+'));
// init custom methods for undefined pages
$this->get('/:page', 'get_custom_page', ['page' => '[a-z0-9-/.//]+']);
$this->post('/:page', 'get_custom_page', ['page' => '[a-z0-9-/.//]+']);
}
}
@@ -46,38 +45,40 @@ class Box_AppClient extends Box_App
public function get_custom_page($page)
{
$ext = $this->ext;
if(strpos($page, '.') !== false) {
$ext = substr($page, strpos($page, '.')+1);
if (false !== strpos($page, '.')) {
$ext = substr($page, strpos($page, '.') + 1);
$page = substr($page, 0, strpos($page, '.'));
}
$page = str_replace('/', '_', $page);
$tpl = 'mod_page_'.$page;
$tpl = 'mod_page_' . $page;
try {
return $this->render($tpl, array('post'=>$_POST), $ext);
} catch(Exception $e) {
if(BB_DEBUG){
return $this->render($tpl, ['post' => $_POST], $ext);
} catch (Exception $e) {
if (BB_DEBUG) {
error_log($e);
}
}
// throw new \Box_Exception('Page :url not found', array(':url'=>$page), 404);
$e = new \Box_Exception('Page :url not found', array(':url'=>$this->url), 404);
error_log($e->getMessage());
header("HTTP/1.0 404 Not Found");
return $this->render('404', array('exception'=>$e));
// throw new \Box_Exception('Page :url not found', array(':url'=>$page), 404);
$e = new \Box_Exception('Page :url not found', [':url' => $this->url], 404);
error_log($e->getMessage());
header('HTTP/1.0 404 Not Found');
return $this->render('404', ['exception' => $e]);
}
/**
* @param string $fileName
*/
public function render($fileName, $variableArray = array(), $ext = 'phtml')
public function render($fileName, $variableArray = [], $ext = 'html.twig')
{
try {
$template = $this->getTwig()->load($fileName.'.'.$ext);
$template = $this->getTwig()->load($fileName . '.' . $ext);
} catch (Twig\Error\LoaderError $e) {
error_log($e->getMessage());
throw new \Box_Exception('Page not found', null, 404);
}
return $template->render($variableArray);
}
@@ -88,11 +89,11 @@ class Box_AppClient extends Box_App
$theme = $service->getTheme($code);
$settings = $service->getThemeSettings($theme);
$loader = new Box_TwigLoader(array(
"mods" => BB_PATH_MODS,
"theme" => BB_PATH_THEMES.DIRECTORY_SEPARATOR.$code,
"type" => "client"
)
$loader = new Box_TwigLoader([
'mods' => BB_PATH_MODS,
'theme' => BB_PATH_THEMES . DIRECTORY_SEPARATOR . $code,
'type' => 'client',
]
);
$twig = $this->di['twig'];
@@ -101,14 +102,14 @@ class Box_AppClient extends Box_App
$twig->addGlobal('current_theme', $code);
$twig->addGlobal('settings', $settings);
if($this->di['auth']->isClientLoggedIn()) {
if ($this->di['auth']->isClientLoggedIn()) {
$twig->addGlobal('client', $this->di['api_client']);
}
if($this->di['auth']->isAdminLoggedIn()) {
if ($this->di['auth']->isAdminLoggedIn()) {
$twig->addGlobal('admin', $this->di['api_admin']);
}
return $twig;
}
}
}
+15 -15
View File
@@ -1,4 +1,5 @@
<?php
/**
* BoxBilling
*
@@ -10,7 +11,6 @@
* with this source code in the file LICENSE
*/
class Box_Mod
{
private $mod = null;
@@ -49,7 +49,7 @@ class Box_Mod
'orderbutton',
'formbuilder',
);
/**
* @param string $mod
*/
@@ -71,7 +71,7 @@ class Box_Mod
{
return file_exists($this->_getModPath() . 'manifest.json');
}
public function getManifest()
{
if(!$this->hasManifest()) {
@@ -100,7 +100,7 @@ class Box_Mod
"minimum_boxbilling_version" => NULL,
"maximum_boxbilling_version" => NULL,
);
$info = array_merge($info, $json);
$info['id'] = $this->mod;
$info['type'] = 'mod';
@@ -111,7 +111,7 @@ class Box_Mod
return $info;
}
public function hasService($sub = '')
{
$filename = sprintf('Service%s.php', ucfirst($sub));
@@ -130,12 +130,12 @@ class Box_Mod
}
return $service;
}
public function hasClientController()
{
return file_exists($this->_getModPath() . 'Controller/Client.php');
}
public function getClientController()
{
if(!$this->hasClientController()) {
@@ -152,14 +152,14 @@ class Box_Mod
public function hasSettingsPage()
{
return file_exists($this->_getModPath() . 'html_admin/mod_'.$this->mod.'_settings.phtml');
return file_exists($this->_getModPath() . 'html_admin/mod_'.$this->mod.'_settings.html.twig');
}
public function hasAdminController()
{
return file_exists($this->_getModPath() . 'Controller/Admin.php');
}
public function getAdminController()
{
if(!$this->hasAdminController()) {
@@ -189,7 +189,7 @@ class Box_Mod
return false;
}
public function uninstall()
{
if($this->isCore()) {
@@ -205,13 +205,13 @@ class Box_Mod
}
return false;
}
public function update()
{
if($this->isCore()) {
throw new \Box_Exception('Core module can not be updated');
}
if($this->hasService()) {
$s = $this->getService();
if(method_exists($s, 'update')) {
@@ -222,17 +222,17 @@ class Box_Mod
}
return false;
}
public function getCoreModules()
{
return $this->core;
}
public function isCore()
{
return in_array($this->mod, $this->core);
}
public function getConfig()
{
$db = $this->di['db'];
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}Client settings{% endblock %}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}{{ 'Payments history'|trans }}{% endblock %}
{% block breadcrumb %} <li class="active">{{ 'Payments history'|trans }}</li>{% endblock %}
@@ -47,7 +47,7 @@
</tr>
</tfoot>
</table>
{% include "partial_pagination.phtml" with { 'list': transactions } %}
{% include "partial_pagination.html.twig" with { 'list': transactions } %}
<div class="row-fluid">
<div class="span3">
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% block meta_title %}{{ 'Profile details'|trans }}{% endblock %}
{% block page_header %}{{ 'User profile settings'|trans }}{% endblock %}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}Cookie consent settings{% endblock %}
@@ -13,7 +13,7 @@
</div>
<div class="help">
<p>{{ 'Here you can specify message which will be shown to user. It will be shown until user will click <strong>Close &times;</strong> button, however it will not be intrusive and will not disturb to perform any actions.'|trans }}</p>
<p>{{ 'If there is a need to change the way notification looks or is being displayed, you can do it by editing'|trans }} <strong>src/bb-modules/Cookieconsent/html_client/mod_cookieconsent_index.phtml</strong></p>
<p>{{ 'If there is a need to change the way notification looks or is being displayed, you can do it by editing'|trans }} <strong>src/bb-modules/Cookieconsent/html_client/mod_cookieconsent_index.html.twig</strong></p>
</div>
{% set params = admin.extension_config_get({"ext":"mod_cookieconsent"}) %}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}{{ 'Cron settings'|trans }}{% endblock %}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% set active_menu = 'system' %}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% set active_menu = 'system' %}
{% block meta_title %}{{ 'Currency settings'|trans }}{% endblock %}
@@ -1,5 +1,5 @@
{% import "macro_functions.phtml" as mf %}
{% extends "layout_default.phtml" %}
{% import "macro_functions.html.twig" as mf %}
{% extends "layout_default.html.twig" %}
{% set active_menu = 'extensions' %}
{% block meta_title %}{{ 'Custom Pages'|trans }}{% endblock %}
@@ -49,8 +49,8 @@
</tbody>
</table>
{% include "partial_batch_delete.phtml" with {'action' : 'admin/custompages/batch_delete'} %}
{% include "partial_pagination.phtml" with {'list': pages, 'url':'custompages'} %}
{% include "partial_batch_delete.html.twig" with {'action' : 'admin/custompages/batch_delete'} %}
{% include "partial_pagination.html.twig" with {'list': pages, 'url':'custompages'} %}
</div>
<div class="fix"></div>
@@ -1,6 +1,6 @@
{% extends "layout_default.phtml" %}
{% extends "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% set active_menu = 'extensions' %}
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% block meta_title %}{{ page.title }}{% endblock %}
{% block meta_description %}{{ page.description }}{% endblock %}
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% block meta_title %}{{ 'Client Area'|trans }}{% endblock %}
{% block page_header %}{{ 'Dashboard'|trans }}{% endblock %}
@@ -12,7 +12,7 @@
{% endif %}
{% endblock %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block content %}
+2 -1
View File
@@ -1,4 +1,5 @@
<?php
/**
* BoxBilling.
*
@@ -389,7 +390,7 @@ class Admin extends \Api_Abstract
/**
* Send email template to email, client or staff members. If template with code does not exist,
* it will be created. Default email template file must exist at mod_example/html_email/mod_example_code.phtml file.
* it will be created. Default email template file must exist at mod_example/html_email/mod_example_code.html.twig file.
*
* @param string $code - Template code to send. Must be mod_%s_%s structure
*
+3 -2
View File
@@ -1,4 +1,5 @@
<?php
/**
* BoxBilling.
*
@@ -225,7 +226,7 @@ class Service implements \Box\InjectionAwareInterface
$matches = [];
preg_match('/mod_([a-zA-Z0-9]+)_([a-zA-Z0-9]+)/i', $code, $matches);
$mod = $matches[1];
$path = BB_PATH_MODS.'/'.ucfirst($mod).'/html_email/'.$code.'.phtml';
$path = BB_PATH_MODS.'/'.ucfirst($mod).'/html_email/'.$code.'.html.twig';
if (file_exists($path)) {
$tpl = file_get_contents($path);
@@ -471,7 +472,7 @@ class Service implements \Box\InjectionAwareInterface
public function templateBatchGenerate()
{
$pattern = BB_PATH_MODS.'/*/html_email/*.phtml';
$pattern = BB_PATH_MODS.'/*/html_email/*.html.twig';
$list = glob($pattern);
foreach ($list as $path) {
$code = pathinfo($path, PATHINFO_FILENAME);
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% set active_menu = 'activity' %}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}{{ 'Email history'|trans }}{% endblock %}
@@ -57,6 +57,6 @@
</table>
</div>
{% include "partial_batch_delete.phtml" with { 'action': 'admin/email/batch_delete' } %}
{% include "partial_pagination.phtml" with { 'list': emails, 'url': 'email/history' } %}
{% include "partial_batch_delete.html.twig" with { 'action': 'admin/email/batch_delete' } %}
{% include "partial_pagination.html.twig" with { 'list': emails, 'url': 'email/history' } %}
{% endblock %}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}{{ 'Email'|trans }}{% endblock %}
{% block breadcrumbs %}
@@ -1,4 +1,4 @@
{% extends "layout_default.phtml" %}
{% extends "layout_default.html.twig" %}
{% block meta_title %}Email template{% endblock %}
{% set active_menu = 'system' %}
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% block meta_title %}{{ 'Email'|trans }}{% endblock %}
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% block meta_title %}{{ 'Emails'|trans }}{% endblock %}
{% block breadcrumb %} <li class="active">{{ 'Emails'|trans }}</li>{% endblock %}
@@ -46,7 +46,7 @@
{% endfor %}
</div>
</div>
{% include "partial_pagination.phtml" with {'list': emails} %}
{% include "partial_pagination.html.twig" with {'list': emails} %}
{% endif %}
</section>
</div>
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% block meta_title %}Embed parts of BoxBilling{% endblock %}
{% set active_menu = 'system' %}
+3 -3
View File
@@ -15,8 +15,8 @@ All modules can communicate with the other modules using their API endpoints.
## Optional
* **README.md** - file for installation and getting started instructions
* **html_admin** folder - for admin area templates, to store custom *.phtml files
* **html_client** folder - for client area templates, to store custom *.phtml files
* **html_admin** folder - for admin area templates, to store custom *.html.twig files
* **html_client** folder - for client area templates, to store custom *.html.twig files
###### Controller folder
* **Admin.php** - if the module has install/uninstall instructions or
an admin area interface
@@ -27,4 +27,4 @@ All modules can communicate with the other modules using their API endpoints.
* **Guest.php** - Guest API, no authorization is needed for these endpoints. Don't provide confidential data over these endpoints. Anybody over the internet will be able to access these information, including bots.
# Tips
We recommend hosting your extensions on a public [GitHub](https://github.com) repository.
We recommend hosting your extensions on a public [GitHub](https://github.com) repository.
+2 -1
View File
@@ -1,4 +1,5 @@
<?php
/**
* BoxBilling.
*
@@ -240,7 +241,7 @@ class Service
$email = array();
$email['to_client'] = $params['client_id'];
$email['code'] = 'mod_example_email'; //@see bb-modules/Example/html_email/mod_example_email.phtml
$email['code'] = 'mod_example_email'; //@see bb-modules/Example/html_email/mod_example_email.html.twig
// these parameters are available in email template
$email['order'] = $api->order_get(array('id'=>$params['id']));
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% block meta_title %}{{ 'Example module'|trans }}{% endblock %}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}Example extension settings{% endblock %}
@@ -25,7 +25,7 @@
<form method="post" action="{{ 'api/admin/extension/config_save'|link }}" class="mainForm api-form" data-api-msg="{{ 'Configuration updated'|trans }}">
<div class="help">
<h3>{{ 'Example extension settings'|trans }}</h3>
<p>{{ 'Every extension can have settings page. Only requirement is to have mod_example_settings.phtml page in html_admin folder'|trans }}</p>
<p>{{ 'Every extension can have settings page. Only requirement is to have mod_example_settings.html.twig page in html_admin folder'|trans }}</p>
</div>
<fieldset>
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% block meta_title %}{{ 'Example module'|trans }}{% endblock %}
{% block breadcrumb %} <li class="active">{{ 'Example module'|trans }}</li>{% endblock %}
@@ -1,8 +1,8 @@
{# {% if guest.extension_is_on({ "mod": "formbuilder" }) %} #}
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}Custom form builder{% endblock %}
@@ -178,8 +178,8 @@
<fieldset>
{% for i,field in form.fields %}
<div class="wrap-field">
{% include 'mod_formbuilder_field.phtml' with field %}
{% include 'mod_formbuilder_preview.phtml' with field %}
{% include 'mod_formbuilder_field.html.twig' with field %}
{% include 'mod_formbuilder_preview.html.twig' with field %}
</div>
{% endfor %}
</fieldset>
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% set active_menu = 'support' %}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% set active_menu = 'support' %}
@@ -52,7 +52,7 @@
{% endfor %}
</tbody>
</table>
{% include "partial_pagination.phtml" with { 'list': posts, 'url': 'forum' } %}
{% include "partial_pagination.html.twig" with { 'list': posts, 'url': 'forum' } %}
</div>
<div class="tab_content nopadding" id="tab-topics">
@@ -93,7 +93,7 @@
{% endfor %}
</tbody>
</table>
{% include "partial_pagination.phtml" with { 'list': topics, 'url': 'forum' } %}
{% include "partial_pagination.html.twig" with { 'list': topics, 'url': 'forum' } %}
</div>
<div class="tab_content nopadding" id="tab-new">
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}Forum - Client profile{% endblock %}
@@ -116,7 +116,7 @@
{% endfor %}
</tbody>
</table>
{% include "partial_pagination.phtml" with { 'list': posts, 'url': 'profile/'~client_id } %}
{% include "partial_pagination.html.twig" with { 'list': posts, 'url': 'profile/'~client_id } %}
</div>
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}{{ 'Forum settings'|trans }}{% endblock %}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% set active_menu = 'support' %}
@@ -232,7 +232,7 @@
</div>
{% endfor %}
</div>
{% include "partial_pagination.phtml" with { 'list': messages, 'url': 'forum/topic/'~topic.id } %}
{% include "partial_pagination.html.twig" with { 'list': messages, 'url': 'forum/topic/'~topic.id } %}
{% endblock %}
{% block head %}{{ mf.bb_editor('.bb-textarea') }}{% endblock %}
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% block meta_title %}{{ forum.title }}{% endblock %}
@@ -81,7 +81,7 @@
</article>
</div>
{% include "partial_pagination.phtml" with {'list': topics} %}
{% include "partial_pagination.html.twig" with {'list': topics} %}
<div class="modal hide fade" id="new-topic-modal">
<div class="modal-header">
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% block meta_title %}{{ 'Forum'|trans }}{% endblock %}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}{{ 'Forum members'|trans }}{% endblock %}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}{{ topic.title }}{% endblock %}
{% block meta_description%}{{ topic.first.message|truncate(200) }}{% endblock %}
@@ -87,7 +87,7 @@
{% else %}
<div class="alert alert-info">{{ 'No replies in this topic'|trans }}</div>
{% endfor %}
{% include "partial_pagination.phtml" with { 'list': messages } %}
{% include "partial_pagination.html.twig" with { 'list': messages } %}
</section>
</div>
</article>
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% block meta_title %}{{ 'Client Area'|trans }}{% endblock %}
{% block page_header %}{{ 'Dashboard'|trans }}{% endblock %}
@@ -12,7 +12,7 @@
{% endif %}
{% endblock %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block content %}
{% if settings.showcase_enabled %}
+84 -76
View File
@@ -100,7 +100,7 @@ class Service implements InjectionAwareInterface
if (null !== $client) {
$sql .= ' AND (cl.first_name LIKE :client_search OR cl.last_name LIKE :client_search OR cl.id = :client OR cl.email = :client)';
$params['client_search'] = $client.'%';
$params['client_search'] = $client . '%';
$params['client'] = $client;
}
@@ -127,7 +127,7 @@ class Service implements InjectionAwareInterface
if ($search) {
$sql .= ' AND (p.id = :int OR p.nr LIKE :search_like OR p.id LIKE :search OR pi.title LIKE :search_like)';
$params['int'] = (int) preg_replace('/[^0-9]/', '', $search);
$params['search_like'] = '%'.$search.'%';
$params['search_like'] = '%' . $search . '%';
$params['search'] = $search;
}
@@ -179,7 +179,7 @@ class Service implements InjectionAwareInterface
$result['nr'] = $row['nr'];
$nr = (is_numeric($result['nr'])) ? $result['nr'] : $result['id'];
$result['serie_nr'] = $result['serie'].sprintf('%05s', $nr);
$result['serie_nr'] = $result['serie'] . sprintf('%05s', $nr);
$result['hash'] = $row['hash'];
$result['gateway_id'] = $row['gateway_id'];
@@ -222,7 +222,7 @@ class Service implements InjectionAwareInterface
'company' => !empty($row['seller_company']) ? $row['seller_company'] : $c['name'],
'company_vat' => $row['seller_company_vat'],
'company_number' => $row['seller_company_number'],
'address' => !empty($row['seller_address']) ? $row['seller_address'] : trim($c['address_1'].' '.$c['address_2'].' '.$c['address_2']),
'address' => !empty($row['seller_address']) ? $row['seller_address'] : trim($c['address_1'] . ' ' . $c['address_2'] . ' ' . $c['address_2']),
'phone' => !empty($row['seller_phone']) ? $row['seller_phone'] : $c['tel'],
'email' => !empty($row['seller_email']) ? $row['seller_email'] : $c['email'],
'account_number' => !empty($c['account_number']) ? $c['account_number'] : null,
@@ -496,7 +496,7 @@ class Service implements InjectionAwareInterface
$model->seller_company = $seller['name'];
$model->seller_company_vat = $seller['vat_number'];
$model->seller_company_number = $seller['number'];
$model->seller_address = trim($seller['address_1'].' '.$seller['address_2'].' '.$seller['address_3']);
$model->seller_address = trim($seller['address_1'] . ' ' . $seller['address_2'] . ' ' . $seller['address_3']);
$model->seller_phone = $seller['tel'];
$model->seller_email = $seller['email'];
@@ -505,11 +505,11 @@ class Service implements InjectionAwareInterface
$model->buyer_company = $buyer['company'];
$model->buyer_company_vat = $buyer['company_vat'];
$model->buyer_company_number = $buyer['company_number'];
$model->buyer_address = $buyer['address_1'].' '.$buyer['address_2'];
$model->buyer_address = $buyer['address_1'] . ' ' . $buyer['address_2'];
$model->buyer_city = $buyer['city'];
$model->buyer_state = $buyer['state'];
$model->buyer_country = $buyer['country'];
$model->buyer_phone = $buyer['phone_cc'].' '.$buyer['phone'];
$model->buyer_phone = $buyer['phone_cc'] . ' ' . $buyer['phone'];
$model->buyer_email = $buyer['email'];
$model->buyer_zip = $buyer['postcode'];
@@ -517,7 +517,7 @@ class Service implements InjectionAwareInterface
if (!is_numeric($invoice_due_days)) {
$invoice_due_days = 1;
}
$due_time = strtotime('+'.$invoice_due_days.' day');
$due_time = strtotime('+' . $invoice_due_days . ' day');
$model->due_at = date('Y-m-d H:i:s', $due_time);
$model->serie = $systemService->getParamValue('invoice_series');
@@ -965,7 +965,7 @@ class Service implements InjectionAwareInterface
// invoice due date
if ($due_days > 0) {
$proforma->due_at = date('Y-m-d H:i:s', strtotime('+'.$due_days.' days'));
$proforma->due_at = date('Y-m-d H:i:s', strtotime('+' . $due_days . ' days'));
$this->di['db']->store($proforma);
} elseif ($order->expires_at) {
$proforma->due_at = $order->expires_at;
@@ -1064,7 +1064,7 @@ class Service implements InjectionAwareInterface
if (\Model_Invoice::STATUS_PAID == $invoice->status) {
return true;
}
$this->di['events_manager']->fire(['event' => 'onBeforeAdminInvoiceSendReminder', 'params' => ['id' => $invoice->id]]);
$invoice->reminded_at = date('Y-m-d H:i:s');
@@ -1214,33 +1214,30 @@ class Service implements InjectionAwareInterface
$currencyCode = $client->currency;
}
$localeDateFormat = $this->di['config']['locale_date_format'];
$invoice = $this->toApiArray($invoice, false, $identity);
$systemService = $this->di['mod_service']('System');
$company = $systemService->getCompany();
$pdf = $this->di['pdf'];
$pdf->AddPage();
$pdf->AddFont('DejaVu', '', 'DejaVuSansCondensed.ttf', true);
$pdf->AddFont('DejaVu', 'B', 'DejaVuSansCondensed-Bold.ttf', true);
$pdf->SetFont('DejaVu', 'B', 20);
$font_size = 8;
$left = 10;
$pdf->text(90, 20, $invoice['serie_nr']);
$pdf->SetFont('DejaVu', '', $font_size);
$fontSize = 12;
if (isset($company['logo_url']) && !empty($company['logo_url'])) {
$url = $company['logo_url'];
if ('.png' === substr($url, -4)) {
$pdf->ImagePngWithAlpha($_SERVER['DOCUMENT_ROOT'].$url, $left + 75, 35, 50);
$pdf->ImagePngWithAlpha($_SERVER['DOCUMENT_ROOT'] . $url, $left + 15, 15, 50);
} else {
// Converting to .png
$img = imagecreatefromstring(file_get_contents($url));
if ($img) {
$filename = 'logo.png';
if (imagepng($img, $filename)) {
$pdf->ImagePngWithAlpha($filename, $left + 75, 35, 50);
$pdf->ImagePngWithAlpha($filename, $left + 15, 15, 50);
unlink($filename);
}
} else {
@@ -1249,88 +1246,99 @@ class Service implements InjectionAwareInterface
}
}
$localeDateFormat = $this->di['config']['locale_date_format'];
$invoiceDate = strftime($localeDateFormat, strtotime($this->di['array_get']($invoice, 'due_at', $invoice['created_at'])));
$invoice_info = __('Invoice number: ').$invoice['nr']."\n".
__('Invoice date: ').$invoiceDate."\n".
__('Due date: ').strftime($localeDateFormat, strtotime($invoice['due_at']))."\n".
__('Invoice status: ').ucfirst($invoice['status']);
$pdf->SetFont('DejaVu', 'B', $font_size);
$pdf->text($left + 15, 75, __('Invoice'));
$pdf->SetFont('DejaVu', '', $font_size);
$pdf->SetXY($left, 70);
$pdf->MultiCell(60, 10, "\n".$invoice_info, 0, 'L', 0);
$invoiceInfo = sprintf("%s: %s\n", __('Invoice number'), $invoice['serie_nr']);
$invoiceInfo .= sprintf("%s: %s\n", __('Invoice date'), $invoiceDate);
$invoiceInfo .= sprintf("%s: %s\n", __('Due date'), strftime($localeDateFormat, strtotime($invoice['due_at'])));
$invoiceInfo .= sprintf("%s: %s\n", __('Invoice status'), ucfirst($invoice['status']));
$company_info = __('Name: ').$invoice['seller']['company']."\n".
__('Address: ').$invoice['seller']['address']."\n".
__('Company VAT: ').$invoice['seller']['company_vat']."\n".
__('Company number: ').$invoice['seller']['company_number']."\n".
__('Account: ').$invoice['seller']['account_number']."\n".
__('Phone: ').$invoice['seller']['phone']."\n".
__('Email: ').$invoice['seller']['email'];
$pdf->SetFont('DejaVu', 'B', $font_size);
$pdf->text(95, 75, __('Company'));
$pdf->SetFont('DejaVu', '', $font_size);
$pdf->SetXY(75, 70);
$pdf->MultiCell(60, 10, "\n".$company_info, 0, 'L', 0);
$pdf->SetXY($pdf->GetPageWidth() / 2, $pdf->GetY());
$pdf->SetFont('DejaVu', '', $fontSize);
$pdf->MultiCell($pdf->GetPageWidth() / 2, 6, "\n" . $invoiceInfo, 0, 'L', 0);
$buyer_info = __('Name: ').$invoice['buyer']['first_name'].' '.$invoice['buyer']['last_name']."\n".
__('Company: ').$invoice['buyer']['company']."\n".
__('Address: ').$invoice['buyer']['address']."\n".
__('Company VAT: ').$invoice['seller']['company_vat']."\n".
__('Company number: ').$invoice['seller']['company_number']."\n".
__('Phone: ').$invoice['buyer']['phone'];
$pdf->SetFont('DejaVu', 'B', $font_size);
$pdf->text(145, 75, __('Billing and delivery address'));
$pdf->SetFont('DejaVu', '', $font_size);
$pdf->SetXY($left, 50);
$pdf->SetLineWidth(0.5);
$pdf->Line($pdf->GetX(), $pdf->GetY(), $pdf->GetPageWidth() - $pdf->GetX(), $pdf->GetY());
$pdf->SetXY(140, 70);
$pdf->MultiCell(60, 10, "\n".$buyer_info, 0, 'L', 0);
$pdf->SetFont('DejaVu', 'B', $fontSize);
$pdf->Text($left, 75, __('Company'));
$companyInfo = sprintf("%s: %s\n", __('Name'), $invoice['seller']['company']);
$companyInfo .= sprintf("%s: %s\n", __('Address'), $invoice['seller']['address']);
$companyInfo .= sprintf("%s: %s\n", __('Company VAT'), $invoice['seller']['company_vat']);
$companyInfo .= sprintf("%s: %s\n", __('Company number'), $invoice['seller']['company_number']);
$companyInfo .= sprintf("%s: %s\n", __('Account'), $invoice['seller']['account_number']);
$companyInfo .= sprintf("%s: %s\n", __('Phone'), $invoice['seller']['phone']);
$companyInfo .= sprintf("%s: %s\n", __('Email'), $invoice['seller']['email']);
$pdf->SetXY($left, 75);
$pdf->SetFont('DejaVu', '', $fontSize);
$pdf->MultiCell(90, 6, "\n" . $companyInfo, 0, 'L', 0);
$pdf->SetFont('DejaVu', 'B', $fontSize);
$pdf->Text($pdf->GetPageWidth() / 2, 75, __('Billing and delivery address'));
$buyerInfo = sprintf("%s: %s %s\n", __('Name'), $invoice['buyer']['first_name'], $invoice['buyer']['last_name']);
$buyerInfo .= sprintf("%s: %s\n", __('Company'), $invoice['buyer']['company']);
$buyerInfo .= sprintf("%s: %s\n", __('Address'), $invoice['buyer']['address']);
$buyerInfo .= sprintf("%s: %s\n", __('Company VAT'), $invoice['seller']['company_vat']);
$buyerInfo .= sprintf("%s: %s\n", __('Company number'), $invoice['seller']['company_number']);
$buyerInfo .= sprintf("%s: %s\n", __('Phone'), $invoice['buyer']['phone']);
$pdf->SetXY($pdf->GetPageWidth() / 2, 75);
$pdf->SetFont('DejaVu', '', $fontSize);
$pdf->MultiCell(90, 6, "\n" . $buyerInfo, 0, 'L', 0);
$header = [__('#'), __('Title'), __('Price'), __('Total')];
$pdf->SetXY($left, 175);
$w = [10, 120, 30, 30];
$pdf->SetXY($left, 155);
$pdf->SetLineWidth(0.1);
$align = ['C', 'L', 'C', 'R'];
$width = [10, 120, 30, 30];
$counted = count($header);
for ($i = 0; $i < $counted; ++$i) {
$pdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C');
$pdf->SetFillColor(74, 74, 74);
$pdf->SetTextColor(255);
$pdf->Cell($width[$i], 10, $header[$i], 0, 0, $align[$i], true);
}
$pdf->SetTextColor(0);
$pdf->Ln();
$pdf->SetFillColor(240, 240, 240);
$fill = true;
$nr = 1;
foreach ($invoice['lines'] as $row) {
$pdf->Cell($w[0], 6, $nr++, 'LR');
$pdf->Cell($w[1], 6, $row['title'], 'LR');
$pdf->Cell($w[2], 6, ($row['quantity'] > 1) ? $row['quantity'].' x '.$this->money($row['price'], $currencyCode) : $this->money($row['price'], $currencyCode), 'LR', 0, 'R');
$pdf->Cell($w[3], 6, $this->money($row['total'], $currencyCode), 'LR', 0, 'R');
$pdf->Cell($width[0], 10, $nr++, 0, 0, 'C', $fill);
$pdf->Cell($width[1], 10, $row['title'], 0, 0, 'L', $fill);
$pdf->Cell($width[2], 10, ($row['quantity'] > 1) ? $row['quantity'] . ' x ' . $this->money($row['price'], $currencyCode) : $this->money($row['price'], $currencyCode), 0, 0, 'C', $fill);
$pdf->Cell($width[3], 10, $this->money($row['total'], $currencyCode), 0, 0, 'R', $fill);
$pdf->Ln();
$fill = !$fill;
}
$pdf->Cell(array_sum($w), 0, '', 'T');
$pdf->Cell(array_sum($width), 0, '', 'T');
$y = $pdf->GetY();
$pdf->SetXY(120, $y + 10);
$pdf->SetXY(140, $pdf->GetY() + 10);
if ($invoice['tax'] > 0) {
$pdf->Cell(40, 6, $invoice['taxname'].' '.$invoice['taxrate'].'%', 'LRTB', 0, 'C');
$pdf->Cell(40, 6, $this->money($invoice['tax'], $currencyCode), 'LRTB', 0, 'C');
$pdf->Cell(30, 6, sprintf('%s %s%%', $invoice['taxname'], $invoice['taxrate']), '', 0, 'C');
$pdf->Cell(30, 6, $this->money($invoice['tax'], $currencyCode), '', 0, 'R');
$pdf->Ln();
$pdf->SetX(120);
}
$pdf->SetX(120);
$pdf->SetX(140);
if (isset($invoice['discount']) && $invoice['discount'] > 0) {
$pdf->Cell(40, 8, __('Discount '), 'LRTB', 0, 'C');
$pdf->Cell(40, 8, $this->money($invoice['discount'], $currencyCode), 'LRTB', 0, 'C');
$pdf->Cell(40, 8, __('Discount '), '', 0, 'C');
$pdf->Cell(40, 8, $this->money($invoice['discount'], $currencyCode), '', 0, 'R');
$pdf->Ln();
$pdf->SetX(120);
}
$pdf->SetFont('DejaVu', 'B', $font_size + 2);
$pdf->Cell(40, 10, __('Total'), 'LRTB', 0, 'C');
$pdf->Cell(40, 10, $this->money($invoice['total'], $currencyCode), 'LRTB', 0, 'C');
$pdf->SetX(140);
$pdf->SetFont('DejaVu', 'B', $fontSize + 2);
$pdf->Cell(30, 10, __('Total'), '', 0, 'C');
$pdf->Cell(30, 10, $this->money($invoice['total'], $currencyCode), '', 0, 'R');
$pdf->Ln();
$pdf->Output($invoice['serie_nr'].'.pdf', 'I');
$pdf->Output($invoice['serie_nr'] . '.pdf', 'I');
}
private function money($price, $currencyCode)
@@ -1341,7 +1349,7 @@ class Service implements InjectionAwareInterface
public function addNote(\Model_Invoice $model, $note)
{
$n = $model->notes;
$model->notes = $n.date('Y-m-d H:i:s').': '.$note.' '.PHP_EOL;
$model->notes = $n . date('Y-m-d H:i:s') . ': ' . $note . ' ' . PHP_EOL;
$model->updated_at = date('Y-m-d H:i:s');
$this->di['db']->store($model);
@@ -1477,7 +1485,7 @@ class Service implements InjectionAwareInterface
$bs->setUnit($period->getUnit());
$mpi->setSubscription($bs);
$mpi->setTitle('Subscription for '.$subitem->title);
$mpi->setTitle('Subscription for ' . $subitem->title);
}
return $mpi;
@@ -1505,7 +1513,7 @@ class Service implements InjectionAwareInterface
$invoices = $this->di['db']->find('Invoice', 'client_id = ?', [$client->id]);
foreach ($invoices as $invoice) {
$invoiceItems = $this->di['db']->find('InvoiceItem', 'invoice_id = ?', [$invoice->id]);
foreach ($invoiceItems as $invoiceItem) {
$this->di['db']->trash($invoiceItem);
}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}{{ 'Invoice settings'|trans }}{% endblock %}
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% block meta_title %}{{ 'Processing payment ...'|trans }}{% endblock %}
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% block meta_title %}{{ 'Invoice management'|trans }}{% endblock %}
{% block page_header %}{{ 'Invoice management'|trans }}{% endblock %}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% set nr = invoice.serie ~ "%05s"|format(invoice.nr) %}
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% block meta_title %}{{ 'Thank you'|trans }}{% endblock %}
{% block breadcrumb %}<li class="active">{{ 'Thank you'|trans }}</li>{% endblock %}
+2 -1
View File
@@ -1,4 +1,5 @@
<?php
/**
* BoxBilling.
*
@@ -40,7 +41,7 @@ class Admin implements \Box\InjectionAwareInterface
'location' => 'kb',
'label' => 'Knowledge Base',
'uri' => $this->di['url']->adminLink('kb'),
'class' => 'support',
'class' => 'info',
'sprite_class' => 'dark-sprite-icon sprite-docs',
],
'subpages' => [
@@ -1,6 +1,6 @@
{% extends "layout_default.phtml" %}
{% extends "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% set active_menu = 'kb' %}
@@ -1,4 +1,4 @@
{% extends "layout_default.phtml" %}
{% extends "layout_default.html.twig" %}
{% set active_menu = 'support' %}
{% block meta_title %}{{ category.title }}{% endblock %}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}{{ 'Knowledge Base'|trans }}{% endblock %}
{% set active_menu = 'kb' %}
@@ -53,7 +53,7 @@
</tbody>
</table>
{% include "partial_pagination.phtml" with {'list': posts, 'url':'kb'} %}
{% include "partial_pagination.html.twig" with {'list': posts, 'url':'kb'} %}
</div>
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% block meta_title %}{{ article.title }}{% endblock %}
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% block meta_title %}{{ category.title }}{% endblock %}
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% block meta_title %}{{ 'Knowledge base'|trans }}{% endblock %}
{% block breadcrumb %}{{ 'Knowledge base'|trans }}{% endblock %}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}Mass mailer{% endblock %}
@@ -52,7 +52,7 @@
{% endfor %}
</tbody>
</table>
{% include "partial_pagination.phtml" with {'list': msgs, 'url':'massmailer'} %}
{% include "partial_pagination.html.twig" with {'list': msgs, 'url':'massmailer'} %}
</div>
<div class="tab_content nopadding" id="tab-new">
@@ -1,4 +1,4 @@
{% extends 'layout_default.phtml' %}
{% extends 'layout_default.html.twig' %}
{% block meta_title %}{{ msg.subject }}{% endblock %}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% set active_menu = 'support' %}
@@ -56,8 +56,8 @@
{% endfor %}
</tbody>
</table>
{% include "partial_pagination.phtml" with { 'list': posts, 'url': 'news/index' } %}
{% include "partial_batch_delete.phtml" with { 'action': 'admin/news/batch_delete' } %}
{% include "partial_pagination.html.twig" with { 'list': posts, 'url': 'news/index' } %}
{% include "partial_batch_delete.html.twig" with { 'action': 'admin/news/batch_delete' } %}
</div>
<div class="tab_content nopadding" id="tab-new">
@@ -1,6 +1,6 @@
{% extends "layout_default.phtml" %}
{% extends "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}{{ post.title }}{% endblock %}
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% block meta_title %}{{ 'Blog'|trans }}{% endblock %}
{% block breadcrumb %}{{ 'Blog'|trans }}{% endblock %}
@@ -34,7 +34,7 @@
{% endfor %}
</section>
</div>
{% include "partial_pagination.phtml" with { 'list': posts } %}
{% include "partial_pagination.html.twig" with { 'list': posts } %}
</article>
</div>
{% endblock %}
@@ -1,4 +1,4 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% block meta_title %}{{ post.title }}{% endblock %}
{% block meta_description %}{{ post.description }}{% endblock %}
@@ -37,7 +37,7 @@
{{ post.content|bbmd }}
{# if post.tags %}Tags: {{ post.tags|join(', ') }}{% endif #}
{% if guest.extension_is_on({ "mod": "comment" }) %}{% include "mod_comment_block.phtml" %}{% endif %}
{% if guest.extension_is_on({ "mod": "comment" }) %}{% include "mod_comment_block.html.twig" %}{% endif %}
<hr/>
<p><a class="btn btn-small" href="{{ 'news'|link }}">{{ 'Back to list'|trans }}</a></p>
</section>
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}Notifications center{% endblock %}
@@ -48,7 +48,7 @@
</tbody>
</table>
{% include "partial_pagination.phtml" with {'list': events, 'url':'notification'} %}
{% include "partial_pagination.html.twig" with {'list': events, 'url':'notification'} %}
<div class="body">
<a href="{{ 'api/admin/notification/delete_all'|link }}" title="" class="btnIconLeft mr10 api-link" data-api-confirm="{{ 'Are you sure?'|trans }}" data-api-reload="1"><img src="images/icons/dark/trash.png" alt="" class="icon"><span>{{ 'Delete all messages'|trans }}</span></a>
+2 -1
View File
@@ -1,4 +1,5 @@
<?php
/**
* BoxBilling.
*
@@ -97,7 +98,7 @@ class Admin implements \Box\InjectionAwareInterface
$set = ['order' => $order];
if (isset($order['plugin']) && !empty($order['plugin'])) {
$set['plugin'] = 'plugin_'.$order['plugin'].'_manage.phtml';
$set['plugin'] = 'plugin_'.$order['plugin'].'_manage.html.twig';
}
return $app->render('mod_order_manage', $set);
+3 -2
View File
@@ -1,4 +1,5 @@
<?php
/**
* BoxBilling.
*
@@ -51,7 +52,7 @@ class Client implements \Box\InjectionAwareInterface
$api = $this->di['api_guest'];
$product = $api->product_get(['slug' => $slug]);
$tpl = 'mod_service'.$product['type'].'_order';
if ($api->system_template_exists(['file' => $tpl.'.phtml'])) {
if ($api->system_template_exists(['file' => $tpl.'.html.twig'])) {
return $app->render($tpl, ['product' => $product]);
}
@@ -63,7 +64,7 @@ class Client implements \Box\InjectionAwareInterface
$api = $this->di['api_guest'];
$product = $api->product_get(['id' => $id]);
$tpl = 'mod_service'.$product['type'].'_order';
if ($api->system_template_exists(['file' => $tpl.'.phtml'])) {
if ($api->system_template_exists(['file' => $tpl.'.html.twig'])) {
return $app->render($tpl, ['product' => $product]);
}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}{{ 'Orders settings'|trans }}{% endblock %}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}{{ 'Order'|trans }}{% endblock %}
@@ -27,7 +27,7 @@
{% endblock %}
{% block sidebar2 %}
{% include 'partial_currency.phtml' %}
{% include 'partial_currency.html.twig' %}
{% endblock %}
{% block js %}
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}{{ 'My Products & Services'|trans }}{% endblock %}
@@ -50,7 +50,7 @@
</tbody>
</table>
{% include "partial_pagination.phtml" with { 'list': orders } %}
{% include "partial_pagination.html.twig" with { 'list': orders } %}
</section>
</article>
</div>
@@ -1,6 +1,6 @@
{% extends request.ajax ? "layout_blank.phtml" : "layout_default.phtml" %}
{% extends request.ajax ? "layout_blank.html.twig" : "layout_default.html.twig" %}
{% import "macro_functions.phtml" as mf %}
{% import "macro_functions.html.twig" as mf %}
{% block meta_title %}{{ order.title }}{% endblock %}
@@ -11,7 +11,7 @@
{{ order.title }}
{% endblock %}
{% set service_partial = "mod_service" ~ order.service_type ~ "_manage.phtml" %}
{% set service_partial = "mod_service" ~ order.service_type ~ "_manage.html.twig" %}
{% set upgradables = client.order_upgradables({ 'id': order.id }) %}
{% block content %}
Loaded 100 of 561 files, more files were not shown because too many files have changed in this diff. Show more