/** * Main function of the MODULE. Write the content to $this->content * There are three main modes: * - Based on a file reference, creating/modifying a DS/TO * - Based on a Template Object uid, remapping * - Based on a Data Structure uid, selecting a Template Object to map. * * @return void */ function main_mode() { global $LANG, $BACK_PATH; $this->doc = t3lib_div::makeInstance('template'); $this->doc->docType= 'xhtml_trans'; $this->doc->backPath = $BACK_PATH; $this->doc->setModuleTemplate('EXT:templavoila/resources/templates/cm1_default.html'); $this->doc->bodyTagId = 'typo3-mod-php'; $this->doc->divClass = ''; $this->doc->inDocStylesArray[]=' #templavoila-frame-visual { height:500px; display:block; margin:0 5px; width:98%; border: 1xpx solid black;} DIV.typo3-fullDoc H2 { width: 100%; } TABLE#c-mapInfo {margin-top: 10px; margin-bottom: 5px; } TABLE#c-mapInfo TR TD {padding-right: 20px;} select option.pagetemplate {background-image:url(../icon_pagetemplate.gif);background-repeat: no-repeat; background-position: 5px 50%; padding: 1px 0 3px 24px; -webkit-background-size: 0;} select option.fce {background-image:url(../icon_fce_ce.png);background-repeat: no-repeat; background-position: 5px 50%; padding: 1px 0 3px 24px; -webkit-background-size: 0;} #c-toMenu { margin-bottom:10px; } '; $this->doc->inDocStylesArray[] = self::$gnyfStyleBlock; // Add custom styles $this->doc->styleSheetFile2 = t3lib_extMgm::extRelPath($this->extKey)."cm1/styles.css"; // General GPvars for module mode: $this->displayFile = tx_templavoila_file::filename(t3lib_div::_GP('file')); $this->displayTable = t3lib_div::_GP('table'); $this->displayUid = t3lib_div::_GP('uid'); $this->displayPath = t3lib_div::_GP('htmlPath'); $this->returnUrl = t3lib_div::sanitizeLocalUrl(t3lib_div::_GP('returnUrl')); // GPvars specific to the DS listing/table and mapping features: $this->_preview = t3lib_div::_GP('_preview'); $this->mapElPath = t3lib_div::_GP('mapElPath'); $this->doMappingOfPath = t3lib_div::_GP('doMappingOfPath'); $this->showPathOnly = t3lib_div::_GP('showPathOnly'); $this->mappingToTags = t3lib_div::_GP('mappingToTags'); $this->DS_element = t3lib_div::_GP('DS_element'); $this->DS_cmd = t3lib_div::_GP('DS_cmd'); $this->fieldName = t3lib_div::_GP('fieldName'); // GPvars specific for DS creation from a file. $this->_load_ds_xml_content = t3lib_div::_GP('_load_ds_xml_content'); $this->_load_ds_xml_to = t3lib_div::_GP('_load_ds_xml_to'); $this->_saveDSandTO_TOuid = t3lib_div::_GP('_saveDSandTO_TOuid'); $this->_saveDSandTO_title = t3lib_div::_GP('_saveDSandTO_title'); $this->_saveDSandTO_type = t3lib_div::_GP('_saveDSandTO_type'); $this->_saveDSandTO_pid = t3lib_div::_GP('_saveDSandTO_pid'); $this->DS_element_DELETE = t3lib_div::_GP('DS_element_DELETE'); // Finding Storage folder: $this->findingStorageFolderIds(); // Setting up form-wrapper: $this->doc->form='<form action="'.$this->linkThisScript(array()).'" method="post" name="pageform">'; // JavaScript $this->doc->JScode.= $this->doc->wrapScriptTags(' script_ended = 0; function jumpToUrl(URL) { // document.location = URL; } function updPath(inPath) { // document.location = "'.t3lib_div::linkThisScript(array('htmlPath'=>'','doMappingOfPath'=>1)).'&htmlPath="+top.rawurlencode(inPath); } function openValidator(key) { new Ajax.Request("' . $GLOBALS['BACK_PATH'] . 'ajax.php?ajaxID=tx_templavoila_cm1_ajax::getDisplayFileContent&key=" + key, { onSuccess: function(response) { var valform = new Element(\'form\',{method: \'post\', target:\'_blank\', action: \'http://validator.w3.org/check#validate_by_input\'}); valform.insert(new Element(\'input\',{name: \'fragment\', value:response.responseText, type: \'hidden\'}));$(document.body).insert(valform); valform.submit(); } }); } '); if(tx_templavoila_div::convertVersionNumberToInteger(TYPO3_version) < 4005000) { $this->doc->getDynTabMenuJScode(); } else { $this->doc->loadJavascriptLib('js/tabmenu.js'); } // Setting up the context sensitive menu: $CMparts = $this->doc->getContextMenuCode(); $this->doc->bodyTagAdditions = $CMparts[1]; $this->doc->JScode.=$CMparts[0]; $this->doc->postCode.= $CMparts[2]; // Icons $this->dsTypes = array( 'sc' => $LANG->getLL('dsTypes_section') . ': ', 'co' => $LANG->getLL('dsTypes_container') . ': ', 'el' => $LANG->getLL('dsTypes_attribute') . ': ', 'at' => $LANG->getLL('dsTypes_element') . ': ', 'no' => $LANG->getLL('dsTypes_notmapped') . 'Not : '); foreach ($this->dsTypes as $id => $title) { $this->dsTypes[$id] = array( // abbrevation $id, // descriptive title $title, // image-path t3lib_iconWorks::skinImg($this->doc->backPath,t3lib_extMgm::extRelPath('templavoila').'cm1/item_'.$id.'.gif','width="24" height="16" border="0" style="margin-right: 5px;"'), // background-path t3lib_iconWorks::skinImg($this->doc->backPath,t3lib_extMgm::extRelPath('templavoila').'cm1/item_'.$id.'.gif','',1) ); // information $this->dsTypes[$id][4] = @getimagesize($this->dsTypes[$id][3]); } // Render content, depending on input values: if ($this->displayFile) { // Browsing file directly, possibly creating a template/data object records. $this->renderFile(); } elseif ($this->displayTable=='tx_templavoila_datastructure') { // Data source display $this->renderDSO(); } elseif ($this->displayTable=='tx_templavoila_tmplobj') { // Data source display $this->renderTO(); } // Add spacer: $this->content.=$this->doc->spacer(10); $this->pageinfo = t3lib_BEfunc::readPageAccess($this->id,$this->perms_clause); $docHeaderButtons = $this->getDocHeaderButtons(); $docContent = array( 'CSH' => $docHeaderButtons['csh'], 'CONTENT' => $this->content ); $content = $this->doc->startPage($GLOBALS['LANG']->getLL('title')); $content .= $this->doc->moduleBody( $this->pageinfo, $docHeaderButtons, $docContent ); $content .= $this->doc->endPage(); // Replace content with templated content $this->content = $content; }
/** * 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 (tx_templavoila_file::is_file($table)) { if ($BE_USER->isAdmin()) { if (tx_templavoila_file::is_xmlFile($table)) { $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 // Disables the item in the top-bar. Set this to zero if you wish the item to appear in the top bar! ); } } } 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 // Disables the item in the top-bar. Set this to zero if you wish the item to appear in the top bar! ); } $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 // Disables the item in the top-bar. Set this to zero if you wish the item to appear in the top bar! ); } // 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 // Disables the item in the top-bar. Set this to zero if you wish the item to appear in the top bar! ); } // 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 // Disables the item in the top-bar. Set this to zero if you wish the item to appear in the top bar! ); } } # 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 // Disables the item in the top-bar. Set this to zero if you wish the item to appear in the top bar! ); } } } } } // Simply merges the two arrays together and returns ... if (count($localItems)) { $menuItems = array_merge($menuItems,$localItems); } return $menuItems; }