forked from slims/slims9_bulian
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://gitlab.com/slims/slims9_bulian into…
… develop
- Loading branch information
Showing
15 changed files
with
234 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
<?php | ||
/** | ||
* @Source by : Waris Agung Widodo ([email protected]) | ||
* @Created Date : 05/11/20 21.33 | ||
* @File name : plugins.php | ||
* @Modified by : Drajat Hasan ([email protected]) | ||
*/ | ||
|
||
use SLiMS\DB; | ||
use SLiMS\Migration\Runner; | ||
use SLiMS\Json; | ||
use SLiMS\Jquery; | ||
use SLiMS\Plugins; | ||
use SLiMS\Filesystems\Storage; | ||
use SLiMS\Parcel\Package; | ||
use SLiMS\Migration\Runner; | ||
use SLiMS\Filesystems\Storage; | ||
|
||
define('INDEX_AUTH', 1); | ||
|
||
|
@@ -14,6 +22,7 @@ | |
require SB . 'admin/default/session_check.inc.php'; | ||
|
||
$plugins = Plugins::getInstance(); | ||
$upload_success = false; | ||
|
||
if (count($_POST) == 0) $_POST = json_decode(file_get_contents('php://input'), true); | ||
|
||
|
@@ -53,7 +62,7 @@ | |
if (dirname($plugin->path) == $pluginPath) return true; | ||
})); | ||
}); | ||
|
||
$upload_success = true; | ||
} | ||
else | ||
{ | ||
|
@@ -107,27 +116,20 @@ | |
|
||
$run = $query->execute(); | ||
|
||
if ($run) { | ||
if (isset($_POST['format'])) echo json_encode(['status' => true, 'message' => $message]); | ||
} else { | ||
if (isset($_POST['format'])) echo json_encode(['status' => false, 'message' => DB::getInstance()->errorInfo()]); | ||
} | ||
if (!$run) $message = __('Something error : turn on development mode to get more information'); | ||
|
||
if (!isset($_POST['format'])) { | ||
$message = toastr($run == false ? DB::getInstance()->errorInfo() : $message); | ||
if ($run == false) $message->error(); | ||
else $message->success(); | ||
} | ||
if (isset($_POST['format'])) echo Json::stringify(['status' => (bool)$run, 'message' => $message])->withHeader(); | ||
else toastr($message . ' 1')->{($run === false ? 'error' : 'success')}; | ||
|
||
} catch (Exception $exception) { | ||
if (isset($_POST['format'])) echo json_encode(['status' => false, 'message' => $exception->getMessage()]); | ||
else toastr($exception->getMessage())->error(); | ||
if (isset($_POST['format'])) echo Json::stringify(['status' => false, 'message' => $exception->getMessage()])->withHeader(); | ||
else toastr($exception->getMessage() . ' 2')->error(); | ||
} | ||
|
||
// redirect content | ||
if ($upload_success) { | ||
Jquery::raw('colorbox.close()'); | ||
redirect()->simbioAJAX(AWB . 'modules/system/plugins.php'); | ||
} | ||
exit(); | ||
} | ||
|
||
// if (isset($_POST['upload'])) { | ||
|
||
// exit; | ||
// } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
<?php | ||
/** | ||
* @author Drajat Hasan | ||
* @email [email protected] | ||
* @create date 2023-06-06 05:39:26 | ||
* @modify date 2023-06-06 15:59:35 | ||
* @license GPLv3 | ||
* @desc [description] | ||
*/ | ||
namespace SLiMS; | ||
|
||
use Closure; | ||
|
||
class Jquery | ||
{ | ||
private static ?object $instance = null; | ||
private string $mainSelector = ''; | ||
private string $result = ''; | ||
private string $contents = ''; | ||
public string $position = 'top.'; | ||
|
||
private function __construct(){} | ||
|
||
public static function getInstance(string $mainSelector) | ||
{ | ||
if (is_null(self::$instance)) self::$instance = new Jquery; | ||
self::$instance->mainSelector = $mainSelector; | ||
return self::$instance; | ||
} | ||
|
||
public static function raw(string $content) | ||
{ | ||
$instance = self::getInstance(''); | ||
$instance->contents = $instance->position . 'jQuery.' . $content; | ||
echo $instance; | ||
$instance->contents = ''; | ||
} | ||
|
||
public function writeIfExists(string $contents):void | ||
{ | ||
$position = $this->position; | ||
$message = isDev() ? "alert('jQuery not exists!')" : "console.log('jQuery not exists!')"; | ||
$this->result = <<<HTML | ||
<script type="text/javascript"> | ||
if (typeof {$position}\$ === 'function') { | ||
{$position}\$(document).ready(function(){ | ||
{$contents} | ||
}) | ||
} else { {$message} } | ||
</script> | ||
HTML; | ||
} | ||
|
||
public function delayIn(int $timeout) | ||
{ | ||
$contents = $this->contents; | ||
$this->contents = ''; | ||
$this->setContent(<<<HTML | ||
setTimeout(() => {$contents}, {$timeout}) | ||
HTML); | ||
return $this; | ||
} | ||
|
||
public function on(string $selector, string $eventListener, Closure|string $contents) | ||
{ | ||
$position = $this->position; | ||
$mainSelector = $this->mainSelector; | ||
$this->setContent(<<<HTML | ||
{$position}\$('{$mainSelector}').on('{$eventListener}', '{$selector}', function(e){ | ||
{$contents} | ||
}) | ||
HTML); | ||
} | ||
|
||
public function getContents() | ||
{ | ||
return $this->contents; | ||
} | ||
|
||
public function getResult() | ||
{ | ||
return $this->result; | ||
} | ||
|
||
public function setPosition(string $position) | ||
{ | ||
$this->position = $position; | ||
return $this; | ||
} | ||
|
||
private function setContent(string $content) | ||
{ | ||
$this->contents .= $content . PHP_EOL; | ||
} | ||
|
||
|
||
public function __call($method, $parameters) | ||
{ | ||
if (!method_exists($this, $method)) { | ||
$mainSelector = $this->mainSelector; | ||
$position = $this->position; | ||
|
||
if (count($parameters) === 1 && is_callable($parameters[0])) | ||
{ | ||
$contents = <<<HTML | ||
function(e) { | ||
{$parameters[0]()} | ||
} | ||
HTML; | ||
} else if (count($parameters) === 1 && substr($parameters[0], 0,1) === "'") { | ||
$contents = $parameters[0]; | ||
} else { | ||
$contents = "'" . implode(',', $parameters) . "'"; | ||
} | ||
|
||
$this->setContent(<<<HTML | ||
{$position}\$('{$mainSelector}').{$method}({$contents}) | ||
HTML); | ||
|
||
return $this; | ||
} | ||
} | ||
|
||
public function __toString():String | ||
{ | ||
$this->writeIfExists($this->contents); | ||
return $this->getResult(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* @author Drajat Hasan | ||
* @email [email protected] | ||
* @create date 2022-10-06 22:44:30 | ||
* @modify date 2022-11-12 05:27:50 | ||
* @modify date 2023-06-04 06:20:36 | ||
* @license GPLv3 | ||
* @desc [description] | ||
*/ | ||
|
@@ -51,6 +51,7 @@ private function __construct() | |
//Recipients | ||
$this->setFrom($mail['from'], $mail['from_name']); | ||
$this->addReplyTo($mail['reply_to'], $mail['reply_to_name']); | ||
$this->charSet($mail['charset']??'UTF-8'); | ||
} | ||
|
||
public static function getInstance() | ||
|
@@ -85,6 +86,17 @@ public function subject(string $mailObject) | |
return $this; | ||
} | ||
|
||
/** | ||
* Set content charset | ||
* | ||
* @param string $charSet | ||
* @return void | ||
*/ | ||
public function charSet(string $charSet) | ||
{ | ||
$this->CharSet = $charSet; | ||
} | ||
|
||
/** | ||
* Set plain message without html format | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* @author Drajat Hasan | ||
* @email [email protected] | ||
* @create date 2023-04-06 07:59:09 | ||
* @modify date 2023-04-06 13:36:54 | ||
* @modify date 2023-06-06 05:35:28 | ||
* @license GPLv3 | ||
* @desc [description] | ||
*/ | ||
|
@@ -92,4 +92,9 @@ public function getIterator(): \Traversable | |
{ | ||
return new \ArrayIterator($this->packages); | ||
} | ||
|
||
public static function getError() | ||
{ | ||
return self::getInstance()->error; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.