/** * Main function of the module. * * @return void * @access public */ function main() { global $BE_USER, $LANG, $BACK_PATH; $this->content = ''; // Access check! The page will show only if there is a valid page and if this page may be viewed by the user if (is_array($this->altRoot)) { $access = true; // get PID of altRoot Element to get pageInfoArr $altRootRecord = t3lib_BEfunc::getRecordWSOL($this->altRoot['table'], $this->altRoot['uid'], 'pid'); $pageInfoArr = t3lib_BEfunc::readPageAccess($altRootRecord['pid'], $this->perms_clause); } else { $pageInfoArr = t3lib_BEfunc::readPageAccess($this->id, $this->perms_clause); $access = intval($pageInfoArr['uid'] > 0); } if ($access) { if (t3lib_div::_GP('ajaxUnlinkRecord')) { $unlinkDestinationPointer = $this->apiObj->flexform_getPointerFromString(t3lib_div::_GP('ajaxUnlinkRecord')); $this->apiObj->unlinkElement($unlinkDestinationPointer); } $this->calcPerms = $this->getCalcPerms($pageInfoArr['uid']); // Define the root element record: $this->rootElementTable = is_array($this->altRoot) ? $this->altRoot['table'] : 'pages'; $this->rootElementUid = is_array($this->altRoot) ? $this->altRoot['uid'] : $this->id; $this->rootElementRecord = t3lib_BEfunc::getRecordWSOL($this->rootElementTable, $this->rootElementUid, '*'); if ($this->rootElementRecord['t3ver_swapmode'] == 0 && $this->rootElementRecord['_ORIG_uid']) { $this->rootElementUid_pidForContent = $this->rootElementRecord['_ORIG_uid']; } else { if ($this->rootElementRecord['t3ver_swapmode'] == -1 && $this->rootElementRecord['t3ver_oid'] && $this->rootElementRecord['pid'] < 0) { // typo3 lacks a proper API to properly detect Offline versions and extract Live Versions therefore this is done by hand if ($this->rootElementTable == 'pages') { $this->rootElementUid_pidForContent = $this->rootElementRecord['t3ver_oid']; } else { $liveRec = t3lib_beFunc::getLiveRecord($this->rootElementTable, $this->rootElementUid); $this->rootElementUid_pidForContent = $liveRec['pid']; } } else { // If pages use current UID, otherwhise you must use the PID to define the Page ID if ($this->rootElementTable == 'pages') { $this->rootElementUid_pidForContent = $this->rootElementRecord['uid']; } else { $this->rootElementUid_pidForContent = $this->rootElementRecord['pid']; } } } // Check if we have to update the pagetree: if (t3lib_div::_GP('updatePageTree')) { t3lib_BEfunc::setUpdateSignal('updatePageTree'); } // Draw the header. $this->doc = t3lib_div::makeInstance('template'); $this->doc->backPath = $BACK_PATH; $this->doc->setModuleTemplate('EXT:templavoila/resources/templates/mod1_default.html'); $this->doc->docType = 'xhtml_trans'; $this->doc->bodyTagId = 'typo3-mod-php'; $this->doc->divClass = ''; $this->doc->form = '<form action="' . htmlspecialchars('index.php?' . $this->link_getParameters()) . '" method="post">'; // Add custom styles $styleSheetFile = t3lib_extMgm::extPath($this->extKey) . 'mod1/pagemodule_' . substr(TYPO3_version, 0, 3) . '.css'; if (file_exists($styleSheetFile)) { $styleSheetFile = t3lib_extMgm::extRelPath($this->extKey) . 'mod1/pagemodule_' . substr(TYPO3_version, 0, 3) . '.css'; } else { $styleSheetFile = t3lib_extMgm::extRelPath($this->extKey) . 'mod1/pagemodule.css'; } if (isset($this->modTSconfig['properties']['stylesheet'])) { $styleSheetFile = $this->modTSconfig['properties']['stylesheet']; } $this->doc->getPageRenderer()->addCssFile($GLOBALS['BACK_PATH'] . $styleSheetFile); if (isset($this->modTSconfig['properties']['stylesheet.'])) { foreach ($this->modTSconfig['properties']['stylesheet.'] as $file) { if (substr($file, 0, 4) == 'EXT:') { list($extKey, $local) = explode('/', substr($file, 4), 2); $filename = ''; if (strcmp($extKey, '') && t3lib_extMgm::isLoaded($extKey) && strcmp($local, '')) { $file = t3lib_extMgm::extRelPath($extKey) . $local; } } $this->doc->getPageRenderer()->addCssFile($GLOBALS['BACK_PATH'] . $file); } } // Adding classic jumpToUrl function, needed for the function menu. Also, the id in the parent frameset is configured. $this->doc->JScode = $this->doc->wrapScriptTags(' if (top.fsMod) top.fsMod.recentIds["web"] = ' . intval($this->id) . '; ' . $this->doc->redirectUrls() . ' var T3_TV_MOD1_BACKPATH = "' . $BACK_PATH . '"; var T3_TV_MOD1_RETURNURL = "' . rawurlencode(t3lib_div::getIndpEnv('REQUEST_URI')) . '"; '); $this->doc->getPageRenderer()->loadExtJs(); $this->doc->JScode .= $this->doc->wrapScriptTags(' var typo3pageModule = { /** * Initialization */ init: function() { typo3pageModule.enableHighlighting(); }, /** * This method is used to bind the higlighting function "setActive" * to the mouseenter event and the "setInactive" to the mouseleave event. */ enableHighlighting: function() { Ext.get(\'typo3-docbody\') .on(\'mouseover\', typo3pageModule.setActive,typo3pageModule); }, /** * This method is used as an event handler when the * user hovers the a content element. */ setActive: function(e, t) { Ext.select(\'.active\').removeClass(\'active\').addClass(\'inactive\'); var parent = Ext.get(t).findParent(\'.t3-page-ce\', null, true); if (parent) { parent.removeClass(\'inactive\').addClass(\'active\'); } } } Ext.onReady(function() { typo3pageModule.init(); }); '); // Preparing context menues // this also adds prototype to the list of required libraries $CMparts = $this->doc->getContextMenuCode(); $mod1_file = 'dragdrop' . ($this->debug ? '.js' : '-min.js'); if (method_exists('t3lib_div', 'createVersionNumberedFilename')) { $mod1_file = t3lib_div::createVersionNumberedFilename($mod1_file); } else { $mod1_file .= '?' . filemtime(t3lib_extMgm::extPath('templavoila') . 'mod1/' . $mod1_file); } //Prototype /Scriptaculous // prototype is loaded before, so no need to include twice. $this->doc->JScodeLibArray['scriptaculous'] = '<script src="' . $this->doc->backPath . 'contrib/scriptaculous/scriptaculous.js?load=effects,dragdrop,builder" type="text/javascript"></script>'; $this->doc->JScodeLibArray['templavoila_mod1'] = '<script src="' . $this->doc->backPath . '../' . t3lib_extMgm::siteRelPath('templavoila') . 'mod1/' . $mod1_file . '" type="text/javascript"></script>'; if (isset($this->modTSconfig['properties']['javascript.']) && is_array($this->modTSconfig['properties']['javascript.'])) { // add custom javascript files foreach ($this->modTSconfig['properties']['javascript.'] as $key => $value) { if ($value) { if (substr($value, 0, 4) == 'EXT:') { list($extKey, $local) = explode('/', substr($value, 4), 2); $filename = ''; if (strcmp($extKey, '') && t3lib_extMgm::isLoaded($extKey) && strcmp($local, '')) { $value = t3lib_extMgm::extRelPath($extKey) . $local; } } $this->doc->JScodeLibArray[$key] = '<script src="' . $this->doc->backPath . htmlspecialchars($value) . '" type="text/javascript"></script>'; } } } // Set up JS for dynamic tab menu and side bar if (tx_templavoila_div::convertVersionNumberToInteger(TYPO3_version) < 4005000) { $this->doc->JScode .= $this->doc->getDynTabMenuJScode(); } else { $this->doc->loadJavascriptLib('js/tabmenu.js'); } $this->doc->JScode .= $this->modTSconfig['properties']['sideBarEnable'] ? $this->sideBarObj->getJScode() : ''; // Setting up support for context menus (when clicking the items icon) $this->doc->bodyTagAdditions = $CMparts[1]; $this->doc->JScode .= $CMparts[0]; $this->doc->postCode .= $CMparts[2]; // CSS for drag and drop if (t3lib_extMgm::isLoaded('t3skin')) { // Fix padding for t3skin in disabled tabs $this->doc->inDocStyles .= ' table.typo3-dyntabmenu td.disabled, table.typo3-dyntabmenu td.disabled_over, table.typo3-dyntabmenu td.disabled:hover { padding-left: 10px; } '; } $this->handleIncomingCommands(); // Start creating HTML output $render_editPageScreen = true; // Show message if the page is of a special doktype: if ($this->rootElementTable == 'pages') { // Initialize the special doktype class: $specialDoktypesObj =& t3lib_div::getUserObj('&tx_templavoila_mod1_specialdoktypes', ''); $specialDoktypesObj->init($this); $doktype = $this->rootElementRecord['doktype']; // if doktype is configured as editType render normal edit view $docTypesToEdit = $this->modTSconfig['properties']['additionalDoktypesRenderToEditView']; if ($docTypesToEdit && t3lib_div::inList($docTypesToEdit, $doktype)) { //Make sure it is editable by page module $doktype = self::DOKTYPE_NORMAL_EDIT; } $methodName = 'renderDoktype_' . $doktype; if (method_exists($specialDoktypesObj, $methodName)) { $result = $specialDoktypesObj->{$methodName}($this->rootElementRecord); if ($result !== FALSE) { $this->content .= $result; if ($GLOBALS['BE_USER']->isPSet($this->calcPerms, 'pages', 'edit')) { // Edit icon only if page can be modified by user $iconEdit = t3lib_iconWorks::getSpriteIcon('actions-document-open', array('title' => $LANG->sL('LLL:EXT:lang/locallang_mod_web_list.xml:editPage'))); $this->content .= '<br/><br/><strong>' . $this->link_edit($iconEdit . $LANG->sL('LLL:EXT:lang/locallang_mod_web_list.xml:editPage'), 'pages', $this->id) . '</strong>'; } $render_editPageScreen = false; // Do not output editing code for special doctypes! } } } if ($render_editPageScreen) { $editCurrentPageHTML = ''; // warn if page renders content from other page if ($this->rootElementRecord['content_from_pid']) { $contentPage = t3lib_BEfunc::getRecord('pages', intval($this->rootElementRecord['content_from_pid'])); $title = t3lib_BEfunc::getRecordTitle('pages', $contentPage); $linkToPid = 'index.php?id=' . intval($this->rootElementRecord['content_from_pid']); $link = '<a href="' . $linkToPid . '">' . htmlspecialchars($title) . ' (PID ' . intval($this->rootElementRecord['content_from_pid']) . ')</a>'; $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', '', sprintf($LANG->getLL('content_from_pid_title'), $link), t3lib_FlashMessage::INFO); $editCurrentPageHTML = ''; t3lib_FlashMessageQueue::addMessage($flashMessage); } // Render "edit current page" (important to do before calling ->sideBarObj->render() - otherwise the translation tab is not rendered! $editCurrentPageHTML .= $this->render_editPageScreen(); if (t3lib_div::_GP('ajaxUnlinkRecord')) { $this->render_editPageScreen(); echo $this->render_sidebar(); exit; } $this->content .= $editCurrentPageHTML; // Create sortables if (is_array($this->sortableContainers)) { $script = ''; $sortable_items_json = json_encode($this->sortableItems); $all_items_json = json_encode($this->allItems); $script .= 'var all_items = ' . $all_items_json . ';' . 'var sortable_items = ' . $sortable_items_json . ';' . 'var sortable_removeHidden = ' . ($this->MOD_SETTINGS['tt_content_showHidden'] !== '0' ? 'false;' : 'true;') . 'var sortable_linkParameters = \'' . $this->link_getParameters() . '\';'; $containment = '[' . t3lib_div::csvValues($this->sortableContainers, ',', '"') . ']'; $script .= 'Event.observe(window,"load",function(){'; foreach ($this->sortableContainers as $s) { $script .= 'tv_createSortable(\'' . $s . '\',' . $containment . ');'; } $script .= '});'; $this->content .= t3lib_div::wrapJS($script); } $this->doc->divClass = 'tpm-editPageScreen'; } } else { // No access or no current page uid: $this->doc = t3lib_div::makeInstance('template'); $this->doc->backPath = $BACK_PATH; $this->doc->setModuleTemplate('EXT:templavoila/resources/templates/mod1_noaccess.html'); $this->doc->docType = 'xhtml_trans'; $this->doc->bodyTagId = 'typo3-mod-php'; $cmd = t3lib_div::_GP('cmd'); switch ($cmd) { // Create a new page case 'crPage': // Output the page creation form $this->content .= $this->wizardsObj->renderWizard_createNewPage(t3lib_div::_GP('positionPid')); break; // If no access or if ID == zero // If no access or if ID == zero default: $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $LANG->getLL('default_introduction'), $LANG->getLL('title'), t3lib_FlashMessage::INFO); $this->content .= $flashMessage->render(); } } // Place content inside template $content = $this->doc->startPage($GLOBALS['LANG']->getLL('title')); $content .= $this->doc->moduleBody(array(), $this->getDocHeaderButtons(), $this->getBodyMarkers()); $content .= $this->doc->endPage(); // Replace content with templated content $this->content = $content; }