Exemple #1
0
 public function updateAction()
 {
     $request = $this->getRequest();
     $fishId = intval($request->getParam(Fish::COL_ID));
     $dbAdapter = Zend_Registry::get('DB_CONNECTION1');
     if ($request->isPost() and $this->form->isValid($request->getParams($fishId))) {
         $data = array(Fish::COL_SAMPLE_CODE => $this->form->getValue(Fish::COL_SAMPLE_CODE), Fish::COL_USER_ID => AuthQuery::getUserId());
         $this->fishTable->updateFishAndMetadata($this->form, $fishId, $data);
         $namespace = new Zend_Session_Namespace('default');
         $redirect = new Zend_Controller_Action_Helper_Redirector();
         if ($namespace->next != null) {
             $nextArray = $namespace->next;
             $namespace->next = null;
             $redirect->setGotoSimple($nextArray['nextAction'], $nextArray['nextController'], $nextArray['nextModul']);
         } else {
             $redirect->setGotoSimple('search', 'search', 'fish');
         }
     } else {
         $fishResult = $this->fishTable->find($fishId)->current();
         if ($fishResult != null) {
             $fishArray = $fishResult->toArray();
         } else {
             $fishArray = array();
         }
         // get meta data
         $select = $dbAdapter->select();
         $select->from(MetaDataFish::TABLE_NAME);
         $select->join(AttributeDescriptor::TABLE_NAME, MetaDataFish::TABLE_NAME . '.' . MetaDataFish::COL_ATTRIBUTE_DESCRIPTOR_ID . '=' . AttributeDescriptor::TABLE_NAME . '.ATDE_ID');
         $select->where(MetaDataFish::COL_FISH_ID . '=?', $fishId);
         $metaArray = $dbAdapter->fetchAll($select);
         $this->form->dynPopulate($metaArray, MetaDataFish::COL_VALUE, $fishArray);
         $this->view->form = $this->form;
         $this->render('form');
     }
 }
Exemple #2
0
 public function updateAction()
 {
     $request = $this->getRequest();
     if ($request->isPost() and $this->form->isValid($request->getParams())) {
         $imageId = $this->form->getValue(Image::COL_ID);
         $data = array(Image::COL_ORIGINAL_FILENAME => $this->form->getValue(Image::COL_ORIGINAL_FILENAME), Image::COL_RATIO_EXTERNAL => $this->form->getValue(Image::COL_RATIO_EXTERNAL));
         $this->imageTable->updateImageAndMetadata($this->form, $imageId, $data);
         $redirect = new Zend_Controller_Action_Helper_Redirector();
         $redirect->setGotoSimple('search', 'search', 'image');
     } else {
         $dbAdapter = Zend_Registry::get('DB_CONNECTION1');
         $imageId = intval($this->getRequest()->getParam(Image::COL_ID));
         $imageResult = $this->imageTable->find($imageId)->current();
         if ($imageResult != null) {
             $imageArray = $imageResult->toArray();
         } else {
             $imageArray = array();
         }
         // get meta data
         $select = $dbAdapter->select();
         $select->from(MetaDataImage::TABLE_NAME);
         $select->join(AttributeDescriptor::TABLE_NAME, MetaDataImage::TABLE_NAME . '.' . MetaDataImage::COL_ATTRIBUTE_DESCRIPTOR_ID . '=' . AttributeDescriptor::TABLE_NAME . '.' . AttributeDescriptor::COL_ID);
         $select->where(MetaDataImage::COL_IMAGE_ID . '=?', $imageId);
         //TODO: Fish::COL_SAMPLE_CODE abfragen über FISH_ID
         $metaArray = $dbAdapter->fetchAll($select);
         $this->form->dynPopulate($metaArray, MetaDataImage::COL_VALUE, $imageArray);
         $this->view->form = $this->form;
     }
 }
 public function byceAction()
 {
     $images = new Service_Image();
     $namespace = new Zend_Session_Namespace('default');
     $resultKey = new Ble422_Guid();
     $ceId = $this->getRequest()->getParam(CalibrationExercise::COL_ID);
     if ($ceId != null) {
         //get images
         $namespace->{$resultKey} = $images->getImages($ceId);
         //getCeInfo
         //set CE id
         $constCeId = CalibrationExercise::COL_ID;
         $namespace->{$constCeId} = $ceId;
         //Set CE-info result Object
         $dbadapter = Zend_Registry::get('DB_CONNECTION1');
         $select = $dbadapter->select();
         $select->from(array('caex' => CalibrationExercise::TABLE_NAME));
         $select->join(array('exp' => Expertise::TABLE_NAME), 'caex.' . CalibrationExercise::COL_EXPERTISE_ID . "=" . 'exp.' . Expertise::COL_ID);
         $select->join(array('key' => KeyTable::TABLE_NAME), 'caex.' . CalibrationExercise::COL_KEY_TABLE_ID . "=" . 'key.' . KeyTable::COL_ID);
         $select->join(array('work' => Workshop::TABLE_NAME), 'caex.' . CalibrationExercise::COL_WORKSHOP_ID . "=" . "work." . Workshop::COL_ID, array(Workshop::COL_NAME));
         $select->where('caex.' . CalibrationExercise::COL_ID . "=?", $ceId);
         $ceArray = $dbadapter->fetchAll($select);
         $namespace->ceArray = $ceArray;
     } else {
         $redirect = new Zend_Controller_Action_Helper_Redirector();
         $redirect->setGotoSimple('index', 'index', 'default');
     }
     $this->view->resultKey = $resultKey->__toString();
     $this->render('start');
 }
 public function searchAction()
 {
     $request = $this->getRequest();
     $formValues = $this->namespace->formValues;
     $this->view->callingAction = $this->defaultNamespace->callingAction;
     // get meta data select for image and fish descriptors
     $metaData = new Default_MetaData();
     $metaData->getSelectForGroups(FALSE);
     $select = $metaData->addWhereToSelect($formValues);
     //TODO test with multiple fish / multiple image checked attributes
     //changed, if images are found, but search was for fish, multiple image attributes would cause multiple entries
     //TODO error: only first fish without images shown due to this group; if there are many fishes without image, there is only one of them shown in list
     $select->group('fish.' . Fish::COL_ID);
     if ($this->defaultNamespace->callingAction == 'annotation/browse/byfish') {
         $select->joinLeft(array('vaa' => 'v_all_annotations'), 'vaa.' . CeHasImage::COL_IMAGE_ID . ' = ' . 'image.' . Image::COL_ID, array());
         //auf cehas_image damit die ausgefiltert werden die keine annotationen haben
         $select->group('image.' . Image::COL_ID);
         $resultArray = Zend_Registry::get('DB_CONNECTION1')->fetchAll($select);
         if ($resultArray != array()) {
             $resultKey = new Ble422_Guid();
             $this->defaultNamespace->{$resultKey} = $resultArray;
             $redirect = new Zend_Controller_Action_Helper_Redirector();
             $redirect->setGotoSimple('start', 'browse', 'annotation', array('resultKey' => $resultKey));
         }
     } else {
         //select only own fish
         if ($this->defaultNamespace->callingAction == 'user/edit/myfishes') {
             $select->where('fish.' . Fish::COL_USER_ID . ' = ?', $this->defaultNamespace->callingActionId);
         }
         //new
         $this->namespace->select = $select;
         //new
         /**
          * Pagination control
          */
         $paginator = new Ble422_Paginator_Extended($select, $this->getRequest());
         //static + dynamic header array
         $statArray = array(array('raw' => Fish::COL_SAMPLE_CODE, 'name' => 'Fish sample code'));
         $dynArray = array();
         $i = 0;
         foreach ($metaData->fishRowSetArray as $fishAttr) {
             $dynInnerArray = array('raw' => 'ATDE_' . $fishAttr[AttributeDescriptor::COL_ID], 'name' => $fishAttr[AttributeDescriptor::COL_NAME] . '<br>' . $fishAttr['UNIT']);
             $dynArray[$i] = $dynInnerArray;
             $i++;
         }
         $headerArray = array_merge($statArray, $dynArray);
         unset($i);
         unset($dynArray);
         unset($dynInnerArray);
         $paginator->setHeader($headerArray);
         $paginator->setCurrentPageNumber($this->getRequest()->getParam('page'))->setItemCountPerPage(1000)->setPageRange(10)->orderBy($this->getRequest()->getParam('orderBy'));
         //$this->_getParam('pageRange'));
         Zend_View_Helper_PaginationControl::setDefaultViewPartial('partials/list_pagination_control.phtml');
         $this->view->paginator = $paginator;
         $storage = Zend_Auth::getInstance()->getStorage()->read();
         $constUserRole = User::COL_ROLE;
         $this->view->userRole = $storage->{$constUserRole};
     }
 }
 public function createAction()
 {
     $expId = intval($this->getRequest()->getParam(Expertise::COL_ID));
     $keyId = intval($this->getRequest()->getParam(KeyTable::COL_ID));
     $expTable = new Expertise();
     $expRow = $expTable->find($expId);
     $keyTable = new KeyTable();
     $keyRow = $keyTable->find($keyId);
     if ($keyRow->count() != 0 || $expRow->count() != 0) {
         $keyArray = $keyRow->toArray();
         $expArray = $expRow->toArray();
         // create CE row
         $ceTable = new CalibrationExercise();
         $ceName = $expArray[0][Expertise::COL_SPECIES] . ' / ' . AuthQuery::getUserName();
         //TODO \r in der Datenbank
         $ceDescription = 'Area: ' . $expArray[0][Expertise::COL_AREA] . '\\r' . 'Subject: ' . $expArray[0][Expertise::COL_SUBJECT] . '\\r' . 'KeyName: ' . $keyArray[0][KeyTable::COL_NAME];
         $ceData = array(CalibrationExercise::COL_NAME => $ceName, CalibrationExercise::COL_DESCRIPTION => $ceDescription, CalibrationExercise::COL_KEY_TABLE_ID => $keyArray[0][KeyTable::COL_ID], CalibrationExercise::COL_EXPERTISE_ID => $expArray[0][Expertise::COL_ID], CalibrationExercise::COL_COMPAREABLE => 1, CalibrationExercise::COL_IS_STOPPED => 0, CalibrationExercise::COL_TRAINING => 1);
         $ceId = $ceTable->insert($ceData);
         // create participant row
         $partTable = new Participant();
         $partData = array(Participant::COL_CE_ID => $ceId, Participant::COL_USER_ID => AuthQuery::getUserId(), Participant::COL_NUMBER => 1);
         $partId = $partTable->insert($partData);
         // add all possible shown attributes
         $dbAdapter = $ceTable->getAdapter();
         $selectAttr = $dbAdapter->select();
         $selectAttr->from(AttributeDescriptor::TABLE_NAME);
         $selectAttr->orWhere(AttributeDescriptor::COL_GROUP . '=?', 'fish');
         $selectAttr->orWhere(AttributeDescriptor::COL_GROUP . '=?', 'image');
         $attrArray = $dbAdapter->fetchAll($selectAttr);
         $ceHasAttrTable = new CeHasAttributeDescriptor();
         foreach ($attrArray as $attr) {
             $attrData = array(CeHasAttributeDescriptor::COL_ATDE_ID => $attr[AttributeDescriptor::COL_ID], CeHasAttributeDescriptor::COL_CAEX_ID => $ceId);
             $ceHasAttrTable->insert($attrData);
         }
         //get images for exp/key
         $refQuery = new Default_ReferenceQuery();
         $images = $refQuery->getImages($expId, $keyId);
         // create imageset
         //			$selectImages = $dbAdapter->select();
         //			$imagesArray = $dbAdapter->fetchAll($selectImages);
         $imageSetTable = new CeHasImage();
         foreach ($images as $image) {
             $data = array(CeHasImage::COL_IMAGE_ID => $image, CeHasImage::COL_CALIBRATION_EXERCISE_ID => $ceId);
             $imageSetTable->insert($data);
         }
         //$this->render('form');
         $Redirect = new Zend_Controller_Action_Helper_Redirector();
         $Redirect->setGotoSimple('index', 'make', 'annotation', array(CalibrationExercise::COL_ID => $ceId));
     } else {
         throw new Zend_Controller_Exception('Error at craeting a new training Calibration Exercise.', 505);
     }
 }
 public function redirectTo()
 {
     $Redirect = new Zend_Controller_Action_Helper_Redirector();
     $Redirect->setGotoSimple('edit', 'valuelist', 'admin', array(AttributeDescriptor::COL_ID => $this->atDeId));
 }
 public function indexAction()
 {
     $redirect = new Zend_Controller_Action_Helper_Redirector();
     $redirect->setGotoSimple('myce', 'search', 'ce');
 }
Exemple #8
0
 public function redirectTo($params = array())
 {
     $Redirect = new Zend_Controller_Action_Helper_Redirector();
     $Redirect->setGotoSimple('details', 'search', 'workshop', array(WorkshopInfo::COL_WORKSHOP_ID => $this->getRequest()->getParam(WorkshopInfo::COL_WORKSHOP_ID)));
 }
 public function indexAction()
 {
     $addFish = false;
     if ($this->getRequest()->isPost()) {
         $params = $this->getRequest()->getParams();
         if ($this->form->isValid($params)) {
             //TODO wenn fishsamplecode noch nicht in der datenbank,
             //dann lege fisch an mit diesem samplecode (erledigt)
             //und SPRINGE IN Fish_CreateController (am Ende des Controllers)
             //TODO mit getElement und Konstanten arbeiten
             $fishSampleCode = $this->form->getValue(Fish::COL_SAMPLE_CODE);
             $fishTable = new Fish();
             $row = $fishTable->fetchRow($fishTable->select()->where(Fish::COL_SAMPLE_CODE . '= ?', $fishSampleCode));
             if (is_null($row)) {
                 //echo 'Warnung: Fish Sample Code nicht vorhanden.';
                 $fishId = $fishTable->insert(array(Fish::COL_SAMPLE_CODE => $fishSampleCode));
                 $addFish = true;
                 $constFishId = Fish::COL_ID;
                 $fishId->{$constFishId} = $fishId;
             } else {
                 $addFish = false;
                 $fishId = $row->FISH_ID;
             }
             //TODO dateinamen mit leerzeichen
             //könnte ein problem bei der weiterverarbeitung in linux sein
             //klären,
             //ggf. akzeptieren und umwandeln oder verweigern?
             //don't call $form->getValues() - causes physical upload immediately
             //look ZFDoc 19.1.3
             //note: if using Zend_Form_Element_File (in view) you can't use new instance of Zend_File_Transfer_Adapter_Http in controller!
             // http://www.zfforums.com/zend-framework-forum-8/general-talks-12/file_transfer-illegal-uploaded-possible-attack-1737.html
             // http://www.nabble.com/Zend_File_Transfer-td19024470.html
             //solution:
             //getTransferAdapter()
             $upload = $this->form->uploadElement->getTransferAdapter();
             // Returns all known internal file informations
             $files = $upload->getFileInfo();
             $imageTable = new Image();
             $medimTable = new MetaDataImage();
             //look ZFDoc 19.3.3
             //iterates over all file elemens
             $numberImagesUploaded = 0;
             $userId = AuthQuery::getUserId();
             foreach ($files as $file => $info) {
                 /*handle only uploaded files, skip blank file elements
                 	 store original file in certain path
                 	 file is saved without excplicit temp directory with Zend Filter
                 	 image import uses temp directory instead
                 	 */
                 if (!$upload->isUploaded($file)) {
                     continue;
                 }
                 $creator_guid = new Ble422_Guid();
                 $guid = $creator_guid->__toString();
                 $fileName = $info['name'];
                 $path_parts = pathinfo($fileName);
                 $originalFileName = $path_parts['basename'];
                 //used later to create Image dataset
                 $newFileNameWithGuid = $guid . '.' . strtolower($path_parts['extension']);
                 //save extension in lower-case
                 //relative path with new filename, prefix dot&slash required
                 $completeTarget = './' . Image::RELATIVE_UPLOAD_PATH . '/' . $newFileNameWithGuid;
                 //apply filter only for uploaded file $fileName
                 $upload->addFilter('Rename', array('target' => $completeTarget, 'overwrite' => false), $fileName);
                 $upload->receive($file);
                 //TODO write protect files
                 $upload->clearFilters();
                 try {
                     $ratio = $this->form->getValue(Image::COL_RATIO_EXTERNAL);
                     $tn_ratio = $imageTable->processImage($completeTarget);
                     //ratio is filled from form
                     $imageId = $imageTable->insertImageDataset($completeTarget, $originalFileName, $fishId, $guid, $userId, $ratio, $tn_ratio);
                     $imageTable->updateImageAndMetadata($this->form, $imageId);
                     $numberImagesUploaded++;
                 } catch (Exception $e) {
                     echo "Exception: " . $e->getMessage();
                 }
             }
             Zend_Registry::set('MESSAGE', $numberImagesUploaded . ' image(s) successfully inserted');
             if ($addFish) {
                 $next = array('nextAction' => 'index', 'nextController' => 'upload', 'nextModul' => 'image');
                 $namespace = new Zend_Session_Namespace('default');
                 $namespace->next = $next;
                 $redirect = new Zend_Controller_Action_Helper_Redirector();
                 $redirect->setGotoSimple('update', 'edit', 'fish', array(Fish::COL_ID => $fishId));
             }
         } else {
             //form isn't valid
             $this->form->populate($params);
             $this->view->form = $this->form;
         }
     }
     //$this->view->form = $form;
 }
 public function redirectTo($action)
 {
     $Redirect = new Zend_Controller_Action_Helper_Redirector();
     $Redirect->setGotoSimple($action, 'editparticipants', 'ce');
 }
Exemple #11
0
 public function redirectTo($action, $params = array())
 {
     $Redirect = new Zend_Controller_Action_Helper_Redirector();
     $Redirect->setGotoSimple($action, 'Edit', 'ce', $params);
 }
 public function searchAction()
 {
     $request = $this->getRequest();
     $formValues = $this->namespace->formValues;
     $this->view->callingAction = $this->defaultNamespace->callingAction;
     // get meta data select for image and fish descriptors
     $metaData = new Default_MetaData();
     $metaData->getSelectForGroups(TRUE);
     $select = $metaData->addWhereToSelect($formValues);
     if ($this->defaultNamespace->callingAction == 'annotation/browse/byimage') {
         unset($this->namespace->ceArray);
         $select->joinLeft(array('vaa' => 'v_all_annotations'), 'vaa.' . CeHasImage::COL_IMAGE_ID . ' = ' . 'image.' . Image::COL_ID, array());
         //auf cehas_image damit die ausgefiltert werden die keine annotationen haben
         $select->where(Annotations::COL_WS_REF . "=? ", 1);
         $select->orWhere(Annotations::COL_FINAL . " = ? ", 1);
         $select->orWhere(Annotations::COL_GROUP . "=? ", 1);
         $select->orWhere(Annotations::COL_WEBGR_REF . "=? ", 1);
         $select->group('image.' . Image::COL_ID);
         $resultArray = Zend_Registry::get('DB_CONNECTION1')->fetchAll($select);
         if ($resultArray != array()) {
             $resultKey = new Ble422_Guid();
             $this->defaultNamespace->{$resultKey} = $resultArray;
             $redirect = new Zend_Controller_Action_Helper_Redirector();
             $redirect->setGotoSimple('start', 'browse', 'annotation', array('resultKey' => $resultKey));
         }
     } else {
         //select only own images
         if ($this->defaultNamespace->callingAction == 'user/edit/myimages') {
             $select->where('image.' . Image::COL_USER_ID . ' = ?', $this->defaultNamespace->callingActionId);
         }
         //filter double datasets caused by multiple meta data
         //$select->group('image.'.Image::COL_ID);
         //get already assigned datasets for setting disabled in view
         if ($this->defaultNamespace->callingAction == '/ce/edit/addimages') {
             $ceId = $this->defaultNamespace->callingActionId;
             $ceHasIm = new CeHasImage();
             $rowSet = $ceHasIm->fetchAll(CeHasImage::COL_CALIBRATION_EXERCISE_ID . '=' . $ceId);
             if (count($rowSet) > 0) {
                 $assignedImages = array();
                 foreach ($rowSet as $row) {
                     $assignedImages[$row[CeHasImage::COL_IMAGE_ID]] = TRUE;
                 }
                 $this->view->assignedImages = $assignedImages;
             }
         }
         //echo $select;
         /**
          * Pagination control
          */
         $paginator = new Ble422_Paginator_Extended($select, $this->getRequest());
         //			echo $select->__toString();
         //			die();
         //static + dynamic header array
         $statArray = array(array('raw' => Image::COL_ORIGINAL_FILENAME, 'name' => 'Original file name'), array('raw' => Fish::COL_SAMPLE_CODE, 'name' => 'Fish sample code'), array('raw' => Image::COL_DIM_X, 'name' => 'Width'), array('raw' => Image::COL_DIM_Y, 'name' => 'Height'));
         $dynArray = array();
         $i = 0;
         foreach ($metaData->fishRowSetArray as $fishAttr) {
             $dynInnerArray = array('raw' => 'ATDE_' . $fishAttr[AttributeDescriptor::COL_ID], 'name' => $fishAttr[AttributeDescriptor::COL_NAME] . '<br>' . $fishAttr['UNIT']);
             $dynArray[$i] = $dynInnerArray;
             $i++;
         }
         $headerArray = array_merge($statArray, $dynArray);
         unset($i);
         unset($dynArray);
         unset($dynInnerArray);
         $i = 0;
         foreach ($metaData->imageRowSetArray as $imAttr) {
             $dynInnerArray = array('raw' => 'ATDE_' . $imAttr[AttributeDescriptor::COL_ID], 'name' => $imAttr[AttributeDescriptor::COL_NAME] . '<br>' . $imAttr['UNIT']);
             $dynArray[$i] = $dynInnerArray;
             $i++;
         }
         $headerArray = array_merge($headerArray, $dynArray);
         unset($i);
         unset($dynArray);
         unset($dynInnerArray);
         $paginator->setHeader($headerArray);
         $paginator->setCurrentPageNumber($this->getRequest()->getParam('page'))->setItemCountPerPage(1000)->setPageRange(10)->orderBy($this->getRequest()->getParam('orderBy'));
         //$this->_getParam('pageRange'));
         Zend_View_Helper_PaginationControl::setDefaultViewPartial('partials/list_pagination_control.phtml');
         $this->view->paginator = $paginator;
     }
 }
 public function redirectTo()
 {
     $Redirect = new Zend_Controller_Action_Helper_Redirector();
     $Redirect->setGotoSimple('list', 'attribute', 'admin');
 }