4.1.0 Support

This commit is contained in:
Nick Thompson 2021-11-30 02:40:50 -07:00
parent aa74d2c634
commit 6011c93f11
13 changed files with 26219 additions and 280 deletions

View file

@ -25,7 +25,7 @@ Mautic Whitelabeler makes customizing the core branding elements of [Mautic](htt

## Requirements

* Mautic versions 2.15.0 - 4.0.2 (Use previous [Whitelabeler 1.0](https://github.com/nickian/mautic-whitelabeler/releases) release for older versions of Mautic. Beta versions are not tested.)
* Mautic versions 2.15.0 - 4.1.0 (Use previous [Whitelabeler 1.0](https://github.com/nickian/mautic-whitelabeler/releases) release for older versions of Mautic. Beta versions are not tested.)
* Make sure you have installed Mautic using the correct zip file from the [Mautic releases page](https://github.com/mautic/mautic/releases). DO NOT use the "update" zip file. The whitelabeler will not work correctly with these versions.

* Apache server (will work on some nginx configurations, but not officially supported)

54
cli.php
View file

@ -5,13 +5,9 @@ $cli = new League\CLImate\CLImate;
$whitelabeler = new Whitelabeler;

if ( count($argv) > 1 ) {

if ( $argv[1] == '--whitelabel' ) {
if ( isset($argv[2]) ) {
$config_file = explode('=', $argv[2]);
if ( !empty($config_file) && $config_file[0] == '--config' ) {
if ( file_exists($config_file[1]) ) {
@ -20,7 +16,6 @@ if ( count($argv) > 1 ) {
$cli->error('Config file not found.');
exit();
}
} else {
if ( file_exists(__DIR__.'/assets/'.$argv[2]) ) {
@ -29,9 +24,7 @@ if ( count($argv) > 1 ) {
$cli->error('Config file not found.');
exit();
}
}
} else {
if ( file_exists(__DIR__.'/assets/config.json') ) {
$config = $whitelabeler->validateConfigValues();
@ -42,17 +35,13 @@ if ( count($argv) > 1 ) {
}

if ( !empty($config['errors'] ) ) {
foreach( $config['errors'] as $error ) {
$cli->red($error);
}
} else {
$cli->magenta('Whitelabeling...');

// Replace CSS colors
$cli->out('Updating colors...');
$config = $config['config'];
@ -77,12 +66,10 @@ if ( count($argv) > 1 ) {
);
if ( $colors['status'] == 1 ) {
$cli->green($colors['message']);
} else {
$cli->error($colors['message']);
exit();
$cli->error($colors['message']);
exit();
}
// Update company name in templates
@ -96,14 +83,14 @@ if ( count($argv) > 1 ) {
$config['footer']
);
if ( $company_name['status'] == 1 ) {
$cli->green($company_name['message']);
} else {
foreach( $company_name['message'] as $error ) {
$cli->error($error);
}
exit();
}
if ( $company_name['status'] == 1 ) {
$cli->green($company_name['message']);
} else {
foreach( $company_name['message'] as $error ) {
$cli->error($error);
}
exit();
}
// Update logo images
@ -156,16 +143,12 @@ if ( count($argv) > 1 ) {
} else {
$cli->error($clear_cache['message']);
}
}

} elseif ( $argv[1] == '--backup' ) {

if ( $whitelabeler->mauticVersion(dirname(__DIR__, 1))['status'] == 1 ) {

$mautic_path = dirname(__DIR__, 1);
$backups_dir = __DIR__.'/backups';
$cli->out('Backing up Mautic... ');
// Create backups folder if it doesn't exist
@ -186,19 +169,16 @@ if ( count($argv) > 1 ) {
} else {
$cli->green('Backup complete!');
}

} else {
$cli->yellow('Mautic not found. Make sure the whitelabeler is placed in the Mautic root directory.');
}

} elseif ( $argv[1] == '--restore' ) {
if ( !is_dir(__DIR__.'/backups') ) {
$cli->yellow('No backups found. Use "php cli.php --backup --path=/path/to/mautic" to backup a Mautic installation');
exit();
}
// Look for backups
$backups = array();
foreach (new DirectoryIterator(__DIR__.'/backups') as $file) {
@ -223,12 +203,9 @@ if ( count($argv) > 1 ) {
}
if ( $whitelabeler->mauticVersion(dirname(__DIR__, 1))['status'] == 1 ) {
$mautic_path = dirname(__DIR__, 1);
$mautic_path = dirname(__DIR__, 1);
$cli->out('Mautic found.');
} else {
$input = $cli->yellow('Couldn\'t automatically find your Mautic files in '. dirname(__DIR__, 1));
$input = $cli->input('What\'s the absolute path to your Mautic files?');
$mautic_path = $input->prompt();
@ -239,7 +216,6 @@ if ( count($argv) > 1 ) {
$input = $cli->red('Couldn\'t find your Mautic files in '.$mautic_path);
exit();
}
}
// Do the restore
@ -257,12 +233,9 @@ if ( count($argv) > 1 ) {
$cli->out('Setting ownership of the Mautic directory to www-data:www-data user/group...');
shell_exec('chown -R www-data:www-data '.$mautic_path);
$cli->green('Restore complete!');
} elseif ( $argv[1] == '--compare' ) {
$errors = array();
$errors = array();
if ( isset($argv[2]) && substr($argv[2], 0, 7) == '--path1' ) {
$mautic_path_1 = explode('=', $argv[2]);
$mautic_path_1 = $mautic_path_1[1];
@ -299,7 +272,6 @@ if ( count($argv) > 1 ) {
$cli->error($error);
}
}
}
} else {

View file

@ -5,8 +5,8 @@
require_once('whitelabeler.php');
$whitelabeler = new Whitelabeler;

$v1_path = '../4.0.1';
$v2_path = '../4.0.2';
$v1_path = '../4.0.2';
$v2_path = '../4.1.0';

$compare = $whitelabeler->compareMauticVersions($v1_path, $v2_path);


170
index.php
View file

@ -4,63 +4,51 @@ $whitelabeler = new Whitelabeler;

if (isset($_GET['q'])) {

/*
|--------------------------------------------------------------------------
| Determine Mautic version by path
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| Determine Mautic version by path
|--------------------------------------------------------------------------
*/
if ( $_GET['q'] == 'version' ) {

header('Content-Type: application/json');

if ( isset($_GET['path']) && is_dir($_GET['path']) ) {

echo json_encode(
$whitelabeler->mauticVersion($_GET['path'])
);

} else {

echo json_encode(array(
'status' => 0,
'message' => 'Directory does not exist.'
));

}

exit();

/*
|--------------------------------------------------------------------------
| Find Mautic by URL (look for LICENSE.txt to verify this is Mautic root)
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| Find Mautic by URL (look for LICENSE.txt to verify this is Mautic root)
|--------------------------------------------------------------------------
*/
} elseif ( $_GET['q'] == 'url' && isset($_GET['url']) ) {

header('Content-Type: application/json');

echo json_encode(
$whitelabeler->findMauticUrl($_GET['url'])
);

exit();


/*
|--------------------------------------------------------------------------
| Check for image in assets
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| Check for image in assets
|--------------------------------------------------------------------------
*/
} elseif ( $_GET['q'] == 'asset' && isset($_GET['url']) ) {
echo $whitelabeler->assetExists(urldecode($_GET['url']));
exit();


/*
|--------------------------------------------------------------------------
| Save Images
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| Save Images
|--------------------------------------------------------------------------
*/
} elseif ( $_GET['q'] == 'save-images' && $_SERVER['REQUEST_METHOD'] == 'POST' ) {

require_once('vendor/chrisjean/php-ico/class-php-ico.php');
@ -70,14 +58,12 @@ if (isset($_GET['q'])) {

// sidebar logo
if ( isset($_FILES['sidebar_logo_file']) ) {

if (
$_FILES['sidebar_logo_file']['type'] == 'image/png' ||
$_FILES['sidebar_logo_file']['type'] == 'image/jpg' ||
$_FILES['sidebar_logo_file']['type'] == 'image/jpeg' ||
$_FILES['sidebar_logo_file']['type'] == 'image/gif'
) {

$whitelabeler->imageResize(
$_POST['sidebar_logo_width'],
$_FILES['sidebar_logo_file']['tmp_name'],
@ -89,23 +75,19 @@ if (isset($_GET['q'])) {
} else {
$result['images']['sidebar_logo'] = $_FILES['sidebar_logo_file']['name'];
}

} else {
$errors[] = 'Invalid file type provided for sidebar logo.';
}

}

// login logo
if ( isset($_FILES['login_logo_file']) ) {

if (
$_FILES['login_logo_file']['type'] == 'image/png' ||
$_FILES['login_logo_file']['type'] == 'image/jpg' ||
$_FILES['login_logo_file']['type'] == 'image/jpeg' ||
$_FILES['login_logo_file']['type'] == 'image/gif'
) {

$whitelabeler->imageResize(
$_POST['login_logo_width'],
$_FILES['login_logo_file']['tmp_name'],
@ -120,7 +102,6 @@ if (isset($_GET['q'])) {

// If favicon file is not set, we'll use the login logo
if ( !isset($_FILES['favicon_file']) && !isset($_POST['saved_favicon']) ) {

$logo_filename_explode = explode('.', $_FILES['login_logo_file']['name']);
$ico_lib = new PHP_ICO($_FILES['login_logo_file']['tmp_name'], array( array( 64, 64 ) ) );
$ico_lib->save_ico(__DIR__.'/assets/favicon-'.$logo_filename_explode[0].'.ico');
@ -131,16 +112,13 @@ if (isset($_GET['q'])) {
$result['images']['favicon_files'] = 'favicon-'.$logo_filename_explode[0].'.ico';
}
}

} else {
$errors[] = 'Invalid file type provided for login logo.';
}

}

// favicon
if ( isset($_FILES['favicon_file']) ) {

if (
$_FILES['favicon_file']['type'] == 'image/png' ||
$_FILES['favicon_file']['type'] == 'image/x-icon' ||
@ -149,10 +127,8 @@ if (isset($_GET['q'])) {
$_FILES['favicon_file']['type'] == 'image/jpeg' ||
$_FILES['favicon_file']['type'] == 'image/gif'
) {

// If favicon is .ico, move/copy the file
if ($_FILES['favicon_file']['type'] == 'image/vnd.microsoft.icon' || $_FILES['favicon_file']['type'] == 'image/x-icon') {

move_uploaded_file($_FILES['favicon_file']['tmp_name'], __DIR__.'/assets/'.$_FILES['favicon_file']['name']);

if ( !file_exists(__DIR__.'/assets/'.$_FILES['favicon_file']['name']) ) {
@ -160,10 +136,8 @@ if (isset($_GET['q'])) {
} else {
$result['images']['favicon'] = $_FILES['favicon_file']['name'];
}

// convert to .ico and save.
} else {

$logo_filename_explode = explode('.', $_FILES['favicon_file']['name']);

$ico_lib = new PHP_ICO($_FILES['favicon_file']['tmp_name'], array( array( 64, 64 ) ) );
@ -174,29 +148,24 @@ if (isset($_GET['q'])) {
} else {
$result['images']['favicon'] = $logo_filename_explode[0].'.ico';
}

}

} else {
$errors[] = 'Invalid file type provided for favicon.';
}

}

header('Content-Type: application/json');
if ( !empty($errors) ) {
echo json_encode( array('status' => 0, 'message' => $errors) );
} else {
echo json_encode( array('status' => 1, 'message' => $result) );
}

exit();

/*
|--------------------------------------------------------------------------
| Save values entered
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| Save values entered
|--------------------------------------------------------------------------
*/
} elseif ( $_GET['q'] == 'save' && $_SERVER['REQUEST_METHOD'] == 'POST' ) {
// Encode the array into a JSON string.
$encodedString = json_encode($_POST['config'], JSON_PRETTY_PRINT);
@ -207,11 +176,11 @@ if (isset($_GET['q'])) {
};
exit();

/*
|--------------------------------------------------------------------------
| Save as a different filename
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| Save as a different filename
|--------------------------------------------------------------------------
*/
} elseif ( $_GET['q'] == 'save-as' && $_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['file']) ) {
// Encode the array into a JSON string.
$encodedString = json_encode($_POST['config'], JSON_PRETTY_PRINT);
@ -222,23 +191,22 @@ if (isset($_GET['q'])) {
};
exit();

/*
|--------------------------------------------------------------------------
| Get list of config files from assets directory
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| Get list of config files from assets directory
|--------------------------------------------------------------------------
*/
} elseif ( $_GET['q'] == 'config-files' ) {
header('Content-Type: application/json');
echo json_encode($whitelabeler->getConfigFiles());
exit();

/*
|--------------------------------------------------------------------------
| Look for saved values and files to populate form automatically
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| Look for saved values and files to populate form automatically
|--------------------------------------------------------------------------
*/
} elseif ( $_GET['q'] == 'saved' && isset($_GET['file']) ) {

$config = $whitelabeler->loadJsonConfig($_GET['file']);

if ( $config ) {
@ -248,15 +216,13 @@ if (isset($_GET['q'])) {
header('Content-Type: application/json');
echo json_encode(array('status' => 0, 'message' => 'config.json not found in assets folder.'));
}

exit();


/*
|--------------------------------------------------------------------------
| Reset saved values
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| Reset saved values
|--------------------------------------------------------------------------
*/
} elseif ( $_GET['q'] == 'reset' && $_SERVER['REQUEST_METHOD'] == 'POST' ) {
//Encode the array into a JSON string.
$encodedString = json_encode($_POST['config'], JSON_PRETTY_PRINT);
@ -266,12 +232,11 @@ if (isset($_GET['q'])) {
};
exit();


/*
|--------------------------------------------------------------------------
| Regenerate Assets / Clear Cache
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| Regenerate Assets / Clear Cache
|--------------------------------------------------------------------------
*/
} elseif ( $_GET['q'] == 'assets' && isset($_GET['assets']) && isset($_GET['path']) ) {
if ( substr($_GET['path'], -1) == '/' ) {
$path = substr($_GET['path'], 0, -1);
@ -285,20 +250,19 @@ if (isset($_GET['q'])) {
}
exit();

/*
|--------------------------------------------------------------------------
| POST Logos
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| POST Logos
|--------------------------------------------------------------------------
*/
} elseif ( $_GET['q'] == 'logos' ) {

if ( isset($_POST['mautic_path']) && isset($_POST['mautic_url']) ) {

if ( substr($_POST['mautic_path'], -1) == '/' ) {
$path = substr($_POST['mautic_path'], 0, -1);
} else {
$path = $_POST['mautic_path'];
}

if ( substr($_POST['mautic_url'], -1) == '/' ) {
$url = substr($_POST['mautic_url'], 0, -1);
} else {
@ -316,7 +280,6 @@ if (isset($_GET['q'])) {
}

if (empty($errors)) {

// Use saved sidebar logo
if ( !isset($_FILES['sidebar_logo_file']) && isset($_POST['sidebar_logo_file']) ) {
$sidebar_logo = __DIR__.'/assets/'.$_POST['sidebar_logo_file'];
@ -384,13 +347,12 @@ if (isset($_GET['q'])) {
exit();
}

/*
|--------------------------------------------------------------------------
| POST CSS Colors
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| POST CSS Colors
|--------------------------------------------------------------------------
*/
} elseif ( $_GET['q'] == 'css' && $_SERVER['REQUEST_METHOD'] == 'POST' ) {

if (
isset($_POST['path']) &&
isset($_POST['version']) &&
@ -438,11 +400,11 @@ if (isset($_GET['q'])) {
}
exit();

/*
|--------------------------------------------------------------------------
| POST Company Name
|--------------------------------------------------------------------------
*/
/*
|--------------------------------------------------------------------------
| POST Company Name
|--------------------------------------------------------------------------
*/
} elseif ( $_GET['q'] == 'companyname' && $_SERVER['REQUEST_METHOD'] == 'POST') {
if ( substr($_POST['path'], -1) == '/' ) {
$path = substr($_POST['path'], 0, -1);

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,86 @@
<?php

/*
* @copyright 2014 Mautic Contributors. All rights reserved
* @author Mautic
*
* @link http://mautic.org
*
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
?>
<!DOCTYPE html>
<html>
<?php echo $view->render('MauticCoreBundle:Default:head.html.php'); ?>
<body class="header-fixed">
<!-- start: app-wrapper -->
<section id="app-wrapper">
<?php $view['assets']->outputScripts('bodyOpen'); ?>

<!-- start: app-sidebar(left) -->
<aside class="app-sidebar sidebar-left">
<?php echo $view->render('MauticCoreBundle:LeftPanel:index.html.php'); ?>
</aside>
<!--/ end: app-sidebar(left) -->

<!-- start: app-sidebar(right) -->
<aside class="app-sidebar sidebar-right">
<?php echo $view->render('MauticCoreBundle:RightPanel:index.html.php'); ?>
</aside>
<!--/ end: app-sidebar(right) -->

<!-- start: app-header -->
<header id="app-header" class="navbar">
<?php echo $view->render('MauticCoreBundle:Default:navbar.html.php'); ?>

<?php echo $view->render('MauticCoreBundle:Notification:flashes.html.php'); ?>
</header>
<!--/ end: app-header -->

<!-- start: app-footer(need to put on top of #app-content)-->
<footer id="app-footer">
<div class="container-fluid">
<div class="row">
<div class="col-xs-6 text-muted"> {{company_name}}{{footer_prefix}} {{footer}}</div>
<div class="col-xs-6 text-muted text-right small">v<?php
/** @var \Mautic\CoreBundle\Templating\Helper\VersionHelper $version */
$version = $view['version'];
echo $version->getVersion(); ?>
</div>
</div>
</div>
</footer>
<!--/ end: app-footer -->

<!-- start: app-content -->
<section id="app-content">
<?php $view['slots']->output('_content'); ?>
</section>
<!--/ end: app-content -->

</section>
<!--/ end: app-wrapper -->

<script>
Mautic.onPageLoad('body');
<?php if ('dev' === $app->getEnvironment()): ?>
mQuery( document ).ajaxComplete(function(event, XMLHttpRequest, ajaxOption){
if(XMLHttpRequest.responseJSON && typeof XMLHttpRequest.responseJSON.ignore_wdt == 'undefined' && XMLHttpRequest.getResponseHeader('x-debug-token')) {
if (mQuery('[class*="sf-tool"]').length) {
mQuery('[class*="sf-tool"]').remove();
}

mQuery.get(mauticBaseUrl + '_wdt/'+XMLHttpRequest.getResponseHeader('x-debug-token'),function(data){
mQuery('body').append('<div class="sf-toolbar-reload">'+data+'</div>');
});
}
});
<?php endif; ?>
</script>
<?php $view['assets']->outputScripts('bodyClose'); ?>
<?php echo $view->render('MauticCoreBundle:Helper:modal.html.php', [
'id' => 'MauticSharedModal',
'footerButtons' => true,
]); ?>
</body>
</html>

View file

@ -0,0 +1,28 @@
<?php

/*
* @copyright 2014 Mautic Contributors. All rights reserved
* @author Mautic
*
* @link http://mautic.org
*
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
?>
<head>
<meta charset="UTF-8" />
<title><?php if (!empty($view['slots']->get('headerTitle', ''))): ?>
<?php echo strip_tags(str_replace('<', ' <', $view['slots']->get('headerTitle', ''))); ?> |
<?php endif; ?>
<?php echo $view['slots']->get('pageTitle', '{{company_name}}'); ?>
</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="icon" type="image/x-icon" href="<?php echo $view['assets']->getUrl('media/images/favicon.ico'); ?>" />
<link rel="icon" sizes="192x192" href="<?php echo $view['assets']->getUrl('media/images/favicon.ico'); ?>">
<link rel="apple-touch-icon" href="<?php echo $view['assets']->getUrl('media/images/apple-touch-icon.png'); ?>" />

<?php echo $view['assets']->outputSystemStylesheets(); ?>

<?php echo $view->render('MauticCoreBundle:Default:script.html.php'); ?>
<?php $view['assets']->outputHeadDeclarations(); ?>
</head>

View file

@ -0,0 +1,53 @@
<?php

/*
* @copyright 2014 Mautic Contributors. All rights reserved
* @author Mautic
*
* @link http://mautic.org
*
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
$extraMenu = $view['menu']->render('extra');
?>
<!-- start: sidebar-header -->
<div class="sidebar-header">
<!-- brand -->
<a class="mautic-brand<?php echo (!empty($extraMenu)) ? ' pull-left pl-0 pr-0' : ''; ?>" href="#">
<img src="<?php echo $view['assets']->getUrl('{{sidebar_image}}') ?>" style="width:100%; max-width:{{sidebar_width}}px; margin:{{margin_top}}px {{margin_right}}px 0 {{margin_left}}px;" />
</a>
<?php if (!empty($extraMenu)): ?>
<div class="dropdown extra-menu">
<a href="#" data-toggle="dropdown" class="dropdown-toggle">
<i class="fa fa-chevron-down fa-lg"></i>
</a>
<?php echo $extraMenu; ?>
</div>
<?php endif; ?>
<!--/ brand -->
</div>
<!--/ end: sidebar-header -->

<!-- start: sidebar-content -->
<div class="sidebar-content">
<!-- scroll-content -->
<div class="scroll-content slimscroll">
<!-- start: navigation -->
<nav class="nav-sidebar">
<?php echo $view['content']->getCustomContent('menu.above', $mauticTemplateVars); ?>
<?php echo $view['menu']->render('main'); ?>

<!-- start: left nav -->
<ul class="nav sidebar-left-dark">
<li class="hidden-xs">
<a href="javascript:void(0)" data-toggle="minimize" class="sidebar-minimizer"><span class="direction icon pull-left fa"></span><span class="nav-item-name pull-left text"><?php echo $view['translator']->trans('mautic.core.menu.left.collapse'); ?></span></a>
</li>
</ul>
<!--/ end: left nav -->

</nav>
<!--/ end: navigation -->
</div>
<!--/ scroll-content -->
</div>
<!--/ end: sidebar-content -->

View file

@ -0,0 +1,54 @@
<?php

/*
* @copyright 2014 Mautic Contributors. All rights reserved
* @author Mautic
*
* @link http://mautic.org
*
* @license GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
?>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title><?php echo $view['slots']->get('pageTitle', '{{company_name}}'); ?></title>
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="icon" type="image/x-icon" href="<?php echo $view['assets']->getUrl('media/images/favicon.ico'); ?>" />
<link rel="apple-touch-icon" href="<?php echo $view['assets']->getUrl('media/images/apple-touch-icon.png'); ?>" />
<?php $view['assets']->outputSystemStylesheets(); ?>
<?php echo $view->render('MauticCoreBundle:Default:script.html.php'); ?>
<?php $view['assets']->outputHeadDeclarations(); ?>
</head>
<body>
<section id="main" role="main">
<div class="container" style="margin-top:100px;">
<div class="row">
<div class="col-lg-4 col-lg-offset-4">
<div class="panel" name="form-login">
<div class="panel-body">
<div class="mautic-logo img-circle mb-md text-center" style="width:{{login_logo_width}}px;">
<img src="<?php echo $view['assets']->getUrl('{{login_logo}}') ?>" style="width:{{login_logo_width}}px; margin:{{login_logo_margin_top}}px 0 {{login_logo_margin_bottom}}px 0;" />
</div>
<div id="main-panel-flash-msgs">
<?php echo $view->render('MauticCoreBundle:Notification:flashes.html.php'); ?>
</div>
<?php $view['slots']->output('_content'); ?>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-4 col-lg-offset-4 text-center text-muted">
&copy; <?php echo date('Y');?> {{company_name}}{{footer_prefix}}
<p style="margin-top:1em;">{{footer}}</p>
</div>
</div>
</div>
</section>
<?php echo $view['security']->getAuthenticationContent(); ?>
</body>
</html>

View file

@ -73,7 +73,6 @@
</div><!--sidebar-->
</div><!--sidebar-container-->


<div class="whitelabeler">
<div class="container">
<div class="row">
@ -151,7 +150,6 @@
</div><!--row-->
</div><!--colors-->


<div id="sidebarcolors">
<h3>Sidebar Colors</h3>
<div class="row">
@ -223,10 +221,8 @@
</div>
</div>
</div><!--row-->

</div><!--sidebar-colors-->


<div id="sidebarlogo">
<h3>Sidebar Logo</h3>
<div class="row">

View file

@ -1,12 +1,14 @@
<?php

class Whitelabeler {

/*
|--------------------------------------------------------------------------
| Get JSON config files from assets folder
|--------------------------------------------------------------------------
*/
public function getConfigFiles() {
/*
|--------------------------------------------------------------------------
| Get JSON config files from assets folder
|--------------------------------------------------------------------------
*/
public function getConfigFiles()
{
$config_files = array();
$files = scandir(__DIR__.'/assets');
foreach( $files as $file ) {
@ -19,12 +21,14 @@ class Whitelabeler {
return $config_files;
}

/*
|--------------------------------------------------------------------------
| Load config.json file if it exists
|--------------------------------------------------------------------------
*/
public function loadJsonConfig($file) {

/*
|--------------------------------------------------------------------------
| Load config.json file if it exists
|--------------------------------------------------------------------------
*/
public function loadJsonConfig($file)
{
$config = array();
if ( file_exists( __DIR__.'/assets/'.$file ) ) {
$config = json_decode(file_get_contents(__DIR__.'/assets/'.$file), true);
@ -35,14 +39,13 @@ class Whitelabeler {
}


/*
|--------------------------------------------------------------------------
| Find Mautic URL with cURL
|--------------------------------------------------------------------------
*/

public function findMauticUrl($url) {

/*
|--------------------------------------------------------------------------
| Find Mautic URL with cURL
|--------------------------------------------------------------------------
*/
public function findMauticUrl($url)
{
if ( function_exists('curl_version') ) {

$url = urldecode($url);
@ -77,23 +80,17 @@ class Whitelabeler {
curl_close($curl);

if ( $output == false ) {

return array(
'status' => 0,
'message' => 'Address timed out. Make sure it\'s accessible by your server\'s network.'
);

} else {

if ( $http_code[1] != 200) {

return array(
'status' => 0,
'message' => 'Mautic not found: '. $headers['status']
);

} else {

$license = substr(file_get_contents($url.'/LICENSE.txt', false, stream_context_create(array(
'ssl' => array(
'verify_peer' => false,
@ -102,42 +99,34 @@ class Whitelabeler {
))), 0, 6);

if ($license == 'Mautic') {

return array(
'status' => 1,
'message' => 'OK, Mautic found.'
);

} else {

return array(
'status' => 0,
'message' => 'Mautic not found. Make sure LICENSE.txt exists in the domain root, check for errors in your server error log.'
);

}
}

}

} else {

return array(
'status' => 0,
'message' => 'cURL PHP extension is not installed on your server.'
);
}


}

/*
|--------------------------------------------------------------------------
| Find Mautic version by path
|--------------------------------------------------------------------------
*/
public function mauticVersion($path) {

/*
|--------------------------------------------------------------------------
| Find Mautic version by path
|--------------------------------------------------------------------------
*/
public function mauticVersion($path)
{
$data = array();

if ( substr($path, -1) == '/' ) {
@ -145,26 +134,19 @@ class Whitelabeler {
}

if (file_exists($path.'/app/version.txt')) {

$file = fopen($path.'/app/version.txt', 'r') or die('Unable to open file!');

$version = trim(fread($file , filesize($path.'/app/version.txt')));

if (strpos($version, '-dev') !== false) {

return array(
'status' => 0,
'message' => 'You are using a development version of Mautic ('.$version.'). Whitelabeler only supports official, non-beta releases.'
);

} else {

return $this->templateVersions($version);

}

} else {

$release_metadata = $path.'/app/release_metadata.json';

// Look for >= 3.0.0 /app/release_metadata.json
@ -176,16 +158,12 @@ class Whitelabeler {
$version = $version['version'];

if (strpos($version, '-dev') !== false) {

return array(
'status' => 0,
'message' => 'You are using a development version of Mautic ('.$version.'). Whitelabeler only supports official, non-beta releases.'
);
} else {
return $this->templateVersions($version);
}

// Couldn't find version.txt or release_metadata.json
@ -195,11 +173,7 @@ class Whitelabeler {
'message' => $path.'/app/version.txt file not found.'
);
}



}

}


@ -208,35 +182,35 @@ class Whitelabeler {
| Check for an asset by URL
|--------------------------------------------------------------------------
*/
public function assetExists($url) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_HEADER => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_NOBODY => true,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false
));
$output = curl_exec($curl);
$headers = [];
$data = explode("\n",$output);
$headers['status'] = $data[0];
array_shift($data);
foreach($data as $key => $part) {
$middle = explode(":",$part);
if ( isset($middle[1]) ) {
$headers[trim($middle[0])] = trim($middle[1]);
}
}
$http_code = explode(' ', $headers['status']);

if ($http_code[1] == 200) {
return 1;
} else {
return 0;
}
public function assetExists($url)
{
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_HEADER => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_NOBODY => true,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false
));
$output = curl_exec($curl);
$headers = [];
$data = explode("\n",$output);
$headers['status'] = $data[0];
array_shift($data);
foreach($data as $key => $part) {
$middle = explode(":",$part);
if ( isset($middle[1]) ) {
$headers[trim($middle[0])] = trim($middle[1]);
}
}
$http_code = explode(' ', $headers['status']);

if ($http_code[1] == 200) {
return 1;
} else {
return 0;
}
}


@ -245,7 +219,8 @@ class Whitelabeler {
| Look for an image in assets folder
|--------------------------------------------------------------------------
*/
public function imageExists($image) {
public function imageExists($image)
{
if ( file_exists(__DIR__.'/assets/'.$image) ) {
return true;
} else {
@ -275,12 +250,10 @@ class Whitelabeler {
$submenu_bullet_bg,
$submenu_bullet_shadow
) {

// Replace app.css contents with template and new colors
$app_css = $path.'/app/bundles/CoreBundle/Assets/css/app.css';

if (file_exists($app_css)) {

$app_css_template = file_get_contents('templates/'.$version.'/app/bundles/CoreBundle/Assets/css/app.css');
$app_css_new = str_replace(
// Look for these template tags.
@ -297,21 +270,17 @@ class Whitelabeler {
$file = fopen($app_css, "w");
fwrite($file, $app_css_new);
fclose($file);

} else {

return array(
'status' => 0,
'message' => 'Unable to find app.css in your Mautic installation.'
);

}

// Replace libraries.css contents with template and new colors
$libraries_css = $path.'/app/bundles/CoreBundle/Assets/css/libraries/libraries.css';

if (file_exists($libraries_css)) {

$libraries_css_template = file_get_contents('templates/'.$version.'/app/bundles/CoreBundle/Assets/css/libraries/libraries.css');
$libraries_css_new = str_replace(
// Look for these template tags.
@ -328,14 +297,11 @@ class Whitelabeler {
'status' => 1,
'message' => 'CSS files updated with new colors!'
);

} else {

return array(
'status' => 0,
'message' => 'Unable to find libraries.css in your Mautic installation.'
);

}
}

@ -345,9 +311,8 @@ class Whitelabeler {
| Replace "Mautic" with Comapny Name
|--------------------------------------------------------------------------
*/

public function companyName($path, $version, $company_name, $footer_prefix, $footer) {

public function companyName($path, $version, $company_name, $footer_prefix, $footer)
{
$base_copyright = '/app/bundles/CoreBundle/Views/Default/base.html.php';
$head_title = '/app/bundles/CoreBundle/Views/Default/head.html.php';
$js = '1a.content.js';
@ -443,8 +408,8 @@ class Whitelabeler {
| Resize and Save Image File
|--------------------------------------------------------------------------
*/

public function imageResize($new_width, $original, $target) {
public function imageResize($new_width, $original, $target)
{
$info = getimagesize($original);
if ($info['mime'] == 'image/png') {
try {
@ -497,7 +462,6 @@ class Whitelabeler {
| Process and Replace Images
|--------------------------------------------------------------------------
*/

public function replaceImages(
$path,
$url,
@ -510,7 +474,6 @@ class Whitelabeler {
$login_margin, // array (top, bottom)
$favicon_image
) {

if ( $favicon_image == false ) {
$favicon_image = $login_image;
}
@ -568,7 +531,6 @@ class Whitelabeler {
$login_page = $path.'/app/bundles/UserBundle/Views/Security/base.html.php';

if ( file_exists($login_page) ) {

$login_page_template = file_get_contents($login_page);
$login_page_new = str_replace(
// Look for these template tags.
@ -586,26 +548,21 @@ class Whitelabeler {
'status' => 1,
'message' => 'Logos updated! '
);

} else {

return array(
'status' => 0,
'message' => $login_page.' NOT FOUND.'
);

}

}


/*
|--------------------------------------------------------------------------
| Used to run Mautic Console Commands (taken from upgrade.php)
|--------------------------------------------------------------------------
*/

public function runSymfonyCommand($path, $command, array $args) {
public function runSymfonyCommand($path, $command, array $args)
{
static $application;
require_once $path.'/app/autoload.php';
require_once $path.'/app/AppKernel.php';
@ -631,7 +588,6 @@ class Whitelabeler {
| Used to Clear Cache (taken from upgrade.php)
|--------------------------------------------------------------------------
*/

public function recursiveRemoveDirectory($directory) {
// if the path has a slash at the end we remove it here
if (substr($directory, -1) == '/') {
@ -680,13 +636,25 @@ class Whitelabeler {
}
}

// Rebuild the Cache
public function buildCache($path) {

/*
|--------------------------------------------------------------------------
| Rebuild the Cache
|--------------------------------------------------------------------------
*/
public function buildCache($path)
{
return $this->runSymfonyCommand($path, 'cache:clear', ['--no-interaction', '--env=prod', '--no-debug', '--no-warmup']);
}

// Clear and Rebuild the Cache
public function clearMauticCache($path) {

/*
|--------------------------------------------------------------------------
| Clear and Rebuild the Cache
|--------------------------------------------------------------------------
*/
public function clearMauticCache($path)
{
if (!$this->recursiveRemoveDirectory($path.'/app/cache/prod')) {
return array(
'status' => 0,
@ -699,8 +667,14 @@ class Whitelabeler {
);
}

// Rebuild Mautic Assets
public function rebuildAssets($path) {

/*
|--------------------------------------------------------------------------
| Rebuild Mautic Assets
|--------------------------------------------------------------------------
*/
public function rebuildAssets($path)
{
return $this->runSymfonyCommand($path, 'mautic:assets:generate', ['--no-interaction', '--env=prod', '--no-debug']);
}

@ -710,8 +684,8 @@ class Whitelabeler {
| Get Compatible Versions of Mautic for Whitelabeling
|--------------------------------------------------------------------------
*/

public function templateVersions($version) {
public function templateVersions($version)
{
$path = 'templates';
$versions = array();
foreach (new DirectoryIterator($path) as $file) {
@ -721,20 +695,16 @@ class Whitelabeler {
}
}
if (in_array(substr($version, 0, 3), $versions) || in_array($version, $versions)) {

return array(
'status' => 1,
'version' => $version,
'message' => 'Compatible version found ('.$version.')'
);

} else {

return array(
'status' => 0,
'message' => 'The version of Mautic you are using ('.$version.') is not currently supported.'
);

}
}

@ -745,7 +715,8 @@ class Whitelabeler {
| have been changed.
|--------------------------------------------------------------------------
*/
public function compareMauticVersions($v1, $v2) {
public function compareMauticVersions($v1, $v2)
{
$comparision = array();

$base_copyright = '/app/bundles/CoreBundle/Views/Default/base.html.php';
@ -855,14 +826,14 @@ class Whitelabeler {
return $comparision;
}


/*
|--------------------------------------------------------------------------
| Validate configuration values from config.json
|--------------------------------------------------------------------------
*/

public function validateConfigValues($file=false) {

public function validateConfigValues($file=false)
{
if ( $file != false ) {
$config_vals = $this->loadJsonConfig($file);
} else {
@ -997,7 +968,5 @@ class Whitelabeler {
'errors' => $errors,
'config' => $config_vals
);

}

}