/**
  * run function from external cObject
  * @param	object		tx_div2007_alpha_language_base object
  */
 function load_noLinkExtCobj_fh001($langObj)
 {
     if ($langObj->conf['externalProcessing_final'] || is_array($langObj->conf['externalProcessing_final.'])) {
         // If there is given another cObject for the final order confirmation template!
         $langObj->externalCObject = tx_div2007_alpha::getExternalCObject_fh001($langObj, 'externalProcessing_final');
     }
 }
    /**
     * Returns a results browser. This means a bar of page numbers plus a "previous" and "next" link. For each entry in the bar the ctrlVars "pointer" will be pointing to the "result page" to show.
     * Using $this->ctrlVars['pointer'] as pointer to the page to display. Can be overwritten with another string ($pointerName) to make it possible to have more than one pagebrowser on a page)
     * Using $this->internal['resCount'], $this->internal['limit'] and $this->internal['maxPages'] for count number, how many results to show and the max number of pages to include in the browse bar.
     * Using $this->internal['dontLinkActivePage'] as switch if the active (current) page should be displayed as pure text or as a link to itself
     * Using $this->internal['bShowFirstLast'] as switch if the two links named "<< First" and "LAST >>" will be shown and point to the first or last page.
     * Using $this->internal['pagefloat']: this defines were the current page is shown in the list of pages in the Pagebrowser. If this var is an integer it will be interpreted as position in the list of pages. If its value is the keyword "center" the current page will be shown in the middle of the pagelist.
     * Using $this->internal['showRange']: this var switches the display of the pagelinks from pagenumbers to ranges f.e.: 1-5 6-10 11-15... instead of 1 2 3...
     * Using $this->pi_isOnlyFields: this holds a comma-separated list of fieldnames which - if they are among the GETvars - will not disable caching for the page with pagebrowser.
     *
     * The third parameter is an array with several wraps for the parts of the pagebrowser. The following elements will be recognized:
     * disabledLinkWrap, inactiveLinkWrap, activeLinkWrap, browseLinksWrap, showResultsWrap, showResultsNumbersWrap, browseBoxWrap.
     *
     * If $wrapArr['showResultsNumbersWrap'] is set, the formatting string is expected to hold template markers (###FROM###, ###TO###, ###OUT_OF###, ###FROM_TO###, ###CURRENT_PAGE###, ###TOTAL_PAGES###)
     * otherwise the formatting string is expected to hold sprintf-markers (%s) for from, to, outof (in that sequence)
     *
     * @param	object		parent object of type tx_div2007_alpha_browse_base
     * @param	object		language object of type tx_div2007_alpha_language_base
     * @param	object		cObject
     * @param	string		prefix id
     * @param	boolean		if CSS styled content with div tags shall be used
     * @param	integer		determines how the results of the pagerowser will be shown. See description below
     * @param	string		Attributes for the table tag which is wrapped around the table cells containing the browse links
     *						(only used if no CSS style is set)
     * @param	array		Array with elements to overwrite the default $wrapper-array.
     * @param	string		varname for the pointer.
     * @param	boolean		enable htmlspecialchars() for the tx_div2007_alpha::getLL function (set this to FALSE if you want e.g. use images instead of text for links like 'previous' and 'next').
     * @param	array		Additional query string to be passed as parameters to the links
     * @return	string		Output HTML-Table, wrapped in <div>-tags with a class attribute (if $wrapArr is not passed,
     */
    public static function &list_browseresults_fh002($pObject, $langObj, $cObj, $prefixId, $bCSSStyled = TRUE, $showResultCount = 1, $browseParams = '', $wrapArr = array(), $pointerName = 'pointer', $hscText = TRUE, $addQueryString = array())
    {
        // example $wrapArr-array how it could be traversed from an extension
        /* $wrapArr = array(
        			'showResultsNumbersWrap' => '<span class="showResultsNumbersWrap">|</span>'
        		); */
        $linkArray = $addQueryString;
        // Initializing variables:
        $pointer = intval($pObject->ctrlVars[$pointerName]);
        $count = intval($pObject->internal['resCount']);
        $limit = tx_div2007_core::intInRange($pObject->internal['limit'], 1, 1000);
        $totalPages = ceil($count / $limit);
        $maxPages = tx_div2007_core::intInRange($pObject->internal['maxPages'], 1, 100);
        $bUseCache = self::autoCache_fh001($pObject, $pObject->ctrlVars);
        // $showResultCount determines how the results of the pagerowser will be shown.
        // If set to 0: only the result-browser will be shown
        //	 		 1: (default) the text "Displaying results..." and the result-browser will be shown.
        //	 		 2: only the text "Displaying results..." will be shown
        $showResultCount = intval($showResultCount);
        // if this is set, two links named "<< First" and "LAST >>" will be shown and point to the very first or last page.
        $bShowFirstLast = $pObject->internal['bShowFirstLast'];
        // if this has a value the "previous" button is always visible (will be forced if "bShowFirstLast" is set)
        $alwaysPrev = $bShowFirstLast ? TRUE : $pObject->internal['bAlwaysPrev'];
        if (isset($pObject->internal['pagefloat'])) {
            if (strtoupper($pObject->internal['pagefloat']) == 'CENTER') {
                $pagefloat = ceil(($maxPages - 1) / 2);
            } else {
                // pagefloat set as integer. 0 = left, value >= $pObject->internal['maxPages'] = right
                $pagefloat = tx_div2007_core::intInRange($pObject->internal['pagefloat'], -1, $maxPages - 1);
            }
        } else {
            $pagefloat = -1;
            // pagefloat disabled
        }
        // default values for "traditional" wrapping with a table. Can be overwritten by vars from $wrapArr
        if ($bCSSStyled) {
            $wrapper['disabledLinkWrap'] = '<span class="disabledLinkWrap">|</span>';
            $wrapper['inactiveLinkWrap'] = '<span class="inactiveLinkWrap">|</span>';
            $wrapper['activeLinkWrap'] = '<span class="activeLinkWrap">|</span>';
            $wrapper['browseLinksWrap'] = '<div class="browseLinksWrap">|</div>';
            $wrapper['disabledNextLinkWrap'] = '<span class="pagination-next">|</span>';
            $wrapper['inactiveNextLinkWrap'] = '<span class="pagination-next">|</span>';
            $wrapper['disabledPreviousLinkWrap'] = '<span class="pagination-previous">|</span>';
            $wrapper['inactivePreviousLinkWrap'] = '<span class="pagination-previous">|</span>';
        } else {
            $wrapper['disabledLinkWrap'] = '<td nowrap="nowrap"><p>|</p></td>';
            $wrapper['inactiveLinkWrap'] = '<td nowrap="nowrap"><p>|</p></td>';
            $wrapper['activeLinkWrap'] = '<td' . self::classParam_fh001('browsebox-SCell', '', $prefixId) . ' nowrap="nowrap"><p>|</p></td>';
            $wrapper['browseLinksWrap'] = trim('<table ' . $browseParams) . '><tr>|</tr></table>';
        }
        if (is_array($pObject->internal['image']) && $pObject->internal['image']['path']) {
            $onMouseOver = $pObject->internal['image']['onmouseover'] ? 'onmouseover="' . $pObject->internal['image']['onmouseover'] . '" ' : '';
            $onMouseOut = $pObject->internal['image']['onmouseout'] ? 'onmouseout="' . $pObject->internal['image']['onmouseout'] . '" ' : '';
            $onMouseOverActive = $pObject->internal['imageactive']['onmouseover'] ? 'onmouseover="' . $pObject->internal['imageactive']['onmouseover'] . '" ' : '';
            $onMouseOutActive = $pObject->internal['imageactive']['onmouseout'] ? 'onmouseout="' . $pObject->internal['imageactive']['onmouseout'] . '" ' : '';
            $wrapper['browseTextWrap'] = '<img src="' . $pObject->internal['image']['path'] . $pObject->internal['image']['filemask'] . '" ' . $onMouseOver . $onMouseOut . '>';
            $wrapper['activeBrowseTextWrap'] = '<img src="' . $pObject->internal['image']['path'] . $pObject->internal['imageactive']['filemask'] . '" ' . $onMouseOverActive . $onMouseOutActive . '>';
        }
        if ($bCSSStyled) {
            $wrapper['showResultsWrap'] = '<div class="showResultsWrap">|</div>';
            $wrapper['browseBoxWrap'] = '<div class="browseBoxWrap">|</div>';
        } else {
            $wrapper['showResultsWrap'] = '<p>|</p>';
            $wrapper['browseBoxWrap'] = '
			<!--
				List browsing box:
			-->
			<div ' . self::classParam_fh001('browsebox', '', $prefixId) . '>
				|
			</div>';
        }
        // now overwrite all entries in $wrapper which are also in $wrapArr
        $wrapper = array_merge($wrapper, $wrapArr);
        if ($showResultCount != 2) {
            //show pagebrowser
            if ($pagefloat > -1) {
                $lastPage = min($totalPages, max($pointer + 1 + $pagefloat, $maxPages));
                $firstPage = max(0, $lastPage - $maxPages);
            } else {
                $firstPage = 0;
                $lastPage = tx_div2007_core::intInRange($totalPages, 1, $maxPages);
            }
            $links = array();
            // Make browse-table/links:
            if ($bShowFirstLast) {
                // Link to first page
                if ($pointer > 0) {
                    $linkArray[$pointerName] = null;
                    $links[] = $cObj->wrap(self::linkTP_keepCtrlVars($pObject, $cObj, $prefixId, tx_div2007_alpha::getLL($langObj, 'list_browseresults_first', '<< First', $hscText), $linkArray, $bUseCache), $wrapper['inactiveLinkWrap']);
                } else {
                    $links[] = $cObj->wrap(tx_div2007_alpha::getLL($langObj, 'list_browseresults_first', '<< First', $hscText), $wrapper['disabledLinkWrap']);
                }
            }
            if ($alwaysPrev >= 0) {
                // Link to previous page
                $previousText = tx_div2007_alpha::getLL($langObj, 'list_browseresults_prev', '< Previous', $hscText);
                if ($pointer > 0) {
                    $linkArray[$pointerName] = $pointer - 1 ? $pointer - 1 : '';
                    $links[] = $cObj->wrap(self::linkTP_keepCtrlVars($pObject, $cObj, $prefixId, $previousText, $linkArray, $bUseCache), $wrapper['inactiveLinkWrap']);
                } elseif ($alwaysPrev) {
                    $links[] = $cObj->wrap($previousText, $wrapper['disabledLinkWrap']);
                }
            }
            for ($a = $firstPage; $a < $lastPage; $a++) {
                // Links to pages
                $pageText = '';
                if ($pObject->internal['showRange']) {
                    $pageText = $a * $limit + 1 . '-' . min($count, ($a + 1) * $limit);
                } else {
                    if ($totalPages > 1) {
                        if ($wrapper['browseTextWrap']) {
                            if ($pointer == $a) {
                                // current page
                                $pageText = $cObj->wrap($a + 1, $wrapper['activeBrowseTextWrap']);
                            } else {
                                $pageText = $cObj->wrap($a + 1, $wrapper['browseTextWrap']);
                            }
                        } else {
                            $pageText = trim(tx_div2007_alpha::getLL($langObj, 'list_browseresults_page', 'Page', $hscText)) . ' ' . ($a + 1);
                        }
                    }
                }
                if ($pointer == $a) {
                    // current page
                    if ($pObject->internal['dontLinkActivePage']) {
                        $links[] = $cObj->wrap($pageText, $wrapper['activeLinkWrap']);
                    } else {
                        if ($pageText != '') {
                            $linkArray[$pointerName] = $a ? $a : '';
                            $link = self::linkTP_keepCtrlVars($pObject, $cObj, $prefixId, $pageText, $linkArray, $bUseCache);
                            $links[] = $cObj->wrap($link, $wrapper['activeLinkWrap']);
                        }
                    }
                } else {
                    if ($pageText != '') {
                        $linkArray[$pointerName] = $a ? $a : '';
                        $links[] = $cObj->wrap(self::linkTP_keepCtrlVars($pObject, $cObj, $prefixId, $pageText, $linkArray, $bUseCache), $wrapper['inactiveLinkWrap']);
                    }
                }
            }
            if ($pointer < $totalPages - 1 || $bShowFirstLast) {
                $nextText = tx_div2007_alpha::getLL($langObj, 'list_browseresults_next', 'Next >', $hscText);
                if ($pointer == $totalPages - 1) {
                    // Link to next page
                    $links[] = $cObj->wrap($nextText, $wrapper['disabledLinkWrap']);
                } else {
                    $linkArray[$pointerName] = $pointer + 1;
                    $links[] = $cObj->wrap(self::linkTP_keepCtrlVars($pObject, $cObj, $prefixId, $nextText, $linkArray, $bUseCache), $wrapper['inactiveLinkWrap']);
                }
            }
            if ($bShowFirstLast) {
                // Link to last page
                if ($pointer < $totalPages - 1) {
                    $linkArray[$pointerName] = $totalPages - 1;
                    $links[] = $cObj->wrap(self::linkTP_keepCtrlVars($pObject, $cObj, $prefixId, tx_div2007_alpha::getLL($langObj, 'list_browseresults_last', 'Last >>', $hscText), $linkArray, $bUseCache), $wrapper['inactiveLinkWrap']);
                } else {
                    $links[] = $cObj->wrap(tx_div2007_alpha::getLL($langObj, 'list_browseresults_last', 'Last >>', $hscText), $wrapper['disabledLinkWrap']);
                }
            }
            $theLinks = $cObj->wrap(implode(chr(10), $links), $wrapper['browseLinksWrap']);
        } else {
            $theLinks = '';
        }
        $pR1 = $pointer * $limit + 1;
        $pR2 = $pointer * $limit + $limit;
        if ($showResultCount) {
            if (isset($wrapper['showResultsNumbersWrap'])) {
                // this will render the resultcount in a more flexible way using markers (new in TYPO3 3.8.0).
                // the formatting string is expected to hold template markers (see function header). Example: 'Displaying results ###FROM### to ###TO### out of ###OUT_OF###'
                $markerArray['###FROM###'] = $cObj->wrap($count > 0 ? $pR1 : 0, $wrapper['showResultsNumbersWrap']);
                $markerArray['###TO###'] = $cObj->wrap(min($count, $pR2), $wrapper['showResultsNumbersWrap']);
                $markerArray['###OUT_OF###'] = $cObj->wrap($count, $wrapper['showResultsNumbersWrap']);
                $markerArray['###FROM_TO###'] = $cObj->wrap(($count > 0 ? $pR1 : 0) . ' ' . tx_div2007_alpha::getLL($langObj, 'list_browseresults_to', 'to') . ' ' . min($count, $pR2), $wrapper['showResultsNumbersWrap']);
                $markerArray['###CURRENT_PAGE###'] = $cObj->wrap($pointer + 1, $wrapper['showResultsNumbersWrap']);
                $markerArray['###TOTAL_PAGES###'] = $cObj->wrap($totalPages, $wrapper['showResultsNumbersWrap']);
                $list_browseresults_displays = tx_div2007_alpha::getLL($langObj, 'list_browseresults_displays_marker', 'Displaying results ###FROM### to ###TO### out of ###OUT_OF###');
                // substitute markers
                $resultCountMsg = $cObj->substituteMarkerArray($list_browseresults_displays, $markerArray);
            } else {
                // render the resultcount in the "traditional" way using sprintf
                $resultCountMsg = sprintf(str_replace('###SPAN_BEGIN###', '<span' . self::classParam_fh001('browsebox-strong', '', $prefixId) . '>', tx_div2007_alpha::getLL($langObj, 'list_browseresults_displays', 'Displaying results ###SPAN_BEGIN###%s to %s</span> out of ###SPAN_BEGIN###%s</span>')), $count > 0 ? $pR1 : 0, min($count, $pR2), $count);
            }
            $resultCountMsg = $cObj->wrap($resultCountMsg, $wrapper['showResultsWrap']);
        } else {
            $resultCountMsg = '';
        }
        $rc = $cObj->wrap($resultCountMsg . $theLinks, $wrapper['browseBoxWrap']);
        return $rc;
    }