Clearskys.net Booking manager plugin to function correctly.
Version: 1.1
Author: clearskys.net
Author URI: http://blog.clearskys.net
*/
/* Copyright 2007 clearskys.net Ltd (email : team@clearskys.net)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as published by
the Free Software Foundation .
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
define('WPCPLUGINPATH', (DIRECTORY_SEPARATOR != '/') ? str_replace(DIRECTORY_SEPARATOR, '/', dirname(__FILE__)) : dirname(__FILE__));
include_once('includes/csbooking.php');
class CSbookwidget
{
function isquerystring($url)
{
return stristr($url,'?');
}
function CSbookwidget()
{
// Add the installation and uninstallation hooks
$file = WPCPLUGINPATH . '/' . basename(__FILE__);
register_activation_hook($file, array(&$this, 'install'));
register_deactivation_hook($file, array(&$this, 'uninstall'));
add_action('plugins_loaded', array(&$this,'initcalendar'));
}
function install() {
}
function uninstall() {
}
function initcalendar() {
if (!function_exists('register_sidebar_widget')) {
return;
}
$csw = get_option('clearskys_calendar_widget_config');
$number = $csw['clearskys_calwidget']['number'];
if ( $number < 1 ) $number = 1;
if ( $number > 99 ) $number = 99;
for ($i = 1; $i <= 99; $i++) {
$name = array('Availability Calendar %s', 'widgets', $i);
//change next line
register_sidebar_widget($name, $i <= $number ? array(&$this,'showcalendar') : /* unregister */ '', $i);
register_widget_control($name, $i <= $number ? array(&$this,'setupcalendarcontrol') : /* unregister */ '',300,425, $i);
}
add_action('sidebar_admin_setup', array(&$this,'calendar_setup'));
add_action('sidebar_admin_page', array(&$this,'calendar_admin_page'));
//register_sidebar_widget('Availability Calendar', array('CSbookwidget','showcalendar'));
//register_widget_control('Availability Calendar', array('CSbookwidget','setupcalendar'),300,425);
}
function calendar_setup() {
$ocsw = $csw = get_option('clearskys_calendar_widget_config');
$number = $csw['clearskys_calwidget']['number'];
//$options = $newoptions = get_option('widget_text');
if ( isset($_POST['clearskys_calwidget_number_submit']) ) {
$number = (int) $_POST['clearskys_calwidget_number'];
if ( $number > 99 ) $number = 99;
if ( $number < 1 ) $number = 1;
$csw['clearskys_calwidget']['number'] = $number;
}
if ($ocsw != $csw ) {
update_option('clearskys_calendar_widget_config', $csw);
$this->initcalendar();
}
}
function calendar_admin_page() {
$csw = get_option('clearskys_calendar_widget_config');
$number = $csw['clearskys_calwidget']['number'];
?>
";
}
switch($arrayday) {
case 6:
// end of week so build week for this month
$week[$arrayday] = str_replace('{day}',$n,$dayhtml);
$month = $month + array("$m" => $week);
$m++;
$arrayday = 0;
break;
default:
// other days
$week[$arrayday++] = str_replace('{day}',$n,$dayhtml);
break;
}
}
// last week fill in the end blanks of the last row
if($arrayday <= 6 && $arrayday != 0) {
for($n = $arrayday; $n <= 6; $n++) {
$week[$n] = str_replace('{day}',' ','
{day}
');
}
// Add last week to the month
$month = $month + array("$m" => $week);
}
//Build the month table and return the html
setlocale(LC_ALL,$cs["clearskys_publiclocale"]);
$amonth="";
foreach($month as $week) {
$amonth .= "