/** * Logs message to the system log. * This should be implemented around the source code, including the Core and both frontend and backend, logging serious errors. * If you want to implement the sysLog in your applications, simply add lines like: * tx_div2007_div::sysLog('[write message in English here]', 'extension_key', 'severity'); * * @param string $msg Message (in English). * @param string $extKey Extension key (from which extension you are calling the log) or "Core" * @param integer $severity Severity: 0 is info, 1 is notice, 2 is warning, 3 is error, 4 is fatal error * @return void */ public static function sysLog($msg, $extKey, $severity = 0) { $severity = tx_div2007_core::intInRange($severity, 0, 4); // is message worth logging? if (intval($GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLogLevel']) > $severity) { return; } // initialize logging if (!$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogInit']) { self::initSysLog(); } // do custom logging if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'])) { $params = array('msg' => $msg, 'extKey' => $extKey, 'backTrace' => debug_backtrace(), 'severity' => $severity); $fakeThis = FALSE; foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLog'] as $hookMethod) { self::callUserFunction($hookMethod, $params, $fakeThis); } } // TYPO3 logging enabled? if (!$GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLog']) { return; } $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']; $timeFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm']; // use all configured logging options foreach (explode(';', $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLog'], 2) as $log) { list($type, $destination, $level) = explode(',', $log, 4); // is message worth logging for this log type? if (intval($level) > $severity) { continue; } $msgLine = ' - ' . $extKey . ': ' . $msg; // write message to a file if ($type == 'file') { $lockObject = self::makeInstance('t3lib_lock', $destination, $GLOBALS['TYPO3_CONF_VARS']['SYS']['lockingMode']); /** @var t3lib_lock $lockObject */ $lockObject->setEnableLogging(FALSE); $lockObject->acquire(); $file = fopen($destination, 'a'); if ($file) { fwrite($file, date($dateFormat . ' ' . $timeFormat) . $msgLine . LF); fclose($file); self::fixPermissions($destination); } $lockObject->release(); } elseif ($type == 'mail') { list($to, $from) = explode('/', $destination); if (!self::validEmail($from)) { $from = t3lib_utility_Mail::getSystemFrom(); } /** @var $mail t3lib_mail_Message */ $mail = self::makeInstance('t3lib_mail_Message'); $mail->setTo($to)->setFrom($from)->setSubject('Warning - error in TYPO3 installation')->setBody('Host: ' . $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] . LF . 'Extension: ' . $extKey . LF . 'Severity: ' . $severity . LF . LF . $msg); $mail->send(); } elseif ($type == 'error_log') { error_log($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_div.php']['systemLogHost'] . $msgLine, 0); } elseif ($type == 'syslog') { $priority = array(LOG_INFO, LOG_NOTICE, LOG_WARNING, LOG_ERR, LOG_CRIT); syslog($priority[(int) $severity], $msgLine); } } }
/** * 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 object tslib_pibase object * @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'). * @return string Output HTML-Table, wrapped in <div>-tags with a class attribute (if $wrapArr is not passed, */ function list_browseresults_fh001(&$pObject, $showResultCount = 1, $tableParams = '', $wrapArr = array(), $pointerName = 'pointer', $hscText = TRUE) { // Initializing variables: $pointer = intval($pObject->piVars[$pointerName]); $count = intval($pObject->internal['res_count']); $results_at_a_time = tx_div2007_core::intInRange($pObject->internal['results_at_a_time'], 1, 1000); $totalPages = ceil($count / $results_at_a_time); $maxPages = tx_div2007_core::intInRange($pObject->internal['maxPages'], 1, 100); $pi_isOnlyFields = $pObject->pi_isOnlyFields($pObject->pi_isOnlyFields); // $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 = $pObject->internal['showFirstLast']; // if this has a value the "previous" button is always visible (will be forced if "showFirstLast" is set) $alwaysPrev = $showFirstLast ? 1 : $pObject->pi_alwaysPrev; 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 $wrapper['disabledLinkWrap'] = '<td nowrap="nowrap"><p>|</p></td>'; $wrapper['inactiveLinkWrap'] = '<td nowrap="nowrap"><p>|</p></td>'; $wrapper['activeLinkWrap'] = '<td' . $pObject->pi_classParam('browsebox-SCell') . ' nowrap="nowrap"><p>|</p></td>'; $wrapper['browseLinksWrap'] = trim('<table ' . $tableParams) . '><tr>|</tr></table>'; if ($pObject->internal['imagePath']) { $onMouseOver = $pObject->internal['imageOnMouseOver'] ? 'onmouseover="' . $pObject->internal['imageOnMouseOver'] . '" ' : ''; $onMouseOut = $pObject->internal['imageOnMouseOut'] ? 'onmouseout="' . $pObject->internal['imageOnMouseOut'] . '" ' : ''; $onMouseOverActive = $pObject->internal['imageActiveOnMouseOver'] ? 'onmouseover="' . $pObject->internal['imageActiveOnMouseOver'] . '" ' : ''; $onMouseOutActive = $pObject->internal['imageActiveOnMouseOut'] ? 'onmouseout="' . $pObject->internal['imageActiveOnMouseOut'] . '" ' : ''; $wrapper['browseTextWrap'] = '<img src="' . $pObject->internal['imagePath'] . $pObject->internal['imageFilemask'] . '" ' . $onMouseOver . $onMouseOut . '>'; $wrapper['activeBrowseTextWrap'] = '<img src="' . $pObject->internal['imagePath'] . $pObject->internal['imageActiveFilemask'] . '" ' . $onMouseOverActive . $onMouseOutActive . '>'; } $wrapper['showResultsWrap'] = '<p>|</p>'; $wrapper['browseBoxWrap'] = ' <!-- List browsing box: --> <div ' . $pObject->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 = tx_div2007_core::intInRange($totalPages, 1, $maxPages); } $links = array(); // Make browse-table/links: if ($showFirstLast) { // Link to first page if ($pointer > 0) { $links[] = $pObject->cObj->wrap($pObject->pi_linkTP_keepPIvars(htmlspecialchars($pObject->pi_getLL('pi_list_browseresults_first', '<< First', $hscText)), array($pointerName => null), $pi_isOnlyFields), $wrapper['inactiveLinkWrap']); } else { $links[] = $pObject->cObj->wrap(htmlspecialchars($pObject->pi_getLL('pi_list_browseresults_first', '<< First', $hscText)), $wrapper['disabledLinkWrap']); } } if ($alwaysPrev >= 0) { // Link to previous page $previousText = $pObject->pi_getLL('pi_list_browseresults_prev', '< Previous', $hscText); if ($pointer > 0) { $links[] = $pObject->cObj->wrap($pObject->pi_linkTP_keepPIvars($previousText, array($pointerName => $pointer - 1 ? $pointer - 1 : ''), $pi_isOnlyFields), $wrapper['inactiveLinkWrap']); } elseif ($alwaysPrev) { $links[] = $pObject->cObj->wrap($previousText, $wrapper['disabledLinkWrap']); } } for ($a = $firstPage; $a < $lastPage; $a++) { // Links to pages if ($pObject->internal['showRange']) { $pageText = $a * $results_at_a_time + 1 . '-' . min($count, ($a + 1) * $results_at_a_time); } else { if ($totalPages > 1) { if ($wrapper['browseTextWrap']) { if ($pointer == $a) { // current page $pageText = $pObject->cObj->wrap($a + 1, $wrapper['activeBrowseTextWrap']); } else { $pageText = $pObject->cObj->wrap($a + 1, $wrapper['browseTextWrap']); } } else { $pageText = trim($pObject->pi_getLL('pi_list_browseresults_page', 'Page', $hscText)) . ' ' . ($a + 1); } } } if ($pointer == $a) { // current page if ($pObject->internal['dontLinkActivePage']) { $links[] = $pObject->cObj->wrap($pageText, $wrapper['activeLinkWrap']); } else { $linkArray = array($pointerName => $a ? $a : ''); $link = $pObject->pi_linkTP_keepPIvars($pageText, $linkArray, $pi_isOnlyFields); $links[] = $pObject->cObj->wrap($link, $wrapper['activeLinkWrap']); } } else { $links[] = $pObject->cObj->wrap($pObject->pi_linkTP_keepPIvars($pageText, array($pointerName => $a ? $a : ''), $pi_isOnlyFields), $wrapper['inactiveLinkWrap']); } } if ($pointer < $totalPages - 1 || $showFirstLast) { $nextText = $pObject->pi_getLL('pi_list_browseresults_next', 'Next >', $hscText); if ($pointer == $totalPages - 1) { // Link to next page $links[] = $pObject->cObj->wrap($nextText, $wrapper['disabledLinkWrap']); } else { $links[] = $pObject->cObj->wrap($pObject->pi_linkTP_keepPIvars($nextText, array($pointerName => $pointer + 1), $pi_isOnlyFields), $wrapper['inactiveLinkWrap']); } } if ($showFirstLast) { // Link to last page if ($pointer < $totalPages - 1) { $links[] = $pObject->cObj->wrap($pObject->pi_linkTP_keepPIvars($pObject->pi_getLL('pi_list_browseresults_last', 'Last >>', $hscText), array($pointerName => $totalPages - 1), $pi_isOnlyFields), $wrapper['inactiveLinkWrap']); } else { $links[] = $pObject->cObj->wrap($pObject->pi_getLL('pi_list_browseresults_last', 'Last >>', $hscText), $wrapper['disabledLinkWrap']); } } $theLinks = $pObject->cObj->wrap(implode(chr(10), $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 (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###'] = $pObject->cObj->wrap($pObject->internal['res_count'] > 0 ? $pR1 : 0, $wrapper['showResultsNumbersWrap']); $markerArray['###TO###'] = $pObject->cObj->wrap(min($pObject->internal['res_count'], $pR2), $wrapper['showResultsNumbersWrap']); $markerArray['###OUT_OF###'] = $pObject->cObj->wrap($pObject->internal['res_count'], $wrapper['showResultsNumbersWrap']); $markerArray['###FROM_TO###'] = $pObject->cObj->wrap(($pObject->internal['res_count'] > 0 ? $pR1 : 0) . ' ' . $pObject->pi_getLL('pi_list_browseresults_to', 'to') . ' ' . min($pObject->internal['res_count'], $pR2), $wrapper['showResultsNumbersWrap']); $markerArray['###CURRENT_PAGE###'] = $pObject->cObj->wrap($pointer + 1, $wrapper['showResultsNumbersWrap']); $markerArray['###TOTAL_PAGES###'] = $pObject->cObj->wrap($totalPages, $wrapper['showResultsNumbersWrap']); $pi_list_browseresults_displays = $pObject->pi_getLL('pi_list_browseresults_displays', 'Displaying results ###FROM### to ###TO### out of ###OUT_OF###'); // substitute markers $resultCountMsg = $pObject->cObj->substituteMarkerArray($pi_list_browseresults_displays, $markerArray); } else { // render the resultcount in the "traditional" way using sprintf $resultCountMsg = sprintf(str_replace('###SPAN_BEGIN###', '<span' . $pObject->pi_classParam('browsebox-strong') . '>', $pObject->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 = $pObject->cObj->wrap($resultCountMsg, $wrapper['showResultsWrap']); } else { $resultCountMsg = ''; } $sTables = $pObject->cObj->wrap($resultCountMsg . $theLinks, $wrapper['browseBoxWrap']); return $sTables; }