/**
  * render textlink for normal option
  *
  * @param integer $filterUid The filter uid
  * @param array $option An array containing the option
  * @return string A HTML formatted textlink
  */
 public function renderTextlinkForNormalOption($filterUid, $option)
 {
     // if multi is set AND option(s) of current filter is set by piVars
     // then more than one entry can be selected
     //if($this->pObj->piVars['multi'] && $this->pObj->piVars['filter'][$filterUid][$option['uid']]) {
     $markerArray['###CLASS###'] = 'normal';
     $markerArray['###TEXTLINK###'] = $this->generateLink($filterUid, $option);
     return $this->cObj->substituteMarkerArray($this->templateArray['options'], $markerArray);
 }
Exemplo n.º 2
0
 /**
  * Main function, called from TypoScript
  * A content object that renders "tt_content" records. See the comment to this class for TypoScript example of how to trigger it.
  * This detects the CType of the current content element and renders it accordingly. Only wellknown types are rendered.
  *
  * @param	tslib_pibase	$invokingObj the tt_news object
  * @return	string			Plain text content
  */
 function extraCodesProcessor(&$invokingObj)
 {
     $content = '';
     $this->conf = $invokingObj->conf;
     if ($this->conf['code'] == 'PLAINTEXT') {
         $this->cObj = $invokingObj->cObj;
         $this->config = $invokingObj->config;
         $this->tt_news_uid = $invokingObj->tt_news_uid;
         $this->enableFields = $invokingObj->enableFields;
         $this->sys_language_mode = $invokingObj->sys_language_mode;
         $this->templateCode = $invokingObj->templateCode;
         $this->renderPlainText = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_directmail_pi1');
         $this->renderPlainText->init($GLOBALS['TSFE']->tmpl->setup['plugin.']['tx_directmail_pi1.']);
         $this->renderPlainText->cObj = $this->cObj;
         $this->renderPlainText->labelsList = 'tt_news_author_prefix,tt_news_author_date_prefix,tt_news_author_email_prefix,tt_news_short_header,tt_news_bodytext_header';
         $lines = array();
         $singleWhere = 'tt_news.uid=' . intval($this->tt_news_uid);
         $singleWhere .= ' AND type=0' . $this->enableFields;
         // type=0->only real news.
         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tt_news', $singleWhere);
         $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res);
         $GLOBALS['TYPO3_DB']->sql_free_result($res);
         // get the translated record if the content language is not the default language
         if ($GLOBALS['TSFE']->sys_language_content) {
             $OLmode = $this->sys_language_mode == 'strict' ? 'hideNonTranslated' : '';
             $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay('tt_news', $row, $GLOBALS['TSFE']->sys_language_content, $OLmode);
         }
         if (is_array($row)) {
             // Render the title
             $lines[] = $this->renderPlainText->renderHeader($row['title']);
             // Render author of the tt_news record
             $lines[] = $this->renderAuthor($row);
             // Render the short version of the tt_news record
             $lines[] = $this->renderPlainText->breakContent(strip_tags($this->renderPlainText->parseBody($row['short'], 'tt_news_short')));
             // Render the main text of the tt_news record
             $lines[] = $this->renderPlainText->breakContent(strip_tags($this->renderPlainText->parseBody($row['bodytext'], 'tt_news_bodytext')));
             // Render the images of the tt_news record.
             $lines[] = $this->getImages($row);
             // Render the downloads of the tt_news record.
             $lines[] = $this->renderPlainText->renderUploads($row['news_files']);
         } elseif ($this->sys_language_mode == 'strict' && $this->tt_news_uid) {
             $noTranslMsg = $this->cObj->stdWrap($invokingObj->pi_getLL('noTranslMsg', 'Sorry, there is no translation for this news-article'), $this->conf['noNewsIdMsg_stdWrap.']);
             $content .= $noTranslMsg;
         }
         if (!empty($lines)) {
             $content = implode(LF, $lines) . $content;
         }
         // Substitute labels
         if (!empty($content)) {
             $markerArray = array();
             $markerArray = $this->renderPlainText->addLabelsMarkers($markerArray);
             $content = $this->cObj->substituteMarkerArray($content, $markerArray);
         }
     }
     return $content;
 }
 /**
  * The main entry point of this class
  * It will return the complete sorting HTML
  *
  * @return string HTML
  */
 public function renderSorting()
 {
     // show sorting:
     // if show Sorting is activated in FlexForm
     // if a value to sortBy is set in FlexForm (title, relevance, sortdate, what ever...)
     // if there are any entries in current search results
     if ($this->conf['showSortInFrontend'] && !empty($this->conf['sortByVisitor']) && $this->pObj->numberOfResults) {
         // loop all allowed orderings
         foreach ($this->sortBy as $field) {
             // we can't sort by score if there is no sword given
             if ($this->pObj->sword != '' || $field != 'score') {
                 $sortByDir = $this->getDefaultSortingDirection($field);
                 if (TYPO3_VERSION_INTEGER >= 7000000) {
                     $dbOrdering = TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(' ', $this->db->getOrdering());
                 } else {
                     $dbOrdering = t3lib_div::trimExplode(' ', $this->db->getOrdering());
                 }
                 /* if ordering direction is the same change it
                  *
                  * Explaintation:
                  * No ordering is active. Default Ordering by db is "sortdate desc".
                  * Default ordering by current field is also "sortdate desc".
                  * So...if you click the link for sortdate it will sort the results by "sortdate desc" again
                  * To prevent this we change the default ordering here
                  */
                 if ($field == $dbOrdering[0] && $sortByDir == $dbOrdering[1]) {
                     $sortByDir = $this->changeOrdering($sortByDir);
                 }
                 $markerArray['###FIELDNAME###'] = $field;
                 $markerArray['###URL###'] = $this->generateSortingLink($field, $sortByDir);
                 $markerArray['###CLASS###'] = $this->getClassNameForUpDownArrow($field, $dbOrdering);
                 $links .= $this->cObj->substituteMarkerArray($this->subpartArray['###SORT_LINK###'], $markerArray);
             }
         }
         $content = $this->cObj->substituteSubpart($this->subpartArray['###ORDERNAVIGATION###'], '###SORT_LINK###', $links);
         $content = $this->cObj->substituteMarker($content, '###LABEL_SORT###', $this->pObj->pi_getLL('label_sort'));
         return $content;
     } else {
         return '';
     }
 }
    /**
     * Returns a results browser. This means a bar of page numbers plus a "previous" and "next" link. For each entry in the bar the piVars "pointer" will be pointing to the "result page" to show.
     * Using $this->piVars['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['res_count'], $this->internal['results_at_a_time'] 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['showFirstLast'] 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	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
     * @param	array		Array with elements to overwrite the default $wrapper-array.
     * @param	string		varname for the pointer.
     * @param	boolean		enable htmlspecialchars() for the pi_getLL function (set this to FALSE if you want f.e use images instead of text for links like 'previous' and 'next').
     * @param   boolean     forces the output of the page browser if you set this option to "true" (otherwise it's only drawn if enough entries are available)
     * @return	string		Output HTML-Table, wrapped in <div>-tags with a class attribute (if $wrapArr is not passed,
     */
    function pi_list_browseresults($showResultCount = 1, $tableParams = '', $wrapArr = array(), $pointerName = 'pointer', $hscText = TRUE, $forceOutput = FALSE)
    {
        // example $wrapArr-array how it could be traversed from an extension
        /* $wrapArr = array(
        			'browseBoxWrap' => '<div class="browseBoxWrap">|</div>',
        			'showResultsWrap' => '<div class="showResultsWrap">|</div>',
        			'browseLinksWrap' => '<div class="browseLinksWrap">|</div>',
        			'showResultsNumbersWrap' => '<span class="showResultsNumbersWrap">|</span>',
        			'disabledLinkWrap' => '<span class="disabledLinkWrap">|</span>',
        			'inactiveLinkWrap' => '<span class="inactiveLinkWrap">|</span>',
        			'activeLinkWrap' => '<span class="activeLinkWrap">|</span>'
        		); */
        // Initializing variables:
        $pointer = intval($this->piVars[$pointerName]);
        $count = intval($this->internal['res_count']);
        $results_at_a_time = t3lib_div::intInRange($this->internal['results_at_a_time'], 1, 1000);
        $totalPages = ceil($count / $results_at_a_time);
        $maxPages = t3lib_div::intInRange($this->internal['maxPages'], 1, 100);
        $pi_isOnlyFields = $this->pi_isOnlyFields($this->pi_isOnlyFields);
        if (!$forceOutput && $count <= $results_at_a_time) {
            return '';
        }
        // $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.
        $showFirstLast = $this->internal['showFirstLast'];
        // if this has a value the "previous" button is always visible (will be forced if "showFirstLast" is set)
        $alwaysPrev = $showFirstLast ? 1 : $this->pi_alwaysPrev;
        if (isset($this->internal['pagefloat'])) {
            if (strtoupper($this->internal['pagefloat']) == 'CENTER') {
                $pagefloat = ceil(($maxPages - 1) / 2);
            } else {
                // pagefloat set as integer. 0 = left, value >= $this->internal['maxPages'] = right
                $pagefloat = t3lib_div::intInRange($this->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
        $wrapper['disabledLinkWrap'] = '<td nowrap="nowrap"><p>|</p></td>';
        $wrapper['inactiveLinkWrap'] = '<td nowrap="nowrap"><p>|</p></td>';
        $wrapper['activeLinkWrap'] = '<td' . $this->pi_classParam('browsebox-SCell') . ' nowrap="nowrap"><p>|</p></td>';
        $wrapper['browseLinksWrap'] = trim('<table ' . $tableParams) . '><tr>|</tr></table>';
        $wrapper['showResultsWrap'] = '<p>|</p>';
        $wrapper['browseBoxWrap'] = '
		<!--
			List browsing box:
		-->
		<div ' . $this->pi_classParam('browsebox') . '>
			|
		</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 = t3lib_div::intInRange($totalPages, 1, $maxPages);
            }
            $links = array();
            // Make browse-table/links:
            if ($showFirstLast) {
                // Link to first page
                if ($pointer > 0) {
                    $links[] = $this->cObj->wrap($this->pi_linkTP_keepPIvars($this->pi_getLL('pi_list_browseresults_first', '<< First', $hscText), array($pointerName => null), $pi_isOnlyFields), $wrapper['inactiveLinkWrap']);
                } else {
                    $links[] = $this->cObj->wrap($this->pi_getLL('pi_list_browseresults_first', '<< First', $hscText), $wrapper['disabledLinkWrap']);
                }
            }
            if ($alwaysPrev >= 0) {
                // Link to previous page
                if ($pointer > 0) {
                    $links[] = $this->cObj->wrap($this->pi_linkTP_keepPIvars($this->pi_getLL('pi_list_browseresults_prev', '< Previous', $hscText), array($pointerName => $pointer - 1 ? $pointer - 1 : ''), $pi_isOnlyFields), $wrapper['inactiveLinkWrap']);
                } elseif ($alwaysPrev) {
                    $links[] = $this->cObj->wrap($this->pi_getLL('pi_list_browseresults_prev', '< Previous', $hscText), $wrapper['disabledLinkWrap']);
                }
            }
            for ($a = $firstPage; $a < $lastPage; $a++) {
                // Links to pages
                if ($this->internal['showRange']) {
                    $pageText = $a * $results_at_a_time + 1 . '-' . min($count, ($a + 1) * $results_at_a_time);
                } else {
                    $pageText = trim($this->pi_getLL('pi_list_browseresults_page', 'Page', $hscText) . ' ' . ($a + 1));
                }
                if ($pointer == $a) {
                    // current page
                    if ($this->internal['dontLinkActivePage']) {
                        $links[] = $this->cObj->wrap($pageText, $wrapper['activeLinkWrap']);
                    } else {
                        $links[] = $this->cObj->wrap($this->pi_linkTP_keepPIvars($pageText, array($pointerName => $a ? $a : ''), $pi_isOnlyFields), $wrapper['activeLinkWrap']);
                    }
                } else {
                    $links[] = $this->cObj->wrap($this->pi_linkTP_keepPIvars($pageText, array($pointerName => $a ? $a : ''), $pi_isOnlyFields), $wrapper['inactiveLinkWrap']);
                }
            }
            if ($pointer < $totalPages - 1 || $showFirstLast) {
                if ($pointer >= $totalPages - 1) {
                    // Link to next page
                    $links[] = $this->cObj->wrap($this->pi_getLL('pi_list_browseresults_next', 'Next >', $hscText), $wrapper['disabledLinkWrap']);
                } else {
                    $links[] = $this->cObj->wrap($this->pi_linkTP_keepPIvars($this->pi_getLL('pi_list_browseresults_next', 'Next >', $hscText), array($pointerName => $pointer + 1), $pi_isOnlyFields), $wrapper['inactiveLinkWrap']);
                }
            }
            if ($showFirstLast) {
                // Link to last page
                if ($pointer < $totalPages - 1) {
                    $links[] = $this->cObj->wrap($this->pi_linkTP_keepPIvars($this->pi_getLL('pi_list_browseresults_last', 'Last >>', $hscText), array($pointerName => $totalPages - 1), $pi_isOnlyFields), $wrapper['inactiveLinkWrap']);
                } else {
                    $links[] = $this->cObj->wrap($this->pi_getLL('pi_list_browseresults_last', 'Last >>', $hscText), $wrapper['disabledLinkWrap']);
                }
            }
            $theLinks = $this->cObj->wrap(implode(LF, $links), $wrapper['browseLinksWrap']);
        } else {
            $theLinks = '';
        }
        $pR1 = $pointer * $results_at_a_time + 1;
        $pR2 = $pointer * $results_at_a_time + $results_at_a_time;
        if ($showResultCount) {
            if ($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###'] = $this->cObj->wrap($this->internal['res_count'] > 0 ? $pR1 : 0, $wrapper['showResultsNumbersWrap']);
                $markerArray['###TO###'] = $this->cObj->wrap(min($this->internal['res_count'], $pR2), $wrapper['showResultsNumbersWrap']);
                $markerArray['###OUT_OF###'] = $this->cObj->wrap($this->internal['res_count'], $wrapper['showResultsNumbersWrap']);
                $markerArray['###FROM_TO###'] = $this->cObj->wrap(($this->internal['res_count'] > 0 ? $pR1 : 0) . ' ' . $this->pi_getLL('pi_list_browseresults_to', 'to') . ' ' . min($this->internal['res_count'], $pR2), $wrapper['showResultsNumbersWrap']);
                $markerArray['###CURRENT_PAGE###'] = $this->cObj->wrap($pointer + 1, $wrapper['showResultsNumbersWrap']);
                $markerArray['###TOTAL_PAGES###'] = $this->cObj->wrap($totalPages, $wrapper['showResultsNumbersWrap']);
                // substitute markers
                $resultCountMsg = $this->cObj->substituteMarkerArray($this->pi_getLL('pi_list_browseresults_displays', 'Displaying results ###FROM### to ###TO### out of ###OUT_OF###'), $markerArray);
            } else {
                // render the resultcount in the "traditional" way using sprintf
                $resultCountMsg = sprintf(str_replace('###SPAN_BEGIN###', '<span' . $this->pi_classParam('browsebox-strong') . '>', $this->pi_getLL('pi_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 = $this->cObj->wrap($resultCountMsg, $wrapper['showResultsWrap']);
        } else {
            $resultCountMsg = '';
        }
        $sTables = $this->cObj->wrap($resultCountMsg . $theLinks, $wrapper['browseBoxWrap']);
        return $sTables;
    }
 /**
  * Main function, called from TypoScript
  * A content object that renders "tt_content" records. See the comment to this class for TypoScript example of how to trigger it.
  * This detects the CType of the current content element and renders it accordingly. Only wellknown types are rendered.
  *
  * @param	string		$content: Empty, ignore.
  * @param	array		$conf: TypoScript properties for this content object/function call
  * @return	string		$content: Plain text content
  */
 function main($content, $conf)
 {
     global $TYPO3_CONF_VARS;
     $this->init($conf);
     $lines = array();
     $CType = (string) $this->cObj->data['CType'];
     switch ($CType) {
         case 'header':
             $lines[] = $this->getHeader();
             if ($this->cObj->data['subheader']) {
                 $lines[] = $this->breakContent(strip_tags($this->cObj->data['subheader']));
             }
             break;
         case 'text':
         case 'textpic':
             $lines[] = $this->getHeader();
             if ($CType == 'textpic' && !($this->cObj->data['imageorient'] & 24)) {
                 $lines[] = $this->getImages();
                 $lines[] = '';
             }
             $lines[] = $this->breakContent(strip_tags($this->parseBody($this->cObj->data['bodytext'])));
             if ($CType == 'textpic' && $this->cObj->data['imageorient'] & 24) {
                 $lines[] = '';
                 $lines[] = $this->getImages();
             }
             break;
         case 'image':
             $lines[] = $this->getHeader();
             $lines[] = $this->getImages();
             break;
         case 'uploads':
             $lines[] = $this->getHeader();
             $lines[] = $this->renderUploads($this->cObj->data['media']);
             break;
         case 'menu':
             $lines[] = $this->getHeader();
             $lines[] = $this->getMenuSitemap();
             break;
         case 'shortcut':
             $lines[] = $this->getShortcut();
             break;
         case 'bullets':
             $lines[] = $this->getHeader();
             $lines[] = $this->breakBulletlist(strip_tags($this->parseBody($this->cObj->data['bodytext'])));
             break;
         case 'table':
             $lines[] = $this->getHeader();
             $lines[] = $this->breakTable(strip_tags($this->parseBody($this->cObj->data['bodytext'])));
             break;
         case 'html':
             $lines[] = $this->getHTML();
             break;
         default:
             // Hook for processing other content types
             if (is_array($TYPO3_CONF_VARS['EXTCONF']['direct_mail']['renderCType'])) {
                 foreach ($TYPO3_CONF_VARS['EXTCONF']['direct_mail']['renderCType'] as $_classRef) {
                     $_procObj =& GeneralUtility::getUserObj($_classRef);
                     $lines = array_merge($lines, $_procObj->renderPlainText($this, $content));
                 }
             }
             if (empty($lines)) {
                 $defaultOutput = $this->getString($this->conf['defaultOutput']);
                 if ($defaultOutput) {
                     $lines[] = str_replace('###CType###', $CType, $defaultOutput);
                 }
             }
             break;
     }
     $lines[] = '';
     // First break.
     $content = implode(LF, $lines);
     // Substitute labels
     $markerArray = array();
     $markerArray = $this->addLabelsMarkers($markerArray);
     $content = $this->cObj->substituteMarkerArray($content, $markerArray);
     // User processing:
     $content = $this->userProcess('userProc', $content);
     return $content;
 }