예제 #1
0
	public function fetchAllJoin($key = null,$condition = null) //check
	{
		if($condition == null)
		{
			$resultSet = $this->getDbTable()->fetchAll();
			}
			else
			{
				$resultSet = $this->getDbTable()->search($key,$condition);
				}

		$images = array();

		foreach($resultSet as $row){
			$image = new Pment_Models_Image();
			$image ->setImageId($row->imageId)
				->setProjectId($row->projectId)
				->setPrgType($row->prgType)
				->setPrgId($row->prgId)
				->setImageSn($row->imageSn)
				->setDescription($row->description)
				->setCTime($row->cTime);
				
			$images[] = $image;
			}
		return $images;
		}
예제 #2
0
	public function displayAction()
	{
		$wkprgs = new Pment_Models_WkprgMapper();
		$images = new Pment_Models_ImageMapper();
		$wkprgId = $this->_getParam('id',0);
		$projectId = $this->_getProjectId();
		$prgType = 'wk';
		$wkprg = new Pment_Models_Wkprg();
		$wkprgs->find($wkprgId,$wkprg);
		if($wkprgId >0)
		{
		//add upload form
			$errorMsg = null;
			$imageForm = new Pment_Forms_ImageSave();
			$imageForm->setAttrib('enctype', 'multipart/form-data');
			
			if($this->getRequest()->isPost())
			{
				if ($imageForm->isValid($this->getRequest()->getPost()))
				{
					if ($imageForm->imageUpload->receive())
					{
						$locationFile = $imageForm->imageUpload->getFileName();
						$nameFile = time().rand(100,199).'.jpg';
						$fullPathNameFile = 'images/upload/'.$nameFile;
						// Renommage du fichier
						$filterRename = new Zend_Filter_File_Rename(array('target' => $fullPathNameFile, 'overwrite' => true));
						$filterRename->filter($locationFile);
						//make thumbnail
						$this->view->image('uploadImage',$nameFile,null,'280x280');
						//save to db
						$uploadImage = new Pment_Models_Image();
						$uploadImage->setProjectId($projectId);
						$uploadImage->setPrgType($prgType);
						$uploadImage->setPrgId($wkprgId);
						$uploadImage->setImageSn($nameFile);
						$uploadImage->setDescription($imageForm->getValue('description'));
						$images->save($uploadImage);
						}
					}
				}
			$condition[0] = $projectId;
			$condition[1] = $prgType;
			$arrayImages = $images->fetchAllJoin($wkprgId,$condition);

			$this ->view->wkprg = $wkprg;
			$this->view->imageForm = $imageForm;
			$this->view->errorMsg = $errorMsg;
			$this->view->arrayImages = $arrayImages;
			}
			else
			{
				$this->_redirect('/pment/wkprg');
				}
	}