Back to PhocacartUtilsExtension class

Method getExtensionsObtainTypeButton

public static
getExtensionsObtainTypeButton
(mixed $type, mixed $downloadSource, mixed $extension)

Method getExtensionsObtainTypeButton - Source code

public static function getExtensionsObtainTypeButton($type, $downloadSource, $extension)
{
    // We are now in Joomla 4
    $download = '';
    if (isset($downloadSource['4']) && $downloadSource['4'] != '') {
        $download = $downloadSource['4'];
        // $downloadSource['5']
    }
    $extensionVersion = $extension['version4'];
    // $extension['version5']
    $s = PhocacartRenderStyle::getStyles();
    $o = '';
    // BUTTON
    $link = '';
    $icon = '';
    $text = '';
    $class = '';
    $target = '';
    // TEXT
    $iconTxt = '';
    $classTxt = '';
    $textTxt = '';
    if (($type == 0 || $type == 4) && $extension['installed'] == false) {
        $link = $download;
        $icon = 'shopping-cart';
        $class = 'btn-buy';
        $text = Text::_('COM_PHOCACART_BUY_NOW');
        $target = 'target="_blank"';
    } else {
        if ($extension['installed']) {
            if ($extension['enabled']) {
                if ($extension['versioncurrent']) {
                    if ($type == 0) {
                        // 0 - Paid but update - installed but updated paid version found
                        $link = $download;
                        $icon = 'shopping-cart';
                        $class = 'btn-buy';
                        $text = Text::_('COM_PHOCACART_REQUEST') . ' (' . $extensionVersion . ')';
                        $target = 'target="_blank"';
                        $iconTxt = 'ok';
                        $classTxt = 'ph-success-txt';
                        $textTxt = Text::_('COM_PHOCACART_INSTALLED');
                    } else {
                        if ($type == 4) {
                            // 0 - Paid but update - installed but updated paid version found
                            $link = $download;
                            $icon = 'shopping-cart';
                            $class = 'btn-buy';
                            $text = Text::_('COM_PHOCACART_REQUEST') . ' (' . $extensionVersion . ')';
                            $target = 'target="_blank"';
                            $iconTxt = 'ok';
                            $classTxt = 'ph-success-txt';
                            $textTxt = Text::_('COM_PHOCACART_INSTALLED');
                        } else {
                            if ($type == 1) {
                                // Direct Install
                                $link = '';
                                if ($download != '') {
                                    $link = JRoute::_('index.php?option=com_phocacart&task=phocacartextension.install&link=' . base64_encode($download) . '&' . JSession::getFormToken() . '=1', false);
                                    //SEC
                                }
                                $icon = 'refresh';
                                $class = 'btn-success';
                                $text = Text::_('COM_PHOCACART_UPDATE') . ' (' . $extensionVersion . ')';
                                $target = '';
                                $iconTxt = 'ok';
                                $classTxt = 'ph-success-txt';
                                $textTxt = Text::_('COM_PHOCACART_INSTALLED');
                            } else {
                                // 2 - Download, 3 Download/Register
                                $link = $download;
                                $icon = 'download';
                                $class = 'btn-primary';
                                $text = Text::_('COM_PHOCACART_DOWNLOAD') . ' (' . $extensionVersion . ')';
                                $target = 'target="_blank"';
                                $iconTxt = 'ok';
                                $classTxt = 'ph-success-txt';
                                $textTxt = Text::_('COM_PHOCACART_INSTALLED');
                            }
                        }
                    }
                } else {
                    // Installed - version OK
                    $iconTxt = 'ok';
                    $classTxt = 'ph-success-txt';
                    $textTxt = Text::_('COM_PHOCACART_INSTALLED');
                }
            } else {
                $iconTxt = 'remove';
                $classTxt = 'ph-disabled-txt';
                $textTxt = Text::_('COM_PHOCACART_DISABLED');
            }
        } else {
            if ($type == 1) {
                // Direct Install
                $link = '';
                if ($download != '') {
                    $link = Route::_('index.php?option=com_phocacart&task=phocacartextension.install&link=' . base64_encode($download) . '&' . Session::getFormToken() . '=1', false);
                }
                $icon = 'download-alt';
                $class = 'btn-success';
                $text = Text::_('COM_PHOCACART_INSTALL');
                $target = '';
            } else {
                // 2 - Download, 3 Download/Register
                $link = $download;
                $icon = 'download';
                $class = 'btn-primary';
                $text = Text::_('COM_PHOCACART_DOWNLOAD');
                $target = 'target="_blank"';
            }
        }
    }
    $o .= '<div class="ph-center ph-extension-button">';
    if ($textTxt != '' && $classTxt != '' && $iconTxt != '') {
        $o .= '<div class="' . $classTxt . '"><span class="' . $s['i'][$iconTxt] . '"></span> ' . $textTxt . '</div>';
    }
    if ($link != '' && $icon != '' && $text != '') {
        $o .= '<a href="' . $link . '" ' . $target . ' class="btn btn-small ' . $class . '">';
        $o .= '<span class="' . $s['i'][$icon] . '"></span> ';
        $o .= $text . '</a>';
    }
    $o .= '</div>';
    return $o;
}