<?php
// Copyright 1999-2025. WebPros International GmbH. All rights reserved.
?>
<div class="aps-marketplace">
    <div class="aps-marketplace-details">
        <div id="ad-package-<?php echo $this->id; ?>" class="package-block">
            <div class="package-actions">
                <?php $blockCssStyle = 'action-1'; ?>
                <?php if ($this->buyNowButtonAvailable): ?>
                <div class="action-block <?php echo $blockCssStyle; ?>">
                    <p class="action-description"><?php echo $this->lmsg('smb.components.forms.aps.catalog.buttonBuyDescription'); ?></p>
                    <p class="action-control">
                        <?php echo $this->partial('partials/button.phtml', [
                            'id' => 'ad-buy-' . $this->id,
                            'title' => $this->lmsg('smb.components.forms.aps.catalog.buttonBuy'),
                            'description' => $this->lmsg('smb.components.forms.aps.catalog.buttonBuyTooltip'),
                            'onclick' => 'Smb.ApsLicense.buy("' . Plesk_Base_Utils_String::safeForJs($this->purchaseCommandAction) . '"); return false;',
                        ]); ?>
                    </p>
                </div>
                    <?php $blockCssStyle = 'action-2'; ?>
                <?php endif; ?>
                <?php if ($this->showInstallButton): ?>
                    <div class="action-block <?php echo $blockCssStyle; ?>">
                        <p class="action-description">
                            <?php echo $this->buyNowButtonAvailable ? $this->lmsg('smb.components.forms.aps.catalog.buttonInstallDescription') : $this->lmsg('smb.components.forms.aps.catalog.buttonInstallDescriptionFree'); ?>
                        </p>
                        <div class="action-control">
                            <?php
                            if ($this->hideQuickInstall) {
                                echo $this->partial('partials/button.phtml', [
                                    'id' => 'ad-advanced-install-' . $this->id,
                                    'title' => $this->lmsg('smb.components.forms.aps.catalog.buttonInstall'),
                                    'description' => $this->lmsg('smb.components.forms.aps.catalog.buttonAdvancedInstallTooltip'),
                                    'onclick' => $this->advancedInstallOnClick,
                                ]);
                            } else {
                                echo $this->partial('partials/split-button.phtml', [
                                    'id' => 'ad-install-' . $this->id,
                                    'renderTo' => new Zend_Json_Expr('document.querySelector("#ad-package-' . $this->id . ' .action-control")'),
                                    'title' => $this->lmsg('smb.components.forms.aps.catalog.buttonInstall'),
                                    'description' => $this->lmsg('smb.components.forms.aps.catalog.buttonInstallTooltip'),
                                    'onclick' => $this->installOnClick,
                                    'items' => [[
                                        'id' => 'ad-advanced-install-' . $this->id,
                                        'title' => $this->lmsg('smb.components.forms.aps.catalog.buttonAdvancedInstall'),
                                        'description' => $this->lmsg('smb.components.forms.aps.catalog.buttonAdvancedInstallTooltip'),
                                        'onclick' => $this->advancedInstallOnClick,
                                    ], [
                                        'id' => 'ad-install-old-version-' . $this->id,
                                        'title' => $this->lmsg('smb.components.forms.aps.catalog.buttonInstallOldVersion'),
                                        'description' => $this->lmsg('smb.components.forms.aps.catalog.buttonInstallOldVersionTooltip'),
                                        'submenu' => new Zend_Json_Expr('function(submenu) {apsCatalog.showAppVersions(' . $this->appData . ', submenu);}'),
                                    ]],
                                    'isMenuFlip' => true,
                                ]);
                            } ?>
                        </div>
                    </div>
                <?php elseif ($this->downloadUrl): ?>
                    <div class="action-block <?php echo $blockCssStyle; ?>">
                        <p class="action-description">
                            <?php echo $this->lmsg('smb.components.forms.aps.catalog.buttonDownloadDescription'); ?>
                        </p>
                        <p class="action-control">
                            <button class="btn" type="button" onclick="window.open('<?php echo $this->downloadUrl; ?>'); return false;">
                                <span><?php echo $this->lmsg('smb.components.forms.aps.catalog.buttonDownload'); ?></span>
                            </button>
                        </p>
                    </div>
                <?php endif; ?>
                <div class="action-block action-3">
                    <?php echo $this->requirementsPartial ?>
                    <?php if (
                        array_key_exists('applicationHomePage', $this->links['base']) &&
                        $this->links['base']['applicationHomePage']['href']
                    ): ?>
                        <div class="more-info">
                            <p>
                                <?php echo $this->lmsg('smb.components.forms.aps.catalog.marketplaceMoreInfo', [
                                    'link' =>
                                        '<a href="' . $this->escape($this->links['base']['applicationHomePage']['href']) . '" onclick="window.open(this.href); return false;">' .
                                            $this->lmsg('smb.components.forms.aps.catalog.marketplaceMoreInfoLink') .
                                        '</a>',
                                ]) ?>
                            </p>
                        </div>
                    <?php endif?>
                    <?php foreach((array)$this->infoLinks as $infoLink): ?>
                        <div class="more-info">
                            <p>
                                <a href="<?php echo $this->escape($infoLink['href']); ?>" onclick="window.open(this.href); return false;">
                                    <?php echo $this->escape($infoLink['label']); ?>
                                </a>
                            </p>
                        </div>
                    <?php endforeach; ?>
                </div>
            </div>
            <div class="package-content clearfix">
                <div class="package-info">
                    <div class="package-icon">
                        <?php echo $this->packageIcon;?>
                    </div>
                    <h3>
                        <span class="package-name"><?php echo $this->escape($this->name); ?></span>
                        <span class="package-version"><?php echo $this->lmsg('smb.components.forms.aps.catalog.version'); ?> <span id="package-version-to-install"><?php echo $this->escape($this->version); ?></span></span>
                    </h3>
                    <div class="package-summary"><?php echo $this->summary; ?></div>
                </div>
                <div class="package-description">
                    <p><b><?php echo $this->lmsg('smb.components.forms.aps.catalog.overview'); ?></b></p>
                    <p><?php echo $this->description; ?></p>
                </div>
                <div class="package-screenshot">
                    <?php echo $this->screenshotsPartial; ?>
                </div>
            </div>
        </div>
    </div>
</div>
