Exemplo n.º 1
0
 /**
  * Main function, adding items to the click menu array.
  *
  * @param	object		Reference to the parent object of the clickmenu class which calls this function
  * @param	array		The current array of menu items - you have to add or remove items to this array in this function. Thats the point...
  * @param	string		The database table OR filename
  * @param	integer		For database tables, the UID
  * @return	array		The modified menu array.
  */
 function main(&$backRef, $menuItems, $table, $uid)
 {
     global $BE_USER, $LANG, $TYPO3_DB;
     $localItems = array();
     if (!$backRef->cmLevel) {
         $LL = $LANG->includeLLFile(t3lib_extMgm::extPath('templavoila') . 'locallang.xml', 0);
         // Adding link for Mapping tool:
         if (@is_file($table)) {
             if ($BE_USER->isAdmin()) {
                 if (function_exists('finfo_open')) {
                     $finfoMode = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME;
                     $fi = finfo_open($finfoMode);
                     $mimeInformation = @finfo_file($fi, $table);
                     $enabled = FALSE;
                     if (t3lib_div::isFirstPartOfStr($mimeInformation, 'text/html') || t3lib_div::isFirstPartOfStr($mimeInformation, 'application/xml')) {
                         $enabled = TRUE;
                     }
                     finfo_close($fi);
                 } else {
                     $pi = @pathinfo($table);
                     $enabled = preg_match('/(html?|tmpl|xml)/', $pi['extension']);
                 }
                 if ($enabled) {
                     $url = t3lib_extMgm::extRelPath('templavoila') . 'cm1/index.php?file=' . rawurlencode($table);
                     $localItems[] = $backRef->linkItem($LANG->getLLL('cm1_title', $LL, 1), $backRef->excludeIcon('<img src="' . $backRef->backPath . t3lib_extMgm::extRelPath('templavoila') . 'cm1/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'), $backRef->urlRefForCM($url, 'returnUrl'), 1);
                 }
             }
         } elseif (t3lib_div::inList('tx_templavoila_tmplobj,tx_templavoila_datastructure,tx_templavoila_content', $table)) {
             $url = t3lib_extMgm::extRelPath('templavoila') . 'cm1/index.php?table=' . rawurlencode($table) . '&uid=' . $uid . '&_reload_from=1';
             $localItems[] = $backRef->linkItem($LANG->getLLL('cm1_title', $LL, 1), $backRef->excludeIcon('<img src="' . $backRef->backPath . t3lib_extMgm::extRelPath('templavoila') . 'cm1/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'), $backRef->urlRefForCM($url, 'returnUrl'), 1);
         }
         $isTVelement = ('tt_content' == $table && $backRef->rec['CType'] == 'templavoila_pi1' || 'pages' == $table) && $backRef->rec['tx_templavoila_flex'];
         // Adding link for "View: Sub elements":
         if ($table == 'tt_content' && $isTVelement) {
             $localItems = array();
             $url = t3lib_extMgm::extRelPath('templavoila') . 'mod1/index.php?id=' . intval($backRef->rec['pid']) . '&altRoot[table]=' . rawurlencode($table) . '&altRoot[uid]=' . $uid . '&altRoot[field_flex]=tx_templavoila_flex';
             $localItems[] = $backRef->linkItem($LANG->getLLL('cm1_viewsubelements', $LL, 1), $backRef->excludeIcon('<img src="' . $backRef->backPath . t3lib_extMgm::extRelPath('templavoila') . 'cm1/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'), $backRef->urlRefForCM($url, 'returnUrl'), 1);
         }
         // Adding link for "View: Flexform XML" (admin only):
         if ($BE_USER->isAdmin() && $isTVelement) {
             $url = t3lib_extMgm::extRelPath('templavoila') . 'cm2/index.php?' . '&viewRec[table]=' . rawurlencode($table) . '&viewRec[uid]=' . $uid . '&viewRec[field_flex]=tx_templavoila_flex';
             $localItems[] = $backRef->linkItem($LANG->getLLL('cm1_viewflexformxml', $LL, 1), $backRef->excludeIcon('<img src="' . $backRef->backPath . t3lib_extMgm::extRelPath('templavoila') . 'cm2/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'), $backRef->urlRefForCM($url, 'returnUrl'), 1);
         }
         // Adding link for "View: DS/TO" (admin only):
         if ($BE_USER->isAdmin() && $isTVelement) {
             if (tx_templavoila_div::canBeInterpretedAsInteger($backRef->rec['tx_templavoila_ds'])) {
                 $url = t3lib_extMgm::extRelPath('templavoila') . 'cm1/index.php?' . 'table=tx_templavoila_datastructure&uid=' . $backRef->rec['tx_templavoila_ds'];
                 $localItems[] = $backRef->linkItem($LANG->getLLL('cm_viewdsto', $LL, 1) . ' [' . $backRef->rec['tx_templavoila_ds'] . '/' . $backRef->rec['tx_templavoila_to'] . ']', $backRef->excludeIcon('<img src="' . $backRef->backPath . t3lib_extMgm::extRelPath('templavoila') . 'cm2/cm_icon.gif" width="15" height="12" border="0" align="top" alt="" />'), $backRef->urlRefForCM($url, 'returnUrl'), 1);
             }
         }
         #			if ($table=='tt_content') {
         #					// Adding link for "Pages using this element":
         #				$localItems[] = $backRef->linkItem(
         #					$LANG->getLLL('cm1_pagesusingthiselement',$LL),
         #					$backRef->excludeIcon('<img src="'.t3lib_extMgm::extRelPath('templavoila').'cm1/cm_icon_activate.gif" width="15" height="12" border=0 align=top>'),
         #					"top.loadTopMenu('".t3lib_div::linkThisScript()."&cmLevel=1&subname=tx_templavoila_cm1_pagesusingthiselement');return false;",
         #					0,
         #					1
         #				);
         #			}
     } else {
         if (t3lib_div::_GP('subname') == 'tx_templavoila_cm1_pagesusingthiselement') {
             $menuItems = array();
             $url = t3lib_extMgm::extRelPath('templavoila') . 'mod1/index.php?id=';
             // Generate a list of pages where this element is also being used:
             $res = $TYPO3_DB->exec_SELECTquery('*', 'tx_templavoila_elementreferences', 'uid=' . $backRef->rec['uid']);
             if ($res) {
                 while (false != ($referenceRecord = $TYPO3_DB->sql_fetch_assoc($res))) {
                     $pageRecord = t3lib_beFunc::getRecord('pages', $referenceRecord['pid']);
                     $icon = t3lib_iconWorks::getSpriteIconForRecord('pages', $pageRecord);
                     // To do: Display language flag icon and jump to correct language
                     #						if ($referenceRecord['lkey'] != 'lDEF') {
                     #							$icon .= ' lKey:'.$referenceRecord['lkey'];
                     #						} elseif ($referenceRecord['vkey'] != 'vDEF') {
                     #							$icon .= ' vKey:'.$referenceRecord['vkey'];
                     #						}
                     if (is_array($pageRecord)) {
                         $menuItems[] = $backRef->linkItem($icon, t3lib_beFunc::getRecordTitle('pages', $pageRecord, 1), $backRef->urlRefForCM($url . $pageRecord['uid'], 'returnUrl'), 1);
                     }
                 }
             }
         }
     }
     // Simply merges the two arrays together and returns ...
     if (count($localItems)) {
         $menuItems = array_merge($menuItems, $localItems);
     }
     return $menuItems;
 }
Exemplo n.º 2
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>' . $GLOBALS['LANG']->getLL('renderTO_toDetails') . ':</strong>'.
							$this->cshItem('xMOD_tx_templavoila','mapping_to',$this->doc->backPath,'').
							'</td>
					</tr>';

					// Get title and icon:
				$icon = t3lib_iconWorks::getSpriteIconForRecord('tx_templavoila_tmplobj', $row);

				$title = t3lib_BEfunc::getRecordTitle('tx_templavoila_tmplobj', $row);
				$title = t3lib_BEFunc::getRecordTitlePrep($GLOBALS['LANG']->sL($title));
				$tRows[]='
					<tr class="bgColor4">
						<td>'.$GLOBALS['LANG']->getLL('templateObject').':</td>
						<td>' . $this->doc->wrapClickMenuOnIcon($icon, 'tx_templavoila_tmplobj', $row['uid'], 1) . $title . '</td>
					</tr>';

					// Session data
				$sessionKey = $this->MCONF['name'] . '_validatorInfo:' . $row['uid'];
				$sesDat = array('displayFile' => $row['fileref']);
				$GLOBALS['BE_USER']->setAndSaveSessionData($sessionKey, $sesDat);

					// 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 rowspan="2">'.$GLOBALS['LANG']->getLL('templateFile').':</td>
							<td><a href="#" onclick="'.htmlspecialchars($onCl).'">'.htmlspecialchars($relFilePath).'</a></td>
						</tr>
						<tr class="bgColor4">
							<td>
								<a href="#" onclick ="openValidator(\'' .  $sessionKey . '\');return false;">
									' . t3lib_iconWorks::getSpriteIcon('extensions-templavoila-htmlvalidate') . '
									' . $GLOBALS['LANG']->getLL('validateTpl') . '
								</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 (tx_templavoila_div::canBeInterpretedAsInteger($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::getSpriteIconForRecord('tx_templavoila_datastructure',$DS_row);
							$title = t3lib_BEfunc::getRecordTitle('tx_templavoila_datastructure', $DS_row);
							$title = t3lib_BEFunc::getRecordTitlePrep($GLOBALS['LANG']->sL($title));

							$tRows[]='
								<tr class="bgColor4">
									<td>' . $GLOBALS['LANG']->getLL('renderTO_dsRecord') . ':</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'] . '&uid=' . $DS_row['uid'] . '&returnUrl=' . $this->returnUrl;
							$onClMsg = '
								if (confirm(' . $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('renderTO_updateWarningConfirm')) . ')) {
									document.location=\''.$onCl.'\';
								}
								return false;
								';
							$tRows[]='
								<tr class="bgColor4">
									<td>&nbsp;</td>
									<td><input type="submit" name="_" value="' . $GLOBALS['LANG']->getLL('renderTO_editDSTO') . '" 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>' . $GLOBALS['LANG']->getLL('renderTO_dsFile') . ':</td>
									<td><a href="#" onclick="'.htmlspecialchars($onCl).'">'.htmlspecialchars($relFilePath).'</a></td>
								</tr>';
							$onCl = 'index.php?file=' . rawurlencode($theFile) . '&_load_ds_xml=1&_load_ds_xml_to=' . $row['uid'] . '&uid=' . rawurlencode($DSOfile) . '&returnUrl=' . $this->returnUrl;
							$onClMsg = '
								if (confirm(' . $GLOBALS['LANG']->JScharCode($GLOBALS['LANG']->getLL('renderTO_updateWarningConfirm')) . ')) {
									document.location=\''.$onCl.'\';
								}
								return false;
								';
							$tRows[]='
								<tr class="bgColor4">
									<td>&nbsp;</td>
									<td><input type="submit" name="_" value="' . $GLOBALS['LANG']->getLL('renderTO_editDSTO') . '" onclick="'.htmlspecialchars($onClMsg).'"/>'.
										$this->cshItem('xMOD_tx_templavoila','mapping_to_modifyDSTO',$this->doc->backPath,'').
										'</td>
								</tr>';

								// Read Data Structure:
							$dataStruct = $this->getDataStructFromDSO('',$DSOfile);
						}

							// Write header of page:
						$content.= '

							<!--
								Template Object Header:
							-->
							<h3>' . $GLOBALS['LANG']->getLL('renderTO_toInfo') . ':</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') . ': ' . sprintf($GLOBALS['LANG']->getLL('errorNoDSfound'), $dsValue);
					} else $content.= $GLOBALS['LANG']->getLL('error') . ': ' . sprintf($GLOBALS['LANG']->getLL('errorNoDSfound'), $dsValue);
				} else $content.= $GLOBALS['LANG']->getLL('error') . ': ' . sprintf($GLOBALS['LANG']->getLL('errorFileNotFound'), $row['fileref']);
			} else $content.= $GLOBALS['LANG']->getLL('error') . ': ' . sprintf($GLOBALS['LANG']->getLL('errorNoTOfound'), $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);
		}
	}
 /**
  * [Describe function...]
  *
  * @param	[type]		$editStruct: ...
  * @param	[type]		$currentMappingInfo: ...
  * @param	[type]		$firstLevelImplodeToken: ...
  * @param	[type]		$valueKey: ...
  * @return	[type]		...
  */
 function mergeFormDataIntoTemplateStructure($editStruct, $currentMappingInfo, $firstLevelImplodeToken = '', $valueKey = 'vDEF')
 {
     $isSection = 0;
     $htmlParse = $this->htmlParse ? $this->htmlParse : t3lib_div::makeInstance('t3lib_parsehtml');
     if (is_array($editStruct) && count($editStruct)) {
         $testInt = implode('', array_keys($editStruct));
         $isSection = !preg_match('/[^0-9]/', $testInt);
     }
     $out = '';
     if ($isSection) {
         foreach ($editStruct as $section) {
             if (is_array($section)) {
                 $secKey = key($section);
                 $secDat = $section[$secKey];
                 if ($currentMappingInfo['sub'][$secKey]) {
                     $out .= $this->mergeFormDataIntoTemplateStructure($secDat['el'], $currentMappingInfo['sub'][$secKey], '', $valueKey);
                 }
             }
         }
     } else {
         if (is_array($currentMappingInfo['cArray'])) {
             foreach ($currentMappingInfo['cArray'] as $key => $val) {
                 if (!tx_templavoila_div::canBeInterpretedAsInteger($key)) {
                     if (is_array($editStruct[$key]['el']) && $currentMappingInfo['sub'][$key]) {
                         $currentMappingInfo['cArray'][$key] = $this->mergeFormDataIntoTemplateStructure($editStruct[$key]['el'], $currentMappingInfo['sub'][$key], '', $valueKey);
                     } else {
                         # NO htmlspecialchars()'ing here ... it might be processed values that should be allowed to go through easily.
                         $currentMappingInfo['cArray'][$key] = $editStruct[$key][$valueKey];
                     }
                 } else {
                     $currentMappingInfo['cArray'][$key] = $htmlParse->XHTML_clean($currentMappingInfo['cArray'][$key]);
                 }
             }
             $out = implode($firstLevelImplodeToken, $currentMappingInfo['cArray']);
         }
     }
     return $out;
 }
 /**
  * Retrieves DS/TO storage pid for the current page. This function expectes
  * to be called from the itemsProcFunc only!
  *
  * @param	array	$params	Parameters as come to the itemsProcFunc
  * @param	t3lib_TCEforms	$pObj	Calling object
  * @return	int	Storage pid
  */
 protected function getStoragePid(array &$params, t3lib_TCEforms &$pObj)
 {
     // Get default first
     $tsConfig =& $pObj->cachedTSconfig[$params['table'] . ':' . $params['row']['uid']];
     $storagePid = intval($tsConfig['_STORAGE_PID']);
     // Check for alternative storage folder
     $field = $params['table'] == 'pages' ? 'uid' : 'pid';
     $modTSConfig = t3lib_BEfunc::getModTSconfig($params['row'][$field], 'tx_templavoila.storagePid');
     if (is_array($modTSConfig) && tx_templavoila_div::canBeInterpretedAsInteger($modTSConfig['value'])) {
         $storagePid = intval($modTSConfig['value']);
     }
     return $storagePid;
 }
Exemplo n.º 5
0
 /**
  * Returns the page uid of the selected storage folder from the context of the given page uid.
  *
  * @param	integer		$pageUid: Context page uid
  * @return	integer		PID of the storage folder
  * @access	public
  */
 function getStorageFolderPid($pageUid)
 {
     // Negative PID values is pointing to a page on the same level as the current.
     if ($pageUid < 0) {
         $pidRow = t3lib_BEfunc::getRecordWSOL('pages', abs($pageUid), 'pid');
         $pageUid = $pidRow['pid'];
     }
     $row = t3lib_BEfunc::getRecordWSOL('pages', $pageUid);
     $TSconfig = t3lib_BEfunc::getTCEFORM_TSconfig('pages', $row);
     $storagePid = intval($TSconfig['_STORAGE_PID']);
     // Check for alternative storage folder
     $modTSConfig = t3lib_BEfunc::getModTSconfig($pageUid, 'tx_templavoila.storagePid');
     if (is_array($modTSConfig) && tx_templavoila_div::canBeInterpretedAsInteger($modTSConfig['value'])) {
         $storagePid = intval($modTSConfig['value']);
     }
     return $storagePid;
 }