コード例 #1
0
 /**
  * Replaces all markers and subparts in a template with the content provided in the structured array.
  *
  * @param string $content
  * @param array $markersAndSubparts
  * @param string $wrap
  * @param bool $uppercase
  * @param bool $deleteUnused
  * @return string
  */
 public function substituteMarkerAndSubpartArrayRecursive($content, array $markersAndSubparts, $wrap = '', $uppercase = false, $deleteUnused = false)
 {
     return $this->templateService->substituteMarkerAndSubpartArrayRecursive($content, $markersAndSubparts, $wrap, $uppercase, $deleteUnused);
 }
コード例 #2
0
 /**
  * Build the mail content
  *
  * @param int $curPage Id of the current page
  * @param string $pageList List of pages id
  * @param array $markerArray Array of markers
  * @param array $oldBrokenLink Marker array with the number of link found
  * @return string Content of the mail
  */
 protected function buildMail($curPage, $pageList, array $markerArray, array $oldBrokenLink)
 {
     $pageSectionHtml = $this->templateService->getSubpart($this->templateMail, '###PAGE_SECTION###');
     // Hook
     if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['buildMailMarkers'])) {
         foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['buildMailMarkers'] as $userFunc) {
             $params = array('curPage' => $curPage, 'pageList' => $pageList, 'markerArray' => $markerArray, 'oldBrokenLink' => $oldBrokenLink, 'pObj' => &$this);
             $newMarkers = GeneralUtility::callUserFunction($userFunc, $params, $this);
             if (is_array($newMarkers)) {
                 $markerArray = $newMarkers + $markerArray;
             }
             unset($params);
         }
     }
     if (is_array($markerArray)) {
         foreach ($markerArray as $markerKey => $markerValue) {
             if (empty($oldBrokenLink[$markerKey])) {
                 $oldBrokenLink[$markerKey] = 0;
             }
             if ($markerValue != $oldBrokenLink[$markerKey]) {
                 $this->isDifferentToLastRun = true;
             }
             $markerArray[$markerKey . '_old'] = $oldBrokenLink[$markerKey];
         }
     }
     $markerArray['title'] = BackendUtility::getRecordTitle('pages', BackendUtility::getRecord('pages', $curPage));
     $content = '';
     if ($markerArray['brokenlinkCount'] > 0) {
         $content = $this->templateService->substituteMarkerArray($pageSectionHtml, $markerArray, '###|###', true, true);
     }
     return $content;
 }
コード例 #3
0
 /**
  * Builds the checkboxes out of the hooks array
  *
  * @param array $brokenLinkOverView Array of broken links information
  * @param string $prefix
  * @return string code content
  */
 protected function getCheckOptions(array $brokenLinkOverView, $prefix = '')
 {
     $markerArray = array();
     if (!empty($prefix)) {
         $additionalAttr = ' class="' . $prefix . '"';
     } else {
         $additionalAttr = ' class="refresh"';
     }
     $checkOptionsTemplate = $this->templateService->getSubpart($this->doc->moduleTemplate, '###CHECKOPTIONS_SECTION###');
     $hookSectionTemplate = $this->templateService->getSubpart($checkOptionsTemplate, '###HOOK_SECTION###');
     $markerArray['statistics_header'] = $this->doc->sectionHeader($this->getLanguageService()->getLL('report.statistics.header'));
     $markerArray['total_count_label'] = BackendUtility::wrapInHelp('linkvalidator', 'checkboxes', $this->getLanguageService()->getLL('overviews.nbtotal'));
     $markerArray['total_count'] = $brokenLinkOverView['brokenlinkCount'] ?: '0';
     $linktypes = GeneralUtility::trimExplode(',', $this->modTS['linktypes'], true);
     $hookSectionContent = '';
     if (is_array($linktypes)) {
         if (!empty($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks']) && is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'])) {
             foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['linkvalidator']['checkLinks'] as $type => $value) {
                 if (in_array($type, $linktypes)) {
                     $hookSectionMarker = array('count' => $brokenLinkOverView[$type] ?: '0');
                     $translation = $this->getLanguageService()->getLL('hooks.' . $type) ?: $type;
                     $hookSectionMarker['option'] = '<input type="checkbox"' . $additionalAttr . ' id="' . $prefix . 'SET_' . $type . '" name="' . $prefix . 'SET[' . $type . ']" value="1"' . ($this->pObj->MOD_SETTINGS[$type] ? ' checked="checked"' : '') . '/>' . '<label for="' . $prefix . 'SET_' . $type . '">&nbsp;' . htmlspecialchars($translation) . '</label>';
                     $hookSectionContent .= $this->templateService->substituteMarkerArray($hookSectionTemplate, $hookSectionMarker, '###|###', true, true);
                 }
             }
         }
     }
     $checkOptionsTemplate = $this->templateService->substituteSubpart($checkOptionsTemplate, '###HOOK_SECTION###', $hookSectionContent);
     return $this->templateService->substituteMarkerArray($checkOptionsTemplate, $markerArray, '###|###', true, true);
 }
コード例 #4
0
ファイル: DocumentTemplate.php プロジェクト: burguin/test01
 /**
  * Fill the button lists with the defined HTML
  *
  * @param array $buttons HTML for all buttons
  * @return array Containing HTML for both buttonlists
  */
 protected function getDocHeaderButtons($buttons)
 {
     $markers = array();
     // Fill buttons for left and right float
     $floats = array('left', 'right');
     foreach ($floats as $key) {
         // Get the template for each float
         $buttonTemplate = $this->templateService->getSubpart($this->moduleTemplate, '###BUTTON_GROUPS_' . strtoupper($key) . '###');
         // Fill the button markers in this float
         $buttonTemplate = $this->templateService->substituteMarkerArray($buttonTemplate, $buttons, '###|###', true);
         // getting the wrap for each group
         $buttonWrap = $this->templateService->getSubpart($this->moduleTemplate, '###BUTTON_GROUP_WRAP###');
         // looping through the groups (max 6) and remove the empty groups
         for ($groupNumber = 1; $groupNumber < 6; $groupNumber++) {
             $buttonMarker = '###BUTTON_GROUP' . $groupNumber . '###';
             $buttonGroup = $this->templateService->getSubpart($buttonTemplate, $buttonMarker);
             if (trim($buttonGroup)) {
                 if ($buttonWrap) {
                     $buttonGroup = $this->templateService->substituteMarker($buttonWrap, '###BUTTONS###', $buttonGroup);
                 }
                 $buttonTemplate = $this->templateService->substituteSubpart($buttonTemplate, $buttonMarker, trim($buttonGroup));
             }
         }
         // Replace the marker with the template and remove all line breaks (for IE compat)
         $markers['BUTTONLIST_' . strtoupper($key)] = str_replace(LF, '', $buttonTemplate);
     }
     // Hook for manipulating docHeaderButtons
     if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['docHeaderButtonsHook'])) {
         $params = array('buttons' => $buttons, 'markers' => &$markers, 'pObj' => &$this);
         foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['docHeaderButtonsHook'] as $funcRef) {
             GeneralUtility::callUserFunction($funcRef, $params, $this);
         }
     }
     return $markers;
 }
コード例 #5
0
 /**
  * @test
  * @param string $template
  * @param array $markersAndSubparts
  * @param string $wrap
  * @param bool $uppercase
  * @param bool $deleteUnused
  * @param string $expected
  * @dataProvider substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArrayDataProvider
  */
 public function substituteMarkerAndSubpartArrayRecursiveResolvesMarkersAndSubpartsArray($template, $markersAndSubparts, $wrap, $uppercase, $deleteUnused, $expected)
 {
     $this->assertSame($expected, $this->templateService->substituteMarkerAndSubpartArrayRecursive($template, $markersAndSubparts, $wrap, $uppercase, $deleteUnused));
 }