/** * @param $originalPrefix * @param $outputPrefix * @param $action * @param $extension * @param $data * @param array $extraParams * @return false|string */ public function buildLink($originalPrefix, $outputPrefix, $action, $extension, $data, array &$extraParams) { $parts = explode('/', $action, 2); $subComponentName = strtolower($parts[0]); if ($subComponentName === 'photos') { if (isset($data['photo_id']) && !isset($data['content_id'])) { $data['content_id'] = $data['photo_id']; } if (isset($data['title']) && $data['title'] == $data['content_id']) { $data['title'] = ''; } } if ($subComponentName === 'videos') { if (isset($data['title']) && $data['title'] == $data['content_id']) { $data['title'] = ''; } } if ($subComponentName === 'locations' && isset($data['location_url'])) { $data['location_url'] = sonnb_XenGallery_Model_Gallery::getTitleForUrl($data['location_url']); } if ($subComponentName === 'cameras' && isset($data['camera_url'])) { $data['camera_url'] = sonnb_XenGallery_Model_Gallery::getTitleForUrl($data['camera_url']); } $link = XenForo_Link::buildSubComponentLink($this->_subComponents, $outputPrefix, $action, $extension, $data); if (!$link) { $link = XenForo_Link::buildBasicLinkWithIntegerParam($outputPrefix, $action, $extension, $data, ''); } return $link; }
public function actionView() { $locationPortion = $this->_input->filterSingle('location_url', XenForo_Input::STRING); $locationPortion = sonnb_XenGallery_Model_Gallery::getTitleForUrl($locationPortion); if (!$locationPortion) { return $this->responseReroute(__CLASS__, 'index'); } $xenOptions = XenForo_Application::getOptions(); $itemsPerPage = $xenOptions->sonnbXG_photoPerPage; $locationModel = $this->_getLocationModel(); $page = max(1, $this->_input->filterSingle('page', XenForo_Input::UINT)); $conditions = array('location_url' => $locationPortion); $fetchOptions = array('page' => $page, 'perPage' => $itemsPerPage, 'order' => 'location_id', 'orderDirection' => 'asc'); $totalItems = $locationModel->countLocations($conditions, $fetchOptions); if (!$totalItems) { return $this->responseRedirect(XenForo_ControllerResponse_Redirect::RESOURCE_CANONICAL, XenForo_Link::buildPublicLink('gallery/locations')); } $locations = $locationModel->getLocations($conditions, $fetchOptions); $locations = $locationModel->prepareLocations($locations); $itemsGrouped = $this->_getGalleryModel()->groupContentsContentType($locations); $location = reset($locations); return $this->responseView('sonnb_XenGallery_ViewPublic_Location_View', 'sonnb_xengallery_location_view', array('location' => $location, 'locations' => $locations, 'totalItems' => $totalItems, 'itemsGrouped' => $itemsGrouped, 'page' => $page, 'itemsPerPage' => $itemsPerPage, 'breadCrumbs' => $locationModel->getLocationBreadCrumbs($location))); }
public function actionShopping() { $xenOptions = XenForo_Application::getOptions(); $cameraPortion = $this->_input->filterSingle('camera_url', XenForo_Input::STRING); $cameraPortion = sonnb_XenGallery_Model_Gallery::getTitleForUrl($cameraPortion); if (!$cameraPortion || !$xenOptions->sonnbXG_amazonEnable || !class_exists('SoapClient')) { return $this->responseReroute(__CLASS__, 'index'); } $cameraModel = $this->_getCameraModel(); $page = max(1, $this->_input->filterSingle('page', XenForo_Input::UINT)); $camera = $cameraModel->getCamerasByCameraUrl($cameraPortion); $camera = reset($camera); if ($camera) { $camera = $cameraModel->getDataCameras(array('camera_name' => $camera['camera_name'])); $camera = reset($camera); } $response = array(); if ($camera) { $camera['camera_url'] = $cameraPortion; $amazonEcs = new sonnb_XenGallery_Model_AmazonECS($xenOptions->sonnbXG_amazonAccessKey, $xenOptions->sonnbXG_amazonSecretKey, $xenOptions->sonnbXG_amazonSite, $xenOptions->sonnbXG_amazonAssociateTag); $amazonEcs->returnType(sonnb_XenGallery_Model_AmazonECS::RETURN_TYPE_ARRAY); $amazonEcs->page($page); try { $response = $amazonEcs->category('Electronics')->responseGroup('Large')->search($camera['camera_name']); } catch (Exception $e) { } } return $this->responseView('sonnb_XenGallery_ViewPublic_Camera_Shopping', 'sonnb_xengallery_camera_shopping', array('camera' => $camera, 'items' => empty($response['Items']['Item']) ? array() : $response['Items']['Item'], 'page' => $page, 'perPage' => 10, 'totalItems' => empty($response['Items']['TotalResults']) ? 0 : $response['Items']['TotalResults'], 'totalPages' => empty($response['Items']['TotalPages']) ? 0 : $response['Items']['TotalPages'], 'breadCrumbs' => $cameraModel->getCameraBreadCrumbs())); }
public function insertLocation($contentType, $contentId, $locationData) { $existingLocation = $this->getLocationByContentId($contentType, $contentId); $locationData['location_name'] = utf8_bad_replace($locationData['location_name'], ''); if ($existingLocation) { if (sonnb_XenGallery_Model_Gallery::getTitleForUrl($locationData['location_name']) !== sonnb_XenGallery_Model_Gallery::getTitleForUrl($existingLocation['location_name'])) { $this->_getDb()->update('sonnb_xengallery_location', array('location_lat' => floatval($locationData['location_lat']), 'location_lng' => floatval($locationData['location_lng']), 'location_name' => trim($locationData['location_name']), 'location_url' => sonnb_XenGallery_Model_Gallery::getTitleForUrl($locationData['location_name'])), 'location_id = ' . $existingLocation['location_id']); } } else { if (utf8_strlen($locationData['location_name'])) { $this->_getDb()->insert('sonnb_xengallery_location', array('content_type' => $contentType, 'content_id' => $contentId, 'location_lat' => floatval($locationData['location_lat']), 'location_lng' => floatval($locationData['location_lng']), 'location_name' => trim($locationData['location_name']), 'location_url' => sonnb_XenGallery_Model_Gallery::getTitleForUrl($locationData['location_name']))); } } }
public function insertLocation($data) { if (!isset($data['location_lat']) || !isset($data['location_lng'])) { return false; } if ($this->isChanged('content_location')) { $contentType = $this->get('content_type'); $contentId = $this->get('content_id'); $existingLocation = $this->_getLocationModel()->getLocationByContentId($contentType, $contentId); if ($existingLocation) { $this->_db->update('sonnb_xengallery_location', array('location_lat' => $data['location_lat'], 'location_lng' => $data['location_lng'], 'location_name' => trim($this->get('content_location')), 'location_url' => sonnb_XenGallery_Model_Gallery::getTitleForUrl(trim($this->get('content_location')))), 'location_id = ' . $existingLocation['location_id']); } else { if (utf8_strlen($this->get('content_location'))) { $this->_db->insert('sonnb_xengallery_location', array('content_type' => $contentType, 'content_id' => $contentId, 'location_lat' => $data['location_lat'], 'location_lng' => $data['location_lng'], 'location_name' => trim($this->get('content_location')), 'location_url' => sonnb_XenGallery_Model_Gallery::getTitleForUrl(trim($this->get('content_location'))))); } } } }
public function rebuildCounters(array $options = array(), array $contentData = null) { $contentDataModel = $this->_getPhotoDataModel(); $xenOptions = XenForo_Application::getOptions(); $options = array_merge(array('exif' => false, 'user' => false, 'index' => true, 'streams' => false, 'tags' => false, 'thumbnail' => false, 'thumbnail_information' => false, 'apply_watermark' => false, 'move' => false, 'move_target' => 'local', 'delete_original' => false), $options); if ($contentData === null) { $contentData = $contentDataModel->getDataByDataId($this->get('content_data_id')); } parent::rebuildCounters($options, $contentData); if (!empty($contentData) && (empty($contentData['large_height']) || empty($contentData['large_width']) || $options['thumbnail_information'])) { /* @var sonnb_XenGallery_DataWriter_ContentData $dataDw */ $dataDw = XenForo_DataWriter::create('sonnb_XenGallery_DataWriter_ContentData'); $dataDw->setExistingData($contentData['content_data_id']); $dataDw->rebuildThumbnailSize(); $dataDw->save(); } if (!XenForo_Application::getOptions()->sonnbXG_disableOriginal && !empty($contentData) && $options['exif']) { $db = $this->_db; $filePath = $this->_getContentDataModel()->getContentDataFile($contentData); $exif = $this->_getPhotoModel()->getPhotoExif($contentData, $filePath); $this->set('is_animated', $this->_getPhotoModel()->isAnimatedGif($filePath) ? 1 : 0); $this->set('photo_exif', $exif); if (!empty($exif['Model']) && utf8_strlen($exif['Model'])) { $photoId = $this->get('content_id'); $db->insert('sonnb_xengallery_photo_camera', array('photo_id' => $photoId, 'camera_name' => $exif['Model'], 'camera_url' => sonnb_XenGallery_Model_Gallery::getTitleForUrl($exif['Model']))); } } if ($options['delete_original'] && $xenOptions->sonnbXG_disableOriginal) { //Remove original photos only if disabled original is selected. $contentDataModel->deleteContentDataFile($contentData, sonnb_XenGallery_Model_ContentData::CONTENT_FILE_TYPE_ORIGINAL); } if (!empty($contentData) && $options['thumbnail'] && !$xenOptions->sonnbXG_disableOriginal) { $originalFile = $contentDataModel->getContentDataFile($contentData); if (is_file($originalFile)) { $tempFile = tempnam(XenForo_Helper_File::getTempDir(), 'xf'); $contentDataModel->copyFile($originalFile, $tempFile); $outputType = sonnb_XenGallery_Model_ContentData::$typeMap[$contentData['extension']]; $contentDataModel->exifRotate($tempFile, $outputType, $tempFile); $largeFile = $contentDataModel->getContentDataLargeThumbnailFile($contentData, true); $mediumFile = $contentDataModel->getContentDataMediumThumbnailFile($contentData, true); $smallFile = $contentDataModel->getContentDataSmallThumbnailFile($contentData, true); $dimensions = array(); $contentDataModel->createContentDataThumbnailFile($tempFile, $largeFile, $outputType, sonnb_XenGallery_Model_ContentData::CONTENT_FILE_TYPE_LARGE, $fallback, $dimensions, true); $contentDataModel->createContentDataThumbnailFile($largeFile, $mediumFile, $outputType, sonnb_XenGallery_Model_ContentData::CONTENT_FILE_TYPE_MEDIUM, $fallback, $dimensions); $contentDataModel->createContentDataThumbnailFile($largeFile, $smallFile, $outputType, sonnb_XenGallery_Model_ContentData::CONTENT_FILE_TYPE_SMALL, $fallback, $dimensions); $engine = $contentData['bdattachmentstore_engine']; $storeOptions = @unserialize($contentData['bdattachmentstore_options']); if (!empty($engine) && !empty($storeOptions)) { $fileModel = $this->_bdAttachmentStore_getFileModel(); $smallThumbFileStore = $contentDataModel->getStoreContentDataSmallThumbnailFile($contentData); $mediumThumbFileStore = $contentDataModel->getStoreContentDataMediumThumbnailFile($contentData); $largeThumbFileStore = $contentDataModel->getStoreContentDataLargeThumbnailFile($contentData); $fileModel->saveFile($engine, $storeOptions, $largeFile, $largeThumbFileStore, basename($largeThumbFileStore)); $fileModel->saveFile($engine, $storeOptions, $mediumFile, $mediumThumbFileStore, basename($mediumThumbFileStore)); $fileModel->saveFile($engine, $storeOptions, $smallFile, $smallThumbFileStore, basename($smallThumbFileStore)); if (empty($storeOptions['keepLocalCopy'])) { @unlink($largeFile); @unlink($mediumFile); @unlink($smallFile); } } if (!empty($dimensions)) { $this->_db->update('sonnb_xengallery_content_data', $dimensions, array('content_data_id = ?' => $contentData['content_data_id'])); } @unlink($tempFile); } } }