TYPO3 CMS  TYPO3_6-2
MoveElementController.php
Go to the documentation of this file.
1 <?php
3 
20 
27 
28  // Internal, static (eg. from GPvars):
32  public $sys_language = 0;
33 
37  public $page_id;
38 
42  public $table;
43 
47  public $R_URI;
48 
53 
57  public $moveUid;
58 
62  public $makeCopy;
63 
70  public $doc;
71 
72  // Pages-select clause
76  public $perms_clause;
77 
78  // Internal, dynamic:
79  // Content for module accumulated here.
83  public $content;
84 
88  public function __construct() {
89  $GLOBALS['LANG']->includeLLFile('EXT:lang/locallang_misc.xlf');
90  $GLOBALS['SOBE'] = $this;
91  $this->init();
92  }
93 
100  public function init() {
101  // Setting internal vars:
102  $this->sys_language = (int)GeneralUtility::_GP('sys_language');
103  $this->page_id = (int)GeneralUtility::_GP('uid');
104  $this->table = GeneralUtility::_GP('table');
105  $this->R_URI = GeneralUtility::sanitizeLocalUrl(GeneralUtility::_GP('returnUrl'));
106  $this->input_moveUid = GeneralUtility::_GP('moveUid');
107  $this->moveUid = $this->input_moveUid ? $this->input_moveUid : $this->page_id;
108  $this->makeCopy = GeneralUtility::_GP('makeCopy');
109  // Select-pages where clause for read-access:
110  $this->perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1);
111  // Starting the document template object:
112  $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
113  $this->doc->backPath = $GLOBALS['BACK_PATH'];
114  $this->doc->setModuleTemplate('EXT:backend/Resources/Private/Templates/move_el.html');
115  $this->doc->JScode = '';
116  // Starting document content (header):
117  $this->content = '';
118  $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('movingElement'));
119  }
120 
127  public function main() {
128  if ($this->page_id) {
129  // Get record for element:
130  $elRow = BackendUtility::getRecordWSOL($this->table, $this->moveUid);
131  // Headerline: Icon, record title:
132  $hline = IconUtility::getSpriteIconForRecord($this->table, $elRow, array('id' => 'c-recIcon', 'title' => htmlspecialchars(BackendUtility::getRecordIconAltText($elRow, $this->table))));
133  $hline .= BackendUtility::getRecordTitle($this->table, $elRow, TRUE);
134  // Make-copy checkbox (clicking this will reload the page with the GET var makeCopy set differently):
135  $hline .= $this->doc->spacer(5);
136  $onClick = 'window.location.href=\'' . GeneralUtility::linkThisScript(array('makeCopy' => !$this->makeCopy)) . '\';';
137  $hline .= $this->doc->spacer(5);
138  $hline .= '<input type="hidden" name="makeCopy" value="0" />' . '<input type="checkbox" name="makeCopy" id="makeCopy" value="1"' . ($this->makeCopy ? ' checked="checked"' : '') . ' onclick="' . htmlspecialchars($onClick) . '" /> <label for="makeCopy" class="t3-label-valign-top">' . $GLOBALS['LANG']->getLL('makeCopy', 1) . '</label>';
139  // Add the header-content to the module content:
140  $this->content .= $this->doc->section('', $hline, FALSE, TRUE);
141  $this->content .= $this->doc->spacer(20);
142  // Reset variable to pick up the module content in:
143  $code = '';
144  // IF the table is "pages":
145  if ((string) $this->table == 'pages') {
146  // Get page record (if accessible):
147  $pageinfo = BackendUtility::readPageAccess($this->page_id, $this->perms_clause);
148  if (is_array($pageinfo) && $GLOBALS['BE_USER']->isInWebMount($pageinfo['pid'], $this->perms_clause)) {
149  // Initialize the position map:
150  $posMap = GeneralUtility::makeInstance('ext_posMap_pages');
151  $posMap->moveOrCopy = $this->makeCopy ? 'copy' : 'move';
152  // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page).
153  if ($pageinfo['pid']) {
154  $pidPageInfo = BackendUtility::readPageAccess($pageinfo['pid'], $this->perms_clause);
155  if (is_array($pidPageInfo)) {
156  if ($GLOBALS['BE_USER']->isInWebMount($pidPageInfo['pid'], $this->perms_clause)) {
157  $code .= '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array('uid' => (int)$pageinfo['pid'], 'moveUid' => $this->moveUid))) . '">' . IconUtility::getSpriteIcon('actions-view-go-up') . BackendUtility::getRecordTitle('pages', $pidPageInfo, TRUE) . '</a><br />';
158  } else {
159  $code .= IconUtility::getSpriteIconForRecord('pages', $pidPageInfo) . BackendUtility::getRecordTitle('pages', $pidPageInfo, TRUE) . '<br />';
160  }
161  }
162  }
163  // Create the position tree:
164  $code .= $posMap->positionTree($this->page_id, $pageinfo, $this->perms_clause, $this->R_URI);
165  }
166  }
167  // IF the table is "tt_content":
168  if ((string) $this->table == 'tt_content') {
169  // First, get the record:
170  $tt_content_rec = BackendUtility::getRecord('tt_content', $this->moveUid);
171  // ?
172  if (!$this->input_moveUid) {
173  $this->page_id = $tt_content_rec['pid'];
174  }
175  // Checking if the parent page is readable:
176  $pageinfo = BackendUtility::readPageAccess($this->page_id, $this->perms_clause);
177  if (is_array($pageinfo) && $GLOBALS['BE_USER']->isInWebMount($pageinfo['pid'], $this->perms_clause)) {
178  // Initialize the position map:
179  $posMap = GeneralUtility::makeInstance('ext_posMap_tt_content');
180  $posMap->moveOrCopy = $this->makeCopy ? 'copy' : 'move';
181  $posMap->cur_sys_language = $this->sys_language;
182  // Headerline for the parent page: Icon, record title:
183  $hline = IconUtility::getSpriteIconForRecord('pages', $pageinfo, array('title' => htmlspecialchars(BackendUtility::getRecordIconAltText($pageinfo, 'pages'))));
184  $hline .= BackendUtility::getRecordTitle('pages', $pageinfo, TRUE);
185  // Load SHARED page-TSconfig settings and retrieve column list from there, if applicable:
186  // SHARED page-TSconfig settings.
187  $modTSconfig_SHARED = BackendUtility::getModTSconfig($this->page_id, 'mod.SHARED');
188  $colPosArray = GeneralUtility::callUserFunction('TYPO3\\CMS\\Backend\\View\\BackendLayoutView->getColPosListItemsParsed', $this->page_id, $this);
189  $colPosIds = array();
190  foreach ($colPosArray as $colPos) {
191  $colPosIds[] = $colPos[1];
192  }
193  // Removing duplicates, if any
194  $colPosList = implode(',', array_unique($colPosIds));
195  // Adding parent page-header and the content element columns from position-map:
196  $code = $hline . '<br />';
197  $code .= $posMap->printContentElementColumns($this->page_id, $this->moveUid, $colPosList, 1, $this->R_URI);
198  // Print a "go-up" link IF there is a real parent page (and if the user has read-access to that page).
199  $code .= '<br /><br />';
200  if ($pageinfo['pid']) {
201  $pidPageInfo = BackendUtility::readPageAccess($pageinfo['pid'], $this->perms_clause);
202  if (is_array($pidPageInfo)) {
203  if ($GLOBALS['BE_USER']->isInWebMount($pidPageInfo['pid'], $this->perms_clause)) {
204  $code .= '<a href="' . htmlspecialchars(GeneralUtility::linkThisScript(array(
205  'uid' => (int)$pageinfo['pid'],
206  'moveUid' => $this->moveUid
207  ))) . '">' . IconUtility::getSpriteIcon('actions-view-go-up') . BackendUtility::getRecordTitle('pages', $pidPageInfo, TRUE) . '</a><br />';
208  } else {
209  $code .= IconUtility::getSpriteIconForRecord('pages', $pidPageInfo) . BackendUtility::getRecordTitle('pages', $pidPageInfo, TRUE) . '<br />';
210  }
211  }
212  }
213  // Create the position tree (for pages):
214  $code .= $posMap->positionTree($this->page_id, $pageinfo, $this->perms_clause, $this->R_URI);
215  }
216  }
217  // Add the $code content as a new section to the module:
218  $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('selectPositionOfElement'), $code, FALSE, TRUE);
219  }
220  // Setting up the buttons and markers for docheader
221  $docHeaderButtons = $this->getButtons();
222  $markers['CSH'] = $docHeaderButtons['csh'];
223  $markers['CONTENT'] = $this->content;
224  // Build the <body> for the module
225  $this->content = $this->doc->startPage($GLOBALS['LANG']->getLL('movingElement'));
226  $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
227  $this->content .= $this->doc->endPage();
228  $this->content = $this->doc->insertStylesAndJS($this->content);
229  }
230 
237  public function printContent() {
238  echo $this->content;
239  }
240 
246  protected function getButtons() {
247  $buttons = array(
248  'csh' => '',
249  'back' => ''
250  );
251  if ($this->page_id) {
252  if ((string) $this->table == 'pages') {
253  $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'move_el_pages', $GLOBALS['BACK_PATH'], '', TRUE);
254  } elseif ((string) $this->table == 'tt_content') {
255  $buttons['csh'] = BackendUtility::cshItem('xMOD_csh_corebe', 'move_el_cs', $GLOBALS['BACK_PATH'], '', TRUE);
256  }
257  if ($this->R_URI) {
258  $buttons['back'] = '<a href="' . htmlspecialchars($this->R_URI) . '" class="typo3-goBack" title="' . $GLOBALS['LANG']->getLL('goBack', TRUE) . '">' . IconUtility::getSpriteIcon('actions-view-go-back') . '</a>';
259  }
260  }
261  return $buttons;
262  }
263 
264 }
static getRecordWSOL($table, $uid, $fields=' *', $where='', $useDeleteClause=TRUE, $unsetMovePointers=FALSE)
static getRecordTitle($table, $row, $prep=FALSE, $forceResult=TRUE)
static getSpriteIconForRecord($table, array $row, array $options=array())
static linkThisScript(array $getParams=array())
static getRecordIconAltText($row, $table='pages')
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]