request->get('inlineMedicalEdit', 0); $openProgressEditId = (int)Yii::$app->request->get('inlineProgressEdit', 0); $layoutMode = isset($layoutMode) ? trim((string)$layoutMode) : 'default'; $isTabletLayout = $layoutMode === 'tablet'; $medicalVisitsUrl = $space->createUrl('/animal_management/animals/medical-visits', ['id' => (int)$animal->id]); $progressUpdatesUrl = $space->createUrl('/animal_management/animals/progress-updates', ['id' => (int)$animal->id]); $transferRequestUrl = $space->createUrl('/animal_management/animals/transfer', ['id' => (int)$animal->id]); $tabletBackUrl = $space->createUrl('/animal_management/animals/index', ['view' => 'tablet']); $transferById = []; foreach ($transfers as $transfer) { if ($transfer instanceof AnimalTransfer) { $transferById[(int)$transfer->id] = $transfer; } } $coverImageUrl = trim((string)$animalCoverImageUrl); $profileImageUrl = trim((string)($animalProfileImageUrl ?? '')); $hasCoverImage = $coverImageUrl !== '' && (preg_match('/^https?:\/\//i', $coverImageUrl) || substr($coverImageUrl, 0, 1) === '/'); $hasProfileImage = $profileImageUrl !== '' && (preg_match('/^https?:\/\//i', $profileImageUrl) || substr($profileImageUrl, 0, 1) === '/'); $statusLabel = Animal::statusOptions()[$animal->status] ?? (string)$animal->status; $detailFieldMap = [ 'name' => (string)$animal->getDisplayName(), 'species' => (string)$animal->species, 'breed' => (string)$animal->breed, 'sex' => (string)$animal->sex, 'status' => (string)$statusLabel, 'location_name' => (string)$animal->location_name, 'animal_uid' => (string)$animal->animal_uid, 'public_summary' => trim((string)$animal->public_summary), 'last_medical' => !empty($medicalVisits) ? DateDisplayHelper::format((string)$medicalVisits[0]->visit_at) : '', ]; $heroFieldValues = []; foreach ($detailHeroFields as $fieldKey) { $fieldKey = trim((string)$fieldKey); if ($fieldKey === '' || $fieldKey === 'name' || !array_key_exists($fieldKey, $detailFieldMap)) { continue; } $value = trim((string)$detailFieldMap[$fieldKey]); if ($value === '') { continue; } $heroFieldValues[] = $value; } $customHeroCount = 0; foreach ($customFieldValues as $customField) { if ($customHeroCount >= 3) { break; } $label = trim((string)($customField['label'] ?? '')); $value = trim((string)($customField['value'] ?? '')); if ($label === '' || $value === '') { continue; } $heroFieldValues[] = $label . ': ' . $value; $customHeroCount++; } if (class_exists(GalleryAssets::class)) { GalleryAssets::register($this); } $uiGalleryId = 'animal-gallery-' . (int)$animal->id; $showDonationSettingsButton = $canManage && $space->moduleManager->isEnabled('donations'); $existingDonationGoal = null; $profileTileOverlayAddonHtml = ''; if ($space->moduleManager->isEnabled('donations')) { $donationGoalClass = 'humhub\\modules\\donations\\models\\DonationGoal'; if (class_exists($donationGoalClass) && Yii::$app->db->schema->getTableSchema($donationGoalClass::tableName(), true) !== null ) { $existingDonationGoal = $donationGoalClass::find() ->where([ 'contentcontainer_id' => (int)$space->contentcontainer_id, 'goal_type' => $donationGoalClass::TYPE_ANIMAL, 'target_animal_id' => (int)$animal->id, ]) ->orderBy(['is_active' => SORT_DESC, 'id' => SORT_DESC]) ->one(); } } $profileDonationToggleInputId = 'animal-profile-donation-toggle-' . (int)$animal->id; $profileDonationInlineFormId = 'animal-profile-donation-inline-' . (int)$animal->id; $profileDonationFileFieldId = 'animal-profile-donation-image-file-' . (int)$animal->id; $profileDonationPreviewId = 'animal-profile-donation-image-preview-' . (int)$animal->id; $profileCreateInlineGoalUrl = $space->createUrl('/donations/settings/create-animal-goal-inline', [ 'animalId' => (int)$animal->id, ]); $profileGalleryUrls = []; foreach ($galleryItems as $galleryItem) { if (!$galleryItem instanceof AnimalGalleryItem) { continue; } $url = trim((string)$galleryItem->getImageUrl()); if ($url === '') { continue; } $profileGalleryUrls[] = $url; } $profileGalleryUrls = array_slice($profileGalleryUrls, 0, 8); $profileDefaultGoalTitle = Yii::t('DonationsModule.base', '{animalName} Care Fund', [ 'animalName' => (string)$animal->getDisplayName(), ]); $profileExistingGoalId = is_object($existingDonationGoal) ? (int)($existingDonationGoal->id ?? 0) : 0; $profileExistingGoalTitle = trim((string)(is_object($existingDonationGoal) ? ($existingDonationGoal->title ?? '') : '')); $profileExistingGoalTargetAmount = is_object($existingDonationGoal) ? (float)($existingDonationGoal->target_amount ?? 0) : 0.0; $profileExistingGoalDescription = trim((string)(is_object($existingDonationGoal) ? ($existingDonationGoal->description ?? '') : '')); $profileExistingGoalImage = trim((string)(is_object($existingDonationGoal) ? ($existingDonationGoal->image_path ?? '') : '')); $profileExistingGoalActive = is_object($existingDonationGoal) ? (int)($existingDonationGoal->is_active ?? 1) : 1; if ($profileExistingGoalTitle === '') { $profileExistingGoalTitle = $profileDefaultGoalTitle; } if (class_exists(AnimalTileRenderEvent::class) && $space->moduleManager->isEnabled('donations')) { $profileTileRenderEvent = new AnimalTileRenderEvent([ 'animal' => $animal, 'contentContainer' => $space, 'existingDonationGoal' => $existingDonationGoal, 'showDonationSettingsButton' => $showDonationSettingsButton, 'donationToggleInputId' => $profileDonationToggleInputId, 'donationInlineFormId' => $profileDonationInlineFormId, ]); Event::trigger(AnimalTileRenderEvent::class, AnimalTileRenderEvent::EVENT_RENDER_OVERLAY, $profileTileRenderEvent); $profileTileOverlayAddonHtml = $profileTileRenderEvent->getHtml(); } $profileInlineFormBackgroundStyle = 'padding:12px;border-top:1px solid #e6edf5;display:none;background:#fff;'; if ($profileExistingGoalImage !== '') { $profileInlineFormBackgroundStyle = 'padding:12px;border-top:1px solid #e6edf5;display:none;' . 'background-image:linear-gradient(rgba(255,255,255,0.35),rgba(255,255,255,0.45)),url(' . Html::encode($profileExistingGoalImage) . ');' . 'background-size:cover;background-position:center;'; } ?>