示例#1
0
 /**
  * Outputs information about a specific user for the post listing.
  * @param  int    $uid          The UID of the user whose information are to be displayed
  * @param  array  $conf         The configuration vars of the plugin
  * @param  bool   $threadauthor TRUE, if the user is the author of the thread displayed. In
  *                              this case, a special string telling that this user is the author
  *                              of the thread is displayed.
  * @return string               The user information
  */
 function ident_user($uid, $conf, $threadauthor = FALSE)
 {
     $userData = !is_array($uid) ? tx_mmforum_tools::get_userdata($uid) : $uid;
     $template = $this->cObj->fileResource($this->conf['template.']['list_post']);
     $template = $this->cObj->getSubpart($template, '###USERINFO###');
     if ($template) {
         $avatar = $this->getUserAvatar($userData);
         $marker = array('###LLL_DELETED###' => $this->pi_getLL('user-deleted'), '###USERNAME###' => $this->cObj->stdWrap($userData[$this->getUserNameField()], $this->conf['list_posts.']['userinfo.']['username_stdWrap.']), '###USERREALNAME###' => $this->cObj->stdWrap($userData['name'], $this->conf['list_posts.']['userinfo.']['realname_stdWrap.']), '###USERRANKS###' => $this->get_userranking($uid, $conf), '###TOPICCREATOR###' => $uid == $threadauthor ? $this->cObj->stdWrap($this->pi_getLL('topic-topicauthor'), $this->conf['list_posts.']['userinfo.']['creator_stdWrap.']) : '', '###AVATAR###' => $avatar, '###LLL_REGSINCE###' => $this->pi_getLL('user-regSince'), '###LLL_POSTCOUNT###' => $this->pi_getLL('user-posts'), '###REGSINCE###' => $this->cObj->stdWrap($userData['crdate'], $this->conf['list_posts.']['userinfo.']['crdate_stdWrap.']), '###POSTCOUNT###' => intval($userData['tx_mmforum_posts']), '###USER_RATING###' => $this->isUserRating() ? $this->getRatingDisplay('fe_users', $userData['uid']) : '');
         if ($userData === false) {
             $template = $this->cObj->substituteSubpart($template, '###USERINFO_REGULAR###', '');
         } else {
             $template = $this->cObj->substituteSubpart($template, '###USERINFO_DELETED###', '');
         }
         // Include hooks
         if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['userInformation_marker'])) {
             foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['mm_forum']['forum']['userInformation_marker'] as $_classRef) {
                 $_procObj =& GeneralUtility::getUserObj($_classRef);
                 $marker = $_procObj->userInformation_marker($marker, $userData, $this);
             }
         }
         $content = $this->cObj->substituteMarkerArray($template, $marker);
     } else {
         if ($userData === false) {
             return '<strong>' . $this->pi_getLL('user.deleted') . '</strong>';
         }
         $content = '<strong>' . $userData[$this->getUserNameField()] . '</strong><br />';
         if ($this->conf['list_posts.']['userinfo_realName'] && $userData['name']) {
             $content .= $this->cObj->wrap($userData['name'], $this->conf['list_posts.']['userinfo_realName_wrap']);
         }
         $userranking = $this->get_userranking($uid, $conf) . '<br />';
         if ($uid == $threadauthor) {
             $userranking .= $this->cObj->wrap($this->pi_getLL('topic.topicauthor'), $this->conf['list_posts.']['userinfo_topicauthor_wrap']);
         }
         $content .= $userranking;
         if ($userData['tx_mmforum_avatar']) {
             $content .= $this->tools->res_img($conf['path_avatar'] . $userData['tx_mmforum_avatar'], $conf['avatar_height'], $conf['avatar_width']);
         }
         $content .= $this->cObj->wrap($this->pi_getLL('user.regSince') . ': ' . date('d.m.Y', $userData['crdate']) . '<br />' . $this->pi_getLL('user.posts') . ': ' . $userData['tx_mmforum_posts'], $this->conf['list_posts.']['userinfo_content_wrap']);
     }
     return $content;
 }
示例#2
0
    /**
     * Generates the "edit panels" which can be shown for a page or records on a page when the Admin Panel is enabled for a backend users surfing the frontend.
     * With the "edit panel" the user will see buttons with links to editing, moving, hiding, deleting the element
     * This function is used for the cObject EDITPANEL and the stdWrap property ".editPanel"
     *
     * @param string $content A content string containing the content related to the edit panel. For cObject "EDITPANEL" this is empty but not so for the stdWrap property. The edit panel is appended to this string and returned.
     * @param array $conf TypoScript configuration properties for the editPanel
     * @param string $currentRecord The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW
     * @param array $dataArr Alternative data array to use. Default is $this->data
     * @param string $table
     * @param array $allow
     * @param int $newUID
     * @param array $hiddenFields
     * @return string The input content string with the editPanel appended. This function returns only an edit panel appended to the content string if a backend user is logged in (and has the correct permissions). Otherwise the content string is directly returned.
     */
    public function editPanel($content, array $conf, $currentRecord = '', array $dataArr = array(), $table = '', array $allow = array(), $newUID = 0, array $hiddenFields = array())
    {
        $hiddenFieldString = $command = '';
        // Special content is about to be shown, so the cache must be disabled.
        $this->frontendController->set_no_cache('Frontend edit panel is shown', TRUE);
        $formName = 'TSFE_EDIT_FORM_' . substr($this->frontendController->uniqueHash(), 0, 4);
        $formTag = '<form name="' . $formName . '" id ="' . $formName . '" action="' . htmlspecialchars(GeneralUtility::getIndpEnv('REQUEST_URI')) . '" method="post" enctype="' . htmlspecialchars($GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype']) . '" onsubmit="return TBE_EDITOR.checkSubmit(1);">';
        $sortField = $GLOBALS['TCA'][$table]['ctrl']['sortby'];
        $labelField = $GLOBALS['TCA'][$table]['ctrl']['label'];
        $hideField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
        $panel = '';
        if (isset($allow['toolbar']) && $this->backendUser->adminPanel instanceof AdminPanelView) {
            $panel .= $this->backendUser->adminPanel->ext_makeToolBar();
        }
        if (isset($allow['edit'])) {
            $icon = IconUtility::getSpriteIcon('actions-document-open', array('title' => $this->backendUser->extGetLL('p_editRecord')));
            $panel .= $this->editPanelLinkWrap($icon, $formName, 'edit', $dataArr['_LOCALIZED_UID'] ? $table . ':' . $dataArr['_LOCALIZED_UID'] : $currentRecord);
        }
        // Hiding in workspaces because implementation is incomplete
        if (isset($allow['move']) && $sortField && $this->backendUser->workspace === 0) {
            $icon = IconUtility::getSpriteIcon('actions-move-up', array('title' => $this->backendUser->extGetLL('p_moveUp')));
            $panel .= $this->editPanelLinkWrap($icon, $formName, 'up');
            $icon = IconUtility::getSpriteIcon('actions-move-down', array('title' => $this->backendUser->extGetLL('p_moveDown')));
            $panel .= $this->editPanelLinkWrap($icon, $formName, 'down');
        }
        // Hiding in workspaces because implementation is incomplete
        // Hiding for localizations because it is unknown what should be the function in that case
        if (isset($allow['hide']) && $hideField && $this->backendUser->workspace === 0 && !$dataArr['_LOCALIZED_UID']) {
            if ($dataArr[$hideField]) {
                $icon = IconUtility::getSpriteIcon('actions-edit-unhide', array('title' => $this->backendUser->extGetLL('p_unhide')));
                $panel .= $this->editPanelLinkWrap($icon, $formName, 'unhide');
            } else {
                $icon = IconUtility::getSpriteIcon('actions-edit-hide', array('title' => $this->backendUser->extGetLL('p_hide')));
                $panel .= $this->editPanelLinkWrap($icon, $formName, 'hide', '', $this->backendUser->extGetLL('p_hideConfirm'));
            }
        }
        if (isset($allow['new'])) {
            if ($table === 'pages') {
                $icon = IconUtility::getSpriteIcon('actions-page-new', array('title' => $this->backendUser->extGetLL('p_newSubpage')));
                $panel .= $this->editPanelLinkWrap($icon, $formName, 'new', $currentRecord, '');
            } else {
                $icon = IconUtility::getSpriteIcon('actions-document-new', array('title' => $this->backendUser->extGetLL('p_newRecordAfter')));
                $panel .= $this->editPanelLinkWrap($icon, $formName, 'new', $currentRecord, '', $newUID);
            }
        }
        // Hiding in workspaces because implementation is incomplete
        // Hiding for localizations because it is unknown what should be the function in that case
        if (isset($allow['delete']) && $this->backendUser->workspace === 0 && !$dataArr['_LOCALIZED_UID']) {
            $icon = IconUtility::getSpriteIcon('actions-edit-delete', array('title' => $this->backendUser->extGetLL('p_delete')));
            $panel .= $this->editPanelLinkWrap($icon, $formName, 'delete', '', $this->backendUser->extGetLL('p_deleteConfirm'));
        }
        // Final
        $labelTxt = $this->cObj->stdWrap($conf['label'], $conf['label.']);
        foreach ((array) $hiddenFields as $name => $value) {
            $hiddenFieldString .= '<input type="hidden" name="TSFE_EDIT[' . htmlspecialchars($name) . ']" value="' . htmlspecialchars($value) . '"/>' . LF;
        }
        $panel = '<!-- BE_USER Edit Panel: -->
								' . $formTag . $hiddenFieldString . '
									<input type="hidden" name="TSFE_EDIT[cmd]" value="" />
									<input type="hidden" name="TSFE_EDIT[record]" value="' . $currentRecord . '" />
									<div class="typo3-editPanel">' . $panel . ($labelTxt ? '<div class="typo3-editPanel-label">' . sprintf($labelTxt, htmlspecialchars(GeneralUtility::fixed_lgd_cs($dataArr[$labelField], 50))) . '</div>' : '') . '
									</div>
								</form>';
        // Wrap the panel
        if ($conf['innerWrap']) {
            $panel = $this->cObj->wrap($panel, $conf['innerWrap']);
        }
        if ($conf['innerWrap.']) {
            $panel = $this->cObj->stdWrap($panel, $conf['innerWrap.']);
        }
        // Wrap the complete panel
        if ($conf['outerWrap']) {
            $panel = $this->cObj->wrap($panel, $conf['outerWrap']);
        }
        if ($conf['outerWrap.']) {
            $panel = $this->cObj->stdWrap($panel, $conf['outerWrap.']);
        }
        if ($conf['printBeforeContent']) {
            $finalOut = $panel . $content;
        } else {
            $finalOut = $content . $panel;
        }
        $hidden = $this->isDisabled($table, $dataArr) ? ' typo3-feedit-element-hidden' : '';
        $outerWrapConfig = isset($conf['stdWrap.']) ? $conf['stdWrap.'] : array('wrap' => '<div class="typo3-feedit-element' . $hidden . '">|</div>');
        $finalOut = $this->cObj->stdWrap($finalOut, $outerWrapConfig);
        return $finalOut;
    }
示例#3
0
    /**
     * 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 int $showResultCount Determines how the results of the pagerowser will be shown. See description below
     * @param string $tableParams Attributes for the table tag which is wrapped around the table cells containing the browse links
     * @param array $wrapArr Array with elements to overwrite the default $wrapper-array.
     * @param string $pointerName varname for the pointer.
     * @param bool $hscText 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 bool $forceOutput 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,
     */
    public 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 = (int) $this->piVars[$pointerName];
        $count = (int) $this->internal['res_count'];
        $results_at_a_time = MathUtility::forceIntegerInRange($this->internal['results_at_a_time'], 1, 1000);
        $totalPages = ceil($count / $results_at_a_time);
        $maxPages = MathUtility::forceIntegerInRange($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 = (int) $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 = MathUtility::forceIntegerInRange($this->internal['pagefloat'], -1, $maxPages - 1);
            }
        } else {
            // pagefloat disabled
            $pagefloat = -1;
        }
        // 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);
        // Show pagebrowser
        if ($showResultCount != 2) {
            if ($pagefloat > -1) {
                $lastPage = min($totalPages, max($pointer + 1 + $pagefloat, $maxPages));
                $firstPage = max(0, $lastPage - $maxPages);
            } else {
                $firstPage = 0;
                $lastPage = MathUtility::forceIntegerInRange($totalPages, 1, $maxPages);
            }
            $links = array();
            // Make browse-table/links:
            // Link to first page
            if ($showFirstLast) {
                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']);
                }
            }
            // Link to previous page
            if ($alwaysPrev >= 0) {
                if ($pointer > 0) {
                    $links[] = $this->cObj->wrap($this->pi_linkTP_keepPIvars($this->pi_getLL('pi_list_browseresults_prev', '< Previous', $hscText), array($pointerName => $pointer - 1 ?: ''), $pi_isOnlyFields), $wrapper['inactiveLinkWrap']);
                } elseif ($alwaysPrev) {
                    $links[] = $this->cObj->wrap($this->pi_getLL('pi_list_browseresults_prev', '< Previous', $hscText), $wrapper['disabledLinkWrap']);
                }
            }
            // Links to pages
            for ($a = $firstPage; $a < $lastPage; $a++) {
                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));
                }
                // Current page
                if ($pointer == $a) {
                    if ($this->internal['dontLinkActivePage']) {
                        $links[] = $this->cObj->wrap($pageText, $wrapper['activeLinkWrap']);
                    } else {
                        $links[] = $this->cObj->wrap($this->pi_linkTP_keepPIvars($pageText, array($pointerName => $a ?: ''), $pi_isOnlyFields), $wrapper['activeLinkWrap']);
                    }
                } else {
                    $links[] = $this->cObj->wrap($this->pi_linkTP_keepPIvars($pageText, array($pointerName => $a ?: ''), $pi_isOnlyFields), $wrapper['inactiveLinkWrap']);
                }
            }
            if ($pointer < $totalPages - 1 || $showFirstLast) {
                // Link to next page
                if ($pointer >= $totalPages - 1) {
                    $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']);
                }
            }
            // Link to last page
            if ($showFirstLast) {
                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;
    }
    /**
     * Generates the "edit panels" which can be shown for a page or records on a page when the Admin Panel is enabled for a backend users surfing the frontend.
     * With the "edit panel" the user will see buttons with links to editing, moving, hiding, deleting the element
     * This function is used for the cObject EDITPANEL and the stdWrap property ".editPanel"
     *
     * @param string $content A content string containing the content related to the edit panel. For cObject "EDITPANEL" this is empty but not so for the stdWrap property. The edit panel is appended to this string and returned.
     * @param array $conf TypoScript configuration properties for the editPanel
     * @param string $currentRecord The "table:uid" of the record being shown. If empty string then $this->currentRecord is used. For new records (set by $conf['newRecordFromTable']) it's auto-generated to "[tablename]:NEW
     * @param array $dataArr Alternative data array to use. Default is $this->data
     * @param string $table
     * @param string $allow
     * @param integer $newUID
     * @param array $hiddenFields
     * @return string The input content string with the editPanel appended. This function returns only an edit panel appended to the content string if a backend user is logged in (and has the correct permissions). Otherwise the content string is directly returned.
     */
    public function editPanel($content, array $conf, $currentRecord = '', array $dataArr = array(), $table = '', $allow = '', $newUID = 0, array $hiddenFields = array())
    {
        // Special content is about to be shown, so the cache must be disabled.
        $GLOBALS['TSFE']->set_no_cache();
        $formName = 'TSFE_EDIT_FORM_' . substr($GLOBALS['TSFE']->uniqueHash(), 0, 4);
        $formTag = '<form name="' . $formName . '" id ="' . $formName . '" action="' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('REQUEST_URI')) . '" method="post" enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '" onsubmit="return TBE_EDITOR.checkSubmit(1);" style="margin: 0 0 0 0;">';
        $sortField = $GLOBALS['TCA'][$table]['ctrl']['sortby'];
        $labelField = $GLOBALS['TCA'][$table]['ctrl']['label'];
        $hideField = $GLOBALS['TCA'][$table]['ctrl']['enablecolumns']['disabled'];
        $blackLine = $conf['line'] ? '<img src="clear.gif" width="1" height="' . intval($conf['line']) . '" alt="" title="" /><br /><table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="black" style="border: 0px;" summary=""><tr style="border: 0px;"><td style="border: 0px;"><img src="clear.gif" width="1" height="1" alt="" title="" /></td></tr></table><br />' : '';
        $theCmd = '';
        $TSFE_EDIT = $GLOBALS['BE_USER']->frontendEdit->TSFE_EDIT;
        if (is_array($TSFE_EDIT) && $TSFE_EDIT['record'] == $currentRecord && !$TSFE_EDIT['update_close']) {
            $theCmd = $TSFE_EDIT['cmd'];
        }
        switch ($theCmd) {
            case 'edit':
            case 'new':
                $finalOut = $this->editContent($formTag, $formName, $theCmd, $newUID, $dataArr, $table, $currentRecord, $blackLine);
                break;
            default:
                $panel = '';
                if (isset($allow['toolbar']) && $GLOBALS['BE_USER']->adminPanel instanceof \TYPO3\CMS\Frontend\View\AdminPanelView) {
                    $panel .= $GLOBALS['BE_USER']->adminPanel->ext_makeToolBar() . '<img src="clear.gif" width="2" height="1" alt="" title="" />';
                }
                if (isset($allow['edit'])) {
                    $panel .= $this->editPanelLinkWrap('<img ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/edit2.gif', 'width="11" height="12" hspace="2" border="0"') . ' title="' . $GLOBALS['BE_USER']->extGetLL('p_editRecord') . '" align="top" alt="" />', $formName, 'edit', $dataArr['_LOCALIZED_UID'] ? $table . ':' . $dataArr['_LOCALIZED_UID'] : $currentRecord);
                }
                // Hiding in workspaces because implementation is incomplete
                if (isset($allow['move']) && $sortField && $GLOBALS['BE_USER']->workspace === 0) {
                    $panel .= $this->editPanelLinkWrap('<img  ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/button_up.gif', 'width="11" height="10" vspace="1" hspace="2" border="0" ') . ' title="' . $GLOBALS['BE_USER']->extGetLL('p_moveUp') . '" align="top" alt="" />', $formName, 'up');
                    $panel .= $this->editPanelLinkWrap('<img  ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/button_down.gif', 'width="11" height="10" vspace="1" hspace="2" border="0" ') . ' title="' . $GLOBALS['BE_USER']->extGetLL('p_moveDown') . '" align="top" alt="" />', $formName, 'down');
                }
                // Hiding in workspaces because implementation is incomplete, Hiding for localizations because it is unknown what should be the function in that case
                if (isset($allow['hide']) && $hideField && $GLOBALS['BE_USER']->workspace === 0 && !$dataArr['_LOCALIZED_UID']) {
                    if ($dataArr[$hideField]) {
                        $panel .= $this->editPanelLinkWrap('<img  ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/button_unhide.gif', 'width="11" height="10" vspace="1" hspace="2" border="0" ') . ' title="' . $GLOBALS['BE_USER']->extGetLL('p_unhide') . '" align="top" alt="" />', $formName, 'unhide');
                    } else {
                        $panel .= $this->editPanelLinkWrap('<img  ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/button_hide.gif', 'width="11" height="10" vspace="1" hspace="2" border="0" ') . ' title="' . $GLOBALS['BE_USER']->extGetLL('p_hide') . '" align="top" alt="" />', $formName, 'hide', '', $GLOBALS['BE_USER']->extGetLL('p_hideConfirm'));
                    }
                }
                if (isset($allow['new'])) {
                    if ($table == 'pages') {
                        $panel .= $this->editPanelLinkWrap('<img  ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/new_page.gif', 'width="13" height="12" vspace="1" hspace="2" border="0" ') . ' title="' . $GLOBALS['BE_USER']->extGetLL('p_newSubpage') . '" align="top" alt="" />', $formName, 'new', $currentRecord, '');
                    } else {
                        $panel .= $this->editPanelLinkWrap('<img  ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/new_record.gif', 'width="16" height="12" vspace="1" hspace="2" border="0" ') . ' title="' . $GLOBALS['BE_USER']->extGetLL('p_newRecordAfter') . '" align="top" alt="" />', $formName, 'new', $currentRecord, '', $newUID);
                    }
                }
                // Hiding in workspaces because implementation is incomplete, Hiding for localizations because it is unknown what should be the function in that case
                if (isset($allow['delete']) && $GLOBALS['BE_USER']->workspace === 0 && !$dataArr['_LOCALIZED_UID']) {
                    $panel .= $this->editPanelLinkWrap('<img  ' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg(TYPO3_mainDir, 'gfx/delete_record.gif', 'width="12" height="12" vspace="1" hspace="2" border="0" ') . ' title="' . $GLOBALS['BE_USER']->extGetLL('p_delete') . '" align="top" alt="" />', $formName, 'delete', '', $GLOBALS['BE_USER']->extGetLL('p_deleteConfirm'));
                }
                //	Final
                $labelTxt = $this->cObj->stdWrap($conf['label'], $conf['label.']);
                foreach ((array) $hiddenFields as $name => $value) {
                    $hiddenFieldString .= '<input type="hidden" name="TSFE_EDIT[' . $name . ']" value="' . $value . '"/>' . LF;
                }
                $panel = '

							<!-- BE_USER Edit Panel: -->
							' . $formTag . $hiddenFieldString . '
								<input type="hidden" name="TSFE_EDIT[cmd]" value="" />
								<input type="hidden" name="TSFE_EDIT[record]" value="' . $currentRecord . '" />
								<table border="0" cellpadding="0" cellspacing="0" class="typo3-editPanel" summary="">
									<tr>
										<td nowrap="nowrap" bgcolor="#ABBBB4" class="typo3-editPanel-controls">' . $panel . '</td>' . ($labelTxt ? '<td nowrap="nowrap" bgcolor="#F6F2E6" class="typo3-editPanel-label"><font face="verdana" size="1" color="black">&nbsp;' . sprintf($labelTxt, htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($dataArr[$labelField], 50))) . '&nbsp;</font></td>' : '') . '
									</tr>
								</table>
							</form>';
                // Wrap the panel
                if ($conf['innerWrap']) {
                    $panel = $this->cObj->wrap($panel, $conf['innerWrap']);
                }
                if ($conf['innerWrap.']) {
                    $panel = $this->cObj->stdWrap($panel, $conf['innerWrap.']);
                }
                // Add black line:
                $panel .= $blackLine;
                // Wrap the complete panel
                if ($conf['outerWrap']) {
                    $panel = $this->cObj->wrap($panel, $conf['outerWrap']);
                }
                if ($conf['outerWrap.']) {
                    $panel = $this->cObj->stdWrap($panel, $conf['outerWrap.']);
                }
                if ($conf['printBeforeContent']) {
                    $finalOut = $panel . $content;
                } else {
                    $finalOut = $content . $panel;
                }
                break;
        }
        if ($conf['previewBorder']) {
            if (!is_array($conf['previewBorder.'])) {
                $conf['previewBorder.'] = array();
            }
            $finalOut = $this->editPanelPreviewBorder($table, $dataArr, $finalOut, $conf['previewBorder'], $conf['previewBorder.']);
        }
        return $finalOut;
    }
示例#5
0
 /**
  * Generates a list from an array with data on users logged in.
  * @author Martin Helmich <*****@*****.**>
  * @param  array   $userData The user data, ordered by the pattern array('admins'=>array(array('uid'=>[...],'username'=>[...],'usergroup'=>[...]),[...]),'mods'=>array([...]),'users'=>array([...])).
  * @param  boolean $seperate Determines, if the users listed are to be grouped by user status (user, moderator, administrator).
  * @param  string  $sepChar  The seperator string that is to be used to seperate the different user groups (see above) from each other.
  * @return string            The user list's HTML code.
  * @uses getPartUserList
  */
 function getUserList($userData, $seperate = TRUE, $sepChar = '<br />')
 {
     $result = '';
     // Output regular user list
     if (count($userData['users']) > 0) {
         if ($seperate) {
             $users = $this->cObj->wrap($this->pi_getLL('list.users') . ':', $this->conf['userList.']['groupTitle_wrap']) . ' ' . $this->getPartUserList($userData['users'], 'tx-mmforum-pi6-user');
         } else {
             $users = $this->getPartUserList($userData['users'], 'tx-mmforum-pi6-user');
         }
         $result .= (strlen($result) > 0 ? $seperate ? $sepChar : ', ' : '') . $users;
     }
     // Output moderator list
     if (count($userData['mods']) > 0) {
         if ($seperate) {
             $mods = $this->cObj->wrap($this->pi_getLL('list.moderators') . ':', $this->conf['userList.']['groupTitle_wrap']) . ' ' . $this->getPartUserList($userData['mods'], 'tx-mmforum-pi6-mod');
         } else {
             $mods = $this->getPartUserList($userData['mods'], 'tx-mmforum-pi6-mod');
         }
         $result .= (strlen($result) > 0 ? $seperate ? $sepChar : ', ' : '') . $mods;
     }
     // Output administrator list
     if (count($userData['admins']) > 0) {
         if ($seperate) {
             $admins = $this->cObj->wrap($this->pi_getLL('list.administrators') . ':', $this->conf['userList.']['groupTitle_wrap']) . ' ' . $this->getPartUserList($userData['admins'], 'tx-mmforum-pi6-admin');
         } else {
             $admins = $this->getPartUserList($userData['admins'], 'tx-mmforum-pi6-admin');
         }
         $result .= (strlen($result) > 0 ? $seperate ? $sepChar : ', ' : '') . $admins;
     }
     return $result;
 }
示例#6
0
 /**
  * Creates the mm_forum page title.
  * This function generates the title of the mm_forum using the rootline
  * locallang names.
  */
 function createPageTitle()
 {
     if ($this->conf['removeOriginalPagetitle']) {
         $GLOBALS['TSFE']->page['title'] = '';
     }
     switch ($this->piVars['action']) {
         // List post view, new post form, post alert form
         // Sets a title like "mm_forum page -> Category -> Board -> Topic (-> New post/Report post)"
         case 'list_post':
         case 'new_post':
         case 'post_alert':
             $res = $this->databaseHandle->exec_SELECTquery('topic_title, f.forum_name, c.forum_name', 'tx_mmforum_topics t, tx_mmforum_forums f, tx_mmforum_forums c', 't.uid="' . intval($this->piVars['tid']) . '" AND f.uid=t.forum_id AND c.uid=f.parentID');
             list($topicTitle, $forumTitle, $catTitle) = $this->databaseHandle->sql_fetch_row($res);
             $topicTitle = stripslashes($topicTitle);
             $topicTitle = str_replace('<', '&lt;', $topicTitle);
             $topicTitle = str_replace('>', '&gt;', $topicTitle);
             if ($this->piVars['action'] == 'new_post') {
                 $pageTitle = $this->pi_getLL('rootline.reply');
             } elseif ($this->piVars['action'] == 'post_alert') {
                 $pageTitle = $this->pi_getLL('rootline.post_alert');
             }
             break;
             // New topic form, topic listing view
             // Sets a title like "mm_forum page -> Category -> Board (-> New topic)"
         // New topic form, topic listing view
         // Sets a title like "mm_forum page -> Category -> Board (-> New topic)"
         case 'new_topic':
         case 'list_topic':
             $res = $this->databaseHandle->exec_SELECTquery('f.forum_name, c.forum_name', 'tx_mmforum_forums f, tx_mmforum_forums c', 'f.uid="' . intval($this->piVars['fid']) . '" AND c.uid=f.parentID');
             list($forumTitle, $catTitle) = $this->databaseHandle->sql_fetch_row($res);
             if ($this->piVars['action'] == 'new_topic') {
                 $pageTitle = $this->pi_getLL('rootline.new_topic');
             }
             break;
             // Post editing form
             // Sets a title like "mm_forum page -> Category -> Board -> Topic -> Edit post"
         // Post editing form
         // Sets a title like "mm_forum page -> Category -> Board -> Topic -> Edit post"
         case 'post_edit':
             $res = $this->databaseHandle->exec_SELECTquery('topic_title,f.forum_name,c.forum_name', 'tx_mmforum_posts p, tx_mmforum_topics t, tx_mmforum_forums f, tx_mmforum_forums c', 'p.uid="' . intval($this->piVars['pid']) . '" AND t.uid=p.topic_id AND f.uid=p.forum_id AND c.uid=f.parentID');
             list($topicTitle, $forumTitle, $catTitle) = $this->databaseHandle->sql_fetch_row($res);
             $topicTitle = stripslashes($topicTitle);
             $topicTitle = str_replace('<', '&lt;', $topicTitle);
             $topicTitle = str_replace('>', '&gt;', $topicTitle);
             $pageTitle = $this->pi_getLL('rootline.edit_post');
             break;
             // User profile
             // Sets a title like "mm_forum page -> User profile: Username"
         // User profile
         // Sets a title like "mm_forum page -> User profile: Username"
         case 'forum_view_profil':
             if ($this->useRealUrl() && $this->piVars['fid']) {
                 $user = tx_mmforum_FeUser::getByUsername($this->piVars['fid']);
             } else {
                 $user = tx_mmforum_FeUser::getByUID($this->piVars['user_id']);
             }
             $pageTitle = sprintf($this->pi_getLL('rootline.userprofile'), (bool) $user ? $this->escape($user->gD($this->getUserNameField())) : '');
             break;
             // List unread or unanswered topics
             // Sets a title like "mm_forum page -> List unread/unanswered topics"
         // List unread or unanswered topics
         // Sets a title like "mm_forum page -> List unread/unanswered topics"
         case 'list_unread':
         case 'list_unans':
             $pageTitle = $this->pi_getLL('rootline.' . $this->piVars['action']);
             break;
     }
     if ($this->conf['pagetitleLastForumPageTitleOnly']) {
         if (isset($topicTitle)) {
             if ($GLOBALS['TSFE']->page['title'] == '') {
                 $GLOBALS['TSFE']->page['title'] = $topicTitle;
             } else {
                 $GLOBALS['TSFE']->page['title'] .= $this->conf['display.']['pageTitle.']['separator'] . $topicTitle;
             }
         } elseif (isset($forumTitle)) {
             if ($GLOBALS['TSFE']->page['title'] == '') {
                 $GLOBALS['TSFE']->page['title'] = $forumTitle;
             } else {
                 $GLOBALS['TSFE']->page['title'] .= $this->conf['display.']['pageTitle.']['separator'] . $forumTitle;
             }
         } elseif (isset($catTitle)) {
             if ($GLOBALS['TSFE']->page['title'] == '') {
                 $GLOBALS['TSFE']->page['title'] = $catTitle;
             } else {
                 $GLOBALS['TSFE']->page['title'] .= $this->conf['display.']['pageTitle.']['separator'] . $catTitle;
             }
         }
     } else {
         if (isset($catTitle)) {
             if ($GLOBALS['TSFE']->page['title'] == '') {
                 $GLOBALS['TSFE']->page['title'] = $catTitle;
             } else {
                 $GLOBALS['TSFE']->page['title'] .= $this->conf['display.']['pageTitle.']['separator'] . $catTitle;
             }
         }
         if (isset($forumTitle)) {
             if ($GLOBALS['TSFE']->page['title'] == '') {
                 $GLOBALS['TSFE']->page['title'] = $forumTitle;
             } else {
                 $GLOBALS['TSFE']->page['title'] .= $this->conf['display.']['pageTitle.']['separator'] . $forumTitle;
             }
         }
         if (isset($topicTitle)) {
             if ($GLOBALS['TSFE']->page['title'] == '') {
                 $GLOBALS['TSFE']->page['title'] = $topicTitle;
             } else {
                 $GLOBALS['TSFE']->page['title'] .= $this->conf['display.']['pageTitle.']['separator'] . $topicTitle;
             }
         }
     }
     if (isset($pageTitle)) {
         $GLOBALS['TSFE']->page['title'] .= $this->conf['display.']['pageTitle.']['separator'] . $pageTitle;
     }
     //wrap the page title
     $GLOBALS['TSFE']->page['title'] = $this->cObj->wrap($GLOBALS['TSFE']->page['title'], $this->conf['pagetitleWrap']);
     // set page title for indexed search
     $GLOBALS['TSFE']->indexedDocTitle = $GLOBALS['TSFE']->page['title'];
     //get to know if it is a USER_INT extension
     if ($this->pi_USER_INT_obj == true) {
         //$GLOBALS['TSFE']->page['title'] is already written, so the change does
         //not have any effect
         $GLOBALS['TSFE']->content = preg_replace('/<title>.+<\\/title>/', '<title>' . $GLOBALS['TSFE']->page['title'] . '</title>', $GLOBALS['TSFE']->content, 1);
     }
 }
示例#7
0
 /**
  * Fills the image markers for the SINGLE view with data. Supports Optionssplit for some parameters
  *
  * @param $lConf
  * @param $imgs
  * @param $imgsCaptions
  * @param $imgsAltTexts
  * @param $imgsTitleTexts
  * @param $imageNum
  * @param $markerArray
  * @return mixed
  */
 function getSingleViewImages($lConf, $imgs, $imgsCaptions, $imgsAltTexts, $imgsTitleTexts, $imageNum, $markerArray)
 {
     $marker = 'NEWS_IMAGE';
     $sViewSplitLConf = array();
     $tmpMarkers = array();
     $iC = count($imgs);
     // remove first img from image array in single view if the TSvar firstImageIsPreview is set
     if ($iC > 1 && $this->config['firstImageIsPreview'] || $iC >= 1 && $this->config['forceFirstImageIsPreview']) {
         array_shift($imgs);
         array_shift($imgsCaptions);
         array_shift($imgsAltTexts);
         array_shift($imgsTitleTexts);
         $iC--;
     }
     if ($iC > $imageNum) {
         $iC = $imageNum;
     }
     // get img array parts for single view pages
     if ($this->piVars[$this->config['singleViewPointerName']]) {
         /**
          * TODO
          * does this work with optionsplit ?
          */
         $spage = $this->piVars[$this->config['singleViewPointerName']];
         $astart = $imageNum * $spage;
         $imgs = array_slice($imgs, $astart, $imageNum);
         $imgsCaptions = array_slice($imgsCaptions, $astart, $imageNum);
         $imgsAltTexts = array_slice($imgsAltTexts, $astart, $imageNum);
         $imgsTitleTexts = array_slice($imgsTitleTexts, $astart, $imageNum);
     }
     $osCount = 0;
     if ($this->conf['enableOptionSplit']) {
         if ($lConf['imageMarkerOptionSplit']) {
             $ostmp = explode('|*|', $lConf['imageMarkerOptionSplit']);
             $osCount = count($ostmp);
         }
         $sViewSplitLConf = $this->processOptionSplit($lConf, $iC);
     }
     // reset markers for optionSplitted images
     for ($m = 1; $m <= $imageNum; $m++) {
         $markerArray['###' . $marker . '_' . $m . '###'] = '';
     }
     $cc = 0;
     $theImgCode = '';
     foreach ($imgs as $val) {
         if ($cc == $imageNum) {
             break;
         }
         if ($val) {
             if (!empty($sViewSplitLConf[$cc])) {
                 $lConf = $sViewSplitLConf[$cc];
             }
             //				if (1) {
             //					$lConf['image.']['imgList.'] = '';
             //					$lConf['image.']['imgList'] = $val;
             //					$lConf['image.']['imgPath'] = 'uploads/pics/';
             //	debug($lConf['image.'], ' ('.__CLASS__.'::'.__FUNCTION__.')', __LINE__, __FILE__, 3);
             //
             //					$imgHtml = $this->local_cObj->IMGTEXT($lConf['image.']);
             //
             //				} else {
             $lConf['image.']['altText'] = $imgsAltTexts[$cc];
             $lConf['image.']['titleText'] = $imgsTitleTexts[$cc];
             $lConf['image.']['file'] = 'uploads/pics/' . $val;
             $imgHtml = $this->local_cObj->IMAGE($lConf['image.']) . $this->local_cObj->stdWrap($imgsCaptions[$cc], $lConf['caption_stdWrap.']);
             //				}
             //debug($imgHtml, '$imgHtml ('.__CLASS__.'::'.__FUNCTION__.')', __LINE__, __FILE__, 3);
             if ($osCount) {
                 if ($iC > 1) {
                     $mName = '###' . $marker . '_' . $lConf['imageMarkerOptionSplit'] . '###';
                 } else {
                     // fall back to the first image marker if only one image has been found
                     $mName = '###' . $marker . '_1###';
                 }
                 $tmpMarkers[$mName]['html'] .= $imgHtml;
                 $tmpMarkers[$mName]['wrap'] = $lConf['imageWrapIfAny'];
             } else {
                 $theImgCode .= $imgHtml;
             }
         }
         $cc++;
     }
     if ($cc) {
         if ($osCount) {
             foreach ($tmpMarkers as $mName => $res) {
                 $markerArray[$mName] = $this->local_cObj->wrap($res['html'], $res['wrap']);
             }
         } else {
             $markerArray['###' . $marker . '###'] = $this->local_cObj->wrap($theImgCode, $lConf['imageWrapIfAny']);
         }
     } else {
         if ($lConf['imageMarkerOptionSplit']) {
             $m = '_1';
         } else {
             $m = '';
         }
         $markerArray['###' . $marker . $m . '###'] = $this->local_cObj->stdWrap($markerArray['###' . $marker . $m . '###'], $lConf['image.']['noImage_stdWrap.']);
     }
     //		debug($sViewSplitLConf, '$sViewSplitLConf ('.__CLASS__.'::'.__FUNCTION__.')', __LINE__, __FILE__, 2);
     return $markerArray;
 }