function groupenrollmentAction()
 {
     $criteria = Criteria::create();
     $formfile = new \Application\Form\Groupenrollment();
     //Get entry manner
     $entrymanners = $this->admission->getEntity("\\Application\\Entity\\Entrymanner", $criteria);
     //Get Study mode
     $studymodes = $this->admission->getEntity("\\Application\\Entity\\Studymode", $criteria);
     //Academic period
     $acperiod = $this->admission->getEntity("\\Application\\Entity\\Academicperiod", $criteria);
     //Class
     $classes = $this->admission->getEntity("\\Application\\Entity\\Programgroup", $criteria);
     if ($this->request->getPost('btnupload')) {
         $post = array_merge_recursive($this->request->getPost()->toArray(), $this->request->getFiles()->toArray());
         $formfile->setData($post);
         if ($formfile->isValid()) {
             $validator = new \Zend\Validator\File\Extension('csv');
             if ($validator->isValid($post['File']['filename'])) {
                 $uploadfile = $formfile->getData();
                 $filecontent = $uploadfile['File']['filename']['tmp_name'];
                 $handle = fopen($filecontent, "r");
                 while (($rowdata = fgetcsv($handle, 1000, ",")) !== FALSE) {
                     //Process validation class/group, academic period, entry manner, study mode
                     $student[] = $this->admission->getEnrolledStudentsArray($rowdata);
                 }
                 $this->admissionsession->enrolmentlist = $student;
                 //$this->admissionsession->getManager()->getStorage()->clear('ADMISSION');
                 return $this->redirect()->toRoute("admission", array("action" => "confirmgroupenrollment"));
             }
         }
     }
     return new ViewModel(array("classes" => $classes, "academicperiod" => $acperiod, "entrymanners" => $entrymanners, "studymodes" => $studymodes, "uploadform" => $formfile));
 }
Esempio n. 2
0
 public function index05Action()
 {
     echo "<h3 style='color:red;font-weight:bold'>" . __METHOD__ . "</h3>";
     $validator = new \Zend\Validator\File\Extension("php,html,wmv");
     $validator = new \Zend\Validator\File\Extension("php,html,WMV", true);
     // mac dinh false
     $input = PUBLIC_PATH . "files/Wildlife.wmv";
     if (!$validator->isValid($input)) {
         $message = $validator->getMessages();
         echo current($message);
     } else {
         echo "ok";
     }
     return false;
 }
Esempio n. 3
0
 /**
  * Upload an image to be displayed on a page.
  *
  * @param array $files
  *
  * @throws \Exception
  * @return array
  */
 public function uploadImage($files)
 {
     $imageValidator = new \Zend\Validator\File\IsImage(['magicFile' => false]);
     $extensionValidator = new \Zend\Validator\File\Extension(['JPEG', 'JPG', 'JFIF', 'TIFF', 'RIF', 'GIF', 'BMP', 'PNG']);
     if ($imageValidator->isValid($files['upload']['tmp_name'])) {
         if ($extensionValidator->isValid($files['upload'])) {
             $config = $this->getStorageConfig();
             $fileName = $this->getFileStorageService()->storeUploadedFile($files['upload']);
             return $config['public_dir'] . '/' . $fileName;
         } else {
             throw new \Exception($this->getTranslator()->translate('The uploaded file does not have a valid extension'));
         }
     } else {
         throw new \Exception($this->getTranslator()->translate('The uploaded file is not a valid image'));
     }
 }
Esempio n. 4
0
 public function upload($files, $album)
 {
     if (!$this->isAllowed('photo', 'upload')) {
         throw new \User\Permissions\NotAllowedException($this->getTranslator()->translate('Not allowed to upload photos.'));
     }
     $imageValidator = new \Zend\Validator\File\IsImage(array('magicFile' => false));
     $extensionValidator = new \Zend\Validator\File\Extension(array('JPEG', 'JPG', 'JFIF', 'TIFF', 'RIF', 'GIF', 'BMP', 'PNG'));
     $translator = $this->getTranslator();
     if ($files['file']['error'] !== 0) {
         throw new \Exception($translator->translate('An unknown error occurred during uploading (' . $files['file']['error'] . ')'));
     }
     /**
      * We re-add the original extension so it can be preserved later on
      * when moving the file.
      */
     $extension = explode('/', $files['file']['type'])[1];
     $path = $files['file']['tmp_name'] . '.' . $extension;
     move_uploaded_file($files['file']['tmp_name'], $path);
     if ($imageValidator->isValid($path)) {
         if ($extensionValidator->isValid($path)) {
             $this->storeUploadedPhoto($path, $album, true);
         } else {
             throw new \Exception($translator->translate('The uploaded file does not have a valid extension'));
         }
     } else {
         throw new \Exception($translator->translate('The uploaded file is not a valid image'));
     }
 }
Esempio n. 5
0
 public function upload($files, $album)
 {
     $this->checkUploadAllowed();
     $imageValidator = new \Zend\Validator\File\IsImage(['magicFile' => false]);
     $extensionValidator = new \Zend\Validator\File\Extension(['JPEG', 'JPG', 'JFIF', 'TIFF', 'RIF', 'GIF', 'BMP', 'PNG']);
     $translator = $this->getTranslator();
     if ($files['file']['error'] !== 0) {
         throw new \Exception($translator->translate('An unknown error occurred during uploading (' . $files['file']['error'] . ')'));
     }
     /**
      * We re-add the original extension so it can be preserved later on
      * when moving the file.
      */
     $extension = explode('/', $files['file']['type'])[1];
     $path = $files['file']['tmp_name'] . '.' . $extension;
     move_uploaded_file($files['file']['tmp_name'], $path);
     if ($imageValidator->isValid($path)) {
         if ($extensionValidator->isValid($path)) {
             $this->storeUploadedPhoto($path, $album, true);
         } else {
             throw new \Exception($translator->translate('The uploaded file does not have a valid extension'));
         }
     } else {
         throw new \Exception(sprintf($translator->translate("The uploaded file is not a valid image \nError: %s"), implode(',', array_values($imageValidator->getMessages()))));
     }
 }
Esempio n. 6
0
 /**
  * Upload an image to be displayed on a page.
  *
  * @param array $files
  *
  * @throws \Exception
  * @return array
  */
 public function uploadImage($files)
 {
     $imageValidator = new \Zend\Validator\File\IsImage(array('magicFile' => false));
     $extensionValidator = new \Zend\Validator\File\Extension(array('JPEG', 'JPG', 'JFIF', 'TIFF', 'RIF', 'GIF', 'BMP', 'PNG'));
     $translator = $this->getTranslator();
     if ($files['upload']['error'] !== 0) {
         throw new \Exception($translator->translate('An unknown error occurred during uploading (' . $files['upload']['error'] . ')'));
     }
     if ($imageValidator->isValid($files['upload']['tmp_name'])) {
         if ($extensionValidator->isValid($files['upload']['name'])) {
             //TODO
         } else {
             throw new \Exception($translator->translate('The uploaded file does not have a valid extension'));
         }
     } else {
         throw new \Exception($translator->translate('The uploaded file is not a valid image'));
     }
 }