public function addImage($postArr) { $status = true; $imgManager = new ImageShared(); //Set target path $subTargetPath = $this->collMap['institutioncode']; if ($this->collMap['collectioncode']) { $subTargetPath .= '_' . $this->collMap['collectioncode']; } $subTargetPath .= '/'; if (!$this->occurrenceMap) { $this->setOccurArr(); } $catNum = $this->occurrenceMap[$this->occid]['catalognumber']; if ($catNum) { $catNum = str_replace(array('/', '\\', ' '), '', $catNum); if (preg_match('/^(\\D{0,8}\\d{4,})/', $catNum, $m)) { $catPath = substr($m[1], 0, -3); if (is_numeric($catPath) && strlen($catPath) < 5) { $catPath = str_pad($catPath, 5, "0", STR_PAD_LEFT); } $subTargetPath .= $catPath . '/'; } else { $subTargetPath .= '00000/'; } } else { $subTargetPath .= date('Ym') . '/'; } $imgManager->setTargetPath($subTargetPath); //Import large image or not if (array_key_exists('nolgimage', $postArr) && $postArr['nolgimage'] == 1) { $imgManager->setMapLargeImg(false); } else { $imgManager->setMapLargeImg(true); } //Set image metadata variables if (array_key_exists('caption', $postArr)) { $imgManager->setCaption($postArr['caption']); } if (array_key_exists('photographeruid', $postArr)) { $imgManager->setPhotographerUid($postArr['photographeruid']); } if (array_key_exists('photographer', $postArr)) { $imgManager->setPhotographer($postArr['photographer']); } if (array_key_exists('sourceurl', $postArr)) { $imgManager->setSourceUrl($postArr['sourceurl']); } if (array_key_exists('copyright', $postArr)) { $imgManager->setCopyright($postArr['copyright']); } if (array_key_exists("notes", $postArr)) { $imgManager->setNotes($postArr['notes']); } if (array_key_exists("sortsequence", $postArr)) { $imgManager->setSortSeq($postArr['sortsequence']); } $sourceImgUri = $postArr['imgurl']; if ($sourceImgUri) { //Source image is a URI supplied by user if (array_key_exists('copytoserver', $postArr) && $postArr['copytoserver']) { if (!$imgManager->copyImageFromUrl($sourceImgUri)) { $status = false; } } else { $imgManager->parseUrl($sourceImgUri); } } else { //Image is a file upload if (!$imgManager->uploadImage()) { $status = false; } } $imgManager->setOccid($this->occid); if (isset($this->occurrenceMap[$this->occid]['tidinterpreted'])) { $imgManager->setTid($this->occurrenceMap[$this->occid]['tidinterpreted']); } if ($imgManager->processImage()) { $this->activeImgId = $imgManager->getActiveImgId(); } //Load tags $status = $imgManager->insertImageTags($postArr); //Get errors and warnings if ($imgManager->getErrArr()) { $this->errorStr = implode('<br/>', $imgManager->getErrArr()); } return $status; }
public function loadImage($postArr) { $status = true; $imgManager = new ImageShared(); $imgPath = $postArr["filepath"]; $imgManager->setTid($this->tid); $imgManager->setCaption($postArr['caption']); $imgManager->setPhotographer($postArr['photographer']); $imgManager->setPhotographerUid($postArr['photographeruid']); $imgManager->setSourceUrl($postArr['sourceurl']); $imgManager->setCopyright($postArr['copyright']); $imgManager->setOwner($postArr['owner']); $imgManager->setLocality($postArr['locality']); $imgManager->setOccid($postArr['occid']); $imgManager->setNotes($postArr['notes']); $imgManager->setSortSeq($postArr['sortsequence']); $imgManager->setTargetPath($this->family . '/' . date('Ym') . '/'); if ($imgPath) { $imgManager->setMapLargeImg(true); $importUrl = array_key_exists('importurl', $postArr) && $postArr['importurl'] == 1 ? true : false; if ($importUrl) { $imgManager->copyImageFromUrl($imgPath); } else { $imgManager->parseUrl($imgPath); } } else { if (array_key_exists('createlargeimg', $postArr) && $postArr['createlargeimg'] == 1) { $imgManager->setMapLargeImg(true); } else { $imgManager->setMapLargeImg(false); } if (!$imgManager->uploadImage()) { //echo implode('; ',$imgManager->getErrArr()); } } $imgManager->processImage(); if ($imgManager->getErrArr()) { $this->errorStr = implode('<br/>', $imgManager->getErrArr()); } return $status; }
public function addImages($postArr, $newOccId, $tid) { $status = true; $imgManager = new ImageShared(); //Set target path $subTargetPath = $this->collMap['institutioncode']; if ($this->collMap['collectioncode']) { $subTargetPath .= '_' . $this->collMap['collectioncode']; } for ($i = 1; $i <= 3; $i++) { //Set parameters $imgManager->setTargetPath($subTargetPath . '/' . date('Ym') . '/'); $imgManager->setMapLargeImg(false); //Do not import large image, at least for now $imgManager->setPhotographerUid($GLOBALS['SYMB_UID']); $imgManager->setSortSeq(40); $imgManager->setOccid($newOccId); $imgManager->setTid($tid); $imgFileName = 'imgfile' . $i; if (!array_key_exists($imgFileName, $_FILES) || !$_FILES[$imgFileName]['name']) { break; } //Set image metadata variables if (isset($postArr['caption' . $i])) { $imgManager->setCaption($postArr['caption' . $i]); } if (isset($postArr['notes' . $i])) { $imgManager->setNotes($postArr['notes' . $i]); } //Image is a file upload if ($imgManager->uploadImage($imgFileName)) { $status = $imgManager->processImage(); } else { $status = false; } if (!$status) { //Get errors and warnings if ($errArr = $imgManager->getErrArr()) { foreach ($errArr as $errStr) { $this->errArr[] = $errStr; } } } $imgManager->reset(); } return $status; }