00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 if (!defined('TYPO3_MODE'))
00026 die('Access denied.');
00027
00028 if (!class_exists('tx_date2cal_extTables'))
00029 {
00030
00031 require_once(t3lib_extMgm::extPath('date2cal') . 'src/class.tx_date2cal_shared.php');
00032
00038 class tx_date2cal_extTables
00039 {
00041 var $extConf = array();
00042
00044 var $cache = '';
00045
00047 var $tcaTables = array();
00048
00056 function tx_date2cal_extTables()
00057 {
00058
00059 $this->extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['date2cal']);
00060 $this->extConf['extCache'] = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extCache'];
00061
00062
00063 if ($this->extConf['datetime'])
00064 $this->tx_date2cal_toDatetime();
00065
00066
00067 $this->tx_date2cal_setWizard();
00068
00069
00070 if ($this->extConf['extCache'] && $this->extConf['doCache'])
00071 $this->tx_date2cal_writeCacheFile();
00072 }
00073
00079 function tx_date2cal_writeCacheFile() {
00080 $tca = '';
00081 foreach($this->tcaTables as $tcaTable)
00082 $tca .= 't3lib_div::loadTCA(\'' . $tcaTable . '\');' . "\n";
00083
00084 $this->cache = "<?php\n" . $tca . $this->cache . "?>\n";
00085 t3lib_div::writeFile(PATH_site . 'typo3temp/date2cal_cache.php',
00086 html_entity_decode($this->cache));
00087 }
00088
00094 function tx_date2cal_setWizard()
00095 {
00096
00097 foreach($GLOBALS['TCA'] as $tcaTable => $tConf)
00098 {
00099 $changed = false;
00100 t3lib_div::loadTCA($tcaTable);
00101
00102
00103 foreach($GLOBALS['TCA'][$tcaTable]['columns'] as $field => $fConf)
00104 {
00105
00106 $type = tx_date2cal_shared::isDateOrDateTime($fConf['config']);
00107 if ($type === false)
00108 continue;
00109
00110
00111 tx_date2cal_shared::addWizard($GLOBALS['TCA'][$tcaTable]['columns'][$field], $type);
00112 $changed = true;
00113
00114
00115 $this->cache .=
00116 '$TCA[\'' . $tcaTable . '\'][\'columns\'][\'' . $field . '\']' .
00117 '[\'config\'][\'wizards\'][\'calendar\'][\'type\'] = \'userFunc\';
00118 $TCA[\'' . $tcaTable . '\'][\'columns\'][\'' . $field . '\']' .
00119 '[\'config\'][\'wizards\'][\'calendar\'][\'userFunc\'] = ' .
00120 '\'EXT:date2cal/src/class.tx_date2cal_wizard.php:tx_date2cal_wizard->renderWizard\';
00121 $TCA[\'' . $tcaTable . '\'][\'columns\'][\'' . $field . '\']' .
00122 '[\'config\'][\'wizards\'][\'calendar\'][\'evalValue\'] = ' .
00123 '\'' . $type . '\';' . "\n";
00124 }
00125
00126 if ($changed)
00127 $this->tcaTables[] = $tcaTable;
00128 }
00129 }
00130
00137 function tx_date2cal_toDatetime()
00138 {
00139 t3lib_div::loadTCA('tt_content');
00140 $GLOBALS['TCA']['tt_content']['columns']['starttime']['config']['eval'] = 'datetime';
00141 $GLOBALS['TCA']['tt_content']['columns']['starttime']['config']['size'] = 12;
00142 $GLOBALS['TCA']['tt_content']['columns']['endtime']['config']['eval'] = 'datetime';
00143 $GLOBALS['TCA']['tt_content']['columns']['endtime']['config']['size'] = 12;
00144
00145 t3lib_div::loadTCA('pages');
00146 $GLOBALS['TCA']['pages']['columns']['starttime']['config']['eval'] = 'datetime';
00147 $GLOBALS['TCA']['pages']['columns']['starttime']['config']['size'] = 12;
00148 $GLOBALS['TCA']['pages']['columns']['endtime']['config']['eval'] = 'datetime';
00149 $GLOBALS['TCA']['pages']['columns']['endtime']['config']['size'] = 12;
00150
00151 $this->cache =
00152 '$TCA[\'tt_content\'][\'columns\'][\'starttime\'][\'config\'][\'eval\'] = \'datetime\';
00153 $TCA[\'tt_content\'][\'columns\'][\'starttime\'][\'config\'][\'size\'] = 12;
00154 $TCA[\'tt_content\'][\'columns\'][\'endtime\'][\'config\'][\'eval\'] = \'datetime\';
00155 $TCA[\'tt_content\'][\'columns\'][\'endtime\'][\'config\'][\'size\'] = 12;
00156 $TCA[\'pages\'][\'columns\'][\'starttime\'][\'config\'][\'eval\'] = \'datetime\';
00157 $TCA[\'pages\'][\'columns\'][\'starttime\'][\'config\'][\'size\'] = 12;
00158 $TCA[\'pages\'][\'columns\'][\'endtime\'][\'config\'][\'eval\'] = \'datetime\';
00159 $TCA[\'pages\'][\'columns\'][\'endtime\'][\'config\'][\'size\'] = 12;' . "\n";
00160 }
00161 }
00162
00163
00164 $call = true;
00165 if ($TYPO3_LOADED_EXT['_CACHEFILE'] != '' &&
00166 is_file(PATH_site . 'typo3temp/date2cal_cache.php')) {
00167 $t1 = filemtime(PATH_typo3conf . $TYPO3_LOADED_EXT['_CACHEFILE'] . '_ext_tables.php');
00168 $t2 = @filemtime(PATH_site . 'typo3temp/date2cal_cache.php');
00169 if (($t2 + 30) > $t1)
00170 $call = false;
00171 }
00172
00173
00174 if ($call) {
00175 $date2cal = new tx_date2cal_extTables();
00176 unset($date2cal);
00177 } else {
00178 include_once(PATH_site . 'typo3temp/date2cal_cache.php');
00179 }
00180
00181 }
00182 ?>