upgrade all with dice compatible
This commit is contained in:
+6
-6
@@ -6,9 +6,9 @@
|
||||
Desc. : Class pembuatan file CSV
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : April 2rd, 2011.
|
||||
Last Modified : July 25th, 2026.
|
||||
Last Modified : August 21st, 2026.
|
||||
|
||||
(c) 2011 - 2026, 3FONIA Software; WWW.3FONIA.COM.
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
@@ -23,11 +23,11 @@ final class CSV {
|
||||
private $__avalue = [];
|
||||
private $__atabel = [];
|
||||
|
||||
public function add_field($tnama="", $ffunc="") {
|
||||
$this->__atabel[] = [$tnama, $ffunc];
|
||||
public function add_field(string $nama, string $func=""): void {
|
||||
$this->__atabel[] = [ $nama, $func ];
|
||||
}
|
||||
|
||||
public function add_value() {
|
||||
public function add_value(): void {
|
||||
$tmp_arr = func_get_args();
|
||||
if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0];
|
||||
$tmp_out = "";
|
||||
@@ -44,7 +44,7 @@ final class CSV {
|
||||
$this->__avalue[] = $tmp_out;
|
||||
}
|
||||
|
||||
public function download($nama_file="export.csv") {
|
||||
public function download(string $nama_file="export.csv"): void {
|
||||
$out = ""; $tmp_out = "";
|
||||
// add header
|
||||
for ($i=0; $i<count($this->__atabel); $i++) {
|
||||
|
||||
+32
-26
@@ -6,21 +6,21 @@
|
||||
Desc. : Class cache css dan js aplikasi
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : March 16th, 2008.
|
||||
Last Modified : August 19th, 2026.
|
||||
Last Modified : August 21st, 2026.
|
||||
|
||||
(c) 2008 - 2026, 3FONIA Software; WWW.3FONIA.COM.
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
//OK
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Data;
|
||||
|
||||
use flight\Engine;
|
||||
use FilesystemIterator;
|
||||
use MatthiasMullie\Minify;
|
||||
use SplFileInfo;
|
||||
use \flight\Engine;
|
||||
use \flight\Session;
|
||||
use \FilesystemIterator;
|
||||
use \MatthiasMullie\Minify;
|
||||
use \SplFileInfo;
|
||||
|
||||
final class Cache {
|
||||
private $__cachedir = "";
|
||||
@@ -31,15 +31,16 @@ final class Cache {
|
||||
private $__rootdir = "";
|
||||
private $__ini = [];
|
||||
protected Engine $app;
|
||||
protected Session $session;
|
||||
protected array $__asset = [];
|
||||
|
||||
public function __construct(?Engine $app = null, array $asset = []) {
|
||||
$this->app = (empty($app) === true) ? Flight::app() : $app;
|
||||
$this->__asset = $asset;
|
||||
$rootdir = (defined('PROJECT_ROOT')) ? PROJECT_ROOT : $this->app->get('flight.root_dir');
|
||||
public function __construct(Engine $app, Session $session) {
|
||||
$this->app = $app;
|
||||
$this->session = $session;
|
||||
$rootdir = (defined('PROJECT_ROOT')) ? PROJECT_ROOT : $this->app->get('app.project_root');
|
||||
$this->__cachedir = $rootdir . '/public/chunks/';
|
||||
$this->__localedir = $rootdir . '/app/locale/';
|
||||
$this->__jsapp = $rootdir . '/app/scripts/';
|
||||
$this->__localedir = $rootdir . '/app/Scripts/locale/';
|
||||
$this->__jsapp = $rootdir . '/app/Scripts/';
|
||||
$this->__cssdir = __DIR__ . '/../../assets/css/';
|
||||
$this->__jsdir = __DIR__ . '/../../assets/js/';
|
||||
$this->__rootdir = $rootdir . '/';
|
||||
@@ -54,7 +55,11 @@ final class Cache {
|
||||
} else $this->__ini = parse_ini_file($this->__cachedir . "cache.ini", true);
|
||||
}
|
||||
|
||||
private function gen_file($mode = "index", $type = "css") {
|
||||
public function set_asset(array $asset = []): void {
|
||||
$this->__asset = $asset;
|
||||
}
|
||||
|
||||
private function gen_file(string $mode = "index", string $type = "css"): array {
|
||||
$itime = 0;
|
||||
$afile = [];
|
||||
if ($type == "css") {
|
||||
@@ -65,8 +70,8 @@ final class Cache {
|
||||
$afile[] = $_file->getRealPath();
|
||||
$itime += $_file->getMTime();
|
||||
}
|
||||
if (is_dir($this->__rootdir . 'app/css/')) {
|
||||
$iterator = new FilesystemIterator($this->__rootdir . 'app/css/', FilesystemIterator::SKIP_DOTS);
|
||||
if (is_dir($this->__rootdir . 'app/Styles/')) {
|
||||
$iterator = new FilesystemIterator($this->__rootdir . 'app/Styles/', FilesystemIterator::SKIP_DOTS);
|
||||
foreach ($iterator as $_file) {
|
||||
if ($_file->isFile()) {
|
||||
$afile[] = $_file->getRealPath();
|
||||
@@ -83,7 +88,7 @@ final class Cache {
|
||||
$itime += $_file->getMTime();
|
||||
}
|
||||
// add locale file
|
||||
$ljs = ($this->app->session()->get('__WEB_USER')['LOCALE'] ?? $this->app->session()->get('__WEB_APP')['DEF_LOCALE']).'.js';
|
||||
$ljs = ($this->session->get('__WEB_USER')['LOCALE'] ?? $this->session->get('__WEB_APP')['DEF_LOCALE']).'.js';
|
||||
if (is_dir($this->__localedir)) {
|
||||
$iterator = new \FilesystemIterator($this->__localedir, \FilesystemIterator::SKIP_DOTS);
|
||||
foreach ($iterator as $_file) {
|
||||
@@ -97,7 +102,8 @@ final class Cache {
|
||||
if ($mode === 'index') {
|
||||
if (is_dir($this->__jsapp)) {
|
||||
$dirIterator = new \RecursiveDirectoryIterator($this->__jsapp, \RecursiveDirectoryIterator::SKIP_DOTS);
|
||||
$iterator = new \RecursiveIteratorIterator($dirIterator);
|
||||
$dirFilter = new \RecursiveCallbackFilterIterator($dirIterator, fn($curr, $key, $iter) => !($curr->isDir() && in_array($curr->getFilename(), ['locale'])));
|
||||
$iterator = new \RecursiveIteratorIterator($dirFilter);
|
||||
foreach ($iterator as $_file) {
|
||||
if ($_file->isFile() && !in_array($_file->getFilename(), ['login.js','display.js'])) {
|
||||
$afile[] = $_file->getRealPath();
|
||||
@@ -116,7 +122,7 @@ final class Cache {
|
||||
return [ $afile, $itime ];
|
||||
}
|
||||
|
||||
private function create_cache($type = "css", $afile = [], $cachefile = "") {
|
||||
private function create_cache(string $type = "css", array $afile = [], string $cachefile = ""): void {
|
||||
$contents = ''; $smini = null;
|
||||
$bpublic = ($this->app->request()->ip === '127.0.0.1') ? false : true;
|
||||
if ($bpublic == true) {
|
||||
@@ -139,7 +145,7 @@ final class Cache {
|
||||
file_put_contents($this->__cachedir . $cachefile, $contents);
|
||||
}
|
||||
|
||||
private function save_ini() {
|
||||
private function save_ini(): void {
|
||||
$content = "";
|
||||
foreach ($this->__ini as $key => $elem) {
|
||||
$content .= ($content==""?"":"\n"). "[".$key."]\n";
|
||||
@@ -151,7 +157,7 @@ final class Cache {
|
||||
file_put_contents($this->__cachedir . "cache.ini", $content);
|
||||
}
|
||||
|
||||
public function Cache($mode = "index") {
|
||||
public function Cache(string $mode = "index"): array {
|
||||
$is_modif = false;
|
||||
foreach (['css','js','app'] as $type) {
|
||||
[ $afile, $lastmod ] = $this->gen_file($mode, $type);
|
||||
@@ -174,17 +180,17 @@ final class Cache {
|
||||
}
|
||||
}
|
||||
|
||||
$session = $this->app->session();
|
||||
$aoption = $session->get('__WEB_APP');
|
||||
$auser = $session->get('__WEB_USER');
|
||||
$aoption = $this->session->get('__WEB_APP');
|
||||
$auser = $this->session->get('__WEB_USER');
|
||||
$nonce = $this->app->get('csp_nonce');
|
||||
$islog = user_logged($this->session);
|
||||
$_secret = $aoption['APP_CODE'] .";". $aoption['APP_SID'] .";". $this->app->request()->getVar('HTTP_HOST') .";". "http://".$this->app->request()->getVar('HTTP_HOST') .";". isMobile() .";". ($aoption['AUTH_LEVEL']?$aoption['AUTH_LEVEL']:0);
|
||||
$_suser = (user_logged()) ? $auser['Username'] .";". $auser['UserID'] .";". $auser['Grup_MenuID'] .";". $auser['Level'] : "nobody;999;999;9";
|
||||
$_suser = ($islog) ? $auser['Username'] .";". $auser['UserID'] .";". $auser['Grup_MenuID'] .";". $auser['Level'] : "nobody;999;999;9";
|
||||
|
||||
$acache['JSX'][] = '<script nonce="'.$nonce.'" type="text/javascript">';
|
||||
$acache['JSX'][] = 'FoniaJS.setConfig("'.base64_encode($_secret).'", "'.base64_encode($_suser).'");';
|
||||
$acache['JSX'][] = '$(document).ready(function(){';
|
||||
if (user_logged()) $acache['JSX'][] = 'FoniaJS.loadMenu();';
|
||||
if ($islog) $acache['JSX'][] = 'FoniaJS.loadMenu();';
|
||||
$acache['JSX'][] = '});';
|
||||
$acache['JSX'][] = '</script>';
|
||||
|
||||
|
||||
+38
-33
@@ -6,9 +6,9 @@
|
||||
Desc. : Class pembuatan file PDF
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : April 18th, 2015.
|
||||
Last Modified : July 25th, 2026.
|
||||
Last Modified : August 21st, 2026.
|
||||
|
||||
(c) 2015 - 2026, 3FONIA Software; WWW.3FONIA.COM.
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
@@ -16,22 +16,27 @@ declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Data;
|
||||
|
||||
use Mpdf;
|
||||
use \flight\Session;
|
||||
use \Mpdf;
|
||||
|
||||
final class PDF {
|
||||
private $__avalue = [];
|
||||
private $__atabel = [];
|
||||
private $__theader = "";
|
||||
private $__tcolname = "";
|
||||
protected array $webapp;
|
||||
protected array $webuser;
|
||||
|
||||
public function __construct() {
|
||||
public function __construct(Session $session) {
|
||||
$this->webapp = $session->get('__WEB_APP', ['REG_NAME'=>'', 'APP_NAME'=>'', 'APP_VER'=>'']);
|
||||
$this->webuser = $session->get('__WEB_USER', ['UserID'=>0, 'Username'=>'']);
|
||||
}
|
||||
|
||||
public function add_field($tnama="", $nlebar=0, $talign="L", $ffunc="", $nkol=1) {
|
||||
$this->__atabel[] = array($tnama, $nlebar.'%', $ffunc, $talign, $nkol);
|
||||
public function add_field(string $nama, string|int $lebar=0, string $align="L", string $func="", int $kol=1): void {
|
||||
$this->__atabel[] = [ $nama, (string)$lebar.'%', $func, $align, $kol ];
|
||||
}
|
||||
|
||||
public function show_fields() {
|
||||
public function show_fields(): void {
|
||||
$tmp_out = "<thead><tr>";
|
||||
for ($i=0; $i<count($this->__atabel); $i++) {
|
||||
if ($this->__atabel[$i][4]==0) continue;
|
||||
@@ -41,21 +46,21 @@ final class PDF {
|
||||
$this->__tcolname = $tmp_out;
|
||||
}
|
||||
|
||||
public function clear() {
|
||||
public function clear(): void {
|
||||
$this->__avalue = [];
|
||||
$this->__theader = "";
|
||||
$this->__tcolname = "";
|
||||
}
|
||||
|
||||
public function set_header($tlapor="", $tperiod="") {
|
||||
$thasil = '<div style="text-align:center;font-size:12pt;"><b>'.strtoupper($_SESSION['__WEB_APP']['REG_NAME']);
|
||||
$thasil .= (($tlapor=="") ? "" : '<br>'.$tlapor) . '</b>';
|
||||
$thasil .= ($tperiod=="") ? "" : '<br><span style="font-size:11pt;">'.$tperiod.'</span>';
|
||||
public function set_header(string $lapor, string $period): void {
|
||||
$thasil = '<div style="text-align:center;font-size:12pt;"><b>'.strtoupper($this->webapp['REG_NAME']);
|
||||
$thasil .= (($lapor=="") ? "" : '<br>'.$lapor) . '</b>';
|
||||
$thasil .= ($period=="") ? "" : '<br><span style="font-size:11pt;">'.$period.'</span>';
|
||||
$thasil .= '</div><br>';
|
||||
$this->__theader = $thasil;
|
||||
}
|
||||
|
||||
public function add_value() {
|
||||
public function add_value(): void {
|
||||
$tmp_arr = func_get_args();
|
||||
if (is_array($tmp_arr[0])) $tmp_arr = $tmp_arr[0];
|
||||
$tmp_out = "<tr>";
|
||||
@@ -73,7 +78,7 @@ final class PDF {
|
||||
$this->__avalue[] = $tmp_out;
|
||||
}
|
||||
|
||||
public function add_span() {
|
||||
public function add_span(): void {
|
||||
$tmp_arr = func_get_args();
|
||||
$tmp_out = "<tr>";
|
||||
for ($i=0; $i<count($tmp_arr); $i++) {
|
||||
@@ -88,19 +93,19 @@ final class PDF {
|
||||
$this->__avalue[] = $tmp_out;
|
||||
}
|
||||
|
||||
public function add_empty() {
|
||||
public function add_empty(): void {
|
||||
$this->__avalue[] = $this->set_align(" ", 0, "L,NB", true);
|
||||
}
|
||||
|
||||
public function add_stamp($ctk_ke=1, $bnama=false) {
|
||||
$this->__avalue[] = $this->set_align($_SESSION['__WEB_APP']['APP_NAME']."v".$_SESSION['__WEB_APP']['APP_VER'].date("\@ymd.His")."-".user_id(3).(($bnama==true)?"/".strtoupper(user_user()):"").(($ctk_ke>0)?"#".isi_nol($ctk_ke,2):""), 0, "L,NB", true);
|
||||
public function add_stamp(int $ctk_ke=1, bool $tampil_nama=false): void {
|
||||
$this->__avalue[] = $this->set_align($this->get_stamp($ctk_ke, $tampil_nama), 0, "L,NB", true);
|
||||
}
|
||||
|
||||
public function get_stamp($ctk_ke=1, $bnama=false) {
|
||||
return $_SESSION['__WEB_APP']['APP_NAME']."v".$_SESSION['__WEB_APP']['APP_VER'].date("\@ymd.His")."-".user_id(3).(($bnama==true)?"/".strtoupper(user_user()):"").(($ctk_ke>0)?"#".isi_nol($ctk_ke,2):"");
|
||||
public function get_stamp(int $ctk_ke=1, bool $tampil_nama=false): string {
|
||||
return $this->webapp['APP_NAME']."v".$this->webapp['APP_VER'].date("\@ymd.His")."-".isi_nol($this->webuser['UserID'], 3).(($tampil_nama)?"/".strtoupper($this->webuser['Username']):"").(($ctk_ke>0)?"#".isi_nol($ctk_ke,2):"");
|
||||
}
|
||||
|
||||
public function createPDF($nama_file = "Nama_File.pdf", $nfontz = 8, $orien = "P") {
|
||||
public function createPDF(string $nama_file = "Nama_File.pdf", int $fontz = 8, string $orien = "P"): void {
|
||||
$html = '
|
||||
<style>
|
||||
#pdf_area {
|
||||
@@ -148,33 +153,33 @@ final class PDF {
|
||||
$html .= $this->__avalue[$i];
|
||||
}
|
||||
$html .= '</tbody></table></div></div></body>';
|
||||
$mpdf = new mPDF('c', 'A4'.($orien=="L"?"-L":""), $nfontz, '', 5, 5, 5, 10, 5, 5);
|
||||
$mpdf = new mPDF('c', 'A4'.($orien==="L"?"-L":""), $fontz, '', 5, 5, 5, 10, 5, 5);
|
||||
$mpdf->useSubstitutions = false;
|
||||
$mpdf->WriteHTML($html);
|
||||
$mpdf->Output($nama_file.".pdf", "I");
|
||||
}
|
||||
|
||||
public function set_align($ttext, $nlen, $tdir="L", $bline=false, $bhead=false, $ncol=1) {
|
||||
$tstyle = $this->create_style($tdir);
|
||||
if (strpos(strtolower($ttext), "<tr>")===false) { //jika tidak ada <tr> up 2011-04-14
|
||||
if ($bline===true) {
|
||||
return '<tr><td colspan="'.count($this->__atabel).'" class="'.$tstyle.'">'.$ttext."</td></tr>";
|
||||
public function set_align(string $text, string|int $width, string $dir="L", bool $line=false, bool $head=false, int $col=1): string {
|
||||
$tstyle = $this->create_style($dir);
|
||||
if (strpos(strtolower($text), "<tr>")===false) {
|
||||
if ($line===true) {
|
||||
return '<tr><td colspan="'.count($this->__atabel).'" class="'.$tstyle.'">'.$text."</td></tr>";
|
||||
} else {
|
||||
return (($bhead===true)?"<th":"<td").(($ncol>1)?' colspan="'.$ncol.'"':"").' class="'.$tstyle.'" '.(($bhead===true)?'width="'.$nlen.'"':"").">".$ttext.(($bhead===true)?"</th>":"</td>");
|
||||
return (($head===true)?"<th":"<td").(($col>1)?' colspan="'.(string)$col.'"':"").' class="'.$tstyle.'" '.(($head===true)?'width="'.(string)$width.'"':"").">".$text.(($head===true)?"</th>":"</td>");
|
||||
}
|
||||
} else {
|
||||
return (($bline===true) ? $ttext : (($bhead===true)?"<th":"<td").(($ncol>1)?" colspan=\"".$ncol."\"":"")." class=\"".$tstyle." \" ".(($bhead===true)?"width=\"".$nlen."\"":"").">".$ttext.(($bhead===true)?"</th>":"</td>"));
|
||||
return (($line===true) ? $text : (($head===true)?"<th":"<td").(($col>1)?" colspan=\"".(string)$col."\"":"")." class=\"".$tstyle." \" ".(($head===true)?"width=\"".(string)$width."\"":"").">".$text.(($head===true)?"</th>":"</td>"));
|
||||
}
|
||||
}
|
||||
|
||||
private function create_style($tstyle="L") {
|
||||
private function create_style(string $style="L"): string {
|
||||
$apad = ["L"=>"left", "R"=>"right", "C"=>"center", "NB"=>"nb", "NL"=>"noleft", "NR"=>"noright", "B"=>"bold", "I"=>"italic"];
|
||||
$_astyle = explode(",", $tstyle);
|
||||
$thasil = "";
|
||||
$_astyle = explode(",", $style);
|
||||
$ahasil = [];
|
||||
foreach ($_astyle as $_key => $_val) {
|
||||
$thasil .= " ".$apad[$_val];
|
||||
$ahasil[] = $apad[$_val];
|
||||
}
|
||||
return substr($thasil,1);
|
||||
return implode(' ', $ahasil);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,10 +8,11 @@
|
||||
Created Date : November 18th, 2012.
|
||||
Last Modified : September 30th, 2025.
|
||||
|
||||
(c) 2012 - 2025, 3FONIA Software; WWW.3FONIA.COM.
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
//todo: deprecated
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Data;
|
||||
|
||||
+2
-1
@@ -8,10 +8,11 @@
|
||||
Created Date : November 18th, 2012.
|
||||
Last Modified : October 26th, 2023.
|
||||
|
||||
(c) 2012 - 2023, 3FONIA Software; WWW.3FONIA.COM.
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
//todo: deprecated
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace siaupheng\webapp\Data;
|
||||
|
||||
Reference in New Issue
Block a user