function js($path, $fileName = '') { $result = ""; if (empty($fileName)) { $temp = removeMultiple(baseUrl() . "/Resources/" . $path); return removeMultiple('<script type="text/javascript" src="' . $temp . '"></script>') . PHP_EOL; } else { if (is_array($fileName)) { foreach ($fileName as $file) { $temp = removeMultiple(baseUrl() . "/Resources/" . $path . "/" . $file); $result .= '<script type="text/javascript" src="' . $temp . '"></script>' . PHP_EOL; } return $result; } else { $temp = removeMultiple(baseUrl() . "/Resources/" . $path . '/' . $fileName); return removeMultiple('<script type="text/javascript" src="' . $temp . '"></script>') . PHP_EOL; } } }
private static function setRoute($method, $url, $controller) { $arrController = array(); if (!is_array($controller)) { $arrController['Controller'] = $controller; $arrController['Name'] = $controller; } else { $arrController = $controller; } $ctrl = explode('@', $arrController['Controller']); $routeProperties = ['Controller' => $ctrl[0], 'Action' => $ctrl[1], 'Middleware' => self::$middleware]; $route = ['Url' => removeMultiple(self::$prefixUrl . $url), 'Method' => $method, 'Name' => $arrController['Name'], 'Properties' => $routeProperties]; switch ($method) { case 'GET': array_push(self::$routesGet, $route); break; case 'POST': array_push(self::$routesPost, $route); break; case 'PUT': array_push(self::$routesPut, $route); break; case 'DELETE': array_push(self::$routesDelete, $route); break; default: // code... break; } }
/** * Membuat gambar thumbnial dari file yang diupload * @param string $destination folder tujuan * @param string $preffix penambahakn awalan pada nama file yang akan disimpan * @param int $width lebar gambar * @param int $height tinggi gambar */ public static function makeThumbnail($destination, $preffix = '', $width = null, $height = null) { if (empty(self::$tmpPath)) { trigger_error("Can not create thumbnails, the file you uploaded must be an image", E_USER_ERROR); } $img = Image::make(self::$tmpPath); if (!is_null($width) && !is_null($height)) { $img->resize($width, $height); } else { if (!is_null($width) && is_null($height)) { $img->resize($width, null, function ($constraint) { $constraint->aspectRatio(); }); } else { if (!is_null($height) && is_null($width)) { $img->resize(null, $height, function ($constraint) { $constraint->aspectRatio(); }); } } } $pathParts = pathinfo(removeMultiple($destination . "/" . self::$name)); $img->save(removeMultiple($destination . "/" . $preffix . $pathParts['filename'] . "." . $pathParts['extension'])); return new self(); }
function redirect($url) { if (!filter_var($url, FILTER_VALIDATE_URL)) { $url = baseUrl() . "/" . $url; } header("location: " . removeMultiple($url)); }
/** * Mendapatkan file dan juga path cache * @param string $key */ private static function getCacheFile($key) { $config = Config::get("Cache", "Configuration"); $directory = removeMultiple($config['File']['Path']); $fileName = $config['File']['EncryptFileName'] ? md5($key) : $key; return removeMultiple($directory . "/" . $fileName . ".cache"); }