Project

General

Profile

Bug #18470 » docheaderClass_engine.diff

Administrator Admin, 2008-03-18 11:10

View differences:

typo3/classes/class.docheader.php (revision 0)
<?php
/***************************************************************
* Copyright notice
*
* (c) 2008 Steffen Kamper <info@sk-typo3.de>
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
* A copy is found in the textfile GPL.txt and important notices to the license
* from the author is found in LICENSE.txt distributed with these scripts.
*
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
***************************************************************/
/**
* class to render the docheader in the backend
*
*
* @author Steffen Kamper <info@sk-typo3.de>
* @package TYPO3
* @subpackage core
*/
class TYPO3Docheader {
private $row1; //html for first row
private $row2; //html for second row
public $callingModule; //name of the calling module
public $htmlTemplate; //path for template file
public $buttons = array(); //array with button markers
/**
* constructor
*
* @return void
*/
public function __construct() {
}
/**
* renders the docheader
*
* @return string logo html code snippet to use in the backend
*/
public function render() {
// Adds hook for processing of extra buttons
if (is_array($GLOBALS['TYPO3_CONF_VARS']['template']['docheaderButtonsHook'])) {
foreach($GLOBALS['TYPO3_CONF_VARS']['template']['docheaderButtonsHook'] as $_classRef) {
$_procObj = & t3lib_div::getUserObj($_classRef);
$_procObj->docheaderProcessor($this);
}
}
$markers = array();
// Get the HTML template for the module
$moduleBody = t3lib_parsehtml::getSubpart($this->htmlTemplate, '###FULLDOC###');
$docHeaderSuppart = t3lib_parsehtml::getSubpart($this->htmlTemplate, '###DOCHEADER###');
// Fill buttons for left and right float
$floats = array('left', 'right');
foreach($floats as $key) {
// Get the template for each float
$buttonTemplate = t3lib_parsehtml::getSubpart($this->htmlTemplate, '###BUTTON_GROUPS_' . strtoupper($key) . '###');
// Fill the button markers in this float
$buttonTemplate = t3lib_parsehtml::substituteMarkerArray($buttonTemplate, $this->buttons, '###|###', true);
// getting the wrap for each group
$buttonWrap = t3lib_parsehtml::getSubpart($this->htmlTemplate, '###BUTTON_GROUP_WRAP###');
// looping through the groups (max 6) and remove the empty groups
for ($groupNumber = 1; $groupNumber < 6; $groupNumber++) {
$buttonMarker = '###BUTTON_GROUP' . $groupNumber . '###';
$buttonGroup = t3lib_parsehtml::getSubpart($buttonTemplate, $buttonMarker);
if (trim($buttonGroup)) {
if ($buttonWrap) {
$buttonGroup = t3lib_parsehtml::substituteMarker($buttonWrap, '###BUTTONS###', $buttonGroup);
}
$buttonTemplate = t3lib_parsehtml::substituteSubpart($buttonTemplate, $buttonMarker, trim($buttonGroup));
}
}
// replace the marker with the template and remove all line breaks (for IE compat)
$markers['BUTTONLIST_' . strtoupper($key)] = str_replace("\n", '', $buttonTemplate);
}
$docHeader['DOCHEADER'] = t3lib_parsehtml::substituteMarkerArray($docHeaderSuppart, $markers, '###|###');
return $docHeader;
}
}
if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/classes/class.docheader.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['typo3/classes/class.docheader.php']);
}
?>
typo3/stylesheet.css (working copy)
margin: 1px 0 0;
}
div#typo3-docheader div.pagepath {
div#typo3-docheader div.docheader-row2-left {
margin-left: 6px;
float: left;
}
div#typo3-docheader div.infooptions {
div#typo3-docheader div.docheader-row2-right {
margin-right: 6px;
float: right;
}
typo3/template.php (working copy)
if (!defined('TYPO3_MODE')) die("Can't include this file directly.");
require_once(PATH_t3lib.'class.t3lib_ajax.php');
require_once(PATH_typo3.'classes/class.docheader.php');
......
/**
* Deprecated fontwrap function. Is just transparent now.
*
......
var $postCode=''; // Additional 'page-end' code could be accommulated in this var. It will be outputted at the end of page before </body> and some other internal page-end code.
var $docType = ''; // Doc-type used in the header. Default is HTML 4. You can also set it to 'strict', 'xhtml_trans', or 'xhtml_frames'.
var $moduleTemplate = ''; // HTML template with markers for module
var $docHeader; // Docheader class
// Other vars you can change, but less frequently used:
var $scriptID=''; // Script ID.
var $bodyTagId=''; // Id which can be set for the body tag. Default value is based on script ID
......
// Background image
if ($TBE_STYLES['background']) $this->backGroundImage = $TBE_STYLES['background'];
// instance docheader class
$this->docHeader = t3lib_div::makeInstance('TYPO3Docheader');
}
......
if ($GLOBALS['TBE_STYLES']['htmlTemplates'][$filename]) {
$filename = $GLOBALS['TBE_STYLES']['htmlTemplates'][$filename];
}
return ($filename ? t3lib_div::getURL($this->backPath . $filename) : '');
$htmlTemplate = ($filename ? t3lib_div::getURL($this->backPath . $filename) : '');
$this->docHeader->htmlTemplate = $htmlTemplate;
return $htmlTemplate;
}
/**
......
$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);
......
}
/**
* Fill the button lists with the defined HTML
*
* @param array HTML for all buttons
* @return array Containing HTML for both buttonlists
*/
private function getDocHeaderButtons($buttons) {
$markers = array();
// Fill buttons for left and right float
$floats = array('left', 'right');
foreach($floats as $key) {
// Get the template for each float
$buttonTemplate = t3lib_parsehtml::getSubpart($this->moduleTemplate, '###BUTTON_GROUPS_' . strtoupper($key) . '###');
// Fill the button markers in this float
$buttonTemplate = t3lib_parsehtml::substituteMarkerArray($buttonTemplate, $buttons, '###|###', true);
// getting the wrap for each group
$buttonWrap = t3lib_parsehtml::getSubpart($this->moduleTemplate, '###BUTTON_GROUP_WRAP###');
// looping through the groups (max 6) and remove the empty groups
for ($groupNumber = 1; $groupNumber < 6; $groupNumber++) {
$buttonMarker = '###BUTTON_GROUP' . $groupNumber . '###';
$buttonGroup = t3lib_parsehtml::getSubpart($buttonTemplate, $buttonMarker);
if (trim($buttonGroup)) {
if ($buttonWrap) {
$buttonGroup = t3lib_parsehtml::substituteMarker($buttonWrap, '###BUTTONS###', $buttonGroup);
}
$buttonTemplate = t3lib_parsehtml::substituteSubpart($buttonTemplate, $buttonMarker, trim($buttonGroup));
}
}
// replace the marker with the template and remove all line breaks (for IE compat)
$markers['BUTTONLIST_' . strtoupper($key)] = str_replace("\n", '', $buttonTemplate);
}
return $markers;
}
/**
* Generate the page path for docheader
*
* @param array Current page
(1-1/3)