public function addImage($postArr) { $status = true; $imgManager = new ImageShared(); //Set target path $subTargetPath = $this->collMap['institutioncode']; if ($this->collMap['collectioncode']) { $subTargetPath .= '_' . $this->collMap['collectioncode']; } $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 ($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 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; }