repo
stringlengths
7
63
file_url
stringlengths
81
284
file_path
stringlengths
5
200
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:02:33
2026-01-05 05:24:06
truncated
bool
2 classes
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/app/Http/Controllers/ApiTokenController.php
Sso/app/Http/Controllers/ApiTokenController.php
<?php namespace App\Http\Controllers; use App\Models\ApiToken; use App\Http\Requests\ApiTokenRequest; use App\Http\Resources\ApiTokenResource; use Yajra\DataTables\DataTables; class ApiTokenController extends Controller { public function index() { return response()->format([ 'html' => view('api_tokens.index'), 'json' => ApiTokenResource::collection(ApiToken::paginate()), ]); } public function json(Datatables $dataTables) { $apiTokens = ApiToken::select()->get(); return $dataTables->of($apiTokens) ->addColumn('actions', function (ApiToken $apiToken) { return [ 'edit' => route('api-tokens.edit', $apiToken), 'destroy' => route('api-tokens.destroy', $apiToken), ]; }) ->addColumn('action_methods', function (ApiToken $apiToken) { return [ 'destroy' => 'DELETE', ]; }) ->rawColumns(['actions', 'active']) ->setRowId('id') ->make(true); } public function create() { $apiToken = new ApiToken(); $apiToken->fill(old()); return view('api_tokens.create', [ 'apiToken' => $apiToken, ]); } public function store(ApiTokenRequest $request) { $apiToken = new ApiToken(); $apiToken->fill($request->all()); $apiToken->save(); return response()->format([ 'html' => $this->getRouteBasedOnAction( $request->get('action'), [ self::FORM_ACTION_SAVE_CLOSE => 'api-tokens.index', self::FORM_ACTION_SAVE => 'api-tokens.edit', ], $apiToken )->with('success', sprintf('API token [%s] was created', $apiToken->token)), 'json' => new ApiTokenResource($apiToken), ]); } public function show(ApiToken $apiToken) { return response()->format([ 'html' => view('api-tokens.show', [ 'apiToken' => $apiToken, ]), 'json' => new ApiTokenResource($apiToken), ]); } public function edit(ApiToken $apiToken) { $apiToken->fill(old()); return view('api_tokens.edit', [ 'apiToken' => $apiToken, ]); } public function update(ApiTokenRequest $request, ApiToken $apiToken) { $apiToken->fill($request->all()); $apiToken->save(); return response()->format([ 'html' => $this->getRouteBasedOnAction( $request->get('action'), [ self::FORM_ACTION_SAVE_CLOSE => 'api-tokens.index', self::FORM_ACTION_SAVE => 'api-tokens.edit', ], $apiToken )->with('success', sprintf('API token [%s] was updated', $apiToken->token)), 'json' => new ApiTokenResource($apiToken), ]); } public function destroy(ApiToken $apiToken) { $apiToken->delete(); return response()->format([ 'html' => redirect(route('api-tokens.index'))->with('success', sprintf('API token [%s] was removed', $apiToken->token)), 'json' => new ApiTokenResource([]), ]); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/app/Http/Controllers/Controller.php
Sso/app/Http/Controllers/Controller.php
<?php namespace App\Http\Controllers; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Routing\Controller as BaseController; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; class Controller extends BaseController { use AuthorizesRequests, DispatchesJobs, ValidatesRequests; const FORM_ACTION_SAVE_CLOSE = 'save_close'; const FORM_ACTION_SAVE = 'save'; /** * Decide where to redirect based on form action. * * Array $formActionRoutes should contain at least route for FORM_ACTION_SAVE action. Format: * * [ * self::FORM_ACTION_SAVE_CLOSE => 'resource.index', * self::FORM_ACTION_SAVE => 'resource.edit', * ] * * @param string $action * @param array $formActionRoutes * @return \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse */ protected function getRouteBasedOnAction(string $action, array $formActionRoutes, $resource) { // FORM_ACTION_SAVE must be set, it's default action // if it's not, redirect back to previous view if (!isset($formActionRoutes[self::FORM_ACTION_SAVE])) { return redirect()->back(); } // if action wasn't provided with actions routes, use default action (FORM_ACTION_SAVE) if (!isset($formActionRoutes[$action])) { $action = self::FORM_ACTION_SAVE; } return redirect()->route($formActionRoutes[$action], $resource); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/app/Http/Controllers/UserController.php
Sso/app/Http/Controllers/UserController.php
<?php namespace App\Http\Controllers; use App\Models\User; use Tymon\JWTAuth\JWTAuth; use Yajra\DataTables\DataTables; class UserController extends Controller { public function index() { return response()->format([ 'html' => view('users.index'), ]); } public function json(Datatables $dataTables) { $users = User::select(['id', 'email', 'name', 'created_at', 'updated_at'])->get(); return $dataTables->of($users) ->addColumn('actions', function (User $user) { return [ 'destroy' => auth()->id() !== $user->id ? route('users.destroy', $user) : null, ]; }) ->addColumn('action_methods', function (User $user) { return [ 'destroy' => 'DELETE', ]; }) ->rawColumns(['actions']) ->setRowId('id') ->make(true); } public function destroy(JWTAuth $auth, User $user) { if (auth()->id() === $user->id) { return response()->format([ 'html' => redirect(route('users.index'))->with('error', 'You cannot remove yourself'), ]); } $user->delete(); return response()->format([ 'html' => redirect(route('users.index'))->with('success', sprintf('User [%s] was removed', $user->email)), ]); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/app/Http/Controllers/SettingsController.php
Sso/app/Http/Controllers/SettingsController.php
<?php namespace App\Http\Controllers; class SettingsController extends Controller { public function jwtwhitelist() { return response()->format([ 'html' => view('settings.jwtwhitelist', [ 'jwtwhitelist' => config('domain_whitelist') ]) ]); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/app/Http/Controllers/AuthController.php
Sso/app/Http/Controllers/AuthController.php
<?php namespace App\Http\Controllers; use App\Models\ApiToken; use App\UrlHelper; use App\Models\User; use Carbon\Carbon; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Redis; use Symfony\Component\HttpKernel\Exception\BadRequestHttpException; use Tymon\JWTAuth\Exceptions\JWTException; use Tymon\JWTAuth\Exceptions\TokenExpiredException; use Tymon\JWTAuth\Facades\JWTAuth; class AuthController extends Controller { public function login(Request $request, UrlHelper $urlHelper, \Tymon\JWTAuth\JWTAuth $auth) { $successUrl = $request->input('successUrl'); if (!$successUrl) { throw new BadRequestHttpException('missing successUrl query param'); } $errorUrl = $request->input('errorUrl'); if (!$errorUrl) { throw new BadRequestHttpException('missing errorUrl query param'); } if ($user = session()->get(User::USER_SUBJECT_SESSION_KEY)) { // Old class (kept for compatibility reasons) if ($user instanceof \App\User) { // reload correct type $user = User::where('email', $user->email)->first(); session()->put(User::USER_SUBJECT_SESSION_KEY, $user); } try { $userCheck = User::withTrashed()->where('id', $user->id)->first(); if (!$userCheck) { throw new JWTException("User #{$user->id} ({$user->email}) not found in the database"); } if ($userCheck->trashed()) { throw new JWTException("User #{$user->id} ({$user->email}) has been deleted"); } $token = $auth->fromSubject($user); $redirectUrl = $urlHelper->appendQueryParams($successUrl, [ 'token' => $token, ]); return redirect($redirectUrl); } catch (JWTException $e) { // cannot refresh the token (it might have been already blacklisted), let user log in again session()->forget(User::USER_SUBJECT_SESSION_KEY); } } $defaultProvider = config('auth.defaults.sso_provider'); // if there's only one provider, treat is as default $providers = config('auth.sso_providers'); if (count($providers) === 1) { $defaultProvider = array_key_first($providers); } // If the app has configured default provider, use it directly. if ($defaultProvider) { $redirectRoute = 'auth.' . $defaultProvider; if (!Route::has($redirectRoute)) { throw new \Exception("Unable to use provider [{$defaultProvider}], redirect route [{$redirectRoute}] is not defined"); } $redirectUrl = $urlHelper->appendQueryParams(route($redirectRoute), [ 'successUrl' => $successUrl, 'errorUrl' => $errorUrl, ]); return redirect($redirectUrl); } // Otherwise initialize all providers and let user choose. $providerRedirects = []; foreach ($providers as $key => $provider) { $redirectRoute = 'auth.' . $key; if (!Route::has($redirectRoute)) { throw new \Exception("Unable to use provider [{$key}], redirect route [{$redirectRoute}] is not defined"); } $providerRedirects[$key] = $urlHelper->appendQueryParams(route($redirectRoute), [ 'successUrl' => $successUrl, 'errorUrl' => $errorUrl, ]); } return view('auth.login', ['providerRedirects' => $providerRedirects]); } public function logout(\Tymon\JWTAuth\JWTAuth $auth) { $user = session()->remove(User::USER_SUBJECT_SESSION_KEY); if ($user) { $user->last_logout_at = Carbon::now(); $user->save(); } return redirect()->back(); } public function logoutWeb() { Auth::logout(); return redirect()->back(); } public function refresh(\Tymon\JWTAuth\JWTAuth $auth, Request $request) { try { $token = $auth->setRequest($request)->parseToken(); $userId = $token->payload()->get('id'); $lastLogout = Redis::hget(User::USER_LAST_LOGOUT_KEY, $userId); if ($lastLogout && $lastLogout > $token->getClaim('iat')) { throw new TokenExpiredException(); } $userCheck = User::withTrashed()->where('id', $userId)->first(); if (!$userCheck) { session()->forget(User::USER_SUBJECT_SESSION_KEY); return response()->json([ 'code' => 'user_not_found', 'detail' => 'user extracted from token was not found', 'redirect' => route('auth.login'), ])->setStatusCode(401); } if ($userCheck->trashed()) { session()->forget(User::USER_SUBJECT_SESSION_KEY); return response()->json([ 'code' => 'user_deleted', 'detail' => 'user has been deleted', 'redirect' => route('auth.login'), ])->setStatusCode(401); } $refreshedToken = $token->refresh(); return response()->json([ 'token' => $refreshedToken, ]); } catch (TokenExpiredException $e) { session()->forget(User::USER_SUBJECT_SESSION_KEY); return response()->json([ 'code' => 'token_expired', 'detail' => 'token is expired: refresh timeout hit', 'redirect' => route('auth.login'), ])->setStatusCode(401); } catch (JWTException $e) { return response()->json([ 'code' => 'token_invalid', 'detail' => 'provided token is invalid', 'redirect' => route('auth.login'), ])->setStatusCode(400); } } public function introspect() { $payload = JWTAuth::getPayload(); return response()->json([ 'id' => $payload['id'], 'name' => $payload->get('name'), 'email' => $payload->get('email'), 'scopes' => $payload->get('scopes'), ]); } public function apiToken(Request $request) { $bearerToken = $request->bearerToken(); $token = ApiToken::whereToken($bearerToken)->first(); if (!$token) { return response()->json(null, 404); } return response()->json(null, 200); } public function invalidate(\Tymon\JWTAuth\JWTAuth $auth, Request $request) { $auth = $auth->setRequest($request)->parseToken(); Redis::hset(User::USER_LAST_LOGOUT_KEY, $auth->payload()->get('id'), time()); try { $auth->invalidate(); } catch (\Exception $e) { // no token found or token blacklisted, we're fine } return response()->json([ 'redirect' => route('auth.logout'), ], 200); } public function error(Request $request) { $message = $request->get('error'); return response()->format([ 'html' => view('auth.error', [ 'message' => $message, ]), 'json' => [ 'message' => $message, ], ]); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/app/Http/Controllers/DashboardController.php
Sso/app/Http/Controllers/DashboardController.php
<?php namespace App\Http\Controllers; use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Bus\DispatchesJobs; use Illuminate\Foundation\Validation\ValidatesRequests; class DashboardController extends Controller { use AuthorizesRequests, DispatchesJobs, ValidatesRequests; }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/app/Http/Controllers/Auth/GoogleController.php
Sso/app/Http/Controllers/Auth/GoogleController.php
<?php namespace App\Http\Controllers\Auth; use App\EmailWhitelist; use App\Models\GoogleUser; use App\Http\Controllers\Controller; use App\UrlHelper; use App\Models\User; use Illuminate\Http\Request; use Laravel\Socialite\Two\GoogleProvider; use Symfony\Component\HttpFoundation\Response; use Socialite; use Session; use Tymon\JWTAuth\JWT; class GoogleController extends Controller { const SUCCESS_URL_KEY = 'url.success'; const ERROR_URL_KEY = 'url.error'; const SUCCESS_URL_QUERY_PARAM = 'successUrl'; const ERROR_URL_QUERY_PARAM = 'errorUrl'; /** * Redirect the user to the GitHub authentication page. * * @param Request $request * @return Response */ public function redirect(Request $request) { Session::put(self::SUCCESS_URL_KEY, $request->input(self::SUCCESS_URL_QUERY_PARAM, '/')); Session::put(self::ERROR_URL_KEY, $request->input(self::ERROR_URL_QUERY_PARAM, '/')); /** @var GoogleProvider $driver */ $driver = Socialite::driver(User::PROVIDER_GOOGLE); return $driver->stateless()->redirect(); } /** * Obtain the user information from GitHub. * * @param JWT $jwt * @param EmailWhitelist $whitelist * @param UrlHelper $urlHelper * * @return Response */ public function callback(JWT $jwt, EmailWhitelist $whitelist, UrlHelper $urlHelper) { $backUrl = Session::get(self::SUCCESS_URL_KEY); Session::forget(self::SUCCESS_URL_KEY); $errorUrl = Session::get(self::ERROR_URL_KEY); Session::forget(self::ERROR_URL_KEY); /** @var GoogleProvider $driver */ $driver = Socialite::driver(User::PROVIDER_GOOGLE); /** @var \Laravel\Socialite\Two\User $factoryUser */ $factoryUser = $driver->stateless()->user(); if (!$whitelist->validate($factoryUser->getEmail())) { $errorUrl = $urlHelper->appendQueryParams($errorUrl, [ 'error' => sprintf('email not whitelisted to log in: %s', $factoryUser->getEmail()), ]); return redirect($errorUrl); } /** @var User $user */ $user = User::withTrashed()->firstOrCreate([ 'email' => $factoryUser->getEmail(), ], [ 'email' => $factoryUser->getEmail(), 'name' => $factoryUser->getName(), ]); if ($user->trashed()) { // previously trashed user was allowed access again, just restore $user->restore(); } /** @var GoogleUser $googleUser */ $googleUser = $user->googleUser()->firstOrNew([ 'google_id' => $factoryUser->getId(), 'nickname' => $factoryUser->getNickname(), 'name' => $factoryUser->getName(), ]); $googleUser->nickname = $factoryUser->getNickname(); $googleUser->name = $factoryUser->getName(); $googleUser->save(); $user->latestProvider = User::PROVIDER_GOOGLE; $token = $jwt->fromSubject($user); session()->put(User::USER_SUBJECT_SESSION_KEY, $user); $redirectUrl = $urlHelper->appendQueryParams($backUrl, [ 'token' => $token, ]); return redirect($redirectUrl); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/app/Http/Middleware/VerifyUserToken.php
Sso/app/Http/Middleware/VerifyUserToken.php
<?php namespace App\Http\Middleware; use App\Models\User; use Closure; use Illuminate\Contracts\Routing\ResponseFactory; use Illuminate\Http\Request; use Illuminate\Support\Facades\Redis; use Tymon\JWTAuth\Exceptions\JWTException; use Tymon\JWTAuth\Exceptions\TokenExpiredException; use Tymon\JWTAuth\JWTAuth; class VerifyUserToken { protected $auth; protected $response; public function __construct(JWTAuth $auth, ResponseFactory $response) { $this->auth = $auth; $this->response = $response; } /** * Handle an incoming request. * * @param Request $request * @param Closure $next * @return mixed * @internal param JWTAuth $auth * @internal param ResponseFactory $response */ public function handle(Request $request, Closure $next) { if (!$this->auth->parser()->setRequest($request)->hasToken()) { return $this->respond('token_not_provided', 'no JWT token was provided', 400); } try { $user = $this->auth->parseToken()->authenticate(); if (!$user) { return $this->respond('user_not_found', 'user extracted from token was not found', 401); } if ($user->trashed()) { return $this->respond('user_deleted', 'user has been deleted', 401); } $payload = $this->auth->payload(); } catch (TokenExpiredException $e) { return $this->respond('token_expired', 'provided token has already expired: ' . $e->getMessage(), 401); } catch (JWTException $e) { return $this->respond('token_invalid', 'provided token is invalid: ' . $e->getMessage(), 401); } $lastLogout = Redis::hget(User::USER_LAST_LOGOUT_KEY, $payload->get('id')); if ($lastLogout && $lastLogout > $this->auth->getClaim('iat')) { if (config('jwt.blacklist_enabled')) { $this->auth->invalidate(); } return $this->respond('token_expired', 'provided token was invalidated', 401); } return $next($request); } protected function respond($code, $detail, $status) { return $this->response->json([ 'code' => $code, 'detail' => $detail, 'redirect' => route('auth.login'), ], $status); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/app/Http/Resources/ApiTokenResource.php
Sso/app/Http/Resources/ApiTokenResource.php
<?php namespace App\Http\Resources; use Remp\LaravelHelpers\Resources\JsonResource; class ApiTokenResource extends JsonResource { }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/app/Contracts/Providers/Illuminate.php
Sso/app/Contracts/Providers/Illuminate.php
<?php namespace App\Contracts\Providers; use Illuminate\Support\Facades\Auth; use Illuminate\Contracts\Auth\Guard as GuardContract; /** * Class Illuminate * * Purpose of this class is override usage of default guard set by application * and always use Web guard when using JWTAuth to get user info. * * @package App\Contracts\Providers */ class Illuminate extends \Tymon\JWTAuth\Providers\Auth\Illuminate { protected $auth; public function __construct(GuardContract $auth) { parent::__construct($auth); $this->auth = Auth::guard('web'); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/app/Console/Command.php
Sso/app/Console/Command.php
<?php namespace App\Console; use Illuminate\Console\Command as ConsoleCommand; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; class Command extends ConsoleCommand { public function initialize(InputInterface $input, OutputInterface $output) { parent::initialize($input, $output); $memoryLimits = config('system.commands_memory_limits'); if (isset($memoryLimits[$this->getName()])) { ini_set('memory_limit', $memoryLimits[$this->getName()]); } } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/app/Console/Commands/PostInstallCommand.php
Sso/app/Console/Commands/PostInstallCommand.php
<?php namespace App\Console\Commands; use App\Console\Command; class PostInstallCommand extends Command { protected $signature = 'service:post-install'; protected $description = 'Executes services needed to be run after the Beam installation/update'; public function handle() { return self::SUCCESS; } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/app/Console/Commands/ReconstructLoggedOutCache.php
Sso/app/Console/Commands/ReconstructLoggedOutCache.php
<?php namespace App\Console\Commands; use App\Models\User; use Illuminate\Console\Command; use Illuminate\Support\Facades\Redis; class ReconstructLoggedOutCache extends Command { protected $signature = 'reconstruct:logged_out_cache'; protected $description = 'Reconstructs last logout date cache stored in redis'; public function handle() { /** @var User[] $users */ $users = User::all(); $bar = $this->output->createProgressBar(count($users)); Redis::del(User::USER_LAST_LOGOUT_KEY); foreach ($users as $user) { if (!$user->last_logout_at) { $bar->advance(); continue; } Redis::hset(User::USER_LAST_LOGOUT_KEY, $user->id, $user->last_logout_at->timestamp); $bar->advance(); } $bar->finish(); $this->line(''); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/app/Models/GoogleUser.php
Sso/app/Models/GoogleUser.php
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; class GoogleUser extends Model { protected $fillable = [ 'nickname', 'name', 'avatar', 'google_id', ]; protected $hidden = [ 'token', 'refresh_token', 'expires_in', ]; public function user(): BelongsTo { return $this->belongsTo(User::class); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/app/Models/User.php
Sso/app/Models/User.php
<?php namespace App\Models; use Carbon\Carbon; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Relations\HasOne; use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Support\Facades\Redis; use Tymon\JWTAuth\Contracts\JWTSubject; class User extends Authenticatable implements JWTSubject { use HasFactory, SoftDeletes; const PROVIDER_GOOGLE = 'google'; const USER_SUBJECT_SESSION_KEY = 'user_token'; const USER_LAST_LOGOUT_KEY = 'user_logout'; public string $latestProvider; protected $fillable = [ 'name', 'email', ]; protected $casts = [ 'last_logout_at' => 'datetime', ]; public function delete() { $this->last_logout_at = Carbon::now(); $this->save(); Redis::hset(User::USER_LAST_LOGOUT_KEY, $this->id, time()); return parent::delete(); } public function googleUser(): HasOne { return $this->hasOne(GoogleUser::class); } /** * Get the identifier that will be stored in the subject claim of the JWT. * * @return mixed */ public function getJWTIdentifier() { return $this->getKey(); } /** * Return a key value array, containing any custom claims to be added to the JWT. * * @return array */ public function getJWTCustomClaims() { /** @var GoogleUser $googleUser */ $googleUser = $this->googleUser; $name = match ($this->latestProvider) { self::PROVIDER_GOOGLE => $googleUser->name, default => null, }; return [ 'provider' => $this->latestProvider, 'id' => $this->id, 'name' => $name, 'email' => $this->email, 'scopes' => [], ]; } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/app/Models/ApiToken.php
Sso/app/Models/ApiToken.php
<?php namespace App\Models; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\SoftDeletes; use Ramsey\Uuid\Uuid; class ApiToken extends Model { use SoftDeletes; protected $fillable = [ 'name', 'active', ]; protected $casts = [ 'active' => 'boolean', 'name' => 'string', ]; public static $rules = [ 'name' => 'required|string|max:255', 'active' => 'required|boolean', ]; protected static function boot() { parent::boot(); static::creating(function (ApiToken $apiToken) { $apiToken->token = Uuid::uuid4()->toString(); }); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/app/Providers/AppServiceProvider.php
Sso/app/Providers/AppServiceProvider.php
<?php namespace App\Providers; use Illuminate\Database\Connection; use Illuminate\Pagination\Paginator; use Illuminate\Support\Facades\URL; use Illuminate\Support\ServiceProvider; use Remp\LaravelHelpers\Database\MySqlConnection; class AppServiceProvider extends ServiceProvider { /** * Bootstrap any application services. * * @return void */ public function boot() { if (config('app.force_https')) { URL::forceScheme('https'); } Paginator::useBootstrapThree(); } /** * Register any application services. * * @return void */ public function register() { Connection::resolverFor('mysql', function ($connection, $database, $prefix, $config) { // Use local resolver to control DateTimeInterface bindings. return new MySqlConnection($connection, $database, $prefix, $config); }); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/bootstrap/app.php
Sso/bootstrap/app.php
<?php use Illuminate\Foundation\Application; use Illuminate\Foundation\Configuration\Exceptions; use Illuminate\Foundation\Configuration\Middleware; use Sentry\Laravel\Integration; return Application::configure(basePath: dirname(__DIR__)) ->withRouting( web: __DIR__.'/../routes/web.php', api: __DIR__.'/../routes/api.php', commands: __DIR__.'/../routes/console.php', health: '/up', ) ->withMiddleware(function (Middleware $middleware) { $middleware->trustProxies(at: '*'); }) ->withExceptions(function (Exceptions $exceptions) { Integration::handles($exceptions); })->create();
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/bootstrap/providers.php
Sso/bootstrap/providers.php
<?php return [ App\Providers\AppServiceProvider::class, ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/tests/TestCase.php
Sso/tests/TestCase.php
<?php namespace Tests; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase { use CreatesApplication; }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/tests/CreatesApplication.php
Sso/tests/CreatesApplication.php
<?php namespace Tests; use Illuminate\Contracts\Console\Kernel; trait CreatesApplication { /** * Creates the application. * * @return \Illuminate\Foundation\Application */ public function createApplication() { $app = require __DIR__.'/../bootstrap/app.php'; $app->make(Kernel::class)->bootstrap(); return $app; } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/routes/web.php
Sso/routes/web.php
<?php /* |-------------------------------------------------------------------------- | Web Routes |-------------------------------------------------------------------------- | | Here is where you can register web routes for your application. These | routes are loaded by the RouteServiceProvider within a group which | contains the "web" middleware group. Now create something great! | */ use App\Http\Controllers\ApiTokenController; use App\Http\Controllers\Auth\GoogleController; use App\Http\Controllers\AuthController; use App\Http\Controllers\SettingsController; use App\Http\Controllers\UserController; use Illuminate\Support\Facades\Route; use Remp\LaravelSso\Http\Middleware\VerifyJwtToken; Route::get('/error', [AuthController::class, 'error'])->name('sso.error'); Route::middleware(VerifyJwtToken::class)->group(function () { Route::get('/', [ApiTokenController::class, 'index']); Route::get('api-tokens/json', [ApiTokenController::class, 'json'])->name('api-tokens.json'); Route::resource('api-tokens', ApiTokenController::class); Route::get('users', [UserController::class, 'index'])->name('users.index'); Route::get('users/json', [UserController::class, 'json'])->name('users.json'); Route::delete('users/{user}', [UserController::class, 'destroy'])->name('users.destroy'); Route::get('auth/logout-web', [AuthController::class, 'logoutWeb'])->name('auth.logout-web'); Route::get('settings/jwtwhitelist', [SettingsController::class, 'jwtwhitelist'])->name('settings.jwtwhitelist'); }); Route::get('auth/login', [AuthController::class, 'login'])->name('auth.login'); Route::get('auth/logout', [AuthController::class, 'logout'])->name('auth.logout'); Route::get('auth/google', [GoogleController::class, 'redirect'])->name('auth.google'); Route::get('auth/google/callback', [GoogleController::class, 'callback']);
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/routes/api.php
Sso/routes/api.php
<?php use App\Http\Controllers\AuthController; use App\Http\Middleware\VerifyUserToken; use Illuminate\Support\Facades\Route; /* |-------------------------------------------------------------------------- | API Routes |-------------------------------------------------------------------------- | | Here is where you can register API routes for your application. These | routes are loaded by the RouteServiceProvider within a group which | is assigned the "api" middleware group. Enjoy building your API! | */ Route::middleware(VerifyUserToken::class)->group(function() { Route::get('auth/introspect', [AuthController::class, 'introspect'])->name('auth.introspect'); }); Route::post('auth/refresh', [AuthController::class, 'refresh'])->name('auth.refresh'); Route::post('auth/invalidate', [AuthController::class, 'invalidate'])->name('auth.invalidate'); Route::get('auth/check-token', [AuthController::class, 'apiToken'])->name('auth.check-token');
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/routes/console.php
Sso/routes/console.php
<?php use Illuminate\Foundation\Inspiring; use Illuminate\Support\Facades\Artisan; /* |-------------------------------------------------------------------------- | Console Routes |-------------------------------------------------------------------------- | | This file is where you may define all of your Closure based console | commands. Each Closure is bound to a command instance allowing a | simple approach to interacting with each command's IO methods. | */ Artisan::command('inspire', function () { $this->comment(Inspiring::quote()); })->purpose('Display an inspiring quote');
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/public/index.php
Sso/public/index.php
<?php use Illuminate\Foundation\Application; use Illuminate\Http\Request; define('LARAVEL_START', microtime(true)); // Determine if the application is in maintenance mode... if (file_exists($maintenance = __DIR__.'/../storage/framework/maintenance.php')) { require $maintenance; } // Register the Composer autoloader... require __DIR__.'/../vendor/autoload.php'; // Bootstrap Laravel and handle the request... /** @var Application $app */ $app = require_once __DIR__.'/../bootstrap/app.php'; $app->handleRequest(Request::capture());
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/app.php
Sso/config/app.php
<?php return [ /* |-------------------------------------------------------------------------- | Application Name |-------------------------------------------------------------------------- | | This value is the name of your application, which will be used when the | framework needs to place the application's name in a notification or | other UI elements where an application name needs to be displayed. | */ 'name' => env('APP_NAME', 'REMP SSO'), /* |-------------------------------------------------------------------------- | Application Environment |-------------------------------------------------------------------------- | | This value determines the "environment" your application is currently | running in. This may determine how you prefer to configure various | services the application utilizes. Set this in your ".env" file. | */ 'env' => env('APP_ENV', 'production'), /* |-------------------------------------------------------------------------- | Application Debug Mode |-------------------------------------------------------------------------- | | When your application is in debug mode, detailed error messages with | stack traces will be shown on every error that occurs within your | application. If disabled, a simple generic error page is shown. | */ 'debug' => (bool) env('APP_DEBUG', false), /* |-------------------------------------------------------------------------- | Application URL |-------------------------------------------------------------------------- | | This URL is used by the console to properly generate URLs when using | the Artisan command line tool. You should set this to the root of | the application so that it's available within Artisan commands. | */ 'url' => env('APP_URL', 'http://localhost'), /* |-------------------------------------------------------------------------- | Application Timezone |-------------------------------------------------------------------------- | | Here you may specify the default timezone for your application, which | will be used by the PHP date and date-time functions. The timezone | is set to "UTC" by default as it is suitable for most use cases. | */ 'timezone' => 'UTC', /* |-------------------------------------------------------------------------- | Application Locale Configuration |-------------------------------------------------------------------------- | | The application locale determines the default locale that will be used | by Laravel's translation / localization methods. This option can be | set to any locale for which you plan to have translation strings. | */ 'locale' => env('APP_LOCALE', 'en'), 'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'), 'faker_locale' => env('APP_FAKER_LOCALE', 'en_US'), /* |-------------------------------------------------------------------------- | Encryption Key |-------------------------------------------------------------------------- | | This key is utilized by Laravel's encryption services and should be set | to a random, 32 character string to ensure that all encrypted values | are secure. You should do this prior to deploying the application. | */ 'cipher' => 'AES-256-CBC', 'key' => env('APP_KEY'), 'previous_keys' => [ ...array_filter( explode(',', env('APP_PREVIOUS_KEYS', '')) ), ], /* |-------------------------------------------------------------------------- | Maintenance Mode Driver |-------------------------------------------------------------------------- | | These configuration options determine the driver used to determine and | manage Laravel's "maintenance mode" status. The "cache" driver will | allow maintenance mode to be controlled across multiple machines. | | Supported drivers: "file", "cache" | */ 'maintenance' => [ 'driver' => env('APP_MAINTENANCE_DRIVER', 'file'), 'store' => env('APP_MAINTENANCE_STORE', 'database'), ], ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/tracy.php
Sso/config/tracy.php
<?php return [ 'enabled' => env('APP_DEBUG') === true, 'showBar' => env('APP_ENV') !== 'production', 'accepts' => [ 'text/html', ], 'appendTo' => 'body', 'editor' => env('APP_DEBUG_EDITOR', 'phpstorm://open?file=%file&line=%line'), 'maxDepth' => 4, 'maxLength' => 1000, 'scream' => true, 'showLocation' => true, 'strictMode' => true, 'panels' => [ 'routing' => true, 'database' => true, 'view' => true, 'event' => true, 'session' => true, 'request' => true, 'auth' => true, 'html-validator' => true, 'terminal' => true, ], ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/logging.php
Sso/config/logging.php
<?php use Monolog\Handler\NullHandler; use Monolog\Handler\StreamHandler; use Monolog\Handler\SyslogUdpHandler; return [ /* |-------------------------------------------------------------------------- | Default Log Channel |-------------------------------------------------------------------------- | | This option defines the default log channel that gets used when writing | messages to the logs. The name specified in this option should match | one of the channels defined in the "channels" configuration array. | */ 'default' => env('LOG_CHANNEL', 'stack'), /* |-------------------------------------------------------------------------- | Log Channels |-------------------------------------------------------------------------- | | Here you may configure the log channels for your application. Out of | the box, Laravel uses the Monolog PHP logging library. This gives | you a variety of powerful log handlers / formatters to utilize. | | Available Drivers: "single", "daily", "slack", "syslog", | "errorlog", "monolog", | "custom", "stack" | */ 'channels' => [ 'stack' => [ 'driver' => 'stack', 'channels' => ['single'], 'ignore_exceptions' => false, ], 'airbrake' => [ 'driver' => 'custom', 'via' => App\AirbrakeLogger::class, 'level' => 'notice', ], 'single' => [ 'driver' => 'single', 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), 'permission' => 0666, ], 'daily' => [ 'driver' => 'daily', 'path' => storage_path('logs/laravel.log'), 'level' => env('LOG_LEVEL', 'debug'), 'days' => 14, 'permission' => 0666, ], 'slack' => [ 'driver' => 'slack', 'url' => env('LOG_SLACK_WEBHOOK_URL'), 'username' => 'Laravel Log', 'emoji' => ':boom:', 'level' => env('LOG_LEVEL', 'critical'), ], 'papertrail' => [ 'driver' => 'monolog', 'level' => env('LOG_LEVEL', 'debug'), 'handler' => SyslogUdpHandler::class, 'handler_with' => [ 'host' => env('PAPERTRAIL_URL'), 'port' => env('PAPERTRAIL_PORT'), ], ], 'stderr' => [ 'driver' => 'monolog', 'level' => env('LOG_LEVEL', 'debug'), 'handler' => StreamHandler::class, 'formatter' => env('LOG_STDERR_FORMATTER'), 'with' => [ 'stream' => 'php://stderr', ], ], 'syslog' => [ 'driver' => 'syslog', 'level' => env('LOG_LEVEL', 'debug'), ], 'errorlog' => [ 'driver' => 'errorlog', 'level' => env('LOG_LEVEL', 'debug'), ], 'null' => [ 'driver' => 'monolog', 'handler' => NullHandler::class, ], 'emergency' => [ 'path' => storage_path('logs/laravel.log'), ], ], ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/session.php
Sso/config/session.php
<?php use Illuminate\Support\Str; return [ /* |-------------------------------------------------------------------------- | Default Session Driver |-------------------------------------------------------------------------- | | This option controls the default session "driver" that will be used on | requests. By default, we will use the lightweight native driver but | you may specify any of the other wonderful drivers provided here. | | Supported: "file", "cookie", "database", "apc", | "memcached", "redis", "dynamodb", "array" | */ 'driver' => env('SESSION_DRIVER', 'file'), /* |-------------------------------------------------------------------------- | Session Lifetime |-------------------------------------------------------------------------- | | Here you may specify the number of minutes that you wish the session | to be allowed to remain idle before it expires. If you want them | to immediately expire on the browser closing, set that option. | */ 'lifetime' => env('SESSION_LIFETIME', 20160), // default 2 weeks, same as JWT lifetime 'expire_on_close' => false, /* |-------------------------------------------------------------------------- | Session Encryption |-------------------------------------------------------------------------- | | This option allows you to easily specify that all of your session data | should be encrypted before it is stored. All encryption will be run | automatically by Laravel and you can use the Session like normal. | */ 'encrypt' => false, /* |-------------------------------------------------------------------------- | Session File Location |-------------------------------------------------------------------------- | | When using the native session driver, we need a location where session | files may be stored. A default has been set for you but a different | location may be specified. This is only needed for file sessions. | */ 'files' => storage_path('framework/sessions'), /* |-------------------------------------------------------------------------- | Session Database Connection |-------------------------------------------------------------------------- | | When using the "database" or "redis" session drivers, you may specify a | connection that should be used to manage these sessions. This should | correspond to a connection in your database configuration options. | */ 'connection' => env('SESSION_CONNECTION', 'session'), /* |-------------------------------------------------------------------------- | Session Database Table |-------------------------------------------------------------------------- | | When using the "database" session driver, you may specify the table we | should use to manage the sessions. Of course, a sensible default is | provided for you; however, you are free to change this as needed. | */ 'table' => 'sessions', /* |-------------------------------------------------------------------------- | Session Cache Store |-------------------------------------------------------------------------- | | While using one of the framework's cache driven session backends you may | list a cache store that should be used for these sessions. This value | must match with one of the application's configured cache "stores". | | Affects: "apc", "dynamodb", "memcached", "redis" | */ 'store' => env('SESSION_STORE', null), /* |-------------------------------------------------------------------------- | Session Sweeping Lottery |-------------------------------------------------------------------------- | | Some session drivers must manually sweep their storage location to get | rid of old sessions from storage. Here are the chances that it will | happen on a given request. By default, the odds are 2 out of 100. | */ 'lottery' => [2, 100], /* |-------------------------------------------------------------------------- | Session Cookie Name |-------------------------------------------------------------------------- | | Here you may change the name of the cookie used to identify a session | instance by ID. The name specified here will get used every time a | new session cookie is created by the framework for every driver. | */ 'cookie' => env( 'SESSION_COOKIE', Str::slug(env('APP_NAME', 'laravel'), '_').'_session' ), /* |-------------------------------------------------------------------------- | Session Cookie Path |-------------------------------------------------------------------------- | | The session cookie path determines the path for which the cookie will | be regarded as available. Typically, this will be the root path of | your application but you are free to change this when necessary. | */ 'path' => '/', /* |-------------------------------------------------------------------------- | Session Cookie Domain |-------------------------------------------------------------------------- | | Here you may change the domain of the cookie used to identify a session | in your application. This will determine which domains the cookie is | available to in your application. A sensible default has been set. | */ 'domain' => env('SESSION_DOMAIN', null), /* |-------------------------------------------------------------------------- | HTTPS Only Cookies |-------------------------------------------------------------------------- | | By setting this option to true, session cookies will only be sent back | to the server if the browser has a HTTPS connection. This will keep | the cookie from being sent to you if it can not be done securely. | */ 'secure' => env('SESSION_SECURE_COOKIE'), /* |-------------------------------------------------------------------------- | HTTP Access Only |-------------------------------------------------------------------------- | | Setting this value to true will prevent JavaScript from accessing the | value of the cookie and the cookie will only be accessible through | the HTTP protocol. You are free to modify this option if needed. | */ 'http_only' => true, /* |-------------------------------------------------------------------------- | Same-Site Cookies |-------------------------------------------------------------------------- | | This option determines how your cookies behave when cross-site requests | take place, and can be used to mitigate CSRF attacks. By default, we | will set this value to "lax" since this is a secure default value. | | Supported: "lax", "strict", "none", null | */ 'same_site' => null, ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/queue.php
Sso/config/queue.php
<?php return [ /* |-------------------------------------------------------------------------- | Default Queue Connection Name |-------------------------------------------------------------------------- | | Laravel's queue API supports an assortment of back-ends via a single | API, giving you convenient access to each back-end using the same | syntax for every one. Here you may define a default connection. | */ 'default' => env('QUEUE_CONNECTION', 'sync'), /* |-------------------------------------------------------------------------- | Queue Connections |-------------------------------------------------------------------------- | | Here you may configure the connection information for each server that | is used by your application. A default configuration has been added | for each back-end shipped with Laravel. You are free to add more. | | Drivers: "sync", "database", "beanstalkd", "sqs", "redis", "null" | */ 'connections' => [ 'sync' => [ 'driver' => 'sync', ], 'database' => [ 'driver' => 'database', 'table' => 'jobs', 'queue' => 'default', 'retry_after' => 90, 'after_commit' => false, ], 'beanstalkd' => [ 'driver' => 'beanstalkd', 'host' => 'localhost', 'queue' => 'default', 'retry_after' => 90, 'block_for' => 0, 'after_commit' => false, ], 'sqs' => [ 'driver' => 'sqs', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'prefix' => env('SQS_PREFIX', 'https://sqs.us-east-1.amazonaws.com/your-account-id'), 'queue' => env('SQS_QUEUE', 'default'), 'suffix' => env('SQS_SUFFIX'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'after_commit' => false, ], 'redis' => [ 'driver' => 'redis', 'connection' => 'queue', 'queue' => env('REDIS_QUEUE', 'default'), 'retry_after' => 90, 'block_for' => null, 'after_commit' => false, ], ], /* |-------------------------------------------------------------------------- | Failed Queue Jobs |-------------------------------------------------------------------------- | | These options configure the behavior of failed queue job logging so you | can control which database and table are used to store the jobs that | have failed. You may change them to any database / table you wish. | */ 'failed' => [ 'driver' => env('QUEUE_FAILED_DRIVER', 'database-uuids'), 'database' => env('DB_CONNECTION', 'mysql'), 'table' => 'failed_jobs', ], ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/jwt.php
Sso/config/jwt.php
<?php /* * This file is part of jwt-auth. * * (c) Sean Tymon <tymon148@gmail.com> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ return [ /* |-------------------------------------------------------------------------- | JWT Authentication Secret |-------------------------------------------------------------------------- | | Don't forget to set this in your .env file, as it will be used to sign | your tokens. A helper command is provided for this: | `php artisan jwt:secret` | | Note: This will be used for Symmetric algorithms only (HMAC), | since RSA and ECDSA use a private/public key combo (See below). | */ 'secret' => env('JWT_SECRET'), /* |-------------------------------------------------------------------------- | JWT Authentication Keys |-------------------------------------------------------------------------- | | The algorithm you are using, will determine whether your tokens are | signed with a random string (defined in `JWT_SECRET`) or using the | following public & private keys. | | Symmetric Algorithms: | HS256, HS384 & HS512 will use `JWT_SECRET`. | | Asymmetric Algorithms: | RS256, RS384 & RS512 / ES256, ES384 & ES512 will use the keys below. | */ 'keys' => [ /* |-------------------------------------------------------------------------- | Public Key |-------------------------------------------------------------------------- | | A path or resource to your public key. | | E.g. 'file://path/to/public/key' | */ 'public' => env('JWT_PUBLIC_KEY'), /* |-------------------------------------------------------------------------- | Private Key |-------------------------------------------------------------------------- | | A path or resource to your private key. | | E.g. 'file://path/to/private/key' | */ 'private' => env('JWT_PRIVATE_KEY'), /* |-------------------------------------------------------------------------- | Passphrase |-------------------------------------------------------------------------- | | The passphrase for your private key. Can be null if none set. | */ 'passphrase' => env('JWT_PASSPHRASE'), ], /* |-------------------------------------------------------------------------- | JWT time to live |-------------------------------------------------------------------------- | | Specify the length of time (in minutes) that the token will be valid for. | Defaults to 1 hour. | | You can also set this to null, to yield a never expiring token. | Some people may want this behaviour for e.g. a mobile app. | This is not particularly recommended, so make sure you have appropriate | systems in place to revoke the token if necessary. | Notice: If you set this to null you should remove 'exp' element from 'required_claims' list. | */ 'ttl' => env('JWT_TTL', 60), /* |-------------------------------------------------------------------------- | Refresh time to live |-------------------------------------------------------------------------- | | Specify the length of time (in minutes) that the token can be refreshed | within. I.E. The user can refresh their token within a 2 week window of | the original token being created until they must re-authenticate. | Defaults to 2 weeks. | | You can also set this to null, to yield an infinite refresh time. | Some may want this instead of never expiring tokens for e.g. a mobile app. | This is not particularly recommended, so make sure you have appropriate | systems in place to revoke the token if necessary. | */ 'refresh_ttl' => env('JWT_REFRESH_TTL', 20160), /* |-------------------------------------------------------------------------- | JWT hashing algorithm |-------------------------------------------------------------------------- | | Specify the hashing algorithm that will be used to sign the token. | */ 'algo' => env('JWT_ALGO', Tymon\JWTAuth\Providers\JWT\Provider::ALGO_HS256), /* |-------------------------------------------------------------------------- | Required Claims |-------------------------------------------------------------------------- | | Specify the required claims that must exist in any token. | A TokenInvalidException will be thrown if any of these claims are not | present in the payload. | */ 'required_claims' => [ 'iss', 'iat', 'exp', 'nbf', 'sub', 'jti', ], /* |-------------------------------------------------------------------------- | Persistent Claims |-------------------------------------------------------------------------- | | Specify the claim keys to be persisted when refreshing a token. | `sub` and `iat` will automatically be persisted, in | addition to the these claims. | | Note: If a claim does not exist then it will be ignored. | */ 'persistent_claims' => [ // 'foo', // 'bar', ], /* |-------------------------------------------------------------------------- | Lock Subject |-------------------------------------------------------------------------- | | This will determine whether a `prv` claim is automatically added to | the token. The purpose of this is to ensure that if you have multiple | authentication models e.g. `App\User` & `App\OtherPerson`, then we | should prevent one authentication request from impersonating another, | if 2 tokens happen to have the same id across the 2 different models. | | Under specific circumstances, you may want to disable this behaviour | e.g. if you only have one authentication model, then you would save | a little on token size. | */ 'lock_subject' => true, /* |-------------------------------------------------------------------------- | Leeway |-------------------------------------------------------------------------- | | This property gives the jwt timestamp claims some "leeway". | Meaning that if you have any unavoidable slight clock skew on | any of your servers then this will afford you some level of cushioning. | | This applies to the claims `iat`, `nbf` and `exp`. | | Specify in seconds - only if you know you need it. | */ 'leeway' => env('JWT_LEEWAY', 0), /* |-------------------------------------------------------------------------- | Blacklist Enabled |-------------------------------------------------------------------------- | | In order to invalidate tokens, you must have the blacklist enabled. | If you do not want or need this functionality, then set this to false. | */ 'blacklist_enabled' => env('JWT_BLACKLIST_ENABLED', true), /* | ------------------------------------------------------------------------- | Blacklist Grace Period | ------------------------------------------------------------------------- | | When multiple concurrent requests are made with the same JWT, | it is possible that some of them fail, due to token regeneration | on every request. | | Set grace period in seconds to prevent parallel request failure. | */ 'blacklist_grace_period' => env('JWT_BLACKLIST_GRACE_PERIOD', 0), /* |-------------------------------------------------------------------------- | Cookies encryption |-------------------------------------------------------------------------- | | By default Laravel encrypt cookies for security reason. | If you decide to not decrypt cookies, you will have to configure Laravel | to not encrypt your cookie token by adding its name into the $except | array available in the middleware "EncryptCookies" provided by Laravel. | see https://laravel.com/docs/master/responses#cookies-and-encryption | for details. | | Set it to true if you want to decrypt cookies. | */ 'decrypt_cookies' => false, /* |-------------------------------------------------------------------------- | Providers |-------------------------------------------------------------------------- | | Specify the various providers used throughout the package. | */ 'providers' => [ /* |-------------------------------------------------------------------------- | JWT Provider |-------------------------------------------------------------------------- | | Specify the provider that is used to create and decode the tokens. | */ 'jwt' => Tymon\JWTAuth\Providers\JWT\Lcobucci::class, /* |-------------------------------------------------------------------------- | Authentication Provider |-------------------------------------------------------------------------- | | Specify the provider that is used to authenticate users. | */ 'auth' => App\Contracts\Providers\Illuminate::class, /* |-------------------------------------------------------------------------- | Storage Provider |-------------------------------------------------------------------------- | | Specify the provider that is used to store tokens in the blacklist. | */ 'storage' => Tymon\JWTAuth\Providers\Storage\Illuminate::class, ], /* * Comma separated pattern whitelist. * User * character to allow all domains to be registered. */ 'domain_whitelist' => env('JWT_EMAIL_PATTERN_WHITELIST', '@remp2020.com') ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/airbrake.php
Sso/config/airbrake.php
<?php return [ 'enabled' => env('AIRBRAKE_ENABLED', false), 'projectKey' => env('AIRBRAKE_API_KEY', ''), 'host' => env('AIRBRAKE_API_HOST', 'api.airbrake.io'), 'environment' => env('APP_ENV', 'production'), 'projectId' => '_', 'appVersion' => '', 'rootDirectory' => '', 'httpClient' => '', ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/sentry.php
Sso/config/sentry.php
<?php return [ 'dsn' => env('SENTRY_DSN'), // capture release as git sha // 'release' => trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')), // When left empty or `null` the Laravel environment will be used 'environment' => env('SENTRY_ENVIRONMENT'), 'attach_stacktrace' => true, 'breadcrumbs' => [ // Capture Laravel logs in breadcrumbs 'logs' => true, // Capture SQL queries in breadcrumbs 'sql_queries' => true, // Capture bindings on SQL queries logged in breadcrumbs 'sql_bindings' => true, // Capture queue job information in breadcrumbs 'queue_info' => true, // Capture command information in breadcrumbs 'command_info' => true, ], // @see: https://docs.sentry.io/platforms/php/configuration/options/#send-default-pii 'send_default_pii' => true, 'traces_sample_rate' => (float)(env('SENTRY_TRACES_SAMPLE_RATE', 0.0)), 'controllers_base_namespace' => env('SENTRY_CONTROLLERS_BASE_NAMESPACE', 'App\\Http\\Controllers'), ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/cache.php
Sso/config/cache.php
<?php use Illuminate\Support\Str; return [ /* |-------------------------------------------------------------------------- | Default Cache Store |-------------------------------------------------------------------------- | | This option controls the default cache connection that gets used while | using this caching library. This connection is used when another is | not explicitly specified when executing a given caching function. | */ 'default' => env('CACHE_DRIVER', 'file'), /* |-------------------------------------------------------------------------- | Cache Stores |-------------------------------------------------------------------------- | | Here you may define all of the cache "stores" for your application as | well as their drivers. You may even define multiple stores for the | same cache driver to group types of items stored in your caches. | | Supported drivers: "apc", "array", "database", "file", | "memcached", "redis", "dynamodb", "null" | */ 'stores' => [ 'apc' => [ 'driver' => 'apc', ], 'array' => [ 'driver' => 'array', 'serialize' => false, ], 'database' => [ 'driver' => 'database', 'table' => 'cache', 'connection' => null, 'lock_connection' => null, ], 'file' => [ 'driver' => 'file', 'path' => storage_path('framework/cache/data'), ], 'memcached' => [ 'driver' => 'memcached', 'persistent_id' => env('MEMCACHED_PERSISTENT_ID'), 'sasl' => [ env('MEMCACHED_USERNAME'), env('MEMCACHED_PASSWORD'), ], 'options' => [ // Memcached::OPT_CONNECT_TIMEOUT => 2000, ], 'servers' => [ [ 'host' => env('MEMCACHED_HOST', '127.0.0.1'), 'port' => env('MEMCACHED_PORT', 11211), 'weight' => 100, ], ], ], 'redis' => [ 'driver' => 'redis', 'connection' => 'cache', 'lock_connection' => 'default', ], 'dynamodb' => [ 'driver' => 'dynamodb', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), 'table' => env('DYNAMODB_CACHE_TABLE', 'cache'), 'endpoint' => env('DYNAMODB_ENDPOINT'), ], ], /* |-------------------------------------------------------------------------- | Cache Key Prefix |-------------------------------------------------------------------------- | | When utilizing a RAM based store such as APC or Memcached, there might | be other applications utilizing the same cache. So, we'll specify a | value to get prefixed to all our keys so we can avoid collisions. | */ 'prefix' => env('CACHE_PREFIX', 'sso'), ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/hashing.php
Sso/config/hashing.php
<?php return [ /* |-------------------------------------------------------------------------- | Default Hash Driver |-------------------------------------------------------------------------- | | This option controls the default hash driver that will be used to hash | passwords for your application. By default, the bcrypt algorithm is | used; however, you remain free to modify this option if you wish. | | Supported: "bcrypt", "argon" | */ 'driver' => 'bcrypt', /* |-------------------------------------------------------------------------- | Bcrypt Options |-------------------------------------------------------------------------- | | Here you may specify the configuration options that should be used when | passwords are hashed using the Bcrypt algorithm. This will allow you | to control the amount of time it takes to hash the given password. | */ 'bcrypt' => [ 'rounds' => env('BCRYPT_ROUNDS', 10), ], /* |-------------------------------------------------------------------------- | Argon Options |-------------------------------------------------------------------------- | | Here you may specify the configuration options that should be used when | passwords are hashed using the Argon algorithm. These will allow you | to control the amount of time it takes to hash the given password. | */ 'argon' => [ 'memory' => 1024, 'threads' => 2, 'time' => 2, ], ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/view.php
Sso/config/view.php
<?php return [ /* |-------------------------------------------------------------------------- | View Storage Paths |-------------------------------------------------------------------------- | | Most templating systems load templates from disk. Here you may specify | an array of paths that should be checked for your views. Of course | the usual Laravel view path has already been registered for you. | */ 'paths' => [ resource_path('views'), ], /* |-------------------------------------------------------------------------- | Compiled View Path |-------------------------------------------------------------------------- | | This option determines where all the compiled Blade templates will be | stored for your application. Typically, this is within the storage | directory. However, as usual, you are free to change this value. | */ 'compiled' => env( 'VIEW_COMPILED_PATH', realpath(storage_path('framework/views')) ), ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/database.php
Sso/config/database.php
<?php if (!function_exists('configure_redis')) { function configure_redis($database) { // If the app uses Redis Sentinel, different configuration is necessary. // // Default database and password need to be set within options.parameters to be actually used. if ($sentinelService = env('REDIS_SENTINEL_SERVICE')) { $redisClient = env('REDIS_CLIENT', 'predis'); if ($redisClient !== 'predis') { throw new \Exception("Unable to configure Redis Sentinel for client '{$redisClient}', only 'predis' is supported. You can configure the client via 'REDIS_CLIENT' environment variable."); } $redisUrl = env('REDIS_URL'); if ($redisUrl === null) { throw new \Exception("Unable to configure Redis Sentinel. Use 'REDIS_URL' environment variable to configure comma-separated sentinel instances."); } $config = explode(',', $redisUrl); $config['options'] = [ 'replication' => 'sentinel', 'service' => $sentinelService, 'parameters' => [ 'database' => $database, ], ]; if ($password = env('REDIS_PASSWORD')) { $config['options']['parameters']['password'] = $password; } return $config; } // default configuration supporting both url-based and host-port-database-based config. return [ 'url' => env('REDIS_URL'), 'host' => env('REDIS_HOST', '127.0.0.1'), 'password' => env('REDIS_PASSWORD'), 'port' => env('REDIS_PORT', '6379'), 'database' => $database, ]; } } return [ /* |-------------------------------------------------------------------------- | Default Database Connection Name |-------------------------------------------------------------------------- | | Here you may specify which of the database connections below you wish | to use as your default connection for all database work. Of course | you may use many connections at once using the Database library. | */ 'default' => env('DB_CONNECTION', 'mysql'), /* |-------------------------------------------------------------------------- | Database Connections |-------------------------------------------------------------------------- | | Here are each of the database connections setup for your application. | Of course, examples of configuring each database platform that is | supported by Laravel is shown below to make development simple. | | | All database work in Laravel is done through the PHP PDO facilities | so make sure you have the driver for your particular database of | choice installed on your machine before you begin development. | */ 'connections' => [ 'sqlite' => [ 'driver' => 'sqlite', 'url' => env('DATABASE_URL'), 'database' => env('DB_DATABASE', database_path('database.sqlite')), 'prefix' => '', 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), ], 'mysql' => [ 'driver' => 'mysql', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'prefix_indexes' => true, 'strict' => true, 'engine' => null, 'timezone' => '+00:00', 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), ]) : [], ], 'pgsql' => [ 'driver' => 'pgsql', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '5432'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'prefix' => '', 'prefix_indexes' => true, 'schema' => 'public', 'sslmode' => 'prefer', ], 'sqlsrv' => [ 'driver' => 'sqlsrv', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', 'localhost'), 'port' => env('DB_PORT', '1433'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'prefix' => '', 'prefix_indexes' => true, ], ], /* |-------------------------------------------------------------------------- | Migration Repository Table |-------------------------------------------------------------------------- | | This table keeps track of all the migrations that have already run for | your application. Using this information, we can determine which of | the migrations on disk haven't actually been run in the database. | */ 'migrations' => 'migrations', /* |-------------------------------------------------------------------------- | Redis Databases |-------------------------------------------------------------------------- | | Redis is an open source, fast, and advanced key-value store that also | provides a richer body of commands than a typical key-value system | such as APC or Memcached. Laravel makes it easy to dig right in. | */ 'redis' => [ // Default Laravel 6+ is phpredis, but to avoid adding additional dependency (PHP extension) // we still use predis 'client' => env('REDIS_CLIENT', 'predis'), 'options' => [ 'cluster' => env('REDIS_CLUSTER', 'predis'), 'prefix' => env('REDIS_PREFIX', ''), ], 'default' => configure_redis(env('REDIS_DEFAULT_DATABASE', '0')), 'session' => configure_redis(env('REDIS_SESSION_DATABASE', '1')), 'cache' => configure_redis(env('REDIS_CACHE_DATABASE', '2')), 'queue' => configure_redis(env('REDIS_QUEUE_DATABASE', '3')), ], ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/services.php
Sso/config/services.php
<?php return [ /* |-------------------------------------------------------------------------- | Third Party Services |-------------------------------------------------------------------------- | | This file is for storing the credentials for third party services such | as Mailgun, Postmark, AWS and more. This file provides the de facto | location for this type of information, allowing packages to have | a conventional file to locate the various service credentials. | */ 'mailgun' => [ 'domain' => env('MAILGUN_DOMAIN'), 'secret' => env('MAILGUN_SECRET'), 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), ], 'postmark' => [ 'token' => env('POSTMARK_TOKEN'), ], 'ses' => [ 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION', 'us-east-1'), ], 'sparkpost' => [ 'secret' => env('SPARKPOST_SECRET'), ], 'stripe' => [ 'model' => App\Models\User::class, 'key' => env('STRIPE_KEY'), 'secret' => env('STRIPE_SECRET'), ], 'google' => [ 'client_id' => env('GOOGLE_CLIENT_ID', 'your-github-app-id'), 'client_secret' => env('GOOGLE_CLIENT_SECRET', 'your-github-app-secret'), 'redirect' => env('GOOGLE_CALLBACK_URL', 'http://your-callback-url'), ], 'remp' => [ 'beam' => [ 'web_addr' => env('REMP_BEAM_ADDR'), ], 'mailer' => [ 'web_addr' => env('REMP_MAILER_ADDR'), ], 'sso' => [ 'web_addr' => env('REMP_SSO_ADDR'), ], 'linked' => [ 'beam' => [ 'url' => env('REMP_BEAM_ADDR'), 'icon' => 'album', ], 'campaign' => [ 'url' => env('REMP_CAMPAIGN_ADDR'), 'icon' => 'trending-up', ], 'mailer' => [ 'url' => env('REMP_MAILER_ADDR'), 'icon' => 'email', ], ], ], ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/datatables.php
Sso/config/datatables.php
<?php return [ /* * DataTables search options. */ 'search' => [ /* * Smart search will enclose search keyword with wildcard string "%keyword%". * SQL: column LIKE "%keyword%" */ 'smart' => true, /* * Multi-term search will explode search keyword using spaces resulting into multiple term search. */ 'multi_term' => true, /* * Case insensitive will search the keyword in lower case format. * SQL: LOWER(column) LIKE LOWER(keyword) */ 'case_insensitive' => true, /* * Wild card will add "%" in between every characters of the keyword. * SQL: column LIKE "%k%e%y%w%o%r%d%" */ 'use_wildcards' => false, ], /* * DataTables internal index id response column name. */ 'index_column' => 'DT_Row_Index', /* * List of available builders for DataTables. * This is where you can register your custom dataTables builder. */ 'engines' => [ 'eloquent' => \Yajra\DataTables\EloquentDataTable::class, 'query' => \Yajra\DataTables\QueryDataTable::class, 'collection' => \Yajra\DataTables\CollectionDataTable::class, ], /* * DataTables accepted builder to engine mapping. * This is where you can override which engine a builder should use * Note, only change this if you know what you are doing! */ 'builders' => [ //Illuminate\Database\Eloquent\Relations\Relation::class => 'eloquent', //Illuminate\Database\Eloquent\Builder::class => 'eloquent', //Illuminate\Database\Query\Builder::class => 'query', //Illuminate\Support\Collection::class => 'collection', ], /* * Nulls last sql pattern for Posgresql & Oracle. * For MySQL, use '-%s %s' */ 'nulls_last_sql' => '%s %s NULLS LAST', /* * User friendly message to be displayed on user if error occurs. * Possible values: * null - The exception message will be used on error response. * 'throw' - Throws a \Yajra\DataTables\Exceptions\Exception. Use your custom error handler if needed. * 'custom message' - Any friendly message to be displayed to the user. You can also use translation key. */ 'error' => env('DATATABLES_ERROR', null), /* * Default columns definition of dataTable utility functions. */ 'columns' => [ /* * List of columns hidden/removed on json response. */ 'excess' => ['rn', 'row_num'], /* * List of columns to be escaped. If set to *, all columns are escape. * Note: You can set the value to empty array to disable XSS protection. */ 'escape' => '*', /* * List of columns that are allowed to display html content. * Note: Adding columns to list will make us available to XSS attacks. */ 'raw' => ['action'], /* * List of columns are are forbidden from being searched/sorted. */ 'blacklist' => ['password', 'remember_token'], /* * List of columns that are only allowed fo search/sort. * If set to *, all columns are allowed. */ 'whitelist' => '*', ], /* * JsonResponse header and options config. */ 'json' => [ 'header' => [], 'options' => 0, ], ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/filesystems.php
Sso/config/filesystems.php
<?php return [ /* |-------------------------------------------------------------------------- | Default Filesystem Disk |-------------------------------------------------------------------------- | | Here you may specify the default filesystem disk that should be used | by the framework. The "local" disk, as well as a variety of cloud | based disks are available to your application. Just store away! | */ 'default' => env('FILESYSTEM_DISK', 'local'), /* |-------------------------------------------------------------------------- | Filesystem Disks |-------------------------------------------------------------------------- | | Here you may configure as many filesystem "disks" as you wish, and you | may even configure multiple disks of the same driver. Defaults have | been setup for each driver as an example of the required options. | | Supported Drivers: "local", "ftp", "sftp", "s3" | */ 'disks' => [ 'local' => [ 'driver' => 'local', 'root' => storage_path('app'), ], 'public' => [ 'driver' => 'local', 'root' => storage_path('app/public'), 'url' => env('APP_URL').'/storage', 'visibility' => 'public', ], 's3' => [ 'driver' => 's3', 'key' => env('AWS_ACCESS_KEY_ID'), 'secret' => env('AWS_SECRET_ACCESS_KEY'), 'region' => env('AWS_DEFAULT_REGION'), 'bucket' => env('AWS_BUCKET'), 'url' => env('AWS_URL'), 'endpoint' => env('AWS_ENDPOINT'), ], ], /* |-------------------------------------------------------------------------- | Symbolic Links |-------------------------------------------------------------------------- | | Here you may configure the symbolic links that will be created when the | `storage:link` Artisan command is executed. The array keys should be | the locations of the links and the values should be their targets. | */ 'links' => [ public_path('storage') => storage_path('app/public'), ], ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/healthcheck.php
Sso/config/healthcheck.php
<?php return [ /** * Base path for the health check endpoints, by default will use / */ 'base-path' => '', /** * List of health checks to run when determining the health * of the service */ 'checks' => [ UKFast\HealthCheck\Checks\DatabaseHealthCheck::class, UKFast\HealthCheck\Checks\LogHealthCheck::class, UKFast\HealthCheck\Checks\RedisHealthCheck::class, UKFast\HealthCheck\Checks\StorageHealthCheck::class ], /** * A list of middleware to run on the health-check route * It's recommended that you have a middleware that only * allows admin consumers to see the endpoint. * * See UKFast\HealthCheck\BasicAuth for a one-size-fits all * solution */ 'middleware' => [], /** * Used by the basic auth middleware */ 'auth' => [ 'user' => env('HEALTH_CHECK_USER'), 'password' => env('HEALTH_CHECK_PASSWORD'), ], /** * Can define a list of connection names to test. Names can be * found in your config/database.php file. By default, we just * check the 'default' connection */ 'database' => [ 'connections' => ['default'], ], /** * Can give an array of required environment values, for example * 'REDIS_HOST'. If any don't exist, then it'll be surfaced in the * context of the healthcheck */ 'required-env' => [], /** * List of addresses and expected response codes to * monitor when running the HTTP health check * * e.g. address => response code */ 'addresses' => [], /** * Default response code for HTTP health check. Will be used * when one isn't provided in the addresses config. */ 'default-response-code' => 200, /** * Default timeout for cURL requests for HTTP health check. */ 'default-curl-timeout' => 2.0, /** * An array of other services that use the health check package * to hit. The URI should reference the endpoint specifically, * for example: https://api.example.com/health */ 'x-service-checks' => [], /** * A list of stores to be checked by the Cache health check */ 'cache' => [ 'stores' => [ 'array' ] ], /** * A list of disks to be checked by the Storage health check */ 'storage' => [ 'disks' => [ 'local', ] ], /** * Additional config can be put here. For example, a health check * for your .env file needs to know which keys need to be present. * You can pass this information by specifying a new key here then * accessing it via config('healthcheck.env') in your healthcheck class */ ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/mail.php
Sso/config/mail.php
<?php return [ /* |-------------------------------------------------------------------------- | Default Mailer |-------------------------------------------------------------------------- | | This option controls the default mailer that is used to send any email | messages sent by your application. Alternative mailers may be setup | and used as needed; however, this mailer will be used by default. | */ 'default' => env('MAIL_MAILER', 'smtp'), /* |-------------------------------------------------------------------------- | Mailer Configurations |-------------------------------------------------------------------------- | | Here you may configure all of the mailers used by your application plus | their respective settings. Several examples have been configured for | you and you are free to add your own as your application requires. | | Laravel supports a variety of mail "transport" drivers to be used while | sending an e-mail. You will specify which one you are using for your | mailers below. You are free to add additional mailers as required. | | Supported: "smtp", "sendmail", "mailgun", "ses", | "postmark", "log", "array" | */ 'mailers' => [ 'smtp' => [ 'transport' => 'smtp', 'host' => env('MAIL_HOST', 'smtp.mailgun.org'), 'port' => env('MAIL_PORT', 587), 'encryption' => env('MAIL_ENCRYPTION', 'tls'), 'username' => env('MAIL_USERNAME'), 'password' => env('MAIL_PASSWORD'), 'timeout' => null, 'auth_mode' => null, ], 'ses' => [ 'transport' => 'ses', ], 'mailgun' => [ 'transport' => 'mailgun', ], 'postmark' => [ 'transport' => 'postmark', ], 'sendmail' => [ 'transport' => 'sendmail', 'path' => '/usr/sbin/sendmail -bs', ], 'log' => [ 'transport' => 'log', 'channel' => env('MAIL_LOG_CHANNEL'), ], 'array' => [ 'transport' => 'array', ], ], /* |-------------------------------------------------------------------------- | Global "From" Address |-------------------------------------------------------------------------- | | You may wish for all e-mails sent by your application to be sent from | the same address. Here, you may specify a name and address that is | used globally for all e-mails that are sent by your application. | */ 'from' => [ 'address' => env('MAIL_FROM_ADDRESS', 'hello@example.com'), 'name' => env('MAIL_FROM_NAME', 'Example'), ], /* |-------------------------------------------------------------------------- | Markdown Mail Settings |-------------------------------------------------------------------------- | | If you are using Markdown based email rendering, you may configure your | theme and component paths here, allowing you to customize the design | of the emails. Or, you may simply stick with the Laravel defaults! | */ 'markdown' => [ 'theme' => 'default', 'paths' => [ resource_path('views/vendor/mail'), ], ], ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/cors.php
Sso/config/cors.php
<?php return [ /* |-------------------------------------------------------------------------- | Cross-Origin Resource Sharing (CORS) Configuration |-------------------------------------------------------------------------- | | Here you may configure your settings for cross-origin resource sharing | or "CORS". This determines what cross-origin operations may execute | in web browsers. You are free to adjust these settings as needed. | | To learn more: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS | */ 'paths' => ['api/*', 'sanctum/csrf-cookie'], 'allowed_methods' => ['*'], 'allowed_origins' => ['*'], 'allowed_origins_patterns' => [], 'allowed_headers' => ['*'], 'exposed_headers' => [], 'max_age' => 0, 'supports_credentials' => false, ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/system.php
Sso/config/system.php
<?php $definition = env('COMMANDS_MEMORY_LIMITS'); $limits = []; if (!empty($definition)) { foreach (explode(',', $definition) as $commandLimit) { $config = explode('::', $commandLimit); if (count($config) !== 2 || empty($config[0]) || empty($config[1])) { throw new \Exception('invalid format of COMMANDS_MEMORY_LIMITS entry; expected "command::limit", got "' . $commandLimit . '"'); } $limits[$config[0]] = $config[1]; } } return [ 'commands_memory_limits' => $limits, 'commands_overlapping_expires_at' => env('COMMANDS_OVERLAPPING_EXPIRES_AT', 15), ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/broadcasting.php
Sso/config/broadcasting.php
<?php return [ /* |-------------------------------------------------------------------------- | Default Broadcaster |-------------------------------------------------------------------------- | | This option controls the default broadcaster that will be used by the | framework when an event needs to be broadcast. You may set this to | any of the connections defined in the "connections" array below. | | Supported: "pusher", "ably", "redis", "log", "null" | */ 'default' => env('BROADCAST_DRIVER', 'null'), /* |-------------------------------------------------------------------------- | Broadcast Connections |-------------------------------------------------------------------------- | | Here you may define all of the broadcast connections that will be used | to broadcast events to other systems or over websockets. Samples of | each available type of connection are provided inside this array. | */ 'connections' => [ 'pusher' => [ 'driver' => 'pusher', 'key' => env('PUSHER_APP_KEY'), 'secret' => env('PUSHER_APP_SECRET'), 'app_id' => env('PUSHER_APP_ID'), 'options' => [ 'cluster' => env('PUSHER_APP_CLUSTER'), 'useTLS' => true, ], ], 'ably' => [ 'driver' => 'ably', 'key' => env('ABLY_KEY'), ], 'redis' => [ 'driver' => 'redis', 'connection' => 'default', ], 'log' => [ 'driver' => 'log', ], 'null' => [ 'driver' => 'null', ], ], ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/config/auth.php
Sso/config/auth.php
<?php return [ /* |-------------------------------------------------------------------------- | Authentication Defaults |-------------------------------------------------------------------------- | | This option controls the default authentication "guard" and password | reset options for your application. You may change these defaults | as required, but they're a perfect start for most applications. | */ 'defaults' => [ 'guard' => 'jwtx', 'passwords' => null, 'sso_provider' => env('DEFAULT_SSO_PROVIDER'), ], /* |-------------------------------------------------------------------------- | Authentication Guards |-------------------------------------------------------------------------- | | Next, you may define every authentication guard for your application. | Of course, a great default configuration has been defined for you | here which uses session storage and the Eloquent user provider. | | All authentication drivers have a user provider. This defines how the | users are actually retrieved out of your database or other storage | mechanisms used by this application to persist your user's data. | | Supported: "session", "token" | */ 'guards' => [ 'web' => [ 'driver' => 'session', 'provider' => 'users', ], 'api' => [ 'driver' => 'token', 'provider' => 'users', 'hash' => false, ], 'jwt' => [ 'driver' => 'jwt', 'provider' => 'users', ], 'jwtx' => [ 'driver' => 'jwtx', 'provider' => null, ], ], /* |-------------------------------------------------------------------------- | User Providers |-------------------------------------------------------------------------- | | All authentication drivers have a user provider. This defines how the | users are actually retrieved out of your database or other storage | mechanisms used by this application to persist your user's data. | | If you have multiple user tables or models you may configure multiple | sources which represent each model / table. These sources may then | be assigned to any extra authentication guards you have defined. | | Supported: "database", "eloquent" | */ 'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => App\Models\User::class, ], // 'users' => [ // 'driver' => 'database', // 'table' => 'users', // ], ], /* |-------------------------------------------------------------------------- | Resetting Passwords |-------------------------------------------------------------------------- | | You may specify multiple password reset configurations if you have more | than one user table or model in the application and you want to have | separate password reset settings based on the specific user types. | | The expire time is the number of minutes that the reset token should be | considered valid. This security feature keeps tokens short-lived so | they have less time to be guessed. You may change this as needed. | */ 'passwords' => [ 'users' => [ 'provider' => 'users', 'table' => 'password_resets', 'expire' => 60, 'throttle' => 60, ], ], /* |-------------------------------------------------------------------------- | SSO Providers |-------------------------------------------------------------------------- | | You may specify multiple SSO providers and let user to choose one | they prefer. Providers are defined as key-value array: | | - key: ID of SSO provider. Needs to be the same as one used in | services.php definition and available as `config("services.$key")`. | - value: Label of SSO provider used on login page. | */ 'sso_providers' => [ 'google' => 'Google', // define additional providers in services.php and enable them here ], /* |-------------------------------------------------------------------------- | Password Confirmation Timeout |-------------------------------------------------------------------------- | | Here you may define the amount of seconds before a password confirmation | times out and the user is prompted to re-enter their password via the | confirmation screen. By default, the timeout lasts for three hours. | */ 'password_timeout' => 10800, ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/database/factories/UserFactory.php
Sso/database/factories/UserFactory.php
<?php namespace Database\Factories; use App\Models\User; use Illuminate\Database\Eloquent\Factories\Factory; use Illuminate\Support\Str; /* |-------------------------------------------------------------------------- | Model Factories |-------------------------------------------------------------------------- | | Here you may define all of your model factories. Model factories give | you a convenient way to create models for testing and seeding your | database. Just tell the factory how a default model should look. | */ class UserFactory extends Factory { /** * The name of the factory's corresponding model. * * @var string */ protected $model = User::class; /** * Define the model's default state. * * @return array */ public function definition() { static $password; return [ 'name' => $this->faker->name, 'email' => $this->faker->unique()->safeEmail, 'password' => $password ?: $password = bcrypt('secret'), 'remember_token' => Str::random(10), ]; } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/database/migrations/2017_07_07_122646_users.php
Sso/database/migrations/2017_07_07_122646_users.php
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class Users extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('users', function (Blueprint $table) { $table->increments('id'); $table->string('email')->unique(); $table->string('name')->nullable(); $table->timestamps(); }); Schema::create('google_users', function (Blueprint $table) { $table->increments('id'); $table->integer('user_id')->unsigned(); $table->string('google_id'); $table->string('nickname')->nullable(); $table->string('name')->nullable(); $table->timestamps(); $table->foreign('user_id')->references('id')->on('users'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('google_users'); Schema::dropIfExists('users'); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/database/migrations/2017_11_29_102649_create_api_tokens_table.php
Sso/database/migrations/2017_11_29_102649_create_api_tokens_table.php
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateApiTokensTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('api_tokens', function (Blueprint $table) { $table->increments('id'); $table->string('name'); $table->string('token'); $table->boolean('active'); $table->timestamps(); $table->softDeletes(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('api_tokens'); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/database/migrations/2025_12_10_133741_add_soft_deletes_to_users_table.php
Sso/database/migrations/2025_12_10_133741_add_soft_deletes_to_users_table.php
<?php use Illuminate\Database\Migrations\Migration; use Illuminate\Database\Schema\Blueprint; use Illuminate\Support\Facades\Schema; return new class extends Migration { /** * Run the migrations. */ public function up(): void { Schema::table('users', function (Blueprint $table) { $table->softDeletes(); }); } /** * Reverse the migrations. */ public function down(): void { Schema::table('users', function (Blueprint $table) { $table->dropSoftDeletes(); }); } };
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/database/migrations/2018_03_14_143051_last_logged_at.php
Sso/database/migrations/2018_03_14_143051_last_logged_at.php
<?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class LastLoggedAt extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::table('users', function (Blueprint $table) { $table->timestamp('last_logout_at')->nullable(); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::table('users', function (Blueprint $table) { $table->dropColumn('last_logout_at'); }); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/database/seeders/DatabaseSeeder.php
Sso/database/seeders/DatabaseSeeder.php
<?php namespace Database\Seeders; use Illuminate\Database\Seeder; class DatabaseSeeder extends Seeder { /** * Run the database seeds. * * @return void */ public function run() { // $this->call(UsersTableSeeder::class); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/resources/lang/en/passwords.php
Sso/resources/lang/en/passwords.php
<?php return [ /* |-------------------------------------------------------------------------- | Password Reset Language Lines |-------------------------------------------------------------------------- | | The following language lines are the default lines which match reasons | that are given by the password broker for a password update attempt | has failed, such as for an invalid token or invalid new password. | */ 'reset' => 'Your password has been reset!', 'sent' => 'We have e-mailed your password reset link!', 'throttled' => 'Please wait before retrying.', 'token' => 'This password reset token is invalid.', 'user' => "We can't find a user with that e-mail address.", ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/resources/lang/en/pagination.php
Sso/resources/lang/en/pagination.php
<?php return [ /* |-------------------------------------------------------------------------- | Pagination Language Lines |-------------------------------------------------------------------------- | | The following language lines are used by the paginator library to build | the simple pagination links. You are free to change them to anything | you want to customize your views to better match your application. | */ 'previous' => '&laquo; Previous', 'next' => 'Next &raquo;', ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/resources/lang/en/validation.php
Sso/resources/lang/en/validation.php
<?php return [ /* |-------------------------------------------------------------------------- | Validation Language Lines |-------------------------------------------------------------------------- | | The following language lines contain the default error messages used by | the validator class. Some of these rules have multiple versions such | as the size rules. Feel free to tweak each of these messages here. | */ 'accepted' => 'The :attribute must be accepted.', 'active_url' => 'The :attribute is not a valid URL.', 'after' => 'The :attribute must be a date after :date.', 'after_or_equal' => 'The :attribute must be a date after or equal to :date.', 'alpha' => 'The :attribute must only contain letters.', 'alpha_dash' => 'The :attribute must only contain letters, numbers, dashes and underscores.', 'alpha_num' => 'The :attribute must only contain letters and numbers.', 'array' => 'The :attribute must be an array.', 'before' => 'The :attribute must be a date before :date.', 'before_or_equal' => 'The :attribute must be a date before or equal to :date.', 'between' => [ 'numeric' => 'The :attribute must be between :min and :max.', 'file' => 'The :attribute must be between :min and :max kilobytes.', 'string' => 'The :attribute must be between :min and :max characters.', 'array' => 'The :attribute must have between :min and :max items.', ], 'boolean' => 'The :attribute field must be true or false.', 'confirmed' => 'The :attribute confirmation does not match.', 'date' => 'The :attribute is not a valid date.', 'date_equals' => 'The :attribute must be a date equal to :date.', 'date_format' => 'The :attribute does not match the format :format.', 'different' => 'The :attribute and :other must be different.', 'digits' => 'The :attribute must be :digits digits.', 'digits_between' => 'The :attribute must be between :min and :max digits.', 'dimensions' => 'The :attribute has invalid image dimensions.', 'distinct' => 'The :attribute field has a duplicate value.', 'email' => 'The :attribute must be a valid email address.', 'ends_with' => 'The :attribute must end with one of the following: :values.', 'exists' => 'The selected :attribute is invalid.', 'file' => 'The :attribute must be a file.', 'filled' => 'The :attribute field must have a value.', 'gt' => [ 'numeric' => 'The :attribute must be greater than :value.', 'file' => 'The :attribute must be greater than :value kilobytes.', 'string' => 'The :attribute must be greater than :value characters.', 'array' => 'The :attribute must have more than :value items.', ], 'gte' => [ 'numeric' => 'The :attribute must be greater than or equal :value.', 'file' => 'The :attribute must be greater than or equal :value kilobytes.', 'string' => 'The :attribute must be greater than or equal :value characters.', 'array' => 'The :attribute must have :value items or more.', ], 'image' => 'The :attribute must be an image.', 'in' => 'The selected :attribute is invalid.', 'in_array' => 'The :attribute field does not exist in :other.', 'integer' => 'The :attribute must be an integer.', 'ip' => 'The :attribute must be a valid IP address.', 'ipv4' => 'The :attribute must be a valid IPv4 address.', 'ipv6' => 'The :attribute must be a valid IPv6 address.', 'json' => 'The :attribute must be a valid JSON string.', 'lt' => [ 'numeric' => 'The :attribute must be less than :value.', 'file' => 'The :attribute must be less than :value kilobytes.', 'string' => 'The :attribute must be less than :value characters.', 'array' => 'The :attribute must have less than :value items.', ], 'lte' => [ 'numeric' => 'The :attribute must be less than or equal :value.', 'file' => 'The :attribute must be less than or equal :value kilobytes.', 'string' => 'The :attribute must be less than or equal :value characters.', 'array' => 'The :attribute must not have more than :value items.', ], 'max' => [ 'numeric' => 'The :attribute must not be greater than :max.', 'file' => 'The :attribute must not be greater than :max kilobytes.', 'string' => 'The :attribute must not be greater than :max characters.', 'array' => 'The :attribute must not have more than :max items.', ], 'mimes' => 'The :attribute must be a file of type: :values.', 'mimetypes' => 'The :attribute must be a file of type: :values.', 'min' => [ 'numeric' => 'The :attribute must be at least :min.', 'file' => 'The :attribute must be at least :min kilobytes.', 'string' => 'The :attribute must be at least :min characters.', 'array' => 'The :attribute must have at least :min items.', ], 'multiple_of' => 'The :attribute must be a multiple of :value.', 'not_in' => 'The selected :attribute is invalid.', 'not_regex' => 'The :attribute format is invalid.', 'numeric' => 'The :attribute must be a number.', 'password' => 'The password is incorrect.', 'present' => 'The :attribute field must be present.', 'regex' => 'The :attribute format is invalid.', 'required' => 'The :attribute field is required.', 'required_if' => 'The :attribute field is required when :other is :value.', 'required_unless' => 'The :attribute field is required unless :other is in :values.', 'required_with' => 'The :attribute field is required when :values is present.', 'required_with_all' => 'The :attribute field is required when :values are present.', 'required_without' => 'The :attribute field is required when :values is not present.', 'required_without_all' => 'The :attribute field is required when none of :values are present.', 'prohibited' => 'The :attribute field is prohibited.', 'prohibited_if' => 'The :attribute field is prohibited when :other is :value.', 'prohibited_unless' => 'The :attribute field is prohibited unless :other is in :values.', 'same' => 'The :attribute and :other must match.', 'size' => [ 'numeric' => 'The :attribute must be :size.', 'file' => 'The :attribute must be :size kilobytes.', 'string' => 'The :attribute must be :size characters.', 'array' => 'The :attribute must contain :size items.', ], 'starts_with' => 'The :attribute must start with one of the following: :values.', 'string' => 'The :attribute must be a string.', 'timezone' => 'The :attribute must be a valid zone.', 'unique' => 'The :attribute has already been taken.', 'uploaded' => 'The :attribute failed to upload.', 'url' => 'The :attribute format is invalid.', 'uuid' => 'The :attribute must be a valid UUID.', /* |-------------------------------------------------------------------------- | Custom Validation Language Lines |-------------------------------------------------------------------------- | | Here you may specify custom validation messages for attributes using the | convention "attribute.rule" to name the lines. This makes it quick to | specify a specific custom language line for a given attribute rule. | */ 'custom' => [ 'attribute-name' => [ 'rule-name' => 'custom-message', ], ], /* |-------------------------------------------------------------------------- | Custom Validation Attributes |-------------------------------------------------------------------------- | | The following language lines are used to swap our attribute placeholder | with something more reader friendly such as "E-Mail Address" instead | of "email". This simply helps us make our message more expressive. | */ 'attributes' => [], ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/resources/lang/en/auth.php
Sso/resources/lang/en/auth.php
<?php return [ /* |-------------------------------------------------------------------------- | Authentication Language Lines |-------------------------------------------------------------------------- | | The following language lines are used during authentication for various | messages that we need to display to the user. You are free to modify | these language lines according to your application's requirements. | */ 'failed' => 'These credentials do not match our records.', 'password' => 'The provided password is incorrect.', 'throttle' => 'Too many login attempts. Please try again in :seconds seconds.', ];
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/resources/views/welcome.blade.php
Sso/resources/views/welcome.blade.php
@extends('layouts.app') @section('content') @endsection
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/resources/views/auth/login.blade.php
Sso/resources/views/auth/login.blade.php
@extends('layouts.login') @section('content') <style type="text/css"> .sso-provider { text-decoration: none; text-transform: uppercase; } </style> @foreach ($providerRedirects as $name => $redirectUrl) <a href="{{ $redirectUrl }}" class="sso-provider"> <div class="btn palette-Cyan bg">{{ $name }}</div> </a> @endforeach @endsection
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/resources/views/auth/error.blade.php
Sso/resources/views/auth/error.blade.php
@extends('layouts.auth') @section('title', 'Error') @section('content') <div class="lb-header palette-Teal bg"> <i class="zmdi zmdi-account-circle"></i> <p>There was an error signing you in.</p> <p>If you believe this shouldn't happen, please contact your administrator.</p> </div> <div class="lb-body"> {{ $message }} </div> @endsection
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/resources/views/settings/jwtwhitelist.blade.php
Sso/resources/views/settings/jwtwhitelist.blade.php
@extends('layouts.app') @section('title', 'JWT Whitelist') @section('content') <div class="c-header"> <h2>JWT Whitelist</h2> </div> <div class="card"> <div class="card-header"> <h2>JWT Whitelist <small></small></h2> </div> <div class="card-body card-padding"> @include('flash::message') <div class="row"> <div class="col-md-6"> <ul> @foreach (explode(',', $jwtwhitelist) as $item) <li><code>{{$item}}</code></li> @endforeach </ul> </div> </div> </div> </div> @endsection
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/resources/views/layouts/login.blade.php
Sso/resources/views/layouts/login.blade.php
<!DOCTYPE html> @include('layouts._head') <body> <div class="login" data-lbg="teal"> <!-- Login --> <div class="l-block toggled" id="l-login"> <div class="lb-header palette-Teal bg"> <i class="zmdi zmdi-account-circle"></i> Please select your login provider: </div> <div class="lb-body"> @yield('content') </div> </div> </div> <!-- Older IE warning message --> <!--[if lt IE 9]> <div class="ie-warning"> <h1 class="c-white">Warning!!</h1> <p>You are using an outdated version of Internet Explorer, please upgrade <br/>to any of the following web browsers to access this website.</p> <div class="iew-container"> <ul class="iew-download"> <li> <a href="http://www.google.com/chrome/"> <img src="img/browsers/chrome.png" alt=""> <div>Chrome</div> </a> </li> <li> <a href="https://www.mozilla.org/en-US/firefox/new/"> <img src="img/browsers/firefox.png" alt=""> <div>Firefox</div> </a> </li> <li> <a href="http://www.opera.com"> <img src="img/browsers/opera.png" alt=""> <div>Opera</div> </a> </li> <li> <a href="https://www.apple.com/safari/"> <img src="img/browsers/safari.png" alt=""> <div>Safari</div> </a> </li> <li> <a href="http://windows.microsoft.com/en-us/internet-explorer/download-ie"> <img src="img/browsers/ie.png" alt=""> <div>IE (New)</div> </a> </li> </ul> </div> <p>Sorry for the inconvenience!</p> </div> <![endif]--> </body> </html>
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/resources/views/layouts/_head.blade.php
Sso/resources/views/layouts/_head.blade.php
<head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title> @yield('title') </title> <link rel="apple-touch-icon" sizes="57x57" href="/assets/img/favicon/apple-icon-57x57.png"> <link rel="apple-touch-icon" sizes="60x60" href="/assets/img/favicon/apple-icon-60x60.png"> <link rel="apple-touch-icon" sizes="72x72" href="/assets/img/favicon/apple-icon-72x72.png"> <link rel="apple-touch-icon" sizes="76x76" href="/assets/img/favicon/apple-icon-76x76.png"> <link rel="apple-touch-icon" sizes="114x114" href="/assets/img/favicon/apple-icon-114x114.png"> <link rel="apple-touch-icon" sizes="120x120" href="/assets/img/favicon/apple-icon-120x120.png"> <link rel="apple-touch-icon" sizes="144x144" href="/assets/img/favicon/apple-icon-144x144.png"> <link rel="apple-touch-icon" sizes="152x152" href="/assets/img/favicon/apple-icon-152x152.png"> <link rel="apple-touch-icon" sizes="180x180" href="/assets/img/favicon/apple-icon-180x180.png"> <link rel="icon" type="image/png" sizes="192x192" href="/assets/img/favicon/android-icon-192x192.png"> <link rel="icon" type="image/png" sizes="32x32" href="/assets/img/favicon/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="96x96" href="/assets/img/favicon/favicon-96x96.png"> <link rel="icon" type="image/png" sizes="16x16" href="/assets/img/favicon/favicon-16x16.png"> <link rel="manifest" href="/assets/img/favicon/manifest.json"> <meta name="msapplication-TileColor" content="#ffffff"> <meta name="msapplication-TileImage" content="/assets/img/favicon/ms-icon-144x144.png"> <meta name="csrf-token" content="{{ csrf_token() }}"> <link href="{{ asset(mix('/css/vendor.css', '/assets/vendor')) }}" rel="stylesheet"> <link href="{{ asset(mix('/css/app.css', '/assets/vendor')) }}" rel="stylesheet"> <script src="{{ asset(mix('/js/manifest.js', '/assets/vendor')) }}"></script> <script src="{{ asset(mix('/js/vendor.js', '/assets/vendor')) }}"></script> <script src="{{ asset(mix('/js/app.js', '/assets/vendor')) }}"></script> @stack('head') </head>
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/resources/views/layouts/auth.blade.php
Sso/resources/views/layouts/auth.blade.php
<html> @include('layouts._head') <body> <div class="login"> <!-- Login --> <div class="l-block toggled" id="l-login"> @yield('content') </div> </div> </body> </html>
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/resources/views/layouts/app.blade.php
Sso/resources/views/layouts/app.blade.php
<!DOCTYPE html> @include('layouts._head') <body data-ma-header="cyan-600"> <div class="remp-menu"> <nav class="navbar navbar-default"> <div class="container-fluid"> <div class="navbar-header"> <a class="navbar-brand" href="/"> <div class="svg-logo"></div> </a> </div> <ul class="nav navbar-nav navbar-remp display-on-computer"> @foreach(config('services.remp.linked') as $key => $service) @isset($service['url']) <li @class(['active' => $service['url'] === '/'])> <a href="{{ $service['url'] }}"><i class="zmdi zmdi-{{ $service['icon'] }} zmdi-hc-fw"></i> {{ $key }}</a> </li> @endisset @endforeach </ul> <ul class="nav navbar-nav navbar-right"> <li class="dropdown hm-profile"> <a data-toggle="dropdown" href=""> <img src="https://www.gravatar.com/avatar/" alt=""> </a> <ul class="dropdown-menu pull-right dm-icon"> <li> <a href="{{ route('settings.jwtwhitelist') }}"><i class="zmdi zmdi-accounts-list"></i> JWT Whitelist</a> </li> <li> <a href="{{ route('auth.logout-web') }}"><i class="zmdi zmdi-time-restore"></i> Logout</a> </li> </ul> </li> </ul> </div> </nav> </div> <header id="header" class="media"> <div class="pull-left h-logo"> <a href="/" class="hidden-xs"></a> <div class="menu-collapse" data-ma-action="sidebar-open" data-ma-target="main-menu"> <div class="mc-wrap"> <div class="mcw-line top palette-White bg"></div> <div class="mcw-line center palette-White bg"></div> <div class="mcw-line bottom palette-White bg"></div> </div> </div> </div> <ul class="pull-right h-menu"> <li class="hm-search-trigger"> <a href="" data-ma-action="search-open"> <i class="hm-icon zmdi zmdi-search"></i> </a> </li> </ul> <div class="media-body h-search"> <form class="p-relative"> <input type="text" class="hs-input" placeholder="Search for people, files & reports"> <i class="zmdi zmdi-search hs-reset" data-ma-action="search-clear"></i> </form> </div> </header> <section id="main"> <aside id="s-main-menu" class="sidebar"> <ul class="main-menu"> <li {!! route_active(['api-tokens.index']) !!}> <a href="{{ route('api-tokens.index') }}"><i class="zmdi zmdi-key"></i> API Tokens</a> </li> <li {!! route_active(['users.index']) !!}> <a href="{{ route('users.index') }}"><i class="zmdi zmdi-accounts"></i> Users</a> </li> </ul> </aside> <section id="content"> <div class="container"> @yield('content') @if (count($errors) > 0) <div class="alert alert-danger"> <ul> @foreach ($errors->all() as $error) <li>{{ $error }}</li> @endforeach </ul> </div> @endif </div> </section> <footer id="footer"> <p>Thank you for using <a href="https://remp2020.com/" title="Readers’ Engagement and Monetization Platform | Open-source tools for publishers">REMP</a>, open-source software by Denník N.</p> </footer> </section> <!-- Older IE warning message --> <!--[if lt IE 9]> <div class="ie-warning"> <h1 class="c-white">Warning!!</h1> <p>You are using an outdated version of Internet Explorer, please upgrade <br/>to any of the following web browsers to access this website.</p> <div class="iew-container"> <ul class="iew-download"> <li> <a href="http://www.google.com/chrome/"> <img src="img/browsers/chrome.png" alt=""> <div>Chrome</div> </a> </li> <li> <a href="https://www.mozilla.org/en-US/firefox/new/"> <img src="img/browsers/firefox.png" alt=""> <div>Firefox</div> </a> </li> <li> <a href="http://www.opera.com"> <img src="img/browsers/opera.png" alt=""> <div>Opera</div> </a> </li> <li> <a href="https://www.apple.com/safari/"> <img src="img/browsers/safari.png" alt=""> <div>Safari</div> </a> </li> <li> <a href="http://windows.microsoft.com/en-us/internet-explorer/download-ie"> <img src="img/browsers/ie.png" alt=""> <div>IE (New)</div> </a> </li> </ul> </div> <p>Sorry for the inconvenience!</p> </div> <![endif]--> <script type="application/javascript"> $(document).ready(function() { let delay = 250; @foreach ($errors->all() as $error) (function(delay) { window.setTimeout(function() { $.notify({ message: '{{ $error }}' }, { allow_dismiss: false, type: 'danger' }); }, delay); })(delay); delay += 250; @endforeach }); </script> @stack('scripts') </body> </html>
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/resources/views/users/index.blade.php
Sso/resources/views/users/index.blade.php
@extends('layouts.app') @section('title', 'Users') @section('content') <div class="c-header"> <h2>Users</h2> </div> <div class="card"> <div class="card-header"> <h2>List of Users <small></small></h2> </div> {!! Widget::run('DataTable', [ 'colSettings' => [ 'id' => [ 'header' => 'ID', 'priority' => 1, ], 'email' => [ 'header' => 'Email', 'priority' => 1, ], 'name' => [ 'header' => 'Name', 'priority' => 1, ], 'created_at' => [ 'header' => 'Created at', 'render' => 'date', 'priority' => 2, ], 'updated_at' => [ 'header' => 'Updated at', 'render' => 'date', 'priority' => 3, ], ], 'dataSource' => route('users.json'), 'rowActions' => [ ['name' => 'destroy', 'class' => 'zmdi-palette-Cyan zmdi-delete', 'title' => 'Remove user'], ], 'order' => [0, 'desc'], ]) !!} </div> @endsection @push('scripts') <script> $(document).ready(function() { $(document).on('submit', 'form[data-action-method="DELETE"]', function(e) { var $form = $(this); var actionUrl = $form.attr('action'); // Check if this is a user deletion form if (actionUrl && actionUrl.indexOf('/users/') !== -1) { if (!confirm('Are you sure you want to remove this user? This action cannot be undone.')) { e.preventDefault(); return false; } } }); }); </script> @endpush
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/resources/views/api_tokens/edit.blade.php
Sso/resources/views/api_tokens/edit.blade.php
@extends('layouts.app') @section('title', 'Edit API token') @section('content') <div class="c-header"> <h2>API tokens: {{ $apiToken->name }}</h2> </div> <div class="card"> <div class="card-header"> <h2>Edit API token <small>{{ $apiToken->name }}</small></h2> </div> <div class="card-body card-padding"> @include('flash::message') {{ html()->modelForm($apiToken, 'PATCH')->route('api-tokens.update', $apiToken)->open() }} @include('api_tokens._form') {{ html()->closeModelForm() }} </div> </div> @endsection
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/resources/views/api_tokens/_form.blade.php
Sso/resources/views/api_tokens/_form.blade.php
<div class="row"> <div class="col-md-6 form-group"> <div class="input-group fg-float m-t-10"> <span class="input-group-addon"><i class="zmdi zmdi-file-text"></i></span> <div class="fg-line"> {{ html()->label('Name')->attribute('class', 'fg-label') }} {{ html()->text('name')->attribute('class', 'form-control fg-input') }} </div> </div> <div class="input-group fg-float m-t-30 checkbox"> <label class="m-l-15"> Activate {{ html()->hidden('active', 0) }} {{ html()->checkbox('active') }} <i class="input-helper"></i> </label> </div> <div class="input-group m-t-20"> <div class="fg-line"> {{ html()->button('<i class="zmdi zmdi-check"></i> Save', 'submit', 'action')->attributes([ 'class' => 'btn btn-info waves-effect', 'value' => 'save' ]) }} {{ html()->button('<i class="zmdi zmdi-mail-send"></i> Save and close', 'submit', 'action')->attributes([ 'class' => 'btn btn-info waves-effect', 'value' => 'save_close' ]) }} </div> </div> </div> </div>
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/resources/views/api_tokens/index.blade.php
Sso/resources/views/api_tokens/index.blade.php
@extends('layouts.app') @section('title', 'API Tokens') @section('content') <div class="c-header"> <h2>API Tokens</h2> </div> <div class="card"> <div class="card-header"> <h2>List of API Tokens <small></small></h2> <div class="actions"> <a href="{{ route('api-tokens.create') }}" class="btn palette-Cyan bg waves-effect">Add new API Token</a> </div> </div> {!! Widget::run('DataTable', [ 'colSettings' => [ 'name' => [ 'priority' => 1, ], 'token' => [ 'priority' => 2, ], 'active' => [ 'header' => 'Is active', 'render' => 'boolean', 'priority' => 2, ], 'created_at' => [ 'header' => 'Created at', 'render' => 'date', 'priority' => 3, ], 'updated_at' => [ 'header' => 'Updated at', 'render' => 'date', 'priority' => 4, ], ], 'dataSource' => route('api-tokens.json'), 'rowActions' => [ ['name' => 'edit', 'class' => 'zmdi-palette-Cyan zmdi-edit'], ['name' => 'destroy', 'class' => 'zmdi-palette-Cyan zmdi-delete'], ], 'rowActionLink' => 'show', 'order' => [4, 'desc'], ]) !!} </div> @endsection
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Sso/resources/views/api_tokens/create.blade.php
Sso/resources/views/api_tokens/create.blade.php
@extends('layouts.app') @section('title', 'Add API token') @section('content') <div class="c-header"> <h2>API tokens</h2> </div> <div class="card"> <div class="card-header"> <h2>Add new API token</h2> </div> <div class="card-body card-padding"> {{ html()->modelForm($apiToken)->route('api-tokens.store')->open() }} @include('api_tokens._form') {{ html()->closeModelForm() }} </div> </div> @endsection
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Bootstrap.php
Mailer/app/Bootstrap.php
<?php declare(strict_types=1); namespace Remp\Mailer; use Dotenv\Dotenv; use Nette\Bootstrap\Configurator; final class Bootstrap { public static function boot(): Configurator { // attempt to fix access rights issues in writable folders caused by different web/cli users writing to logs umask(0); (Dotenv::createImmutable(__DIR__ . '/../'))->load(); $configurator = new Configurator; $environment = $_ENV['ENV']; if ($_ENV['FORCE_HTTPS'] === 'true') { $_SERVER['HTTPS'] = 'on'; $_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https'; $_SERVER['SERVER_PORT'] = 443; } if ($environment === 'local') { $configurator->setDebugMode(true); } else { $configurator->setDebugMode(false); } $configurator->enableTracy(__DIR__ . '/../log'); $configurator->setTimeZone($_ENV['TIMEZONE']); $configurator->setTempDirectory(__DIR__ . '/../temp'); $configurator->createRobotLoader() ->addDirectory(__DIR__) ->register(); // Root config, so MailerModule can register extensions, etc. $configurator->addConfig(__DIR__ . '/../vendor/remp/mailer-module/src/config/config.root.neon'); // Rest of configuration $configurator->addConfig(__DIR__ . '/config/config.neon'); $configurator->addConfig(__DIR__ . '/config/config.local.neon'); return $configurator; } public static function isCli() { return PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg' || isset($_SERVER['SHELL']) || isset($_SERVER['TERM']) || defined('STDIN'); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Components/GeneratorWidgets/Widgets/MediaBriefingWidget/MediaBriefingWidget.php
Mailer/app/Components/GeneratorWidgets/Widgets/MediaBriefingWidget/MediaBriefingWidget.php
<?php declare(strict_types=1); namespace Remp\Mailer\Components\GeneratorWidgets\Widgets\MediaBriefingWidget; use Nette\Application\Responses\JsonResponse; use Nette\Application\UI\Form; use Nette\Http\Session; use Remp\Mailer\Forms\MediaBriefingTemplateFormFactory; use Remp\MailerModule\Components\BaseControl; use Remp\MailerModule\Components\GeneratorWidgets\Widgets\IGeneratorWidget; use Remp\MailerModule\Models\ContentGenerator\ContentGenerator; use Remp\MailerModule\Models\ContentGenerator\GeneratorInputFactory; use Remp\MailerModule\Presenters\MailGeneratorPresenter; use Remp\MailerModule\Repositories\ActiveRowFactory; use Remp\MailerModule\Repositories\LayoutsRepository; use Remp\MailerModule\Repositories\ListsRepository; class MediaBriefingWidget extends BaseControl implements IGeneratorWidget { private string $templateName = 'mediabriefing_widget.latte'; public function __construct( private Session $session, private LayoutsRepository $layoutsRepository, private ListsRepository $listsRepository, private ContentGenerator $contentGenerator, private MediaBriefingTemplateFormFactory $mediaBriefingTemplateFormFactory, private GeneratorInputFactory $generatorInputFactory, private ActiveRowFactory $activeRowFactory, ) { } public function identifier(): string { return "mediabriefingwidget"; } public function render($params): void { if (!isset($params['addonParams'])) { return; } foreach ($params['addonParams'] as $var => $param) { $this->template->$var = $param; } $this->template->htmlContent = $params['htmlContent']; $this->template->textContent = $params['textContent']; $this->template->setFile(__DIR__ . '/' . $this->templateName); $this->template->render(); } public function createComponentMediaBriefingTemplateForm(): Form { $form = $this->mediaBriefingTemplateFormFactory->create(); $this->mediaBriefingTemplateFormFactory->onSave = function () { $this->getPresenter()->flashMessage("MediaBriefing batches were created and run."); $this->getPresenter()->redirect("Job:Default"); }; return $form; } public function handleMediaBriefingPreview(): void { $request = $this->getPresenter()->getRequest(); $htmlContent = $request->getPost('html_content'); $textContent = $request->getPost('text_content'); $lockedHtmlContent = $request->getPost('locked_html_content'); $lockedTextContent = $request->getPost('locked_text_content'); $mailLayout = $this->layoutsRepository->find($_POST['mail_layout_id']); $lockedMailLayout = $this->layoutsRepository->find($_POST['locked_mail_layout_id']); $mailType = $this->listsRepository->find($_POST['mail_type_id']); $generate = function ($htmlContent, $textContent, $mailLayout, $mailType) use ($request) { $mailTemplate = $this->activeRowFactory->create([ 'name' => $request->getPost('name'), 'code' => 'tmp_' . microtime(true), 'description' => '', 'from' => $request->getPost('from'), 'autologin' => true, 'subject' => $request->getPost('subject'), 'mail_body_text' => $textContent, 'mail_body_html' => $htmlContent, 'mail_layout_id' => $mailLayout->id, 'mail_layout' => $mailLayout, 'mail_type_id' => $request->getPost('mail_type_id'), 'mail_type' => $mailType, 'params' => null, 'click_tracking' => false, ]); return $this->contentGenerator->render($this->generatorInputFactory->create($mailTemplate)); }; $mailContent = $generate($htmlContent, $textContent, $mailLayout, $mailType); $this->template->generatedHtml = $mailContent->html(); $this->template->generatedText = $mailContent->text(); $lockedMailContent = $generate($lockedHtmlContent, $lockedTextContent, $lockedMailLayout, $mailType); $this->template->generatedLockedHtml = $lockedMailContent->html(); $this->template->generatedLockedText = $lockedMailContent->text(); // Store data in session for full-screen preview $sessionSection = $this->session->getSection(MailGeneratorPresenter::SESSION_SECTION_CONTENT_PREVIEW); $sessionSection->generatedHtml = $mailContent->html(); $sessionSection->generatedLockedHtml = $lockedMailContent->html(); $response = new JsonResponse([ 'generatedHtml' => $mailContent->html(), 'generatedText' => $mailContent->text(), 'generatedLockedHtml' => $lockedMailContent->html(), 'generatedLockedText' => $lockedMailContent->text(), ]); $this->getPresenter()->sendResponse($response); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Components/GeneratorWidgets/Widgets/MMSWidget/MMSWidget.php
Mailer/app/Components/GeneratorWidgets/Widgets/MMSWidget/MMSWidget.php
<?php declare(strict_types=1); namespace Remp\Mailer\Components\GeneratorWidgets\Widgets\MMSWidget; use Nette\Application\Responses\JsonResponse; use Nette\Application\UI\Form; use Nette\Http\Session; use Remp\Mailer\Forms\MMSTemplateFormFactory; use Remp\MailerModule\Components\BaseControl; use Remp\MailerModule\Components\GeneratorWidgets\Widgets\IGeneratorWidget; use Remp\MailerModule\Models\ContentGenerator\ContentGenerator; use Remp\MailerModule\Models\ContentGenerator\GeneratorInputFactory; use Remp\MailerModule\Presenters\MailGeneratorPresenter; use Remp\MailerModule\Repositories\ActiveRowFactory; use Remp\MailerModule\Repositories\LayoutsRepository; use Remp\MailerModule\Repositories\ListsRepository; class MMSWidget extends BaseControl implements IGeneratorWidget { private string $templateName = 'mms_widget.latte'; public function __construct( private Session $session, private LayoutsRepository $layoutsRepository, private ListsRepository $listsRepository, private ContentGenerator $contentGenerator, private MMSTemplateFormFactory $mmsTemplateFormFactory, private GeneratorInputFactory $generatorInputFactory, private ActiveRowFactory $activeRowFactory, ) { } public function identifier(): string { return "mmswidget"; } public function render($params): void { if (!isset($params['addonParams'])) { return; } foreach ($params['addonParams'] as $var => $param) { $this->template->$var = $param; } $this->template->htmlContent = $params['htmlContent']; $this->template->textContent = $params['textContent']; $this->template->setFile(__DIR__ . '/' . $this->templateName); $this->template->render(); } public function createComponentMMSTemplateForm(): Form { $form = $this->mmsTemplateFormFactory->create(); $this->mmsTemplateFormFactory->onSave = function () { $this->getPresenter()->flashMessage("Odkaz MMS batches were created and run."); $this->getPresenter()->redirect("Job:Default"); }; return $form; } public function handleMMSPreview(): void { $request = $this->getPresenter()->getRequest(); $htmlContent = $request->getPost('html_content'); $textContent = $request->getPost('text_content'); $lockedHtmlContent = $request->getPost('locked_html_content'); $lockedTextContent = $request->getPost('locked_text_content'); $mailLayout = $this->layoutsRepository->find($_POST['mail_layout_id']); $lockedMailLayout = $this->layoutsRepository->find($_POST['locked_mail_layout_id']); $mailType = $this->listsRepository->find($_POST['mail_type_id']); $generate = function ($htmlContent, $textContent, $mailLayout, $mailType) use ($request) { $mailTemplate = $this->activeRowFactory->create([ 'name' => $request->getPost('name'), 'code' => 'tmp_' . microtime(true), 'description' => '', 'from' => $request->getPost('from'), 'autologin' => true, 'subject' => $request->getPost('subject'), 'mail_body_text' => $textContent, 'mail_body_html' => $htmlContent, 'mail_layout_id' => $mailLayout->id, 'mail_layout' => $mailLayout, 'mail_type_id' => $request->getPost('mail_type_id'), 'mail_type' => $mailType, 'params' => null, 'click_tracking' => false, ]); return $this->contentGenerator->render($this->generatorInputFactory->create($mailTemplate)); }; $mailContent = $generate($htmlContent, $textContent, $mailLayout, $mailType); $this->template->generatedHtml = $mailContent->html(); $this->template->generatedText = $mailContent->text(); $lockedMailContent = $generate($lockedHtmlContent, $lockedTextContent, $lockedMailLayout, $mailType); $this->template->generatedLockedHtml = $lockedMailContent->html(); $this->template->generatedLockedText = $lockedMailContent->text(); // Store data in session for full-screen preview $sessionSection = $this->session->getSection(MailGeneratorPresenter::SESSION_SECTION_CONTENT_PREVIEW); $sessionSection->generatedHtml = $mailContent->html(); $sessionSection->generatedLockedHtml = $lockedMailContent->html(); $response = new JsonResponse([ 'generatedHtml' => $mailContent->html(), 'generatedText' => $mailContent->text(), 'generatedLockedHtml' => $lockedMailContent->html(), 'generatedLockedText' => $lockedMailContent->text(), ]); $this->getPresenter()->sendResponse($response); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Components/GeneratorWidgets/Widgets/DailyMinuteWidget/DailyMinuteWidget.php
Mailer/app/Components/GeneratorWidgets/Widgets/DailyMinuteWidget/DailyMinuteWidget.php
<?php declare(strict_types=1); namespace Remp\Mailer\Components\GeneratorWidgets\Widgets\DailyMinuteWidget; use Nette\Application\Responses\JsonResponse; use Nette\Application\UI\Form; use Nette\Http\Session; use Remp\Mailer\Forms\DailyMinuteTemplateFormFactory; use Remp\MailerModule\Components\BaseControl; use Remp\MailerModule\Components\GeneratorWidgets\Widgets\IGeneratorWidget; use Remp\MailerModule\Models\ContentGenerator\ContentGenerator; use Remp\MailerModule\Models\ContentGenerator\GeneratorInputFactory; use Remp\MailerModule\Presenters\MailGeneratorPresenter; use Remp\MailerModule\Repositories\ActiveRowFactory; use Remp\MailerModule\Repositories\LayoutsRepository; use Remp\MailerModule\Repositories\ListsRepository; class DailyMinuteWidget extends BaseControl implements IGeneratorWidget { private string $templateName = 'daily_minute_widget.latte'; public function __construct( private Session $session, private LayoutsRepository $layoutsRepository, private ListsRepository $listsRepository, private ContentGenerator $contentGenerator, private DailyMinuteTemplateFormFactory $dailyMinuteTemplateFormFactory, private GeneratorInputFactory $generatorInputFactory, private ActiveRowFactory $activeRowFactory, ) { } public function identifier(): string { return "dailyminutewidget"; } public function render($params): void { if (!isset($params['addonParams'])) { return; } foreach ($params['addonParams'] as $var => $param) { $this->template->$var = $param; } $this->template->htmlContent = $params['htmlContent']; $this->template->textContent = $params['textContent']; $this->template->setFile(__DIR__ . '/' . $this->templateName); $this->template->render(); } public function createComponentDailyMinuteTemplateForm(): Form { $form = $this->dailyMinuteTemplateFormFactory->create(); $this->dailyMinuteTemplateFormFactory->onSave = function () { $this->getPresenter()->flashMessage("Daily minute batches were created and run."); $this->getPresenter()->redirect("Job:Default"); }; return $form; } public function handleDailyMinutePreview(): void { $request = $this->getPresenter()->getRequest(); $htmlContent = $request->getPost('html_content'); $textContent = $request->getPost('text_content'); $mailLayout = $this->layoutsRepository->find($_POST['mail_layout_id']); $mailType = $this->listsRepository->find($_POST['mail_type_id']); $generate = function ($htmlContent, $textContent, $mailLayout, $mailType) use ($request) { $mailTemplate = $this->activeRowFactory->create([ 'name' => $request->getPost('name'), 'code' => 'tmp_' . microtime(true), 'description' => '', 'from' => $request->getPost('from'), 'autologin' => true, 'subject' => $request->getPost('subject'), 'mail_body_text' => $textContent, 'mail_body_html' => $htmlContent, 'mail_layout_id' => $mailLayout->id, 'mail_layout' => $mailLayout, 'mail_type_id' => $request->getPost('mail_type_id'), 'mail_type' => $mailType, 'params' => null, 'click_tracking' => false, ]); return $this->contentGenerator->render($this->generatorInputFactory->create($mailTemplate)); }; $mailContent = $generate($htmlContent, $textContent, $mailLayout, $mailType); $this->template->generatedHtml = $mailContent->html(); $this->template->generatedText = $mailContent->text(); // Store data in session for full-screen preview $sessionSection = $this->session->getSection(MailGeneratorPresenter::SESSION_SECTION_CONTENT_PREVIEW); $sessionSection->generatedHtml = $mailContent->html(); $response = new JsonResponse([ 'generatedHtml' => $mailContent->html(), 'generatedText' => $mailContent->text(), ]); $this->getPresenter()->sendResponse($response); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Components/GeneratorWidgets/Widgets/RespektUrlParserWidget/RespektUrlParserWidget.php
Mailer/app/Components/GeneratorWidgets/Widgets/RespektUrlParserWidget/RespektUrlParserWidget.php
<?php declare(strict_types=1); namespace Remp\Mailer\Components\GeneratorWidgets\Widgets\RespektUrlParserWidget; use Nette\Application\Responses\JsonResponse; use Nette\Application\UI\Form; use Nette\Http\Session; use Remp\Mailer\Forms\RespektUrlParserTemplateFormFactory; use Remp\MailerModule\Components\BaseControl; use Remp\MailerModule\Components\GeneratorWidgets\Widgets\IGeneratorWidget; use Remp\MailerModule\Models\ContentGenerator\ContentGenerator; use Remp\MailerModule\Models\ContentGenerator\GeneratorInputFactory; use Remp\MailerModule\Presenters\MailGeneratorPresenter; use Remp\MailerModule\Repositories\ActiveRowFactory; use Remp\MailerModule\Repositories\LayoutsRepository; use Remp\MailerModule\Repositories\ListsRepository; class RespektUrlParserWidget extends BaseControl implements IGeneratorWidget { private string $templateName = 'respekt_url_parser_widget.latte'; public function __construct( private readonly Session $session, private readonly RespektUrlParserTemplateFormFactory $templateFormFactory, private readonly LayoutsRepository $layoutsRepository, private readonly ListsRepository $listsRepository, private readonly ContentGenerator $contentGenerator, private readonly GeneratorInputFactory $generatorInputFactory, private readonly ActiveRowFactory $activeRowFactory ) { } public function identifier(): string { return 'respekturlparserwidget'; } public function render($params): void { if (!isset($params['addonParams'])) { return; } foreach ($params['addonParams'] as $var => $param) { $this->template->$var = $param; } $this->template->htmlContent = $params['htmlContent']; $this->template->textContent = $params['textContent']; $this->template->lists = $this->listsRepository->all()->fetchAssoc('id'); $this->template->setFile(__DIR__ . '/' . $this->templateName); $this->template->render(); } public function createComponentTemplateForm(): Form { $form = $this->templateFormFactory->create(); $this->templateFormFactory->onSave = function () { $this->getPresenter()->flashMessage("Job batches were created and run."); $this->getPresenter()->redirect("Job:Default"); }; return $form; } public function handlePreview(): void { $request = $this->getPresenter()->getRequest(); $htmlContent = $request->getPost('html_content'); $textContent = $request->getPost('text_content'); $mailLayout = $this->layoutsRepository->find($_POST['mail_layout_id']); $mailType = $this->listsRepository->find($_POST['mail_type_id']); $generate = function ($htmlContent, $textContent, $mailLayout, $mailType) use ($request) { $mailTemplate = $this->activeRowFactory->create([ 'name' => $request->getPost('name'), 'code' => 'tmp_' . microtime(true), 'description' => '', 'from' => $request->getPost('from'), 'autologin' => true, 'subject' => $request->getPost('subject'), 'mail_body_text' => $textContent, 'mail_body_html' => $htmlContent, 'mail_layout_id' => $mailLayout->id, 'mail_layout' => $mailLayout, 'mail_type_id' => $request->getPost('mail_type_id'), 'mail_type' => $mailType, 'params' => null, 'click_tracking' => false, ]); return $this->contentGenerator->render($this->generatorInputFactory->create($mailTemplate)); }; $mailContent = $generate($htmlContent, $textContent, $mailLayout, $mailType); $this->template->generatedHtml = $mailContent->html(); $this->template->generatedText = $mailContent->text(); // Store data in session for full-screen preview $sessionSection = $this->session->getSection(MailGeneratorPresenter::SESSION_SECTION_CONTENT_PREVIEW); $sessionSection->generatedHtml = $mailContent->html(); $response = new JsonResponse([ 'generatedHtml' => $mailContent->html(), 'generatedText' => $mailContent->text(), ]); $this->getPresenter()->sendResponse($response); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Components/GeneratorWidgets/Widgets/GrafdnaWidget/GrafdnaWidget.php
Mailer/app/Components/GeneratorWidgets/Widgets/GrafdnaWidget/GrafdnaWidget.php
<?php namespace Remp\Mailer\Components\GeneratorWidgets\Widgets\GrafdnaWidget; use Nette\Application\Responses\JsonResponse; use Nette\Application\UI\Form; use Nette\Http\Session; use Remp\Mailer\Forms\GrafdnaTemplateFormFactory; use Remp\MailerModule\Components\BaseControl; use Remp\MailerModule\Components\GeneratorWidgets\Widgets\IGeneratorWidget; use Remp\MailerModule\Models\ContentGenerator\ContentGenerator; use Remp\MailerModule\Models\ContentGenerator\GeneratorInputFactory; use Remp\MailerModule\Presenters\MailGeneratorPresenter; use Remp\MailerModule\Repositories\ActiveRowFactory; use Remp\MailerModule\Repositories\LayoutsRepository; use Remp\MailerModule\Repositories\ListsRepository; class GrafdnaWidget extends BaseControl implements IGeneratorWidget { private string $templateName = 'grafdna_widget.latte'; public function __construct( private Session $session, private LayoutsRepository $layoutsRepository, private ListsRepository $listsRepository, private ContentGenerator $contentGenerator, private GrafdnaTemplateFormFactory $grafdnaTemplateFormFactory, private GeneratorInputFactory $generatorInputFactory, private ActiveRowFactory $activeRowFactory, ) { } public function identifier(): string { return "grafdnawidget"; } public function render($params): void { if (!isset($params['addonParams'])) { return; } foreach ($params['addonParams'] as $var => $param) { $this->template->$var = $param; } $this->template->htmlContent = $params['htmlContent']; $this->template->textContent = $params['textContent']; $this->template->setFile(__DIR__ . '/' . $this->templateName); $this->template->render(); } public function createComponentGrafdnaTemplateForm(): Form { $form = $this->grafdnaTemplateFormFactory->create(); $this->grafdnaTemplateFormFactory->onSave = function () { $this->getPresenter()->flashMessage("Grafdna batches were created and run."); $this->getPresenter()->redirect("Job:Default"); }; return $form; } public function handleGrafdnaPreview(): void { $request = $this->getPresenter()->getRequest(); $htmlContent = $request->getPost('html_content'); $textContent = $request->getPost('text_content'); $lockedHtmlContent = $request->getPost('locked_html_content'); $lockedTextContent = $request->getPost('locked_text_content'); $mailLayout = $this->layoutsRepository->find($_POST['mail_layout_id']); $lockedMailLayout = $this->layoutsRepository->find($_POST['locked_mail_layout_id']); $mailType = $this->listsRepository->find($_POST['mail_type_id']); $generate = function ($htmlContent, $textContent, $mailLayout, $mailType) use ($request) { $mailTemplate = $this->activeRowFactory->create([ 'name' => $request->getPost('name'), 'code' => 'tmp_' . microtime(true), 'description' => '', 'from' => $request->getPost('from'), 'autologin' => true, 'subject' => $request->getPost('subject'), 'mail_body_text' => $textContent, 'mail_body_html' => $htmlContent, 'mail_layout_id' => $mailLayout->id, 'mail_layout' => $mailLayout, 'mail_type_id' => $request->getPost('mail_type_id'), 'mail_type' => $mailType, 'params' => null, 'click_tracking' => false, ]); return $this->contentGenerator->render($this->generatorInputFactory->create($mailTemplate)); }; $mailContent = $generate($htmlContent, $textContent, $mailLayout, $mailType); $this->template->generatedHtml = $mailContent->html(); $this->template->generatedText = $mailContent->text(); $lockedMailContent = $generate($lockedHtmlContent, $lockedTextContent, $lockedMailLayout, $mailType); $this->template->generatedLockedHtml = $lockedMailContent->html(); $this->template->generatedLockedText = $lockedMailContent->text(); // Store data in session for full-screen preview $sessionSection = $this->session->getSection(MailGeneratorPresenter::SESSION_SECTION_CONTENT_PREVIEW); $sessionSection->generatedHtml = $mailContent->html(); $sessionSection->generatedLockedHtml = $lockedMailContent->html(); $response = new JsonResponse([ 'generatedHtml' => $mailContent->html(), 'generatedText' => $mailContent->text(), 'generatedLockedHtml' => $lockedMailContent->html(), 'generatedLockedText' => $lockedMailContent->text(), ]); $this->getPresenter()->sendResponse($response); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Components/GeneratorWidgets/Widgets/RespektArticleParserWidget/RespektArticleParserWidget.php
Mailer/app/Components/GeneratorWidgets/Widgets/RespektArticleParserWidget/RespektArticleParserWidget.php
<?php declare(strict_types=1); namespace Remp\Mailer\Components\GeneratorWidgets\Widgets\RespektArticleParserWidget; use Nette\Application\Responses\JsonResponse; use Nette\Application\UI\Form; use Nette\Http\Session; use Remp\Mailer\Forms\RespektArticleParserTemplateFormFactory; use Remp\MailerModule\Components\BaseControl; use Remp\MailerModule\Components\GeneratorWidgets\Widgets\IGeneratorWidget; use Remp\MailerModule\Models\ContentGenerator\ContentGenerator; use Remp\MailerModule\Models\ContentGenerator\GeneratorInputFactory; use Remp\MailerModule\Presenters\MailGeneratorPresenter; use Remp\MailerModule\Repositories\ActiveRowFactory; use Remp\MailerModule\Repositories\LayoutsRepository; use Remp\MailerModule\Repositories\ListsRepository; class RespektArticleParserWidget extends BaseControl implements IGeneratorWidget { private string $templateName = 'respekt_article_parser_widget.latte'; public function __construct( private readonly Session $session, private readonly RespektArticleParserTemplateFormFactory $templateFormFactory, private readonly LayoutsRepository $layoutsRepository, private readonly ListsRepository $listsRepository, private readonly ContentGenerator $contentGenerator, private readonly GeneratorInputFactory $generatorInputFactory, private readonly ActiveRowFactory $activeRowFactory ) { } public function identifier(): string { return 'respektarticleparserwidget'; } public function render($params): void { if (!isset($params['addonParams'])) { return; } foreach ($params['addonParams'] as $var => $param) { $this->template->$var = $param; } $this->template->htmlContent = $params['htmlContent']; $this->template->textContent = $params['textContent']; $this->template->lists = array_map(function ($item) { return $item->toArray(); }, $this->listsRepository->all()->fetchAll()); $this->template->setFile(__DIR__ . '/' . $this->templateName); $this->template->render(); } public function createComponentTemplateForm(): Form { $form = $this->templateFormFactory->create(); $this->templateFormFactory->onSave = function () { $this->getPresenter()->flashMessage("Job batches were created and run."); $this->getPresenter()->redirect("Job:Default"); }; return $form; } public function handlePreview(): void { $request = $this->getPresenter()->getRequest(); $htmlContent = $request->getPost('html_content'); $textContent = $request->getPost('text_content'); $lockedHtmlContent = $request->getPost('locked_html_content'); $lockedTextContent = $request->getPost('locked_text_content'); $mailLayout = $this->layoutsRepository->find($request->getPost('mail_layout_id')); $lockedMailLayout = $this->layoutsRepository->find($request->getPost('locked_mail_layout_id')); $mailType = $this->listsRepository->find($request->getPost('mail_type_id')); $generate = function ($htmlContent, $textContent, $mailLayout, $mailType) use ($request) { $mailTemplate = $this->activeRowFactory->create([ 'name' => $request->getPost('name'), 'code' => 'tmp_' . microtime(true), 'description' => '', 'from' => $request->getPost('from'), 'autologin' => true, 'subject' => $request->getPost('subject'), 'mail_body_text' => $textContent, 'mail_body_html' => $htmlContent, 'mail_layout_id' => $mailLayout->id, 'mail_layout' => $mailLayout, 'mail_type_id' => $request->getPost('mail_type_id'), 'mail_type' => $mailType, 'params' => null, 'click_tracking' => false, ]); return $this->contentGenerator->render($this->generatorInputFactory->create($mailTemplate)); }; $mailContent = $generate($htmlContent, $textContent, $mailLayout, $mailType); $this->template->generatedHtml = $mailContent->html(); $this->template->generatedText = $mailContent->text(); $lockedMailContent = $generate($lockedHtmlContent, $lockedTextContent, $lockedMailLayout, $mailType); $this->template->generatedLockedHtml = $lockedMailContent->html(); $this->template->generatedLockedText = $lockedMailContent->text(); // Store data in session for full-screen preview $sessionSection = $this->session->getSection(MailGeneratorPresenter::SESSION_SECTION_CONTENT_PREVIEW); $sessionSection->generatedHtml = $mailContent->html(); $response = new JsonResponse([ 'generatedHtml' => $mailContent->html(), 'generatedText' => $mailContent->text(), 'generatedLockedHtml' => $lockedMailContent->html(), 'generatedLockedText' => $lockedMailContent->text(), ]); $this->getPresenter()->sendResponse($response); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Components/GeneratorWidgets/Widgets/NewsfilterWidget/NewsfilterWidget.php
Mailer/app/Components/GeneratorWidgets/Widgets/NewsfilterWidget/NewsfilterWidget.php
<?php declare(strict_types=1); namespace Remp\Mailer\Components\GeneratorWidgets\Widgets\NewsfilterWidget; use Nette\Application\Responses\JsonResponse; use Nette\Application\UI\Form; use Nette\Http\Session; use Remp\Mailer\Forms\NewsfilterTemplateFormFactory; use Remp\MailerModule\Components\BaseControl; use Remp\MailerModule\Components\GeneratorWidgets\Widgets\IGeneratorWidget; use Remp\MailerModule\Models\ContentGenerator\ContentGenerator; use Remp\MailerModule\Models\ContentGenerator\GeneratorInputFactory; use Remp\MailerModule\Presenters\MailGeneratorPresenter; use Remp\MailerModule\Repositories\ActiveRowFactory; use Remp\MailerModule\Repositories\LayoutsRepository; use Remp\MailerModule\Repositories\ListsRepository; class NewsfilterWidget extends BaseControl implements IGeneratorWidget { private string $templateName = 'newsfilter_widget.latte'; public function __construct( private Session $session, private LayoutsRepository $layoutsRepository, private ListsRepository $listsRepository, private ContentGenerator $contentGenerator, private NewsfilterTemplateFormFactory $newsfilterTemplateFormFactory, private GeneratorInputFactory $generatorInputFactory, private ActiveRowFactory $activeRowFactory, ) { } public function identifier(): string { return "newsfilterwidget"; } public function render($params): void { if (!isset($params['addonParams'])) { return; } foreach ($params['addonParams'] as $var => $param) { $this->template->$var = $param; } $this->template->htmlContent = $params['htmlContent']; $this->template->textContent = $params['textContent']; $this->template->setFile(__DIR__ . '/' . $this->templateName); $this->template->render(); } public function createComponentNewsfilterTemplateForm(): Form { $form = $this->newsfilterTemplateFormFactory->create(); $this->newsfilterTemplateFormFactory->onSave = function () { $this->getPresenter()->flashMessage("Newsfilter batches were created and run."); $this->getPresenter()->redirect("Job:Default"); }; return $form; } public function handleNewsfilterPreview(): void { $request = $this->getPresenter()->getRequest(); $htmlContent = $request->getPost('html_content'); $textContent = $request->getPost('text_content'); $lockedHtmlContent = $request->getPost('locked_html_content'); $lockedTextContent = $request->getPost('locked_text_content'); $mailLayout = $this->layoutsRepository->findBy('code', $request->getPost('mail_layout_code')); $lockedMailLayout = $this->layoutsRepository->findBy('code', $request->getPost('locked_mail_layout_code')); $mailType = $this->listsRepository->findBy('code', $request->getPost('mail_type_code')); $generate = function ($htmlContent, $textContent, $mailLayout, $mailType) use ($request) { $mailTemplate = $this->activeRowFactory->create([ 'name' => $request->getPost('name'), 'code' => 'tmp_' . microtime(true), 'description' => '', 'from' => $request->getPost('from'), 'autologin' => true, 'subject' => $request->getPost('subject'), 'mail_body_text' => $textContent, 'mail_body_html' => $htmlContent, 'mail_layout_id' => $mailLayout->id, 'mail_layout' => $mailLayout, 'mail_type_id' => $mailType->id, 'mail_type' => $mailType, 'params' => null, 'click_tracking' => false, ]); return $this->contentGenerator->render($this->generatorInputFactory->create($mailTemplate)); }; $mailContent = $generate($htmlContent, $textContent, $mailLayout, $mailType); $this->template->generatedHtml = $mailContent->html(); $this->template->generatedText = $mailContent->text(); $lockedMailContent = $generate($lockedHtmlContent, $lockedTextContent, $lockedMailLayout, $mailType); $this->template->generatedLockedHtml = $lockedMailContent->html(); $this->template->generatedLockedText = $lockedMailContent->text(); // Store data in session for full-screen preview $sessionSection = $this->session->getSection(MailGeneratorPresenter::SESSION_SECTION_CONTENT_PREVIEW); $sessionSection->generatedHtml = $mailContent->html(); $sessionSection->generatedLockedHtml = $lockedMailContent->html(); $response = new JsonResponse([ 'generatedHtml' => $mailContent->html(), 'generatedText' => $mailContent->text(), 'generatedLockedHtml' => $lockedMailContent->html(), 'generatedLockedText' => $lockedMailContent->text(), ]); $this->getPresenter()->sendResponse($response); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Components/GeneratorWidgets/Widgets/DennikeWidget/DennikeWidget.php
Mailer/app/Components/GeneratorWidgets/Widgets/DennikeWidget/DennikeWidget.php
<?php declare(strict_types=1); namespace Remp\Mailer\Components\GeneratorWidgets\Widgets\DennikeWidget; use Nette\Application\Responses\JsonResponse; use Nette\Application\UI\Form; use Nette\Http\Session; use Remp\Mailer\Forms\DennikeTemplateFormFactory; use Remp\MailerModule\Components\BaseControl; use Remp\MailerModule\Components\GeneratorWidgets\Widgets\IGeneratorWidget; use Remp\MailerModule\Models\ContentGenerator\ContentGenerator; use Remp\MailerModule\Models\ContentGenerator\GeneratorInputFactory; use Remp\MailerModule\Presenters\MailGeneratorPresenter; use Remp\MailerModule\Repositories\ActiveRowFactory; use Remp\MailerModule\Repositories\LayoutsRepository; use Remp\MailerModule\Repositories\ListsRepository; class DennikeWidget extends BaseControl implements IGeneratorWidget { private string $templateName = 'dennike_widget.latte'; public function __construct( private Session $session, private LayoutsRepository $layoutsRepository, private ListsRepository $listsRepository, private ContentGenerator $contentGenerator, private DennikeTemplateFormFactory $dennikeTemplateFormFactory, private GeneratorInputFactory $generatorInputFactory, private ActiveRowFactory $activeRowFactory, ) { } public function identifier(): string { return "dennikewidget"; } public function render($params): void { if (!isset($params['addonParams'])) { return; } foreach ($params['addonParams'] as $var => $param) { $this->template->$var = $param; } $this->template->htmlContent = $params['htmlContent']; $this->template->textContent = $params['textContent']; $this->template->setFile(__DIR__ . '/' . $this->templateName); $this->template->render(); } public function createComponentDennikeTemplateForm(): Form { $form = $this->dennikeTemplateFormFactory->create(); $this->dennikeTemplateFormFactory->onSave = function () { $this->getPresenter()->flashMessage("Dennike batches were created and run."); $this->getPresenter()->redirect("Job:Default"); }; return $form; } public function handleDennikePreview(): void { $request = $this->getPresenter()->getRequest(); $htmlContent = $request->getPost('html_content'); $textContent = $request->getPost('text_content'); $lockedHtmlContent = $request->getPost('locked_html_content'); $lockedTextContent = $request->getPost('locked_text_content'); $mailLayout = $this->layoutsRepository->find($_POST['mail_layout_id']); $lockedMailLayout = $this->layoutsRepository->find($_POST['locked_mail_layout_id']); $mailType = $this->listsRepository->find($_POST['mail_type_id']); $generate = function ($htmlContent, $textContent, $mailLayout, $mailType) use ($request) { $mailTemplate = $this->activeRowFactory->create([ 'name' => $request->getPost('name'), 'code' => 'tmp_' . microtime(true), 'description' => '', 'from' => $request->getPost('from'), 'autologin' => true, 'subject' => $request->getPost('subject'), 'mail_body_text' => $textContent, 'mail_body_html' => $htmlContent, 'mail_layout_id' => $mailLayout->id, 'mail_layout' => $mailLayout, 'mail_type_id' => $request->getPost('mail_type_id'), 'mail_type' => $mailType, 'params' => null, 'click_tracking' => false, ]); return $this->contentGenerator->render($this->generatorInputFactory->create($mailTemplate)); }; $mailContent = $generate($htmlContent, $textContent, $mailLayout, $mailType); $this->template->generatedHtml = $mailContent->html(); $this->template->generatedText = $mailContent->text(); $lockedMailContent = $generate($lockedHtmlContent, $lockedTextContent, $lockedMailLayout, $mailType); $this->template->generatedLockedHtml = $lockedMailContent->html(); $this->template->generatedLockedText = $lockedMailContent->text(); // Store data in session for full-screen preview $sessionSection = $this->session->getSection(MailGeneratorPresenter::SESSION_SECTION_CONTENT_PREVIEW); $sessionSection->generatedHtml = $mailContent->html(); $sessionSection->generatedLockedHtml = $mailContent->text(); $response = new JsonResponse([ 'generatedHtml' => $mailContent->html(), 'generatedText' => $mailContent->text(), 'generatedLockedHtml' => $lockedMailContent->html(), 'generatedLockedText' => $lockedMailContent->text(), ]); $this->getPresenter()->sendResponse($response); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Components/GeneratorWidgets/Widgets/ArticleUrlParserWidget/ArticleUrlParserWidget.php
Mailer/app/Components/GeneratorWidgets/Widgets/ArticleUrlParserWidget/ArticleUrlParserWidget.php
<?php declare(strict_types=1); namespace Remp\Mailer\Components\GeneratorWidgets\Widgets\ArticleUrlParserWidget; use Nette\Application\Responses\JsonResponse; use Nette\Application\UI\Form; use Nette\Http\Session; use Remp\Mailer\Forms\ArticleUrlParserTemplateFormFactory; use Remp\MailerModule\Components\BaseControl; use Remp\MailerModule\Components\GeneratorWidgets\Widgets\IGeneratorWidget; use Remp\MailerModule\Models\ContentGenerator\ContentGenerator; use Remp\MailerModule\Models\ContentGenerator\GeneratorInputFactory; use Remp\MailerModule\Presenters\MailGeneratorPresenter; use Remp\MailerModule\Repositories\ActiveRowFactory; use Remp\MailerModule\Repositories\LayoutsRepository; use Remp\MailerModule\Repositories\ListsRepository; class ArticleUrlParserWidget extends BaseControl implements IGeneratorWidget { private string $templateName = 'article_url_parser_widget.latte'; public function __construct( private Session $session, private ArticleUrlParserTemplateFormFactory $templateFormFactory, private LayoutsRepository $layoutsRepository, private ListsRepository $listsRepository, private ContentGenerator $contentGenerator, private GeneratorInputFactory $generatorInputFactory, private ActiveRowFactory $activeRowFactory ) { } public function identifier(): string { return 'articleurlparserwidget'; } public function render($params): void { if (!isset($params['addonParams'])) { return; } foreach ($params['addonParams'] as $var => $param) { $this->template->$var = $param; } $this->template->htmlContent = $params['htmlContent']; $this->template->textContent = $params['textContent']; $this->template->lists = $this->listsRepository->all()->fetchAssoc('id'); $this->template->setFile(__DIR__ . '/' . $this->templateName); $this->template->render(); } public function createComponentTemplateForm(): Form { $form = $this->templateFormFactory->create(); $this->templateFormFactory->onSave = function () { $this->getPresenter()->flashMessage("Job batches were created and run."); $this->getPresenter()->redirect("Job:Default"); }; return $form; } public function handlePreview(): void { $request = $this->getPresenter()->getRequest(); $htmlContent = $request->getPost('html_content'); $textContent = $request->getPost('text_content'); $mailLayout = $this->layoutsRepository->find($_POST['mail_layout_id']); $mailType = $this->listsRepository->find($_POST['mail_type_id']); $generate = function ($htmlContent, $textContent, $mailLayout, $mailType) use ($request) { $mailTemplate = $this->activeRowFactory->create([ 'name' => $request->getPost('name'), 'code' => 'tmp_' . microtime(true), 'description' => '', 'from' => $request->getPost('from'), 'autologin' => true, 'subject' => $request->getPost('subject'), 'mail_body_text' => $textContent, 'mail_body_html' => $htmlContent, 'mail_layout_id' => $mailLayout->id, 'mail_layout' => $mailLayout, 'mail_type_id' => $request->getPost('mail_type_id'), 'mail_type' => $mailType, 'params' => null, 'click_tracking' => false, ]); return $this->contentGenerator->render($this->generatorInputFactory->create($mailTemplate)); }; $mailContent = $generate($htmlContent, $textContent, $mailLayout, $mailType); $this->template->generatedHtml = $mailContent->html(); $this->template->generatedText = $mailContent->text(); // Store data in session for full-screen preview $sessionSection = $this->session->getSection(MailGeneratorPresenter::SESSION_SECTION_CONTENT_PREVIEW); $sessionSection->generatedHtml = $mailContent->html(); $response = new JsonResponse([ 'generatedHtml' => $mailContent->html(), 'generatedText' => $mailContent->text(), ]); $this->getPresenter()->sendResponse($response); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Components/GeneratorWidgets/Widgets/TldrWidget/TldrWidget.php
Mailer/app/Components/GeneratorWidgets/Widgets/TldrWidget/TldrWidget.php
<?php declare(strict_types=1); namespace Remp\Mailer\Components\GeneratorWidgets\Widgets\TldrWidget; use Nette\Application\Responses\JsonResponse; use Nette\Application\UI\Form; use Nette\Http\Session; use Remp\Mailer\Forms\TldrTemplateFormFactory; use Remp\MailerModule\Components\BaseControl; use Remp\MailerModule\Components\GeneratorWidgets\Widgets\IGeneratorWidget; use Remp\MailerModule\Models\ContentGenerator\ContentGenerator; use Remp\MailerModule\Models\ContentGenerator\GeneratorInputFactory; use Remp\MailerModule\Presenters\MailGeneratorPresenter; use Remp\MailerModule\Repositories\ActiveRowFactory; use Remp\MailerModule\Repositories\LayoutsRepository; use Remp\MailerModule\Repositories\ListsRepository; class TldrWidget extends BaseControl implements IGeneratorWidget { private string $templateName = 'tldr_widget.latte'; public function __construct( private Session $session, private LayoutsRepository $layoutsRepository, private ListsRepository $listsRepository, private ContentGenerator $contentGenerator, private TldrTemplateFormFactory $tldrTemplateFormFactory, private GeneratorInputFactory $generatorInputFactory, private ActiveRowFactory $activeRowFactory, ) { } public function identifier(): string { return "tldrwidget"; } public function render($params): void { if (!isset($params['addonParams'])) { return; } foreach ($params['addonParams'] as $var => $param) { $this->template->$var = $param; } $this->template->htmlContent = $params['htmlContent']; $this->template->textContent = $params['textContent']; $this->template->setFile(__DIR__ . '/' . $this->templateName); $this->template->render(); } public function createComponentTldrTemplateForm(): Form { $form = $this->tldrTemplateFormFactory->create(); $this->tldrTemplateFormFactory->onSave = function () { $this->getPresenter()->flashMessage("Tl;dr batches were created and run."); $this->getPresenter()->redirect("Job:Default"); }; return $form; } public function handleTldrPreview(): void { $request = $this->getPresenter()->getRequest(); $htmlContent = $request->getPost('html_content'); $textContent = $request->getPost('text_content'); $lockedHtmlContent = $request->getPost('locked_html_content'); $lockedTextContent = $request->getPost('locked_text_content'); $mailLayout = $this->layoutsRepository->find($_POST['mail_layout_id']); $lockedMailLayout = $this->layoutsRepository->find($_POST['locked_mail_layout_id']); $mailType = $this->listsRepository->find($_POST['mail_type_id']); $generate = function ($htmlContent, $textContent, $mailLayout, $mailType) use ($request) { $mailTemplate = $this->activeRowFactory->create([ 'name' => $request->getPost('name'), 'code' => 'tmp_' . microtime(true), 'description' => '', 'from' => $request->getPost('from'), 'autologin' => true, 'subject' => $request->getPost('subject'), 'mail_body_text' => $textContent, 'mail_body_html' => $htmlContent, 'mail_layout_id' => $mailLayout->id, 'mail_layout' => $mailLayout, 'mail_type_id' => $request->getPost('mail_type_id'), 'mail_type' => $mailType, 'params' => null, 'click_tracking' => false, ]); return $this->contentGenerator->render($this->generatorInputFactory->create($mailTemplate)); }; $mailContent = $generate($htmlContent, $textContent, $mailLayout, $mailType); $this->template->generatedHtml = $mailContent->html(); $this->template->generatedText = $mailContent->text(); $lockedMailContent = $generate($lockedHtmlContent, $lockedTextContent, $lockedMailLayout, $mailType); $this->template->generatedLockedHtml = $lockedMailContent->html(); $this->template->generatedLockedText = $lockedMailContent->text(); // Store data in session for full-screen preview $sessionSection = $this->session->getSection(MailGeneratorPresenter::SESSION_SECTION_CONTENT_PREVIEW); $sessionSection->generatedHtml = $mailContent->html(); $sessionSection->generatedLockedHtml = $lockedMailContent->html(); $response = new JsonResponse([ 'generatedHtml' => $mailContent->html(), 'generatedText' => $mailContent->text(), 'generatedLockedHtml' => $lockedMailContent->html(), 'generatedLockedText' => $lockedMailContent->text(), ]); $this->getPresenter()->sendResponse($response); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Components/GeneratorWidgets/Widgets/NovydenikNewsfilterWidget/NovydenikNewsfilterWidget.php
Mailer/app/Components/GeneratorWidgets/Widgets/NovydenikNewsfilterWidget/NovydenikNewsfilterWidget.php
<?php declare(strict_types=1); namespace Remp\Mailer\Components\GeneratorWidgets\Widgets\NovydenikNewsfilterWidget; use Nette\Application\Responses\JsonResponse; use Nette\Application\UI\Form; use Nette\Http\Session; use Remp\Mailer\Forms\NovydenikNewsfilterTemplateFormFactory; use Remp\MailerModule\Components\BaseControl; use Remp\MailerModule\Components\GeneratorWidgets\Widgets\IGeneratorWidget; use Remp\MailerModule\Models\ContentGenerator\ContentGenerator; use Remp\MailerModule\Models\ContentGenerator\GeneratorInputFactory; use Remp\MailerModule\Presenters\MailGeneratorPresenter; use Remp\MailerModule\Repositories\ActiveRowFactory; use Remp\MailerModule\Repositories\LayoutsRepository; use Remp\MailerModule\Repositories\ListsRepository; class NovydenikNewsfilterWidget extends BaseControl implements IGeneratorWidget { private string $templateName = 'novydenik_newsfilter_widget.latte'; public function __construct( private Session $session, private LayoutsRepository $layoutsRepository, private ListsRepository $listsRepository, private ContentGenerator $contentGenerator, private NovydenikNewsfilterTemplateFormFactory $newsfilterTemplateFormFactory, private GeneratorInputFactory $generatorInputFactory, private ActiveRowFactory $activeRowFactory, ) { } public function identifier(): string { return "novydeniknewsfilterwidget"; } public function render($params): void { if (!isset($params['addonParams'])) { return; } foreach ($params['addonParams'] as $var => $param) { $this->template->$var = $param; } $this->template->htmlContent = $params['htmlContent']; $this->template->textContent = $params['textContent']; $this->template->setFile(__DIR__ . '/' . $this->templateName); $this->template->render(); } public function createComponentNewsfilterTemplateForm(): Form { $form = $this->newsfilterTemplateFormFactory->create(); $this->newsfilterTemplateFormFactory->onSave = function () { $this->getPresenter()->flashMessage("Newsfilter batches were created and run."); $this->getPresenter()->redirect("Job:Default"); }; return $form; } public function handleNewsfilterPreview(): void { $request = $this->getPresenter()->getRequest(); $htmlContent = $request->getPost('html_content'); $textContent = $request->getPost('text_content'); $lockedHtmlContent = $request->getPost('locked_html_content'); $lockedTextContent = $request->getPost('locked_text_content'); $mailLayout = $this->layoutsRepository->find($_POST['mail_layout_id']); $lockedMailLayout = $this->layoutsRepository->find($_POST['locked_mail_layout_id']); $mailType = $this->listsRepository->find($_POST['mail_type_id']); $generate = function ($htmlContent, $textContent, $mailLayout, $mailType) use ($request) { $mailTemplate = $this->activeRowFactory->create([ 'name' => $request->getPost('name'), 'code' => 'tmp_' . microtime(true), 'description' => '', 'from' => $request->getPost('from'), 'autologin' => true, 'subject' => $request->getPost('subject'), 'mail_body_text' => $textContent, 'mail_body_html' => $htmlContent, 'mail_layout_id' => $mailLayout->id, 'mail_layout' => $mailLayout, 'mail_type_id' => $request->getPost('mail_type_id'), 'mail_type' => $mailType, 'params' => null, 'click_tracking' => false, ]); return $this->contentGenerator->render($this->generatorInputFactory->create($mailTemplate)); }; $mailContent = $generate($htmlContent, $textContent, $mailLayout, $mailType); $this->template->generatedHtml = $mailContent->html(); $this->template->generatedText = $mailContent->text(); $lockedMailContent = $generate($lockedHtmlContent, $lockedTextContent, $lockedMailLayout, $mailType); $this->template->generatedLockedHtml = $lockedMailContent->html(); $this->template->generatedLockedText = $lockedMailContent->text(); // Store data in session for full-screen preview $sessionSection = $this->session->getSection(MailGeneratorPresenter::SESSION_SECTION_CONTENT_PREVIEW); $sessionSection->generatedHtml = $mailContent->html(); $sessionSection->generatedLockedHtml = $lockedMailContent->html(); $response = new JsonResponse([ 'generatedHtml' => $mailContent->html(), 'generatedText' => $mailContent->text(), 'generatedLockedHtml' => $lockedMailContent->html(), 'generatedLockedText' => $lockedMailContent->text(), ]); $this->getPresenter()->sendResponse($response); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Hermes/MailgunBotTrackerHandler.php
Mailer/app/Hermes/MailgunBotTrackerHandler.php
<?php declare(strict_types=1); namespace Remp\Mailer\Hermes; use Remp\MailerModule\Hermes\HermesException; use Remp\MailerModule\Models\RedisClientFactory; use Remp\MailerModule\Models\RedisClientTrait; use Tomaj\Hermes\Handler\HandlerInterface; use Tomaj\Hermes\MessageInterface; class MailgunBotTrackerHandler implements HandlerInterface { private const APPLE_BOT_EMAILS = 'apple_bot_emails'; use RedisClientTrait; public function __construct(protected RedisClientFactory $redisClientFactory) { } public function handle(MessageInterface $message): bool { $payload = $message->getPayload(); if (!isset($payload['mail_sender_id'])) { // email sent via mailgun and not sent via mailer (e.g. CMS) return true; } if (!isset($payload['event'])) { throw new HermesException('unable to handle event: event is missing'); } if ($payload['event'] !== "opened") { return true; } if (isset($payload['client']['bot']) && $payload['client']['bot'] === "apple") { $redis = $this->redisClientFactory->getClient(); $redis->sadd(self::APPLE_BOT_EMAILS, [$payload['email']]); } return true; } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Hermes/BatchSendingFinishedSlackHandler.php
Mailer/app/Hermes/BatchSendingFinishedSlackHandler.php
<?php declare(strict_types=1); namespace Remp\Mailer\Hermes; use GuzzleHttp\Client; use GuzzleHttp\Exception\ClientException; use Nette\Application\LinkGenerator; use Nette\Database\Table\ActiveRow; use Remp\MailerModule\Repositories\BatchesRepository; use Tomaj\Hermes\Handler\HandlerInterface; use Tomaj\Hermes\Handler\RetryTrait; use Tomaj\Hermes\MessageInterface; use Tracy\Debugger; class BatchSendingFinishedSlackHandler implements HandlerInterface { use RetryTrait; private $ignoredCategories = []; public function __construct( protected readonly string $mailerBaseUrl, protected readonly string $environment, protected readonly string $slackWebhookUrl, protected readonly BatchesRepository $batchesRepository, protected LinkGenerator $linkGenerator, ) { $this->linkGenerator = $this->linkGenerator->withReferenceUrl($this->mailerBaseUrl); } public function ignoreMailTypeCategory(string $categoryCode): void { $this->ignoredCategories[$categoryCode] = true; } public function handle(MessageInterface $message): bool { $payload = $message->getPayload(); $status = $payload['status']; if ($status !== BatchesRepository::STATUS_DONE) { return true; } $batchId = $payload['mail_job_batch_id']; $jobBatch = $this->batchesRepository->find($batchId); if (!$jobBatch) { return false; } $mailTemplate = $jobBatch->related('mail_job_batch_templates')->limit(1)->fetch(); $mailType = $mailTemplate->mail_template->mail_type; if (array_key_exists($mailType->mail_type_category->code, $this->ignoredCategories)) { return true; } $this->sendSlackNotification($jobBatch, $mailType); return true; } protected function sendSlackNotification(ActiveRow $jobBatch, ActiveRow $mailType): void { $targetUrl = $this->linkGenerator->link(':Mailer:Job:Show', ['id' => $jobBatch->mail_job_id]); $durationDiff = $jobBatch->last_email_sent_at->diff($jobBatch->first_email_sent_at); $duration = "{$durationDiff->s}s"; if ($durationDiff->i) { $duration = "{$durationDiff->i}m $duration"; } if ($durationDiff->h) { $duration = "{$durationDiff->h}h $duration"; } // https://docs.slack.dev/block-kit/formatting-with-rich-text $payload = [ 'blocks' => [ [ 'type' => 'rich_text', 'elements' => [ [ 'type' => 'rich_text_section', 'elements' => [ [ 'type' => 'text', 'text' => $this->environment, 'style' => [ 'bold' => true, ], ], ], ], [ 'type' => 'rich_text_section', 'elements' => [ [ 'type' => 'text', 'text' => 'Newsletter ', ], [ 'type' => 'text', 'text' => $mailType->title, 'style' => [ 'italic' => true, ], ], [ 'type' => 'text', 'text' => " was just sent in {$duration} (", ], [ 'type' => 'link', 'text' => "{$jobBatch->sent_emails} emails sent", 'url' => $targetUrl, ], [ 'type' => 'text', 'text' => ").", ], ], ], ], ], ], ]; try { $client = new Client(); $client->post($this->slackWebhookUrl, [ 'json' => $payload, 'headers' => [ 'Content-Type' => 'application/json', ], ]); } catch (ClientException $e) { Debugger::log('Unable to post Slack notification: ' . $e->getResponse()->getBody()->getContents(), Debugger::ERROR); } } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Models/WebClient.php
Mailer/app/Models/WebClient.php
<?php namespace Remp\Mailer\Models; use Exception; use GuzzleHttp\Client as GuzzleClient; use GuzzleHttp\Exception\ClientException; use Nette\Utils\DateTime; use Nette\Utils\Json; class WebClient { private $client; public function __construct(string $baseUrl) { $this->client = new GuzzleClient([ 'base_uri' => $baseUrl, ]); } public function getEconomyPostsLast24Hours() { $now = new DateTime(); $yesterday = (clone $now)->modify("-1 day"); try { $response = $this->client->get('api/v2/reader/posts', [ 'query' => [ 'category' => 'ekonomika', 'datetime_after' => $yesterday, 'datetime_before' => $now, ], ]); return Json::decode($response->getBody()->getContents(), Json::FORCE_ARRAY); } catch (ClientException $clientException) { throw new Exception("unable to get economy posts: {$clientException->getMessage()}"); } } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Models/ContentGenerator/Respekt/Replace/TextUrlUtmReplace.php
Mailer/app/Models/ContentGenerator/Respekt/Replace/TextUrlUtmReplace.php
<?php declare(strict_types=1); namespace Remp\Mailer\Models\ContentGenerator\Respekt\Replace; use Remp\MailerModule\Models\ContentGenerator\Replace\IReplace; use Remp\MailerModule\Models\ContentGenerator\Replace\TextUrlRtmReplace; class TextUrlUtmReplace extends TextUrlRtmReplace implements IReplace { use UtmReplaceTrait; }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Models/ContentGenerator/Respekt/Replace/AnchorUtmReplace.php
Mailer/app/Models/ContentGenerator/Respekt/Replace/AnchorUtmReplace.php
<?php declare(strict_types=1); namespace Remp\Mailer\Models\ContentGenerator\Respekt\Replace; use Remp\MailerModule\Models\ContentGenerator\Replace\AnchorRtmReplace; use Remp\MailerModule\Models\ContentGenerator\Replace\IReplace; class AnchorUtmReplace extends AnchorRtmReplace implements IReplace { use UtmReplaceTrait; }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Models/ContentGenerator/Respekt/Replace/UtmReplaceTrait.php
Mailer/app/Models/ContentGenerator/Respekt/Replace/UtmReplaceTrait.php
<?php declare(strict_types=1); namespace Remp\Mailer\Models\ContentGenerator\Respekt\Replace; use Remp\MailerModule\Models\ContentGenerator\GeneratorInput; trait UtmReplaceTrait { /** * Put UTM parameters into URL parameters * Function also respects MailGun Variables (e.g. %recipient.autologin%) * * @param string $hrefUrl * * @param GeneratorInput $generatorInput * @return string */ public function replaceUrl(string $hrefUrl, GeneratorInput $generatorInput): string { $utmSource = $generatorInput->template()->mail_type->code; // !! could be maybe performance issue? $utmMedium = 'email'; $utmCampaign = $generatorInput->template()->code; $utmContent = $generatorInput->batchId(); $matches = []; // Split URL between path and params (before and after '?') preg_match('/^([^?]*)\??(.*)$/', $hrefUrl, $matches); $path = $matches[1]; $params = explode('&', $matches[2] ?? ''); $finalParams = []; $rtmSourceAdded = $rtmMediumAdded = $rtmCampaignAdded = $rtmContentAdded = false; foreach ($params as $param) { if (empty($param)) { continue; } $items = explode('=', $param, 2); if (isset($items[1])) { $key = $items[0]; $value = $items[1]; if (strcasecmp($key, 'utm_source') === 0) { $finalParams[] = "$key={$utmSource}"; $rtmSourceAdded = true; } elseif (strcasecmp($key, 'utm_medium') === 0) { $finalParams[] = "$key={$utmMedium}"; $rtmMediumAdded = true; } elseif (strcasecmp($key, 'utm_campaign') === 0) { $finalParams[] = "$key={$utmCampaign}"; $rtmCampaignAdded = true; } elseif (strcasecmp($key, 'utm_content') === 0) { $finalParams[] = "$key={$utmContent}"; $rtmContentAdded = true; } else { $finalParams[] = "$key=" . $value; } } else { $finalParams[] = $param; } } if (!$rtmSourceAdded) { $finalParams[] = "utm_source={$utmSource}"; } if (!$rtmMediumAdded) { $finalParams[] = "utm_medium={$utmMedium}"; } if (!$rtmCampaignAdded) { $finalParams[] = "utm_campaign={$utmCampaign}"; } if (!$rtmContentAdded) { $finalParams[] = "utm_content={$utmContent}"; } return $path . '?' . implode('&', $finalParams); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Models/ContentGenerator/Respekt/Replace/UrlUtmReplace.php
Mailer/app/Models/ContentGenerator/Respekt/Replace/UrlUtmReplace.php
<?php declare(strict_types=1); namespace Remp\Mailer\Models\ContentGenerator\Respekt\Replace; use Remp\MailerModule\Models\ContentGenerator\Replace\IReplace; use Remp\MailerModule\Models\ContentGenerator\Replace\UrlRtmReplace; class UrlUtmReplace extends UrlRtmReplace implements IReplace { use UtmReplaceTrait; }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Models/Generators/MinutaAlertGenerator.php
Mailer/app/Models/Generators/MinutaAlertGenerator.php
<?php declare(strict_types=1); namespace Remp\Mailer\Models\Generators; use Nette\Application\UI\Form; use Nette\Utils\ArrayHash; use Remp\MailerModule\Models\ContentGenerator\Engine\EngineFactory; use Remp\MailerModule\Models\Generators\IGenerator; use Remp\MailerModule\Models\Generators\InvalidUrlException; use Remp\MailerModule\Models\PageMeta\Content\ContentInterface; use Remp\MailerModule\Models\PageMeta\Transport\TransportInterface; use Remp\MailerModule\Repositories\SourceTemplatesRepository; use Tomaj\NetteApi\Params\PostInputParam; class MinutaAlertGenerator implements IGenerator { protected $sourceTemplatesRepository; protected $content; private $engineFactory; public $onSubmit; private $transport; public function __construct( SourceTemplatesRepository $sourceTemplatesRepository, TransportInterface $transporter, ContentInterface $content, EngineFactory $engineFactory ) { $this->sourceTemplatesRepository = $sourceTemplatesRepository; $this->transport = $transporter; $this->content = $content; $this->engineFactory = $engineFactory; } public function generateForm(Form $form): void { $form->addText('post', 'Url of post'); $form->onSuccess[] = [$this, 'formSucceeded']; } public function apiParams(): array { return [ (new PostInputParam('post'))->setRequired(), ]; } public function onSubmit(callable $onSubmit): void { $this->onSubmit = $onSubmit; } public function formSucceeded(Form $form, ArrayHash $values): void { try { $output = $this->process((array) $values); $this->onSubmit->__invoke($output['htmlContent'], $output['textContent']); } catch (InvalidUrlException $e) { $form->addError($e->getMessage()); } } public function getWidgets(): array { return []; } public function process(array $values): array { $sourceTemplate = $this->sourceTemplatesRepository->find($values['source_template_id']); $post = $this->content->fetchUrlMeta($values['post']); $params = [ 'post' => $post, ]; $engine = $this->engineFactory->engine(); return [ 'htmlContent' => $engine->render($sourceTemplate->content_html, $params), 'textContent' => strip_tags($engine->render($sourceTemplate->content_text, $params)), ]; } public function preprocessParameters($data): ?ArrayHash { return null; } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Models/Generators/MMSGenerator.php
Mailer/app/Models/Generators/MMSGenerator.php
<?php declare(strict_types=1); namespace Remp\Mailer\Models\Generators; use Nette\Application\UI\Form; use Nette\Utils\ArrayHash; use Remp\Mailer\Components\GeneratorWidgets\Widgets\MMSWidget\MMSWidget; use Remp\MailerModule\Models\ContentGenerator\Engine\EngineFactory; use Remp\MailerModule\Models\Generators\HtmlArticleLocker; use Remp\MailerModule\Models\Generators\EmbedParser; use Remp\MailerModule\Models\Generators\IGenerator; use Remp\MailerModule\Models\Generators\PreprocessException; use Remp\MailerModule\Models\Generators\WordpressHelpers; use Remp\MailerModule\Models\PageMeta\Content\ContentInterface; use Remp\MailerModule\Repositories\SourceTemplatesRepository; use Tomaj\NetteApi\Params\PostInputParam; class MMSGenerator implements IGenerator { use RulesTrait, TemplatesTrait; public $onSubmit; private $mailSourceTemplateRepository; private $helpers; private $content; private $embedParser; private $articleLocker; private $engineFactory; public function __construct( SourceTemplatesRepository $mailSourceTemplateRepository, WordpressHelpers $helpers, ContentInterface $content, EmbedParser $embedParser, HtmlArticleLocker $articleLocker, EngineFactory $engineFactory ) { $this->mailSourceTemplateRepository = $mailSourceTemplateRepository; $this->helpers = $helpers; $this->content = $content; $this->embedParser = $embedParser; $this->articleLocker = $articleLocker; $this->engineFactory = $engineFactory; } public function apiParams(): array { return [ (new PostInputParam('mms_html'))->setRequired(), (new PostInputParam('url'))->setRequired(), (new PostInputParam('title'))->setRequired(), (new PostInputParam('sub_title')), (new PostInputParam('image_url')), (new PostInputParam('image_title')), (new PostInputParam('from'))->setRequired(), ]; } public function getWidgets(): array { return [MMSWidget::class]; } public function process(array $values): array { $sourceTemplate = $this->mailSourceTemplateRepository->find($values['source_template_id']); $post = $values['mms_html']; $lockedPost = $this->articleLocker->getLockedPost($post); $generatorRules = [ '/<span.*?>(.*?)<\/span>/is' => "$1", '/<p.*?>(.*?)<\/p>/is' => "<p style=\"color:#181818;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight:normal;padding:0;margin:0 0 26px 0;text-align:left;font-size:18px;line-height:160%;\">$1</p>", ]; $rules = $this->getRules($generatorRules); foreach ($rules as $rule => $replace) { if (is_array($replace) || is_callable($replace)) { $post = preg_replace_callback($rule, $replace, $post); $lockedPost = preg_replace_callback($rule, $replace, $lockedPost); } else { $post = preg_replace($rule, $replace, $post); $lockedPost = preg_replace($rule, $replace, $lockedPost); } } // wrap text in paragraphs $post = $this->helpers->wpautop($post); $lockedPost = $this->helpers->wpautop($lockedPost); // parse article links $post = $this->helpers->wpParseArticleLinks($post, 'https://dennikn.sk/', $this->getArticleLinkTemplateFunction()); $lockedPost = $this->helpers->wpParseArticleLinks($lockedPost, 'https://dennikn.sk/', $this->getArticleLinkTemplateFunction()); // fix pees [$post, $lockedPost] = preg_replace('/<p>/is', "<p style=\"color:#181818;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight:normal;padding:0;margin:0 0 26px 0;text-align:left;font-size:18px;line-height:160%;\">", [$post, $lockedPost]); $imageHtml = ''; [$captionTemplate,,,,,$imageTemplate] = $this->getTemplates(); if (isset($values['image_title']) && isset($values['image_url'])) { $imageHtml = str_replace('$1', $values['image_url'], $captionTemplate); $imageHtml = str_replace('$2', $values['image_title'], $imageHtml); } elseif (isset($values['image_url'])) { $imageHtml = str_replace('$1', $values['image_url'], $imageTemplate); } $post = $imageHtml . $post; $lockedPost = $imageHtml . $lockedPost; $lockedPost = $this->articleLocker->injectLockedMessage($lockedPost); $text = str_replace("<br />", "\r\n", $post); $lockedText = str_replace("<br />", "\r\n", $lockedPost); $text = strip_tags($text); $lockedText = strip_tags($lockedText); $text = preg_replace('/(\r\n|\r|\n)+/', "\n", $text); $lockedText = preg_replace('/(\r\n|\r|\n)+/', "\n", $lockedText); $params = [ 'title' => $values['title'], 'sub_title' => $values['sub_title'], 'url' => $values['url'], 'html' => $post, 'text' => $text, ]; $lockedParams = [ 'title' => $values['title'], 'sub_title' => $values['sub_title'], 'url' => $values['url'], 'html' => $lockedPost, 'text' => strip_tags($lockedText), ]; $engine = $this->engineFactory->engine(); return [ 'htmlContent' => $engine->render($sourceTemplate->content_html, $params), 'textContent' => strip_tags($engine->render($sourceTemplate->content_text, $params)), 'lockedHtmlContent' => $engine->render($sourceTemplate->content_html, $lockedParams), 'lockedTextContent' => strip_tags($engine->render($sourceTemplate->content_text, $lockedParams)), ]; } public function formSucceeded(Form $form, ArrayHash $values): void { $output = $this->process((array)$values); $addonParams = [ 'lockedHtmlContent' => $output['lockedHtmlContent'], 'lockedTextContent' => $output['lockedTextContent'], 'mmsTitle' => $values->title, 'from' => $values->from, 'render' => true, 'articleId' => $values->article_id, ]; $this->onSubmit->__invoke($output['htmlContent'], $output['textContent'], $addonParams); } public function generateForm(Form $form): void { // disable CSRF protection as external sources could post the params here $form->offsetUnset(Form::PROTECTOR_ID); $form->addText('title', 'Title') ->setRequired("Field 'Title' is required."); $form->offsetUnset(Form::PROTECTOR_ID); $form->addText('sub_title', 'Sub title'); $form->addText('from', 'Sender'); $form->addText('url', 'Odkaz MMS URL') ->addRule(Form::URL) ->setRequired("Field 'Odkaz MMS URL' is required."); $form->addTextArea('mms_html', 'HTML') ->setHtmlAttribute('rows', 20) ->setHtmlAttribute('class', 'form-control html-editor') ->getControlPrototype(); $form->addHidden('article_id'); $form->addSubmit('send') ->getControlPrototype() ->setName('button') ->setHtml('<i class="fa fa-magic"></i> ' . 'Generate'); $form->onSuccess[] = [$this, 'formSucceeded']; } public function onSubmit(callable $onSubmit): void { $this->onSubmit = $onSubmit; } /** * @param \stdClass $data containing WP article data * @return ArrayHash with data to fill the form with */ public function preprocessParameters($data): ?ArrayHash { $output = new ArrayHash(); if (!isset($data->post_authors[0]->display_name)) { throw new PreprocessException("WP json object does not contain required attribute 'post_authors.0.display_name'"); } if (isset($data->sender_email) && $data->sender_email) { $output->from = $data->sender_email; } else { $output->from = "Denník N <info@dennikn.sk>"; foreach ($data->post_authors as $author) { if ($author->user_email === "editori@dennikn.sk") { continue; } $output->from = $author->display_name . ' Denník N <' . $author->user_email . '>'; break; } } if (!isset($data->post_title)) { throw new PreprocessException("WP json object does not contain required attribute 'post_title'"); } $output->title = $data->post_title; if (!isset($data->post_url)) { throw new PreprocessException("WP json object does not contain required attribute 'post_url'"); } $output->url = $data->post_url; if (!isset($data->post_excerpt)) { throw new PreprocessException("WP json object does not contain required attribute 'post_excerpt'"); } $output->sub_title = $data->post_excerpt; if (isset($data->post_image->image_sizes->medium->file)) { $output->image_url = $data->post_image->image_sizes->medium->file; } if (isset($data->post_image->image_title)) { $output->image_title = $data->post_image->image_title; } if (!isset($data->post_content)) { throw new PreprocessException("WP json object does not contain required attribute 'post_content'"); } $output->mms_html = $data->post_content; $output->article_id = $data->ID; return $output; } public function getTemplates() { $captionTemplate = <<< HTML <img src="$1" alt="" style="outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;width:auto;max-width:100%;clear:both;display:block;margin-bottom:20px;"> <p style="margin:0 0 0 26px;Margin:0 0 0 26px;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;font-size:18px;line-height:1.6;margin-bottom:26px;Margin-bottom:26px;line-height:160%;text-align:left;font-weight:normal;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto;border-collapse:collapse !important;"> <small class="text-gray" style="font-size:13px;line-height:18px;display:block;color:#9B9B9B;">$2</small> </p> HTML; $captionWithLinkTemplate = <<< HTML <a href="$1" style="color:#181818;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight:normal;padding:0;margin:0;Margin:0;text-align:left;line-height:1.3;color:#1F3F83;text-decoration:none;"> <img src="$2" alt="" style="outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;width:auto;max-width:100%;clear:both;display:block;margin-bottom:20px;border:none;"> </a> <p style="margin:0 0 0 26px;Margin:0 0 0 26px;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;font-size:18px;line-height:1.6;margin-bottom:26px;Margin-bottom:26px;line-height:160%;text-align:left;font-weight:normal;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto;border-collapse:collapse !important;"> <small class="text-gray" style="font-size:13px;line-height:18px;display:block;color:#9B9B9B;">$3</small> </p> HTML; $liTemplate = <<< HTML <tr style="padding:0;vertical-align:top;text-align:left;"> <td class="bullet" style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;width:30px;border-collapse:collapse !important;">&#8226;</td> <td style="padding:0;vertical-align:top;text-align:left;font-size:18px;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;border-collapse:collapse !important;"> <p style="color:#181818;padding:0;margin:0 0 5px 0;font-size:18px;line-height:160%;text-align:left;font-weight:normal;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto;border-collapse:collapse !important;">$1</p> </td> </tr> HTML; $hrTemplate = <<< HTML <table cellspacing="0" cellpadding="0" border="0" width="100%" style="border-spacing:0;border-collapse:collapse;vertical-align:top;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;text-align:left;font-family:'Helvetica Neue', Helvetica, Arial;width:100%;min-width:100%;"> <tr style="padding:0;vertical-align:top;text-align:left;width:100%;min-width:100%;"> <td style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;border-collapse:collapse !important; padding: 30px 0 0 0; border-top:1px solid #E2E2E2;height:0;line-height: 0;width:100%;min-width:100%;">&#xA0;</td> </tr> </table> HTML; $spacerTemplate = <<< HTML <table class="spacer" style="border-spacing:0;border-collapse:collapse;vertical-align:top;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;text-align:left;font-family:'Helvetica Neue', Helvetica, Arial;width:100%;"> <tbody> <tr style="padding:0;vertical-align:top;text-align:left;"> <td height="20px" style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;mso-line-height-rule:exactly;border-collapse:collapse !important;font-size:20px;line-height:20px;">&#xA0;</td> </tr> </tbody> </table> HTML; $imageTemplate = <<< HTML <img src="$1" alt="" style="outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;width:auto;max-width:100%;clear:both;display:block;margin-bottom:20px;"> HTML; return [ $captionTemplate, $captionWithLinkTemplate, $liTemplate, $hrTemplate, $spacerTemplate, $imageTemplate, ]; } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Models/Generators/DennikNBestPerformingArticlesGenerator.php
Mailer/app/Models/Generators/DennikNBestPerformingArticlesGenerator.php
<?php declare(strict_types=1); namespace Remp\Mailer\Models\Generators; use Nette\Application\UI\Form; use Nette\Utils\ArrayHash; use Remp\MailerModule\Models\ContentGenerator\Engine\EngineFactory; use Remp\MailerModule\Models\Generators\IGenerator; use Remp\MailerModule\Models\PageMeta\Content\ContentInterface; use Remp\MailerModule\Repositories\SourceTemplatesRepository; use Tomaj\NetteApi\Params\PostInputParam; class DennikNBestPerformingArticlesGenerator implements IGenerator { protected $sourceTemplatesRepository; protected $content; private $engineFactory; public $onSubmit; public function __construct( SourceTemplatesRepository $sourceTemplatesRepository, ContentInterface $content, EngineFactory $engineFactory ) { $this->sourceTemplatesRepository = $sourceTemplatesRepository; $this->content = $content; $this->engineFactory = $engineFactory; } public function generateForm(Form $form): void { $form->addTextArea('articles', 'List of articles') ->setHtmlAttribute('rows', 4) ->setHtmlAttribute('class', 'form-control html-editor') ->setOption('description', 'Insert Url of every article - each on separate line'); $form->onSuccess[] = [$this, 'formSucceeded']; } public function onSubmit(callable $onSubmit): void { $this->onSubmit = $onSubmit; } public function getWidgets(): array { return []; } public function formSucceeded(Form $form, ArrayHash $values): void { $output = $this->process((array) $values); $this->onSubmit->__invoke($output['htmlContent'], $output['textContent']); } public function apiParams(): array { return [ (new PostInputParam('articles'))->setRequired(), ]; } public function process(array $values): array { $sourceTemplate = $this->sourceTemplatesRepository->find($values['source_template_id']); $items = []; $urls = explode("\n", trim($values['articles'])); foreach ($urls as $url) { $url = trim($url); $meta = $this->content->fetchUrlMeta($url); if ($meta) { $items[$url] = $meta; } } $params = [ 'items' => $items, ]; $engine = $this->engineFactory->engine(); return [ 'htmlContent' => $engine->render($sourceTemplate->content_html, $params), 'textContent' => strip_tags($engine->render($sourceTemplate->content_text, $params)), ]; } public function preprocessParameters($data): ?ArrayHash { return null; } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Models/Generators/DennikeGenerator.php
Mailer/app/Models/Generators/DennikeGenerator.php
<?php declare(strict_types=1); namespace Remp\Mailer\Models\Generators; use Nette\Application\UI\Form; use Nette\Utils\ArrayHash; use Remp\Mailer\Components\GeneratorWidgets\Widgets\DennikeWidget\DennikeWidget; use Remp\MailerModule\Models\ContentGenerator\Engine\EngineFactory; use Remp\MailerModule\Models\Generators\HtmlArticleLocker; use Remp\MailerModule\Models\Generators\EmbedParser; use Remp\MailerModule\Models\Generators\IGenerator; use Remp\MailerModule\Models\Generators\PreprocessException; use Remp\MailerModule\Models\Generators\WordpressHelpers; use Remp\MailerModule\Models\PageMeta\Content\ContentInterface; use Remp\MailerModule\Repositories\SourceTemplatesRepository; use GuzzleHttp\Client; use Tomaj\NetteApi\Params\PostInputParam; class DennikeGenerator implements IGenerator { use RulesTrait, TemplatesTrait; public $onSubmit; private $mailSourceTemplateRepository; private $helpers; private $content; private $linksColor = "#1F3F83"; private $embedParser; private $articleLocker; private $engineFactory; public function __construct( SourceTemplatesRepository $mailSourceTemplateRepository, WordpressHelpers $helpers, ContentInterface $content, EmbedParser $embedParser, HtmlArticleLocker $articleLocker, EngineFactory $engineFactory ) { $this->mailSourceTemplateRepository = $mailSourceTemplateRepository; $this->helpers = $helpers; $this->content = $content; $this->embedParser = $embedParser; $this->articleLocker = $articleLocker; $this->engineFactory = $engineFactory; } public function apiParams(): array { return [ (new PostInputParam('dennike_html'))->setRequired(), (new PostInputParam('url'))->setRequired(), (new PostInputParam('title'))->setRequired(), (new PostInputParam('sub_title')), (new PostInputParam('author')), (new PostInputParam('image_url')), (new PostInputParam('image_title')), (new PostInputParam('from'))->setRequired(), ]; } public function getWidgets(): array { return [DennikeWidget::class]; } public function process(array $values): array { $this->articleLocker->setLockText('Predplaťte si Denník E a tento newsletter dostanete každé ráno celý.'); $this->articleLocker->setupLockLink('Pridajte sa k predplatiteľom', 'https://predplatne.dennikn.sk/ecko'); $sourceTemplate = $this->mailSourceTemplateRepository->find($values['source_template_id']); $post = $values['dennike_html']; $lockedPost = $this->articleLocker->getLockedPost($post); $generatorRules = [ '/<ul.*?>/is' => '<table style="border-spacing:0;border-collapse:collapse;vertical-align:top;color:#181818;padding:0;line-height:1.3;text-align:left;font-family:\'Helvetica Neue\', Helvetica, Arial;width:100%;margin:0 0 26px 0;"><tbody>', '/<p.*?>(.*?)<\/p>/is' => "<p style=\"color:#181818;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight:normal;padding:0;margin:0 0 26px 0;text-align:left;font-size:18px;line-height:160%;\">$1</p>", ]; $rules = $this->getRules($generatorRules); foreach ($rules as $rule => $replace) { if (is_array($replace) || is_callable($replace)) { $post = preg_replace_callback($rule, $replace, $post); $lockedPost = preg_replace_callback($rule, $replace, $lockedPost); } else { $post = preg_replace($rule, $replace, $post); $lockedPost = preg_replace($rule, $replace, $lockedPost); } } // wrap text in paragraphs $post = $this->helpers->wpautop($post); $lockedPost = $this->helpers->wpautop($lockedPost); // parse article links $post = $this->helpers->wpParseArticleLinks($post, 'https://dennikn.sk/', $this->getArticleLinkTemplateFunction()); $lockedPost = $this->helpers->wpParseArticleLinks($lockedPost, 'https://dennikn.sk/', $this->getArticleLinkTemplateFunction()); // fix pees [$post, $lockedPost] = preg_replace('/<p>/is', "<p style=\"color:#181818;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight:normal;padding:0;margin:0 0 26px 0;text-align:left;font-size:18px;line-height:160%;\">", [$post, $lockedPost]); [$captionTemplate,,,,,$imageTemplate] = $this->getTemplates(); $imageHtml = ''; if (isset($values['image_title']) && isset($values['image_url'])) { $imageHtml = str_replace('$1', $values['image_url'], $captionTemplate); $imageHtml = str_replace('$2', $values['image_title'], $imageHtml); } elseif (isset($values['image_url'])) { $imageHtml = str_replace('$1', $values['image_url'], $imageTemplate); } $post = $imageHtml . $post; $lockedPost = $imageHtml . $lockedPost; $text = str_replace("<br />", "\r\n", $post); $lockedText = str_replace("<br />", "\r\n", $lockedPost); $lockedPost = $this->articleLocker->injectLockedMessage($lockedPost); $text = strip_tags($text); $lockedText = strip_tags($lockedText); $text = preg_replace('/(\r\n|\r|\n)+/', "\n", $text); $lockedText = preg_replace('/(\r\n|\r|\n)+/', "\n", $lockedText); $params = [ 'title' => $values['title'], 'sub_title' => $values['sub_title'], 'author' => $values['author'], 'url' => $values['url'], 'html' => $post, 'text' => $text, ]; $lockedParams = [ 'title' => $values['title'], 'sub_title' => $values['sub_title'], 'author' => $values['author'], 'url' => $values['url'], 'html' => $lockedPost, 'text' => strip_tags($lockedText), ]; $engine = $this->engineFactory->engine(); return [ 'htmlContent' => $engine->render($sourceTemplate->content_html, $params), 'textContent' => strip_tags($engine->render($sourceTemplate->content_text, $params)), 'lockedHtmlContent' => $engine->render($sourceTemplate->content_html, $lockedParams), 'lockedTextContent' => strip_tags($engine->render($sourceTemplate->content_text, $lockedParams)), ]; } public function formSucceeded(Form $form, ArrayHash $values): void { $output = $this->process((array) $values); $addonParams = [ 'lockedHtmlContent' => $output['lockedHtmlContent'], 'lockedTextContent' => $output['lockedTextContent'], 'dennikeTitle' => $values->title, 'from' => $values->from, 'render' => true, 'articleId' => $values->article_id, ]; $this->onSubmit->__invoke($output['htmlContent'], $output['textContent'], $addonParams); } public function generateForm(Form $form): void { // disable CSRF protection as external sources could post the params here $form->offsetUnset(Form::PROTECTOR_ID); $form->addText('title', 'Title') ->setRequired("Field 'Title' is required."); $form->offsetUnset(Form::PROTECTOR_ID); $form->addText('sub_title', 'Sub title'); $form->addText('author', 'Author'); $form->addText('from', 'Sender'); $form->addText('url', 'Dennik E URL') ->addRule(Form::URL) ->setRequired("Field 'Dennik E URL' is required."); $form->addTextArea('dennike_html', 'HTML') ->setHtmlAttribute('rows', 20) ->setHtmlAttribute('class', 'form-control html-editor') ->getControlPrototype(); $form->addHidden('article_id'); $form->addSubmit('send') ->getControlPrototype() ->setName('button') ->setHtml('<i class="fa fa-magic"></i> ' . 'Generate'); $form->onSuccess[] = [$this, 'formSucceeded']; } public function onSubmit(callable $onSubmit): void { $this->onSubmit = $onSubmit; } /** * @param \stdClass $data containing WP article data * @return ArrayHash with data to fill the form with */ public function preprocessParameters($data): ?ArrayHash { $output = new ArrayHash(); if (!isset($data->post_authors[0]->display_name)) { throw new PreprocessException("WP json object does not contain required attribute 'post_authors.0.display_name'"); } if (isset($data->sender_email) && $data->sender_email) { $output->from = $data->sender_email; } else { $output->from = "Denník N <info@dennikn.sk>"; foreach ($data->post_authors as $author) { if ($author->user_email === "editori@dennikn.sk") { continue; } $output->from = $author->display_name . ' <' . $author->user_email . '>'; break; } } if (!isset($data->post_title)) { throw new PreprocessException("WP json object does not contain required attribute 'post_title'"); } $output->title = $data->post_title; if (!isset($data->post_url)) { throw new PreprocessException("WP json object does not contain required attribute 'post_url'"); } $output->url = $data->post_url; if (!isset($data->post_excerpt)) { throw new PreprocessException("WP json object does not contain required attribute 'post_excerpt'"); } $output->sub_title = $data->post_excerpt; if (isset($data->post_image->image_sizes->medium->file)) { $output->image_url = $data->post_image->image_sizes->medium->file; } if (isset($data->post_image->image_title)) { $output->image_title = $data->post_image->image_title; } if (!isset($data->post_content)) { throw new PreprocessException("WP json object does not contain required attribute 'post_content'"); } $output->dennike_html = $data->post_content; $output->article_id = $data->ID; return $output; } public function parseEmbed(array $matches): string { $link = trim($matches[0]); if (preg_match('/youtu/', $link)) { $result = (new Client())->get('https://www.youtube.com/oembed?url=' . $link . '&format=json')->getBody()->getContents(); $result = json_decode($result); $thumbLink = $result->thumbnail_url; return "<br><a href=\"{$link}\" target=\"_blank\" style=\"color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;color:#1F3F83;text-decoration:underline;\"><img src=\"{$thumbLink}\" alt=\"\" style=\"outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;width:auto;max-width:100%;clear:both;display:block;margin-bottom:20px;\"></a><br><br>" . PHP_EOL; } return "<a href=\"{$link}\" target=\"_blank\" style=\"color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;color:#1F3F83;text-decoration:underline;\">$link</a><br><br>"; } public function getTemplates(): array { $captionTemplate = <<< HTML <img src="$1" alt="" style="outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;width:auto;max-width:100%;clear:both;display:block;margin-bottom:20px;"><p style="margin:0 0 0 26px;Margin:0 0 0 26px;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;font-size:18px;line-height:1.6;margin-bottom:26px;Margin-bottom:26px;line-height:160%;text-align:left;font-weight:normal;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto;border-collapse:collapse !important;"><small class="text-gray" style="font-size:13px;line-height:18px;display:block;color:#9B9B9B;">$2</small></p> HTML; $captionWithLinkTemplate = <<< HTML <a href="$1" style="color:#181818;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight:normal;padding:0;margin:0;Margin:0;text-align:left;line-height:1.3;color:#1F3F83;text-decoration:none; margin-bottom: 0;"><img src="$2" alt="" style="outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;width:auto;max-width:100%;clear:both;display:block;margin-bottom:5px;border:none;"></a><p style="margin:0 0 0 26px;Margin:0 0 0 26px;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;font-size:18px;line-height:1.6;margin-bottom:15px;Margin-bottom:15px;line-height:160%;text-align:left;font-weight:normal;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto;border-collapse:collapse !important;"><small class="text-gray" style="font-size:13px;line-height:18px;display:block;color:#9B9B9B;">$3</small></p> HTML; $liTemplate = <<< HTML <tr style="padding:0;vertical-align:top;text-align:left;"> <td class="bullet" style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;width:30px;border-collapse:collapse !important;">&#8226;</td> <td style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;border-collapse:collapse !important;"> <p style="margin:0 0 0 26px;Margin:0 0 0 26px;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;font-size:18px;line-height:1.6;margin-bottom:0px;Margin-bottom:0px;line-height:160%;text-align:left;font-weight:normal;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto;border-collapse:collapse !important; font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;">$1</p> </td> </tr> HTML; $hrTemplate = <<< HTML <table cellspacing="0" cellpadding="0" border="0" width="100%" style="border-spacing:0;border-collapse:collapse;vertical-align:top;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;text-align:left;font-family:'Helvetica Neue', Helvetica, Arial;width:100%;"> <tr style="padding:0;vertical-align:top;text-align:left;"> <td style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;border-collapse:collapse !important; padding: 20px 0 0 0; border-top:1px solid #E2E2E2;"></td> </tr> </table> HTML; $spacerTemplate = <<< HTML <table class="spacer" style="border-spacing:0;border-collapse:collapse;vertical-align:top;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;text-align:left;font-family:'Helvetica Neue', Helvetica, Arial;width:100%;"> <tbody> <tr style="padding:0;vertical-align:top;text-align:left;"> <td height="20px" style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;mso-line-height-rule:exactly;border-collapse:collapse !important;font-size:20px;line-height:20px;">&#xA0;</td> </tr> </tbody> </table> HTML; $imageTemplate = <<< HTML <img src="$1" alt="" style="outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;width:auto;max-width:100%;clear:both;display:block;margin-bottom:20px;border: 10px solid #1F3F83;"> HTML; return [ $captionTemplate, $captionWithLinkTemplate, $liTemplate, $hrTemplate, $spacerTemplate, $imageTemplate, ]; } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Models/Generators/RespektArticleGenerator.php
Mailer/app/Models/Generators/RespektArticleGenerator.php
<?php namespace Remp\Mailer\Models\Generators; use Nette\Application\UI\Form; use Nette\Utils\ArrayHash; use Remp\Mailer\Components\GeneratorWidgets\Widgets\RespektArticleParserWidget\RespektArticleParserWidget; use Remp\Mailer\Models\PageMeta\Content\RespektContent; use Remp\Mailer\Models\PageMeta\RespektMeta; use Remp\MailerModule\Models\ContentGenerator\Engine\EngineFactory; use Remp\MailerModule\Models\Generators\IGenerator; use Remp\MailerModule\Models\Generators\SnippetArticleLocker; use Remp\MailerModule\Models\PageMeta\Content\ContentInterface; use Remp\MailerModule\Models\PageMeta\Content\InvalidUrlException; use Remp\MailerModule\Repositories\SourceTemplatesRepository; use Tomaj\NetteApi\Params\PostInputParam; use Tracy\Debugger; use Tracy\ILogger; class RespektArticleGenerator implements IGenerator { public $onSubmit; public function __construct( private readonly ContentInterface $content, private readonly SourceTemplatesRepository $sourceTemplatesRepository, private readonly EngineFactory $engineFactory, private readonly SnippetArticleLocker $snippetArticleLocker, ) { } public function generateForm(Form $form): void { $form->addText('article', 'Article') ->setOption('description', 'Paste article URL.') ->setRequired() ->getControlPrototype() ->setHtmlAttribute('class', 'form-control html-editor'); $form->addText('author_name', 'Author') ->setOption('description', 'Author name for use in notification email.'); $form->onSuccess[] = [$this, 'formSucceeded']; } public function onSubmit(callable $onSubmit): void { $this->onSubmit = $onSubmit; } public function formSucceeded(Form $form, ArrayHash $values): void { if (!$this->content instanceof RespektContent) { Debugger::log(self::class . ' depends on ' . RespektContent::class . '.', ILogger::ERROR); $sourceTemplate = null; if (isset($values['source_template_id'])) { $sourceTemplate = $this->sourceTemplatesRepository->find($values['source_template_id']); } $form->addError(sprintf( "Mail generator [%s] is not configured correctly. Contact developers.", $sourceTemplate->title ?? '', )); return; } try { $output = $this->process((array) $values); $addonParams = [ 'render' => true, 'errors' => $output['errors'], 'lockedHtmlContent' => $output['lockedHtmlContent'], 'lockedTextContent' => $output['lockedTextContent'], 'subject' => $output['subject'], ]; $this->onSubmit->__invoke($output['htmlContent'], $output['textContent'], $addonParams); } catch (InvalidUrlException $e) { $form->addError($e->getMessage()); } } public function apiParams(): array { return [ (new PostInputParam('article'))->setRequired(), (new PostInputParam('author_name')), ]; } public function process(array $values): array { $sourceTemplate = $this->sourceTemplatesRepository->find($values['source_template_id']); $errors = []; $url = trim($values['article']); try { /** @var RespektMeta $article */ $article = $this->content->fetchUrlMeta($url); if (!$article) { $errors[] = $url; } } catch (InvalidUrlException $e) { $errors[] = $url; } $params = [ 'article' => $article ?? null, 'url' => $url, 'author_name' => $values['author_name'] ?? null, ]; $lockedParams = $params; if (isset($article)) { $unlockedContent = $article->unlockedContent . " " . SnippetArticleLocker::LOCKED_TEXT_PLACEHOLDER; $unlockedContent = $this->snippetArticleLocker->injectLockedMessage($unlockedContent); $lockedArticle = new RespektMeta( title: $article->getTitle(), image: $article->getImage(), authors: $article->getAuthors(), type: $article->type, subtitle: $article->subtitle, firstParagraph: $article->firstParagraph, firstContentPartType: $article->firstContentPartType, fullContent:$unlockedContent, imageTitle: $article->imageTitle, subject: $article->subject, ); $lockedParams['article'] = $lockedArticle; } $engine = $this->engineFactory->engine(); return [ 'htmlContent' => $engine->render($sourceTemplate->content_html, $params), 'textContent' => strip_tags($engine->render($sourceTemplate->content_text, $params)), 'lockedHtmlContent' => $engine->render($sourceTemplate->content_html, $lockedParams), 'lockedTextContent' => strip_tags($engine->render($sourceTemplate->content_text, $lockedParams)), 'errors' => $errors, 'subject' => $article->subject ?? null, ]; } public function getWidgets(): array { return [RespektArticleParserWidget::class]; } public function preprocessParameters($data): ?ArrayHash { return null; } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Models/Generators/TldrGenerator.php
Mailer/app/Models/Generators/TldrGenerator.php
<?php declare(strict_types=1); namespace Remp\Mailer\Models\Generators; use Nette\Application\UI\Form; use Nette\Utils\ArrayHash; use Remp\Mailer\Components\GeneratorWidgets\Widgets\TldrWidget\TldrWidget; use Remp\MailerModule\Models\ContentGenerator\Engine\EngineFactory; use Remp\MailerModule\Models\Generators\HtmlArticleLocker; use Remp\MailerModule\Models\Generators\EmbedParser; use Remp\MailerModule\Models\Generators\IGenerator; use Remp\MailerModule\Models\Generators\PreprocessException; use Remp\MailerModule\Models\Generators\WordpressHelpers; use Remp\MailerModule\Models\PageMeta\Content\ContentInterface; use Remp\MailerModule\Repositories\SourceTemplatesRepository; use Tomaj\NetteApi\Params\PostInputParam; class TldrGenerator implements IGenerator { use RulesTrait, TemplatesTrait; public $onSubmit; private $mailSourceTemplateRepository; private $helpers; private $content; private $embedParser; private $articleLocker; private $engineFactory; public function __construct( SourceTemplatesRepository $mailSourceTemplateRepository, WordpressHelpers $helpers, ContentInterface $content, EmbedParser $embedParser, HtmlArticleLocker $articleLocker, EngineFactory $engineFactory ) { $this->mailSourceTemplateRepository = $mailSourceTemplateRepository; $this->helpers = $helpers; $this->content = $content; $this->embedParser = $embedParser; $this->articleLocker = $articleLocker; $this->engineFactory = $engineFactory; } public function apiParams(): array { return [ (new PostInputParam('tldr_html'))->setRequired(), (new PostInputParam('url'))->setRequired(), (new PostInputParam('title'))->setRequired(), (new PostInputParam('sub_title'))->setRequired(), (new PostInputParam('image_url'))->setRequired(), (new PostInputParam('image_title'))->setRequired(), (new PostInputParam('from'))->setRequired(), ]; } public function getWidgets(): array { return [TldrWidget::class]; } public function process(array $values): array { $sourceTemplate = $this->mailSourceTemplateRepository->find($values['source_template_id']); $post = $values['tldr_html']; $post = $this->parseOls($post); $lockedPost = $this->articleLocker->getLockedPost($post); $generatorRules = [ '/<p.*?>(.*?)<\/p>/is' => "<p style=\"color:#181818;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight:normal;padding:0;margin:0 0 26px 0;text-align:left;font-size:18px;line-height:160%;\">$1</p>", ]; $rules = $this->getRules($generatorRules); foreach ($rules as $rule => $replace) { if (is_array($replace) || is_callable($replace)) { $post = preg_replace_callback($rule, $replace, $post); $lockedPost = preg_replace_callback($rule, $replace, $lockedPost); } else { $post = preg_replace($rule, $replace, $post); $lockedPost = preg_replace($rule, $replace, $lockedPost); } } // wrap text in paragraphs $post = $this->helpers->wpautop($post); $lockedPost = $this->helpers->wpautop($lockedPost); // parse article links $post = $this->helpers->wpParseArticleLinks($post, 'https://dennikn.sk/', $this->getArticleLinkTemplateFunction()); $lockedPost = $this->helpers->wpParseArticleLinks($lockedPost, 'https://dennikn.sk/', $this->getArticleLinkTemplateFunction()); // fix pees [$post, $lockedPost] = preg_replace('/<p>/is', "<p style=\"color:#181818;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight:normal;padding:0;margin:0 0 26px 0;text-align:left;font-size:18px;line-height:160%;\">", [$post, $lockedPost]); [$captionTemplate,,,,,$imageTemplate] = $this->getTemplates(); $imageHtml = ''; if (isset($values['image_title']) && isset($values['image_url'])) { $imageHtml = str_replace('$1', $values['image_url'], $captionTemplate); $imageHtml = str_replace('$2', $values['image_title'], $imageHtml); } elseif (isset($values['image_url'])) { $imageHtml = str_replace('$1', $values['image_url'], $imageTemplate); } $post = $imageHtml . $post; $lockedPost = $imageHtml . $lockedPost; $lockedPost = $this->articleLocker->injectLockedMessage($lockedPost); $text = str_replace("<br />", "\r\n", $post); $lockedText = str_replace("<br />", "\r\n", $lockedPost); $text = strip_tags($text); $lockedText = strip_tags($lockedText); $text = preg_replace('/(\r\n|\r|\n)+/', "\n", $text); $lockedText = preg_replace('/(\r\n|\r|\n)+/', "\n", $lockedText); $params = [ 'title' => $values['title'], 'sub_title' => $values['sub_title'], 'url' => $values['url'], 'html' => $post, 'text' => $text, ]; $lockedParams = [ 'title' => $values['title'], 'sub_title' => $values['sub_title'], 'url' => $values['url'], 'html' => $lockedPost, 'text' => strip_tags($lockedText), ]; $engine = $this->engineFactory->engine(); return [ 'htmlContent' => $engine->render($sourceTemplate->content_html, $params), 'textContent' => strip_tags($engine->render($sourceTemplate->content_text, $params)), 'lockedHtmlContent' => $engine->render($sourceTemplate->content_html, $lockedParams), 'lockedTextContent' => strip_tags($engine->render($sourceTemplate->content_text, $lockedParams)), ]; } public function formSucceeded(Form $form, ArrayHash $values): void { $output = $this->process((array)$values); $addonParams = [ 'lockedHtmlContent' => $output['lockedHtmlContent'], 'lockedTextContent' => $output['lockedTextContent'], 'tldrTitle' => $values->title, 'from' => $values->from, 'render' => true, 'articleId' => $values->article_id, ]; $this->onSubmit->__invoke($output['htmlContent'], $output['textContent'], $addonParams); } public function generateForm(Form $form): void { // disable CSRF protection as external sources could post the params here $form->offsetUnset(Form::PROTECTOR_ID); $form->addText('title', 'Title') ->setRequired("Field 'Title' is required."); $form->offsetUnset(Form::PROTECTOR_ID); $form->addText('sub_title', 'Sub title'); $form->addText('from', 'Sender'); $form->addText('url', 'Tl;dr URL') ->addRule(Form::URL) ->setRequired("Field 'Tl;dr URL' is required."); $form->addTextArea('tldr_html', 'HTML') ->setHtmlAttribute('rows', 20) ->setHtmlAttribute('class', 'form-control html-editor') ->getControlPrototype(); $form->addHidden('article_id'); $form->addSubmit('send') ->getControlPrototype() ->setName('button') ->setHtml('<i class="fa fa-magic"></i> ' . 'Generate'); $form->onSuccess[] = [$this, 'formSucceeded']; } public function onSubmit(callable $onSubmit): void { $this->onSubmit = $onSubmit; } /** * @param \stdClass $data containing WP article data * @return ArrayHash with data to fill the form with */ public function preprocessParameters($data): ?ArrayHash { $output = new ArrayHash(); if (!isset($data->post_authors[0]->display_name)) { throw new PreprocessException("WP json object does not contain required attribute 'post_authors.0.display_name'"); } if (isset($data->sender_email) && $data->sender_email) { $output->from = $data->sender_email; } else { $output->from = "Denník N <info@dennikn.sk>"; foreach ($data->post_authors as $author) { if ($author->user_email === "editori@dennikn.sk") { continue; } $output->from = $author->display_name . ' Denník N <' . $author->user_email . '>'; break; } } if (!isset($data->post_title)) { throw new PreprocessException("WP json object does not contain required attribute 'post_title'"); } $output->title = $data->post_title; if (!isset($data->post_url)) { throw new PreprocessException("WP json object does not contain required attribute 'post_url'"); } $output->url = $data->post_url; if (!isset($data->post_excerpt)) { throw new PreprocessException("WP json object does not contain required attribute 'post_excerpt'"); } $output->sub_title = $data->post_excerpt; if (isset($data->post_image->image_sizes->medium->file)) { $output->image_url = $data->post_image->image_sizes->medium->file; } if (isset($data->post_image->image_title)) { $output->image_title = $data->post_image->image_title; } if (!isset($data->post_content)) { throw new PreprocessException("WP json object does not contain required attribute 'post_content'"); } $output->tldr_html = $data->post_content; $output->article_id = $data->ID; return $output; } public function parseOls(string $post): string { $ols = []; preg_match_all('/<ol>(.*?)<\/ol>/is', $post, $ols); foreach ($ols[1] as $olContent) { $olsLis = []; $liNum = 1; $newOlContent = ''; preg_match_all('/<li>(.*?)<\/li>/is', $olContent, $olsLis); foreach ($olsLis[1] as $liContent) { $newOlContent .= ' <tr style="padding:0;vertical-align:top;text-align:left;"> <td class="bullet" style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;width:30px;border-collapse:collapse !important;">' . $liNum . '</td> <td style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;border-collapse:collapse !important;"> <p style="margin:0 0 0 26px;Margin:0 0 0 26px;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;font-size:18px;line-height:1.6;margin-bottom:26px;Margin-bottom:26px;line-height:160%;text-align:left;font-weight:normal;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto;border-collapse:collapse !important;">' . $liContent . '</p> </td> </tr>'; $liNum++; } $post = str_replace($olContent, $newOlContent, $post); } return $post; } public function getTemplates(): array { $captionTemplate = <<< HTML <img src="$1" alt="" style="outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;width:auto;max-width:100%;clear:both;display:block;margin-bottom:20px;"> <p style="margin:0 0 0 26px;Margin:0 0 0 26px;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;font-size:18px;line-height:1.6;margin-bottom:26px;Margin-bottom:26px;line-height:160%;text-align:left;font-weight:normal;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto;border-collapse:collapse !important;"> <small class="text-gray" style="font-size:13px;line-height:18px;display:block;color:#9B9B9B;">$2</small> </p> HTML; $captionWithLinkTemplate = <<< HTML <a href="$1" style="color:#181818;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight:normal;padding:0;margin:0;Margin:0;text-align:left;line-height:1.3;color:#1F3F83;text-decoration:none;"> <img src="$2" alt="" style="outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;width:auto;max-width:100%;clear:both;display:block;margin-bottom:20px;border:none;"> </a> <p style="margin:0 0 0 26px;Margin:0 0 0 26px;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;font-size:18px;line-height:1.6;margin-bottom:26px;Margin-bottom:26px;line-height:160%;text-align:left;font-weight:normal;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto;border-collapse:collapse !important;"> <small class="text-gray" style="font-size:13px;line-height:18px;display:block;color:#9B9B9B;">$3</small> </p> HTML; $liTemplate = <<< HTML <tr style="padding:0;vertical-align:top;text-align:left;"> <td class="bullet" style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;width:30px;border-collapse:collapse !important;">&#8226;</td> <td style="padding:0;vertical-align:top;text-align:left;font-size:18px;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;border-collapse:collapse !important;"> <p style="color:#181818;padding:0;margin:0 0 5px 0;font-size:18px;line-height:160%;text-align:left;font-weight:normal;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto;border-collapse:collapse !important;">$1</p> </td> </tr> HTML; $hrTemplate = <<< HTML <table cellspacing="0" cellpadding="0" border="0" width="100%" style="border-spacing:0;border-collapse:collapse;vertical-align:top;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;text-align:left;font-family:'Helvetica Neue', Helvetica, Arial;width:100%;min-width:100%;"> <tr style="padding:0;vertical-align:top;text-align:left;width:100%;min-width:100%;"> <td style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;border-collapse:collapse !important; padding: 30px 0 0 0; border-top:1px solid #E2E2E2;height:0;line-height: 0;width:100%;min-width:100%;">&#xA0;</td> </tr> </table> HTML; $spacerTemplate = <<< HTML <table class="spacer" style="border-spacing:0;border-collapse:collapse;vertical-align:top;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;text-align:left;font-family:'Helvetica Neue', Helvetica, Arial;width:100%;"> <tbody> <tr style="padding:0;vertical-align:top;text-align:left;"> <td height="20px" style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;mso-line-height-rule:exactly;border-collapse:collapse !important;font-size:20px;line-height:20px;">&#xA0;</td> </tr> </tbody> </table> HTML; $imageTemplate = <<< HTML <img src="$1" alt="" style="outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;width:auto;max-width:100%;clear:both;display:block;margin-bottom:20px;"> HTML; return [ $captionTemplate, $captionWithLinkTemplate, $liTemplate, $hrTemplate, $spacerTemplate, $imageTemplate, ]; } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Models/Generators/NovydenikNewsfilterGenerator.php
Mailer/app/Models/Generators/NovydenikNewsfilterGenerator.php
<?php declare(strict_types=1); namespace Remp\Mailer\Models\Generators; use Nette\Application\UI\Form; use Nette\Utils\ArrayHash; use Remp\Mailer\Components\GeneratorWidgets\Widgets\NovydenikNewsfilterWidget\NovydenikNewsfilterWidget; use Remp\MailerModule\Models\ContentGenerator\Engine\EngineFactory; use Remp\MailerModule\Models\Generators\EmbedParser; use Remp\MailerModule\Models\Generators\IGenerator; use Remp\MailerModule\Models\Generators\PreprocessException; use Remp\MailerModule\Models\Generators\SnippetArticleLocker; use Remp\MailerModule\Models\Generators\WordpressHelpers; use Remp\MailerModule\Models\PageMeta\Content\ContentInterface; use Remp\MailerModule\Repositories\SourceTemplatesRepository; use Tomaj\NetteApi\Params\PostInputParam; class NovydenikNewsfilterGenerator implements IGenerator { use RulesTrait; public $onSubmit; private $mailSourceTemplateRepository; private $helpers; private $content; private $embedParser; private $articleLocker; private $engineFactory; public function __construct( SourceTemplatesRepository $mailSourceTemplateRepository, WordpressHelpers $helpers, ContentInterface $content, EmbedParser $embedParser, SnippetArticleLocker $articleLocker, EngineFactory $engineFactory ) { $this->mailSourceTemplateRepository = $mailSourceTemplateRepository; $this->helpers = $helpers; $this->content = $content; $this->embedParser = $embedParser; $this->articleLocker = $articleLocker; $this->engineFactory = $engineFactory; } public function apiParams(): array { return [ (new PostInputParam('newsfilter_html'))->setRequired(), (new PostInputParam('url'))->setRequired(), (new PostInputParam('title'))->setRequired(), (new PostInputParam('editor'))->setRequired(), (new PostInputParam('summary')), (new PostInputParam('gender')), (new PostInputParam('from'))->setRequired(), ]; } public function getWidgets(): array { return [NovydenikNewsfilterWidget::class]; } public function process(array $values): array { $sourceTemplate = $this->mailSourceTemplateRepository->find($values['source_template_id']); $post = $values['newsfilter_html']; $lockedPost = $this->articleLocker->getLockedPost($post); $generatorRules = [ "/https:\/\/denikn\.podbean\.com\/e\/.*?[\s\n\r]/is" => "", "/<em.*?>(.*?)<\/em>/is" => "<i>$1</i>", '/\[articlelink.*?id="?(\d+)"?.*?\]/is' => function ($matches) { $url = "https://denikn.cz/{$matches[1]}"; $meta = $this->content->fetchUrlMeta($url); return $meta ? '<a href="' . $url . '" style="padding:0;margin:0;line-height:1.3;color:#F26755;text-decoration:none;">' . $meta->getTitle() . '</a>' : ''; }, '/<a\s[^>]*href="(.*?)".*?>(.*?)<\/a>/is' => '<a href="$1" style="padding:0;margin:0;line-height:1.3;color:#b00c28;text-decoration:none;">$2</a>', '/<p.*?>(.*?)<\/p>/is' => "<p style=\"font-weight: normal;\">$1</p>", ]; $rules = $this->getRules($generatorRules); foreach ($rules as $rule => $replace) { if (is_array($replace) || is_callable($replace)) { $post = preg_replace_callback($rule, $replace, $post); $lockedPost = preg_replace_callback($rule, $replace, $lockedPost); } else { $post = preg_replace($rule, $replace, $post); $lockedPost = preg_replace($rule, $replace, $lockedPost); } } // wrap text in paragraphs $post = $this->helpers->wpautop($post); $lockedPost = $this->helpers->wpautop($lockedPost); $post = str_replace('<p>', '<p style="font-weight: normal;">', $post); $lockedPost = str_replace('<p>', '<p style="font-weight: normal;">', $lockedPost); $lockedPost = $this->articleLocker->injectLockedMessage($lockedPost); $params = [ 'title' => $values['title'], 'editor' => $values['editor'], 'gender' => $values['gender'] ?? null, 'summary' => $values['summary'], 'url' => $values['url'], 'html' => $post, 'text' => strip_tags($post), ]; $lockedParams = [ 'title' => $values['title'], 'editor' => $values['editor'], 'gender' => $values['gender'] ?? null, 'summary' => $values['summary'], 'url' => $values['url'], 'html' => $lockedPost, 'text' => strip_tags($lockedPost), ]; $engine = $this->engineFactory->engine(); return [ 'htmlContent' => $engine->render($sourceTemplate->content_html, $params), 'textContent' => strip_tags($engine->render($sourceTemplate->content_text, $params)), 'lockedHtmlContent' => $engine->render($sourceTemplate->content_html, $lockedParams), 'lockedTextContent' => strip_tags($engine->render($sourceTemplate->content_text, $lockedParams)), ]; } public function formSucceeded(Form $form, ArrayHash $values): void { $output = $this->process((array) $values); $addonParams = [ 'lockedHtmlContent' => $output['lockedHtmlContent'], 'lockedTextContent' => $output['lockedTextContent'], 'newsfilterTitle' => $values->title, 'from' => $values->from, 'render' => true, 'articleId' => $values->article_id, ]; $this->onSubmit->__invoke($output['htmlContent'], $output['textContent'], $addonParams); } public function generateForm(Form $form): void { // disable CSRF protection as external sources could post the params here $form->offsetUnset(Form::PROTECTOR_ID); $form->addText('title', 'Title') ->setRequired("Field 'Title' is required."); $form->addText('url', 'Newsfilter URL') ->addRule(Form::URL) ->setRequired("Field 'Newsfilter URL' is required."); $form->addText('from', 'Sender'); $form->addText('editor', 'Editor') ->setRequired("Field 'Editor' is required."); $form->addSelect('gender', 'Gender', [ '' => 'Please select', 'male' => 'Male', 'female' => 'Female', 'none' => 'None', ]); $form->addTextArea('summary', 'Summary') ->setHtmlAttribute('rows', 3) ->setRequired(false); $form->addTextArea('newsfilter_html', 'HTML') ->setHtmlAttribute('rows', 20) ->setHtmlAttribute('class', 'form-control html-editor') ->getControlPrototype(); $form->addHidden('article_id'); $form->addSubmit('send') ->getControlPrototype() ->setName('button') ->setHtml('<i class="fa fa-magic"></i> ' . 'Generate'); $form->onSuccess[] = [$this, 'formSucceeded']; } public function onSubmit(callable $onSubmit): void { $this->onSubmit = $onSubmit; } /** * @param \stdClass $data containing WP article data * @return ArrayHash with data to fill the form with */ public function preprocessParameters($data): ?ArrayHash { $output = new ArrayHash(); if (!isset($data->post_authors[0]->display_name)) { throw new PreprocessException("WP json object does not contain required attribute 'post_authors.0.display_name'"); } $output->editor = $data->post_authors[0]->display_name; if (isset($data->sender_email) && $data->sender_email) { $output->from = $data->sender_email; } if (!isset($data->post_title)) { throw new PreprocessException("WP json object does not contain required attribute 'post_title'"); } $output->title = $data->post_title; if (!isset($data->post_url)) { throw new PreprocessException("WP json object does not contain required attribute 'post_url'"); } $output->url = $data->post_url; if (!isset($data->post_excerpt)) { throw new PreprocessException("WP json object does not contain required attribute 'post_excerpt'"); } $output->summary = $data->post_excerpt; if (!isset($data->post_content)) { throw new PreprocessException("WP json object does not contain required attribute 'post_content'"); } $output->newsfilter_html = $data->post_content; $output->article_id = $data->ID; $output->gender = $data->post_authors[0]->gender ?? null; return $output; } public function getTemplates(): array { $captionTemplate = <<< HTML <img src="$1" alt="" style="outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;width:auto;max-width:100%;clear:both;display:block;margin-bottom:20px;"> <p style="margin:0 0 0 26px;Margin:0 0 0 26px;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;font-size:18px;line-height:1.6;margin-bottom:26px;Margin-bottom:26px;line-height:160%;text-align:left;font-weight:normal;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto;border-collapse:collapse !important;"> <small class="text-gray" style="font-size:13px;line-height:18px;display:block;color:#9B9B9B;">$2</small> </p> HTML; $captionWithLinkTemplate = <<< HTML <a href="$1" style="color:#181818;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight:normal;padding:0;margin:0;Margin:0;text-align:left;line-height:1.3;color:#b00c28;text-decoration:none;"> <img src="$2" alt="" style="outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;width:auto;max-width:100%;clear:both;display:block;margin-bottom:20px;border:none;"> </a> <p style="margin:0 0 0 26px;Margin:0 0 0 26px;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;font-size:18px;line-height:1.6;margin-bottom:26px;Margin-bottom:26px;line-height:160%;text-align:left;font-weight:normal;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto;border-collapse:collapse !important;"> <small class="text-gray" style="font-size:13px;line-height:18px;display:block;color:#9B9B9B;">$3</small> </p> HTML; $liTemplate = <<< HTML <tr style="padding:0;vertical-align:top;text-align:left;"> <td class="bullet" style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;width:30px;border-collapse:collapse !important;">&#8226;</td> <td style="padding:0;vertical-align:top;text-align:left;font-size:18px;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;border-collapse:collapse !important;"> <p style="color:#181818;padding:0;margin:0 0 5px 0;font-size:18px;line-height:160%;text-align:left;font-weight:normal;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto;border-collapse:collapse !important;">$1</p> </td> </tr> HTML; $hrTemplate = <<< HTML <table cellspacing="0" cellpadding="0" border="0" width="100%" style="border-spacing:0;border-collapse:collapse;vertical-align:top;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;text-align:left;font-family:'Helvetica Neue', Helvetica, Arial;width:100%;min-width:100%;"> <tr style="padding:0;vertical-align:top;text-align:left;width:100%;min-width:100%;"> <td style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;border-collapse:collapse !important; padding: 30px 0 0 0; border-top:1px solid #E2E2E2;height:0;line-height: 0;width:100%;min-width:100%;">&#xA0;</td> </tr> </table> HTML; $spacerTemplate = <<< HTML <table class="spacer" style="border-spacing:0;border-collapse:collapse;vertical-align:top;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;text-align:left;font-family:'Helvetica Neue', Helvetica, Arial;width:100%;"> <tbody> <tr style="padding:0;vertical-align:top;text-align:left;"> <td height="20px" style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;mso-line-height-rule:exactly;border-collapse:collapse !important;font-size:20px;line-height:20px;">&#xA0;</td> </tr> </tbody> </table> HTML; $imageTemplate = <<< HTML <img src="$1" alt="" style="outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;width:auto;max-width:100%;clear:both;display:block;margin-bottom:20px;"> HTML; return [ $captionTemplate, $captionWithLinkTemplate, $liTemplate, $hrTemplate, $spacerTemplate, $imageTemplate, ]; } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Models/Generators/NewsfilterGenerator.php
Mailer/app/Models/Generators/NewsfilterGenerator.php
<?php declare(strict_types=1); namespace Remp\Mailer\Models\Generators; use Nette\Application\UI\Form; use Nette\Utils\ArrayHash; use Remp\Mailer\Components\GeneratorWidgets\Widgets\NewsfilterWidget\NewsfilterWidget; use Remp\MailerModule\Models\ContentGenerator\Engine\EngineFactory; use Remp\MailerModule\Models\Generators\HtmlArticleLocker; use Remp\MailerModule\Models\Generators\EmbedParser; use Remp\MailerModule\Models\Generators\IGenerator; use Remp\MailerModule\Models\Generators\PreprocessException; use Remp\MailerModule\Models\Generators\WordpressHelpers; use Remp\MailerModule\Models\PageMeta\Content\ContentInterface; use Remp\MailerModule\Models\PageMeta\Content\InvalidUrlException; use Remp\MailerModule\Repositories\SourceTemplatesRepository; use Tomaj\NetteApi\Params\PostInputParam; class NewsfilterGenerator implements IGenerator { use RulesTrait, TemplatesTrait; public $onSubmit; private $mailSourceTemplateRepository; private $helpers; private $content; private $embedParser; protected $articleLocker; private $engineFactory; public function __construct( SourceTemplatesRepository $mailSourceTemplateRepository, WordpressHelpers $helpers, ContentInterface $content, EmbedParser $embedParser, HtmlArticleLocker $articleLocker, EngineFactory $engineFactory ) { $this->mailSourceTemplateRepository = $mailSourceTemplateRepository; $this->helpers = $helpers; $this->content = $content; $this->embedParser = $embedParser; $this->articleLocker = $articleLocker; $this->engineFactory = $engineFactory; } public function apiParams(): array { return [ (new PostInputParam('newsfilter_html'))->setRequired(), (new PostInputParam('url'))->setRequired(), (new PostInputParam('title'))->setRequired(), (new PostInputParam('editor'))->setRequired(), (new PostInputParam('summary')), (new PostInputParam('from'))->setRequired(), ]; } public function getWidgets(): array { return [NewsfilterWidget::class]; } public function process(array $values): array { $sourceTemplate = $this->mailSourceTemplateRepository->find($values['source_template_id']); $post = $values['newsfilter_html']; $post = $this->parseOls($post); $lockedPost = $this->articleLocker->getLockedPost($post); $errors = []; $generatorRules = [ '/<h2.*?>.*?\*.*?<\/h2>/im' => '<div style="color:#181818;padding:0;line-height:1.3;font-weight:bold;text-align:center;margin:0 0 30px 0;font-size:24px;">*</div>', "/https:\/\/dennikn\.podbean\.com\/e\/.*?[\s\n\r]/is" => "", ]; $rules = $this->getRules($generatorRules); foreach ($rules as $rule => $replace) { if (is_array($replace) || is_callable($replace)) { $post = preg_replace_callback($rule, $replace, $post); $lockedPost = preg_replace_callback($rule, $replace, $lockedPost); } else { $post = preg_replace($rule, $replace, $post); $lockedPost = preg_replace($rule, $replace, $lockedPost); } } // wrap text in paragraphs $post = $this->helpers->wpautop($post); $lockedPost = $this->helpers->wpautop($lockedPost); // parse article links $post = $this->helpers->wpParseArticleLinks($post, 'https://dennikn.sk/', $this->getArticleLinkTemplateFunction(), $errors); $lockedPost = $this->helpers->wpParseArticleLinks($lockedPost, 'https://dennikn.sk/', $this->getArticleLinkTemplateFunction(), $errors); [$post, $lockedPost] = preg_replace('/<p>/is', "<p style=\"color:#181818;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight:normal;padding:0;text-align:left;font-size:18px;line-height:160%;margin: 16px 0 16px 0\">", [$post, $lockedPost]); $lockedPost = $this->articleLocker->injectLockedMessage($lockedPost); $params = [ 'title' => $values['title'], 'editor' => $values['editor'], 'summary' => $values['summary'], 'url' => $values['url'], 'html' => $post, 'text' => strip_tags($post), 'locked' => false, ]; $lockedParams = [ 'title' => $values['title'], 'editor' => $values['editor'], 'summary' => $values['summary'], 'url' => $values['url'], 'html' => $lockedPost, 'text' => strip_tags($lockedPost), 'locked' => true, ]; $engine = $this->engineFactory->engine(); return [ 'htmlContent' => $engine->render($sourceTemplate->content_html, $params), 'textContent' => strip_tags($engine->render($sourceTemplate->content_text, $params)), 'lockedHtmlContent' => $engine->render($sourceTemplate->content_html, $lockedParams), 'lockedTextContent' => strip_tags($engine->render($sourceTemplate->content_text, $lockedParams)), 'errors' => $errors, ]; } public function formSucceeded(Form $form, ArrayHash $values): void { $output = $this->process((array) $values); $addonParams = [ 'lockedHtmlContent' => $output['lockedHtmlContent'], 'lockedTextContent' => $output['lockedTextContent'], 'newsfilterTitle' => $values->title, 'from' => $values->from, 'render' => true, 'articleId' => $values->article_id, 'errors' => $output['errors'], ]; $this->onSubmit->__invoke($output['htmlContent'], $output['textContent'], $addonParams); } public function generateForm(Form $form): void { // disable CSRF protection as external sources could post the params here $form->offsetUnset(Form::PROTECTOR_ID); $form->addText('title', 'Title') ->setRequired("Field 'Title' is required."); $form->addText('url', 'Newsfilter URL') ->addRule(Form::URL) ->setRequired("Field 'Newsfilter URL' is required."); $form->addText('from', 'Sender'); $form->addText('editor', 'Editor') ->setRequired("Field 'Editor' is required."); $form->addTextArea('summary', 'Summary') ->setHtmlAttribute('rows', 3) ->setRequired(false); $form->addTextArea('newsfilter_html', 'HTML') ->setHtmlAttribute('rows', 20) ->setHtmlAttribute('class', 'form-control html-editor') ->getControlPrototype(); $form->addHidden('article_id'); $form->addSubmit('send') ->getControlPrototype() ->setName('button') ->setHtml('<i class="fa fa-magic"></i> ' . 'Generate'); $form->onSuccess[] = [$this, 'formSucceeded']; } public function onSubmit(callable $onSubmit): void { $this->onSubmit = $onSubmit; } /** * @param \stdClass $data containing WP article data * @return ArrayHash with data to fill the form with */ public function preprocessParameters($data): ?ArrayHash { $output = new ArrayHash(); if (!isset($data->post_authors[0]->display_name)) { throw new PreprocessException("WP json object does not contain required attribute 'post_authors.0.display_name'"); } $output->editor = $data->post_authors[0]->display_name; if (isset($data->sender_email) && $data->sender_email) { $output->from = $data->sender_email; } else { $output->from = "Denník N <info@dennikn.sk>"; foreach ($data->post_authors as $author) { if ($author->user_email === "editori@dennikn.sk") { continue; } if ($author->user_email !== 'e@dennikn.sk') { $output->from = $author->display_name . ' Denník N <' . $author->user_email . '>'; } else { $output->from = $author->display_name . ' <' . $author->user_email . '>'; } break; } } foreach ($data->post_authors as $author) { if ($author->user_email === "editori@dennikn.sk") { continue; } $output->editor = $author->display_name; break; } if (!isset($data->post_title)) { throw new PreprocessException("WP json object does not contain required attribute 'post_title'"); } $output->title = $data->post_title; if (!isset($data->post_url)) { throw new PreprocessException("WP json object does not contain required attribute 'post_url'"); } $output->url = $data->post_url; if (!isset($data->post_excerpt)) { throw new PreprocessException("WP json object does not contain required attribute 'post_excerpt'"); } $output->summary = $data->post_excerpt; if (!isset($data->post_content)) { throw new PreprocessException("WP json object does not contain required attribute 'post_content'"); } $output->newsfilter_html = $data->post_content; $output->article_id = $data->ID; return $output; } public function getTemplates(): array { $captionTemplate = <<< HTML <img src="$1" alt="" style="outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;width:auto;max-width:100%;clear:both;display:block;margin-bottom:20px;"> <p style="margin:0 0 0 26px;Margin:0 0 0 26px;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;font-size:18px;line-height:1.6;margin-bottom:26px;Margin-bottom:26px;line-height:160%;text-align:left;font-weight:normal;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto;border-collapse:collapse !important;"> <small class="text-gray" style="font-size:13px;line-height:18px;display:block;color:#9B9B9B;">$2</small> </p> HTML; $captionWithLinkTemplate = <<< HTML <a href="$1" style="color:#181818;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight:normal;padding:0;margin:0;Margin:0;text-align:left;line-height:1.3;color:{$this->linksColor};text-decoration:none;"> <img src="$2" alt="" style="outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;width:auto;max-width:100%;clear:both;display:block;margin-bottom:20px;border:none;"> </a> <p style="margin:0 0 0 26px;Margin:0 0 0 26px;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;font-size:18px;line-height:1.6;margin-bottom:26px;Margin-bottom:26px;line-height:160%;text-align:left;font-weight:normal;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto;border-collapse:collapse !important;"> <small class="text-gray" style="font-size:13px;line-height:18px;display:block;color:#9B9B9B;">$3</small> </p> HTML; $liTemplate = <<< HTML <tr style="padding:0;vertical-align:top;text-align:left;"> <td class="bullet" style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;width:30px;border-collapse:collapse !important;">&#8226;</td> <td style="padding:0;vertical-align:top;text-align:left;font-size:18px;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;border-collapse:collapse !important;"> <p style="color:#181818;padding:0;margin:0 0 5px 0;font-size:18px;line-height:160%;text-align:left;font-weight:normal;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto;border-collapse:collapse !important;">$1</p> </td> </tr> HTML; $hrTemplate = <<< HTML <table cellspacing="0" cellpadding="0" border="0" width="100%" style="border-spacing:0;border-collapse:collapse;vertical-align:top;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;text-align:left;font-family:'Helvetica Neue', Helvetica, Arial;width:100%;min-width:100%;"> <tr style="padding:0;vertical-align:top;text-align:left;width:100%;min-width:100%;"> <td style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;border-collapse:collapse !important; padding: 30px 0 0 0; border-top:1px solid #E2E2E2;height:0;line-height: 0;width:100%;min-width:100%;">&#xA0;</td> </tr> </table> HTML; $spacerTemplate = <<< HTML <table class="spacer" style="border-spacing:0;border-collapse:collapse;vertical-align:top;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;text-align:left;font-family:'Helvetica Neue', Helvetica, Arial;width:100%;"> <tbody> <tr style="padding:0;vertical-align:top;text-align:left;"> <td height="20px" style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;mso-line-height-rule:exactly;border-collapse:collapse !important;font-size:20px;line-height:20px;">&#xA0;</td> </tr> </tbody> </table> HTML; $imageTemplate = <<< HTML <img src="$1" alt="" style="outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;width:auto;max-width:100%;clear:both;display:block;margin-bottom:20px;"> HTML; return [ $captionTemplate, $captionWithLinkTemplate, $liTemplate, $hrTemplate, $spacerTemplate, $imageTemplate, ]; } public function parseOls($post) { $ols = []; preg_match_all('/<ol.*?>(.*?)<\/ol>/is', $post, $ols); foreach ($ols[1] as $olContent) { $olsLis = []; $liNum = 1; $newOlContent = ''; preg_match_all('/<li>(.*?)<\/li>/is', $olContent, $olsLis); foreach ($olsLis[1] as $liContent) { $newOlContent .= ' <tr style="padding:0;vertical-align:top;text-align:left;"> <td class="bullet" style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;width:30px;border-collapse:collapse !important;">' . $liNum . '</td> <td style="padding:0;vertical-align:top;text-align:left;font-size:18px;line-height:1.6;border-collapse:collapse !important;"> <p style="margin:0 0 0 26px;Margin:0 0 0 26px;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;font-size:18px;line-height:1.6;margin-bottom:26px;Margin-bottom:26px;line-height:160%;text-align:left;font-weight:normal;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto;border-collapse:collapse !important;">' . $liContent . '</p> </td> </tr>'; $liNum++; } $post = str_replace($olContent, $newOlContent, $post); } return $post; } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Models/Generators/TemplatesTrait.php
Mailer/app/Models/Generators/TemplatesTrait.php
<?php namespace Remp\Mailer\Models\Generators; trait TemplatesTrait { public function getArticleLinkTemplateFunction(): callable { return static function ($title, $url, $image) { return <<<HTML <table style="border-spacing:0;border-collapse:collapse;vertical-align:top;text-align:left;font-family:Helvetica, Arial, sans-serif;height:100%;width:100%;color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;background:#f8f8f8 !important;"> <tr style="padding:0;vertical-align:top;text-align:left;"> <td valign="top" style="vertical-align:top;text-align:left;font-size:14px;line-height:1.3;border-collapse:collapse !important;padding-top:16px;padding-left:16px;padding-bottom:16px;padding-right:16px;"> <a href="{$url}" style="text-decoration: none;color: #181818; display:block;width:100%;max-width:100%;height:auto;border:none;"> <img src="{$image}" style="display:block;width:100%;max-width:100%;height:auto;border:none;" alt="{$title}"> </a> <small style="margin: 0;padding: 0;margin-bottom: 8px;margin-top:8px; font-size:12px; display: block;">Prečítajte si</small> <h2 style="margin: 0;padding: 0; font-size: 20px;"> <a href="{$url}" style="text-decoration: none;color: #181818;">{$title}</a> </h2> </td> </tr> </table> HTML; }; } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Models/Generators/EmbedParser.php
Mailer/app/Models/Generators/EmbedParser.php
<?php declare(strict_types=1); namespace Remp\Mailer\Models\Generators; class EmbedParser extends \Remp\MailerModule\Models\Generators\EmbedParser { protected string $twitterLinkText = "Click to display on X (Twitter)"; protected ?string $embedImagePreprocessingUrl = null; protected ?string $salt = ''; public function setTwitterLinkText(string $twitterLinkText = null): void { $this->twitterLinkText = $twitterLinkText; } public function setEmbedImagePreprocessingUrl(string $embedImagePreprocessingUrl, string $salt): void { $this->embedImagePreprocessingUrl = $embedImagePreprocessingUrl; $this->salt = $salt; } private function isTwitterLink($link): bool { return str_contains($link, 'twitt') || str_contains($link, 'x.com'); } public function createEmbedMarkup(string $link, ?string $title = null, ?string $image = null, bool $isVideo = false): string { $html = "<br>"; $html .= "<a href='{$link}' target='_blank' style='color:#181818;padding:0;margin:0;Margin:0;line-height:1.3;text-decoration:none;text-align: center; display: block;width:100%;'>"; if (!is_null($image) && !is_null($title)) { if ($this->embedImagePreprocessingUrl) { $preprocessedImage = sprintf($this->embedImagePreprocessingUrl, $image, hash('sha256', $this->salt . $image)); if ($this->existImage($preprocessedImage)) { $image = $preprocessedImage; } } $html .= "<img src='{$image}' alt='{$title}' style='outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;max-width:100%;clear:both;display:inline;width:100%;height:auto;'>"; } elseif ($this->isTwitterLink($link)) { return "<br><a style=\"display: block;margin: 0 0 20px;padding: 7px 10px;text-decoration: none;text-align: center;font-weight: bold;font-family:'Helvetica Neue', Helvetica, Arial;color: #249fdc; background: #ffffff; border: 3px solid #249fdc;margin: 16px 0 16px 0\" href=\"{$link}\" target=\"_blank\">{$this->twitterLinkText}</a>"; } else { $html .= "<span style='text-decoration: underline; color: #1F3F83;'>" . $link . "</span>"; } if ($isVideo && isset($this->videoLinkText)) { $html .= "<p style='color: #888;font-family: Arial,sans-serif;font-size: 14px;margin: 0; padding: 0;margin-top:5px;line-height: 1.3;text-align: left; text-decoration: none;'><i>{$this->videoLinkText}</i></p><br>"; } return $html . "</a>" . PHP_EOL; } private function existImage(string $link): bool { $response = @get_headers($link); return $response && is_array($response) && str_contains($response[0], '200'); } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Models/Generators/DailyMinuteGenerator.php
Mailer/app/Models/Generators/DailyMinuteGenerator.php
<?php declare(strict_types=1); namespace Remp\Mailer\Models\Generators; use Nette\Application\UI\Form; use Nette\Utils\ArrayHash; use Nette\Utils\DateTime; use Remp\Mailer\Components\GeneratorWidgets\Widgets\DailyMinuteWidget\DailyMinuteWidget; use Remp\MailerModule\Models\ContentGenerator\Engine\EngineFactory; use Remp\MailerModule\Models\Generators\IGenerator; use Remp\MailerModule\Models\Generators\InvalidUrlException; use Remp\MailerModule\Models\Generators\PreprocessException; use Remp\MailerModule\Repositories\SnippetsRepository; use Remp\MailerModule\Repositories\SourceTemplatesRepository; use Tomaj\NetteApi\Params\PostInputParam; class DailyMinuteGenerator implements IGenerator { private string $nameDaySourceFile; private string $from; public $onSubmit; public function __construct( private WordpressBlockParser $wordpressBlockParser, private SourceTemplatesRepository $sourceTemplatesRepository, private EngineFactory $engineFactory, private SnippetsRepository $snippetsRepository, ) { } public function setNameDaySourceFile(string $nameDaySourceFile): void { $this->nameDaySourceFile = $nameDaySourceFile; } public function setFrom(string $from): void { $this->from = $from; } public function generateForm(Form $form): void { // disable CSRF protection as external sources could post the params here $form->offsetUnset(Form::PROTECTOR_ID); $form->addText('subject', 'Subject') ->setHtmlAttribute('class', 'form-control') ->setRequired(); $form->addText('from', 'From') ->setHtmlAttribute('class', 'form-control'); $form->addText('url', 'URL') ->setHtmlAttribute('class', 'form-control'); $form->addTextArea('blocks_json', 'Blocks JSON') ->setHtmlAttribute('rows', 8) ->setHtmlAttribute('class', 'form-control') ->setRequired(); $form->onSuccess[] = [$this, 'formSucceeded']; } public function formSucceeded(Form $form, ArrayHash $values): void { try { $output = $this->process((array)$values); $addonParams = [ 'render' => true, 'from' => $values->from, 'subject' => $values->subject, 'errors' => $output['errors'], ]; $this->onSubmit->__invoke($output['htmlContent'], $output['textContent'], $addonParams); } catch (InvalidUrlException $e) { $form->addError($e->getMessage()); } } public function onSubmit(callable $onSubmit): void { $this->onSubmit = $onSubmit; } public function getWidgets(): array { return [DailyMinuteWidget::class]; } public function apiParams(): array { return [ (new PostInputParam('url'))->setRequired(), (new PostInputParam('subject'))->setRequired(), (new PostInputParam('blocks_json'))->setRequired(), (new PostInputParam('from')), ]; } public function process(array $values): array { [$html, $text] = $this->wordpressBlockParser->parseJson($values['blocks_json']); $adSnippet = $this->snippetsRepository->all()->where([ 'code' => 'r5m-advertisement-end', 'html <> ?' => '', 'mail_type_id' => null, ])->fetch(); $now = new DateTime(); $additionalParams = [ 'date' => $now, 'nameDay' => $this->getNameDayNamesForDate($now), 'url' => $values['url'], 'adSnippetHtml' => $adSnippet?->html, 'adSnippetText' => $adSnippet?->text, ]; $engine = $this->engineFactory->engine(); $sourceTemplate = $this->sourceTemplatesRepository->find($values['source_template_id']); return [ 'htmlContent' => $engine->render($sourceTemplate->content_html, ['html' => $html] + $additionalParams), 'textContent' => $engine->render($sourceTemplate->content_text, ['text' => $text] + $additionalParams), 'from' => $values['from'], 'subject' => $values['subject'], 'errors' => [] ]; } public function preprocessParameters($data): ?ArrayHash { $output = new ArrayHash(); if (!isset($data->blocks)) { throw new PreprocessException("WP json object does not contain required attribute 'blocks'"); } if (!isset($data->subject)) { throw new PreprocessException("WP json object does not contain required attribute 'subject'"); } if (!isset($data->url)) { throw new PreprocessException("WP json object does not contain required attribute 'url'"); } $output->from = $this->from; $output->blocks_json = $data->blocks; $output->subject = $data->subject; $output->url = $data->url; return $output; } private function getNameDayNamesForDate(DateTime $date): string { if (!isset($this->nameDaySourceFile)) { throw new \Exception("No value set for configurable value 'nameDaySourceFile'. Provide file name in configuration file through 'setNameDaySourceFile()' method."); } $json = file_get_contents(__DIR__ . '/resources/' . $this->nameDaySourceFile); $nameDays = json_decode($json, true); // javascript array of months in namedays.json starts from 0 $month = ((int) $date->format('m')) - 1; $day = (int) $date->format('d'); return $nameDays[$month][$day] ?? ''; } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false
remp2020/remp
https://github.com/remp2020/remp/blob/c616d27734c65eb87b470751928ff1119c535549/Mailer/app/Models/Generators/RulesTrait.php
Mailer/app/Models/Generators/RulesTrait.php
<?php namespace Remp\Mailer\Models\Generators; trait RulesTrait { private $linksColor = "#1F3F83"; public function getRules($generatorRules = []) { [ $captionTemplate, $captionWithLinkTemplate, $liTemplate, $hrTemplate, $spacerTemplate, $imageTemplate ] = $this->getTemplates(); // The order of rules is important. Rules that are lower in the list apply later and can overwrite content generated by rules applied sooner. $rules = [ // remove shortcodes "/\[pullboth.*?\/pullboth\]/is" => "", "/<script.*?\/script>/is" => "", "/\[iframe.*?\]/is" => "", '/\[\/?lock\]/i' => "", '/\[lock newsletter\]/i' => "", '/\[lock\]/i' => "", '/\[lock e\]/i' => "", // remove new style of shortcodes '/<div[^>]*class="[^>]*"[^>]*>/is' => '', '/<\/div>/is' => '', // remove iframes "/<iframe.*?\/iframe>/is" => "", '/<p.*?>(.*?)<\/p>/is' => "<p style=\"color:#181818;font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-weight:normal;padding:0;text-align:left;font-size:18px;line-height:160%;margin: 16px 0 16px 0\">$1</p>", // replace em-s "/<em.*?>(.*?)<\/em>/is" => "<i style=\"margin:0 0 26px 0;color:#181818;padding:0;font-size:18px;line-height:160%;text-align:left;font-weight:normal;word-wrap:break-word;-webkit-hyphens:auto;-moz-hyphens:auto;hyphens:auto;border-collapse:collapse !important;\">$1</i>", // remove new lines from inside caption shortcode "/\[caption.*?\/caption\]/is" => function ($matches) { return str_replace(array("\n\r", "\n", "\r"), '', $matches[0]); }, // replace captions '/\[caption.*?\].*?href="(.*?)".*?src="(.*?)".*?\/a>(.*?)\[\/caption\]/im' => $captionWithLinkTemplate, '/\[caption.*?\].*?src="(.*?)".*?\/>(.*?)\[\/caption\]/im' => $captionTemplate, // replace hrefs '/<a\s[^>]*href="(.*?)".*?>(.*?)<\/a>/is' => '<a href="$1" style="padding:0;margin:0;line-height:1.3;color:' . $this->linksColor . ';text-decoration:underline;">$2</a>', // replace h2 '/<h2.*?>(.*?)<\/h2>/is' => '<h2 style="color:#181818;padding:0;line-height:1.3;font-weight:bold;text-align:left;margin:0 0 30px 0;font-size:24px;">$1</h2>' . PHP_EOL, // replace images '/<img.*?src="(.*?)".*?>/is' => $imageTemplate, // replace ul & ol '/<ul.*?>/is' => '<table style="border-spacing:0;border-collapse:collapse;vertical-align:top;color:#181818;padding:0;margin:0;line-height:1.3;text-align:left;font-family:\'Helvetica Neue\', Helvetica, Arial;width:100%;"><tbody>', '/<ol.*?>/is' => '<table style="border-spacing:0;border-collapse:collapse;vertical-align:top;color:#181818;padding:0;margin:0;line-height:1.3;text-align:left;font-family:\'Helvetica Neue\', Helvetica, Arial;width:100%; font-weight: normal;"><tbody>', '/<\/ul>/is' => '</tbody></table>' . PHP_EOL, '/<\/ol>/is' => '</tbody></table>' . PHP_EOL, // replace li '/<li.*?>(.*?)<\/li>/is' => $liTemplate, // hr '/(<hr>|<hr \/>)/is' => $hrTemplate, // parse embeds '/^\s*(http|https)\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(\/\S*)?\s*$/im' => function ($matches) { return $this->embedParser->parse($matches[0]); }, "/\[embed\](.*?)\[\/embed\]/is" => function ($matches) { return $this->embedParser->parse($matches[1]); }, // remove br from inside of a '/<a.*?\/a>/is' => function ($matches) { return str_replace('<br />', '', $matches[0]); }, // greybox "/\[greybox\](.*?)\[\/greybox\]/is" => '<div class="t_greybox" style="padding: 16px; background: #f6f6f6;">$1</div>', '/\[row\](.*?)\[\/row\]/is' => '<div class="t_row gutter_8" style="display: flex; flex-wrap: wrap; margin: 0 -8px">$1</div>', '/\[col\](.*?)\[\/col\]/is' => '<div class="t_col large_0 small_0" style="margin: 0 8px; flex: 1">$1</div>', "/<blockquote.*?>(.*?)<\/blockquote>/is" => '<blockquote style="position: relative;padding: 16px;border-radius: 6px;font-style: normal; background: #f6f6f6; margin: 0 0 16px 0">$1</blockquote>' ]; foreach ($generatorRules as $generatorRuleKey => $generatorRuleValue) { if (array_key_exists($generatorRuleKey, $rules)) { $rules[$generatorRuleKey] = $generatorRuleValue; } else { $rules += [$generatorRuleKey => $generatorRuleValue]; } } return $rules; } }
php
MIT
c616d27734c65eb87b470751928ff1119c535549
2026-01-05T05:12:01.604239Z
false