* 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. * * 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! ***************************************************************/ /*************************************************************** * Because I dont want to redefine the wheel again, some ideas * and code snippets are taken from the seminar manager extension * tx_seminars ***************************************************************/ /** * Class 'tx_wseevents_timeslotslist' for the 'wse_events' extension. * * @package TYPO3 * @subpackage wse_events * @author Michael Oehlhof */ class tx_wseevents_timeslotslist extends tx_wseevents_backendlist{ /** * The constructor. Calls the constructor of the parent class and sets * $this->tableName. * * @param object the current back-end page object * @return void ... */ function tx_wseevents_timeslotslist(&$page) { parent::tx_wseevents_backendlist($page); $this->tableName = $this->tableTimeslots; # $this->page = $page; } /** * Generates and prints out a form for generating many time slot entries in one action. * * @return string the HTML source code of the form * @access public */ function showCreateForm() { global $BACK_PATH, $TCA, $LANG, $BE_USER; $content = $LANG->getLL('showCreateForm') . '
'; // Show name of event $eventid = t3lib_div::_GET('event'); $event = tx_wseevents_events::getEventInfo($eventid); $content .= TAB . '
' . $LANG->getLL('event') . ' ' . $event['name'] . '

' . LF; $defslotlen = $event['defslotcount']; $slotlist = tx_wseevents_events::getEventSlotList($eventid); $rooms = tx_wseevents_events::getEventRooms($eventid); $daycount = $event['length']; $roomcount = count($rooms); $slotsize = $defslotlen * $event['slotsize']; // Description for the columns, table header $content .= TAB . ''; $secofday = 60*60*24; for ( $d = 1; $d <= $daycount; $d++ ) { $thisday = $event['begin']+($d-1)*$secofday; $dayname[$d] = strftime('%Y-%m-%d', $thisday); $weekdays[$d] = strftime('%A', $thisday); $content .= ''; } $content .= '' . LF; $content .= TAB . ''; for ( $d = 1; $d <= $daycount; $d++ ) { foreach ( array_keys($rooms) as $roomid ) { $content .= ''; } } $content .= '' . LF; // Input table $idx = 1; $x = 1; while ($idx < count($slotlist)) { // Input field for beginning of time slot $content .= TAB . ''; // Input field for length of time slot $content .= ''; // Selectors for all rooms for all days for ( $d = 1; $d <= $daycount; $d++ ) { // $content .= ''; foreach ( array_keys($rooms) as $roomid ) { $checked = ''; if (($roomid==0) and ($slotsize != $event['slotsize'])) { $checked = ' checked="checked"'; } if (($roomid>0) and ($slotsize == $event['slotsize'])) { $checked = ' checked="checked"'; } $content .= ''; } } // End of input forone time slot $content .= '' . LF; // Alternate the time slot length between minimum and default time slot size if (($x % 2) == 0) { $idx++; $slotsize = $defslotlen * $event['slotsize']; } else { $idx += $defslotlen; $slotsize = $event['slotsize']; } $x++; } // for ($x = 1; $x < 15; $x++ ) { // $content .= TAB . '
' . LF; // } $content .= TAB . '
' . $LANG->getLL('tscf_begin') . '' . $LANG->getLL('tscf_len') . '' . $weekdays[$d] . ' ' . $dayname[$d] . '
' . $rooms[$roomid] . '
Day ' . $d . '
' . LF; $content .= TAB . '

' . LF; //$content .= '
showCreateForm
'; // Finished creating the form return $content; } /** * Creates many time slot entries in one action. * * @return string the HTML source code of the result * @access public */ function createSlots() { global $BACK_PATH, $TCA, $LANG, $BE_USER; $content = $LANG->getLL('slotCreated') . '
' . LF; // Show name of event $eventid = t3lib_div::_GET('event'); $event = tx_wseevents_events::getEventInfo($eventid); $content .= TAB . '
' . $LANG->getLL('event') . ' ' . $event['name'] . '

' . LF; if (1==0) { $content .= '---POST begin ---' . '
' . LF; $content .= t3lib_utility_Debug::view_array(t3lib_div::_POST()) . '
' . LF; $content .= '---POST end ---' . '
' . LF; } $slotlist = tx_wseevents_events::getEventSlotList($eventid); $slotbegin = t3lib_div::_POST('slotbegin'); $slotlen = t3lib_div::_POST('slotlen'); $rooms = tx_wseevents_events::getEventRooms($eventid); $daycount = $event['length']; $secofday = 60*60*24; for ( $d = 1; $d <= $daycount; $d++ ) { $thisday = $event['begin']+($d-1)*$secofday; $dayname[$d] = strftime('%Y-%m-%d', $thisday); $weekdays[$d] = strftime('%A', $thisday); } $idx = 1; $comment = $LANG->getLL('slotCreatedComment'); while ($idx < count($slotlist)) { if (!empty($slotbegin[$idx])) { for ( $d = 1; $d <= $daycount; $d++ ) { foreach ( array_keys($rooms) as $roomid ) { $cbx = t3lib_div::_POST('room_' . $d . '_' . $roomid); if ($cbx[$idx]) { // Create timeslot record $insertArray = array ( 'event' => $eventid, 'pid' => $event['pid'], 'eventday' => $d, 'room' => $roomid, 'begin' => array_search($slotbegin[$idx], $slotlist), 'length' => intval($slotlen[$idx] / $event['slotsize']), 'name' => $weekdays[$d] . ' ' . $slotbegin[$idx] . ' ' . $rooms[$roomid], 'comment' => $comment, ); $query = $GLOBALS['TYPO3_DB']->exec_INSERTquery($this->tableName, $insertArray); $lastID = $GLOBALS['TYPO3_DB']->sql_insert_id(); // Print out info $content .= TAB . '[' . $lastID . '] ' . $slotbegin[$idx] . ', ' . $slotlen[$idx] . ', ' . $weekdays[$d] . ' ' . $dayname[$d] . ', ' . $rooms[$roomid] . '
' . LF; } } } $content .= '
' . LF; } $idx += 1; } //$content .= '
createForm
'; // Finished creating the form return $content; } /** * Update the name of all time slot entries in one action. * * @return string the HTML source code of the result * @access public */ function updateSlots() { global $BACK_PATH, $TCA, $LANG, $BE_USER; $content = $LANG->getLL('slotUpdate') . '
' . LF; // Show name of event $eventid = t3lib_div::_GET('event'); $event = tx_wseevents_events::getEventInfo($eventid); // Show name of event $content .= LF . TAB . '
' . $LANG->getLL('event') . ' ' . $event['name'] . '
'; // Get list of all possible timeslots for the event $slots = tx_wseevents_events::getEventSlotList($event['uid']); // Get info about event $eventinfo = tx_wseevents_events::getEventInfo($event['uid']); // -------------------- Get list of rooms -------------------- // Initialize variables for the database query. $queryWhere = 'location=' . $event['location'] . ' AND ' . $TCA[$this->tableRooms]['ctrl']['languageField'] . '=0' . t3lib_BEfunc::versioningPlaceholderClause($this->tableRooms) . t3lib_BEfunc::deleteClause($this->tableRooms); $additionalTables = ''; $groupBy = ''; $orderBy = 'number'; $limit = ''; // Get list of all rooms for the location of the event $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( '*', $this->tableRooms, $queryWhere, $groupBy, $orderBy, $limit); // Initialize variables for the database query. $queryWhere = 'event=' . $event['uid'] . t3lib_BEfunc::deleteClause($this->tableName) . t3lib_BEfunc::versioningPlaceholderClause($this->tableName); $additionalTables = ''; $groupBy = ''; $orderBy = 'eventday,begin,room'; $limit = ''; // Get list of all used time slots $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( '*', $this->tableName, $queryWhere, $groupBy, $orderBy, $limit); if ($res) { $slotlist = tx_wseevents_events::getEventSlotList($eventid); $rooms = tx_wseevents_events::getEventRooms($event['uid']); $daycount = $event['length']; $secofday = 60*60*24; for ( $d = 1; $d <= $daycount; $d++ ) { $thisday = $event['begin']+($d-1)*$secofday; // $dayname[$d] = strftime('%Y-%m-%d', $thisday); $weekdays[$d] = strftime('%A', $thisday); } $found = false; while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $found = true; $uid = $row['uid']; $hidden = $row['hidden']; // Add the result row to the table array. $updateArray = array ( 'name' => $weekdays[$row['eventday']] . ' ' . $slotlist[$row['begin']] . ' ' . $rooms[$row['room']], ); // Print out info $newname = '[' . $uid . '] ' . $weekdays[$row['eventday']] . ' ' . $slotlist[$row['begin']] . ' ' . $rooms[$row['room']]; $content .= $newname . '
' . LF; $query = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($this->tableName, 'uid=' . $uid, $updateArray); } $GLOBALS['TYPO3_DB']->sql_free_result($res); $content .= LF; } // Finished creating the form return $content; } /** * Generates and prints out an time slot list. * * @return string the HTML source code of the event list * @access public */ function show() { global $BACK_PATH, $TCA, $LANG, $BE_USER; // Define initial comment $initcomment = LF . TAB . '' . LF; // Check for additonal parameters $action = t3lib_div::_GET('action'); if ($action=='slotCreateForm') { if (t3lib_div::_POST('_CREATE')) { return $initcomment . $this->createSlots(); } else { return $initcomment . $this->showCreateForm(); } } if ($action=='slotCreate') { return $initcomment . $this->createSlots(); } if ($action=='slotUpdate') { return $initcomment . $this->updateSlots(); } // Initialize the variable for the HTML source code. $content = $initcomment; // Set the table layout of the time slot list. $tableLayout = array( 'table' => array( TAB . '' . LF, TAB . '
' . LF ), array( 'tr' => array( TAB . TAB . '' . LF . TAB . TAB . TAB . '' . LF, TAB . TAB . TAB . '' . LF . TAB . TAB . '' . LF ), 'defCol' => array( TAB . TAB . TAB . TAB . '' . LF, TAB . TAB . TAB . TAB . '' . LF ) ), 'defRow' => array( 'tr' => array( TAB . TAB . '' . LF, TAB . TAB . '' . LF ), array( TAB . TAB . TAB . '' . LF, TAB . TAB . TAB . '' . LF ), array( TAB . TAB . TAB . '' . LF, TAB . TAB . TAB . '' . LF ), array( TAB . TAB . TAB . '' . LF, TAB . TAB . TAB . '' . LF ), 'defCol' => array( TAB . TAB . TAB . '' . LF, TAB . TAB . TAB . '' . LF ) ) ); // Fill the first row of the table array with the header. $tableheader = array( array( TAB . TAB . TAB . TAB . TAB . '' . $LANG->getLL('timeslots.name') . '' . LF, TAB . TAB . TAB . TAB . TAB . '' . $LANG->getLL('timeslots.eventday') . '' . LF, TAB . TAB . TAB . TAB . TAB . '' . $LANG->getLL('timeslots.room') . '' . LF, TAB . TAB . TAB . TAB . TAB . '' . $LANG->getLL('timeslots.begin') . '' . LF, TAB . TAB . TAB . TAB . TAB . '' . $LANG->getLL('timeslots.length') . '' . LF, TAB . TAB . TAB . TAB . TAB . '' . $LANG->getLL('timeslots.id') . '' . LF, '', ) ); // unserialize the configuration array $globalConfiguration = unserialize( $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['wse_events'] ); # Get date format for selected language if (!$conf[$index . '.']['fmtDate']){ $conf['strftime'] = '%d.%m.%Y'; } else { $conf['strftime'] = $conf[$index . '.']['fmtDate']; } // Get list of pid $this->selectedPids = $this->getRecursiveUidList($this->page->pageInfo['uid'],2); // Check if sub pages available and remove main page from list if ($this->selectedPids<>$this->page->pageInfo['uid']) { $this->selectedPids = t3lib_div::rmFromList($this->page->pageInfo['uid'],$this->selectedPids); } // Remove duplicate entries $this->selectedPids = t3lib_div::uniqueList($this->selectedPids); // Remove pages with common data $eventPids = $this->removeCommonPages($this->selectedPids); // If all in one page than use page id if (empty($eventPids)) { $eventPids = $this->page->pageInfo['uid']; } // Get page titles $this->selectedPidsTitle = $this->getPidTitleList($this->selectedPids); // Get the where clause $wherePid = 'pid IN (' . $GLOBALS['TYPO3_DB']->cleanIntList($this->selectedPids) . ')'; // Add icon for new record if (!empty($eventPids)) { $content .= $this->getNewIconList($eventPids,$this->selectedPidsTitle); } if (!isset($this->page->pageInfo['uid'])) { return; } // -------------------- Get list of events -------------------- // Initialize variables for the database query. $queryWhere = $wherePid . t3lib_BEfunc::deleteClause($this->tableEvents) . ' AND ' . $TCA[$this->tableEvents]['ctrl']['languageField'] . '=0' . t3lib_BEfunc::versioningPlaceholderClause($this->tableEvents); $additionalTables = ''; $groupBy = ''; $orderBy = 'name'; $limit = ''; // Get list of all events $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( '*', $this->tableEvents, $queryWhere, $groupBy, $orderBy, $limit); $events = array(); if ($res) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $event = array(); $event['uid'] = $row['uid']; $event['pid'] = $row['pid']; $event['name'] = $row['name']; $event['location'] = $row['location']; $events[] = $event; } $GLOBALS['TYPO3_DB']->sql_free_result($res); } // ToDo: Add box for event selection // Get list of time slots for an event foreach ($events as $event) { // Show name of event $content .= LF . TAB . '
' . $LANG->getLL('event') . ' ' . $event['name'] . ''; // $content .= ' ' . $this->getNewIcon($event['pid'],0) . '
'; // Get list of all possible timeslots for the event $slots = tx_wseevents_events::getEventSlotList($event['uid']); // Get info about event $eventinfo = tx_wseevents_events::getEventInfo($event['uid']); // -------------------- Get list of rooms -------------------- // Initialize variables for the database query. $queryWhere = $wherePid . t3lib_BEfunc::deleteClause($this->tableRooms) . ' AND location=' . $event['location'] . ' AND ' . $TCA[$this->tableRooms]['ctrl']['languageField'] . '=0' . t3lib_BEfunc::versioningPlaceholderClause($this->tableRooms); $additionalTables = ''; $groupBy = ''; $orderBy = 'number'; $limit = ''; // Get list of all rooms for the location of the event $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( '*', $this->tableRooms, $queryWhere, $groupBy, $orderBy, $limit); /* $rooms = array(); $rooms[0] = $LANG->getLL('timeslots.allrooms'); if ($res) { while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $rooms[$row['uid']] = $row['name']; } $GLOBALS['TYPO3_DB']->sql_free_result($res); } */ $rooms = tx_wseevents_events::getEventRooms($event['uid']); // Initialize variables for the database query. $queryWhere = $wherePid . ' AND event=' . $event['uid'] . t3lib_BEfunc::deleteClause($this->tableName) . t3lib_BEfunc::versioningPlaceholderClause($this->tableName); $additionalTables = ''; $groupBy = ''; $orderBy = 'eventday,begin,room'; $limit = ''; // Get list of all used time slots $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery( '*', $this->tableName, $queryWhere, $groupBy, $orderBy, $limit); // Clear output table $table = $tableheader; if ($res) { $found = false; while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { $found = true; $uid = $row['uid']; $hidden = $row['hidden']; // Add the result row to the table array. $table[] = array( TAB . TAB . TAB . TAB . t3lib_div::fixed_lgd_cs( $row['name'], $BE_USER->uc['titleLen'] ) . LF, TAB . TAB . TAB . TAB . $row['eventday'] . LF, TAB . TAB . TAB . TAB . $rooms[$row['room']] . LF, TAB . TAB . TAB . TAB . $slots[$row['begin']] . LF, TAB . TAB . TAB . TAB . $eventinfo['slotsize']*$row['length'] . LF, TAB . TAB . TAB . TAB . $row['uid'] . LF, TAB . TAB . TAB . TAB . $this->getEditIcon($uid) . LF . TAB . TAB . TAB . TAB . $this->getDeleteIcon($uid) . LF . TAB . TAB . TAB . TAB . $this->getHideUnhideIcon( $uid, $hidden ) . LF, ); } $GLOBALS['TYPO3_DB']->sql_free_result($res); $content .= LF; // Show no records message if (!$found) { $content .= TAB . '
' . $LANG->getLL('norecords') . '
' . LF; // Show button for creating many slots together $params = '&action=slotCreateForm&event=' . $event['uid']; $newOnClick = t3lib_div::getIndpEnv('REQUEST_URI') . $params; $langNew = $LANG->getLL('slotCreate'); $content .= TAB . '
' . LF; } // Show table with all defined time slots if ($found) { // Output the table array using the tableLayout array with the template // class. $content .= $this->page->doc->table($table, $tableLayout) . TAB . '
' . LF; // Show button for updating name of all slots together $params = '&action=slotUpdate&event=' . $event['uid']; $newOnClick = t3lib_div::getIndpEnv('REQUEST_URI') . $params; $langNew = $LANG->getLL('updateSlots'); $content .= TAB . '
' . LF; } } } return $content; } } if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/wse_events/mod1/class.tx_wseevents_timeslotslist.php']) { include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/wse_events/mod1/class.tx_wseevents_timeslotslist.php']); } ?>