Example #1
0
    /**
     * Renders the display of Template Objects.
     *
     * @return	void
     */
    function renderTO()
    {
        if (intval($this->displayUid) > 0) {
            $row = t3lib_BEfunc::getRecordWSOL('tx_templavoila_tmplobj', $this->displayUid);
            if (is_array($row)) {
                $tRows = array();
                $tRows[] = '
					<tr class="bgColor5">
						<td colspan="2"><strong>Template Object Details:</strong>' . $this->cshItem('xMOD_tx_templavoila', 'mapping_to', $this->doc->backPath, '') . '</td>
					</tr>';
                // Get title and icon:
                $icon = t3lib_iconworks::getIconImage('tx_templavoila_tmplobj', $row, $GLOBALS['BACK_PATH'], ' align="top" title="UID: ' . $this->displayUid . '"');
                $title = t3lib_BEfunc::getRecordTitle('tx_templavoila_tmplobj', $row, 1);
                $tRows[] = '
					<tr class="bgColor4">
						<td>' . $GLOBALS['LANG']->getLL('templateObject') . ':</td>
						<td>' . $this->doc->wrapClickMenuOnIcon($icon, 'tx_templavoila_tmplobj', $row['uid'], 1) . $title . '</td>
					</tr>';
                // Find the file:
                $theFile = t3lib_div::getFileAbsFileName($row['fileref'], 1);
                if ($theFile && @is_file($theFile)) {
                    $relFilePath = substr($theFile, strlen(PATH_site));
                    $onCl = 'return top.openUrlInWindow(\'' . t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $relFilePath . '\',\'FileView\');';
                    $tRows[] = '
						<tr class="bgColor4">
							<td>' . $GLOBALS['LANG']->getLL('templateFile') . ':</td>
							<td><a href="#" onclick="' . htmlspecialchars($onCl) . '">' . htmlspecialchars($relFilePath) . '</a></td>
						</tr>';
                    // Finding Data Structure Record:
                    $DSOfile = '';
                    $dsValue = $row['datastructure'];
                    if ($row['parent']) {
                        $parentRec = t3lib_BEfunc::getRecordWSOL('tx_templavoila_tmplobj', $row['parent'], 'datastructure');
                        $dsValue = $parentRec['datastructure'];
                    }
                    if (t3lib_div::testInt($dsValue)) {
                        $DS_row = t3lib_BEfunc::getRecordWSOL('tx_templavoila_datastructure', $dsValue);
                    } else {
                        $DSOfile = t3lib_div::getFileAbsFileName($dsValue);
                    }
                    if (is_array($DS_row) || @is_file($DSOfile)) {
                        // Get main DS array:
                        if (is_array($DS_row)) {
                            // Get title and icon:
                            $icon = t3lib_iconworks::getIconImage('tx_templavoila_datastructure', $DS_row, $GLOBALS['BACK_PATH'], ' align="top" title="UID: ' . $DS_row['uid'] . '"');
                            $title = t3lib_BEfunc::getRecordTitle('tx_templavoila_datastructure', $DS_row, 1);
                            $tRows[] = '
								<tr class="bgColor4">
									<td>Data Structure Record:</td>
									<td>' . $this->doc->wrapClickMenuOnIcon($icon, 'tx_templavoila_datastructure', $DS_row['uid'], 1) . $title . '</td>
								</tr>';
                            // Link to updating DS/TO:
                            $onCl = 'index.php?file=' . rawurlencode($theFile) . '&_load_ds_xml=1&_load_ds_xml_to=' . $row['uid'];
                            $onClMsg = '
								if (confirm(unescape(\'' . rawurlencode('Warning: You should only modify Data Structures and Template Objects which have not been manually edited.' . chr(10) . 'You risk that manual changes will be removed without further notice!') . '\'))) {
									document.location=\'' . $onCl . '\';
								}
								return false;
								';
                            $tRows[] = '
								<tr class="bgColor4">
									<td>&nbsp;</td>
									<td><input type="submit" name="_" value="Modify DS / TO" onclick="' . htmlspecialchars($onClMsg) . '"/>' . $this->cshItem('xMOD_tx_templavoila', 'mapping_to_modifyDSTO', $this->doc->backPath, '') . '</td>
								</tr>';
                            // Read Data Structure:
                            $dataStruct = $this->getDataStructFromDSO($DS_row['dataprot']);
                        } else {
                            // Show filepath of external XML file:
                            $relFilePath = substr($DSOfile, strlen(PATH_site));
                            $onCl = 'return top.openUrlInWindow(\'' . t3lib_div::getIndpEnv('TYPO3_SITE_URL') . $relFilePath . '\',\'FileView\');';
                            $tRows[] = '
								<tr class="bgColor4">
									<td>Data Structure File:</td>
									<td><a href="#" onclick="' . htmlspecialchars($onCl) . '">' . htmlspecialchars($relFilePath) . '</a></td>
								</tr>';
                            // Read Data Structure:
                            $dataStruct = $this->getDataStructFromDSO('', $DSOfile);
                        }
                        // Write header of page:
                        $content .= '

							<!--
								Template Object Header:
							-->
							<h3>Template Object Information:</h3>
							<table border="0" cellpadding="2" cellspacing="1" id="c-toHeader">
								' . implode('', $tRows) . '
							</table>
						';
                        // If there is a valid data structure, draw table:
                        if (is_array($dataStruct)) {
                            // Working on Header and Body of HTML source:
                            // -- Processing the header editing --
                            list($editContent, $currentHeaderMappingInfo) = $this->renderTO_editProcessing($dataStruct, $row, $theFile, 1);
                            // Determine if DS is a template record and if it is a page template:
                            $showBodyTag = !is_array($DS_row) || $DS_row['scope'] == 1 ? TRUE : FALSE;
                            $parts = array();
                            $parts[] = array('label' => $GLOBALS['LANG']->getLL('tabTODetails'), 'content' => $content);
                            // -- Processing the head editing
                            $headerContent .= '
								<!--
									HTML header parts selection:
								-->
							<h3>' . $GLOBALS['LANG']->getLL('mappingHeadParts') . ': ' . $this->cshItem('xMOD_tx_templavoila', 'mapping_to_headerParts', $this->doc->backPath, '') . '</h3>
								' . $this->renderHeaderSelection($theFile, $currentHeaderMappingInfo, $showBodyTag, $editContent);
                            $parts[] = array('label' => $GLOBALS['LANG']->getLL('tabHeadParts'), 'content' => $headerContent);
                            // -- Processing the body editing --
                            list($editContent, $currentMappingInfo) = $this->renderTO_editProcessing($dataStruct, $row, $theFile, 0);
                            $bodyContent .= '
								<!--
									Data Structure mapping table:
								-->
							<h3>' . $GLOBALS['LANG']->getLL('mappingBodyParts') . ':</h3>
								' . $this->renderTemplateMapper($theFile, $this->displayPath, $dataStruct, $currentMappingInfo, $editContent);
                            $parts[] = array('label' => $GLOBALS['LANG']->getLL('tabBodyParts'), 'content' => $bodyContent);
                        } else {
                            $content .= $GLOBALS['LANG']->getLL('error') . ': No Data Structure Record could be found with UID "' . $dsValue . '"';
                        }
                    } else {
                        $content .= $GLOBALS['LANG']->getLL('error') . ': No Data Structure Record could be found with UID "' . $dsValue . '"';
                    }
                } else {
                    $content .= $GLOBALS['LANG']->getLL('error') . ': The file "' . $row['fileref'] . '" could not be found!';
                }
            } else {
                $content .= $GLOBALS['LANG']->getLL('error') . ': No Template Object Record with the UID ' . $this->displayUid;
            }
            $parts[0]['content'] = $content;
        } else {
            $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('templateObject') . ' ' . $GLOBALS['LANG']->getLL('error'), $GLOBALS['LANG']->getLL('errorNoUidFound'), 0, 1, 3);
        }
        // show tab menu
        if (is_array($parts)) {
            $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('mappingTitle'), '' . $this->doc->getDynTabMenu($parts, 'TEMPLAVOILA:templateModule:' . $this->id, 0, 0, 300), 0, 1);
        }
    }
 /**
  * Renders the data columns
  *
  * @param	array		$item item array
  * @return	array
  */
 function getItemColumns($item)
 {
     // Columns rendering
     $columns = array();
     foreach ($this->columnList as $field => $descr) {
         switch ($field) {
             case 'page':
                 // Create output item for pages record
                 $pageRow = $item[$field];
                 $rootline = t3lib_BEfunc::BEgetRootLine($pageRow['uid']);
                 $pageOnClick = t3lib_BEfunc::viewOnClick($pageRow['uid'], $GLOBALS['BACK_PATH'], $rootline);
                 $iconAltText = t3lib_BEfunc::getRecordIconAltText($pageRow, 'pages');
                 $icon = t3lib_iconWorks::getIconImage('pages', $pageRow, $GLOBALS['BACK_PATH'], 'title="' . $iconAltText . '" align="top"');
                 if ($this->showRootline) {
                     $title = t3lib_BEfunc::getRecordPath($pageRow['uid'], '1=1', 0);
                     $title = t3lib_div::fixed_lgd_cs($title, -$GLOBALS['BE_USER']->uc['titleLen']);
                 } else {
                     $title = t3lib_BEfunc::getRecordTitle('pages', $pageRow, TRUE);
                 }
                 if ($pageRow['doktype'] == 1 || $pageRow['doktype'] == 6) {
                     if ($this->enableContextMenus) {
                         $columns[$field] = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($icon, 'pages', $pageRow['uid'], 1, '', '+view,edit,info') . $title;
                     } else {
                         $columns[$field] = '<a href="#" onclick="' . htmlspecialchars($pageOnClick) . '">' . $icon . $title . '</a>';
                     }
                 } else {
                     if ($this->enableContextMenus) {
                         $columns[$field] = $GLOBALS['SOBE']->doc->wrapClickMenuOnIcon($icon, 'pages', $pageRow['uid'], 1, '', '+edit,info') . $title;
                     } else {
                         $columns[$field] = $icon . $title;
                     }
                 }
                 break;
             case 'content_element':
                 // Create output item for content record
                 $refTable = $item['tablenames'];
                 $refRow = $item[$field];
                 if ($refTable == 'pages') {
                     // The reference to the media is on a field of a page record
                     if ($GLOBALS['BE_USER']->isInWebMount($refRow['uid']) && $GLOBALS['BE_USER']->doesUserHaveAccess($refRow, 1)) {
                         $columns[$field] = tx_dam_SCbase::getRecordInfoEditLink($refTable, $refRow);
                     } else {
                         $pageRow = $refRow;
                         $rootline = t3lib_BEfunc::BEgetRootLine($pageRow['uid']);
                         $pageOnClick = t3lib_BEfunc::viewOnClick($pageRow['uid'], $GLOBALS['BACK_PATH'], $rootline);
                         $iconAltText = t3lib_BEfunc::getRecordIconAltText($refRow, $refTable);
                         $icon = t3lib_iconworks::getIconImage($refTable, $refRow, $GLOBALS['BACK_PATH'], 'class="c-recicon" align="top" title="' . $iconAltText . '"');
                         $title = t3lib_BEfunc::getRecordTitle($refTable, $refRow, 1);
                         if ($pageRow['doktype'] == 1 || $pageRow['doktype'] == 6) {
                             $columns[$field] = '<a href="#" onclick="' . htmlspecialchars($pageOnClick) . '">' . $icon . $title . '</a>';
                         } else {
                             $columns[$field] = $icon . $title;
                         }
                     }
                 } else {
                     // The reference to the media is on a field of a content element record
                     if ($GLOBALS['BE_USER']->isInWebMount($pageRow['uid']) && $GLOBALS['BE_USER']->doesUserHaveAccess($pageRow, 1)) {
                         $columns[$field] = tx_dam_SCbase::getRecordInfoEditLink($refTable, $refRow);
                     } else {
                         $pageRow = $item['page'];
                         $rootline = t3lib_BEfunc::BEgetRootLine($pageRow['uid']);
                         $pageOnClick = t3lib_BEfunc::viewOnClick($pageRow['uid'], $GLOBALS['BACK_PATH'], $rootline);
                         $iconAltText = t3lib_BEfunc::getRecordIconAltText($refRow, $refTable);
                         $icon = t3lib_iconworks::getIconImage($refTable, $refRow, $GLOBALS['BACK_PATH'], 'class="c-recicon" align="top" title="' . $iconAltText . '"');
                         $title = t3lib_BEfunc::getRecordTitle($refTable, $refRow, 1);
                         if ($pageRow['doktype'] == 1 || $pageRow['doktype'] == 6) {
                             $columns[$field] = '<a href="#" onclick="' . htmlspecialchars($pageOnClick) . '">' . $icon . $title . '</a>';
                         } else {
                             $columns[$field] = $icon . $title;
                         }
                     }
                 }
                 break;
             case 'content_field':
                 // Create output item for reference field
                 $columns[$field] = $item[$field];
                 break;
             case 'softref_key':
                 // Create output item for reference key
                 $columns[$field] = $item['softref_key'] ? $GLOBALS['LANG']->sl('LLL:EXT:dam/lib/locallang.xml:softref_key_' . $item['softref_key']) : $GLOBALS['LANG']->sl('LLL:EXT:dam/lib/locallang.xml:softref_key_media');
                 break;
             case 'content_age':
                 // Create output text describing the age of the content element
                 $columns[$field] = t3lib_BEfunc::dateTimeAge($item[$field], 1);
                 break;
             case 'media_element':
                 // Create output item for tx_dam record
                 $columns[$field] = tx_dam_SCbase::getRecordInfoEditLink('tx_dam', $item);
                 break;
             case 'media_element_age':
                 // Create output text describing the tx_dam record age
                 $columns[$field] = t3lib_BEfunc::dateTimeAge($item['tstamp'], 1);
                 break;
             case '_CLIPBOARD_':
                 $columns[$field] = $this->clipboard_getItemControl($item);
                 break;
             case '_CONTROL_':
                 $columns[$field] = $this->getItemControl($item);
                 $this->columnTDAttr[$field] = ' nowrap="nowrap"';
                 break;
             default:
                 $content = $item[$field];
                 $columns[$field] = htmlspecialchars(t3lib_div::fixed_lgd_cs($content, $this->titleLength));
                 break;
         }
         if ($columns[$field] === '') {
             $columns[$field] = '&nbsp;';
         }
     }
     // Thumbsnails?
     if ($this->showThumbs and $this->thumbnailPossible($item)) {
         $columns['media_element'] .= '<div style="margin:2px 0 2px 0;">' . $this->getThumbNail($item) . '</div>';
     }
     return $columns;
 }
 /**
  * Returns a record icon with title and edit link
  *
  * @param	string		Table name (tt_content,...)
  * @param	array		Record array
  * @param	boolean		For pages records the rootline will be rendered
  * @return	string		Rendered icon
  */
 function getRecordInfoEditLink($refTable, $row, $showRootline = FALSE)
 {
     global $BACK_PATH, $LANG, $TCA;
     // Create record title or rootline for pages if option is selected
     if ($refTable === 'pages' and $showRootline) {
         $elementTitle = t3lib_BEfunc::getRecordPath($row['uid'], '1=1', 0);
         $elementTitle = t3lib_div::fixed_lgd_cs($elementTitle, -$BE_USER->uc['titleLen']);
     } else {
         $elementTitle = t3lib_BEfunc::getRecordTitle($refTable, $row, 1);
     }
     // Create icon for record
     if ($refTable === 'tx_dam') {
         $elementIcon = tx_dam_guiFunc::icon_getFileTypeImgTag($row, 'class="c-recicon" align="top"');
     } else {
         $iconAltText = t3lib_BEfunc::getRecordIconAltText($row, $refTable);
         // Prepend table description for non-pages tables
         if (!($refTable === 'pages')) {
             $iconAltText = htmlspecialchars($LANG->sl($TCA[$refTable]['ctrl']['title']) . ': ') . $iconAltText;
         }
         $elementIcon = t3lib_iconworks::getIconImage($refTable, $row, $BACK_PATH, 'class="c-recicon" align="top" title="' . $iconAltText . '"');
     }
     // Return item with edit link
     return tx_dam_SCbase::wrapLink_edit($elementIcon . $elementTitle, $refTable, $row['uid']);
 }
Example #4
0
 /**
  * This method gets the title and the icon for a given record of a given table
  * It returns these as a HTML string
  *
  * @param	string		$table: name of the table
  * @param	integer		$uid: primary key of the record
  * @return	string		HTML to display
  */
 function getRecordDetails($table, $uid)
 {
     global $BACK_PATH;
     if (empty($table) || empty($uid)) {
         return '';
     } else {
         $row = array();
         if (isset($this->records[$table][$uid])) {
             $row = $this->records[$table][$uid];
         } else {
             $row = t3lib_BEfunc::getRecord($table, $uid);
         }
         $iconAltText = t3lib_BEfunc::getRecordIconAltText($row, $table);
         $elementTitle = t3lib_BEfunc::getRecordTitle($table, $row, 1);
         $elementIcon = t3lib_iconworks::getIconImage($table, $row, $BACK_PATH, 'class="c-recicon" title="' . $iconAltText . '"');
         return $elementIcon . $elementTitle;
     }
 }