Exemplo n.º 1
0
 /**
  * Tree rendering
  *
  * @param	integer		PID value
  * @param	string		Additional where clause
  * @return	array		Array of tree elements
  */
 function ext_tree($pid, $clause = '')
 {
     // Initialize:
     $this->init(' AND ' . $this->permsC() . $clause);
     // Get stored tree structure:
     $this->stored = unserialize($this->BE_USER->uc['browseTrees']['browsePages']);
     // PM action:
     $PM = t3lib_div::intExplode('_', t3lib_div::_GP('PM'));
     // traverse mounts:
     $titleLen = intval($this->BE_USER->uc['titleLen']);
     $treeArr = array();
     $idx = 0;
     // Set first:
     $this->bank = $idx;
     $isOpen = $this->stored[$idx][$pid] || $this->expandFirst;
     $curIds = $this->ids;
     // save ids
     $this->reset();
     $this->ids = $curIds;
     // Set PM icon:
     $cmd = $this->bank . '_' . ($isOpen ? '0_' : '1_') . $pid;
     $icon = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/ol/' . ($isOpen ? 'minus' : 'plus') . 'only.gif', 'width="18" height="16"') . ' align="top" alt="" />';
     $firstHtml = $this->PM_ATagWrap($icon, $cmd);
     if ($pid > 0) {
         $rootRec = t3lib_befunc::getRecordWSOL('pages', $pid);
         $firstHtml .= $this->wrapIcon(t3lib_iconWorks::getSpriteIconForRecord('pages', $rootRec), $rootRec);
     } else {
         $rootRec = array('title' => $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename'], 'uid' => 0);
         $firstHtml .= $this->wrapIcon('<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/i/_icon_website.gif', 'width="18" height="16"') . ' align="top" alt="" />', $rootRec);
     }
     $this->tree[] = array('HTML' => $firstHtml, 'row' => $rootRec);
     if ($isOpen) {
         // Set depth:
         $depthD = '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/ol/blank.gif', 'width="18" height="16"') . ' align="top" alt="" />';
         if ($this->addSelfId) {
             $this->ids[] = $pid;
         }
         $this->getTree($pid, 999, $depthD);
         $idH = array();
         $idH[$pid]['uid'] = $pid;
         if (count($this->buffer_idH)) {
             $idH[$pid]['subrow'] = $this->buffer_idH;
         }
         $this->buffer_idH = $idH;
     }
     // Add tree:
     $treeArr = array_merge($treeArr, $this->tree);
     return $treeArr;
 }
Exemplo n.º 2
0
 /**
  * Renders the HTML header for a foreign record, such as the title, toggle-function, drag'n'drop, etc.
  * Later on the command-icons are inserted here.
  *
  * @param string $parentUid The uid of the parent (embedding) record (uid or NEW...)
  * @param string $foreign_table The foreign_table we create a header for
  * @param array $rec The current record of that foreign_table
  * @param array $config content of $PA['fieldConf']['config']
  * @param boolean $isVirtualRecord
  * @return string The HTML code of the header
  * @todo Define visibility
  */
 public function renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config, $isVirtualRecord = FALSE)
 {
     // Init:
     $objectId = $this->inlineNames['object'] . self::Structure_Separator . $foreign_table . self::Structure_Separator . $rec['uid'];
     // We need the returnUrl of the main script when loading the fields via AJAX-call (to correct wizard code, so include it as 3rd parameter)
     // Pre-Processing:
     $isOnSymmetricSide = \TYPO3\CMS\Core\Database\RelationHandler::isOnSymmetricSide($parentUid, $config, $rec);
     $hasForeignLabel = !$isOnSymmetricSide && $config['foreign_label'] ? TRUE : FALSE;
     $hasSymmetricLabel = $isOnSymmetricSide && $config['symmetric_label'] ? TRUE : FALSE;
     // Get the record title/label for a record:
     // render using a self-defined user function
     if ($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc']) {
         $params = array('table' => $foreign_table, 'row' => $rec, 'title' => '', 'isOnSymmetricSide' => $isOnSymmetricSide, 'parent' => array('uid' => $parentUid, 'config' => $config));
         // callUserFunction requires a third parameter, but we don't want to give $this as reference!
         $null = NULL;
         \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc'], $params, $null);
         $recTitle = $params['title'];
     } elseif ($hasForeignLabel || $hasSymmetricLabel) {
         $titleCol = $hasForeignLabel ? $config['foreign_label'] : $config['symmetric_label'];
         $foreignConfig = $this->getPossibleRecordsSelectorConfig($config, $titleCol);
         // Render title for everything else than group/db:
         if ($foreignConfig['type'] != 'groupdb') {
             $recTitle = \TYPO3\CMS\Backend\Utility\BackendUtility::getProcessedValueExtra($foreign_table, $titleCol, $rec[$titleCol], 0, 0, FALSE);
         } else {
             // $recTitle could be something like: "tx_table_123|...",
             $valueParts = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode('|', $rec[$titleCol]);
             $itemParts = \TYPO3\CMS\Core\Utility\GeneralUtility::revExplode('_', $valueParts[0], 2);
             $recTemp = \t3lib_befunc::getRecordWSOL($itemParts[0], $itemParts[1]);
             $recTitle = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($itemParts[0], $recTemp, FALSE);
         }
         $recTitle = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitlePrep($recTitle);
         if (!strcmp(trim($recTitle), '')) {
             $recTitle = \TYPO3\CMS\Backend\Utility\BackendUtility::getNoRecordTitle(TRUE);
         }
     } else {
         $recTitle = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($foreign_table, $rec, TRUE);
     }
     // Renders a thumbnail for the header
     if (!empty($config['appearance']['headerThumbnail']['field'])) {
         $fieldValue = $rec[$config['appearance']['headerThumbnail']['field']];
         $firstElement = array_shift(\TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $fieldValue));
         $fileUid = array_pop(\TYPO3\CMS\Backend\Utility\BackendUtility::splitTable_Uid($firstElement));
         if (!empty($fileUid)) {
             $fileObject = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getFileObject($fileUid);
             if ($fileObject) {
                 $imageSetup = $config['appearance']['headerThumbnail'];
                 unset($imageSetup['field']);
                 $imageSetup = array_merge(array('width' => 64, 'height' => 64), $imageSetup);
                 $imageUrl = $fileObject->process(\TYPO3\CMS\Core\Resource\ProcessedFile::CONTEXT_IMAGEPREVIEW, $imageSetup)->getPublicUrl(TRUE);
                 $thumbnail = '<img src="' . $imageUrl . '" alt="' . htmlspecialchars($recTitle) . '">';
             } else {
                 $thumbnail = FALSE;
             }
         }
     }
     $altText = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordIconAltText($rec, $foreign_table);
     $iconImg = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($foreign_table, $rec, array('title' => htmlspecialchars($altText), 'id' => $objectId . '_icon'));
     $label = '<span id="' . $objectId . '_label">' . $recTitle . '</span>';
     $ctrl = $this->renderForeignRecordHeaderControl($parentUid, $foreign_table, $rec, $config, $isVirtualRecord);
     $header = '<table>' . '<tr>' . (!empty($config['appearance']['headerThumbnail']['field']) && $thumbnail ? '<td class="t3-form-field-header-inline-thumbnail" id="' . $objectId . '_thumbnailcontainer">' . $thumbnail . '</td>' : '<td class="t3-form-field-header-inline-icon" id="' . $objectId . '_iconcontainer">' . $iconImg . '</td>') . '<td class="t3-form-field-header-inline-summary">' . $label . '</td>' . '<td clasS="t3-form-field-header-inline-ctrl">' . $ctrl . '</td>' . '</tr>' . '</table>';
     return $header;
 }
Exemplo n.º 3
0
 /**
  * Wrapper method for t3lib_befunc::getRecordWSOL
  *
  * @param integer $uid The page id
  * @param boolean $unsetMovePointers Whether to unset move pointers
  * @return array
  */
 protected function getRecordWithWorkspaceOverlay($uid, $unsetMovePointers = FALSE)
 {
     return \t3lib_befunc::getRecordWSOL('pages', $uid, '*', '', TRUE, $unsetMovePointers);
 }
 /**
  * Fetches the sub-nodes of the given node
  *
  * @param t3lib_tree_Node $node
  * @param int $mountPoint
  * @param int $level internally used variable as a recursion limiter
  * @return t3lib_tree_NodeCollection
  */
 public function getNodes(t3lib_tree_Node $node, $mountPoint = 0, $level = 0)
 {
     /** @var $nodeCollection t3lib_tree_pagetree_NodeCollection */
     $nodeCollection = t3lib_div::makeInstance('t3lib_tree_pagetree_NodeCollection');
     if ($level >= 99) {
         return $nodeCollection;
     }
     $subpages = $this->getSubpages($node->getId());
     if (!is_array($subpages) || !count($subpages)) {
         return $nodeCollection;
     }
     foreach ($subpages as $subpage) {
         if (in_array($subpage['uid'], $this->hiddenRecords)) {
             continue;
         }
         $subpage = t3lib_befunc::getRecordWSOL('pages', $subpage['uid'], '*', '', TRUE, TRUE);
         if (!$subpage) {
             continue;
         }
         $subNode = t3lib_tree_pagetree_Commands::getNewNode($subpage, $mountPoint);
         if ($this->nodeCounter < $this->nodeLimit) {
             $childNodes = $this->getNodes($subNode, $mountPoint, $level + 1);
             $subNode->setChildNodes($childNodes);
             $this->nodeCounter += $childNodes->count();
         } else {
             $subNode->setLeaf(!$this->hasNodeSubPages($subNode->getId()));
         }
         $nodeCollection->append($subNode);
     }
     return $nodeCollection;
 }
 /**
  * Renders the HTML header for a foreign record, such as the title, toggle-function, drag'n'drop, etc.
  * Later on the command-icons are inserted here.
  *
  * @param	string		$parentUid: The uid of the parent (embedding) record (uid or NEW...)
  * @param	string		$foreign_table: The foreign_table we create a header for
  * @param	array		$rec: The current record of that foreign_table
  * @param	array		$config: content of $PA['fieldConf']['config']
  * @param	boolean		$isVirtualRecord:
  * @return	string		The HTML code of the header
  */
 function renderForeignRecordHeader($parentUid, $foreign_table, $rec, $config, $isVirtualRecord = false)
 {
     // Init:
     $objectId = $this->inlineNames['object'] . self::Structure_Separator . $foreign_table . self::Structure_Separator . $rec['uid'];
     $expandSingle = $config['appearance']['expandSingle'] ? 1 : 0;
     // we need the returnUrl of the main script when loading the fields via AJAX-call (to correct wizard code, so include it as 3rd parameter)
     $onClick = "return inline.expandCollapseRecord('" . htmlspecialchars($objectId) . "', {$expandSingle}, '" . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . "')";
     // Pre-Processing:
     $isOnSymmetricSide = t3lib_loadDBGroup::isOnSymmetricSide($parentUid, $config, $rec);
     $hasForeignLabel = !$isOnSymmetricSide && $config['foreign_label'] ? true : false;
     $hasSymmetricLabel = $isOnSymmetricSide && $config['symmetric_label'] ? true : false;
     // Get the record title/label for a record:
     // render using a self-defined user function
     if ($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc']) {
         $params = array('table' => $foreign_table, 'row' => $rec, 'title' => '', 'isOnSymmetricSide' => $isOnSymmetricSide, 'parent' => array('uid' => $parentUid, 'config' => $config));
         $null = null;
         // callUserFunction requires a third parameter, but we don't want to give $this as reference!
         t3lib_div::callUserFunction($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc'], $params, $null);
         $recTitle = $params['title'];
         // render the special alternative title
     } elseif ($hasForeignLabel || $hasSymmetricLabel) {
         $titleCol = $hasForeignLabel ? $config['foreign_label'] : $config['symmetric_label'];
         $foreignConfig = $this->getPossibleRecordsSelectorConfig($config, $titleCol);
         // Render title for everything else than group/db:
         if ($foreignConfig['type'] != 'groupdb') {
             $recTitle = t3lib_BEfunc::getProcessedValueExtra($foreign_table, $titleCol, $rec[$titleCol], 0, 0, false);
             // Render title for group/db:
         } else {
             // $recTitle could be something like: "tx_table_123|...",
             $valueParts = t3lib_div::trimExplode('|', $rec[$titleCol]);
             $itemParts = t3lib_div::revExplode('_', $valueParts[0], 2);
             $recTemp = t3lib_befunc::getRecordWSOL($itemParts[0], $itemParts[1]);
             $recTitle = t3lib_BEfunc::getRecordTitle($itemParts[0], $recTemp, false);
         }
         $recTitle = t3lib_BEfunc::getRecordTitlePrep($recTitle);
         if (!strcmp(trim($recTitle), '')) {
             $recTitle = t3lib_BEfunc::getNoRecordTitle(true);
         }
         // render the standard
     } else {
         $recTitle = t3lib_BEfunc::getRecordTitle($foreign_table, $rec, true);
     }
     $altText = t3lib_BEfunc::getRecordIconAltText($rec, $foreign_table);
     $iconImg = t3lib_iconWorks::getSpriteIconForRecord($foreign_table, $rec, array('title' => htmlspecialchars($altText), 'id' => $objectId . '_icon"'));
     $label = '<span id="' . $objectId . '_label">' . $recTitle . '</span>';
     if (!$isVirtualRecord) {
         $iconImg = $this->wrapWithAnchor($iconImg, '#', array('onclick' => $onClick));
         $label = $this->wrapWithAnchor($label, '#', array('onclick' => $onClick, 'style' => 'display: block;'));
     }
     $ctrl = $this->renderForeignRecordHeaderControl($parentUid, $foreign_table, $rec, $config, $isVirtualRecord);
     // @TODO: Check the table wrapping and the CSS definitions
     $header = '<table cellspacing="0" cellpadding="0" border="0" width="100%" style="margin-right: ' . $this->inlineStyles['margin-right'] . 'px;"' . ($this->fObj->borderStyle[2] ? ' background="' . htmlspecialchars($this->backPath . $this->fObj->borderStyle[2]) . '"' : '') . ($this->fObj->borderStyle[3] ? ' class="' . htmlspecialchars($this->fObj->borderStyle[3]) . '"' : '') . '>' . '<tr class="class-main12"><td width="18" id="' . $objectId . '_iconcontainer">' . $iconImg . '</td><td align="left"><strong>' . $label . '</strong></td><td align="right">' . $ctrl . '</td></tr></table>';
     return $header;
 }