Пример #1
0
 public function index($id = null)
 {
     if ($id) {
         if ($idmedia = $this->Media->read($id)) {
             $currentMedia = Request::cleanInput($idmedia);
             $this->view->currentMedia = $currentMedia;
         } else {
             Session::setFlash("This Media doesn't exist", "warning");
         }
     }
     $this->view->medias = $this->Media->read();
     $this->view->render('medias/index');
 }
Пример #2
0
 /**
      * @return array|bool
 
     public function create(){
 		$sql= "INSERT INTO tmedias (title, url, type) VALUES ('".$this->title."', '".$this->url."', '".$this->type."')";
 		return $this->db->query($sql);
 	}*/
 public function upload($datas, $names)
 {
     $target_path = 'medias/';
     $uploadOk = 1;
     for ($i = 0; $i < count($datas); $i++) {
         $name = $names[$i];
         $temp_name = $datas[$i];
         $target_path = $target_path . basename($name);
         if (file_exists($target_path)) {
             $uploadOk = 0;
         }
         if ($uploadOk == 0) {
             Session::setFlash('File already exist', 'warning');
         } else {
             if (move_uploaded_file($temp_name, $target_path)) {
                 Session::setFlash("The file " . basename($name) . " has been uploaded.", 'warning');
             } else {
                 Session::setFlash("Sorry, there was an error uploading your file", 'warning');
             }
         }
     }
 }
Пример #3
0
 public function UpdateBrick($id)
 {
     $this->data = Request::all();
     if ($this->Brick->UpdateBrick($id, $this->data)) {
         Session::setFlash('The brick has been updated', "success");
         $this->view->redirect_to('/brick/edit');
     } else {
         Session::setFlash("Problem occur while updating", "warning");
         $this->view->redirect_to('/brick/edit');
     }
 }