How to use getController method of file class

Best Atoum code snippet using file.getController

Application.php

Source:Application.php Github

copy

Full Screen

...20 return true;21 }22 return false;23 }24 static function getController() {25 return self::$controller;26 }27 static function setController($nameController) {28 return self::$controller = $nameController;29 }30 static function getModule() {31 return self::$module;32 }33 static function setgetModule($nameModule) {34 return self::$module = $nameModule;35 }36 static function getAction() {37 return self::$action;38 }39 static function setAction($Action) {40 return self::$action = $Action;41 }42 static function getParam() {43 if (self::$params) {44 foreach (self::$params as $v => $param) {45 self::$params[$v] = self::BokyTuDacBietPaRam(self::$params[$v]);46 }47 return self::$params;48 } else {49 return FALSE;50 }51 }52 function setThongBao($ThongBao) {53 return $_SESSION["ThongBao"] = $ThongBao;54 }55 function setParam($params) {56 $Param = $this->getParam();57 if ($Param) {58 $a1[] = $params;59 $Param = array_merge($a1, $Param);60 } else {61 $Param[] = $params;62 }63 self::$params = $Param;64 }65 function unsetThongBao() {66 unset($_SESSION['ThongBao']);67 }68 function getThongBao() {69 $ThongBao = isset($_SESSION["ThongBao"]) ? $_SESSION["ThongBao"] : FALSE;70 $this->unsetThongBao();71 return $ThongBao;72 }73 static function getLang() {74 return self::$lang;75 }76 public function loi404() {77 header("Location: " . BASE_DIR . "index/loi404");78 }79// kiểm tra các thành phần80 function KiemTraText($text) {81 $text = strip_tags($text);82 return $text;83 }84 function KiemTraURL($url) {85 if (!filter_var($url, FILTER_VALIDATE_URL) === false) {86 return TRUE;87 } else {88 return FALSE;89 }90 }91 function upload_image($file, $extension, $folder, $newname = '') {92 if (isset($_FILES[$file]) && !$_FILES[$file]['error']) {93// $ext = end(explode('.', $_FILES[$file]['name']));94 $ext = trim(substr($_FILES[$file]["type"], 6, strlen($_FILES[$file]["type"])));95// $ext = $ext[1];96 $name = basename($_FILES[$file]['name'], '.' . $ext);97 if (strpos($extension, $ext) === false) {98 alert('Chỉ hỗ trợ upload file dạng ' . $extension);99 return false; // không hỗ trợ100 }101 if ($newname == '' && file_exists($folder . $_FILES[$file]['name']))102 for ($i = 0; $i < 100; $i++) {103 if (!file_exists($folder . $name . $i . '.' . $ext)) {104 $_FILES[$file]['name'] = $name . $i . '.' . $ext;105 break;106 }107 } else {108 $_FILES[$file]['name'] = $newname . '.' . $ext;109 }110 if (!copy($_FILES[$file]["tmp_name"], $folder . $_FILES[$file]['name'])) {111 if (!move_uploaded_file($_FILES[$file]["tmp_name"], $folder . $_FILES[$file]['name'])) {112 return false;113 }114 }115 return $_FILES[$file]['name'];116 }117 return false;118 }119 public function KiemTraFileHinh($Hinh, $size, $nameHinh, $path) {120 if (($Hinh["type"] == "image/gif") ||121 ($Hinh["type"] == "image/jpeg") ||122 ($Hinh["type"] == "image/jpg") ||123 ($Hinh["type"] == "image/png") &&124 $Hinh['size'] < $size125 ) {126 $typeHinh = explode('/', $Hinh['type']);127 $typeHinh = end($typeHinh);128 $pypath = $path . $nameHinh . "." . $typeHinh;129// là hinh thì làm cái gì130 if (copy($Hinh["tmp_name"], $pypath)) {131 if (move_uploaded_file($Hinh["tmp_name"], $pypath)) {132 return $nameHinh . "." . trim(substr($Hinh["type"], 6, strlen($Hinh["type"])));133 } else {134 return FALSE;135 }136 }137// return "." . trim(substr($Hinh["type"], 6, strlen($Hinh["type"])));138 } else {139 return FALSE;140 }141 }142 function getKhachHang() {143 return $_SESSION[KhachHang];144 }145 function KiemTraEmai($email) {146// $regule = '/^[^\W][a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\@[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)*\.[a-zA-Z]{2,4}$/';147 return filter_var($email, FILTER_VALIDATE_EMAIL);148 }149 function KiemTraPhone($Phone) {150 if (preg_match("/^[0-9]{10,11}$/", $Phone)) {151 return $Phone;152 }153 return FALSE;154 }155// dành cho các chuan thuan156 function BokyTuDacBiet($str) {157 if (!empty($str)) {158 $kytu = array("select", "delete", "<script>", "</script>", "insert", "update");159 foreach ($kytu as $k => $v) {160 $str = str_replace($v, "/" . $v, $str);161 }162 return $str;163 } else {164 return FALSE;165 }166 }167 static function BokyTuDacBietPaRam($str) {168 if (!empty($str)) {169 $str = addslashes($str);170 $str = htmlspecialchars($str);171 $kytu = array(";", "select", "delete", "insert", "update");172 foreach ($kytu as $k => $v) {173 $str = str_replace($v, "", $str);174 }175 return $str;176 } else {177 return FALSE;178 }179 }180 function ViewC($data, $CName = "index") {181 $_Controller = $this->getController();182 $_Action = $this->getAction();183 if (!method_exists("Controller_" . $_Controller, $_Action)) {184 $_Action = "index";185 }186 $_Lang = $this->getLang();187 $_Param = $this->getParam();188 $Content = __DIR__ . "/View/{$_Controller}/{$_Action}.phtml";189 $layout = "View/{$CName}/layout/{$CName}_layout.phtml";190 include_once $layout;191 }192 function ViewData($data, $_Controller = "index", $_Action = "index") {193 $_Lang = $this->getLang();194 $_Param = $this->getParam();195 $Content = __DIR__ . "/View/{$_Controller}/{$_Action}.phtml";196 $layout = "View/{$_Controller}/layout/{$_Action}_layout.phtml";197 include_once $layout;198 }199// view trang we200 function View($data) {201 if ($this->getController() == "") {202 $this->controller = "index";203 }204 if ($this->getAction() == "") {205 $this->action = "index";206 }207 $_Controller = $this->getController();208 $_Action = $this->getAction();209 $_Lang = $this->getLang();210 $_Param = $this->getParam();211 if (class_exists("Controller_" . $_Controller, TRUE)) {212 if (method_exists("Controller_" . $_Controller, $_Action)) {213 $Content = __DIR__ . "/View/" . $this->getController() . "/" . $this->getAction() . ".phtml";214 } else {215 $Content = __DIR__ . "/View/" . $this->getController() . "/index.phtml";216 }217 } else {218 $Content = __DIR__ . "/View/index/index.phtml";219 }220 $layout = "View/layout/layout.phtml";221 include_once $layout;222 }223 function ViewTemplate($data) {224 if ($this->getController() == "") {225 $this->controller = "index";226 }227 if ($this->getAction() == "") {228 $this->action = "index";229 }230 $_Controller = $this->getController();231 $_Action = $this->getAction();232 $_Lang = $this->getLang();233 $_Param = $this->getParam();234 if (method_exists("Controller_" . $_Controller, $_Action)) {235 $Content = __DIR__ . "/View/" . $this->getController() . "/" . $this->getAction() . ".phtml";236 } else {237 $Content = __DIR__ . "/View/" . $this->getController() . "/index.phtml";238 }239 $layout = "View/layout/layout.phtml";240 include_once $layout;241 }242 function TemplateView($data) {243 if ($this->getController() == "") {244 $this->controller = "index";245 }246 if ($this->getAction() == "") {247 $this->action = "index";248 }249 $_Controller = $this->getController();250 $_Action = $this->getAction();251 $_Lang = $this->getLang();252 $_Conten = __DIR__ . "/View/" . $this->getController() . "/" . $this->getAction() . ".phtml";253 $layout = __DIR__ . "/public/" . $this->getController() . "/layout/layout_" . $this->getController() . ".phtml";254 include_once $layout;255 }256 function tintucView($data) {257 if ($this->getController() == "") {258 $this->controller = "index";259 }260 if ($this->getAction() == "") {261 $this->action = "index";262 }263 $_Action = $this->getAction();264 $_Controller = $this->getController();265 $_Param = $this->getParam();266 $_Lang = $this->getLang();267 if (method_exists("Controller_" . $_Controller, $_Action)) {268// echo "có action";269 $Content = __DIR__ . "/View/" . $this->getController() . "/" . $this->getAction() . ".phtml";270 } else {271 $Content = __DIR__ . "/View/" . $this->getController() . "/index.phtml";272 }273 $layout = "View/layout/" . $this->getController() . "/layout.phtml";274 include_once $layout;275 }276 function controllerView($data) {277 if ($this->getController() == "") {278 $this->controller = "index";279 }280 if ($this->getAction() == "") {281 $this->action = "index";282 }283 $_Action = $this->getAction();284 $_Controller = $this->getController();285 $_Param = $this->getParam();286 $_Lang = $this->getLang();287 if (method_exists("Controller_" . $_Controller, $_Action)) {288// echo "có action";289 $Content = __DIR__ . "/View/" . $this->getController() . "/" . $this->getAction() . ".phtml";290 } else {291 $Content = __DIR__ . "/View/" . $this->getController() . "/index.phtml";292 }293 $layout = "View/layout/" . $this->getController() . "/layout.phtml";294 include_once $layout;295 }296 function ViewKhuyet($data) {297 if ($this->getController() == "") {298 $this->controller = "index";299 }300 if ($this->getAction() == "") {301 $this->action = "index";302 }303 $_Controller = $this->getController();304 $_Action = $this->getAction();305 $_Lang = $this->getLang();306 $_Param = $this->getParam();307 // tìm quản tri308 if (method_exists("Controller_" . $_Controller, $_Action)) {309// echo "có action";310 $Content = __DIR__ . "/View/" . $this->getController() . "/" . $this->getAction() . ".phtml";311 } else {312 $Content = __DIR__ . "/View/" . $this->getController() . "/index.phtml";313 }314 $layout = "View/layout_cuahang/macdinh/layout_cuahang.phtml";315 include_once $layout;316 }317 function ViewTheme($data = NULL, $theme = "", $themelayout = "") {318 $theme = $theme == "" ? Model_ViewTheme::get_viewthene() : $theme;319 $_Controller = $this->getController();320 $_Action = $this->getAction();321 $_Param = $this->getParam();322 if ($data) {323 if (is_array($data)) {324 extract($data);325 }326 }327 $Content = __DIR__ . "/theme/" . $theme . "/" . $_Controller . "/" . $_Action . ".phtml";328 if (http_response_code() >= 300) {329 $Content = __DIR__ . "/theme/" . $theme . "/index/loi404.phtml";330 }331 if ($themelayout == "") {332 $layout = "theme/" . $theme . "/" . "layout.phtml";333 } else {334 $themelayout = "_" . $themelayout;335 $layout = "theme/" . $theme . "/" . "layout{$themelayout}.phtml";336 }337 if (!is_file($layout)) {338// throw new Exception("Không Có Theme");339 }340 include_once $layout;341 }342 function ViewThemeModule($data = NULL, $theme = "", $themelayout = "") {343// echo __DIR__;344 if ($data) {345 if (is_array($data)) {346 extract($data);347 }348 }349 $theme = $theme == "" ? Model_ViewTheme::get_viewthene() : $theme;350 $_Controller = $this->getController();351 $_Action = $this->getAction();352 $_Param = $this->getParam();353 $Content = sprintf("%s/Module/%s/View/%s/%s.phtml", __DIR__, $this->getModule(), $this->getController(), $this->getAction());354 $themelayout = $themelayout == "" ? "" : "_" . $themelayout;355 $layout = "theme/" . $theme . "/" . "layout{$themelayout}.phtml";356 include_once $layout;357 }358 function ViewKhuyetIndex($data) {359 if ($this->getController() == "") {360 $this->controller = "index";361 }362 if ($this->getAction() == "") {363 $this->action = "index";364 }365 $_Controller = $this->getController();366 $_Action = $this->getAction();367 $_Lang = $this->getLang();368 $_Param = $this->getParam();369 // tìm quản tri370 if (method_exists("Controller_" . $_Controller, $_Action)) {371// echo "có action";372 $Content = __DIR__ . "/View/" . $this->getController() . "/" . $this->getAction() . ".phtml";373 } else {374 $Content = __DIR__ . "/View/" . $this->getController() . "/index.phtml";375 }376 $layout = "View/layout_cuahang/macdinh/layout_cuahang_index.phtml";377 include_once $layout;378 }379 function ViewMobie($data) {380 if ($this->getController() == "") {381 $this->controller = "index";382 }383 if ($this->getAction() == "") {384 $this->action = "index";385 }386 $_Controller = $this->getController();387 $_Action = $this->getAction();388 $_Lang = $this->getLang();389 $_Param = $this->getParam();390 // tìm quản tri391 if (method_exists("Controller_" . $_Controller, $_Action)) {392// echo "có action";393 $Content = __DIR__ . "/View/" . $this->getController() . "/" . $this->getAction() . ".phtml";394 } else {395 $Content = __DIR__ . "/View/" . $this->getController() . "/index.phtml";396 }397 $layout = "View/layout_mobie/layout_mobie_index.phtml";398 include_once $layout;399 }400 function QView($data) {401 $_Controller = $this->getController();402 $_Action = $this->getAction();403 $_Param = $this->getParam();404 $_Lang = $this->getLang();405 $Content = __DIR__ . "/View/" . $this->getController() . "/" . $this->getAction() . ".phtml";406 $layout = "View/layout/layout_quantri/index.phtml";407 include_once $layout;408 }409 function AView($data) {410 if ($this->getController() == "") {411 $this->controller = "index";412 }413 if ($this->getAction() == "") {414 $this->action = "index";415 }416 $_Lang = $this->getLang();417 $_Param = $this->getParam();418 $_Controller = $this->getController();419 $_Action = $this->getAction();420 $view = "View/" . $this->getController() . "/" . $this->getAction() . ".phtml";421 include_once $view;422 }423 function PTURL(&$TieuDeKD) {424 $url = self::$iurl;425 $Tree = [426 "news" => [427 "/\/page-(.*)\/(.*)(\.html)(.*)$/i",428 "/\/page-(.*)\/(.*)(\.html)$/i",429 ]430 ,431 "pagesdetail" => [432 "/\/page-(.*)(.html)(.*)/i",433 "/\/page-(.*)(.html)/i"434 ]...

Full Screen

Full Screen

UploadAndSaveImagesVideosUsersComponent.php

Source:UploadAndSaveImagesVideosUsersComponent.php Github

copy

Full Screen

...28 public function fileBiggerMaxFile($data)29 {30 if(count($data['photo']) > $this->max_files)31 {32 $this->_registry->getController()->Flash->error('Limit exceded');33 return $this->_registry->getController()->redirect(['controller' => 'images', 'action' => 'index']);34 }35 }36 public function createFilePath($data, $galery)37 {38 foreach($data['photo'] as $file)39 {40 $this->filename = $file['name'];41 $this->file_tmp_name = $file['tmp_name'];42 $this->file_ext = substr(strchr($this->filename, '.'), 1);43 $this->dir = WWW_ROOT.'img'.DS.'galerys'.DS.$galery;44 $this->type_allowed = array('png', 'jpg', 'jpeg', 'gif');45 }46 }47 public function sendAndRegisterFile($data, $username = null)48 {49 $file = $data;50 if(!in_array($this->file_ext, $this->type_allowed))51 {52 $this->_registry->getController()->Flash->error('Type of file not is allowed: "'.$file['photo']['type'].'"');53 return $this->_registry->getController()->redirect(['action' => 'add']);54 }55 elseif(is_uploaded_file($this->file_tmp_name))56 {57 $this->filename = Text::uuid().'.'.$this->file_ext;58 $file_db = TableRegistry::get('VideosUsers');59 $entity = $file_db->newEntity();60 $entity->video = $data['video']; 61 $entity->photo = $this->filename; 62 $entity->title = $data['title']; 63 $entity->description = $data['description']; 64 $entity->link_share = $data['link_share']; 65 $entity->users_id = $data['users_id'];66 $entity->playlist_users_id = $data['playlist_users_id'];67 $file_db->save($entity);68 move_uploaded_file($this->file_tmp_name, $this->dir.DS.$this->filename);69 }70 else71 {72 $this->_registry->getController()->Flash->error(__('The image could not be saved. Please, try again.'));73 return $this->_registry->getController()->redirect(['controller' => 'videosUsers', 'action' => 'add', $username]);74 }75 $this->_registry->getController()->Flash->success(__('The images has been saved.'));76 return $this->_registry->getController()->redirect(['controller' => 'videosUsers', 'action' => 'viewByUser', $username]);77 }78 public function sendAndRegisterFileToUpdateVideoPhoto($data, $username = null, $videosUser)79 {80 $file = $data;81 if(!in_array($this->file_ext, $this->type_allowed))82 {83 $this->_registry->getController()->Flash->error('Type of file not is allowed: "'.$file['photo']['type'].'"');84 return $this->_registry->getController()->redirect(['action' => 'add']);85 }86 elseif(is_uploaded_file($this->file_tmp_name))87 {88 $this->filename = Text::uuid().'.'.$this->file_ext;89 $file_db = TableRegistry::get('VideosUsers');90 $entity = $file_db->patchEntity($videosUser, $data); 91 $entity->photo = $this->filename;92 $file_db->save($entity);93 move_uploaded_file($this->file_tmp_name, $this->dir.DS.$this->filename);94 }95 else96 {97 $this->_registry->getController()->Flash->error(__('The image could not be saved. Please, try again.'));98 return $this->_registry->getController()->redirect(['controller' => 'videosUsers', 'action' => 'add', $username]);99 }100 $this->_registry->getController()->Flash->success(__('The images has been saved.'));101 return $this->_registry->getController()->redirect(['controller' => 'videosUsers', 'action' => 'viewByUser', $username]);102 }103}

Full Screen

Full Screen

UploadComponent.php

Source:UploadComponent.php Github

copy

Full Screen

...15 public $fileNames = array();16 17 public function upload($data, $path){18 if(count($data) > $this->max_files){ 19 $this->_registry->getController()->Flash20 ->error('Limite de arquivos excedido.');21 return false;22 //return $this->_registry->getController()23 // ->redirect($this->_registry->getController()->referer());24 }25 //var_dump(count($data));26 //die();27 foreach($data as $file){28 $file_tmp_name = $file['tmp_name'];29 if(trim($file_tmp_name) != ''){ 30 $filename = $file['name'];31 $file_ext = substr(strchr($filename,'.'),1);32 $dir = Configure::read('App.wwwRoot').Configure::read('App.imageBaseUrl').$path;33 $type_allowed = array('png','jpg','jpeg','gif');34 if(!in_array($file_ext, $type_allowed)){35 $this->_registry->getController()->Flash36 ->error('Tipo de arquivo não permitido: "'.$file['type'].'"');37 return false;38 //return $this->_registry->getController()39 // ->redirect($this->_registry->getController()->referer());40 }elseif(is_uploaded_file($file_tmp_name)){41 $filename = Text::uuid().'.'.$file_ext;42 //$file_db = TableRegistry::get('Images');43 //$entity = $file_db->newEntity();44 //$entity->image = $filename;45 //$file_db->sabe($entity);46 $this->fileNames[] = $filename;47 move_uploaded_file($file_tmp_name, $dir.DS.$filename);48 }else{49 $this->_registry->getController()->Flash50 ->error('A imagem não pode ser salva. Por favor, tente novamente.');51 //return $this->_registry->getController()52 // ->redirect($this->_registry->getController()->referer());53 return false;54 }55 }56 }57 //var_dump( $this->fileNames);58 //die;59 //$this->_registry->getController()->Flash60 // ->success('Imagens salvas.');61 //return $this->_registry->getController()->redirect(['action' => 'index']);62 return true;63 }64}...

Full Screen

Full Screen

getController

Using AI Code Generation

copy

Full Screen

1$file = new file();2$controller = $file->getController();3echo $controller;4$file = new file();5$controller = $file->getController();6echo $controller;7$file = new file();8$controller = $file->getController();9echo $controller;10$file = new file();11$controller = $file->getController();12echo $controller;13$file = new file();14$controller = $file->getController();15echo $controller;16$file = new file();17$controller = $file->getController();18echo $controller;19$file = new file();20$controller = $file->getController();21echo $controller;22$file = new file();23$controller = $file->getController();24echo $controller;25$file = new file();26$controller = $file->getController();27echo $controller;28$file = new file();29$controller = $file->getController();30echo $controller;31$file = new file();32$controller = $file->getController();33echo $controller;34$file = new file();35$controller = $file->getController();36echo $controller;37$file = new file();38$controller = $file->getController();39echo $controller;40$file = new file();41$controller = $file->getController();42echo $controller;

Full Screen

Full Screen

getController

Using AI Code Generation

copy

Full Screen

1$file->getController('controller1.php');2$file->getController('controller2.php');3$file->getController('controller3.php');4$file->getController('controller4.php');5$file->getController('controller1.php');6$file->getController('controller2.php');7$file->getController('controller3.php');8$file->getController('controller4.php');9$file->getController('controller1.php');10$file->getController('controller2.php');11$file->getController('controller3.php');12$file->getController('controller4.php');13$file->getController('controller1.php');14$file->getController('controller2.php');15$file->getController('controller3.php');16$file->getController('controller4.php');17$file->getController('controller1.php');18$file->getController('controller2.php');19$file->getController('controller3.php');20$file->getController('controller4.php');21$file->getController('controller1.php');22$file->getController('controller2.php');23$file->getController('controller3.php');

Full Screen

Full Screen

getController

Using AI Code Generation

copy

Full Screen

1require_once 'file.php';2$file = new file();3echo $file->getController();4{5 public function getController()6 {7 $path = $_SERVER['REQUEST_URI'];8 $path = explode('/', $path);9 $path = array_filter($path);10 $path = array_values($path);11 $controller = $path[0];12 return $controller;13 }14}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful