Example #1
0
 /**
  * Gets the filled markers that are used in the HTML template.
  *
  * @return	array		The filled marker array
  */
 protected function getBodyMarkers()
 {
     $bodyMarkers = array('TITLE' => $GLOBALS['LANG']->getLL('title'));
     if ($this->modTSconfig['properties']['sideBarEnable'] && $this->sideBarObj->position == 'left') {
         $sidebarMode = 'SIDEBAR_LEFT';
     } elseif ($this->modTSconfig['properties']['sideBarEnable']) {
         $sidebarMode = 'SIDEBAR_TOP';
     } else {
         $sidebarMode = 'SIDEBAR_DISABLED';
     }
     $editareaTpl = t3lib_parsehtml::getSubpart($this->doc->moduleTemplate, $sidebarMode);
     if ($editareaTpl) {
         $editareaMarkers = array('TABROW' => $this->render_sidebar(), 'CONTENT' => $this->content);
         $editareaMarkers['FLASHMESSAGES'] = t3lib_FlashMessageQueue::renderFlashMessages();
         $editareaContent = t3lib_parsehtml::substituteMarkerArray($editareaTpl, $editareaMarkers, '###|###', true);
         $bodyMarkers['EDITAREA'] = $editareaContent;
     } else {
         $bodyMarkers['CONTENT'] = $this->content;
     }
     return $bodyMarkers;
 }
    /**
     * Put together the various elements for the module <body> using a static HTML
     * template
     *
     * @param	array		Record of the current page, used for page path and info
     * @param	array		HTML for all buttons
     * @param	array		HTML for all other markers
     * @return	string		Composite HTML
     */
    public function moduleBody($pageRecord = array(), $buttons = array(), $markerArray = array(), $subpartArray = array())
    {
        // Get the HTML template for the module
        $moduleBody = t3lib_parsehtml::getSubpart($this->moduleTemplate, '###FULLDOC###');
        // Add CSS
        $this->inDocStylesArray[] = 'html { overflow: hidden; }';
        // Add JS code to the <head> for IE
        $this->JScode .= $this->wrapScriptTags('
				// workaround since IE6 cannot deal with relative height for scrolling elements
			function resizeDocBody()	{
				$("typo3-docbody").style.height = (document.body.offsetHeight - parseInt($("typo3-docheader").getStyle("height")));
			}
			if (Prototype.Browser.IE) {
				var version = parseFloat(navigator.appVersion.split(\';\')[1].strip().split(\' \')[1]);
				if (version == 6) {
					Event.observe(window, "resize", resizeDocBody, false);
					Event.observe(window, "load", resizeDocBody, false);
				}
			}
		');
        // Get the page path for the docheader
        $markerArray['PAGEPATH'] = $this->getPagePath($pageRecord);
        // Get the page info for the docheader
        $markerArray['PAGEINFO'] = $this->getPageInfo($pageRecord);
        // Get all the buttons for the docheader
        $docHeaderButtons = $this->getDocHeaderButtons($buttons);
        // Merge docheader buttons with the marker array
        $markerArray = array_merge($markerArray, $docHeaderButtons);
        // replacing subparts
        foreach ($subpartArray as $marker => $content) {
            $moduleBody = t3lib_parsehtml::substituteSubpart($moduleBody, $marker, $content);
        }
        if ($this->showFlashMessages) {
            // adding flash messages
            $flashMessages = t3lib_FlashMessageQueue::renderFlashMessages();
            if (!empty($flashMessages)) {
                $flashMessages = '<div id="typo3-messages">' . $flashMessages . '</div>';
            }
            if (strstr($moduleBody, '###FLASHMESSAGES###')) {
                // either replace a dedicated marker for the messages if present
                $moduleBody = str_replace('###FLASHMESSAGES###', $flashMessages, $moduleBody);
            } else {
                // or force them to appear before the content
                $moduleBody = str_replace('###CONTENT###', $flashMessages . '###CONTENT###', $moduleBody);
            }
        }
        // replacing all markers with the finished markers and return the HTML content
        return t3lib_parsehtml::substituteMarkerArray($moduleBody, $markerArray, '###|###');
    }
Example #3
0
 /**
  * Returns the rendered flash messages.
  *
  * @return string
  */
 protected function getRenderedFlashMessages()
 {
     if (class_exists('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService', TRUE)) {
         /** @var \TYPO3\CMS\Core\Messaging\FlashMessageService $flashMessageService */
         $flashMessageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
         /** @var \TYPO3\CMS\Core\Messaging\FlashMessageQueue $defaultFlashMessageQueue */
         $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
         $renderedFlashMessages = $defaultFlashMessageQueue->renderFlashMessages();
     } else {
         $renderedFlashMessages = t3lib_FlashMessageQueue::renderFlashMessages();
     }
     return $renderedFlashMessages;
 }
Example #4
0
    /**
     * Put together the various elements for the module <body> using a static HTML
     * template
     *
     * @param	array		Record of the current page, used for page path and info
     * @param	array		HTML for all buttons
     * @param	array		HTML for all other markers
     * @return	string		Composite HTML
     */
    public function moduleBody($pageRecord = array(), $buttons = array(), $markerArray = array(), $subpartArray = array())
    {
        // Get the HTML template for the module
        $moduleBody = t3lib_parsehtml::getSubpart($this->moduleTemplate, '###FULLDOC###');
        // Add CSS
        $this->inDocStylesArray[] = 'html { overflow: hidden; }';
        // Add JS code to the <head> for IE
        $this->JScode .= $this->wrapScriptTags('
				// workaround since IE6 cannot deal with relative height for scrolling elements
			function resizeDocBody()	{
				$("typo3-docbody").style.height = (document.body.offsetHeight - parseInt($("typo3-docheader").getStyle("height")));
			}
			if (Prototype.Browser.IE) {
				var version = parseFloat(navigator.appVersion.split(\';\')[1].strip().split(\' \')[1]);
				if (version == 6) {
					Event.observe(window, "resize", resizeDocBody, false);
					Event.observe(window, "load", resizeDocBody, false);
				}
			}
		');
        // Get the page path for the docheader
        $markerArray['PAGEPATH'] = $this->getPagePath($pageRecord);
        // Get the page info for the docheader
        $markerArray['PAGEINFO'] = $this->getPageInfo($pageRecord);
        // Get all the buttons for the docheader
        $docHeaderButtons = $this->getDocHeaderButtons($buttons);
        // Merge docheader buttons with the marker array
        $markerArray = array_merge($markerArray, $docHeaderButtons);
        // replacing subparts
        foreach ($subpartArray as $marker => $content) {
            $moduleBody = t3lib_parsehtml::substituteSubpart($moduleBody, $marker, $content);
        }
        // adding flash messages
        if ($this->showFlashMessages) {
            $flashMessages = t3lib_FlashMessageQueue::renderFlashMessages();
            if (!empty($flashMessages)) {
                $markerArray['FLASHMESSAGES'] = '<div id="typo3-messages">' . $flashMessages . '</div>';
                // if there is no dedicated marker for the messages present
                // then force them to appear before the content
                if (strpos($moduleBody, '###FLASHMESSAGES###') === FALSE) {
                    $moduleBody = str_replace('###CONTENT###', '###FLASHMESSAGES######CONTENT###', $moduleBody);
                }
            }
        }
        // Hook for adding more markers/content to the page, like the version selector
        if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['moduleBodyPostProcess'])) {
            $params = array('moduleTemplateFilename' => &$this->moduleTemplateFilename, 'moduleTemplate' => &$this->moduleTemplate, 'moduleBody' => &$moduleBody, 'markers' => &$markerArray, 'parentObject' => &$this);
            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/template.php']['moduleBodyPostProcess'] as $funcRef) {
                t3lib_div::callUserFunction($funcRef, $params, $this);
            }
        }
        // replacing all markers with the finished markers and return the HTML content
        return t3lib_parsehtml::substituteMarkerArray($moduleBody, $markerArray, '###|###');
    }
Example #5
0
 /**
  * Main function of the module
  *
  * @access	public
  *
  * @return	void
  */
 public function main()
 {
     // Is the user allowed to access this page?
     $access = is_array($this->pageInfo) || $GLOBALS['BE_USER']->isAdmin();
     if ($this->id && $access) {
         // Increase max_execution_time and max_input_time for large documents.
         if (!ini_get('safe_mode')) {
             ini_set('max_execution_time', '0');
             ini_set('max_input_time', '-1');
         }
         switch ($this->CMD) {
             case 'indexFile':
                 if (!empty($this->data['id']) && isset($this->data['core'])) {
                     // Save document to database and index.
                     $doc =& tx_dlf_document::getInstance($this->data['id'], $this->id, TRUE);
                     if ($doc->ready) {
                         $doc->save($this->id, $this->data['core']);
                     } else {
                         $_message = t3lib_div::makeInstance('t3lib_FlashMessage', htmlspecialchars(sprintf(tx_dlf_helper::getLL('flash.FileNotLoaded'), $title, $uid)), tx_dlf_helper::getLL('flash.error', TRUE), t3lib_FlashMessage::ERROR, TRUE);
                         t3lib_FlashMessageQueue::addMessage($_message);
                     }
                 }
                 break;
             case 'reindexDocs':
                 if (isset($this->data['core'])) {
                     if (!empty($this->data['collection'])) {
                         // Get all documents in this collection.
                         $_result = $GLOBALS['TYPO3_DB']->exec_SELECT_mm_query('tx_dlf_documents.title AS title,tx_dlf_documents.uid AS uid', 'tx_dlf_documents', 'tx_dlf_relations', 'tx_dlf_collections', 'AND tx_dlf_documents.pid=' . intval($this->id) . ' AND tx_dlf_collections.uid=' . intval($this->data['collection']) . ' AND tx_dlf_relations.ident=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('docs_colls', 'tx_dlf_relations') . tx_dlf_helper::whereClause('tx_dlf_documents') . tx_dlf_helper::whereClause('tx_dlf_collections'), 'tx_dlf_documents.uid', '', '');
                     } else {
                         // Get all documents.
                         $_result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_dlf_documents.title AS title,tx_dlf_documents.uid AS uid', 'tx_dlf_documents', 'tx_dlf_documents.pid=' . intval($this->id) . tx_dlf_helper::whereClause('tx_dlf_documents'), '', '', '');
                     }
                     // Save them as a list object in user's session.
                     $elements = array();
                     while ($resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($_result)) {
                         $elements[] = array($resArray['uid'], $resArray['title']);
                     }
                     $this->list = t3lib_div::makeInstance('tx_dlf_list', $elements);
                     // Start index looping.
                     if (count($this->list) > 0) {
                         $this->indexLoop();
                     }
                 }
                 break;
             case 'indexLoop':
                 // Refresh user's session to prevent session timeout.
                 $GLOBALS['BE_USER']->fetchUserSession();
                 // Get document list from user's session.
                 $this->list = t3lib_div::makeInstance('tx_dlf_list');
                 // Continue index looping.
                 if (count($this->list) > 0 && isset($this->data['core'])) {
                     $this->indexLoop();
                 } else {
                     $_message = t3lib_div::makeInstance('t3lib_FlashMessage', tx_dlf_helper::getLL('flash.seeLog', TRUE), tx_dlf_helper::getLL('flash.done', TRUE), t3lib_FlashMessage::OK, TRUE);
                     t3lib_FlashMessageQueue::addMessage($_message);
                 }
                 break;
         }
         $this->markerArray['CONTENT'] .= t3lib_FlashMessageQueue::renderFlashMessages();
         switch ($this->MOD_SETTINGS['function']) {
             case 'indexFile':
                 $this->markerArray['CONTENT'] .= $this->getFileForm();
                 break;
             case 'reindexDoc':
                 $this->markerArray['CONTENT'] .= $this->getDocList();
                 break;
             case 'reindexDocs':
                 $this->markerArray['CONTENT'] .= $this->getCollList();
                 break;
         }
     } else {
         // TODO: Ändern!
         $this->markerArray['CONTENT'] .= 'You are not allowed to access this page or have not selected a page, yet.';
     }
     $this->printContent();
 }
Example #6
0
 /**
  * Returns a "create new record" image tag that is linked to the new record view.
  *
  * @param int $pid the page ID where the record should be stored, must be > 0
  *
  * @return string the HTML source code to return
  */
 public function getNewIcon($pid)
 {
     global $BACK_PATH, $LANG, $BE_USER;
     $result = '';
     $newRecordPid = $this->getNewRecordPid();
     $pid = $newRecordPid > 0 ? $newRecordPid : $pid;
     $pageData = $this->page->getPageData();
     if ($BE_USER->check('tables_modify', $this->tableName) && $this->doesUserHaveAccess($pid) && $pageData['doktype'] == self::SYSFOLDER_TYPE) {
         $params = '&edit[' . $this->tableName . '][';
         if ($pageData['uid'] == $pid) {
             $params .= $pageData['uid'];
             $storageLabel = sprintf($LANG->getLL('label_create_record_in_current_folder'), $pageData['title'], $pageData['uid']);
         } else {
             $storagePageData = t3lib_befunc::readPageAccess($pid, '');
             $params .= $pid;
             $storageLabel = sprintf($LANG->getLL('label_create_record_in_foreign_folder'), $storagePageData['title'], $pid);
         }
         $params .= ']=new';
         $editOnClick = $this->editNewUrl($params, $BACK_PATH);
         $langNew = $LANG->getLL('newRecordGeneral');
         $result = TAB . TAB . '<div id="typo3-newRecordLink">' . LF . TAB . TAB . TAB . '<a href="' . htmlspecialchars($editOnClick) . '">' . LF . TAB . TAB . TAB . TAB . '<img' . t3lib_iconWorks::skinImg($BACK_PATH, 'gfx/new_record.gif', 'width="7" height="4"') . ' title="' . $langNew . '" alt="" />' . LF . TAB . TAB . TAB . TAB . $langNew . LF . TAB . TAB . TAB . '</a>' . LF . TAB . TAB . '</div>' . LF;
         /** @var t3lib_FlashMessage $message */
         $message = t3lib_div::makeInstance('t3lib_FlashMessage', $storageLabel, '', t3lib_FlashMessage::INFO);
         $this->addFlashMessage($message);
         if (class_exists('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService', TRUE)) {
             /** @var \TYPO3\CMS\Core\Messaging\FlashMessageService $flashMessageService */
             $flashMessageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService');
             /** @var \TYPO3\CMS\Core\Messaging\FlashMessageQueue $defaultFlashMessageQueue */
             $defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
             $renderedFlashMessages = $defaultFlashMessageQueue->renderFlashMessages();
         } else {
             $renderedFlashMessages = t3lib_FlashMessageQueue::renderFlashMessages();
         }
         $result .= '<div id="eventsList-clear"></div>' . $renderedFlashMessages;
     }
     return $result;
 }
Example #7
0
 /**
  * Main function of the module
  *
  * @access	public
  *
  * @return	void
  */
 public function main()
 {
     // Is the user allowed to access this page?
     $access = is_array($this->pageInfo) && $GLOBALS['BE_USER']->isAdmin();
     if ($this->id && $access) {
         // Check if page is sysfolder.
         if ($this->pageInfo['doktype'] != 254) {
             $_message = t3lib_div::makeInstance('t3lib_FlashMessage', tx_dlf_helper::getLL('flash.wrongPageTypeMsg'), tx_dlf_helper::getLL('flash.wrongPageType', TRUE), t3lib_FlashMessage::ERROR, FALSE);
             t3lib_FlashMessageQueue::addMessage($_message);
             $this->markerArray['CONTENT'] .= t3lib_FlashMessageQueue::renderFlashMessages();
             $this->printContent();
             return;
         }
         // Should we do something?
         if (!empty($this->CMD)) {
             // Sanitize input...
             $_method = 'cmd' . ucfirst($this->CMD);
             // ...and unset to prevent infinite looping.
             unset($this->CMD);
             if (method_exists($this, $_method)) {
                 $this->{$_method}();
             }
         }
         // Check for existing structure configuration.
         $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'tx_dlf_structures', 'pid=' . intval($this->id) . tx_dlf_helper::whereClause('tx_dlf_structures'));
         if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
             // Fine.
             $_message = t3lib_div::makeInstance('t3lib_FlashMessage', tx_dlf_helper::getLL('flash.structureOkayMsg'), tx_dlf_helper::getLL('flash.structureOkay', TRUE), t3lib_FlashMessage::OK, FALSE);
         } else {
             // Configuration missing.
             $_url = t3lib_div::locationHeaderUrl(t3lib_div::linkThisScript(array('id' => $this->id, 'CMD' => 'addStructure')));
             $_message = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf(tx_dlf_helper::getLL('flash.structureNotOkayMsg'), $_url), tx_dlf_helper::getLL('flash.structureNotOkay', TRUE), t3lib_FlashMessage::ERROR, FALSE);
         }
         t3lib_FlashMessageQueue::addMessage($_message);
         // Check for existing metadata configuration.
         $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'tx_dlf_metadata', 'pid=' . intval($this->id) . tx_dlf_helper::whereClause('tx_dlf_metadata'));
         if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
             // Fine.
             $_message = t3lib_div::makeInstance('t3lib_FlashMessage', tx_dlf_helper::getLL('flash.metadataOkayMsg'), tx_dlf_helper::getLL('flash.metadataOkay', TRUE), t3lib_FlashMessage::OK, FALSE);
         } else {
             // Configuration missing.
             $_url = t3lib_div::locationHeaderUrl(t3lib_div::linkThisScript(array('id' => $this->id, 'CMD' => 'addMetadata')));
             $_message = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf(tx_dlf_helper::getLL('flash.metadataNotOkayMsg'), $_url), tx_dlf_helper::getLL('flash.metadataNotOkay', TRUE), t3lib_FlashMessage::ERROR, FALSE);
         }
         t3lib_FlashMessageQueue::addMessage($_message);
         // Check the access conditions for the command line indexer's user.
         $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,db_mountpoints', 'be_groups', 'title=' . $GLOBALS['TYPO3_DB']->fullQuoteStr('_cli_dlf', 'be_groups') . ' AND ' . $GLOBALS['TCA']['be_groups']['ctrl']['enablecolumns']['disabled'] . '=0' . t3lib_BEfunc::deleteClause('be_groups'));
         if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
             $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
             if (t3lib_div::inList($resArray['db_mountpoints'], $this->id)) {
                 // Fine.
                 $_message = t3lib_div::makeInstance('t3lib_FlashMessage', tx_dlf_helper::getLL('flash.usergroupOkayMsg'), tx_dlf_helper::getLL('flash.usergroupOkay', TRUE), t3lib_FlashMessage::OK, FALSE);
             } else {
                 // Configuration missing.
                 $_url = t3lib_div::locationHeaderUrl(t3lib_div::linkThisScript(array('id' => $this->id, 'CMD' => 'addAccessRights')));
                 $_message = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf(tx_dlf_helper::getLL('flash.usergroupNotOkayMsg'), $_url), tx_dlf_helper::getLL('flash.usergroupNotOkay', TRUE), t3lib_FlashMessage::ERROR, FALSE);
             }
         } else {
             // Usergoup missing.
             $_message = t3lib_div::makeInstance('t3lib_FlashMessage', tx_dlf_helper::getLL('flash.usergroupMissingMsg'), tx_dlf_helper::getLL('flash.usergroupMissing', TRUE), t3lib_FlashMessage::ERROR, FALSE);
         }
         t3lib_FlashMessageQueue::addMessage($_message);
         // Check for existing Solr core.
         $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid,pid', 'tx_dlf_solrcores', 'pid IN (' . intval($this->id) . ',0)' . tx_dlf_helper::whereClause('tx_dlf_solrcores'));
         if ($GLOBALS['TYPO3_DB']->sql_num_rows($result)) {
             $resArray = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result);
             if ($resArray['pid']) {
                 // Fine.
                 $_message = t3lib_div::makeInstance('t3lib_FlashMessage', tx_dlf_helper::getLL('flash.solrcoreOkayMsg'), tx_dlf_helper::getLL('flash.solrcoreOkay', TRUE), t3lib_FlashMessage::OK, FALSE);
             } else {
                 // Default core available, but this is deprecated.
                 $_url = t3lib_div::locationHeaderUrl(t3lib_div::linkThisScript(array('id' => $this->id, 'CMD' => 'addSolrcore')));
                 $_message = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf(tx_dlf_helper::getLL('flash.solrcoreDeprecatedMsg'), $_url), tx_dlf_helper::getLL('flash.solrcoreDeprecatedOkay', TRUE), t3lib_FlashMessage::NOTICE, FALSE);
             }
         } else {
             // Solr core missing.
             $_url = t3lib_div::locationHeaderUrl(t3lib_div::linkThisScript(array('id' => $this->id, 'CMD' => 'addSolrcore')));
             $_message = t3lib_div::makeInstance('t3lib_FlashMessage', sprintf(tx_dlf_helper::getLL('flash.solrcoreMissingMsg'), $_url), tx_dlf_helper::getLL('flash.solrcoreMissing', TRUE), t3lib_FlashMessage::WARNING, FALSE);
         }
         t3lib_FlashMessageQueue::addMessage($_message);
         $this->markerArray['CONTENT'] .= t3lib_FlashMessageQueue::renderFlashMessages();
     } else {
         // TODO: Ändern!
         $this->markerArray['CONTENT'] .= 'You are not allowed to access this page or have not selected a page, yet.';
     }
     $this->printContent();
 }