TYPO3 CMS  TYPO3_6-2
ViewModuleController.php
Go to the documentation of this file.
1 <?php
3 
18 
26 
27  public function __construct() {
28  parent::__construct();
29 
30  $GLOBALS['LANG']->includeLLFile('EXT:viewpage/Resources/Private/Language/locallang.xlf');
31  $this->pageRenderer = $GLOBALS['TBE_TEMPLATE']->getPageRenderer();
32  $this->pageRenderer->addInlineSettingArray('web_view', array(
33  'States' => $GLOBALS['BE_USER']->uc['moduleData']['web_view']['States'],
34  ));
35  $this->pageRenderer->addInlineLanguageLabelFile('EXT:viewpage/Resources/Private/Language/locallang.xlf');
36  }
37 
43  public function showAction() {
44  $this->view->assignMultiple(
45  array(
46  'widths' => $this->getPreviewFrameWidths(),
47  'url' => $this->getTargetUrl()
48  )
49  );
50  }
51 
57  protected function getTargetUrl() {
58  $pageIdToShow = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
59  $adminCommand = $this->getAdminCommand($pageIdToShow);
60  $domainName = $this->getDomainName($pageIdToShow);
61  // Mount point overlay: Set new target page id and mp parameter
63  $sysPage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
64  $sysPage->init(FALSE);
65  $mountPointMpParameter = '';
66  $finalPageIdToShow = $pageIdToShow;
67  $mountPointInformation = $sysPage->getMountPointInfo($pageIdToShow);
68  if ($mountPointInformation && $mountPointInformation['overlay']) {
69  // New page id
70  $finalPageIdToShow = $mountPointInformation['mount_pid'];
71  $mountPointMpParameter = '&MP=' . $mountPointInformation['MPvar'];
72  }
73  // Modify relative path to protocol with host if domain record is given
74  $protocolAndHost = '..';
75  if ($domainName) {
76  // TCEMAIN.previewDomain can contain the protocol, check prevents double protocol URLs
77  if (strpos($domainName, '://') !== FALSE) {
78  $protocolAndHost = $domainName;
79  } else {
80  $protocol = 'http';
81  $page = (array)$sysPage->getPage($finalPageIdToShow);
82  if ($page['url_scheme'] == 2 || $page['url_scheme'] == 0 && \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SSL')) {
83  $protocol = 'https';
84  }
85  $protocolAndHost = $protocol . '://' . $domainName;
86  }
87  }
88  return $protocolAndHost . '/index.php?id=' . $finalPageIdToShow . $this->getTypeParameterIfSet($finalPageIdToShow) . $mountPointMpParameter . $adminCommand;
89  }
90 
97  protected function getAdminCommand($pageId) {
98  // The page will show only if there is a valid page and if this page may be viewed by the user
99  $pageinfo = BackendUtility::readPageAccess($pageId, $GLOBALS['BE_USER']->getPagePermsClause(1));
100  $addCommand = '';
101  if (is_array($pageinfo)) {
102  $addCommand = '&ADMCMD_editIcons=1' . BackendUtility::ADMCMD_previewCmds($pageinfo);
103  }
104  return $addCommand;
105  }
106 
115  protected function getTypeParameterIfSet($pageId) {
116  $typeParameter = '';
117  $modTSconfig = BackendUtility::getModTSconfig($pageId, 'mod.web_view');
118  $typeId = (int)$modTSconfig['properties']['type'];
119  if ($typeId > 0) {
120  $typeParameter = '&type=' . $typeId;
121  }
122  return $typeParameter;
123  }
124 
131  protected function getDomainName($pageId) {
132  $previewDomainConfig = $GLOBALS['BE_USER']->getTSConfig('TCEMAIN.previewDomain', BackendUtility::getPagesTSconfig($pageId));
133  if ($previewDomainConfig['value']) {
134  $domain = $previewDomainConfig['value'];
135  } else {
137  }
138  return $domain;
139  }
140 
146  protected function getPreviewFrameWidths() {
147  $pageId = (int)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('id');
148  $modTSconfig = BackendUtility::getModTSconfig($pageId, 'mod.web_view');
149  $data = json_encode(array(
150  'width' => '100%',
151  'height' => "100%"
152  ));
153  $widths = array(
154  $data => $GLOBALS['LANG']->getLL('autoSize')
155  );
156  if (is_array($modTSconfig['properties']['previewFrameWidths.'])) {
157  foreach ($modTSconfig['properties']['previewFrameWidths.'] as $item => $conf ){
158  $label = '';
159 
160  $width = substr($item, 0, -1);
161  $data = array('width' => $width);
162  $label .= $width . 'px ';
163 
164  //if height is set
165  if (isset($conf['height'])) {
166  $label .= ' × ' . $conf['height'] . 'px ';
167  $data['height'] = $conf['height'];
168  }
169 
170  if (substr($conf['label'], 0, 4) !== 'LLL:') {
171  $label .= $conf['label'];
172  } else {
173  $label .= $GLOBALS['LANG']->sL(trim($conf['label']));
174  }
175  $widths[json_encode($data)] = $label;
176  }
177  }
178  return $widths;
179  }
180 }
static readPageAccess($id, $perms_clause)
static BEgetRootLine($uid, $clause='', $workspaceOL=FALSE)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static getPagesTSconfig($id, $rootLine=NULL, $returnPartArray=FALSE)