mirror of
https://github.com/Bigherollc/wticreatorstudio.git
synced 2026-07-31 14:16:57 -04:00
77 lines
2.2 KiB
PHP
77 lines
2.2 KiB
PHP
<?php
|
|
namespace Modules\Import\Services;
|
|
use File;
|
|
|
|
class AugmentationService
|
|
{
|
|
public function __construct() {
|
|
$this->addImportUsersButtonToStaffIndex();
|
|
$this->updateUtilitiesLangFile();
|
|
}
|
|
|
|
public static function addImportUsersButtonToStaffIndex() {
|
|
|
|
|
|
$path = resource_path('views/backEnd/staffs/index.blade.php');
|
|
if (file_exists($path)) {
|
|
$update = false;
|
|
$content = file_get_contents($path);
|
|
if (!preg_match("/\@include\('import::components\._import_users'\)/", $content)) {
|
|
$matches = null;
|
|
preg_match("/route\(\'staffs\.create\'\)[.\s\S]+?<\/li>/", $content, $matches);
|
|
|
|
if (count($matches) > 0) {
|
|
$code = $matches[0];
|
|
$snippet = "\n
|
|
\t\t\t@if (isModuleActive('Import'))
|
|
\t\t\t\t@include('import::components._import_users')
|
|
\t\t\t@endif";
|
|
$code = $code.$snippet;
|
|
$content = preg_replace("/route\(\'staffs\.create\'\)[.\s\S]+?<\/li>/", $code, $content);
|
|
$update = true;
|
|
}
|
|
}
|
|
|
|
if ($update) {
|
|
file_put_contents($path, $content);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
public static function updateUtilitiesLangFile() {
|
|
|
|
|
|
$path = resource_path('lang/default/utilities.php');
|
|
if (file_exists($path)) {
|
|
$update = false;
|
|
$content = file_get_contents($path);
|
|
|
|
if (!preg_match("/import_users/", $content)) {
|
|
$matches = null;
|
|
preg_match('/Utilities\"\,/', $content, $matches);
|
|
if (count($matches) > 0) {
|
|
$code = $matches[0];
|
|
$snippet = "\n\t'select_file' => 'Select File',
|
|
'import' => 'Import',
|
|
'import_users' => 'Import Staffs',
|
|
'import_videos' => 'Import Videos',";
|
|
$code = $code.$snippet;
|
|
$content = preg_replace("/Utilities\"\,/", $code, $content);
|
|
$update = true;
|
|
}
|
|
}
|
|
|
|
if ($update) {
|
|
file_put_contents($path, $content);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
} |