src/class.tx_date2cal_wizard.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 2006 - 2008 Stefan Galinski (stefan.galinski@gmail.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 *
00017 *  This script is distributed in the hope that it will be useful,
00018 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 *  GNU General Public License for more details.
00021 *
00022 *  This copyright notice MUST APPEAR in all copies of the script!
00023 ***************************************************************/
00024 
00025 require_once('class.jscalendar.php');
00026 
00032 class tx_date2cal_wizard
00033 {
00035         var $extConfig = array();
00036 
00037         function prepareExtConfig()
00038         {
00039                 // unserialize configuration
00040                 $this->extConfig = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['date2cal']);
00041 
00042                 // set backpath
00043                 $this->extConfig['backPath'] = $GLOBALS['BACK_PATH'] . (TYPO3_MODE == 'BE' ? '../' : '');
00044 
00045                 // get calendar image
00046                 $this->extConfig['calImg'] = t3lib_div::getFileAbsFileName($this->extConfig['calImg']);
00047                 $this->extConfig['calImg'] = $this->extConfig['backPath'] .
00048                         substr($this->extConfig['calImg'], strlen(PATH_site));
00049 
00050                 // get help image
00051                 $this->extConfig['helpImg'] = t3lib_div::getFileAbsFileName($this->extConfig['helpImg']);
00052                 $this->extConfig['helpImg'] = $this->extConfig['backPath'] .
00053                         substr($this->extConfig['helpImg'], strlen(PATH_site));
00054 
00055                 // user/group settings
00056                 $userProps = t3lib_BEfunc::getModTSconfig($this->pageinfo['uid'], 'tx_date2cal');
00057                 if (!is_array($userProps))
00058                         $this->extConfig = array_merge($this->extConfig, $userProps['properties']);
00059         }
00060 
00066         function secOptionsOn() {
00067                 $GLOBALS['BE_USER']->pushModuleData('xMOD_alt_doc.php', array('showPalettes' => 1));
00068         }
00069 
00077         function renderWizard($params, &$pObj)
00078         {
00079                 // load extension configuration
00080                 $this->prepareExtConfig();
00081 
00082                 // enabling of secondary options
00083                 if ($this->extConfig['secOptionsAlwaysOn'])
00084                         $this->secOptionsOn();
00085 
00086                 // add id attributes
00087                 $inputId = 'data_' . $params['table'] . '_' . $params['uid'] . '_' . $params['field'];
00088                 $params['item'] = str_replace('<input type="checkbox"', '<input type="checkbox" ' .
00089                         'id="' . $inputId . '_cb"', $params['item']);
00090                 $params['item'] = str_replace('<input type="text"', '<input type="text" ' .
00091                         'id="' . $inputId . '_hr"', $params['item']);
00092 
00093                 // init jscalendar class
00094                 $JSCalendar = JSCalendar::getInstance();
00095 
00096                 // datetime format
00097                 $JSCalendar->setDateFormat(false);
00098                 if ($params['wConf']['evalValue'] == 'datetime')
00099                         $JSCalendar->setDateFormat(true);
00100 
00101                 // set options
00102                 $JSCalendar->setInputField($inputId);
00103                 $JSCalendar->setConfigOption('firstDay', $this->extConfig['firstDay'], true);
00104                 $JSCalendar->setNLP($this->extConfig['natLangParser']);
00105                 $JSCalendar->setCSS($this->extConfig['calendarCSS']);
00106                 $JSCalendar->setLanguage($this->extConfig['lang']);
00107 
00108                 // render calendar images
00109                 $params['item'] .= $JSCalendar->renderImages($this->extConfig['calImg'],
00110                         $this->extConfig['helpImg']);
00111 
00112                 // get initialisation code of the calendar
00113                 if (($jsCode = $JSCalendar->getMainJS()) == '')
00114                         return '';
00115 
00116                 // set initialisation code
00117                 $script = basename(PATH_thisScript);
00118                 if (TYPO3_MODE == 'FE') // frontend mode
00119                         $params['item'] = $jsCode . $params['item'];
00120                 elseif (t3lib_div::int_from_ver(TYPO3_version) >= 4000000 || $script == 'db_layout.php')
00121                         // common for typo3 4.x and quick edit mode
00122                         $GLOBALS['SOBE']->doc->JScode .= $jsCode;
00123                 elseif (is_object($GLOBALS['SOBE']->tceforms)) // common for typo3 3.x
00124                         $GLOBALS['SOBE']->tceforms->additionalCode_pre['date2cal'] = $jsCode;
00125                 else // palette (doesnt work with php4)
00126                         $pObj->additionalCode_pre['date2cal'] = $jsCode;
00127 
00128                 return '';
00129         }
00130 }
00131 
00132 ?>

Generated on Thu Mar 20 21:55:20 2008 for date2cal by  doxygen 1.5.3