TYPO3 API  SVNRelease
class.t3lib_tceforms_fe.php
Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003  *  Copyright notice
00004  *
00005  *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
00006  *  All rights reserved
00007  *
00008  *  This script is part of the TYPO3 project. The TYPO3 project is
00009  *  free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  The GNU General Public License can be found at
00015  *  http://www.gnu.org/copyleft/gpl.html.
00016  *  A copy is found in the textfile GPL.txt and important notices to the license
00017  *  from the author is found in LICENSE.txt distributed with these scripts.
00018  *
00019  *
00020  *  This script is distributed in the hope that it will be useful,
00021  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023  *  GNU General Public License for more details.
00024  *
00025  *  This copyright notice MUST APPEAR in all copies of the script!
00026  ***************************************************************/
00027 /**
00028  * [CLASS/FUNCTION INDEX of SCRIPT]
00029  *
00030  *
00031  *
00032  *   60: class t3lib_TCEforms_FE extends t3lib_TCEforms
00033  *   68:     public function wrapLabels($str)
00034  *   78:     public function printPalette(array $paletteArray)
00035  *  102:     public function setFancyDesign()
00036  *  131:     public function loadJavascriptLib($lib)
00037  *  146:     public function addStyleSheet($key, $href, $title='', $relation='stylesheet')
00038  *
00039  * TOTAL FUNCTIONS: 5
00040  * (This index is automatically created/updated by the extension "extdeveval")
00041  *
00042  */
00043 
00044 /**
00045  * Contains a frontend version of the TYPO3 Core Form generator - AKA "TCEforms"
00046  *
00047  * $Id: class.t3lib_tceforms_fe.php 10121 2011-01-18 20:15:30Z ohader $
00048  *
00049  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00050  */
00051 
00052 
00053 /**
00054  * Extension class for the rendering of TCEforms in the frontend
00055  *
00056  * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
00057  */
00058 class t3lib_TCEforms_FE extends t3lib_TCEforms {
00059 
00060     /**
00061      * Constructs this object.
00062      */
00063     public function __construct() {
00064         $this->initializeTemplateContainer();
00065         parent::__construct();
00066     }
00067 
00068     /**
00069      * Function for wrapping labels.
00070      *
00071      * @param   string      The string to wrap
00072      * @return  string
00073      */
00074     public function wrapLabels($str) {
00075         return '<font face="verdana" size="1" color="black">' . $str . '</font>';
00076     }
00077 
00078     /**
00079      * Prints the palette in the frontend editing (forms-on-page?)
00080      *
00081      * @param   array       The palette array to print
00082      * @return  string      HTML output
00083      */
00084     public function printPalette(array $paletteArray) {
00085         $out = '';
00086         $bgColor = ' bgcolor="#D6DAD0"';
00087         foreach ($paletteArray as $content) {
00088             $hRow[] = '<td' . $bgColor . '><font face="verdana" size="1">&nbsp;</font></td><td nowrap="nowrap"' . $bgColor . '><font color="#666666" face="verdana" size="1">' . $content['NAME'] . '</font></td>';
00089             $iRow[] = '<td valign="top">' .
00090                       '<img name="req_' . $content['TABLE'] . '_' . $content['ID'] . '_' . $content['FIELD'] . '" src="clear.gif" width="10" height="10" alt="" />' .
00091                       '<img name="cm_' . $content['TABLE'] . '_' . $content['ID'] . '_' . $content['FIELD'] . '" src="clear.gif" width="7" height="10" alt="" />' .
00092                       '</td><td nowrap="nowrap" valign="top">' . $content['ITEM'] . $content['HELP_ICON'] . '</td>';
00093         }
00094         $out = '<table border="0" cellpadding="0" cellspacing="0">
00095             <tr><td><img src="clear.gif" width="' . intval($this->paletteMargin) . '" height="1" alt="" /></td>' . implode('', $hRow) . '</tr>
00096             <tr><td></td>' . implode('', $iRow) . '</tr>
00097         </table>';
00098 
00099         return $out;
00100     }
00101 
00102     /**
00103      * Sets the fancy front-end design of the editor.
00104      * Frontend
00105      *
00106      * @return  void
00107      */
00108     public function setFancyDesign() {
00109         $this->fieldTemplate = '
00110     <tr>
00111         <td nowrap="nowrap" bgcolor="#F6F2E6">###FIELD_HELP_ICON###<font face="verdana" size="1" color="black"><strong>###FIELD_NAME###</strong></font>###FIELD_HELP_TEXT###</td>
00112     </tr>
00113     <tr>
00114         <td nowrap="nowrap" bgcolor="#ABBBB4"><img name="req_###FIELD_TABLE###_###FIELD_ID###_###FIELD_FIELD###" src="clear.gif" width="10" height="10" alt="" /><img name="cm_###FIELD_TABLE###_###FIELD_ID###_###FIELD_FIELD###" src="clear.gif" width="7" height="10" alt="" /><font face="verdana" size="1" color="black">###FIELD_ITEM###</font>###FIELD_PAL_LINK_ICON###</td>
00115     </tr>   ';
00116 
00117         $this->totalWrap = '<table border="0" cellpadding="1" cellspacing="0" bgcolor="black"><tr><td><table border="0" cellpadding="2" cellspacing="0">|</table></td></tr></table>';
00118 
00119         $this->palFieldTemplate = '
00120     <tr>
00121         <td nowrap="nowrap" bgcolor="#ABBBB4"><font face="verdana" size="1" color="black">###FIELD_PALETTE###</font></td>
00122     </tr>   ';
00123         $this->palFieldTemplateHeader = '
00124     <tr>
00125         <td nowrap="nowrap" bgcolor="#F6F2E6"><font face="verdana" size="1" color="black"><strong>###FIELD_HEADER###</strong></font></td>
00126     </tr>   ';
00127     }
00128 
00129     /**
00130      * Includes a javascript library that exists in the core /typo3/ directory. The
00131      * backpath is automatically applied.
00132      * This method adds the library to $GLOBALS['TSFE']->additionalHeaderData[$lib].
00133      *
00134      * @param   string      $lib: Library name. Call it with the full path like "contrib/prototype/prototype.js" to load it
00135      * @return  void
00136      */
00137     public function loadJavascriptLib($lib) {
00138         /** @var $pageRenderer t3lib_PageRenderer */
00139         $pageRenderer = $GLOBALS['TSFE']->getPageRenderer();
00140         $pageRenderer->addJsLibrary($lib, $this->prependBackPath($lib));
00141 
00142     }
00143 
00144     /**
00145      * Insert additional style sheet link
00146      *
00147      * @param   string      $key: some key identifying the style sheet
00148      * @param   string      $href: uri to the style sheet file
00149      * @param   string      $title: value for the title attribute of the link element
00150      * @return  string      $relation: value for the rel attribute of the link element
00151      * @return  void
00152      */
00153     public function addStyleSheet($key, $href, $title = '', $relation = 'stylesheet') {
00154         /** @var $pageRenderer t3lib_PageRenderer */
00155         $pageRenderer = $GLOBALS['TSFE']->getPageRenderer();
00156         $pageRenderer->addCssFile($this->prependBackPath($href), $relation, 'screen', $title);
00157     }
00158 
00159     /**
00160      * Initializes an anonymous template container.
00161      * The created container can be compared to alt_doc.php in backend-only disposal.
00162      *
00163      * @return  void
00164      */
00165     public function initializeTemplateContainer() {
00166         t3lib_div::requireOnce(PATH_typo3 . 'template.php');
00167         $GLOBALS['TBE_TEMPLATE'] = t3lib_div::makeInstance('frontendDoc');
00168         $GLOBALS['TBE_TEMPLATE']->getPageRenderer()->addInlineSetting(
00169             '', 'PATH_typo3', t3lib_div::dirname(t3lib_div::getIndpEnv('SCRIPT_NAME')) . '/' . TYPO3_mainDir
00170         );
00171 
00172         $GLOBALS['SOBE'] = new stdClass();
00173         $GLOBALS['SOBE']->doc = $GLOBALS['TBE_TEMPLATE'];
00174     }
00175 
00176     /**
00177      * Prepends backPath to given URL if it's not an absolute URL
00178      *
00179      * @param string $url
00180      * @return string
00181      */
00182     private function prependBackPath($url) {
00183         if (strpos($url, '://') !== FALSE || substr($url, 0, 1) === '/') {
00184             return $url;
00185         } else {
00186             return $this->backPath . $url;
00187         }
00188 
00189     }
00190 }
00191 
00192 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms_fe.php'])) {
00193     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tceforms_fe.php']);
00194 }
00195 
00196 ?>