Back to PhocacartSection class

Method renderTitleAndBackButton

public static
renderTitleAndBackButton
(mixed $sectionId, mixed $unitId)

Method renderTitleAndBackButton - Source code

public static function renderTitleAndBackButton($sectionId, $unitId)
{
    $s = PhocacartRenderStyle::getStyles();
    $section = PhocacartSection::getSectionById($sectionId);
    $unit = PhocacartUnit::getUnitById($unitId);
    $o = '<div class="ph-link-sections">';
    if (isset($section->title) && $section->title != '' && isset($unit->title) && $unit->title != '') {
        // Section including unit
        $unitSectionTitle = $section->title . ' (' . $unit->title . ')';
        $linkSection = Route::_(PhocacartRoute::getPosRoute(1, 0, 0, 'section', $sectionId));
        $o .= '<div class="' . $s['c']['btn-group'] . '" role="group">';
        $o .= '<a href="' . $linkSection . '" class="' . $s['c']['btn.btn-primary'] . ' active">';
        $o .= '<span class="' . $s['i']['back-category'] . ' icon-white" aria-hidden="true"></span></a>';
        $o .= '<a href="' . $linkSection . '" class="' . $s['c']['btn.btn-primary'] . ' active">' . $unitSectionTitle . '</a>';
        $o .= '</div>';
    } else {
        if (isset($section->title) && $section->title != '') {
            // One section without unit
            $unitSectionTitle = $section->title;
            $linkSection = Route::_(PhocacartRoute::getPosRoute(1, 0, 0, 'section', $sectionId));
            $o .= '<div class="' . $s['c']['btn-group'] . '" role="group">';
            $o .= '<a href="' . $linkSection . '" class="' . $s['c']['btn.btn-primary'] . ' active">';
            $o .= '<span class="' . $s['i']['back-category'] . ' icon-white" aria-hidden="true"></span></a>';
            $o .= '<a href="' . $linkSection . '" class="' . $s['c']['btn.btn-primary'] . ' active">' . $unitSectionTitle . '</a>';
            $o .= '</div>';
        } else {
            $sections = PhocacartSection::getSections();
            $linkSections = Route::_(PhocacartRoute::getPosRoute(1, 0, 0, 'section'));
            if (!empty($sections)) {
                foreach ($sections as $k => $v) {
                    $linkSection = Route::_(PhocacartRoute::getPosRoute(1, 0, 0, 'section', (int) $v->id));
                    $o .= '<div class="' . $s['c']['btn-group'] . '" role="group">';
                    $o .= '<a href="' . $linkSection . '" class="' . $s['c']['btn.btn-primary'] . ' active">';
                    $o .= '<span class="' . $s['i']['back-category'] . ' icon-white" aria-hidden="true"></span></a>';
                    $o .= '<a href="' . $linkSection . '" class="' . $s['c']['btn.btn-primary'] . ' active">' . Text::_('COM_PHOCACART_SECTIONS') . '</a>';
                    $o .= '</div>';
                    break;
                }
            } else {
                $o .= '<div> </div>';
            }
        }
    }
    $o .= '</div>';
    return $o;
}